21701 Commits

Author SHA1 Message Date
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
kimvde
0037388660 Simplify VideoSink.handleInputFrame
This method was taking positionUs and elapsedRealtimeUs parameters and
throwing a VideoSinkException because it was calling render() to make
room for a new input frame. Instead of doing that, this CL makes sure
render() is called before  handleInputFrame() in the renderer (even
though it may not make a significant difference).

PiperOrigin-RevId: 702273587
2024-12-03 03:29:30 -08:00
ybai001
1df0ee2052 Minor change to comment 2024-12-03 15:29:57 +08:00
ybai001
e503535ec2 LFE channel should always be counted for AC-4 A-JOC content on MPEG-4 layer 2024-12-03 13:29:57 +08:00
ybai001
547a164f42
Merge pull request #15 from androidx/main
Merge from androidx/media main branch
2024-12-03 10:14:07 +08:00
claincly
675c1d898a Move interface locations
PiperOrigin-RevId: 702096389
2024-12-02 15:03:37 -08:00
claincly
ecdf7c5df7 Propagate sourceEnded to AudioGraphInputAudioSink
PiperOrigin-RevId: 702076933
2024-12-02 13:59:15 -08:00
claincly
8908d82cac Signal end of stream to VideoFrameProcessor in previewing
This will be used by VideoCompositor

PiperOrigin-RevId: 702031907
2024-12-02 11:30:20 -08:00
ibaker
25c927e9f3 Standardize ForwardingXXX tests
Add missing ones for `ForwardingExtractorInput` and `ForwardingSeekMap`.
`ForwardingTimeline` is a bit more fiddly, so it's left for a follow-up
change.

PiperOrigin-RevId: 701988492
2024-12-02 09:12:53 -08:00
dancho
b2ba5da09b Implement cancellation of FrameExtractor.getFrame
Previously cancelling one FrameExtractor.getFrame
ListenableFuture caused the following requests to fail.
Implement ability to cancel Futures, and correctly issue
next player seek commands after all past requests complete.

Removes uses of SettableFuture, and replaces them with
CallbackToFutureAdapter.
Adds a dependency on androidx.concurrent:concurrent-futures

PiperOrigin-RevId: 701941403
2024-12-02 06:09:33 -08:00
Googler
19b276d6a7 Allow track selection parameters to be set in ExoPlayerAssetLoader.
PiperOrigin-RevId: 701926949
2024-12-02 05:04:26 -08:00
dancho
d214e90ce4 Fix Frame Extractor getting stuck
Frame Extractor was getting stuck with SeekParameters.CLOSEST_SYNC.
onPositionDiscontinuity callback was sometimes being called with a
non-adjusted new position.

Fix this by monitoring player state ready.
For the player to become ready, we have to override renderer isReady.

PiperOrigin-RevId: 701924752
2024-12-02 04:56:26 -08:00
tonihei
da4376d48d Avoid modifying legacy custom layout in MediaControllerImplBase
When a session sets a custom layout, we currently convert it to the
media button preferences in MediaControllerImplBase and convert it back
to a custom layout for consumers of MediaController.getCustomLayout.

To avoid unnecessary conversions and potential changes, we can
directly use the provided custom layout to get the same logic as
before. This also means we avoid notifying a change to the custom layout
if only the implicit slots changed that weren't relevant before
introducing them (=we can remove some tests for this behavior).

PiperOrigin-RevId: 701903475
2024-12-02 03:19:51 -08:00
ibaker
77d33645cc Clarify CommandButton javadoc around iconResId and ICON_UNDEFINED
PiperOrigin-RevId: 701898620
2024-12-02 02:59:32 -08:00
Copybara-Service
f113a78e0d Merge pull request #1870 from colinkho:fwd-extractor-clz
PiperOrigin-RevId: 701313111
2024-11-29 10:18:34 -08:00
Copybara-Service
e27238666a Merge pull request #1849 from colinkho:stuckwhenready
PiperOrigin-RevId: 701306291
2024-11-29 09:34:56 -08:00
Ian Baker
7f62f74737 Fix review comments 2024-11-29 17:10:45 +00:00
Ian Baker
21e627da1c Fix review comments 2024-11-28 16:54:00 +00:00
Copybara-Service
55c81f6ed6 Merge pull request #1876 from colinkho:extinputgetreader
PiperOrigin-RevId: 701021720
2024-11-28 07:36:28 -08:00
Ian Baker
037a6f3219 Fix nullness errors 2024-11-28 14:47:57 +00:00
Ian Baker
38145b6e89 Tweak javadoc & reformat 2024-11-28 14:20:27 +00:00
Colin Kho
55a1290bfd Add a getter for DataReader on DefaultExtractorInput 2024-11-28 14:20:27 +00:00
Colin Kho
24ea6c4c14 Relax PlaybackStuck criteria to only when playWhenReady is true 2024-11-28 14:06:44 +00:00
Ian Baker
c5af8ba360 Add & fix copyright headers 2024-11-28 14:04:38 +00:00
Ian Baker
2683331299 Add tests and missing overrides to ForwardingExtractor 2024-11-28 14:01:14 +00:00
Ian Baker
01422d8322 Reformat with google-java-format 2024-11-28 11:45:09 +00:00
Colin Kho
6d265476e4 Added Forwarding classes for Extractor and ExtractorOutput 2024-11-28 11:45:09 +00:00
kimvde
4d925bde81 Remove stale TODO
Handling (very) late buffers is already supported.

PiperOrigin-RevId: 700965581
2024-11-28 03:02:59 -08:00
kimvde
852091f2d9 Implement DefaultVideoSink.isEnded
To do that, I had to add VideoFrameRenderControl.signalEndOfInput() and
isEnded() to match the VideoSink interface.

PiperOrigin-RevId: 700957098
2024-11-28 02:27:50 -08:00
kimvde
f3f4646296 Add VideoSink.signalEndOfCurrentInputStream()
The isLastBuffer flag passed to MediaCodecRenderer.processOutputBuffer()
is unreliable. It is true for the last frames (plural) of a video
stream, which makes it possible for the video renderer to end before all
the frames have been rendered to the output surface.

PiperOrigin-RevId: 700941685
2024-11-28 01:23:55 -08:00
kimvde
dfe3c90f9a Fix CompositionPlayerTest.imagePreview_imagePlaysForSetDuration
PiperOrigin-RevId: 700931124
2024-11-28 00:36:46 -08:00