22485 Commits

Author SHA1 Message Date
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
Copybara-Service
4d9f47920a Merge pull request #2285 from MGaetan89:deprecate_util_sdkint
PiperOrigin-RevId: 750142132
2025-04-22 04:53:39 -07:00
tonihei
0e0553d150 Remove leftover release notes line
The change in the demo app was part of 1.6.0 and we don't need to
document demo app changes.

PiperOrigin-RevId: 750120001
2025-04-22 03:15:55 -07:00
dancho
d26fd583ea More comprehensive EventLogger in CompositionPlayer
* Add an EventLogger to the top-level CompositionPlayer
* Label the sequence player EventLoggers differently

PiperOrigin-RevId: 750104688
2025-04-22 02:11:33 -07:00
Googler
b6f0045840 Add group of pictures (GOP) parameters to VideoEncoderSettings
These parameters enable and configure B frame encoding
for supported encoders.

PiperOrigin-RevId: 749930859
2025-04-21 15:06:40 -07:00
Googler
dc9d023e85 Dolby-Vision: Add dolby-vision codec support in Mp4Muxer
Add dolby vision with hevc and avc codec in Mp4Muxer according to Dolby
ISO media format standard. As initialization data is required for creation of dovi box, CSD is populated in BoxParser.

PiperOrigin-RevId: 749765993
2025-04-21 05:10:22 -07:00
bachinger
d0833c4e7c Make HlsInterstitialsAdsLoader resumable
This allows the app to store the ad playback state and then
when starting again, allow them to resume with the same
ad playback state. This way, users don't have to watch the same
ads twice if/when playback was interrupted. For instance, when the
app was put into background and then is foregrounded again.

PiperOrigin-RevId: 748737832
2025-04-17 10:56:14 -07:00
tianyifeng
7f6ddef502 Enable DownloadHelper to create DownloadRequest with timeRange
PiperOrigin-RevId: 748722156
2025-04-17 10:14:04 -07:00
tonihei
c4c3e5e0c8 Move getMaximumEncodedRateBytesPerSecond to a shared public util
This makes it more easily reusable.

Issue: androidx/media#2339
PiperOrigin-RevId: 748713531
2025-04-17 09:52:18 -07:00
tonihei
ea837aa718 Remove release notes
Deprecatations don't need to be noted
2025-04-17 16:02:33 +01:00
Gaëtan Muller
340264e376 Update release notes 2025-04-17 15:59:01 +01:00
Gaëtan Muller
9b2e1cfca0 Deprecate Util.SDK_INT in favor of Build.VERSION.SDK_INT
`Util.SDK_INT` was introduced to be able to simulate any SDK version during tests.
This is possible by using Robolectric's `@Config(sdk)` annotation.
All usages of `Util.SDK_INT` have been replaced by `Build.VERSION.SDK_INT`.

This is a similar change to what was done in #2107.
2025-04-17 15:55:23 +01:00
shahddaghash
52db3a240d Clear cached encoders in ShadowMediaCodecConfig#after()
Instead of calling it in the tests setup, the change modifies ShadowMediaCodecConfig#after() method to call EncoderUtil#clearCachedEncoders().

PiperOrigin-RevId: 748625111
2025-04-17 03:51:13 -07:00
bachinger
a64d51c909 Fix NullPointerException in MediaBrowserImplLegacy
PiperOrigin-RevId: 748312932
2025-04-16 09:05:55 -07:00
tonihei
5d540acbeb Make implementation of adLoadTimeoutRunnable safer
We currently start the timeout as soon as the player enters
the target ad, but that ad hasn't loaded yet (= at the point
where we actively start waiting for it). And then we try to
clear the timeout at various places that mean we are no longer
waiting for this ad. This is very error-prone though because
there are a lot of places in the AdTagLoader that change the
AdPlaybackState and could mark the ad as skipped, failed or
loaded.

A much less error-prone way of clearing the timeout is not
even try to find all places that may revert the wait condition
and instead just check if we are still waiting at the point
of executing the timeout message.

PiperOrigin-RevId: 748291720
2025-04-16 07:49:53 -07:00
bachinger
fd8547fc3a Ensure ad playback state and timeline are in sync
Before this change a timeline update of a live content
source has produced a timeline refresh before passing
the timeline to the ads loader. When in such a case
the ads loader updates the ad playback state, a
second timeline refresh is trigger that then
includes the updated ad data also. This can result
in a timeline being pulished with stale ad information.

This change prevents this by introducing a boolean
return value that requires the ads loader to signal
whether the ad playback state has been passed back
to the source. This ensures that an update of
timeline and ad playback state produces a single
timeline update and is published in sync.

PiperOrigin-RevId: 748288650
2025-04-16 07:38:23 -07:00
michaelkatz
f860fb156e Cleanup CapturingRenderersFactory to use createMediaCodecVideoRenderer
PiperOrigin-RevId: 748288415
2025-04-16 07:36:13 -07:00
aquilescanta
002ae1473b Fix some linter warnings
PiperOrigin-RevId: 748003827
2025-04-15 13:39:49 -07:00
simakova
4e8de288a5 Fix a crash in effect demo when parsing floats
Change a broken link to a remote video

PiperOrigin-RevId: 747925636
2025-04-15 10:19:57 -07:00
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