15163 Commits

Author SHA1 Message Date
christosts
ae5685427a MediaControllerWithMediaSessionCompatTest
Fix a race condition making test flaky.

PiperOrigin-RevId: 480104467
(cherry picked from commit cb3a6725083d4a1037c6081fe732ea999a5263c9)
2022-10-10 16:34:13 +00:00
tonihei
166b201ae4 Treat NO_VALUE as zero when adding up total required bitrate
We currently use the literal -1 (=NO_VALUE) when adding up the
total. Tracks without known bitrate can be ignored in the
calculation, but we should use an explicit value of 0.

#minor-release

Issue: google/ExoPlayer#10664
PiperOrigin-RevId: 480048126
(cherry picked from commit b0daae72cfa5b5390d2fe2077e011955952d858d)
2022-10-10 11:11:30 +00:00
christosts
48de6838b4 Minor naming cleanup in MediaControllerListenerTest
PiperOrigin-RevId: 480041937
(cherry picked from commit 6f8863fc112aa49cddf8d43bfb3da24f140ef33f)
2022-10-10 10:42:01 +00:00
michaelkatz
46dfb1b7b2 Adjust track selection with Dolby Vision if display does not support
If the sample type is Dolby Vision and the display does not support Dolby Vision, then the capabilities DecoderSupport flag is set to DECODER_SUPPORT_FALLBACK_MIMETYPE. This denotes that the renderer will use a decoder for a fallback mimetype if possible. This alters track selection as tracks with DecoderSupport DECODER_SUPPORT_PRIMARY are preferred.

UnitTests included
-DefaultTrackSelector test that checks track selection reordering with DECODER_SUPPORT_FALLBACK_MIMETYPE
-MediaCodecVideoRenderer test that checks setting of DecoderSupport flag based on Display's Dolby Vision support

Issue: google/ExoPlayer#8944
PiperOrigin-RevId: 480040876
(cherry picked from commit 266de1b21bae6ed267022547d42601a00ea14e88)
2022-10-10 10:35:17 +00:00
christosts
20b086ce23 MediaControllerListenerTest: use local MediaController instances
Replace the instance-field MediaController with a local instance created
in each test.

PiperOrigin-RevId: 480039768
(cherry picked from commit ba1ecafb8f0db2a0e822eceffa724f1baae4a073)
2022-10-10 10:26:45 +00:00
tonihei
d35f67a8a6 Set new playlist and start index with one command
PlayableFolderActivity currently uses two seperate commands
to set the playlist and then seek to the requested item.

This is slightly inefficient and also causes analytics
listeners to believe the first item in the playlist was
briefly active.

#minor-release

Issue: androidx/media#180
PiperOrigin-RevId: 480031682
(cherry picked from commit 5d6d069e4e946a46884a838482567ff085e88283)
2022-10-10 09:33:21 +00:00
claincly
b436001e32 Remove late frame dropping in FrameProcessor
Currently, a frame is dropped if it's requested release time is in the past.
This mode was added to support previewing. However, in normal ExoPlayer
playback, slightly late frames (<30ms late) are also rendered. On MediaCodec
side, this means calling `releaseOutputBuffer` with a release time in the
past.

PiperOrigin-RevId: 479615291
(cherry picked from commit a426cb27c0d0c85bd6cb4c04cb27957e3075754c)
2022-10-07 17:29:15 +00:00
christosts
0ceec3ebb9 MediaControllerImplBase: clean imports
Remove static imports to constants and imports to intdefs, to make the
code more readable.

PiperOrigin-RevId: 479594144
(cherry picked from commit 36e12fbadb7b274f770a5904675493300c8fa89c)
2022-10-07 16:07:50 +00:00
christosts
14e259d44f Bump dexmaker version
PiperOrigin-RevId: 479579252
(cherry picked from commit 49bfca54827f1cfb6f75dfded9427b2398537abe)
2022-10-07 14:49:37 +00:00
huangdarwin
355d81c6bb HDR: Disable tone mapping on unsupported pixel build ID.
Also, update tests to allow AnyOf error codes, and no longer check exception messages, which caused quite a bit of churn.

PiperOrigin-RevId: 479570861
(cherry picked from commit 8548e3519e3d6ef214d5c18d640a8bf6efe19c83)
2022-10-07 13:57:06 +00:00
ibaker
110fe2b61b Document the allowed values of TsPayloadReader.Flags IntDef
PiperOrigin-RevId: 479569806
(cherry picked from commit 91caf7a650a688eec9d2d8e976ae6e90a4be322c)
2022-10-07 13:50:28 +00:00
claincly
8b193f2bb9 Add a FrameProcessor flag to drop the processed frame
This mode is supported by using `C.TIME_UNSET` (which is a negative value). The
new logic decouples the value of `C.TIME_UNSET` and the frame dropping
behaviour.

PiperOrigin-RevId: 479368880
(cherry picked from commit 26be9ae88548bcf95327801931b3b5797304bc66)
2022-10-06 18:30:14 +00:00
aquilescanta
506653bbcc Fix typo in MediaController javadoc
PiperOrigin-RevId: 479268879
(cherry picked from commit 0beccb6e141f40d6cb8cca4839213df2ab600c01)
2022-10-06 10:21:12 +00:00
tianyifeng
243c29a8ad Provide access to original media timestamps in AudioSink.
* Add `setOutputStreamOffsetUs(long)` method in `AudioSink`.
* Add private methods `setOutputStreamOffsetUs(long)` method in `MediaCodecRenderer` and `DecoderAudioRenderer`.
* Add protected method `onOutputStreamOffsetUs(long)` method in `MediaCodecRenderer`, in which:
  * `MediaCodecRenderer` itself will be no-op for this method.
  * `MediaCodecAudioRenderer` will propagate this value to its `audioSink`.
* Add logics in `DecoderAudioRenderer` to calculate `outputStreamOffsetUs`.

PiperOrigin-RevId: 479265429
(cherry picked from commit 5bff8623748a1ce9e411cfa9df171143925da89f)
2022-10-06 09:58:37 +00:00
christosts
1cfeddc369 Misc fix on DefaultMediaNotificationProviderTest
PiperOrigin-RevId: 479079184
(cherry picked from commit bf948db669c32ab5eea2432b7c2c61667af1388a)
2022-10-05 17:22:40 +00:00
tonihei
a31a6c6c1a Fix RequestMetadata JavaDoc link to point to the right MediaController.
The JavaDoc of RequestMetadata should point to the media3 controller,
not the platform one.

PiperOrigin-RevId: 479047924
(cherry picked from commit b70258e43dd9a9aead05eb2247f2058044bee1a5)
2022-10-05 15:03:16 +00:00
claincly
1b25dc2627 Add FrameProcessor functionality to release a frame immediately
Currently `FrameProcessor.releaseOutputFrame()` method supports

Release at a specific system time
Drops the frame
This API is not that convenient to use when the caller wants to release a frame, now, regardless of the release time. A use case is to release (present) a frame when no frame is shown for a while, and it's thus better to just release the frame, now.

Currently if MCVR wants a frame to be rendered now, MCVR calls release frame with a set offset like 10us: `releaseOutputFrame(System.nanoTime() + 10_000)`. The 10us offset is to prevent the frame processor dropping the frame, due to thread hopping delays.

To make the API better usable, consider adding a mode for releasing the frame now, like (bold marks the new mode)

- Use C.TIME_UNSET to drop
- **Use -1 to release the frame immediately, or**
- Use an actual release time.

PiperOrigin-RevId: 479044215
(cherry picked from commit 139a6e8d3175143957c44e4c4b5e15853202682e)
2022-10-05 14:45:27 +00:00
Googler
3ff7c05044 Add button to show/hide input player in TransformerActivity
PiperOrigin-RevId: 479003655
(cherry picked from commit 50df923b258ce89c3bbebac1aa8f48e385e358d2)
2022-10-05 10:26:27 +00:00
huangdarwin
4449ba9c99 HDR: Check isToneMappingApplied in HDR editing test.
Assert that tone mapping is applied when an HDR edit cannot be HDR, but is successfully tone mapped. Meanwhile, assert that fallback, which is applied after codec configuration (which throws the "Tone-mapping requested but not supported by the decoder" error) is not applied when that error is called.

PiperOrigin-RevId: 478762951
(cherry picked from commit 253486d4af057776da0eb5926e31190f43dbe3b3)
2022-10-04 13:01:27 +00:00
Googler
9842c273e9 Allow using different notification IDs for different media sessions
When a media service currently produces multiple media sessions, the notification of the second session overwrites the notification of the first one, because all sessions use the same notification ID. When we use different notification IDs for different sessions, multiple media notifications can be up at the same time, which means that they can both be controlled at the same time.

PiperOrigin-RevId: 478709069
(cherry picked from commit 7783c6e4f71943b543ddb569b120bdbbab362b96)
2022-10-04 07:38:38 +00:00
Googler
c8917b50e6 Add second player for input video
PiperOrigin-RevId: 478510687
(cherry picked from commit 48a7f6a9240cd7c0ce8016915de630d903e5c393)
2022-10-03 15:27:33 +00:00
huangdarwin
186f516b65 HDR: Add tests with HLG10 input.
PiperOrigin-RevId: 478019046
(cherry picked from commit 6e5a4c05b5f4404b09628ae9e9029d046b601865)
2022-09-30 17:02:37 +00:00
huangdarwin
5abbfd774b Effect: Update javadoc to remove "final effect" references
"Final" was likely added to reference the FinalMatrixTextureProcessorWrapper,
which is a package-private class. However, I think more clear to express that
this is the input size, which then has all effects applied, to get the output
size.

PiperOrigin-RevId: 477975358
(cherry picked from commit de82a2be336e9308e194d5baf91c348a2700a5de)
2022-09-30 13:24:26 +00:00
huangdarwin
65a9bd2dfa Tests: Statically import BitmapTestUtil methods.
Per go/java-practices/imports#static

No functional changes intended.

PiperOrigin-RevId: 477974779
(cherry picked from commit d5c272fde88f3efde7535933331270d2aea2fbb9)
2022-09-30 13:20:49 +00:00
huangdarwin
3fd8e47245 Test: Rename to avoid redundant substrings.
Rename test files to avoid substrings that can be implied by the directory name,
like "Transformation" and "Test"

No functional changes. Renaming-only.

PiperOrigin-RevId: 477724724
(cherry picked from commit 62b95a71902349e95693174f83bb48e6927d5249)
2022-09-29 14:54:25 +00:00
samrobinson
c08e4b664b Demo: Split video Effect generation out of createTransformer.
PiperOrigin-RevId: 477524540
(cherry picked from commit 1cfe18cd1f45e850df3b21ca8e63635956cf758e)
2022-09-28 19:39:09 +00:00
huangdarwin
55a7316158 HDR: Add period to end of error message.
For tone mapping error messages.

PiperOrigin-RevId: 477447799
(cherry picked from commit 1711d7f4c2de8ccd7e5a476c79cdf51685ca7334)
2022-09-28 14:30:48 +00:00
huangdarwin
875766ddfe HDR: Add tests for tone mapping.
Also, add checks for output file color.

PiperOrigin-RevId: 477439139
(cherry picked from commit aec4fe738709b3ca564c5309d8623bfbf1298c33)
2022-09-28 13:42:36 +00:00
Googler
ff22da9011 Fix checkboxes on configuration page
PiperOrigin-RevId: 477166507
(cherry picked from commit bb811f0da50b632d68ae50ace90028e10f6bab8e)
2022-09-27 14:31:59 +00:00
bachinger
4d073799e0 Remove unofficial link from test case
PiperOrigin-RevId: 477101201
(cherry picked from commit 9e310150a91d9fb2d46e0e0298a9df41777b76eb)
2022-09-27 08:08:15 +00:00
samrobinson
b39dff76af Fix badly formatted AudioProcessor javadoc.
PiperOrigin-RevId: 476909855
(cherry picked from commit 3e4aa050da64a272c5f752beb513c6359e24b0b1)
2022-09-26 16:00:10 +00:00
tonihei
c91cdb49e0 Remove test that just times out
One of the tests in MediaBrowserListenerTest caused the remote
browser service to crash and then just timed out. As this asserts
nothing useful besides checking that the timeout method is working,
we can remove the test.

Crashing the remote browser service had the side effect of letting
subsequent tests in the same class fail because the previous session
was never released and was still present in the static MediaSession
SESSION_ID_TO_SESSION_MAP instance, which prevented the creation
of new sessions with the same id. This is only an issue in test
runs because a real process would also lose its static variables
when it crashes.

PiperOrigin-RevId: 476905337
(cherry picked from commit d2887d523773de75ed99403c22d634538f6c81df)
2022-09-26 15:39:47 +00:00
bachinger
05ebdb9211 Don't start the service in the foreground with a pause intent
`PlaybackStateCompat.toKeyCode(command)` was replaced by our
own implementation of `toKeyCode()`. The legacy implementation used PLAY and PAUSE, while the new implementation uses PLAY_PAUSE. This made `pause` a pending intent that attempt to start the service in the foreground, but `service.startForeground()` won't be called in `MediaNotificationManager.updateNotificationInternal` when paused.

PiperOrigin-RevId: 476895752
(cherry picked from commit acd9e581c494b18f6347f5abb2cf9fc82344c723)
2022-09-26 14:56:00 +00:00
huangdarwin
4c3acbf739 HDR: Update gamma comments to linear.
Comment-only change.

PiperOrigin-RevId: 476873286
(cherry picked from commit 16dca1828c30c99fef9b63b46a5fe0cd7e7f65dc)
2022-09-26 13:00:17 +00:00
bachinger
cc6c6aa62b Call callback future listeners on app handler
Calling maybeUpdateLegacyErrorState potentially creates a new legacy playback
state which involves calling player methods. This change makes sure that the call
sites of `maybeUpdateLegacyErrorState` are called on the app thread as enforced by
the library.

PiperOrigin-RevId: 476406282
(cherry picked from commit 74124f48ea838fcdb436726ba8337e82abc7552e)
2022-09-23 17:34:25 +00:00
tonihei
e1b947ec92 Add setPreferredAudioDevice method to ExoPlayer
This allows to access the associated functionality of AudioTrack and
fills a feature gap to MediaPlayer, which has a similar method.

Issue: androidx/media#135
PiperOrigin-RevId: 476398964
(cherry picked from commit a069ebda47fffd692838b29aa9acd1b51df86151)
2022-09-23 17:05:43 +00:00
leonwind
638d806a49 Add example CLUT to demo.
PiperOrigin-RevId: 476390089
(cherry picked from commit 5b3efa8ad9557419a68a1a172c1d584aeecfd433)
2022-09-23 16:28:25 +00:00
leonwind
09e0dd8505 Store LUT bitmap as texture with processor creation.
* Before this CL, the texture was stored during the construction of the LUT processor. This failed since if one creates a list of GlEffects on the application thread, the texture will get stored in the application thread during the effect creation and not on the GL thread, which executes the FrameProcessors.
* This is an issue since the executing thread then can't index from the texture stored on a different thread.

PiperOrigin-RevId: 476388021
(cherry picked from commit 44b9aec0b973b1cd5df31df32fff276f340e6ce4)
2022-09-23 16:19:43 +00:00
Marc Baechinger
a7102992ba Merge pull request #123 from stoyicker:wrapping_media_source
PiperOrigin-RevId: 476376463
(cherry picked from commit cac8c4f6e99ba986fceb69c4399e21983cdaa3cb)
2022-09-30 18:15:30 +00:00
leonwind
20518cc151 Add HSL Adjustments to the demo.
PiperOrigin-RevId: 476373520
(cherry picked from commit 7626f70cef1e6a431fbe2773a3a930904a67c803)
2022-09-23 15:11:52 +00:00
leonwind
a21d79cf1f Remove TODOs for merging RGB and MatrixTransformation processors.
PiperOrigin-RevId: 476362571
(cherry picked from commit 7eb0ce623bc1b29db9896cacbde4c6008b02ed32)
2022-09-23 14:21:38 +00:00
michaelkatz
dd425613b7 Try alternative decoder for Dolby Vision if display does not support
If the sample type is dolby vision and the following conditions match
a)There is a supported alternative codec mimetype
b)Display does not support Dolby Vision
Then getDecoderInfos will return the alternative types.

Issue: google/ExoPlayer#9794
PiperOrigin-RevId: 476356223
(cherry picked from commit ed79f4696f026872f2840c53f9526980f4c966d4)
2022-09-23 13:43:21 +00:00
huangdarwin
ab37184917 HDR: Assert output C.ColorTransfer for tests.
To confirm that tone mapping did or did not happen.

PiperOrigin-RevId: 476354606
(cherry picked from commit 87fd51a39b784707d9f28caac6fa6d6abc6b8b33)
2022-09-23 13:33:28 +00:00
leonwind
25a5fdfdac Add HSL Adjustments to the effects module.
PiperOrigin-RevId: 476144167
(cherry picked from commit dc9fa4f463a20a39984ea9d041ced0c4aed53291)
2022-09-22 17:56:54 +00:00
leonwind
63f9df5b1a Add OETF and EOTF ES2 fragment shaders for non-HDR frames.
* Transform the intermediate color space to linear SDR by applying the SMPTE 170M EOTF and OETF.
* Use linear colors for the color filter pixel tests and update all golden bitmaps.

PiperOrigin-RevId: 476124592
(cherry picked from commit 3433758c3b1f02c0ec28b86a8c3b659171f6f92b)
2022-09-22 16:45:28 +00:00
ibaker
395d89a7b7 Work around a bug in the Android 13 ClearKey implementation
The ClearKey CDM will attach an 'invalid' URL in `KeyRequest` objects,
when the documentation states this should be an empty string if a
default URL is not known.

#minor-release

PiperOrigin-RevId: 476113513
(cherry picked from commit 715c948004eeabb6f7e2d45b8b8856ee4a015391)
2022-09-22 15:59:44 +00:00
leonwind
873b806389 Add RGB Adjustments to transformer demo.
PiperOrigin-RevId: 476049125
(cherry picked from commit 9ccdd22e856251e7529fb893edbaa118f4285e49)
2022-09-22 10:04:42 +00:00
samrobinson
7ce758f40b Add file size to TransformationResult at the end of a Transformation.
Tested:
  * Manually using both path and file descriptor.
PiperOrigin-RevId: 475860978
(cherry picked from commit 9ec4e1340a97472c63e9f017f95f2b1a38f88588)
2022-09-21 17:18:42 +00:00
leonwind
ae18b30782 Use golden bitmaps in contrast pixel tests.
PiperOrigin-RevId: 475805421
(cherry picked from commit f00e43cf814df6bf71348a32d65b01ffada9d311)
2022-09-21 12:53:42 +00:00
rohks
4d43f840f1 Fix instrumentation tests not working via Gradle
PiperOrigin-RevId: 475560401
(cherry picked from commit c96e010d351bdd8b45f88b9731c5a80bcec0d2d4)
2022-09-20 15:25:38 +00:00