22264 Commits

Author SHA1 Message Date
kimvde
15fa27cd9a Split VideoSink.setStreamTimestampInfo
This is a step towards merging setStreamStartPositionUs with
onInputStreamChanged, which makes sense as the start position can only
change on stream change.

PiperOrigin-RevId: 735309009
2025-03-10 03:24:04 -07:00
kimvde
a4442a6cc5 Always signal stream changes through render control in DefaultVideoSink
This is part of an effort to remove VideoSink.onRendererEnabled,
which is a step towards making the VideoSink interface renderer
agnostic. The plan is to merge onRendererEnabled, setStreamTimestampInfo
and onInputStreamChanged into a single method in VideoSink.

This change is a no-op refactoring

PiperOrigin-RevId: 735293983
2025-03-10 02:19:23 -07:00
tonihei
91ecc16198 Ensure notification is removed when shouldShowNotification==false
We currently combine stopping the FGS and optionally removing the
notification in one method, which unnecessarily gates its logic on
checking the desired foreground state again. This causes a bug where
the notification should be removed (because shouldShowNotification
returns false), but stays visible because the service is allowed
to stay in the foreground and the notification removal code is not
triggered.

#cherrypick

Issue: androidx/media#2211
PiperOrigin-RevId: 735126704
2025-03-09 09:15:29 -07:00
shahddaghash
8702554591 Remove setVideoEffects_failsWithoutLibEffectsDep test
Removed test that attempted to verify behavior when the lib-effect dependency is missing. This is because it fails when adding lib-transformer to test-util dependency. The introduction of lib-transformer brought in lib-effect as a transitive dependency, which conflicted with the test's expectation of the class not being present.

PiperOrigin-RevId: 734547629
2025-03-07 07:18:19 -08:00
shahddaghash
bf2e338fc2 Increase the buffer size for TestUtil.addAudioDecoders/Encoders
This is a step towards unifying ShadowMediaCodecConfig for ExoPlayer and Transcoding tests.

The buffer size for ExoPlayer's CodecConfig is set to 150_000. This is because some test media has samples larger than 100kB. We can increase the buffer size for Transcoding-related codec configurations.

PiperOrigin-RevId: 734297632
2025-03-06 14:54:07 -08:00
shahddaghash
cfbd6c5493 Add ability to force Transformer failure in Robolectric tests
When `forceTransformerToFail` is set to true, the builder will use a `FailingMuxerFactory` which creates a `FailingMuxer` that throws a `MuxerException` when attempting to write sample data. This ensures Transformer will fail as muxers are used for all cases (transmuxing and transcoding).

PiperOrigin-RevId: 734281681
2025-03-06 14:10:01 -08:00
jbibik
8dcfa1afbe [ui-compose] Move ComposeBom from implementation to api
PlayerSurface exposing the Modifier argument means the gradle dependency needs to be stricter

#cherrypick

PiperOrigin-RevId: 734237616
2025-03-06 12:09:48 -08:00
ibaker
96d98a24fc Add MP3 test asset with Xing header but no Table of Contents
These tests show the current behaviour:
1. Without customization: not seekable
2. With 'enable CBR' flag:
   * File length known: seekable but duration very incorrect
   * File length unknown: not seekable (even though the Xing frame
     contains the number of bytes in the mp3 stream).

Follow-up test changes will:
1. Add a test for the cbr-always case for this file (branched from the
   files submitted in this change).
2. Add a new similar test asset with no ToC but with trailing garbage
   bytes, to verify that the length from the Xing frame is used.

Then follow-up implementation changes will update Mp3Extractor to use
duration and byte length from a Xing frame when falling back to CBR
seeking.

Issue: androidx/media#2194
PiperOrigin-RevId: 734164879
2025-03-06 09:01:40 -08:00
michaelkatz
03a0fb4219 Create API enabling use of MediaCodec.BUFFER_FLAG_DECODE_ONLY
If feature is enabled, MediaCodecVideoRenderer will include the `MediaCodec.BUFFER_FLAG_DECODE_ONLY` flag when queuing decode-only input buffers. This flag will signal the decoder to skip the decode-only buffers thereby resulting in faster seeking.

PiperOrigin-RevId: 734152464
2025-03-06 08:25:01 -08:00
shahddaghash
c030e49dd6 Refactor ShadowMediaCodec to be used for transcoding cases
This is a step towards unifying ShadowMediaCodecConfig for ExoPlayer and Transcoding tests.

This change includes extracting encoder/decoder configurtion logic to a static method that can be called by `ShadowMediaCodecConfig.CodecImpl#configure()` and `TestUtil#addCodec()`.

This is a non-functional refactor.

PiperOrigin-RevId: 734137675
2025-03-06 07:38:41 -08:00
tianyifeng
c95516f0ab Fix proguard-rules.txt path reference in DefaultDownloaderFactory
PiperOrigin-RevId: 734111303
2025-03-06 06:04:47 -08:00
kimvde
377136419d MCVR: call VideoSink.setStreamTimestampInfo on stream change
The start position and buffer adjustement are only allowed to change
when the stream changes so it makes more sense to call
setStreamTimestampInfo when the stream changes.

This is part of an effort to simplify stream change notification to the
video sink, to ease implementation of multi sequences preview.

PiperOrigin-RevId: 734062686
2025-03-06 02:55:41 -08:00
kimvde
ab2affa5a5 Remove references to renderer from VideoFrameReleaseControl's Javadoc
This is a step towards removing the assumption that there is only one
sequence and therefore one renderer feeding data to DefaultVideoSink and
VideoFrameReleaseControl.

PiperOrigin-RevId: 734062629
2025-03-06 02:53:58 -08:00
kimvde
7e6089d3aa VideoFrameReleaseControl: merge onEnabled and onProcessedStreamChange
This is a step towards removing the assumption that there is only one
sequence and therefore one renderer feeding data to DefaultVideoSink and
VideoFrameReleaseControl.

This is a no-op refactoring.

PiperOrigin-RevId: 734044100
2025-03-06 01:48:18 -08:00
ivanbuper
f996a5e3e4 Add support for FLOAT_PCM in ChannelMappingAudioProcessor
This was requested in Issue: androidx/media#2191 for playback of Opus and Vorbis
files with more than two channels with a float PCM pipeline.

Also, add ChannelMappingAudioProcessorTest.

PiperOrigin-RevId: 733766680
2025-03-05 09:39:36 -08:00
ibaker
d7574ffd66 Add ParsableByteArray.peekCodePoint and deprecate peekChar(Charset)
This is analagous to `String.codePointAt` and similar methods. By
dealing only in unicode code points, and returning an `int`, we can
avoid having to reason about how to handle UTF-8 code units that
require two UTF-16 code units (each one a Java `char`) to represent
them.

The zero-arg `peekChar` method remains undeprecated, because it behaves
as "you'd expect" when compared to `peekUnsignedByte` (always reads two
big-endian bytes).

PiperOrigin-RevId: 733752645
2025-03-05 08:55:32 -08:00
michaelkatz
d7163534ff Use ExoPlaybackException.MediaPeriodId in prewarming error handling
With using the `MediaPeriodId` from the `ExoPlaybackException`, ExoPlayerImplInternal can set the same id to the renderer group(primary and secondary).

Tested with `ExoPlayerWithPrewarmingRenderersTest` error-based unit tests like `play_errorByPrewarmingSecondaryRendererAfterAdvancingReadingPeriod_doesNotResetPrimaryRenderer`. If the media period was not set in BaseRenderer then the exception would have the incorrect mediaperiod, attribute the error to the non-prewarming renderer, and the test would fail.

PiperOrigin-RevId: 733744777
2025-03-05 08:32:16 -08:00
jbibik
bc9a974e07 Align release notes labels spelling
PiperOrigin-RevId: 733717073
2025-03-05 07:00:00 -08:00
sheenachhabra
06f340005f Add support for video gaps via addGap() API
The gap item earlier meant audio gap.
Now the gap item will be filled with audio, video
or both based upon what all tracks are present in the
Sequence.
If the very first item is a gap then it is filled with
audio only. Support for video gap at start will be added in
a follow up CL.
If the first item is a gap then `forceAudioTrack`
is set to true.

PiperOrigin-RevId: 733422557
2025-03-04 12:23:12 -08:00
ivanbuper
5a0f4c6b3f Add support for constant power mixing in DefaultAudioMixer
This change exposes a flag in `DefaultAudioMixer#Factory` to set whether
to upmix/downmix using constant power or constant gain mixing matrices.

This is a non-functional change.

PiperOrigin-RevId: 733339367
2025-03-04 08:31:40 -08:00
tianyifeng
4ab7ddea93 Add tracksInfoAvailable parameter in DownloadHelper.Callback.onPrepared
PiperOrigin-RevId: 733311800
2025-03-04 06:53:11 -08:00
ivanbuper
c3d734066d Add support for audio fades and gain automation
This change introduces `GainProcessor` to apply gain automation over an
audio stream. The gain automation is defined with a `GainProvider`.
`DefaultGainProvider` implements a basic `GainProvider` that allows
populating a gain automation line additively by adding fade shapes
(`FadeProvider`) at specific positions with specific durations.
`DefaultGainProvider` also implements basic equal gain and equal power
fades.

The current `DefaultGainProvider` implementation does not support adding
fades at relative offsets from the stream end. Users must know the
stream duration in advance and add fades at absolute positions.

PiperOrigin-RevId: 733311314
2025-03-04 06:51:24 -08:00
Googler
b36d0483b2 Skip decode failures in audio fallback test
PiperOrigin-RevId: 733289692
2025-03-04 05:30:52 -08:00
Googler
c044af9063 Move field initialization to constructor in DebugViewShaderProgram
PiperOrigin-RevId: 733279837
2025-03-04 04:50:45 -08:00
kimvde
7a00841323 Remove references to Renderer from VideoFrameReleaseHelper's Javadoc
With multi video sequences previewing in CompositionPlayer,
VideoFrameReleaseHelper won't be connected to a single renderer.
Multiple renderers will feed the VideoGraph at the same time, and the
VideoGraph output will be connected to the VideoFrameReleaseHelper.

PiperOrigin-RevId: 733250499
2025-03-04 02:50:24 -08:00
ibaker
2da814c8ef Add ParsableByteArray tests for \r line endings
PiperOrigin-RevId: 733140077
2025-03-03 19:02:06 -08:00
ibaker
a92cf5311f Add tests for ParsableByteArray.peekChar
This will help to ensure I don't change the behaviour when I add
`peekCodePoint` in a follow-up change.

PiperOrigin-RevId: 733139422
2025-03-03 18:58:37 -08:00
jbibik
cdb112a85a Version bump for Media3 1.6.0-rc01
#cherrypick

PiperOrigin-RevId: 733036051
2025-03-03 13:19:30 -08:00
dancho
7749ff23f6 Add frame extractor performance analysis test
PiperOrigin-RevId: 732972949
2025-03-03 10:32:36 -08:00
jbibik
7419a81aa7 Update release notes for Media3 1.6.0-rc01 release
#cherrypick

PiperOrigin-RevId: 732964311
2025-03-03 10:08:34 -08:00
Googler
814d368d9f Add CookieHandler support to HttpEngineDataSource.
The original behaviour of the `handleSetCookieRequests` is preserved.
A bug is addressed, where it woulld set `Set-Cookie` header in the client request (as opposed to the expected `Cookies`).

PiperOrigin-RevId: 732945338
2025-03-03 09:10:17 -08:00
sheenachhabra
604a8cc0da Add assumeFormatSupported() check in video gaps test
PiperOrigin-RevId: 732928241
2025-03-03 08:13:59 -08:00
ibaker
da8df3fb81 Statically import charset constants in ParsableByteArrayTest
This makes charset-heavy tests easier to read (and I'm going to add some
more in a follow-up change).

Also switch to Truth's `isEmpty()` assertion as prompted by a lint
check.

PiperOrigin-RevId: 732925878
2025-03-03 08:06:10 -08:00
Googler
1e4a10651a Fix resizing in debug preview
PiperOrigin-RevId: 732905018
2025-03-03 06:48:10 -08:00
sheenachhabra
86df7572d2 Create a private util method to create blank frame bitmap
This method will be reused when inserting gaps in
`GapSignalingAssetLoader` in upcoming CL.

PiperOrigin-RevId: 732896566
2025-03-03 06:14:06 -08:00
kimvde
1361d569cd Remove method VideoFrameReleaseControl.onDisabled
This method didn't have any effect because onEnabled, which also sets
the firstFrameState, should always be the next method being called.

PiperOrigin-RevId: 732846722
2025-03-03 02:41:46 -08:00
Googler
8ea49025aa FragmentedMp4Muxer: Update FragmentedMp4MuxerEndToEndTest
Update Test to test all supported mimeTypes in `FragmentedMp4Muxer`.

PiperOrigin-RevId: 732187238
2025-02-28 10:43:50 -08:00
tonihei
796df136d7 Update CapturingAudioSink to dump after audio processors
This ensures data modifications like channel mapping or
bitrate changes are correctly captured in the dump files.

PiperOrigin-RevId: 732129701
2025-02-28 07:21:54 -08:00
tonihei
2088697a19 Add util to obtain AudioManager
AudioManager internally assumes the thread is was created on can be
used as a callback thread. Since the AudioManager is only created
once in the lifetime of an app, we need to make sure its obtained
on a thread that stays alive.

#cherrypick

PiperOrigin-RevId: 732072255
2025-02-28 03:23:10 -08:00
rohks
5f1af46f56 Add contract test for getMetrics() to MediaExtractorContractTest
PiperOrigin-RevId: 732069514
2025-02-28 03:10:01 -08:00
ibaker
f8c3af52e9 Disable subtitlesRespectClipping_multiplePeriods test on API 21
PiperOrigin-RevId: 732065230
2025-02-28 02:54:45 -08:00
jbibik
66ef013cb8 [ui-compose] Better KDoc formatting
#cherrypick

PiperOrigin-RevId: 731712846
2025-02-27 07:07:54 -08:00
tonihei
1ac82d9824 Do not assume default callback for Audio focus requests is main looper
On API < 26, the callback thread couldn't be set and the current compat
code assumes it's always the main thread. This isn't true, however,
because AudioManager uses the thread on which it was first instantiated
anywhere in the app.

#cherrypick

PiperOrigin-RevId: 731696188
2025-02-27 06:03:25 -08:00
jbibik
b465cbc22c [ui-compose] Add KDoc to observe() methods for button states
#cherrypick

PiperOrigin-RevId: 731686021
2025-02-27 05:21:21 -08:00
Copybara-Service
c1a269b79f Merge pull request #2114 from MGaetan89:remove_player_deprecated_next_methods
PiperOrigin-RevId: 731651706
2025-02-27 03:00:46 -08:00
tonihei
a3c9060daa Work around SurfaceView creation issues on API<26 for tests
PiperOrigin-RevId: 731643287
2025-02-27 02:26:47 -08:00
jbibik
addf01b9a8 [ui-compose] Add PlaybackSpeedState to control playbackParameters.speed
A state holder that handles interaction with a UI component that toggles through a range of playback speeds.

[demo-compose] Use PlaybackSpeedState to create PlaybackSpeedTextButton

Add the button to the bottom extra controls.

PiperOrigin-RevId: 731449526
2025-02-26 14:09:12 -08:00
Copybara-Service
366e5eccf8 Merge pull request #2190 from nift4:main
PiperOrigin-RevId: 731316955
2025-02-26 07:57:38 -08:00
ibaker
ca80c001e2 Suppress UnnecessarilyFullyQualified lint in DefaultRenderersFactory
Also only fully-qualify the media3 types, since these are the ones that
are at risk of moving - I don't think `android.os.Handler` is going
anywhere, and doesn't need to be proguard-kept anyway.

PiperOrigin-RevId: 731315177
2025-02-26 07:50:18 -08:00
tianyifeng
e4369b2317 Allow setting time range for adaptive media in DownloadRequest
PiperOrigin-RevId: 731314103
2025-02-26 07:45:55 -08:00