21551 Commits

Author SHA1 Message Date
rohks
91dfaab93f Add getDrmInitData() API to MediaExtractorCompat
Note: `androidx.media3.common.DrmInitData` is returned instead of the platform `android.media.DrmInitData` because the platform class has a package-private constructor, making it impossible to implement the abstract class outside the platform.
PiperOrigin-RevId: 694096542
2024-11-07 06:33:43 -08:00
Copybara-Service
19d71266ec Merge pull request #1277 from consp1racy:patch-1
PiperOrigin-RevId: 694095488
2024-11-07 06:28:45 -08:00
Eugen Pechanec
b956861442 Git: Ignore .cxx intermediate output directory
This is produced by CMake e.g. in FFmpeg extension.
The directory is created in projectDir rather than buildDir.
2024-11-07 10:56:36 +00:00
shahddaghash
f6116a121a Add functionality for Choose local file button
Added the functionality for `Choose local file` button to be able to go and select a local file from the device. The file was then displayed by using ExoPlayer inside PlayerView.

PiperOrigin-RevId: 693756565
2024-11-06 09:36:08 -08:00
shahddaghash
7b9cfd1964 Add basic UI to effect demo app
Added a basic UI to the effect demo app, including a PlayerView, buttons to choose preset input and choose local file, and a button to apply effects. The buttons are currently not implemented, and the app will show a snackbar message when they are clicked.

PiperOrigin-RevId: 693751272
2024-11-06 09:18:44 -08:00
shahddaghash
d164ce221a Change lib-common dependency scope to api in lib-ui
Changed the dependency of `lib-common` in `lib-ui` from an `implementation` dependency to an `api` dependency. This change ensures that classes and interfaces from `lib-common` used in the public API of `lib-ui` are correctly exposed to consumers of `lib-ui`.

For example, `PlayerView implements AdViewProvider` where the latter is from `androidx.media3.common.AdViewProvider`.

PiperOrigin-RevId: 693734349
2024-11-06 08:21:16 -08:00
rohks
3d51b36e99 Fix wrong class name in error message of MediaExtractorCompatTest
PiperOrigin-RevId: 693685232
2024-11-06 05:08:57 -08:00
dancho
31ae260db4 Support alternative sample MIME types in MuxerWrapper
Enable transformer to transmux into alternative sample MIME types.
For example, some Dolby Vision profiles have a backwards-compatible
AVC or HEVC layer. MV-HEVC is backwards compatible with HEVC.

This change enables Transformer to transmux into the backwards compatible
format to improve compatibility with legacy APIs such as
MediaMetadataRetriever.

PiperOrigin-RevId: 693667597
2024-11-06 03:58:02 -08:00
dancho
f9fd8badec Prevent repeated release of the same EGLContext
All instances of PlaybackVideoGraphWrapper use the same
VIDEO_FRAME_PROCESSOR_FACTORY_SUPPLIER which uses the same
DefaultGlObjectsProvider.

Each call to DefaultGlObjectsProvider.release() releases
all previously created EGLContexts.

Lazily create a new DefaultGlObjectsProvider for each
DefaultVideoFrameProcessor (not one per factory).

PiperOrigin-RevId: 693658458
2024-11-06 03:18:42 -08:00
ibaker
ab723fc8ff Mark every media3-cues sample as a keyframe
This format doesn't require any context from previous samples, so every
sample is a keyframe.

PiperOrigin-RevId: 693658370
2024-11-06 03:15:59 -08:00
tonihei
5336d71c22 Add TestPlayerRunHelper run(player).untilFullyBuffered
This simplifies some common test setup steps that rely on
a fully buffered player before making further test progress.

PiperOrigin-RevId: 693651493
2024-11-06 02:45:51 -08:00
Googler
08470140ac Internal
PiperOrigin-RevId: 693418471
2024-11-05 11:24:39 -08:00
tonihei
d38aba92fe Fix flakiness in HlsPlaybackTest and DashPlaybackTest
The tests became more flaky after 76e4abe428, likely because playback
was able to start slightly earlier, exaggerating any existing race
conditions. Fix the flakiness by letting all tests with subtitle
parsing wait until all data is fully loaded before starting to play.

PiperOrigin-RevId: 693380656
2024-11-05 09:42:53 -08:00
michaelkatz
28b75f7d29 Schedule doSomeWork after setVideoOutput
PiperOrigin-RevId: 693374521
2024-11-05 09:22:17 -08:00
ibaker
286273c10e Enable lint in tests for modules that require no fixes
PiperOrigin-RevId: 693313908
2024-11-05 05:40:03 -08:00
tonihei
12cb803486 Compat logic for MediaController.getCustomLayout
When a new media session sets media button preferences, we need to
"translate" them back to a custom layout to ensure the user preferences
are represented as closely as possible when the controller uses the
old button placement rules.

PiperOrigin-RevId: 693306153
2024-11-05 05:06:47 -08:00
tonihei
9fb4ed91b6 Make getCustomLayoutFromMediaButtonPreferences side-effect free
The method currently modifies the input Bundle, but it's easier to
reason about it if the method is side-effect free and the places
that need to modify a Bundle do this after calling the method.

PiperOrigin-RevId: 693288031
2024-11-05 03:54:40 -08:00
tonihei
76e4abe428 Reduce default values for DefaultLoadControl buffer for playback
PiperOrigin-RevId: 693284512
2024-11-05 03:39:16 -08:00
ibaker
6f81b5792b Add 'session extras' and MediaMetadata.durationMs to the stable API
PiperOrigin-RevId: 693279664
2024-11-05 03:17:06 -08:00
ibaker
212bd943f5 Fix lint violations in MediaExtractorCompatTest
I missed these as part of aebf822c3c

PiperOrigin-RevId: 692982120
2024-11-04 08:51:47 -08:00
rohks
278eaf47ad Add log session ID APIs to MediaExtractorCompat
Implemented `setLogSessionId(LogSessionId)` and `getLogSessionId()` methods.

Note: The `LogSessionId` is currently **not** forwarded to `MediaParser`, but this will be addressed once `MediaParser` can be used to configure `MediaExtractorCompat`.
PiperOrigin-RevId: 692945255
2024-11-04 06:38:38 -08:00
jbibik
0270267e08 Add ShuffleButtonState and RepeatButtonState to ui-compose
* Provide a helper Composable for remembering the state instance and launching the listening coroutine that observes the changes in the Player
* Add an example to demo-compose of using Shuffle- and Repeat- ButtonStates inside a Shuffle- and RepeatButton Composable.
* Reformat the MainActivity usage of `Shuffle` and `Repeat` buttons to form extra Player Controls and combine Prev/Play-Pause/Next with Shuffle/Repeat (Minimal controls + Extra controls = `PlayerControls`)

PiperOrigin-RevId: 692939825
2024-11-04 06:12:57 -08:00
rohks
261ca326c5 Move MediaExtractorCompatTest from test/ to androidTest/
The test has been moved to an instrumentation test as it relies on APIs that vary by SDK version. Robolectric’s emulation lacks sufficient realism in some cases, which impacts test accuracy. By using an instrumentation test, we ensure that the tests run in a real Android environment, providing reliable results for SDK-dependent APIs.

PiperOrigin-RevId: 692933259
2024-11-04 05:42:45 -08:00
ibaker
aebf822c3c Enable lint errors in exoplayer tests
Follow-up to 76db936d68

PiperOrigin-RevId: 692925617
2024-11-04 05:08:34 -08:00
sheenachhabra
c3e72a87e5 Make error messages unique in Boxes.java
PiperOrigin-RevId: 692920946
2024-11-04 04:49:27 -08:00
ibaker
af1c13524c Enable lint in lib-common tests
Also move the `lint.xml` config which disables the `NewApi` check from
`lib-session` to the existing top-level file, and limit it to cover all
Robolectric tests by path matching.

Follow-up to 76db936d68

PiperOrigin-RevId: 692913646
2024-11-04 04:16:39 -08:00
shahddaghash
a8ed6494c3 Create an empty module for Effect demo
The new demo module aims to showcase different `Effect` capabilities.

PiperOrigin-RevId: 692912895
2024-11-04 04:12:55 -08:00
dancho
bd90ef38b0 MCVR.hasSurfaceForCodec considers VideoSink
This change keeps getSurfaceForCodec and hasSurfaceForCodec in sync.
Before this change when ExoPlayer is configured with setVideoEffects
and no display surface, codecs that need Set Output Surface Workaround
would not be initialized because hasSurfaceForCodec always returns false

PiperOrigin-RevId: 692900899
2024-11-04 03:17:54 -08:00
Copybara-Service
aebda58314 Merge pull request #1829 from colinkho:ssms-custom-exec-2
PiperOrigin-RevId: 692897382
2024-11-04 03:02:46 -08:00
rohks
d8ad18383d Optimize sample metadata handling in MediaExtractorCompat
Restructured sample metadata management in `MediaExtractorCompat` to maintain a queue of `SampleMetadata` objects, each containing `timeUs`, `flags`, `size`, and `trackIndex`, rather than storing only track indices.

Introduced a pooling mechanism for `SampleMetadata` to reduce object allocation and improve memory efficiency. The new `SampleMetaDataQueue` centralizes metadata for easier access and management, eliminating the need to allocate a buffer or peek into the `SampleQueue` to retrieve sample metadata.

This change does not change existing behavior, it optimizes the internal structure, and existing tests already verify the relevant APIs.

PiperOrigin-RevId: 692285581
2024-11-01 14:07:11 -07:00
ivanbuper
7edbaa3f2c Use sample-aligned speed changes in SpeedChangingAudioProcessor
This CL adds utility methods to obtain sample-aligned timestamps from a
`SpeedProvider` to solve in a unified way the issues arising from
conversions between sample positions and microseconds.

The new utility methods will also help with the implementation of a
static method like `getDurationAfterProcessorApplied()` that will remove
the need for thread synchronization between the video and audio pipeline
for speed changing effects.

PiperOrigin-RevId: 692233318
2024-11-01 11:09:18 -07:00
ivanbuper
0b1695124b Bump Media3 to 1.5.0-rc01
#cherrypick

PiperOrigin-RevId: 692221696
2024-11-01 10:30:45 -07:00
tonihei
06718c5df3 Fix position tracking bug for inaccurate audio processors
If audio processors report a drifting position, we currently update
the media position parameters to correct this drift. However, this
means we pass in the wrong value to
audioProcessorChain.getMediaDuration, which reuqires the time since
the last flush.

To fix this problem, we can instead save the drift seperately and
apply it where needed.

PiperOrigin-RevId: 692202219
2024-11-01 09:28:15 -07:00
claincly
b0c6106882 Fix trim optimization logic when edit lists exist
Also makes muxer shift the first video timestamp to zero, if it's not.

The trim position should respect the media timeline.

For example in a video that is 10s long (without edit list), if an edit list
adds 1_000ms to each video sample, and trimming 100ms, here's the expected:

- The video duration is 10.9s (`10s + 1s edit - 0.1s trim`)
- The first video frame time would be at 0.9s (`1s edit - 0.1s trim`)

PiperOrigin-RevId: 692187399
2024-11-01 08:36:08 -07:00
ivanbuper
38e1efafc2 Prepare RELEASENOTES.md for Media3 1.5.0-rc01 release
This change also fixes two notes added incorrectly onto the previous
beta01 release section.

#cherrypick

PiperOrigin-RevId: 692169335
2024-11-01 07:32:10 -07:00
Copybara-Service
4910b2cdc0 Merge pull request #1225 from Kekelic:support-for-parsing-rtsp-packets-with-header-extension
PiperOrigin-RevId: 692156233
2024-11-01 06:35:16 -07:00
tonihei
544d7aa2dc Annotate parameters in RepeatModeUtil
PiperOrigin-RevId: 692129684
2024-11-01 04:33:31 -07:00
jbibik
1b302e879a Add PreviousButtonState and NextButtonState to ui-compose
* Provide a helper Composable for remembering the state instance and launching the listening coroutine that observes the changes in the Player
* Add an example to demo-compose of using Previous- and Next- ButtonStates inside a Previous- and NextButton Composable.
* Reformat the MainActivity usage of `Previous`, `PlayPause`, `Next` buttons to form Minimal Player Controls

PiperOrigin-RevId: 691943147
2024-10-31 14:52:38 -07:00
jbibik
676a3872a5 Add PlayPauseButtonState to ui-compose
Provide a helper Composable for remembering the state instance and launching the listening coroutine that observes the changes in the Player

Add an example to demo-compose of using PlayPauseButtonState inside a PlayPauseButton Composable.

The smart State object has been deemed a preferred solution over collecting Flows due to queuing/timing/buffering limitations. Instead, it uses the new `Player.listen` suspending extension function to catch the relevant events.

PiperOrigin-RevId: 691879975
2024-10-31 11:42:14 -07:00
ivanbuper
f991e1f023 Move release note in 1.5.0-beta01 to "Unreleased" section
The item was incorrectly added to the beta01 section in 2a49ffcb23.

#cherrypick

PiperOrigin-RevId: 691876672
2024-10-31 11:34:46 -07:00
microkatz
0e020f778c Added release note 2024-10-31 12:42:03 +00:00
microkatz
71bc177e39 Format with google-java-format 2024-10-31 11:57:47 +00:00
Kekelic
47f4dabb98 Fix documentation and improve readability of unit test with rtpDataWithHeaderExtension example 2024-10-31 11:57:47 +00:00
Kekelic
84f8beb884 Remove saving unnecessary header extension data 2024-10-31 11:57:47 +00:00
Kekelic
5a8a250a1a Add reading length of extension payload from header extension in RtpPacket 2024-10-31 11:57:47 +00:00
Kekelic
1ecb7c3fbf Format changes 2024-10-31 11:57:46 +00:00
Kekelic
7dd428534e Change RtpPacket class to parse header extension if exists 2024-10-31 11:57:46 +00:00
ibaker
b5db8a6cbe Fix empty LoadEventInfo.uri passed to onLoadStarted
This affects both `AnalyticsListener` and `MediaSourceEventListener`

This was introduced by d051b4b993

Also fix a missing 'load started' event for HLS media playlists (this
was also introduced by d051b4b993).

PiperOrigin-RevId: 691580183
2024-10-30 15:52:48 -07:00
jbibik
6cbf77b3f0 Refactor shouldEnablePlayPauseButton out of PlayerControlView into Util
PiperOrigin-RevId: 691502799
2024-10-30 11:59:25 -07:00
rohks
2b27e33784 Refactor OpusDecoderTest to use OpusLibrary.isAvailable()
Replaced the custom `LibraryLoader` instance with `OpusLibrary.isAvailable()` to verify the library loading. This simplifies the code by leveraging the existing library loading mechanism.

#cherrypick

PiperOrigin-RevId: 691457871
2024-10-30 10:02:46 -07:00