22453 Commits

Author SHA1 Message Date
aquilescanta
1ea69ca7be Add @InlineMe to CastPlayer deprecated methods
PiperOrigin-RevId: 747868138
2025-04-15 07:38:16 -07:00
aquilescanta
405365c228 Implement device volume adjustment in CastPlayer
Issue: androidx/media#2089
PiperOrigin-RevId: 747861812
2025-04-15 07:17:41 -07:00
tonihei
70e7121a51 Make some audio processors public
ChannelMappingAudioProcessor, TrimmingAudioProcessor and
ToFloatPcmAudioProcessor are currently package-private even
though they might be useful in custom audio processing chains
or custom version of audio sinks.

Issue: androidx/media#2339
PiperOrigin-RevId: 747857815
2025-04-15 07:03:04 -07:00
tonihei
9cc7dd0dbe Ensure DefaultAudioSink doesn't store non-application Context
The Context is currently passed right down from ExoPlayer.Builder
without ever converting it to the application context. This may
cause memory leaks if a Player is kept across activities/service
lifecycles.

PiperOrigin-RevId: 747835487
2025-04-15 05:40:56 -07:00
tonihei
21514ba8e8 Add missing check for TRACK_TYPE_NONE before accessing selections
The track selections will be null if the track type is NONE even
if the renderer is enabled.

PiperOrigin-RevId: 747818128
2025-04-15 04:38:14 -07:00
bachinger
117db48907 Assert preload looper is not the main looper
Issue: androidx/media#2315
PiperOrigin-RevId: 747809915
2025-04-15 04:08:01 -07:00
dancho
9fca713045 Ignore flaky test
PiperOrigin-RevId: 747793474
2025-04-15 03:06:51 -07:00
dancho
f261fe187a Assert frame counts with tolerance.
MediaCodec decoders sometimes output frames in
the wrong order. Make our asserts more permissive to
reduce noise in tests.

PiperOrigin-RevId: 747414696
2025-04-14 07:48:30 -07:00
shahddaghash
a2265f1dae Replace deprecated ShadowMediaCodecConfig factory methods
This is part of the efforts for adding encoder support for ShadowMediaCodecConfig to use it for ExoPlayer and Transcoding tests.
* Replaced `ShadowMediaCodecConfig#forAllSupportedMimeTypes()` calls with `ShadowMediaCodecConfig#withAllDefaultSupportedCodecs()`
* Replaced `ShadowMediaCodecConfig#withNoDefaultSupportedMimeTypes() calls with `ShadowMediaCodexConfig#withNoDefaultSupportedCodecs()`

PiperOrigin-RevId: 747413859
2025-04-14 07:46:13 -07:00
shahddaghash
07be60ed93 Add encoder support to ShadowMediaCodecConfig
This is a step towards unifying ShadowMediaCodecConfig structure to accommodate having both ExoPlayer and Transcoding codecs configuration.

This includes:
* Adding ability to configure encoders by calling `addEncoders(CodecInfo...)`
* A new factory method that takes specific encoders and decoders CodecInfos
* A new method `addCodecs(boolean, CodecConfig, CodecInfo...) that configures codecs with specified behavior by passing a `CodecConfig`.

This CL also includes migrating Transformer tests to ShadowMediaCodecConfig.

PiperOrigin-RevId: 747390451
2025-04-14 06:30:04 -07:00
bachinger
ed56ed22fb Don't enqueue ad periods that start after the end of the period
Issue: androidx/media#2215
PiperOrigin-RevId: 747376615
2025-04-14 05:41:31 -07:00
tonihei
3205811f23 Update release notes for 1.6.1
PiperOrigin-RevId: 747337479
2025-04-14 03:26:00 -07:00
Googler
b046d590bc Mp4Muxer: Update APV clip in test.
As [APV spec](https://github.com/AcademySoftwareFoundation/openapv/blob/main/readme/apv_isobmff.md#syntax-1) is updated, the current APV clip is replaced with latest
APV clip.

PiperOrigin-RevId: 747272127
2025-04-13 23:45:13 -07:00
tonihei
68538029c9 Fix getChildPeriod logic if the child is a TimeOffsetMediaPeriod
The current instanceof check accidentally unpacks the child,
returning the inner period instead of the one passed to the source.

PiperOrigin-RevId: 746556825
2025-04-11 12:45:01 -07:00
bachinger
21faf85382 Load asset list 3 target durations before ad start time
This makes sure that the asset list is loaded about the
same duration before the ad start as on other platforms.

Further, interstitials in live streams are taken into
account when 3 target durations before the live window.
This enables the ads loader to preload such ads in a
future change. This may be indicated for live streams
that should play as close to the live edge as possible.
In such a case the buffered position may reach the start
of the ad only late. Preloading could help here to
decrease the performance requirements of ad servers.

PiperOrigin-RevId: 746521261
2025-04-11 11:00:56 -07:00
rohks
6f5982792a Derive average bitrate from stsz sample size and mdhd duration
Compute a precise average bitrate using total sample size (from `stsz`) and media duration (from `mdhd`), overriding any existing bitrate read from `btrt` or `esds` boxes.

PiperOrigin-RevId: 746497934
2025-04-11 09:58:18 -07:00
tianyifeng
344f249511 Fix issue where ProgressiveMediaPeriod fails assertPrepared
In `PreloadMediaSource` we accesses the `MediaPeriod.getBufferedPositionUs()` when we receive `onContinueLoadingRequested()` from the period. For `ProgressiveMediaPeriod` which requires loading a portion of media file to get it prepared, there is a chance that it needs more than one round of `onContinueLoadingRequested()` -> `continueLoading()` to complete preparation, for example, when the  `setContinueLoadingIntervalBytes()` is small enough to not include the full information for preparation. Thus we should avoid `MediaPeriod.getBufferedPositionUs()` being called before period is prepared, as it will fail at `assertPrepared`.

Issue: androidx/media#2315

#cherrypick

PiperOrigin-RevId: 746490375
2025-04-11 09:34:57 -07:00
tonihei
df8763ae0d Remove some misleading locks in MediaSessionService
The stub, mediaNotificationManager and actionFactory fields were
already only allowed to be accessed on the main thread, so need to
lock any access to them. Also add a corresponding note to methods
that were already meant to be called on the main thread only, but
didn't have the corresponding note in the Javadoc yet.

PiperOrigin-RevId: 746440272
2025-04-11 06:41:45 -07:00
tonihei
9ca8540f85 Ensure media notification provider can be updated
Some interactions create a default notification provider if
no custom one is set yet (e.g. setForegroundServiceTimeoutMs).
This means a later call to setMediaNotificationProvider will
silently fail to apply the new provider.

This can be fixed by making the media notification provider
updatable.

Issue: androidx/media#2305
PiperOrigin-RevId: 746428193
2025-04-11 05:56:52 -07:00
tonihei
45bcf3ff92 Bump version to 1.6.1
PiperOrigin-RevId: 746409221
2025-04-11 04:36:13 -07:00
bachinger
5f940af3df Always return empty timeline when wrapped player is empty
In `PlayerWrapper.getCurrentTimelineWithCommandCheck()` we
always return `new CurrentMediaItemOnlyTimeline(this)` in
case the wrapped player doesn't have `COMMAND_GET_TIMELINE`
available but has `COMMAND_GET_CURRENT_MEDIA_ITEM`. This is
emulating a single item timeline with a static window count
of 1 which isn't correct when the wrapped player is empty.

Instead, when the wrapped player is empty we need to return
an empty timeline to match the wrapped player.

Issue: androidx/media#2320
PiperOrigin-RevId: 746071237
2025-04-10 09:59:25 -07:00
tonihei
f672590b2d Remember explicit notification dismissal
Currently, a notification may be recreated even if a user dismissed
it as long as the standard conditions for a notification are true.

To avoid this effect, we plumb the dismissal event to the notification
controller, so that it can override its `shouldShowNotification`
decision. The plumbing sets an extra on the media key intent, which
the session forwards as a custom event to the media notification
controller if connected.

Issue: androidx/media#2302
PiperOrigin-RevId: 745989590
2025-04-10 05:38:58 -07:00
dancho
a78d0c3994 Rollback of 73fa820828
PiperOrigin-RevId: 745618560
2025-04-09 09:25:55 -07:00
bachinger
cb0ea7fc95 Make sure subtitle is used without display title being set
PiperOrigin-RevId: 745616511
2025-04-09 09:19:47 -07:00
bachinger
6cae8ab8a0 Support X-SNAP with HLS interstitials
PiperOrigin-RevId: 745614349
2025-04-09 09:13:24 -07:00
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