21347 Commits

Author SHA1 Message Date
Gaëtan Muller
0c564004c4 Remove unnecessary @SdkSuppress annotation 2024-07-24 16:17:01 +01:00
Gaëtan Muller
b84a63d318 Fix deprecation message 2024-07-24 16:17:01 +01:00
Gaëtan Muller
7406b78fbc Update javadoc 2024-07-24 16:17:01 +01:00
Gaëtan Muller
28edfcbb69 Remove unnecessary SDK_INT checks 2024-07-24 16:17:01 +01:00
Gaëtan Muller
7289764a65 Remove unnecessary @RequiresApi 2024-07-24 16:17:00 +01:00
Gaëtan Muller
71b8c32a6f Remove Multidex 2024-07-24 16:17:00 +01:00
Gaëtan Muller
e1633ff03b Remove unnecessary targetApi 2024-07-24 16:17:00 +01:00
Gaëtan Muller
64eedceb8c Use project.ext.minSdkVersion everywhere 2024-07-24 16:17:00 +01:00
ibaker
4fc66f42d6 Move OpusDecoderTest from /test/ (Robolectric) to /androidTest/
The dependency on the native `opusV2JNI` library doesn't work from
Robolectric, so the `assumeTrue` statements in this test always fail,
and the tests are always skipped. Moving it to an instrumentation test
allows the native library to be successfully loaded, and the test to be
run.

PiperOrigin-RevId: 655570129
2024-07-24 08:11:13 -07:00
tianyifeng
d70ff7e4d2 Fix the release notes for 1.4.0 stable release
#cherrypick

PiperOrigin-RevId: 655558346
2024-07-24 07:31:39 -07:00
kimvde
da4c962e09 Rename VideoSink methods
This is following a renaming of registerInputFrame to handleInputFrame.
- queueInputBitmap is renamed to handleInputBitmap for consistency with
  handleInputFrame.
- registerInputStream is renamed to onInputStreamChanged for consistency
  with media3 method names.

PiperOrigin-RevId: 655529699
2024-07-24 05:56:17 -07:00
ktrajkovski
a1f20de3a9 Import a library for a Java clarity fix.
PiperOrigin-RevId: 655488843
2024-07-24 02:38:00 -07:00
dancho
7103f21da9 Use WORKING_COLOR_SPACE_DEFAULT in multi-sequence compositions
Build upon Transformer.videoFrameProcessorFactory in MultipleInputVideoGraph
Check that Transformer.videoFrameProcessorFactory is DefaultVideoFrameProcessor
for multi-input video

Fixes https://github.com/androidx/media/issues/1509

PiperOrigin-RevId: 655232381
2024-07-23 11:14:12 -07:00
dancho
9a42d03466 Enable experimentalAdjustSurfaceTextureTransformationMatrix
PiperOrigin-RevId: 655231134
2024-07-23 11:11:14 -07:00
ktrajkovski
2793ba845e Implement IamfDecoder and LibiamfAudioRenderer configuration.
PiperOrigin-RevId: 655212678
2024-07-23 10:23:48 -07:00
Googler
b77f1d0f99 Add support for Audio Vorbis codec in Mp4Muxer.
Update esdsBox to support muxing of files encoded with Vorbis audio codec .

PiperOrigin-RevId: 655159074
2024-07-23 07:39:26 -07:00
rohks
0ac90855b4 Use getDeclaredLength() in setDataSource for AssetFileDescriptor
Aligns `MediaExtractorCompat` with platform behavior by using `getDeclaredLength()`
instead of `getLength()` when setting the data source. This ensures compatibility
with asset files where the length is not predefined, even though it may result
in reading across multiple logical files when backed by the same physical file.

PiperOrigin-RevId: 655153390
2024-07-23 07:17:52 -07:00
dancho
1797359950 Destroy EGLSurface immediately by focusing a placeholder surface
eglDestroySurface only destroys the surface when it's made not current.
Pass the placeholder surface in FinalShaderProgramWrapper and use it
when destroying eglSurface.

PiperOrigin-RevId: 655139661
2024-07-23 06:22:08 -07:00
dancho
9c075b692e Ensure EGLSurface is released on GL thread
Add VideoFrameProcessingTaskExecutor.invoke() method that blocks until
Task has executed on GL thread.
Use that for FinalShaderProgramWrapper.setOutputSurfaceInfo

PiperOrigin-RevId: 655119768
2024-07-23 04:59:59 -07:00
Googler
3c5c81fc3e BoxesTest: Add default format builders
Move the common initialization code for format builder into separate methods to reduce code duplication.

PiperOrigin-RevId: 655118764
2024-07-23 04:54:32 -07:00
kimvde
225d336713 Remove VideoSinkProvider parameter from renderers
PiperOrigin-RevId: 655073481
2024-07-23 01:41:30 -07:00
tonihei
6147050b90 Delay flush after AudioTrack pause to ramp down volume
AudioTrack automatically ramps down volume when pausing. However,
when this happens as part of a AudioSink.flush() operation, we
need to postpone the actual flush() until the ramp down finished
in the audio system. Otherwise audio is just cut off, creating pop
sounds.

Delaying the release is fine now, because DefaultAudioSink starts
creating a new track immediately without waiting for the previous
track to be released.

Also using the opportunity to add more comments about related quirks
of the AudioTrack flush/release handling for more context.

PiperOrigin-RevId: 654794818
2024-07-22 09:58:53 -07:00
bachinger
225ad482b1 Add EXTRAS_KEY_DOWNLOAD_STATUS to MediaContants
This was used in media1 `MediaItemDescription` to indicate the download
status of a media item. When connected to a legacy
`MediaBrowserServiceCompat` the Media3 browsers converts the legacy
media item to a Media3 `MediaItem` and converts the extras of
`MediaDescriptionCompat.extras` to `MediaMetadata.extras`.

#cherrypick

PiperOrigin-RevId: 654625502
2024-07-21 23:41:37 -07:00
tonihei
0a8ca18305 Create new AudioTrack without waiting for previous released tracks
We currently wait until a previous AudioTrack from the same
DefaultAudioSink is released on a background thread before attempting
to initialize a new AudioTrack. This is done to avoid issues where
the releasing track blocks some shared audio memory, preventing a new
track from being created.

The current solution has two main shortcomings:
 - In most cases, the system can easily handle multiple AudioTracks
   and waiting for the release just causes unnecessary delays (e.g.
   when seeking).
 - It only waits for a previous track from the same DefaultAudioSink,
   not accounting for any other tracks that may be in the process of
   being released from other players.

To improve on both shortcomings, we can
 (1) move the check for "is releasing tracks and thus may block shared
 memory" to the static release infrastructure to be shared across all
 player instances.
 (2) optimistically create a new AudioTrack immediately without waiting
 for the previous one to be fully released.
 (3) extend the existing retry logic that already retries failed
 attempts for 100ms to only start the timer when ongoing releases are
 done. This ensures we really waited until we have all shared resources
 we can get before giving up completely. This also acts as a replacement
 for change (2) to handle situations where creating a second track is
 genuinely not possible. Also increase threshold to 200ms as the new
 unit test is falky on a real device with just 100ms (highlighting that
 the device needed more than 100ms to clean up internal resources).

PiperOrigin-RevId: 654053123
2024-07-19 10:41:17 -07:00
bachinger
076bc451f2 Update Kotlin Gradle plugin to version 1.9.10.
According to b/292763081 the build failure
`unresolved reference: addLast` in the session-demo is caused
by a bug in the Kotlin compiler 1.9.0 to which we depend.

Bumping the Kotlin plugin version to 1.9.10 which is the next
above 1.9.0 as listed in [1], the build problem is resolved.

Further, the Kotlin extension compiler version is set to 1.5.3
to make compose work with Kotlin 1.9.10 (see [2] for the
Kotlin/Compose compatibility map).

[1] https://kotlinlang.org/docs/releases.html#release-details
[2] https://developer.android.com/jetpack/androidx/releases/compose-kotlin

PiperOrigin-RevId: 654030537
2024-07-19 09:33:41 -07:00
tonihei
50f9f35353 Guard timeline access in ImaSSAIMS against empty timelines
All methods check if the player is currently handling the ad source
by calling isCurrentAdPlaying(). This method was missing a check
for empty timelines that throws an exception when trying to access
a non-existent period.

Also add this check to two methods that assume the current item
is the ads source, but didn't check it yet.

PiperOrigin-RevId: 653963557
2024-07-19 04:27:36 -07:00
rohks
0def3b215c Add APIs to set data source using AssetFileDescriptor & FileDescriptor
Introduced three `setDataSource` APIs in `MediaExtractorCompat`, enabling the use of `AssetFileDescriptor` and `FileDescriptor` to set the data source.

PiperOrigin-RevId: 653957035
2024-07-19 04:00:44 -07:00
tofunmi
1e28755b4a CompositionPlayer: clip silence with media source
PiperOrigin-RevId: 653667116
2024-07-18 10:17:29 -07:00
tianyifeng
3c9332bb48 Update media3 version for 1.4.0 stable release
#cherrypick

PiperOrigin-RevId: 653654999
2024-07-18 09:43:16 -07:00
dancho
f8bdb7e59f Fix division by zero in MuxerWrapper
PiperOrigin-RevId: 653644998
2024-07-18 09:18:34 -07:00
tianyifeng
1cbcd20851 Fix the release notes for 1.4.0 stable release
#cherrypick

PiperOrigin-RevId: 653640574
2024-07-18 09:06:22 -07:00
jbibik
4ba7fd0ace Fix javadoc formatting from backticks to tags
PiperOrigin-RevId: 653629763
2024-07-18 08:34:56 -07:00
tonihei
f7a726bb11 Add MediaCodec loudness controller for API35+
This controller connects the audio output to the MediaCodec so
that it can automatically propagate CTA-2075 loudness metadata.

PiperOrigin-RevId: 653628503
2024-07-18 08:31:14 -07:00
sheenachhabra
a52df6d29e Make Mp4MoovStructure.moov() method static
Creating a moov box is same as creating any other box so
there is no particular need to have a separate class for this.
In a follow up CL the method will be moved into Boxes.java along with
other box creation methods.

Made nit changes in the final fields ordering to match with
constructor parameter ordering.

PiperOrigin-RevId: 653602558
2024-07-18 06:50:42 -07:00
samrobinson
570be3680c Reduce test flakes by adding effects to multi-sequence playback test.
This test is flaky at p4head, because CompositionPlayer has no logic to
ensure a specific input is used to configure the audio graph. Depending
on which sequence registers input first, it changes the output format
of the media.

By setting effects on the 2nd sequence, both inputs are the same format
and this flakiness is avoided in the test.

PiperOrigin-RevId: 653582441
2024-07-18 05:40:49 -07:00
samrobinson
e28270b4cb Add preview tests for duration wrt clipping and speed adjustment.
PiperOrigin-RevId: 653569415
2024-07-18 04:43:41 -07:00
tonihei
54f5e0729e Support detached surface mode from API 35
This replaces the existing PlaceholderSurface mode with a more
efficient solution that doesn't require a GL texture or a new
thread.

PiperOrigin-RevId: 653537596
2024-07-18 02:29:57 -07:00
sheenachhabra
51d27d7575 Merge Boxes.moov() into Mp4MoovStucture.moov()
Boxes.moov() simply wraps the subboxes and this logic can be
put into main method which has all the logic of creating moov box.
This is to eventually move Mp4MoovStucture.moov() into
Boxes.java where all other box creation methods are already present.

PiperOrigin-RevId: 653319292
2024-07-17 12:15:44 -07:00
Googler
01dda6d3e5 Add support for Opus audio codec.
Implement dOpsBox to provide support for Opus audio codec

PiperOrigin-RevId: 653288049
2024-07-17 10:51:43 -07:00
tianyifeng
68e8d9cb68 Merge release notes for media3 1.4.0 stable release
#cherrypick

PiperOrigin-RevId: 653261278
2024-07-17 09:38:23 -07:00
tonihei
a86b5f065f Move release note to right section
The change is purely video releated.

PiperOrigin-RevId: 653229546
2024-07-17 07:41:15 -07:00
samrobinson
d0afb96c40 Implement repeat mode for CompositionPlayer.
-----

Context:
* Each sequence is wrapped as a single MediaSource, each being played
by an underlying ExoPlayer.
* Repeat mode is typically implemented in Players as a seek to the next
item in the playlist.

-----

This CL:

Repeat mode is triggered by listening for when the main input player
sees a play when ready change due to the end of the media item.

There is a slight delay at the end of the playback, before it repeats.
Setting repeat mode on the underlying players addresses this, but means
that the players will seek without waiting for the CompositionPlayer,
and as such previewAudioPipeline does not get the correct signals
around blocking/flushing.

PreviewAudioPipeline - The seek position can validly be C.TIME_UNSET,
however preview pipeline did not handle this case.

CompositionPlayer getContentPosition is given (through a lambda) as a
supplier to the State object, which means any comparisons between
previous/new state for this value does not work. In SimpleBasePlayer,
there is logic to use the positionDiscontinuityPositionUs for the
position change (see getPositionInfo called from
updateStateAndInformListeners), however this logic is not considered in
getMediaItemTransitionReason, so a condition needed to be added for
this case.

-----

Tests:
* Dump files clearly show the position and data is repeated.
* Assertions on the reasons for transitions or position
discontinuities.
PiperOrigin-RevId: 653210278
2024-07-17 06:22:02 -07:00
tofunmi
29a2486ce3 implement getDurationAfterEffectApplied in TimestampAdjustment Effect
PiperOrigin-RevId: 653206245
2024-07-17 06:07:27 -07:00
dancho
c05a5c6237 Rollback of 9151dbf9e6
PiperOrigin-RevId: 653192624
2024-07-17 05:08:52 -07:00
Googler
951f296851 Add support for 3gpp h263 codec in Mp4Muxer.
Implement d263Box to provide support for muxing video encoded with the h263 codec.

PiperOrigin-RevId: 653188633
2024-07-17 04:53:28 -07:00
ibaker
76db936d68 Enable lint errors in session tests
Also resolve some failures.

Lint checks [aren't enabled in tests by default](http://groups.google.com/g/lint-dev/c/rtjVpqHmY0Y).

This change suppresses `NewApi` failures in Robolectric tests because
these tests only run at 'target SDK' by default (currently 30), but the
lint doesn't understand this and so flags spurious issues with API
usages below this.

PiperOrigin-RevId: 653172059
2024-07-17 03:50:05 -07:00
ibaker
3b8ea4a412 Allow negative presentation time in ReorderingSeiMessageQueue
PiperOrigin-RevId: 653170404
2024-07-17 03:43:34 -07:00
simakova
e78802d0d8 Update recommendation on setting frame rate for images
PiperOrigin-RevId: 653167049
2024-07-17 03:31:57 -07:00
dancho
e94ee03cd0 Add 1920 and 1088 as guesses for surface texture crop fix
Some devices always allocate 1920x1088 pixel buffers,
regardless of video resolution

PiperOrigin-RevId: 653148028
2024-07-17 02:16:46 -07:00
tofunmi
1e43404468 Correct typo
PiperOrigin-RevId: 653137432
2024-07-17 01:35:01 -07:00