22428 Commits

Author SHA1 Message Date
aquilescanta
c5b6489d5d Add missing isDeviceMuted to EVENT_DEVICE_VOLUME_CHANGED docs
PiperOrigin-RevId: 745591130
2025-04-09 08:05:15 -07:00
bachinger
1b3658e357 Adjust AGGREGATES_CALLBACKS_WITHIN_TIMEOUT_MS and make it configurable
PiperOrigin-RevId: 745585764
2025-04-09 07:47:12 -07:00
tonihei
f9617e1f8d Clear surface from previous player when assigning a new player
The surface must only be used by one player at a time. To ensure
that, we can keep a reference to the previously used player
and clear its surface reference before assigning to a new one.

Note that we do not need to clear the surface in onDispose
of a DisposableEffect because the lifecycle management of the
surface is moved to the Player and the Player takes care of
unregistering its surface reference as soon as the surface is
destroyed (which happens when the AndroidView element is no longer
is the Composable tree).

PiperOrigin-RevId: 745558414
2025-04-09 06:14:47 -07:00
claincly
4bfa154acd Allow replays with CompositionPlayer
PiperOrigin-RevId: 745536073
2025-04-09 04:54:48 -07:00
tianyifeng
71fb3ad5a5 Fix the parameter passed to AudioSink.InitializationException
We used to pass `audioTrackConfig.encoding` as the `bufferSize` parameter to `AudioSink.InitializationException`, for which this CL is supposed to correct. But `encoding` is a useful information for logging anyway, thus an `encoding` parameter is also added to `AudioSink.InitializationException` constructor, so now we pass both `encoding` and `bufferSize` parameters.

PiperOrigin-RevId: 745534997
2025-04-09 04:50:10 -07:00
tianyifeng
eae886fe28 Add Factory for SegmentDownloader implementations
PiperOrigin-RevId: 745530254
2025-04-09 04:33:27 -07:00
Googler
c8a3361cc8 internal change
PiperOrigin-RevId: 745226864
2025-04-08 11:36:50 -07:00
rohks
9182b413dc Ensure chunk duration is set in CmcdData for HLS media
Previously, encrypted media segments did not have the chunk duration set,
causing an assertion failure during `CmcdData` creation. With this change,
the chunk duration is always set, while `CmcdData` ensures it is applied
only for media chunks.

Issue: androidx/media#2312
PiperOrigin-RevId: 745196718
2025-04-08 10:21:36 -07:00
claincly
e11a8a1b19 Fix playback not transition into next mediaItem
This is because the replay cache needs to clear the cache after one mediaItem is fully played.

That is, if the last two frames are cached, we need to wait until they are both rendered before
receiving inputs from the next input stream because the texture size might change. And when the
texture size changes, we teardown all previous used textures, and this causes a state confusion
in the shader program in that, the cache thinks one texture id is in-use (because it's not released)
but the baseGlShaderProgram texturePool thinks it's already free (as a result of size change)

Also fixes an issue that, if replaying a frame after EOS is signalled, the EOS
signal is lost because we flush the pipeline.

PiperOrigin-RevId: 745191032
2025-04-08 10:08:34 -07:00
bachinger
2f1fc4773c Allow testing of clipped VOD windows by adding windowPositionInPeriodUs
This is a no-op change. Preparing for follow up CLs to test
clipped VOD windows.

PiperOrigin-RevId: 745172140
2025-04-08 09:16:41 -07:00
ibaker
83efd8eb66 Add ScrubbingModeParameters
This adds the option to disable certain track types during scrubbing,
with audio and metadata disabled by default.

The tracks are disabled by modifying the `TrackSelectionParameters`,
but in a way that is invisible to
`Player.getTrackSelectionParameters()` and
`Player.Listener.onTrackSelectionParametersChanged`. This allows us to
clearly reason about what should happen if
`Player.setTrackSelectionParameters(...)` is called during scrubbing
mode. The **side effects** of disabling the tracks are all visible
through `Player.Listener` and `AnalyticsListener` (renderer disabled,
decoder released, `onTracksChanged`, etc.).

PiperOrigin-RevId: 743961632
2025-04-04 08:58:44 -07:00
ibaker
6c4c4bdea4 Tweak the parameter name in Util.shouldShowPlayButton
The previous name sounds a bit like it refers to the action of
'playing', rather than which button is shown (which is kind of the
opposite!).

PiperOrigin-RevId: 743908736
2025-04-04 05:40:30 -07:00
sheenachhabra
72bb474604 Add experimental prefix to setForce{Audio,Video}Track APIs
These APIs are likely to change/removed in near future.

PiperOrigin-RevId: 743899703
2025-04-04 04:57:56 -07:00
bachinger
9a700d21bf Use window duration of parsed media playlist in tests
PiperOrigin-RevId: 743875066
2025-04-04 03:00:57 -07:00
claincly
9785c1fd92 Allow setting VideoFrameMetadataListener on CompositionPlayer
PiperOrigin-RevId: 743607386
2025-04-03 10:12:32 -07:00
Googler
feae2dadeb Adds getChannelOutputConfig() to AudioTrackProvider.
PiperOrigin-RevId: 743577038
2025-04-03 08:42:07 -07:00
sheenachhabra
1f3a5e7d1c Do not allow video transmuxing if there are video gaps
PiperOrigin-RevId: 743555458
2025-04-03 07:32:39 -07:00
kimvde
ee611a1ab8 Access finalAudioSink from playback thread
The finalAudioSink was accessed from the main thread but it should only
be accessed from the playback thread.

PiperOrigin-RevId: 743548450
2025-04-03 07:09:01 -07:00
ibaker
f755c7081f Increase the connection timeout in HttpEngineDataSourceContractTest
This test is flaking with a `SocketTimeoutException` on some emulators.

PiperOrigin-RevId: 743545820
2025-04-03 06:58:29 -07:00
dancho
036bed3632 Do not drop decoder input buffers close to a reset position
This is a workaround for a bug where the positionUs seen by
MCVR jumps when audio pre-roll samples are discarded.

PiperOrigin-RevId: 743538208
2025-04-03 06:31:32 -07:00
michaelkatz
8327a2a52d Do not enable offload scheduling while preparing next media
ExoPlayer disables sleeping for offload when the reading period advances and re-evaluates turning it back on when the playing period advances. For playlists of short items where the reading period could advance much further than the playing period, sleeping should still be disabled until the playing period advances to match the current reading period.

Issue: androidx/media#1920
PiperOrigin-RevId: 743503063
2025-04-03 04:15:15 -07:00
kimvde
18e9a3fe36 Rename VideoSink.onStarted/Stopped
start/stopRendering better reflects what the method does.

PiperOrigin-RevId: 743493973
2025-04-03 03:42:57 -07:00
bachinger
96222478cd Don't expect onMetadataChanged and onPlaybackStateChanged in order
PiperOrigin-RevId: 743472646
2025-04-03 02:22:04 -07:00
dancho
769aca2e32 Internal-only change
PiperOrigin-RevId: 743468059
2025-04-03 02:05:44 -07:00
sheenachhabra
bd14b753ee Add forceVideoTrack flag on EditedMediaItemSequence
This is similar to forceAudioTrack.

PiperOrigin-RevId: 743235372
2025-04-02 12:24:58 -07:00
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