6051 Commits

Author SHA1 Message Date
Copybara-Service
acdc71bb63 Merge pull request #2386 from DolbyLaboratories:dlb/cmcd/nullable-configuration
PiperOrigin-RevId: 753210729
2025-04-30 10:04:01 -07:00
sheenachhabra
bfb8c5c237 Fix muxer interface java doc
PiperOrigin-RevId: 753203794
2025-04-30 09:45:50 -07:00
ibaker
8dc8003afc Deprecate Util.compareLong in favour of Long.compare
The `Long` method was only added in API 19, so wasn't previously
usable when ExoPlayer's minSdk was 16.

PiperOrigin-RevId: 753185351
2025-04-30 08:50:22 -07:00
Copybara-Service
df41f6b041 Merge pull request #2387 from DolbyLaboratories:dlb/cmcd/pr-key-not-allowed
PiperOrigin-RevId: 753181724
2025-04-30 08:40:00 -07:00
ibaker
c137d27850 Add support for S_TEXT/SSA CodecId in MKV files
This change renames the existing `sample_with_ssa_subtitles.mkv` test
file (with `S_TEXT/ASS` codec ID) to `sample_with_ass_subtitles.mkv`
(so the file name matches the codec ID), and forks a new test file
called `sample_with_ssa_subtitles.mkv` with the `S_TEXT/SSA` codec ID.
`MatroskaExtractorTest` then asserts that both these files produce
identical dump files.

Issue: androidx/media#2384
PiperOrigin-RevId: 753164883
2025-04-30 07:48:25 -07:00
Copybara-Service
e4b23f6b6c Merge pull request #2377 from bubenheimer:handleSetDeviceVolume_flags
PiperOrigin-RevId: 753132783
2025-04-30 05:52:20 -07:00
jbibik
49d929b212 [ui-compose] Eliminate race condition in PresentationState
PresentationState creation and listener registration are not an atomic operation. This happens because the LaunchedEffect which starts the listen-to-Player-Events coroutine can be pre-empted with other side effects, including the ones that change something in the Player.

rememberPresentationState function creates a PresentationState object and initialises it with the correct fresh values pulled out of the Player. The subscription to Player events with a registration of a Listener (via PresentationState.observe()) is not immediate. It *returns* immediately, but is instead scheduled to happen later, although within the same Handler message. Other LaunchedEffects could have been scheduled earlier and could take place between the button state creation and listener subscription.

This is not a problem if no changes to the player happen, but if we miss the relevant player events, we might end up with a UI that is out of sync with reality. The way to fix this is to pull the latest values out of the Player on demand upon starting to listen to Player events.

PiperOrigin-RevId: 753129489
2025-04-30 05:39:15 -07:00
Mattias Buelens
ec01011374 Fix CMCD sending pr=0.00 even when key is not allowed 2025-04-30 14:28:20 +02:00
Mattias Buelens
a019de887c Allow CmcdConfiguration.Factory to return null to disable CMCD 2025-04-30 14:19:20 +02:00
tonihei
deb466c496 Add artwork to stored preferences
This allows it to be displayed after reboot when we can't reload
it safely over network.

PiperOrigin-RevId: 753122948
2025-04-30 05:13:05 -07:00
sheenachhabra
8d87a69351 Rollback of a31c7ad9a8
PiperOrigin-RevId: 753104435
2025-04-30 04:01:19 -07:00
jbibik
16c071109a [ui-compose] Make PlayerSurface accept a nullable Player
`PlayerSurface` is just an `AndroidView` composable wrapping `SurfaceView` and `TextureView`. It uses the `Player` passed to it to set the `SurfaceHolder`s from those `SurfaceView`/`TextureView` objects. However, it does not technically need the Player to be created - the result will just be an empty Surface.

Add an optimisation to PlayerSurfaceInternal that avoids preemptive clearing of the Surface on the old Player. This helps avoid a costly creation of a surface placeholder right before (potentially) assigning the new Surface to that player.

PiperOrigin-RevId: 752840145
2025-04-29 12:34:35 -07:00
Uli Bubenheimer
0d2b831c94 Add missing @C.VolumeFlags for SimpleBasePlayer.handleSetDeviceVolume 2025-04-29 17:27:54 +01:00
bachinger
965fc81f08 Convert ResultReceivers before sending to legacy app
PiperOrigin-RevId: 752739239
2025-04-29 08:11:21 -07:00
ibaker
e5d3236649 Use ReorderingBufferQueue in H.262 UserDataReader
Issue: androidx/media#2372
PiperOrigin-RevId: 752721649
2025-04-29 07:13:02 -07:00
ibaker
49064c4b82 Stabilize the ExoPlayer.Builder.setSeekForward/BackIncrementMs APIs
The equivalent getters are already stable on `Player`.

Issue: androidx/media#2286
PiperOrigin-RevId: 752686185
2025-04-29 05:02:03 -07:00
ibaker
5775abd7e3 Rename ReorderingSeiMessageQueue to remove reference to SEI
In a follow-up change I am going to use this class in a non-SEI context
for H.262 'user data'.

Issue: androidx/media#2372
PiperOrigin-RevId: 752683541
2025-04-29 04:52:03 -07:00
kimvde
721f3c517b Increase test timeout on emulator
CompositionMultipleSequencePlaybackTest is flaky on emulator because
the pipeline is slow on these devices.

PiperOrigin-RevId: 752667954
2025-04-29 03:51:08 -07:00
kimvde
293c55e062 Adapt InputVideoSink.onInputStreamChanged for CompositionPlayer
The output of CompositionPlayer should be considered as a single clip
(not a playlist) so we should only propagate the first stream change
event in that case.

PiperOrigin-RevId: 752661523
2025-04-29 03:23:42 -07:00
Googler
cfa13e9616 Update Boxes to support writing negative timestamps to edit list
Previously when there were negative timestamps, the tkhd duration was incorrectly equal to the full track duration rather than the presentation duration of the edit list. From the [docs](https://developer.apple.com/documentation/quicktime-file-format/track_header_atom/duration) - "The value of this field is equal to the sum of the durations of all of the track’s edits".

PiperOrigin-RevId: 752655137
2025-04-29 02:59:28 -07:00
kimvde
48832cbbc4 Remove unused setter in PlaybackVideoGraphWrapper.Builder
PiperOrigin-RevId: 752639277
2025-04-29 01:57:12 -07:00
ibaker
ecfd9d1e92 Clear TextRenderer.streamError when disabling or changing stream
Previously a stream error from one playlist item was incorrectly
preserved when switching to the next one, resulting in playback hanging.

Issue: androidx/media#2328
PiperOrigin-RevId: 752624979
2025-04-29 01:05:21 -07:00
kimvde
4d7046c187 Fix failing test
This was introduced by 0f08c97221.

PiperOrigin-RevId: 752273544
2025-04-28 05:52:48 -07:00
kimvde
0f08c97221 Handle rendering in VideoGraph time
Before this CL, the buffer adjustment (which allows to convert from
ExoPlayer time to VideoGraph time) was added to the frame timestamps
before feeding them to the VideoGraph, and then subtracted at the
VideoGraph output. The playback position and stream start position used
for rendering were in ExoPlayer time.

This doesn't work for multi-sequence though because the adjustment might
be different depending on the player (after a seek for example).

To solve this problem, this CL handles rendering in VideoGraph time
instead of ExoPlayer time. More concretely, the VideoGraph output
timestamps are unchanged, and the playback position and stream start
position are converted to VideoGraph time.

PiperOrigin-RevId: 752260744
2025-04-28 04:59:13 -07:00
kimvde
8968d9fa45 Remove VideoSinkProvider
PiperOrigin-RevId: 752227606
2025-04-28 02:48:06 -07:00
ibaker
170098b400 Fix SSA and SRT to display an in-progress cue when enabling subtitles
Issue: androidx/media#2309
PiperOrigin-RevId: 751424941
2025-04-25 08:27:44 -07:00
jbibik
35303c94a1 [ui-compose] Refactor PlayerSurface to use Kotlin function references
PiperOrigin-RevId: 751424812
2025-04-25 08:25:35 -07:00
claincly
09ce64ec21 Share some code for setting video output
The code for setting the video output is almost the same across both places,
with one callsite supporting less types of video output. I think it's still
better to share the code, to minimize the margin for mistake later.

PiperOrigin-RevId: 751423005
2025-04-25 08:20:33 -07:00
ibaker
8bf658cd79 Remove some hard-coding of file and content URI schemes
PiperOrigin-RevId: 751417429
2025-04-25 08:05:22 -07:00
jbibik
fe59718805 Refactor PlayerSurface Kotlin syntax to avoid variable shadowing
PiperOrigin-RevId: 751414538
2025-04-25 07:54:38 -07:00
ibaker
49b57b8da3 Integrate PlayerControlView with new scrubbing mode
This also tweaks the logic in `Util.shouldShowPlayButton` to
special-case the 'scrubbing' suppression reason. In most cases of
playback suppression (e.g. transient loss of audio focus due to a phone
call), the recommended UX is to show a 'play' button (i.e. the UI looks
like the player is paused). This doesn't look right when scrubbing
since although 'ongoing' playback is suppressed, the image on screen
is constantly changing, so a 'pause' button is kept (i.e. the UI looks
like the player is playing).

PiperOrigin-RevId: 751385521
2025-04-25 06:05:00 -07:00
shahddaghash
20ab1ea8e5 ShadowMediaCodecConfig: Replace "exotest" with "media3" in codec names
The "exotest" prefix was associated with decoders configured for ExoPlayer tests.
However, after adding encoder support to ShadowMediaCodecConfig and migrating transcoding tests to use it, changing the prefix to "media3" makes it more expressive.
Sump files were updated accordingly.

This is a non-functional change.

PiperOrigin-RevId: 751357719
2025-04-25 04:07:49 -07:00
Googler
dae5ebb820 Update DefaultEncoderFactory to set GOP parameters
If set on the requested VideoEncoderSettings, then
these parameters are passed into the MediaFormat
used by the DefaultEncoderFactory to configure the
underlying codec.

PiperOrigin-RevId: 751059914
2025-04-24 11:09:49 -07:00
dancho
910b6ab884 Do not flush c2.mtk decoders when outputting to a videoSink
Flushing a c2.mtk decoder that outputs to a SurfaceTexture often
fails and leaves the SurfaceTexture's BufferQueue in an unrecoverable
state. Release the codec instead.

PiperOrigin-RevId: 751006875
2025-04-24 08:39:46 -07:00
michaelkatz
2e20d35c3d 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 supporting AudioSink#getAudioTrackBufferSizeUs().

This CL specifically removes the bypass for the static default for if rendering to end of stream. For scenarios with an intermediary layer between MediaCodecAudioRenderer and DefaultAudioSink, there can be potential underruns even though at the MediaCodecAudioRenderer it has nothing else to write.

PiperOrigin-RevId: 750986145
2025-04-24 07:26:04 -07:00
tonihei
6ce9fdee8c Add test and formatting fixes 2025-04-24 12:52:22 +01:00
Colin Kho
25feac7664 Add ForwardingTrackSelection to allow access to the underlying instance 2025-04-24 12:26:31 +01:00
ibaker
4189a7c8bd Add ExoPlayer.isScrubbingModeEnabled
This helps integration with `PlayerControlView` in a follow-up change,
where we need to reliably know if scrubbing mode is still enabled (in
case someone else disables it after we enable it).

PiperOrigin-RevId: 750913644
2025-04-24 02:35:14 -07:00
kimvde
d9a92e2586 Remove references to defaultVideoSink from inputVideoSink
This makes the chain structure (InputVideoSinks, then VideoGraph, then
DefaultVideoSink) clearer.

PiperOrigin-RevId: 750910247
2025-04-24 02:22:25 -07:00
kimvde
142496fa16 Remove calls to VideoSink.start/stopRendering from image renderer
These calls are now handled from CompositionPlayer (see fe10ca2c9a)

PiperOrigin-RevId: 750580421
2025-04-23 07:15:22 -07:00
tonihei
50345b03aa Fix memory leak caused by removing wrong period from List
MergingMediaSource started keeping references to all MediaPeriods
it ever created since 191bc094a5 as the cleanup step attempted
to remove the outer merged period from the list instead of the
inner period of child source.

Issue: androidx/media#2338
PiperOrigin-RevId: 750566825
2025-04-23 06:21:48 -07:00
tonihei
a7c897003c Fix bug where a MaskingMediaSource never throws prepare error
We suppressed the direct error throwing ability in <unknown commit>
to avoid throwing errors later in the playlist too early. This
logic got moved to MaskingMediaSource in <unknown commit>, but its
original purpose was no longer needed when the player stopped
calling this method directly in <unknown commit>.

This left a pending bug that any other usage of MaskingMediaSource
(e.g. within AdsMediaSource) no longer forwards source prepare
errors.

Issue: androidx/media#2337
PiperOrigin-RevId: 750537823
2025-04-23 04:13:30 -07:00
kimvde
8483b92620 Fix stuck EffectPlaybackPixelTest
PiperOrigin-RevId: 750504178
2025-04-23 01:55:27 -07:00
kimvde
4d68243158 Only join video graph output in playlist mode.
DefaultVideoSink.join() was called when join() was called on the
InputVideoSink. This makes sense in playlist mode but we shouldn't
join if the VideoGraph output is considered as a single clip.

This change is no-op. Indeed, for CompositionPlayer, the
allowedJoiningTimeMs is set to 0, so that join doesn't have any effect.

PiperOrigin-RevId: 750238085
2025-04-22 10:15:18 -07:00
kimvde
fe10ca2c9a Start and stop video rendering from CompositionPlayer
Before, we were starting and stopping video rendering when the
renderers were started/stopped. This doesn't work for multi-video
sequences though because we shouldn't stop and start rendering at every
MediaItem transition in any of the input sequences.

PiperOrigin-RevId: 750206410
2025-04-22 08:43:21 -07:00
jbibik
ab6b0f6e10 [ui-compose] Eliminated race condition inside button state
A bug was introduced because it was unclear that button state creation and listener registration were not an atomic operation. This happens because the `LaunchedEffect` which starts the listen-to-Player-Events coroutine can be pre-empted with other side effects, including the ones that change something in the Player.

`remember*State` functions create some button state object and initialise it with the correct fresh values pulled out of the Player. The subscription to Player events with a registration of a Listener(via `*ButtonState.observe()`) is not immediate. It *returns* immediately, but is instead scheduled to happen *later*, although within the same Handler message. Other LaunchedEffects could have been scheduled earlier and could take place between the button state creation and listener subscription.

This is not a problem if no changes to the player happen, but if we miss the *relevant* player events, we might end up with a UI that is out of sync with reality (e.g. button enabled/disabled when it should be flipped, icons toggled the wrong way). The way to fix this is to pull the latest values out of the Player on demand upon starting to listen to Player events.

PiperOrigin-RevId: 750183793
2025-04-22 07:31:19 -07:00
tonihei
1c855a8abf Remove unneeded SDK checks
PiperOrigin-RevId: 750172684
2025-04-22 06:48:41 -07:00
Copybara-Service
661effcddd Merge pull request #2323 from DolbyLaboratories:dlb/ac4-profile/dev
PiperOrigin-RevId: 750171380
2025-04-22 06:43:36 -07:00
michaelkatz
d3328456a7 Allow trailing whitespace in RTSP SessionDescription lines
This CL fixes the parser for the RTSP SessionDescription such that it will not choke if there is trailing whitespace in the lines.

PiperOrigin-RevId: 750158624
2025-04-22 05:53:56 -07:00
kimvde
ba97999657 Fix compilation error
Patterns in instanceof are not supported on Java 8.

PiperOrigin-RevId: 750147834
2025-04-22 05:12:58 -07:00