21731 Commits

Author SHA1 Message Date
dancho
f55e0f3a3f VideoFrameProcessorTestRunner add support for portrait video
Fixes test failures due to differences test util bug that introduced
a crop in external texture sampling

PiperOrigin-RevId: 705061267
2024-12-11 04:45:12 -08:00
rohks
8d2f531470 Enable sending CmcdData for manifest requests in DASH, HLS and SS
Issue: androidx/media#1951
PiperOrigin-RevId: 704875765
2024-12-10 15:59:39 -08:00
ibaker
c377a34a5a Don't call onAudioPositionAdvancing if AudioTrack is paused
`AudioTrackPositionTracker.pause` "re-arms" the event, to ensure it
fires again when playback resumes. However the `AudioTrack` position
advances by about 100ms **after** `AudioTrack.pause()`, which
consistently causes the event to fire immediately after pausing (and
then **not** after a subsequent resumption).

This change checks whether the `AudioTrack` is paused before firing
the event, to avoid this spurious trigger.

PiperOrigin-RevId: 704759929
2024-12-10 10:31:46 -08:00
tonihei
3e3cd8e6ac Fix Javadoc reference link for VORBIS mapping
PiperOrigin-RevId: 704737734
2024-12-10 09:27:36 -08:00
tonihei
b34a5b4e5d Align logic to ignore disabled and non-custom buttons in custom layout
The legacy custom layout doesn't support disabled buttons or buttons
with non-custom actions. These are currently filtered out, but in
inconsistent ways:
 - MediaControllerImplBase doesn't filter at all.
 - DefaultNotificationProvider filters before converting
   mediaButtonPreferences, PlayerWrapper filters after the conversion.
 - PlayerWrapper doesn't disable buttons that are unavailable.

To ensure it's consistent, we can add these checks to the existing util
method in CommandButton and also make sure PlayerWrapper disables
unavailable buttons before triggering the util method.

This also means we can simplify some of the tests that rely on the
mediaButtonPreference to customLayout conversion in MediaController.

This change also includes two bug fixes in PlayerWrapper that
became evident in the tests: The extras need to be copied to
avoid modifying a Bundle instance that be used elsewhere and
we need to update the custom layout and potentially the session
extras when the available commands change, as they depend on them.

PiperOrigin-RevId: 704678404
2024-12-10 06:13:54 -08:00
shahddaghash
dc21f3add2 Add preset input picker functionality
Added functionality to `Choose preset input` button. The picker allows the user to select a preset input from a list of loaded preset playlists. The selected preset input is then used to populate the ExoPlayer with the corresponding media items.

PiperOrigin-RevId: 704626144
2024-12-10 02:51:06 -08:00
michaelkatz
6689fee2b2 Implement error handling support for pre-warming renderers
PiperOrigin-RevId: 704408379
2024-12-09 14:04:00 -08:00
michaelkatz
be63e156bb Implement mediasource list update support for pre-warming renderers
PiperOrigin-RevId: 704381778
2024-12-09 12:41:37 -08:00
michaelkatz
bb62278627 Implement track reselection support for pre-warming renderers
PiperOrigin-RevId: 704371028
2024-12-09 12:07:58 -08:00
ibaker
ef19740c92 Remove Forwarding from assertForwardingClassOverridesAllMethods
And use it in a "non-forwarding" context in
`DefaultAnalyticsCollectorTest`.

PiperOrigin-RevId: 704331859
2024-12-09 10:22:06 -08:00
sheenachhabra
e017213ee8 Fix some MP4-AT file format related naming
Also add spec link in the code.

PiperOrigin-RevId: 704329143
2024-12-09 10:14:34 -08:00
michaelkatz
459162c692 Implement seeking support for pre-warming renderer feature
PiperOrigin-RevId: 704328162
2024-12-09 10:12:11 -08:00
michaelkatz
987869e456 Implement secondary renderer feature for pre-warming
`RenderersFactory#createSecondaryRenderer` can be implemented to provide secondary renderers for pre-warming. These renderers must match their primaries in terms of reported track type support and `RendererCapabilities`.

If a secondary renderer is provided, ExoPlayer will enable it for a subsequent media item as soon as its `MediaPeriod` is prepared. This will cause the renderer to start decoding and processing content so that it is ready to play as soon as playback transitions to that media item.

PiperOrigin-RevId: 704326302
2024-12-09 10:07:33 -08:00
andrewlewis
fc3f096888 Fix handling of 'no chunk readers' in AVI
Before this change the chunk readers array was accessed out of bounds in files
for which no chunk readers are created.

PiperOrigin-RevId: 704323919
2024-12-09 10:01:13 -08:00
andrewlewis
1f6c795407 Read init data for AAC (and not other formats) in AVI files
AAC is the only format where the codec data buffer is actually used.

Invalid or obscure versions of the relevant syntax can break extraction when we
try to read the codec data, so it's better to read it only when it's required.

PiperOrigin-RevId: 704308925
2024-12-09 09:15:29 -08:00
ibaker
12546070ee Add vorbis comment support for track/disc numbering fields, and genre
Only `TRACKNUMBER` and `GENRE` are listed here:
https://xiph.org/vorbis/doc/v-comment.html

The rest are derived from the example in Issue: androidx/media#1958.

It's possible that other formats exist in the wild:
https://hydrogenaud.io/index.php/topic,69292.msg613808.html#msg613808

Issue: androidx/media#1958
PiperOrigin-RevId: 704308788
2024-12-09 09:12:57 -08:00
andrewlewis
aa0e7298ca Make some no-op fixes to AVI extraction code
PiperOrigin-RevId: 704292203
2024-12-09 08:16:54 -08:00
ibaker
38d12f25e1 Consistently ignore non-fatal errors in subtitle loading error tests
It's expected that the subtitle load errors are emitted as a non-fatal
error, but it's not defined exactly when they will be emitted. By
consistently ignoring these every time we 'advance' the player, this
de-flakes the test (currently it fails when `untilFullyBuffered()`
triggers a non-fatal error).

PiperOrigin-RevId: 704219317
2024-12-09 03:39:57 -08:00
kimvde
1a7da45dd9 Add a TestTransformerBuilder
This is inspired from TestExoPlayerBuilder.

Adding this class has a few advantages:
- It makes testing easier for apps by configuring Transformer for unit
  tests (for example, by setting the clock).
- It removes the Transformer setters that apps should not use for unit
  testing (for example, the video MIME type should not be set because
  it would cause Transformer to transcode.
- It allows us to add additional setters in the future, for example to
  build a Transformer that always fails.

PiperOrigin-RevId: 704181927
2024-12-09 01:06:51 -08:00
sheenachhabra
0a75447785 Rename terminologies as per the MP4-AT spec
https://developer.android.com/media/platform/mp4-at-file-format

PiperOrigin-RevId: 703531148
2024-12-06 09:58:11 -08:00
dancho
1d2ffcb165 Frame extraction support changing MediaItem
Add FrameExtraction.setMediaItem() method
Prefer non-vendor software codecs by default because
vendor codecs sometimes fail when we attempt reuse.

PiperOrigin-RevId: 703486235
2024-12-06 06:57:21 -08:00
rohks
b816e2f284 Add E2E test for DASH stream with CMCD enabled and init segment
The test complements the existing E2E test for HLS in `HlsPlaybackTest` by verifying similar functionality for DASH in `DashPlaybackTest`.

PiperOrigin-RevId: 703454388
2024-12-06 04:39:14 -08:00
jbibik
038d7c8cb9 Remove kotlin-android plugin from main demo
This fixes the problem with `compileDebugKotlin` gradle task and `Unknown Kotlin JVM target: 21`.

PiperOrigin-RevId: 703427496
2024-12-06 02:46:21 -08:00
shahddaghash
862791f837 Fixes after removing deprecated methods from Transformer.Builder
After removing `Transformer.Builder.setFlattenForSlowMotion()`, there is no need to keep `flattenForSlowMotion` in Transformer since it's now set in `EditedMediaItem`.
The change also includes making `audioProcessors` and `videoEffects` attributes final.

PiperOrigin-RevId: 703076023
2024-12-05 05:14:59 -08:00
shahddaghash
b6724e2115 Load preset input from JSON file in EffectActivity
The JSON file contains a list of playlists, each with a name and a list of media items. The EffectActivity loads the JSON file and creates a list of PlaylistHolder objects, which contain the playlist name and the list of media items.

PiperOrigin-RevId: 703069411
2024-12-05 04:46:47 -08:00
kimvde
f1a0e4b0b7 Fix timeouts in CompositionPlaybackTest
Some of the tests were timing out because the emulator was too slow.

PiperOrigin-RevId: 703056616
2024-12-05 03:54:49 -08:00
ibaker
b5a1efdbce ForwardingTimeline: Implement & finalize some methods
`equals`, `hashCode`, and `getPeriodByUid` are correctly implemented on
`Timeline`. Overriding these in a way that maintains correctness is
fiddly, so this CL prevents that for the 'simple' case of subclasses of
`ForwardingTimeline`. Implementations of `Timeline` that need to
override these methods for performance should extend `Timeline` or
`AbstractConcatenatedTimeline` instead of `ForwardingTimeline`.

PiperOrigin-RevId: 703035721
2024-12-05 02:24:19 -08:00
ibaker
92e0b5978f Add ForwardingTimelineTest
PiperOrigin-RevId: 703029260
2024-12-05 01:59:07 -08:00
Googler
5ab9a7856f Rollback of 646a6352a2
PiperOrigin-RevId: 702960045
2024-12-04 20:36:15 -08:00
Googler
f60d2b4146 Rollback of 66e8b53b43
PiperOrigin-RevId: 702943864
2024-12-04 19:22:54 -08:00
dancho
6193f7c38f Generate static HDR metadata when using DefaultEncoderFactory
* Select an encoder that supports HDR editing.
* Set KEY_PROFILE to an HDR10 option
* Use DecodeOneFrameUtil test util to return the MediaCodec format,
  which includes HDR_STATIC_INFO

PiperOrigin-RevId: 702752639
2024-12-04 09:31:13 -08:00
ibaker
3e94bd6125 Enable lint errors in tests for remaining playback modules
Also fix existing violations

This enables the lint for tests in:
* `decoder-iamf`
* `exoplayer-rtsp`
* `test-exoplayer-playback`
* `test-session-current`
* `ui-compose`

PiperOrigin-RevId: 702728438
2024-12-04 08:08:01 -08:00
rohks
fb2d5f905d Fix typo in Javadoc for constructor in SsMediaSource.Factory
PiperOrigin-RevId: 702718127
2024-12-04 07:31:54 -08:00
rohks
e927d7b986 Fix ReplacingCuesResolver.discardCuesBeforeTimeUs to retain active cue
The method previously discarded the cue that was active at `timeUs`,
meaning it had started before but had not ended by `timeUs`.

Issue: androidx/media#1939

#cherrypick

PiperOrigin-RevId: 702707611
2024-12-04 06:51:12 -08:00
kimvde
06b94f5448 DefaultVideoSink: implement handleInputFrame() and listeners
With this CL, PlaybackVideoGraphWrapper doesn't call the
VideoFrameRenderControl directly anymore (which is one of the goals of
DefaultVideoSink).

PiperOrigin-RevId: 702673821
2024-12-04 04:29:03 -08:00
ibaker
c770a6ab6f Enable lint errors in database tests
Also fix existing violations.

PiperOrigin-RevId: 702665065
2024-12-04 03:55:33 -08:00
tonihei
46ab6cf030 Fix wrong copy-pasted comment
PiperOrigin-RevId: 702647886
2024-12-04 02:38:11 -08:00
Googler
bffa253e3a Add initialization data for VP9 and AV1 codec in MatroskaExtractor
Update `MatroskaExtractor` to populate the CSD information for VP9 and AV1 codecs with their codec private data.

For reference: [CodecPrivate for VP9](https://www.webmproject.org/docs/container/#vp9-codec-feature-metadata-codecprivate), [CSD for AV1](https://aomediacodec.github.io/av1-isobmff/#av1codecconfigurationbox-syntax).

PiperOrigin-RevId: 702631838
2024-12-04 01:39:41 -08:00
ibaker
9828d104b5 Improve reflective instantiation in ForwardingFoo test util
This code previously passed null or 'default' for every parameter.
Now it tries to mock non-final types, and recursively constructor final
types if possible, eventually giving up and passing null instead.

The previous null-passing behaviour led to a quite confusing failure in
`ForwardingPlayer.addListener` when writing 25c927e9f3 due to an NPE
when trying to compare parameter equality in `Mockito.verify` [1].
With this change, the failure is much clearer [2].

There's a relatively simple case this code still doesn't handle: A final
type like `PlaybackParameters` where the constructor parameters **have**
to be non-default primitives (greater than zero in that case).

-------

[1]

```
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at androidx.media3.test.utils.TestUtil.assertForwardingClassForwardsAllMethodsExcept(TestUtil.java:687)
	at androidx.media3.common.ForwardingPlayerTest.forwardingPlayer_forwardsAllPlayerMethods(ForwardingPlayerTest.java:110)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:588)
	at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$2(SandboxTestRunner.java:290)
	at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:101)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "this.listener" is null
	at androidx.media3.common.ForwardingPlayer$ForwardingListener.hashCode(ForwardingPlayer.java:1140)
	at java.base/java.lang.Object.toString(Object.java:256)
	at java.base/java.lang.String.valueOf(String.java:4220)
	at org.mockito.internal.verification.argumentmatching.ArgumentMatchingTool.toStringEquals(ArgumentMatchingTool.java:54)
	at org.mockito.internal.verification.argumentmatching.ArgumentMatchingTool.getSuspiciouslyNotMatchingArgsIndexes(ArgumentMatchingTool.java:36)
	at org.mockito.internal.verification.checkers.MissingInvocationChecker.checkMissingInvocation(MissingInvocationChecker.java:45)
	at org.mockito.internal.verification.Times.verify(Times.java:37)
	at org.mockito.internal.verification.MockAwareVerificationMode.verify(MockAwareVerificationMode.java:30)
	at org.mockito.internal.handler.MockHandlerImpl.handle(MockHandlerImpl.java:75)
	at org.mockito.internal.handler.NullResultGuardian.handle(NullResultGuardian.java:29)
	at org.mockito.internal.handler.InvocationNotifierHandler.handle(InvocationNotifierHandler.java:34)
	at org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.doIntercept(MockMethodInterceptor.java:82)
	at org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.doIntercept(MockMethodInterceptor.java:56)
	at org.mockito.internal.creation.bytebuddy.MockMethodInterceptor$DispatcherDefaultingToRealMethod.interceptAbstract(MockMethodInterceptor.java:161)
	at androidx.media3.common.Player$MockitoMock$1276619531.addListener(Unknown Source)
	... 22 more
```

----

[2]

```
Argument(s) are different! Wanted:
player.addListener(
    Mock for Listener, hashCode: 107929032
);
-> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Actual invocations have different arguments:
player.addListener(
    androidx.media3.common.ForwardingPlayer$ForwardingListener@af47cec0
);
-> at androidx.media3.common.ForwardingPlayer.addListener(ForwardingPlayer.java:81)
```

PiperOrigin-RevId: 702378861
2024-12-03 10:10:39 -08:00
ibaker
593899c2b2 Enable lint errors in datasource tests
Fix existing violations

PiperOrigin-RevId: 702377837
2024-12-03 10:07:19 -08:00
ibaker
c870fb7594 Enable lint errors in extractor tests
Fix existing violations.

PiperOrigin-RevId: 702366292
2024-12-03 09:29:30 -08:00
ibaker
876abe315b Increase library target SDK to 31
This only affects the default SDK level that Robolectric tests run at.
Also upgrade the Robolectric version to 4.14.1 to pick up
4f32042afe
which is needed for async `ShadowMediaCodec` support (the default in
ExoPlayer from API 31+).

Some tests fail on Robolectric at API 31. This change configures them to
continue running on API 30, so the failures can be investigated and
fixed in follow-up changes.

PiperOrigin-RevId: 702357124
2024-12-03 08:57:53 -08:00
tianyifeng
148641f049 Move BasePreloadManager.Listener to a top level PreloadManagerListener
PiperOrigin-RevId: 702351887
2024-12-03 08:38:35 -08:00
ibaker
d72453a6cd Use ForwardingTrackOutput in MidiExtractor
PiperOrigin-RevId: 702328995
2024-12-03 07:14:58 -08:00
Copybara-Service
9a3dc3f03a Merge pull request #1889 from yschimke:fix_build
PiperOrigin-RevId: 702323944
2024-12-03 06:56:53 -08:00
Yuri Schimke
10ca39a779 Specify androidx.activity:activity-compose as 1.9.0
The Compose BOM doesn't provide this.
https://developer.android.com/develop/ui/compose/bom/bom-mapping
2024-12-03 14:39:08 +00:00
dancho
e8f60d4fec Remove earlier frame extraction prototypes
Earlier this year, we explored frame extraction built on top of Transformer
or ImageReader.

We decided against these approaches because random-access of frames
is a key requirement. And ImageReader behaviour is unreliable.

PiperOrigin-RevId: 702303490
2024-12-03 05:32:09 -08:00
dancho
7821e7702b Frame extractor: explain color accuracy issues
This is only a javadoc change, setting expectations.

PiperOrigin-RevId: 702295210
2024-12-03 04:56:38 -08:00
Copybara-Service
e4993779db Merge pull request #1943 from DolbyLaboratories:dlb/ac4-ajoc/dev
PiperOrigin-RevId: 702281314
2024-12-03 04:04:52 -08:00
ibaker
18d156fe3c Configure ProgressiveMediaSource with a Format for subtitles
This means we can complete preparation (and trigger track selection)
before opening a `DataSource`, which then means we only end up loading
the data for a selected subtitle track (instead of all tracks as
currently happens).

By making preparation trivial in this case (with no reasonable cause
of error), we can also remove the `suppressPrepareError` option added in
b3290eff10.

This change also fixes the implementation of
`ProgressiveMediaPeriod.maybeStartDeferredRetry` to only short-circuit
return `false` if the chosen track is not audio or video **and** there
is at least one audio or video track in this period.

Issue: androidx/media#1721
PiperOrigin-RevId: 702275968
2024-12-03 03:40:49 -08:00