242 Commits

Author SHA1 Message Date
bachinger
8b0c0761f3 Exclude tracks from PlayerInfo if not changed
This change includes a change in the `IMediaController.aidl` file and needs
to provide backwards compatibility for when a client connects that is of an older or
newer version of the current service implementation.

This CL proposes to create a new AIDL method `onPlayerInfoChangedWithExtensions`
that is easier to extend in the future because it does use an `Bundle` rather than
primitives. A `Bundle` can be changed in a backward/forwards compatible way
in case we need further changes.

The compatibility handling is provided in `MediaSessionStub` and `MediaControllerStub`. The approach is not based on specific AIDL/Binder features but implemented fully in application code.

Issue: androidx/media#102
#minor-release
PiperOrigin-RevId: 490483068
(cherry picked from commit 3d8c52f28d5d3ef04c14868e15036563a9fc662d)
2023-01-25 17:41:00 +00:00
tonihei
9e42426645 Add remaining state and getters to SimpleBasePlayer
This adds the full Builders and State representation needed to
implement all Player getter methods and listener invocations.

PiperOrigin-RevId: 489503319
(cherry picked from commit 81918d8da7a4e80a08b65ade85ecb37c995934e7)
2023-01-25 17:37:31 +00:00
michaelkatz
fc505384c9 Version bump to exoplayer:2.18.2 and media3:1.0.0-beta03
PiperOrigin-RevId: 489959918
(cherry picked from commit 4ea72f0c739f4478cc99b73c5c3550eadaad32ab)
2022-11-22 11:08:15 +00:00
tonihei
8cc37db8e5 Rename getVideoSurfaceSize to getSurfaceSize
This better matches the callback name (onSurfaceSizeChanged) and
probably cause less confusion with getVideoSize.

PiperOrigin-RevId: 488669786
(cherry picked from commit 1143edc59ac96ec8524e8203d9445dbb0f006630)
2022-11-17 10:06:29 +00:00
christosts
c22c2bf0c0 Set valid channel masks for 8 and 12 channels on all Android versions
Util.getAudioTrackChannelConfig() maps a channel count to a
channel mask that is passed to AudioTrack. The method expected that
playback of 8-channel audio is possible from Android 5.1 and playback of
12-channel audio is only possible from Android 12L. However, there is no
restriction on the upper number of channels that can be passed to the
AudioTrack. google/ExoPlayer#10701 is an example where the audio decoder
outputs 12 channels on an Android 10.

This change removes the restrictions for 8 and 12 channels. Note, we still
do not support playback of arbitrary number of channels as it would require
further changes to DefaultAudioSink.

#minor-release

Issue: google/ExoPlayer#10701
PiperOrigin-RevId: 488659831
(cherry picked from commit 491b13622e79f5c2ef84771b1a29e40f47aca653)
2022-11-17 10:06:29 +00:00
tonihei
dab5b3c152 Mark iterationFinished when triggering release event.
When we currently trigger the iteration finished event during the
release, we don't mark the event as triggered. This means that
someone can trigger another release from within the callback,
which then tries to resend the event.

Issue: google/ExoPlayer#10758

PiperOrigin-RevId: 488645089
(cherry picked from commit 1def68bf3c00035aad0821d3997187317ce099dc)
2022-11-17 10:06:25 +00:00
Googler
b780635c0b Add 'Player.getVideoSurfaceSize' that returns the size of the surface
on which the video is rendered.

Design Doc: go/aaos-mu-media-dd

PiperOrigin-RevId: 485884772
2022-11-03 15:50:19 +00:00
samrobinson
48b6d11dde Add AudioProcessor.AudioFormat equals method.
PiperOrigin-RevId: 483983486
(cherry picked from commit e6079c38f2272ea27bdcb18f1a5516acc25ea4ff)
2022-10-26 16:02:24 +00:00
samrobinson
92dc1d34f3 Move DefaultAudioSink.AudioProcessorChain to AudioProcessorChain
Split inner interface into separate file, which will go in common
module. The old interface will be deprecated and extends the new.

#cleanup

PiperOrigin-RevId: 483732226
(cherry picked from commit 7fcb53da2ddcbe5bc3f66c46ef3574d019712945)
2022-10-25 18:31:22 +00:00
samrobinson
35900f94fa Move AudioProcessor to common.
PiperOrigin-RevId: 483699606
(cherry picked from commit fc34542864dac5045d0fb460fd51c6bb2f1112c6)
2022-10-25 16:40:38 +00:00
claincly
5974bee7c5 Add GL utility methods to get 4x4 identity and set identity
PiperOrigin-RevId: 483671580
(cherry picked from commit be7bb0eea4f01e5c73c2aa604c5b3126230586b4)
2022-10-25 14:47:52 +00:00
bachinger
d3e71cd61f Add DAI specific methods to AdPlaybackState
PiperOrigin-RevId: 482755468
(cherry picked from commit c21c486ec6a49da015115a64091fa760649e8fa3)
2022-10-21 11:32:44 +00:00
Googler
656753b809 Corrected ordering of javadoc params
PiperOrigin-RevId: 482231370
(cherry picked from commit 2c61dd9c95e64d0e137d1a4775cd23bc9c0ac42f)
2022-10-19 16:53:37 +00:00
huangdarwin
ebc6b67e72 HDR: Support RGBA_1010102 in GlUtil as a parameter.
Make it easier to support use of RGBA_101012 rather than RGBA_8888 for EGL
contexts, displays, and surfaces.

This tangentially supports adding HDR tests, by slightly simplifying the color
selection logic we'd have to add in HDR tests.

PiperOrigin-RevId: 482219428
(cherry picked from commit bb215857e5fd0768ce53c7c61ba91c48dab14bd2)
2022-10-19 16:04:41 +00:00
tonihei
d56d94fa0a Ensure onMediaItemTransition is sent for repeats of the same item
Currently, repeating the same item (via seekNext/Previous) implicitly
results in a seek to the default position of the current item, which
looks exactly the same as a direct seek. As a result, we don't send
onMediaItemTransition as we would for every other seekNext/Previous
call.

This can be fixed by explicitly marking the repeat case in the internal
BasePlayer/ExoPlayerImpl methods, so that the callback can be triggered.

Issue: google/ExoPlayer#10667
PiperOrigin-RevId: 481951788
(cherry picked from commit f850206c51ced023b1603aa7661dd556ee436740)
2022-10-18 17:08:09 +00:00
huangdarwin
e589718414 GL: Move loadAsset to GlProgram, where it's used.
(Also, make some public methods private)

PiperOrigin-RevId: 481912071
(cherry picked from commit 93ee1f48ad5c9240d3d7b5f26039a98f4dc24b63)
2022-10-18 14:10:39 +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
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
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
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
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
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
bachinger
e6a725b6c2 Add withAvailableAd for server side inserted ad groups
#minor-release

PiperOrigin-RevId: 472714732
(cherry picked from commit 70e82a29b76ef780e8bed691a3f62df0d6d626e6)
2022-09-07 14:01:26 +00:00
bachinger
22f4fcb657 Update presentation time of metadata when the stream offset changes
The stream offset is used to calculate the presentation time of
a metadata object when reading and later when playing, to calculate
the current presentation time to decide whether to send the metadata
to the output.

Accordingly, the presentation time of a pending metadata that has been
calculated with a given offset needs to be recalculated when the
stream offset changes.

#minor-release

PiperOrigin-RevId: 472499943
(cherry picked from commit 0896c4dd3665980d89577db20d247ac13fcd236b)
2022-09-06 17:40:52 +00:00
Googler
590a933a70 Add @SuppressWarnings to nullness errors detected by a newer version of the Checker Framework
PiperOrigin-RevId: 471137219
(cherry picked from commit 1b389ebcf5ee8203f459f0edce55b0b15ee0d93e)
2022-08-31 01:09:09 +00:00
huangdarwin
958df4e030 Effect: Add some FrameProcessor javadoc.
In particular, make it a bit more clear that "rendering" and "releasing" frames are
related concepts, and how they differ from one another in conjunction with frame
dropping.

PiperOrigin-RevId: 471037733
(cherry picked from commit 69714e5f8e506d64247992d15864052918abb1df)
2022-08-30 18:01:11 +00:00
huangdarwin
7e7f07f8ab HDR: Add PQ support.
Use the PQ OETF and EOTF to ensure that intermediate fragment shader operations
using PQ are in linear BT.2020 rather than PQ and HLG-1 BT.2020.

Also, swap the OETF and EOTF in shaders, as they were used incorrectly before

Manually tested by verifying transformer demo HLG and PQ videos look the same with and without this CL, including with a BitmapOverlayProcessor enabled to test flows both with one MatrixTransformationProcessor that skips HDR TFs, and with one that doesn't.

PiperOrigin-RevId: 469736067
(cherry picked from commit 2ad07e88ee39ed5f662df91dc7034bd0ce478abe)
2022-08-24 15:44:22 +00:00
Googler
a265a9bb0f Reassign TODO to new bug.
PiperOrigin-RevId: 468672505
(cherry picked from commit ee04bb882509bb072d403d3ff487fd1a02b776d3)
2022-08-19 11:30:19 +00:00
Googler
373ac4c7bd Change onOutputFrameAvailable timestamp from nanos to micros.
Upstream timestamps from the decoder are also in microseconds,
so using microseconds here is consistent with that.

PiperOrigin-RevId: 468659099
(cherry picked from commit 0b1c540ff96b4f4f4ff7cff16a2e51674a42a0c2)
2022-08-19 09:47:28 +00:00
Googler
166838ae70 Allow frame release to be controlled outside FrameProcessor.
Adds a method to FrameProcessor.Listener to be called when an
output frame is available and a method releaseOutputFrame in
FrameProcessor allowing the caller to trigger release of the
oldest available output frame at a given timestamp. Late frames
or frames with unset release times are dropped in the
FinalMatrixTransformationProcessorWrapper.

More than one output frame can become available before they are
released if the penultimate GlTextureProcessor is capable of producing
multiple output frames. Processing continues while waiting for
releaseOutputFrame to be called. Frame release tasks are prioritized
over other tasks.

PiperOrigin-RevId: 468473072
(cherry picked from commit a5d7fdcab52ea6c12fa35efc348b69eccb53f715)
2022-08-18 16:10:48 +00:00
tonihei
f3d48c21f4 Define CueGroup.EMPTY_TIME_ZERO for convenience
We create an empty CueGroup in many places as default or
where none is needed. Instead, we can define a constant
for this purpose and reuse it.

PiperOrigin-RevId: 467944841
(cherry picked from commit 59895646e03ee15aed5e80fb8e60b7f98a7afe5f)
2022-08-16 16:27:56 +00:00
tonihei
b6002a351d Add initial version of SimpleBasePlayer
This base class will simplify the implementation of custom
Player classes. The current version only supports
available commands and playWhenReady handling.

PiperOrigin-RevId: 467618021
(cherry picked from commit 43ede97d2fc71c283755c23b2049eaa3f2a947cb)
2022-08-15 08:54:27 +00:00
huangdarwin
00749d9d26 HDR: Rename ColorInfo#isHdr to isTransferHdr.
While HDR is most closely tied to the color transfer (ex.
COLOR_TRANSFER_SDR is the only one explicitly mentioning dynamic
range), technically color spaces may be associated with HDR as well,
like BT.2020 commonly being used for HDR rather than BT.709 for SDR.

Therefore, it's more specific to mention just that the transfer is HDR.

PiperOrigin-RevId: 466316960
(cherry picked from commit 35161c748956d96e8e83cee007143615ef6f9d07)
2022-08-09 11:28:31 +00:00
huangdarwin
37274c91de HDR: Input ColorInfo to the FrameProcessor.
This allows the GlEffectsFrameProcessor to later handle HLG and PQ
differently, or limited and full color range differently.

No functional change intended in this CL.

PiperOrigin-RevId: 466070764
(cherry picked from commit 536d42c865fd692c1d1799082077906287a2c3f0)
2022-08-08 16:55:22 +00:00
hmzh
dc29b44f05 Add a custom MIME type for MIDI
PiperOrigin-RevId: 466032455
(cherry picked from commit 579f25802a7d51b712c80e2045a76697be0a72e8)
2022-08-08 14:02:08 +00:00
andrewlewis
f8aaed1ac7 Avoid encoder default color info when tone-mapping
The encoder color info [defaults](https://cs.android.com/android/platform/superproject/+/master:frameworks/av/media/libstagefright/foundation/ColorUtils.cpp;l=377;drc=891c19ccfa4953b5e5f7b87118e007b994d8074c) to a value that depends on the input resolution, but when tone-mapping is enabled we should always get BT.709 color space. Hard-code this constant for now to avoid behavior depending on the resolution. A future change should use the decoder output media format to populate the color info.

PiperOrigin-RevId: 465070378
(cherry picked from commit 3c4ee51e10fe0a2ea495f00a3fcd98d6cb83b561)
2022-08-03 16:06:45 +00:00
hschlueter
89edfbc12b Clean up FrameProcessor TODOs.
PiperOrigin-RevId: 465044342
(cherry picked from commit c5d1940fbab430ede4b158300bbb381c032498bf)
2022-08-03 13:53:53 +00:00
huangdarwin
c34e41950b HDR: Have @C.ColorTransfer check consider NO_VALUE as SDR.
Format.NO_VALUE is a placeholder value for an invalid @C.ColorTransfer, used
for example when the decoder doesn't support this transfer function.

When encountering this invalid value, interpret this as COLOR_TRANSFER_SDR.

Confirmed locally that an exception is thrown when transcoding on p4head, and no exception is thrown when transcoding with this CL.

PiperOrigin-RevId: 464135080
(cherry picked from commit 687a50e9b313e5db37a0b32f5f40559252ab6031)
2022-07-29 19:33:44 +00:00
hschlueter
de4c2e08e1 Move FrameProcessor and related interfaces to common.
This will allow effects preview in ExoPlayer to use the
Effect and FrameProcessor interface (and the interfaces
they depend on) without depending on transformer or the
future effects module.

PiperOrigin-RevId: 464060047
(cherry picked from commit 480c129c54777780f298d7e5dbd9fa23a371f660)
2022-07-29 12:54:30 +00:00
huangdarwin
071f0a5a0d Transformer: Improve misc javadocs and exception logs.
PiperOrigin-RevId: 463971447
(cherry picked from commit 534740fd46f5ec9465215eaaa03a764eebab4ac4)
2022-07-29 01:16:26 +00:00
huangdarwin
db1cad911c HDR: Centralize getting Colorinfo from MediaFormat
* Sets KEY_HDR_STATIC_INFO from MediaFormat in the DefaultCodec.
* Adds checks in mediaparser to ensure color space, range, and transfer are valid
  values.

PiperOrigin-RevId: 463921325
(cherry picked from commit 65a2a3a0a073c6dd8b47a044609f4be1abdd19c9)
2022-07-28 21:07:43 +00:00
bachinger
b4172b3490 Exclude Metadata from Format when bundling from TrackGroup
#minor-release

PiperOrigin-RevId: 463062454
(cherry picked from commit 8ce3d4dc729f53c3f44649ae790d7f6b3a63d5da)
2022-07-25 12:29:44 +00:00
ibaker
878279425b Annotate methods that always return this with @CanIgnoreReturnValue
It's always safe to ignore the result of these methods, because the
caller already has a reference to the returned value.

PiperOrigin-RevId: 462388947
(cherry picked from commit 2deb435625c7569cb0bd250848adaa846884dc50)
2022-07-21 15:24:07 +00:00
tonihei
053f68ae46 Add Util helper methods to work with Futures
This adds two methods that are helpful when working with Futures.
One is a version of postOrRun that can indicate completion by a
Future and the other is a simplified version of Guava's
Futures.transformAsync (which can't be used as it's in Beta).

PiperOrigin-RevId: 461896598
(cherry picked from commit f9eec0c0e88db28c758be5e738e9c82291f090bd)
2022-07-19 16:04:45 +00:00
ibaker
d5e0c7597a Add fail-fast null checks to the stable Player API
This will help developers self-diagnose issues like Issue: google/ExoPlayer#10392
where the NPE occurs far from the original null value because a field
gets assigned to null.

This change aims to ensure that every stable method on Player,
ExoPlayer and ExoPlayer.Builder that takes a non-null type will fail
with an NPE before returning.

#minor-release

PiperOrigin-RevId: 461846580
(cherry picked from commit e1fde5d530a43b64f6e0603843ccafe7692e8453)
2022-07-19 11:05:40 +00:00
huangdarwin
54cdec4614 HDR: Use FP16 color representation for texture processors.
* Introduced `useHdr` for `GlEffect#toGlTextureProcessor`, so
  `TextureProcessor` implementations can decide how to handle HDR.
* Creating FP16 color textures for HDR input.

Tested via manual testing, adding a no-op GlEffectWrapper to the transformation to
force use of intermediate textures, adding a linear ramp to the fragment shader,
and trying to ascertain that there's a real reduction in posterization when
switching from 4-bit to 8-bit unsigned bytes, and again from 8-bit unsigned bytes
to 16-bit floating point.

PiperOrigin-RevId: 461613117
(cherry picked from commit ba9c9bb96471a9589d391ae498ebb0c194a5b41e)
2022-07-18 14:21:17 +00:00
hschlueter
fa08d8e219 HDR: Check whether EXT_YUV_target extension is supported.
This extension is needed for editing HDR input with OpenGL, as the
ExternalTextureProcessor samples raw YUV values from the
external texture for HDR and converts them to RGB itself rather than
relying on the OpenGL driver to do this automatically as for SDR.

PiperOrigin-RevId: 460424154
(cherry picked from commit a5ff4ef17f78b64735d82c6b16f0b69af5a570a3)
2022-07-12 11:04:05 +00:00
huangdarwin
bde5f9e30d HDR: Remove ColorInfo.SDR constant
The SDR constant also specified a color space and range, in addition to
C.COLOR_TRANSFER_SDR. However, it turns out that SDR videos may use different color
space and range values, so following prior ExoPlayer conventions to have `null`
mean "generic SDR" is preferable here.

PiperOrigin-RevId: 459296746
(cherry picked from commit 7078ce312d3650ef70dcd8ed236af88dc07b5333)
2022-07-06 18:11:11 +00:00
huangdarwin
c199608589 HDR: Throw error if attempting HDR editing under API 31.
HDR editing is not supported under API 31

PiperOrigin-RevId: 459211106
(cherry picked from commit ab7747d9533c0ed1c5d096743741607b0e08c609)
2022-07-06 10:25:30 +00:00