12749 Commits

Author SHA1 Message Date
ibaker
0b09ac5bb0 Migrate usages of Timeline#getPeriodPosition to getPeriodPositionUs
#minor-release

PiperOrigin-RevId: 414671861
2021-12-07 17:37:45 +00:00
ibaker
97294f0693 Retry creating a MediaCodec instance in MediaCodecRenderer
It's been observed that some devices fail when releasing a secure codec
attached to a surface and immediately trying to create a new codec
(secure or insecure) attached to the same surface. This change catches
all exceptions thrown during codec creation, sleeps for a short time,
and then retries the codec creation. This is observed to fix the problem
(we believe this is because it allows enough time for some background
part of the previous codec release operation to complete).

This change should have no effect on the control flow when codec
creation succeeds first time. It will introduce a slight delay when
creating the preferred codec fails (while we sleep and retry), which
will either delay propagating a permanent error or attempting to
initialize a fallback decoder. We can't avoid the extra delay to
instantiating the fallback decoder because we can't know whether we
expect the second attempt to create the preferred decoder to succeed or
fail. The benefit to always retrying the preferred decoder creation
(fixing playback failures) outweighs the unfortunate additional delay
to instantiating fallback decoders.

Issue: google/ExoPlayer#8696
#minor-release
PiperOrigin-RevId: 414671743
2021-12-07 17:37:45 +00:00
huangdarwin
07fdf0e794 GL: Document ambiguous parameter names in comments.
Also, made a few other refactoring changes for clarity. No functional
changes intended.

PiperOrigin-RevId: 414487729
2021-12-07 17:37:31 +00:00
kimvde
94caa8ad6c Fix re-encoding after flattening
The decoder is using the SVC NAL unit prefix data on some Samsung
devices.

PiperOrigin-RevId: 414457181
2021-12-07 17:37:31 +00:00
jaewan
6bceec3246 Remove setters for showing actions in Notification
PiperOrigin-RevId: 414441471
2021-12-07 17:37:31 +00:00
kimvde
5264da59b3 Various small improvements in Transformer
PiperOrigin-RevId: 414428415
2021-12-07 17:37:31 +00:00
ibaker
59d98b9a4e Add MediaItem.SubtitleConfiguration#id field
Issue: google/ExoPlayer#9673

#minor-release

PiperOrigin-RevId: 414413320
2021-12-07 17:37:31 +00:00
huangdarwin
1b0742f54a Transformer GL: Create demo UI for changing resolution.
Also, add 144p as an acceptable output resolution, to allow for
a more obvious resolution difference when running the demo.

PiperOrigin-RevId: 414406664
2021-12-07 17:37:31 +00:00
christosts
e4e0c7bce5 Add AudioAttributes.spatializationBehavior
The new field matches the platform's
AudioAttributes.getSpatializationBehavior() API added in Sv2. At the
moment, the platform API is called via reflection, until Sv2 is released
and the compile SDK target can be increased to 32.

PiperOrigin-RevId: 414406126
2021-12-07 17:37:31 +00:00
olly
e765f7a8eb Further media3 session cleanup
* Remove casting getInstance and getCallback methods and just
  use member variables that have the more specific types. I
  didn't manage to get rid of casting completely; there are
  still one-off casts during construction. We should look at
  removing those in the future, but it's not completely
  trivial due to the way the Impl classes back-reference
  their wrapping classes.
* Move all callback invocations inside the Impl classes for
  consistency, and properly encapsulate the callbacks there.
  Sticking with the "OnHandler" naming convention for these
  methods, but we should probably tweak that in a subsequent
  change.
* Encapsulate MediaItemFiller in MediaSessionImpl.
* Some misc cleanup (e.g., converting anonymous inner classes
  to lambdas where possible).

PiperOrigin-RevId: 414401978
2021-12-07 17:37:31 +00:00
olly
e59e15d29d Flatten Library and Session service impls
PiperOrigin-RevId: 414396999
2021-12-07 17:37:31 +00:00
ibaker
f1ab3cf195 Update androidx annotation-experimental version to 1.2-rc01
This version includes several bug fixes related to the `@RequiresOptIn`
annotation used for the `androidx.media3.util.UnstableApi` annotation
in this project.

PiperOrigin-RevId: 414384813
2021-12-07 17:37:31 +00:00
jaewan
21bbdb5871 Remove built-in support for stop() in Notification
PiperOrigin-RevId: 414321900
2021-12-07 17:37:31 +00:00
hschlueter
8bd5d8bcbe Fix condition for when to use the FrameEditor.
outputHeight is the actual output height while
transformation.outputHeight could be Format.NO_VALUE
causing the FrameEditor to be used more often than
necessary in the old version.

PiperOrigin-RevId: 414304251
2021-12-07 17:37:31 +00:00
olly
f2ad8ccd3c Shorten log tags to 23 char limit
When calling Android's Log class directly, there's a LongLogTag
lint check that detects tags over the 23 char limit, however it
cannot detect long log tags in ExoPlayer due to the way that we
log via our own Log class. This commit adds @Size annotations to
enforce the same rule.

PiperOrigin-RevId: 413976364
2021-12-07 17:37:31 +00:00
andrewlewis
aae9ebaa7e Apply MTK E-AC3 workaround before API 24
On the Sony Android TV device where this was originally reproducible on
Android L, on Android N there is an E-AC3 decoder listed which handles
the stream correctly. The workaround is harmless anyway but adding the
API version restriction means it will be obvious it can be removed once
we bump our min API to 24 or above in the future.

PiperOrigin-RevId: 413967443
2021-12-07 17:37:07 +00:00
olly
b9f0592702 Remove interfaces that don't seem to serve a purpose
PiperOrigin-RevId: 413966081
2021-12-07 17:37:07 +00:00
olly
f4989f5de1 Forward callback invocations to MediaLibrarySessionImpl
This is required for correct subscription notifications, as per the
referenced bug. It also just seems better to plumb things this way
in general, rather than re-implementing the functionality in the stub.

PiperOrigin-RevId: 413963824
2021-12-07 17:37:07 +00:00
olly
41a2f9a6b3 Simplify threading for media3 session callbacks
This change removes the requirement that callback implementations
need to be able to handle two specific callbacks being called on
two different threads.

PiperOrigin-RevId: 413958545
2021-12-07 17:37:07 +00:00
tonihei
546d9f592b Turn on HLS chunkless preparation by default.
Using chunkless preparation greatly improves start up time if the master
playlist declares CODECS for the renditions. Hence, we turn this on
by default as it benefits most well-defined HLS master playlists.

The only known reason why developers may want to turn this feature off is
when the renditions contain muxed closed-caption tracks that are not
declared in the master playlist. So this change also updates the documentation
and RELEASENOTES to point out this caveat.

PiperOrigin-RevId: 413950036
2021-12-07 17:37:07 +00:00
andrewlewis
fdc57d2d66 Make FrameEditorTest less flaky
Increase timeout for dequeueing a frame from the codec to reduce
flakiness. At a timeout of 2 seconds there was a 2/1000 flake rate and
at 3 seconds 0/1000. Set the timeout to 5 seconds to give plenty of
leeway.

PiperOrigin-RevId: 413946915
2021-12-07 17:36:48 +00:00
olly
3805237322 Upgrade Cast dependency for Android 12 compatibility
#minor-release
Issue: google/ExoPlayer#9528
PiperOrigin-RevId: 413887784
2021-12-07 16:46:40 +00:00
hschlueter
ef1788dcea Only use a FrameEditor if editing is needed.
When no editing is needed, the OpenGL steps can be skipped.

PiperOrigin-RevId: 413884305
2021-12-07 16:45:42 +00:00
olly
244777234b Refine HW/SW codec approximation for API level 28 and earlier
Hardware audio decoders aren't really a thing, particularly on older
devices. SOC vendors do sometimes provide their own software decoders
though. Hence we update the approximation to assume that audio
decoders on older devices are software.

PiperOrigin-RevId: 413757859
2021-12-07 16:44:25 +00:00
Ian Baker
e1eb30c8ba Merge pull request #9606 from ened:rtsp-socket-factory
PiperOrigin-RevId: 413751821
2021-12-07 16:43:17 +00:00
hschlueter
14b849aba8 Reduce conditional nesting.
PiperOrigin-RevId: 413682281
2021-12-07 16:42:18 +00:00
claincly
fbbedf32f9 Remove the check for dynamic payload type.
Issue: google/ExoPlayer#9744

We do not rely on the payload type to determine the sample MIME type, we depend
on the SDP message, so it's worthless checking the payload type.

After removing the line, a server can use payload type 35 (an unassigned
payload type) for H264; while normally H264 requires payload type >= 96).

PiperOrigin-RevId: 413658076
2021-12-07 16:41:22 +00:00
huangdarwin
58a8aceb97 Transformer GL: Apply transformation_matrix to vertex position.
Previously, transformation_matrix was incorrectly applied to
texture sampling coordinates, which led to transformations
seemingly moving in the opposite position, and an undesirable
GL_CLAMP_TO_EDGE behavior when sampling outside the edge of
the texture.

PiperOrigin-RevId: 413653360
2021-12-07 16:40:04 +00:00
tonihei
417c242625 Prohibit duplicate TrackGroups in TrackGroupArray
Allowing duplicate groups caused some other code working with the
array to use reference equality comparison. This is error-prone,
easily forgotten (e.g. when using the TrackGroups in a map) and
causes bugs when TrackGroups are serialized to disk or to another
process.

All TrackGroups created by ExoPlayer are already unique and custom
code creating TrackGroupArrays with identical groups can easily
distringuish them by adding an id to each group.

Issue: google/ExoPlayer#9718
PiperOrigin-RevId: 413617005
2021-12-02 11:56:42 +00:00
andrewlewis
e077edded5 Update javadoc to reflect removal of WebM container option
It seems fine to remove the documentation about the WebM case now we are only supporting unfragmented MP4, so that new users coming to this API aren't confused about how to set the container MIME type.

PiperOrigin-RevId: 413611472
2021-12-02 11:56:42 +00:00
tonihei
f1a5825d73 Add optional id to TrackGroup.
This allows to give TrackGroups an identifier. The underlying goal is
to provide a way to make otherwise identical TrackGroups
distinguishable.

Also set this id in all internal sources that may produce identical
TrackGroups in certain edge cases.

Issue: google/ExoPlayer#9718
PiperOrigin-RevId: 413430719
2021-12-02 11:56:42 +00:00
huangdarwin
73ed482094 Transformer GL: Create setTransformationMatrix().
Allows a transformation matrix to be input into Transformer,
to apply vertex transformations like cropping, rotation,
and other transformations built into android.graphics.Matrix.

Not building out into a VertexTransformation class yet, as
that class structure wouldn't make sense until we can modify
resolution, per TODOs.

PiperOrigin-RevId: 413384409
2021-12-02 11:56:42 +00:00
andrewlewis
a803604605 Increase transformer min API version to 21
This will remove the need to implement compat code handling very old API
versions where some symbols are not available, and it reduces the burden of
dealing with media framework issues around concurrent codec usage that are
worse on older API versions. Top apps that we've surveyed as potential users
for transformer library features are using API 21 or later.

PiperOrigin-RevId: 413341540
2021-12-02 11:56:42 +00:00
olly
6f63701307 Fix 1 ErrorProneStyle finding
PiperOrigin-RevId: 413188534
2021-12-02 11:55:55 +00:00
hschlueter
8105394ac2 Flip input buffer even if the end of stream is reached.
Sometimes the empty end of stream buffer has a non-zero
data limit. Calling flip first, resets the limit to the
position which is zero in these cases.

PiperOrigin-RevId: 413156455
2021-12-02 11:55:55 +00:00
andrewlewis
1b25e2f93d Add unit test for FrameEditor
The test extracts and decodes the first video frame in the test media, renders it to the frame editor's input surface and then processes data. It then reads back the output from the frame editor, converts it to a bitmap and then compares that with a 'golden' bitmap (which is just the same as the test media's first video frame).

PiperOrigin-RevId: 413131811
2021-12-02 11:55:55 +00:00
olly
b91db3f5e2 Add "3" into media3 version string
PiperOrigin-RevId: 413079384
2021-12-02 11:55:55 +00:00
ibaker
43328d7623 Rollback of f637bb3d40
*** Original commit ***

Remove usage of @ForOverride.

Fixes the gradle compilation failures.

Gradle dependencies need revising if we want to be using this, as
checkerframework is ahead of their latest version, such that we
can't compile.

***

PiperOrigin-RevId: 412901827
2021-12-02 11:55:55 +00:00
samrobinson
d55f9876ac Make use of try with-resources to auto close file.
PiperOrigin-RevId: 412901581
2021-12-02 11:55:55 +00:00
samrobinson
dd9d87549d Create and write the TransformationResult to on-device text file.
PiperOrigin-RevId: 412856100
2021-12-02 11:55:55 +00:00
tonihei
805d3b763d Update track selection to prefer content over technical preferences.
Currently we prefer technical preferences set in the Parameters over
content preferences implied by the media. It proably makes more
sense in the opposite order to avoid the situation where a
non-default track (e.g. commentary) is selected just because it
better matches some technical criteria.

Also add comments explaining the track selection logic stages.

PiperOrigin-RevId: 412840962
2021-12-02 11:55:55 +00:00
hschlueter
fb0768e0d2 Use audio passthrough if flattening is requested but not needed.
When the input is not a slow motion video, then flattening should do
nothing, so there is no need to re-encode audio.

PiperOrigin-RevId: 412443097
2021-12-02 11:55:55 +00:00
samrobinson
2ba7422da3 Move tests into a mh package.
PiperOrigin-RevId: 412438389
2021-12-02 11:55:44 +00:00
huangdarwin
60ce9ae345 Misc refactoring.
Use @VisibleForTesting and add some comments for GL code.

Refactoring change only. No functional changes intended

PiperOrigin-RevId: 412428196
2021-12-02 11:55:44 +00:00
kimvde
f9d3bedb0b Fix inconsistency with spec in H.265 SPS nal units parsing
Issue: google/ExoPlayer#9719

#minor-release

PiperOrigin-RevId: 412424558
2021-12-02 11:55:44 +00:00
bachinger
2a62a5ee30 Make setMediaItemFiller public in MediaSession.Builder
#minor-release
Issue: androidx/media#8
PiperOrigin-RevId: 412403132
2021-12-02 11:55:44 +00:00
huangdarwin
f0fcad16a9 GL: Remove redundant use() call.
This is already called in GlUtil.Program().

Tested by confirming that the demo-gl target still runs as expected.

Refactoring change only. No intended functional changes.

PiperOrigin-RevId: 412308564
2021-12-02 11:55:44 +00:00
tonihei
a7d7c7b73a Add preferredVideoRoleFlags to TrackSelectionParameters.
And also tweak existing role flag logic to strictly prefer perfect
matches over partial matches.

Caveat: Video role flags only supported for fixed track selections
(same issue as Issue: google/ExoPlayer#9519).

Issue: google/ExoPlayer#9402
PiperOrigin-RevId: 412292835
2021-12-02 11:55:44 +00:00
kimvde
a520e7f559 Miscellaneous small fixes in Transformer
PiperOrigin-RevId: 412286692
2021-12-02 11:55:44 +00:00
ibaker
a4c12ca97d Parse DASH forced-subtitle role value
Issue: google/ExoPlayer#9727

#minor-release

PiperOrigin-RevId: 412266397
2021-12-02 11:55:44 +00:00