20923 Commits

Author SHA1 Message Date
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
rohks
ded66debc3 Retry alternative addresses on timeout in SNTP client
Changed the default timeout for SNTP requests to 1 second.

Issue: androidx/media#1540
PiperOrigin-RevId: 652897579
2024-07-16 10:38:10 -07:00
ibaker
7f304092ae Explicitly set the group ID
This avoids it being implicitly set from the `rootProject.name`

PiperOrigin-RevId: 652879619
2024-07-16 09:47:17 -07:00
tonihei
b4975a1b49 Remove unused field in MediaCodecAdapter
The field is always 0 as the only publicly accessible creator
methods set it to zero in all cases.

PiperOrigin-RevId: 652858810
2024-07-16 08:42:48 -07:00
dancho
f68cf30791 Change ExportTest assertion to allow mismatching level
Due to differences in MediaCodec behavior between minor Android
versions, this test was flaky.

PiperOrigin-RevId: 652841512
2024-07-16 07:55:34 -07:00
samrobinson
1c3fe20826 Handle no supported encoder & muxer mime types in the Encoder factory.
PiperOrigin-RevId: 652825117
2024-07-16 07:03:25 -07:00
ibaker
99679645fc Add a test for MediaCodecRenderer handling of IllegalStateException
This is a regression test for the bug introduced in bb9ff30c3a
which was manually spotted and fixed in 0d2bf49d6a.

Reverting the fix causes this test to fail.

This test is a bit hacky because we have to munge the stack trace of
the `IllegalStateException` to make it look like it was thrown from
inside `MediaCodec`. We deliberately do this 'badly' (e.g. using
`fakeMethod`) to avoid a future reader being confused by a
fake-but-plausible stack trace.

PiperOrigin-RevId: 652820878
2024-07-16 06:47:31 -07:00
tonihei
d4c6e39dfb Further unapplied rotation clean-up
Now the value is guaranteed to be zero (see bb9ff30c3a), we can
remove the rotation handling for it in the UI module. We can also
enforce the documentation more clearly by not even setting the
value to anything other than zero.

PiperOrigin-RevId: 652772091
2024-07-16 03:35:46 -07:00
ktrajkovski
104fcc1c76 Add skeleton of the IAMF JNI wrapper for the native decoder in libiamf.
PiperOrigin-RevId: 652761237
2024-07-16 02:54:21 -07:00
rohks
c60baabb1c Allow changing SNTP client timeout
Added a method to set the timeout for the SNTP request.

Also changed the default timeout to 5s instead of 10s as it seemed quite high.

Issue: androidx/media#1540
PiperOrigin-RevId: 652566008
2024-07-15 12:36:30 -07:00
tonihei
0d2bf49d6a Partially revert MediaCodecException detection
The change in bb9ff30c3a removed the detection util completely,
but even on API21+, the codec exceptions can be thrown as
IllegalStateException and we should reinstate this check to
correctly classify the exceptions.

PiperOrigin-RevId: 652557091
2024-07-15 12:06:22 -07:00
tianyifeng
ec1954c1d5 Release all ListenerHolders when clearing ListenerSet
When removing one listener from the `ListenerSet`, we release the corresponding `ListenerHolder`, which prevents the event queued or sent later than the removal from being invoked. We should also do this in the method `ListenerSet.clear()` where every listener is removed.

PiperOrigin-RevId: 652535216
2024-07-15 10:59:13 -07:00
sheenachhabra
d747f38f59 Skip TransformerPauseResumeTest on vivo 1901
The process crashes unexpectedly on vivo devices.
When test is run individually it completes successfully.

PiperOrigin-RevId: 652496852
2024-07-15 08:56:37 -07:00
ibaker
bb9ff30c3a Remove dead code related to MediaCodec now minSdk is 21
This removes several workarounds that are no longer needed, including
`codecNeedsMonoChannelCountWorkaround` which has been permanently
disabled since the (incomplete) minSdk 19 clean-up in fb7438378d.

PiperOrigin-RevId: 652495578
2024-07-15 08:51:35 -07:00
Googler
1bb8d5f956 Update internal reference.
PiperOrigin-RevId: 652448337
2024-07-15 05:34:32 -07:00
dancho
bfe4824bfd Rollback of 9151dbf9e6
PiperOrigin-RevId: 652443920
2024-07-15 05:14:58 -07:00
Googler
11ca78761e Add support for 3gpp amr-nb audio codec.
To support AMR audio codec(audio/3gpp) add `0x81FF` mode to create damrBox.

Add unit test and an Android end to end test.

PiperOrigin-RevId: 652438693
2024-07-15 04:48:28 -07:00
tofunmi
4da1e26206 Take effects in account when calculating presentationDurationUs
PiperOrigin-RevId: 652425099
2024-07-15 03:40:59 -07:00
andrewlewis
4b7cc80593 Handle muxing with timestamps offset from zero in wrapper
Sources (for example media projection) can populate the `Surface` from
`SurfaceAssetLoader` with timestamps that don't start from zero. But
`MuxerWrapper` assumes the latest sample timestamp can be used as the duration
when it calculates average bitrate and notifies its listener.

This can cause a crash because the calculated average bitrate can be zero if
the denominator duration is large enough.

Use the max minus first sample timestamp across tracks instead to get the
duration.

Side note: the large timestamps from the surface texture when using media
projection arrive unchanged (apart from conversion from ns to us) in effect
implementations and in the muxer wrapper (and are passed to the underlying
muxer). The outputs of media3 muxer and the framework muxer are similar.

PiperOrigin-RevId: 652422674
2024-07-15 03:30:26 -07:00
tonihei
c510ab81bb Update compileSdk to 35
This should have no influence on app behavior and other policies
and just allows code to depend on new API 35 platform symbols.

PiperOrigin-RevId: 652414026
2024-07-15 02:45:55 -07:00
ibaker
268c8cf6a2 Remove dead code from MediaStyleNotificationHelper now minSdk is 21
Tested using session demo app on API 21 emulator, and checked
notification layout looked correct.

PiperOrigin-RevId: 652403407
2024-07-15 01:56:37 -07:00
tonihei
e96ca5a242 Decouple displaySurface from placeholderSurface
We currently use displaySurface == placeholderSurface IF codec != null
as a signal that the codec is configured with a placeholder. In the
future, this placeholder might not be needed and we can decouple this
state a bit better by leaving displaySurface == null in this case and
only using placeholderSurface instead of null when setting a Surface
to the codec.

PiperOrigin-RevId: 652391729
2024-07-15 01:04:48 -07:00
ibaker
d035b745cd Remove dead code from ExoPlayerImpl now minSdk is 21
PiperOrigin-RevId: 651815091
2024-07-12 10:27:49 -07:00
ibaker
6a9ff95bf0 Bump minSdk to 21 and remove resulting simple dead code
All other AndroidX libraries have already increased their min SDK to
21.

This change renames private symbols to remove `V21` suffixes and
similar, but doesn't change public or protected symbols with similar
names, to avoid needless breakages/churn on users of the library.

Some of the dead code removal is more complex, so I've split it out
into follow-up changes to make it easier to review.

PiperOrigin-RevId: 651776556
2024-07-12 08:11:01 -07:00
ibaker
5fa9985ce6 Add H264_ prefix to NalUnitUtil.NAL_UNIT_TYPE_* constants
Also promote all H.265 constants to be public in `NalUnitUtil` with
`H265_` prefixes, for consistency.

A lot of these names are used in h.265 too (and `NalUnitUtil` handles
both), but with different values, so this rename aims to avoid
accidentally using an h.264 value in an h.265 context.

PiperOrigin-RevId: 651774188
2024-07-12 08:02:24 -07:00