22453 Commits

Author SHA1 Message Date
tonihei
989e9f9e84 Remove remaining synchronized keywords from EPII
These are needed for the `waitUninterruptibly` handling, which is
really just waiting for a condition to become true on another thread
with a timeout, as well as Clock and interrupt handling.

We already have ConditionVariable that serves this purpose, which
has methods with a timeout and with interrupt handling. Adding
another version of the call with both timeout and interrupt handling
allows to replace the EPII manual code. The ConditionVariable methods
were also missing the clock calls to signal a wait operation.

PiperOrigin-RevId: 743214709
2025-04-02 11:30:04 -07:00
bachinger
d133300627 Make AdPlaybackState.withAdDurationsUs work with removed ad groups
The assertion is changed to check that the number of passed
in arrays of durations is always matching `adGroupCount`
according to the behavior of `withRemoveAdGroupCount(int)`.

Issue: androidx/media#2267
PiperOrigin-RevId: 743185176
2025-04-02 10:15:29 -07:00
ibaker
a9c0349214 Standardize percentage calculations
This is a follow-up to 72f5df582a

PiperOrigin-RevId: 743173295
2025-04-02 09:46:15 -07:00
tonihei
0dd43b0183 Reduce 'synchronized' usage in EPII by making variable single thread
EPII currently uses 'synchronized' for two purposes:
 1. `waitUninteruptably` to ensure the condition checks and
    `wait` calls are atomic + the calls on the playback thread
    that update these conditions to `notifyAll`.
 2. Access to the `released` field that is used a condition
    for `waitUninterruptibly` but otherwise only accessed on the
    app thread.

We can remove the second usage by making the `released` variable
more clearly single thread on the app thread (including renaming to
make it obvious as this is the only variable in this class accessed
on that thread). The `waitUninterruptly` call for `release` can use
an `AtomicBoolean` like the other two calls to this method.

This also fixes a potential bug where a release timeout would leave
the `released` field as `false`, meaning future calls to these other
methods wouldn't be blocked early.

PiperOrigin-RevId: 743156035
2025-04-02 08:54:29 -07:00
ibaker
0517cea4d2 Add new EPI method for when only the suppression reason has changed
This also fixes the 'unsuitable output' logic incorrectly overriding
the `@PlayWhenReadyChangeReason` when only the playback **suppression**
state has changed.

PiperOrigin-RevId: 743148739
2025-04-02 08:32:08 -07:00
michaelkatz
9e80d6d263 Set static interval as default for dynamic scheduling with audio
Applications providing custom `AudioSink` implementations should have the dynamic scheduling for audio playback fallback to the static interval if they are not implementing `AudioSink#getAudioTrackBufferSizeUs()`.

PiperOrigin-RevId: 743082057
2025-04-02 04:47:32 -07:00
rohks
c0e518df97 Remove incorrect frame rate calculation using tkhd box duration
Frame rate is correctly determined using the media duration from the `mdhd` box and the sample count from the `stsz` box. The fallback calculation using the edited sample count and `tkhd` box duration is incorrect, as added silence at the beginning can increase the track duration without affecting the sample count.

No-op change, as we never use the fallback calculation for our sample files in the test.

PiperOrigin-RevId: 743081118
2025-04-02 04:43:25 -07:00
tonihei
a1ed0d4ff6 Update PlayerSurface to directly use AndroidView
The proxy classes Android(Embedded)ExternalSurface just provide a
simple API surface around AndroidView wrapping SurfaceView and
TextureView respectively. However, this prevents accessing the
underlying views directly, which is needed for full lifecycle
tracking by the Player and to access surface size updates (which
are not available when the API is reduced to just `Surface`).

Instead of the proxy classes, we can directly use AndroidView from
PlayerSurface. This allows to call the proper Player APIs to set
SurfaceView or TextureView, so that the Player can keep track of
the view lifecycle and update its internal state and size tracking
accordingly. Because the player keeps tracks of the lifecycle,
none of the callback structure in Android(Embedded)ExternalSurface
is needed, nor are the additional setters for options that are
all default.

PiperOrigin-RevId: 743079058
2025-04-02 04:35:03 -07:00
ibaker
e710179fee Limit the API levels of two lib-datasource tests
`FileDescriptorDataSourceUsingAssetFileDescriptorContractTest` is flaky
emulators earlier than 29.

PiperOrigin-RevId: 743058462
2025-04-02 03:20:41 -07:00
ibaker
d315d90f7a Add scrubbing mode API to ExoPlayer
This initial version prevents incoming seeks from pre-empting
in-progress seeks, allowing more seeks to complete when the scrubber
bar is dragged quickly back and forth.

More scrubbing optimizations will be added in follow-up changes.

PiperOrigin-RevId: 743052527
2025-04-02 03:00:05 -07:00
kimvde
c8a34ec846 Handle RawAssetLoader feeding data while Transformer is being ended
PiperOrigin-RevId: 743017931
2025-04-02 00:58:28 -07:00
sheenachhabra
cf3faf9cff Validate gap at start when building sequence
PiperOrigin-RevId: 742710209
2025-04-01 08:31:37 -07:00
kimvde
812e078310 Make sure ExoPlayerAssetLoader's progress is not more than 100
PiperOrigin-RevId: 742710076
2025-04-01 08:29:44 -07:00
bachinger
3fddf4376c Resolve asset list and populate ad playback state
PiperOrigin-RevId: 742705857
2025-04-01 08:17:43 -07:00
tianyifeng
ce3754a740 Add PlaybackParameters.withPitch() method
Issue: androidx/media#2257
PiperOrigin-RevId: 742693410
2025-04-01 07:42:27 -07:00
sheenachhabra
209ecce6b3 Change getVideoTrackOutput() to getTrackOutput()
The updated method can be used for audio as well.

PiperOrigin-RevId: 742673561
2025-04-01 06:36:03 -07:00
bachinger
c95544156d Clip live periods that get a duration and end position
When an ad is inserted into a live period with an unset
duration, the live period needs to be wrapped with a
`ClippingMediaPeriod` and then actually be clipped to
the end position when the duration gets known. Without
this the renderers will never see an EOS which prevents
the reading/playing period from advancing.

In the case of a server side inserted ad on the other
hand, the actual clipping needs to be prevented to
keep the current behavior for SSAI streams. In an SSAI
stream, an ad inserted before the current position should
not produce a snap back to the newly inserted ad. This is
currently prevented in both places, when the updated
timeline is handled to not disable the renderers, and when
the `mediaPeriodQueue` updates the queued periods. This
behaviour is preserved to not create side effects of this
change.

PiperOrigin-RevId: 742642715
2025-04-01 04:46:31 -07:00
kimvde
f2d644b7b4 PlaybackVideoGraphWrapper: update listener logic for multi sequence
- Only have the primary sequence renderers listen to
PlaybackVideoGraphWrapper events. These events only need to be
forwarded to a single ExoPlayer instance.
- Set the DefaultVideoSinkListener only once.

PiperOrigin-RevId: 742636455
2025-04-01 04:18:39 -07:00
kimvde
595b75b7d3 Deduplicate some of the calls to DefaultVideoSink methods
Some DefaultVideoSink methods are called once per sequence, but this
doesn't make sense as the DefaultVideoSink is connected to the
VideoGraph output. This CL calls the DefaultVideoSink method only for
the primary sequence.

The other problematic DefaultVideoSink method calls will be moved in
follow-up CLs.

This is part of the effort to prepare PlaybackVideoGraphWrapper for
multi-sequence.

PiperOrigin-RevId: 742625589
2025-04-01 03:42:22 -07:00
sheenachhabra
2141d9ef9c Make forceAudioTrack flag mandatory when gap is at start
Earlier when gap is at the start of a sequence
it was automatically filled with silent audio.
Now setting forceAudioTrack flag is mandatory to
indicate that the gap at the start of a sequence
must be filled with silent audio.

PiperOrigin-RevId: 742625236
2025-04-01 03:40:41 -07:00
ibaker
3ab484d93f Stabilize various setUserAgent() and Util.getUserAgent() methods
Issue: androidx/media#2286
PiperOrigin-RevId: 742367539
2025-03-31 13:05:42 -07:00
sheenachhabra
8508e12001 Rename TransformerVideoGapsTest to TransformerGapsTest
This will allow keeping both audio and video gap test
in the same class.

PiperOrigin-RevId: 742291252
2025-03-31 09:27:57 -07:00
kimvde
f8b1dcc33b Move VideoSink config to dedicated method
This is  to improve readability of MediaCodecVideoRenderer.onEnabled

PiperOrigin-RevId: 742246092
2025-03-31 06:40:12 -07:00
sheenachhabra
25c1760b17 Add VIDEO_APV mimetype to FrameworkMuxer supported types
Came up in github issue https://github.com/androidx/media/issues/2275.

PiperOrigin-RevId: 742233737
2025-03-31 05:44:06 -07:00
claincly
9254efd8da Add pixel test for replaying
I could've add another test that seeks into the media before replying, but I
don't think fundamentally it's different from the one added.

I wish I could add one that replays while playing, but it'd be hard to match
the frames perfectly.

I'll add more timestamp based tests

PiperOrigin-RevId: 742229436
2025-03-31 05:22:31 -07:00
claincly
ff6537d69b Fix a bug that video effects are added twice
The tests passed because of an issue in chaining. The chaining listener allows
self-looping, i.e. the producer and the consumer of a frame could be the same
instance. Like an effect chain of `a -> a -> b` This didn't fail any test
before, because the chaining is rectified when connecting a to b, but it should
have failed when connecting a to a.

PiperOrigin-RevId: 742215700
2025-03-31 04:22:18 -07:00
dancho
73fa820828 Skip decoder input buffers for encrypted content
Previous assertion was incorrect. Per-frame initialization
vectors are written to the output stream in
`FragmentedMp4Extractor`

PiperOrigin-RevId: 742203717
2025-03-31 03:34:09 -07:00
kimvde
427daef350 Remove VideoSink.setWakeUpListener
This is the last Renderer reference in VideoSink

PiperOrigin-RevId: 742189332
2025-03-31 02:26:56 -07:00
tianyifeng
72f5df582a Improve the precision of percentDownloaded in Downloaders
We don't require high precision in the calculation of `percentDownloaded` for `Downloader.ProgressListener.onProgress` though, when `byteCached == contentLength`, we hope the `percentDownloaded` to be `100f` (rather than `99.99999f`). The result of `byteCached * 100f` can be less precise as the floating-point numbers are sparser when the value is far from zero. For example, if `byteCached == 812345L`, then the `byteCached * 100f` will become `81234496` (value checked by `BigDecimal`).

PiperOrigin-RevId: 741895445
2025-03-29 16:47:31 -07:00
sheenachhabra
c858abda5d Remove usage of Composition.Builder#experimentalSetForceAudioTrack
This CL removes all usages within media3.

PiperOrigin-RevId: 741469343
2025-03-28 03:51:27 -07:00
michaelkatz
a4f5f67d7e Fix media period mismatch during recoverable renderer error processing
If a recoverable renderer error occurred just before playing period transition(aka media item transition) then the player may enter a continuous loop of retrying to play the previous media item.

This was most easily reproduced in an audio offload scenario where init in offload mode always fails. In initializing the following media, the process would fail with recoverable error to try in non-offload mode. The player would try to recover with playing the previous media item. Most times it would skip to the next track but not always.

Issue: androidx/media#2229
PiperOrigin-RevId: 741213293
2025-03-27 11:03:49 -07:00
tonihei
f74abed984 Add missing 1.6.0 entry to GH bug template
PiperOrigin-RevId: 741120336
2025-03-27 05:48:34 -07:00
Copybara-Service
f2fa0f7b2a Merge pull request #2253 from nirb999:main
PiperOrigin-RevId: 741092998
2025-03-27 03:50:08 -07:00
Googler
10fd1ee270 Minor cleanup to separate content progress provider interface
PiperOrigin-RevId: 740901722
2025-03-26 14:23:11 -07:00
sheenachhabra
87e0d7b95a Add setForceAudioTrack method on EditedMediaItemSequence
PiperOrigin-RevId: 740808813
2025-03-26 10:04:14 -07:00
ibaker
0d60c5bf25 MP4: Parse alternate_group and expose it in Format.metadata
Issue: androidx/media#2242
PiperOrigin-RevId: 740794206
2025-03-26 09:21:21 -07:00
ibaker
96bb777484 Add VideoFrameMetadataListener calls to FakeVideoRenderer
This change also tightens `FakeVideoRenderer` to only 'handle' buffers
that are close to the current playback position.

This condition controls whether the renderer fires `onVideoSizeChanged`
and `onRenderedFirstFrame`, both of which should only be fired once the
frame has been 'released' to the screen, which in a real renderer
happens much closer to 'current position' than the existing 250ms of
`FakeRenderer.SOURCE_READAHEAD_US`.

A later change uses `VideoFrameMetadataListener` to test ExoPlayer
behaviour in scrubbing mode.

PiperOrigin-RevId: 740763283
2025-03-26 07:44:38 -07:00
Rohit Singh
916ffcfe5f Add RELEASENOTES entry 2025-03-26 14:12:55 +00:00
Copybara-Service
95fbecd076 Merge pull request #2260 from MGaetan89:audiomanagercompat_log
PiperOrigin-RevId: 740752418
2025-03-26 07:06:39 -07:00
Rohit Singh
5594dddc99 Fix not sent for manifest requests in HLS and SS 2025-03-26 14:04:08 +00:00
kimvde
12b4c7d780 Remove unused param from VideoSink
PiperOrigin-RevId: 740739740
2025-03-26 06:15:03 -07:00
Googler
a24d1d41d9 BoxParser: Update Dolby Vision codec support.
1. Append initialization data of Dolby Vision codec to list of initialization data.
2. Parse `dwcC` box in BoxParser.

PiperOrigin-RevId: 740737770
2025-03-26 06:07:33 -07:00
kimvde
3d5e650980 Improvements to VideoSink.Listener
- Remove unused VideoSink parameter
- Make methods default so that implementations don't have to override
them all

PiperOrigin-RevId: 740715000
2025-03-26 04:28:07 -07:00
Gaëtan Muller
14b4a9ff32 Use the existing TAG constant in AudioManagerCompat
This also addresses the `Private field 'TAG' is never used` warning.
2025-03-26 11:13:33 +00:00
kimvde
d4ea3ad932 PlaybackVideoGraphWrapper: fix inputType discrepancy
PiperOrigin-RevId: 740699944
2025-03-26 03:29:43 -07:00
Googler
598ec00c5d DolbyVisionConfig: Move file to the container library.
For usage of instance of `DolbyVisionConfig` used in Muxer to support Dolby Vision codec, move `DolbyVisionConfig` file from extractor library to container library.

PiperOrigin-RevId: 740689000
2025-03-26 02:43:37 -07:00
kimvde
6cd15fb4b0 Remove PlaybackVideoGraphWrapper param from its listener methods
It's unclear why the listeners would need access to the
PlaybackVideoGraphWrapper as there should always be only one. Also,
it's not common practice to pass the parent object to the listener in
media3 (see Player.Listener for example).

PiperOrigin-RevId: 740686007
2025-03-26 02:32:51 -07:00
kimvde
0ad7ceadb3 Remove references to Renderers from VideoSink
Remaining references will be removed in follow-up changes

PiperOrigin-RevId: 740362812
2025-03-25 08:43:44 -07:00
ibaker
4338355422 Use dumper.addIfNonDefault in CapturingAudioSink
If encoded audio is dumped, some of these values may not be set.

Also add a related TODO

PiperOrigin-RevId: 740357230
2025-03-25 08:24:44 -07:00
michaelkatz
6e510c26df Set that any error during pre-warming disables and resets pre-warming
For now, even if a recoverable error occurs during pre-warming, the current process will be that pre-warming is disabled until subsequent media item transition.

PiperOrigin-RevId: 740349517
2025-03-25 08:02:42 -07:00