1300 Commits

Author SHA1 Message Date
tonihei
8bd6e5d10a Suppress warning about unused return value
The return value is intentionally unused because the check
is only done to see if the reflection operation succeeds.

PiperOrigin-RevId: 642579373
2024-06-12 05:01:23 -07:00
tonihei
27e6395dbc Make ImageOutput clearable
It's currently not possible to remove a previously set image output
on ExoPlayer, although the underlying renderer already supports
receiving null to clear the output. Marking the parameter as
nullable allows apps to clear it as well.

PiperOrigin-RevId: 642569081
2024-06-12 04:03:32 -07:00
kimvde
5a24f40a66 Pass clock to release control from sink provider
In order to do that, make the VideoSink nullable in MCVR.

We want to avoid calling VideoFrameReleaseControl.setClock directly
from MCVR when the sink is enabled. The goal is to handle all the
communication with the release control from the sink/sink provider.

PiperOrigin-RevId: 642542063
2024-06-12 01:51:27 -07:00
ibaker
b145a96c79 Clean up unecessary zero-arg toBundle() methods
These are no longer needed now that the `Bundleable` interface has been
removed. Public methods are deprecated, package-private ones are
removed. Callers are migrated in both cases (except where tests
explicitly exist for the deprecated method).

PiperOrigin-RevId: 642294451
2024-06-11 09:28:23 -07:00
ibaker
f554c12099 Remove Bundleable type & Bundleable.Creator<Foo> CREATOR fields
This interface is not used in the library. Callers can use the
`Bundle toBundle()` and `static Foo fromBundle(Bundle)` methods
defined directly on each type instead.

PiperOrigin-RevId: 642271609
2024-06-11 08:05:32 -07:00
ibaker
253fcb1fd1 Clarify docs on ExoPlayer.setVideoEffects() re calling prepare()
The previous wording suggested that `setVideoEffects()` may **only** be
called before `prepare()`, i.e. the effect cannot be changed during
playback. The intent is instead that `setVideoEffects()` must be called
once before playback in order to configure the effects pipeline, but
the effect can then be changed during playback by further calls to
`setVideoEffects()`.

Issue: androidx/media#1393
PiperOrigin-RevId: 641853629
2024-06-10 04:12:50 -07:00
kimvde
ec49d19384 Call VideoFrameReleaseControl.setPlaybackSpeed from sink when enabled
Do not call VideoFrameReleaseControl.setPlaybackSpeed directly from
MCVR when the video sink is enabled.

PiperOrigin-RevId: 641840894
2024-06-10 03:15:05 -07:00
kimvde
2c71150f2b Set VideoSink listener when enabling MCVR
Before, the listener was set in onReadyToInitializeCodec, which means
that it was reset every time a new codec was used.

We need to set the listener every time MCVR is enabled (not only the
first time), because it might have been set by another renderer.

PiperOrigin-RevId: 641825717
2024-06-10 02:01:00 -07:00
claincly
38a7229d96 Unify timestamp handling
Before this change, the timestamps output from composition playback is offset
with the renderer offset. After this change, the offset is removed and the
timestamp behaviour converges with Transformer, that is, the timestamps of
video/images frames will follow that of the composition. For example, with a
composition of two 10-s items, clipping the first with 2s at the start, the
timestamp of the first frame in the second item, will be 8s.

PiperOrigin-RevId: 641121358
2024-06-06 21:36:15 -07:00
tonihei
f238db8208 Exit early if buffer becomes invalid
When the frame release control invalidates a buffer and returns that
the buffer must be ignored, we need to exit early before performing
additional checks that may result in method calls using the invalid
buffer.

PiperOrigin-RevId: 640555688
2024-06-05 09:48:30 -07:00
kimvde
f54380f9d8 Remove direct usages of release control when video sink is used
Usages removed in this CL are:
- onProcessedStreamChange, which was already called from the VideoSink
  (via VideoFrameRenderControl)
- setOutputSurface, which was also already called from the VideoSink
- setFrameRate, which this CL now sets in the VideoSink

PiperOrigin-RevId: 640530903
2024-06-05 08:19:17 -07:00
kimvde
9716985272 Move renderer state methods from release control to sink
PiperOrigin-RevId: 640515298
2024-06-05 07:16:36 -07:00
kimvde
d5e9f3b224 MCVR: use shouldUseVideoSink where possible
Before this CL, we were checking whether the video sink was initialized
to determine whether it should be used. In the meantime,
shouldUseVideoSink has been introduced. Use this boolean to check
whether to use the video sink as it's a clearer signal.

PiperOrigin-RevId: 640499147
2024-06-05 06:05:03 -07:00
kimvde
3334f0afee Decide whether to use the VideoSink when enabling renderer
This will simplify moving the release control inside the video sink

PiperOrigin-RevId: 640416128
2024-06-04 23:59:10 -07:00
jbibik
35b8ab411d Add isReleased() to the Exoplayer
This avoids having to add AnalyticsListener and catching the `onPlayerReleased` callback.

The `Exoplayer.release()` method is blocking and one can be sure that the player is released if the call returned. However, the method is useful for UI testing and asserting that the player is released after a certain UI action, e.g. closing the activity or detaching a window.

PiperOrigin-RevId: 640114416
2024-06-04 05:11:15 -07:00
rohks
387153fcf2 Fix CMCD data assignment for init segment
The CMCD data was incorrectly added to the `dataSpec` of the media segment instead of the init segment.

Also relaxed the condition for playbackRate to be C.RATE_UNSET when creating an instance of CmcdData.Factory as there was nothing enforcing this check.

#minor-release

PiperOrigin-RevId: 639046080
2024-05-31 08:42:53 -07:00
michaelkatz
ac34798344 Schedule doSomeWork when MediaCodec signals available buffers
When running in asynchronous mode, MediaCodec will be running the CPU to signal input and output buffers being made available for use by the player. With ExoPlayer.experimentalSetDynamicSchedulingEnabled set to true, ExoPlayer will wakeup to make rendering progress when MediaCodec raises these signals. In this way, ExoPlayer work will align more closely with CPU wake-cycles.

PiperOrigin-RevId: 638962108
2024-05-31 02:22:16 -07:00
jbibik
a652c5b3f5 Add references in javadocs to relevant listeners for Player fields
PiperOrigin-RevId: 638688864
2024-05-30 10:02:01 -07:00
michaelkatz
43f719fbb2 Schedule exoplayer work to when MediaCodecAudioRenderer can progress
Currently ExoPlayer schedules its main work loop on a 10 ms interval. When renderers cannot make any more progress (ex: hardware buffers are fully written with audio data), ExoPlayer should be able to schedule the next work task further than 10ms out into the future.

Through `experimentalSetDynamicSchedulingEnabled` and these changes to `MediaCodecAudioRenderer`, ExoPlayer can use the data provided by the audio renderer to dynamically schedule its work tasks based on when it is expected that progress can be made.

PiperOrigin-RevId: 638677454
2024-05-30 09:25:11 -07:00
tianyifeng
e879c4ac43 Call PreloadControl.onSourcePrepared only once for each preload request
PiperOrigin-RevId: 638677090
2024-05-30 09:21:59 -07:00
michaelkatz
9e0f533a11 Schedule exoplayer work task to when renderers can make progress
Currently ExoPlayer schedules its main work loop on a 10 ms interval. When renderers cannot make any more progress(ex: hardware buffers are fully written with audio data), ExoPlayer should be able to schedule the next work task further than 10Ms out.

Through `experimentalSetDynamicSchedulingEnabled`, ExoPlayer will dynamically schedule its work tasks based on when renderers are expected to be able to make progress.

PiperOrigin-RevId: 638676318
2024-05-30 09:19:28 -07:00
tianyifeng
1f1897709f Rename PreloadMediaSource.PreloadControl methods
The IntDefs in `DefaultPreloadManager.Stage` are also renamed accordingly.

PiperOrigin-RevId: 638631357
2024-05-30 06:32:33 -07:00
ibaker
3d8b5811b4 Remove deprecated RendererSupport.FormatSupport IntDef & constants
Use `C.FormatSupport` and associated constants instead.

PiperOrigin-RevId: 637890304
2024-05-28 07:21:48 -07:00
ibaker
c87b7d86cc Remove deprecated format changed methods
Use the overloads with an additional `@Nullable DecoderReuseEvaluation`
parameter instead.

PiperOrigin-RevId: 637851937
2024-05-28 04:31:14 -07:00
Copybara-Service
67b799c714 Merge pull request #1389 from DolbyLaboratories:dlb/dovi-profile10/dev
PiperOrigin-RevId: 637827802
2024-05-28 02:39:42 -07:00
ibaker
763a5f0272 Remove deprecated DrmSessionManager.DUMMY and getter method
Use `DRM_UNSUPPORTED` constant instead.

PiperOrigin-RevId: 636937592
2024-05-24 09:07:35 -07:00
ibaker
7fd8a06e08 Remove deprecated MediaCodecInfo.isSeamlessAdaptationSupported(...)
Use `MediaCodecInfo.canReuseCodec(...)` instead.

PiperOrigin-RevId: 636918479
2024-05-24 07:59:45 -07:00
ibaker
08d1eb4376 Remove ShadowLog references from tests
These were accidentally submitted after being added for local debugging.

PiperOrigin-RevId: 636865825
2024-05-24 04:10:27 -07:00
ibaker
cfd29e04f3 Remove PlayerMessage.setHandler(Handler)
Use `setLooper(Looper)` instead.

PiperOrigin-RevId: 636840566
2024-05-24 02:13:43 -07:00
ibaker
4fb2255eb9 Print underlying extractor name in UnrecognizedInputFormatException
If subtitle-parsing-during-extraction is enabled (now defaults to on),
the 'outer' extractor class name is often
`SubtitleTranscodingExtractor`, leading to some slightly useless error
messages like:

`None of the available extractors (FragmentedMp4Extractor, Mp4Extractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor, TsExtractor, MatroskaExtractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor, AviExtractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor, SubtitleTranscodingExtractor)`

PiperOrigin-RevId: 636834354
2024-05-24 01:44:12 -07:00
tonihei
7b352e1903 Add more details to thread assertion in onAudioCapabilitiesChanged
This helps to debug issues reported in https://github.com/androidx/media/issues/1191

PiperOrigin-RevId: 636545970
2024-05-23 07:37:04 -07:00
ybai001
205bbef9d6 Add DV profile 10 handling in getAlternativeCodecMimeType() method 2024-05-23 09:42:43 +08:00
Copybara-Service
d175223cc6 Merge pull request #1339 from colinkho:set-play-when-ready-load-control-branch
PiperOrigin-RevId: 636095759
2024-05-22 02:57:15 -07:00
kimvde
9506445148 Remove VideoFrameReleaseControl setter from SinkProvider
Move the parameter to the constructor instead.

PiperOrigin-RevId: 636077477
2024-05-22 01:38:56 -07:00
dancho
b047e81e02 Work around SurfaceTexture implicit scale
If MediaCodec allocates passes an image buffer with a cropped region,
SurfaceTexture.getTransformMatrix will cut off 2 pixels from each dimensions.
The resulting videos will appear a little stretched.

This patch inspects the SurfaceTexture transform matrix, and guesses what the
unscaled transform matrix should be.
Behind experimentalAdjustSurfaceTextureTransformationMatrix flag

PiperOrigin-RevId: 635721267
2024-05-21 01:46:21 -07:00
tonihei
c46bb24264 Move parameters inside LoadControl and use it for shouldStartPlayback
+additional formatting and Javadoc changes
2024-05-20 15:53:07 +01:00
Colin Kho
be5cf6b5fd Allow LoadControl.shouldContinueLoading accept playWhenReady as a parameter 2024-05-20 15:48:14 +01:00
tonihei
dd7fb8178a Handle timeline updates where all periods in window have been replaced
This case is most likely to happen when re-preparing a multi-period
live stream after an error. The live timeline can easily move on to
new periods in the meantime, creating this type of update.

The behavior before this change has two bugs:
 - The player resolves the new start position to a subsequent period
   that existed in the old timeline, or ends playback if that cannot
   be found. The more useful behavior is to restart playback in the
   same live item if it still exists.
-  MaskingMediaSource creates a pending MaskingMediaPeriod using the
   old timeline and then attempts to create the real period from the
   updated source. This fails because MediaSource.createPeriod is
   called with a periodUid that does no longer exist at this point.
   We already have logic to not override the start position and need
   to extend this to also not prepare the real source.

Issue: androidx/media#1329
PiperOrigin-RevId: 634833030
2024-05-17 11:16:12 -07:00
tonihei
34792f7b11 Fix flakiness in ExoPlayerTest
The two affected tests where playing until a specific
position to enable the player to read ahead. The method
pauses at exactly the target position, but then has
temporarily undetermined behavior because the playback
thread uses player.getClock().onThreadBlocked() that lets
the playback thread make progress in parallel to the test
thread. The tests were flaky because they sometimes made
so much progress that they ended playback before we could
query the updated renderer state.

This can be fixed by using
run(player).untilBackgroundThreadCondition instead, which
is guaranteed to be fully deterministic, but may not be able
to stop at exactly the desired position (which we don't
really need anyway for this test).

PiperOrigin-RevId: 634699752
2024-05-17 03:34:04 -07:00
tonihei
2b5bb945e1 Add missing check before calling discardBuffer
The method is only allowed to be called on prepared items.
This check was currently missing and also causing the
corresponding test to be flaky in ExoPlayerTest.

PiperOrigin-RevId: 634694077
2024-05-17 03:09:52 -07:00
ibaker
282a944eb4 Throw errors from WebvttPlaybackTest.stallUntilPlayerCondition
Before this change, if a playback error is thrown the test fails with a
timeout and no additional info:

```
java.util.concurrent.TimeoutException
	at androidx.media3.exoplayer.e2etest.WebvttPlaybackTest.stallPlayerUntilCondition(WebvttPlaybackTest.java:361)
```

After this change, the test failure includes a much more useful stack
trace, e.g. from 0352db9a37:

```
Caused by: java.lang.IllegalStateException: Legacy decoding is disabled, can't handle text/vtt samples (expected application/x-media3-cues).
	at androidx.media3.common.util.Assertions.checkState(Assertions.java:100)
	at androidx.media3.exoplayer.text.TextRenderer.assertLegacyDecodingEnabledIfRequired(TextRenderer.java:587)
	at androidx.media3.exoplayer.text.TextRenderer.onStreamChanged(TextRenderer.java:210)
```

PiperOrigin-RevId: 634672138
2024-05-17 01:33:34 -07:00
kimvde
7b2a1b4443 Fix image not ignored for non-images in setImageDurationMs
PiperOrigin-RevId: 634345071
2024-05-16 05:48:41 -07:00
ibaker
0352db9a37 Default to parse subtitles while extracting, instead of while rendering
To override this change, and go back to parsing during rendering,
apps must make two method calls:

1. `MediaSource.Factory.experimentalParseSubtitlesDuringExtraction(false)`
2. `TextRenderer.experimentalSetLegacyDecodingEnabled(true)`

PiperOrigin-RevId: 634262798
2024-05-16 01:42:56 -07:00
tofunmi
7b357337d2 Support AVIF in exoplayer
https://developer.android.com/media/platform/supported-formats#image-formats was updated to include AVIF support in API 34+, so <unknown commit> updated our associated Util's to reflect this. After that change, ExoPlayer's BitmapFactoryImageDecoder will be able to decode AVIF, but the player won't be able to detect or extract it. Add this support for completeness, so that ExoPlayer can continue to say it supports all formats in https://developer.android.com/media/platform/supported-formats#image-formats.

PiperOrigin-RevId: 633956245
2024-05-15 08:04:41 -07:00
tonihei
67554395cb Fix test flakiness
The test currently resets the time too far in the past and then has
to run through ~30000 additional iterations of doSomeWork to reach
the end, sometimes triggering the test timeout.

Fix it by resetting the time to the intended start position when
transitioning items.

PiperOrigin-RevId: 633918706
2024-05-15 05:45:45 -07:00
tianyifeng
e4f0ff8177 Clear the PreloadMediaSource when deprioritized by the preload manager
PiperOrigin-RevId: 633917110
2024-05-15 05:40:58 -07:00
ibaker
ed4820cb61 Remove @UnstableApi from package-private files
This annotation is only needed on public classes.

This change also removes the `/* package */` comment from some `public`
classes.

PiperOrigin-RevId: 633864544
2024-05-15 02:26:55 -07:00
tonihei
d27c36ac9e Use MaskingMediaSource for AdsMediaSource content source
This means the content source is 'prepared' instantly with a
placeholder, enabling all further preparation steps (e.g. loading
preroll ads) while the actual content is still preparing. This
improvement can speed up the start time for prerolls in  manifest-based
content that doesn't have a zero-time preparation step like progressive
media.

Issue: androidx/media#1358
PiperOrigin-RevId: 633640746
2024-05-14 11:02:00 -07:00
tonihei
2175c432d7 Add error code for codec reclaim
This allows apps to better detect when the platform
reclaims a codec. This requires adding the error code
to MediaCodecDecoderException.

PiperOrigin-RevId: 633588914
2024-05-14 08:12:51 -07:00
tonihei
1a5cf6718b Use BaseAudioProcessor format tracking in SilenceSkippingAudioProcessor
The class currently tracks the input format itself, updating it too
early in onConfigure() instead of onFlush(). This causes issues when
the format changes and the new values are applied to the silence
skipping logic of the old format. The fix is to use the base class
input format handling instead.

Issue: androidx/media#1352
PiperOrigin-RevId: 633232368
2024-05-13 09:17:28 -07:00