Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneous onPlaybackStatsReady calls when changing playlist #180

Closed
1 task
vfsfitvnm opened this issue Oct 5, 2022 · 10 comments
Closed
1 task

Erroneous onPlaybackStatsReady calls when changing playlist #180

vfsfitvnm opened this issue Oct 5, 2022 · 10 comments
Assignees
Labels

Comments

@vfsfitvnm
Copy link

vfsfitvnm commented Oct 5, 2022

Media3 Version

1.0.0-beta02

Devices that reproduce the issue

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

Let's consider the following playlist:

0. A
[...]
497. B
498. C
499. D

And the following onPlaybackStatsReady:

override fun onPlaybackStatsReady(eventTime: AnalyticsListener.EventTime, playbackStats: PlaybackStats) {
    val mediaItem = eventTime.timeline.getWindow(eventTime.windowIndex, Timeline.Window()).mediaItem
    val totalPlayTimeMs = playbackStats.totalPlayTimeMs

    println("${mediaItem.mediaId} played for ${totalPlayTimeMs}ms")
}

Case 1

  1. Play B
  2. Change playlist

Case 2

  1. Play B
  2. Play C
  3. Play D
  4. Change playlist

Expected result

Case 1

B played for 1000ms

Case 2

B played for 1000ms
C played for 1000ms
D played for 1000ms

Actual result

Case 1

B played for 1000ms
A played for 1000ms

Case 2

B played for 1000ms
C played for 1000ms
D played for 1000ms
A played for 2996ms

Media

Not applicable

Bug Report

@vfsfitvnm
Copy link
Author

device-2022-10-05-190902.mp4

@vfsfitvnm vfsfitvnm changed the title Erroneous onPlaybackStatsReady calls when chaning playlist Erroneous onPlaybackStatsReady calls when changing playlist Oct 5, 2022
@tonihei
Copy link
Collaborator

tonihei commented Oct 6, 2022

Could you clarify what you mean by "Change playlist" in your instructions? It seems "A" is never played in the reproduction steps, so it's not entirely clear why you expect a callback for this media item.

Note that the onPlaybackStatsReady is only called once an item definitely finished playing, so maybe it just happens later than you expect it happen?

@tonihei tonihei self-assigned this Oct 6, 2022
@vfsfitvnm
Copy link
Author

After submitting the issue I realized I put the "expected result" as "actual result" as vice versa - and I quickly edited the message. However I think you still read the original message (via e-mail maybe) - however yes, "A" is never played and so I do not expect a callback to be called for such media item.

But as you can see from the screen recording, the callback for "A" occurs.

For "changing playlist" I meant calling player.setMediaItems(...) (this is what happens in demo-session).

@vfsfitvnm
Copy link
Author

vfsfitvnm commented Oct 6, 2022

To add more, playing around with playlist changes, I can see suspicious calls for the first media item of the just-replaced playlist with playbackStats.totalPlayTimeMs equals to zero.

@tonihei
Copy link
Collaborator

tonihei commented Oct 10, 2022

I can reproduce what you are seeing, but it looks as if everything is working as intended.

PlayableFolderActivity in the session demo app calls:

browser.setMediaItems(subItemMediaList)
browser.seekToDefaultPosition(/* mediaItemIndex= */ position)

The first method will start playback with the first item in the list, the second call will update the position to the item you tapped. So the PlaybackStatsListener correctly tracks 0 play time for the first item in the list as it was briefly the active item.

To actually avoid the issue, the PlayableFolderActivity should set the item list and the start position in one command. I'm going to update the code accordingly.

browser.setMediaItems(subItemMediaList, /* startIndex= */ position, /* startPositionMs= */ C.TIME_UNSET)

@vfsfitvnm
Copy link
Author

That's what I thought too, but I swear I couldn't find such setMediaItems overload. This solves the original issue!

However, I still find odd that onPlaybackStatsReady (having the first mediaItem of the playlist) is called with totalPlayTimeMs not equal to zero. It looks like the playback time counter keeps running with these calls:

browser.setMediaItems(subItemMediaList)
browser.seekToDefaultPosition(/* mediaItemIndex= */ position)

@tonihei
Copy link
Collaborator

tonihei commented Oct 10, 2022

It was always zero in my tests. Can you describe a specific sequence of item selections that cause the additional problem of keeping the counter running? And also, where exactly did you add/remove/replace the PlaybackStatsListener?

@vfsfitvnm
Copy link
Author

Here's the fork which reproduces the issue: https://github.com/vfsfitvnm/media

Steps to reproduce:

  1. Album folder > Jazz & Blues > (scroll all the way down) The Messenger
  2. Let the music play for few seconds
  3. Play any other playlist - i.e. Album folder > Irsen's Tale > Leaving

@tonihei
Copy link
Collaborator

tonihei commented Oct 11, 2022

Thanks for the helpful reproduction steps. This is indeed a bug in our session tracking that happens only for the case where we seek very quickly to a new item before the current one got the chance to update its internal state. We'll provide a fix for this as well.

marcbaechinger pushed a commit that referenced this issue Oct 17, 2022
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: #180
PiperOrigin-RevId: 480031682
marcbaechinger pushed a commit that referenced this issue Oct 17, 2022
We already have logic to end all session except the current one if the
current one doesn't have a MediaPeriodId yet. This is assuming that this
only happens after a seek on the app side where the player doesn't have
detailled knowledge about the MediaPeriodIds yet.

Currently this logic isn't triggered if the window we are coming from
doesn't have its MediaPeriodId either as we run into another check that
keeps sessions around until we have a valid windowSequenceNumber.

Swapping both conditions fixes this case without breaking any of the
other known transition scenarios.

Issue: #180
PiperOrigin-RevId: 480866465
marcbaechinger pushed a commit to google/ExoPlayer that referenced this issue Oct 20, 2022
We already have logic to end all session except the current one if the
current one doesn't have a MediaPeriodId yet. This is assuming that this
only happens after a seek on the app side where the player doesn't have
detailled knowledge about the MediaPeriodIds yet.

Currently this logic isn't triggered if the window we are coming from
doesn't have its MediaPeriodId either as we run into another check that
keeps sessions around until we have a valid windowSequenceNumber.

Swapping both conditions fixes this case without breaking any of the
other known transition scenarios.

Issue: androidx/media#180
PiperOrigin-RevId: 480866465
microkatz pushed a commit that referenced this issue Nov 22, 2022
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: #180
PiperOrigin-RevId: 480031682
(cherry picked from commit 5d6d069)
microkatz pushed a commit that referenced this issue Nov 22, 2022
We already have logic to end all session except the current one if the
current one doesn't have a MediaPeriodId yet. This is assuming that this
only happens after a seek on the app side where the player doesn't have
detailled knowledge about the MediaPeriodIds yet.

Currently this logic isn't triggered if the window we are coming from
doesn't have its MediaPeriodId either as we run into another check that
keeps sessions around until we have a valid windowSequenceNumber.

Swapping both conditions fixes this case without breaking any of the
other known transition scenarios.

Issue: #180
PiperOrigin-RevId: 480866465
(cherry picked from commit 409c9f8)
microkatz pushed a commit to google/ExoPlayer that referenced this issue Nov 22, 2022
We already have logic to end all session except the current one if the
current one doesn't have a MediaPeriodId yet. This is assuming that this
only happens after a seek on the app side where the player doesn't have
detailled knowledge about the MediaPeriodIds yet.

Currently this logic isn't triggered if the window we are coming from
doesn't have its MediaPeriodId either as we run into another check that
keeps sessions around until we have a valid windowSequenceNumber.

Swapping both conditions fixes this case without breaking any of the
other known transition scenarios.

Issue: androidx/media#180
PiperOrigin-RevId: 480866465
(cherry picked from commit 6070d91)
guoen21 added a commit to DiceTechnology/ExoPlayer that referenced this issue Dec 8, 2022
* Clean up FrameProcessor TODOs.

PiperOrigin-RevId: 465044342
(cherry picked from commit 245326a0433c82bf851e2fa556bb8399cf1ba2d6)

* Clean up NOP constructor lines in RTP readers

PiperOrigin-RevId: 465067191
(cherry picked from commit 13e9ec9959b5dbd6f2f107f43d0a3a032ae8a717)

* Fix saving previous debugSurfaceView in FinalMatrixTPWrapper.

PiperOrigin-RevId: 465067306
(cherry picked from commit bbb7b1c0bc2dc004612d0644d862494fcdda294d)

* 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 40a28d5aeeb5f3c22e884690128182b68a9929f6)

* Remove clamp function in contrast fragment shader.

* OpenGL automatically clamps the output colors to the [0, 1] interval.

PiperOrigin-RevId: 465071999
(cherry picked from commit 30fab8c00891b2a5423c169dd75ef0b7d40fe5b7)

* AudioOffload recovery.

Avoids disabling Offload on a write error, and instead relies on this being disabled on the AudioTrack init. It will no longer recover by disabling offload.

PiperOrigin-RevId: 465248917
(cherry picked from commit 2fbe1bbfb3c533c370c07a4f45068c00ea9c6efb)

* Expose AudioOffload track state.

Adds a new event to AudioOffloadListener to get the offload state of the track, which indicates when software decoding is taking place.

PiperOrigin-RevId: 465264362
(cherry picked from commit fe2b846552e1dc0095a409a3407c328e38bd6a30)

* Factor out RTP timestamp to sample time method

PiperOrigin-RevId: 465337074
(cherry picked from commit a1be6d6eb39a40b91f9dee0524d13e5ac805246f)

* HDR: Add comment to clarify lack of support HDR10 for AVC

PiperOrigin-RevId: 465360186
(cherry picked from commit e63d594f490da6461bc5087d0526c5ca5215958d)

* Add RgbAdjustment class to build RgbaMatrices

* Add RgbaMatrix interface implementation.
* Add Builder class for easy adjustments.
* Adjust existing RgbaMatrixPixelTests to use new RgbAdjustment class.

PiperOrigin-RevId: 465545429
(cherry picked from commit 6502fce634913420af77ec78c275f97a61b8fac4)

* Use multiple output frames in transformer MediaPipe demo pre API 23.

PiperOrigin-RevId: 465545764
(cherry picked from commit 6da0a3543491a9d9bb3dbfaf1b203a04f7a19f5c)

* Fix frame processor reference

PiperOrigin-RevId: 465562260
(cherry picked from commit aafa31e996f30daebec12f5e9e61aab1dbd0ba81)

* Make AudioTrackBufferSizeProvider public.

Was getting "java.lang.IllegalAccessError: Illegal class access" in debug app.

PiperOrigin-RevId: 465562541
(cherry picked from commit c09b34a61be80f250bac6a5e1f56e8180f68b9e2)

* Fix ConcurrentHashMap usage in demo MediaPipeProcessor.

PiperOrigin-RevId: 465563540
(cherry picked from commit 6e4fc4752248f1a1d233dea041305718cae08cd0)

* Clarify SSIM request method name

`requestCalculateSsim` more clearly represents the intention of the caller.

Also rephrase the javadoc to simplify it and make it more precise.

PiperOrigin-RevId: 465575578
(cherry picked from commit d90d7d30789ec819d905fd98291f66ab7031f47b)

* Throw if tone-mapping is requested but not enabled

In the case where this check fails, the downstream frame processor chain won't be able to handle the incoming (SDR) data anyway as we've already set it up for HDR.

PiperOrigin-RevId: 465584814
(cherry picked from commit 0e99d28a79ddca5ba9517ffba73d2c36fc2679a7)

* Switch @param to @code tags in RgbAdjustment.

PiperOrigin-RevId: 465591877
(cherry picked from commit 650a9d21ec6582230f4cf0dc2120b17d86707715)

* Add support for multiple mid-track tempo changes

PiperOrigin-RevId: 466018462
(cherry picked from commit 4725cff70e3293f43bd11866f305041c6c18792e)

* Remove unused log tag constant

PiperOrigin-RevId: 466025324
(cherry picked from commit 273cf0866aad78018da3674ba1cbe11187d16afd)

* Add a custom MIME type for MIDI

PiperOrigin-RevId: 466032455
(cherry picked from commit 3aa99d5efbd87a410dd8177539e54185c6b17176)

* 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 e444eaa5b76074bbf77a6cab6dfe288665a20204)

* Split GlTextureProcessor.Listener into input/output/error listener.

This simplifies ChainingGlTextureProcessor as it now only connects a
consuming and a producing GlTextureProcessor rather than a previous,
current, and next GlTextureProcessor.

Also use default no-op implementations of the listeners in
SingleFrameGlTextureProcessor and MediaPipeProcessor to avoid
null-checks.

PiperOrigin-RevId: 466301642
(cherry picked from commit a2166a414212a4e10c31b72dfa21ff45367ee31a)

* 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 7075f78eb26daef44275a6fde5362d5139e6df37)

* Remove times(1) from effect and transformer tests as it is the default.

PiperOrigin-RevId: 466324322
(cherry picked from commit 95a7dcaedaf617802054e37acdb3d46d4923ccac)

* Add JSyn library build instructions for the MIDI module

PiperOrigin-RevId: 466370644
(cherry picked from commit 96a2b149b185206d9e5f079251f8808d39a52e48)

* Demo: Add legacy external storage permission for intents.

Without this permission, files in `/sdcard` or other directories cannot be read by the demo, as they're not in the transformer demo's scoped storage container.

For more information, see https://developer.android.com/training/data-storage/use-cases

Tested by uninstalling and re-installing the demo app, granting permission by
starting a transformation, and launching an intent using a local file in `/sdcard`
to start another transformation. Without this CL, this threw an error, and with
this CL it succeeded.

PiperOrigin-RevId: 466399023
(cherry picked from commit 051dee68e362b8d610a42ac01f7ed9cc5f6b894a)

* HDR: Update experimental_setEnableHdrEditing javadoc.

Previously, this feature interpreted SDR signals as HDR when called. Now, only HDR
streams are interpreted as HDR, so the javadoc should be updated. Not yet removing
this method, as there are still some loose ends to finish up (ex. PQ support, e2e
tests).

PiperOrigin-RevId: 466425738
(cherry picked from commit 2d2926b8c0b4cded25616558ed74cb30cc2932fd)

* Avoid spinning in between intermediate texture processors.

This change adds a new method onReadyToAcceptInputFrame to
GlTextureProcesssor.InputListener and changes maybeQueueInputFrame
to queueInputFrame, removing the boolean return value.
This avoids the re-trying in ChainingGlTextureProcessorListener
by allowing it to only feed frames from the producing to the consuming
GlTextureProcessor when there is capacity.

MediaPipeProcessor still needs re-trying when processing isn't 1:1.

PiperOrigin-RevId: 466626369
(cherry picked from commit 9c366b3cfdd06cad046dd5ce1b0ecad21c5c44ba)

* HDR: Clarify tone mapping fallback.

createSupportedTransformationRequest is more accurate than
createFallbackTransformationRequest, as a TransformationRequest will be returned
regardless of whether any fallback is applied.

PiperOrigin-RevId: 466641277
(cherry picked from commit 70972bbab0c884bcc2ef1dfef2177967499c36b6)

* Fix ChainingGlTextureProcessorListener field name.

PiperOrigin-RevId: 466735554
(cherry picked from commit 43aa89aa2ef04756f185738bbd7c17c236bff879)

* Add timeout for ad to load.

In some cases, the IMA SDK fails to call the expected loadAd
event to load the next ad to play. This is (potentially) the
only remaining case where playback can get stuck due to missing
calls from IMA as the player doesn't even have a MediaSource at
this stage and is only waiting for IMA to provide the ad URL.

We can reuse the existing adPreloadTimeoutMs that was added for
a similar purpose (when preloading the first ad in the group).
The JavaDoc matches this purpose as well and the default timeout
is appropriate since we expect to get the loadAd call immediately.

Issue: google/ExoPlayer#10510
PiperOrigin-RevId: 466953617
(cherry picked from commit 91fc5c4f3c52c02439d1e65f09fa2d2c1c5fcf05)

* Add additional build flags for ffmpeg on "arm64-v8a"

From NDK 23.1.7779620 and above, the arm64-v8a ABI needs additional
build flags to correctly link the ffmpeg libraries.

Issue: google/ExoPlayer#9933
PiperOrigin-RevId: 467161973
(cherry picked from commit 6ea1d0ecf068d866faf2f1c0f4624ae5de872497)

* Avoid spinning while queueing input to ExternalTextureProcessor.

This change adds ExternalTextureManager which implements
InputListener to only queue input frames to the
ExternalTextureProcessor when it is ready to accept an input
frame. This replaces the old retry-logic in GlEffectsFrameProcessor.

Before this change, the retrying in GlEffectFrameProcessor wasted
CPU time if input becomes available faster than the
ExternalTextureProcessor can process it.

PiperOrigin-RevId: 467177659
(cherry picked from commit 06ce5ec73898d5e56eb5a2e0f68d4910919c5ea7)

* Refactor RgbaMatrix to RgbMatrix.

* Rename all Rgba instances to Rgb.
* Remove alpha value from the RGBA Matrices and apply the 4x4 matrix
only to the R, G, B channels.
* Restore the alpha from the input unchanged.

PiperOrigin-RevId: 467208888
(cherry picked from commit 80f9ad9bf9631a61c06317df54a68be248e23b4f)

* Increase pixel difference threshold

PiperOrigin-RevId: 467610621
(cherry picked from commit ec7936f64d8019c94d69bcd7a31e2002fcaca695)

* 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 9a7fde8fde6e194b92ec67095b7b889ee23a3d77)

* Update CMake version for AV1 extension

The specified CMake version doesn't work with the latest
Android Studio releases. Updating to a more recent version
fixes the problem.

Issue: google/ExoPlayer#9933
PiperOrigin-RevId: 467634063
(cherry picked from commit 80b635e7abf3a980b801c49c7975c4963aed7518)

* Increase max sample size for HEVC.

Increase the estimated max sample size for HEVC by 2x, and set a minimum
size of 2MB. The 2MB will be applied for resolutions up to 1080p, after
which the new calculation takes effect. This is in par with the
platform's HEVC software decoder.

PiperOrigin-RevId: 467641494
(cherry picked from commit d3d5ffce91452ebf1edf51a0c0c9d80ad29fe0b6)

* Allow high-priority tasks to be executed before other tasks.

This is needed as a pre-requisite for allowing MCVR to control
FrameProcessor frame release for previewing.

Submitting a high-priority task is conceptually different from
posting at the front of a single queue of tasks, as the high-priority
tasks are executed in FIFO order among themselves. This will ensure
that frame release tasks submitted in close succession are executed
in the order they are submitted but before any lower priority tasks.

PiperOrigin-RevId: 467675137
(cherry picked from commit 4d81a6db240b0f5b92936d894d59b53cc493e3b2)

* HDR: Update limited range and add full range YUV to RGB color transforms.

PiperOrigin-RevId: 467910378
(cherry picked from commit 130a536287f705ea823c9351d053f01512bf7e3c)

* 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 29208ec1ed4d78fa86af33b81a2b32f3151b9004)

* Compact a RGB Matrix chain into a singular RGB Matrix.

PiperOrigin-RevId: 468013019
(cherry picked from commit 977370e9db8fda16388a56f8979df9f6f6737b60)

* Fix typo

PiperOrigin-RevId: 468152718
(cherry picked from commit c6a10ad2270ecf295dc06ac338eae6367b7887ca)

* Defensively cancel frame processing tasks on error.

FrameProcessingTaskExecutor should be released on error.
There can be a delay until this happens, so
FrameProcessingTaskExecutor will cancel any pending tasks
and drop new tasks until it is released.

PiperOrigin-RevId: 468171820
(cherry picked from commit d11c3be952d4a5cd31b7f629b427bdddcbf3f15c)

* HDR: Clamp YUV to RGB conversion.

Manually tested using transformer demo HLG videos. Before this CL, RGB values after the YUV to RGB conversion reached up to 1.025. After this CL, RGB values correctly clamp at 1.0.

PiperOrigin-RevId: 468426092
(cherry picked from commit 32ee44805b33d3fedf9d36905fa22d20a2800d78)

* 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 2c063546a1ac8607eb4632acb88506b9a0d46b9e)

* Fix the command sample size given to trackOutput.

Remove the manual overwriting of Note ON events that have 0 velocity with Note OFF. JSyn handles this already.

- The implementation of "running status" means that the amount of bytes read from the file differ from the size of the sample that ends up in the decoder. The decoder sample contains the applied running status (status of previous event), which the file bytes don't contain.

PiperOrigin-RevId: 468537659
(cherry picked from commit 53218b50d465939b74a64fdc87ecaca5f1a95b57)

* 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 4e7f9c575d9ff003f1cc4d4a9f464c6df6b4077a)

* Add device info to CastPlayer

Issue: androidx/media#142
PiperOrigin-RevId: 468666737
(cherry picked from commit d6442f63fa9cb3e5197109d11cadcd482ef5c6a4)

* Reassign TODO to new bug.

PiperOrigin-RevId: 468672505
(cherry picked from commit 010ecec89dcaf74d9536f92a5b99152d99816dfa)

* Handle initial RTSP seek

PiperOrigin-RevId: 469143613
(cherry picked from commit c611435521a868d6675556f05bd2e325355b7e02)

* Replace usage of `android_binary` with `build_test` for libraries

`android_binary` is only required when building an application.

PiperOrigin-RevId: 469413752
(cherry picked from commit f01896af156efdafeaef6a5eb13e9d251a2e1d57)

* Bind contrastFactor in constructor instead of drawFrame method.

PiperOrigin-RevId: 469438747
(cherry picked from commit 9a1e7fbdf41e9de1f5d69590a305ebfafaa3ad07)

* Fix outdated RtpDataLoadable javadoc

PiperOrigin-RevId: 469443086
(cherry picked from commit 5cf166c15767eaac16ce29df9d08d589946d6cae)

* 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 a2139109e3e67d830be8fd5a342687a569009270)

* Fix missing id error

PiperOrigin-RevId: 469750922
(cherry picked from commit 2c70383d38a50482df57f6558b55b2057cbe56c7)

* HDR: Rename GL_COLOR_TRANSFER instances to COLOR_TRANSFER

PiperOrigin-RevId: 469959215
(cherry picked from commit 0f48c89f1f500d211cf6b118214d4bcbf9ef3e13)

* Delete glPrograms in Contrast and RgbMatrix.
Remove unecessary null checks.

PiperOrigin-RevId: 469999952
(cherry picked from commit f454c9aa7490e40d0ea5fdda6aa5698e7e6f6065)

* Switch incorrectly configured native multidex to legacy

Native multidex can only be used for binaries with minSdkVersion of 21 or higher, but minSdkVersion was specified to 16.

PiperOrigin-RevId: 470003836
(cherry picked from commit 142d1c062c4ed4fba450465588217ae5506fece3)

* Switch incorrectly configured native multidex to legacy for demos

Native multidex can only be used for binaries with minSdkVersion of 21 or higher, but minSdkVersion was specified to 16.

PiperOrigin-RevId: 470004102
(cherry picked from commit a395b23d985dd4a118b125c3d121a7e39e2e5435)

* Fix ExternalTextureManager: repeated queueing input frame in preview

TL;DR: we should check if there are new frames available to queue to the
ExternalTextureProcessor before actually queueing a frame.

The overall flow on the external texture processor:

- `SurfaceTexture.onFrameAvailable` is called on `ExtTexMgr`, and
  - it calls `updateTexImage()`, and sets `frame`
  - it calls `maybeQueueFrameToExtTexProc()`
    - the frame is queued to `ExtTexProc` if `frame` is set

  - From `ExtTexProc.queueInputFrame()`:
    - notifies the `frameProcessorListener` of available frame
    - notifies the `inputListener` of `onReadyToAcceptInputFrame`
      - (`ExtTexMgr` is the listener), it calls `maybeQueueFrameToExtTexProc()`
       again

-- Parallelly --
- `ExtTexProc` calls `inputListener.onInputFrameProcessed`, when the frame is
released
  - (`ExtTexMgr` is the listener), sets `frame` to `null`

*Problem*

This logic relies on `frame` to be cleared at the right time.

In transformer, it's OK b/c `ExtTexProc` release the frame immediately in
`queueInputFrame()` and calls `onInputFrameProcessed` which also reset `frame`

But in previewing, the frame is not released for a while, up to 10 ms.
In this case, `frame` will not reset in this 10 ms, and
`maybeQueueFrameToExtTexProc()` is repeatedly queueing the same input frame.

PiperOrigin-RevId: 470211620
(cherry picked from commit a8c54dd378577cc472a1e56fff062b7959e00268)

* Log instead of throwing for transfer mismatch

PiperOrigin-RevId: 470354448
(cherry picked from commit f1a3a40eb1d8a640fed0d7735088a30d00038234)

* Update color info mismatch test

This should now expect transformation to succeed.

PiperOrigin-RevId: 470950411
(cherry picked from commit 1023254d8e8b9bab6001ab550676adac96ae0c50)

* Fix 1 ErrorProneStyle finding:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 470953422
(cherry picked from commit f26e5d4c21d34da840152452f648051322d505eb)

* Remove media3-only line from exoplayer2 `build.gradle` file

#minor-release

PiperOrigin-RevId: 470999044
(cherry picked from commit e285e7078545435e86e3d43219ad9f6fc8373755)

* Update first frame instructions.

PiperOrigin-RevId: 471008623
(cherry picked from commit cb60f506d1f6283e2790ee631c01c5c4128967a2)

* Add static Grayscale and Inverted RGB Filter.

PiperOrigin-RevId: 471017440
(cherry picked from commit 9f67ce4e4c1d6e26a0920bf9bed89c38cecbdaeb)

* Fix 19 ErrorProneStyle findings:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment) (19 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 471022923
(cherry picked from commit 674b3d4575ae6fdb59ae9db58be52151bbcae3a6)

* HDR: Use factory for MatrixTransformationProcessor.

Separate MatrixTransformationProcessor constructors by color input and output.

PiperOrigin-RevId: 471034768
(cherry picked from commit a8e814abbd435755077b2f92cf709d5417494db7)

* 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 e6a1936ba9e210555eaa61a9b6d206bdfa753f09)

* Add @SuppressWarnings to nullness errors detected by a newer version of the Checker Framework

PiperOrigin-RevId: 471137219
(cherry picked from commit 90e684a6dcd5d92470780060feb2099c2f905bbd)

* Fix 3 ErrorProneStyle findings:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment) (3 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 471198016
(cherry picked from commit bac7d697c3620195f8895068369099466fb7bd1c)

* Skip transcoding if HDR video does not need encoding.

https://github.com/google/ExoPlayer/commit/3b0d2c15867b3698f130476736785d427b28b7bd made `shouldPassthrough` always return false for `enableHdrVideoEditing`:

>We force using `FrameEditor` (no passthrough) to avoid the need to select another edit operation, and use the new shaders. The `EGLContext` and `EGLSurface` also need to be set up differently for this path.

However, this was introduced before the `videoNeedsEncoding` setting was introduced in https://github.com/google/ExoPlayer/commit/3f615040c033a37f81b1d73605cd1f7d420b47b5. That setting should apply to HDR videos as much as SDR videos.

PiperOrigin-RevId: 471569853
(cherry picked from commit 94713a8ffb6ba4e83a05bb50921b4cf2ab2eab75)

* Rename shouldPassthrough to shouldTranscode

shouldPassthrough's internal checks seem to be check whether we should *not*
pass through, which seemed a bit like a confusing double-negative to me.

shouldTranscode is slightly more clear, by instead returning true when we do
want to transcode.

No functional changes intended.

PiperOrigin-RevId: 471753771
(cherry picked from commit 1a4cd549a426881474014a02b595382b375864ee)

* Add sepia, grayscale, and inverted filters to the demo app.

PiperOrigin-RevId: 471782565
(cherry picked from commit 87926f0ba8480f39baeb9f9d0ccf8f3576e4fd0e)

* Minor javadoc and scoping cleanup.

No functional changes.

PiperOrigin-RevId: 472245797
(cherry picked from commit 8e14611d60d40f0db41063a5e537638b76c2d46a)

* Fix 1 ErrorProneStyle finding:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 472252461
(cherry picked from commit dfdcf76daf7762fd40f593662bbb1f5141db1da7)

* Fix 3 ErrorProneStyle findings:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment) (3 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 472254253
(cherry picked from commit 83966478960ae6c0f882e523d73848edab95fd3a)

* Merge RgbProcessor and MatrixTransformation.

PiperOrigin-RevId: 472325145
(cherry picked from commit daa77da17de156ea9921914aad791882c4393b84)

* Use super class for toGlProcessor in RgbFilter.

PiperOrigin-RevId: 472405147
(cherry picked from commit c0ad9f51faa5b61e281178666c2cad75329b37f6)

* Make MatrixTransformationsProcessor constructor to take in Lists.

* Replace ImmutableLists to List interface for constructors

PiperOrigin-RevId: 472433434
(cherry picked from commit ce0e3a4fa3e829c987e541f30694a73d8abbc25b)

* Include CamcorderProfile resolution in encoder capability test

PiperOrigin-RevId: 472459423
(cherry picked from commit 6e45824992c8fe72ffd2f4edb726aa0cd8f8c29e)

* Bump IMA SDK version for gradle

PiperOrigin-RevId: 472500789
(cherry picked from commit 60a3ea48b8abf3949a87a2b3bc930ce83cf4ce3f)

* Remove redundant constant definition

PiperOrigin-RevId: 472522846
(cherry picked from commit 9a9baa54a5cdf701695556a91436b2778868cddd)

* Discard backbuffer before playback gets stuck.

If the back buffer is using too much memory, there is a risk
playback could get stuck because LoadControl refuses to load
further data. This eventually results in a stuck-buffering
playback error.

We can detect this case, clear the back buffer and then ask
the LoadControl again to avoid failing playback in such a case.

PiperOrigin-RevId: 472679797
(cherry picked from commit 125646e4c98e80b35d1a8b195300d324a9aaf2b5)

* Add withAvailableAd for server side inserted ad groups

#minor-release

PiperOrigin-RevId: 472714732
(cherry picked from commit 072f376b4839b6d4e71bcd09366695b3b9fc2c02)

* Clarify GlTextureProcessor.InputListener contract

PiperOrigin-RevId: 472745311
(cherry picked from commit 32a21641a2de5fe1fac1c6f1d1a0d644101a4c0b)

* Remove conditional check for no-longer flaky API version

PiperOrigin-RevId: 472949850
(cherry picked from commit caefa565f76912922011155cc580d45243e86ecc)

* HDR: Add fallback MH tests.

Test that HDR editing succeeds on devices supporting HDR editing, tone maps on
devices supporting tone mapping, and throws exceptions on all other devices.

Also, only restrict HDR editing and tone mapping support to API 31+ only when
transcoding, not for all transformations.

PiperOrigin-RevId: 472958965
(cherry picked from commit 8ee2121627c2702419402b514fa93dbe8ac19b8b)

* Add caching for compositeRgbMatrixArray.

* Refactor caching for matrix transformations to reuse it for rgb matrices.

PiperOrigin-RevId: 473042194
(cherry picked from commit 593370bb69ca5db1d693d42509da78ad496218db)

* Decoder: Reduce max pending frame count limit down to 5.

PiperOrigin-RevId: 473212543
(cherry picked from commit 41963fce9b7ad7d2cd9d0fdb428c44eb2bddf5f1)

* Handle int instead of byte in SSIM.

The value of pixels are converted to integers at the point of use,
move this logic to the initialisation step.

This is a prerequisite step for testing SSIM calculation, which
will lead on to some SSIM improvements being verifiable.

Tested manually and SSIM values match for the same video
before and after this change.

PiperOrigin-RevId: 473231779
(cherry picked from commit eb6c1183b69d319a610d79ef57028f62e74a7614)

* Rollback of https://github.com/google/ExoPlayer/commit/eb6c1183b69d319a610d79ef57028f62e74a7614

*** Original commit ***

Handle int instead of byte in SSIM.

The value of pixels are converted to integers at the point of use,
move this logic to the initialisation step.

This is a prerequisite step for testing SSIM calculation, which
will lead on to some SSIM improvements being verifiable.

Tested manually and SSIM values match for the same video
before and after this change.

***

PiperOrigin-RevId: 473259446
(cherry picked from commit 8f9c9d0f88374573f32d76cf7d3a8fde9ca83f87)

* Rename MatrixTransformationProcessor to MatrixTextureProcessor.

PiperOrigin-RevId: 473283967
(cherry picked from commit 40f1bd345a601648bac8f812b4e247140bc420b1)

* Split decoding out of the test

This method is useful for other tests also.

PiperOrigin-RevId: 473574282
(cherry picked from commit f770324f31cd1d63f229b3d536d7f5a58a0fc511)

* Add rgb matrices to java docs for public constructors.

PiperOrigin-RevId: 473699927
(cherry picked from commit 75f920bf25bf052630a16d1d983516409e797363)

* Add java docs for ContrastProcessor constructor.

* Add docs for the public constructor for consistency with all the
other frame processors.

PiperOrigin-RevId: 473726586
(cherry picked from commit 696ef2a5e718ac8df1edf54ad5359389686267b0)

* Add MssimCalculatorTest to verify SSIM calculations.

As part of this change, MssimCalculator is moved from androidTest/ to main/

PiperOrigin-RevId: 473771344
(cherry picked from commit 20aa22c9fad2c1e2d237dc9a8bee81781a729445)

* Change ContrastProcessor java doc for consistency.

PiperOrigin-RevId: 474002026
(cherry picked from commit 7c435621ae3b3ea870fe16524ff7aaa5bd54e931)

* Clarify the replaceOutputBuffer parameter because count is unclear.

PiperOrigin-RevId: 474279220
(cherry picked from commit 3e0ad6d8042c9e6604c281e283885b9e07eb8786)

* Add support for skipping windows in MssimCalculator.

By skipping every other row and column, SSIM calculation time reduces by 10-30%.

PiperOrigin-RevId: 474286702
(cherry picked from commit 6dd2a6dac655f538020a4057e3ab6d997449a9fe)

* Fix testId and match it to the test name.

PiperOrigin-RevId: 474363545
(cherry picked from commit 0e2b6a03b5f91eda6d307b63f49986dfdcc97bfe)

* Add LUT functionalities to transformer.

* Adds SDR 3D LUT functionalities with OpenGL 2.0 support.

PiperOrigin-RevId: 474561060
(cherry picked from commit 702419dd227cec4b23cd6e723a6a15908313f7c9)

* Fix tracing under offload.

Currently doSomeWork is never closed and so tracing is deceiving.

See https://screenshot.googleplex.com/eZDzn5APpBNnhe5

PiperOrigin-RevId: 474755816
(cherry picked from commit 005b73c82a1a3264a7167ffdf93a9387c4d22b95)

* Fix outdated command in bitmap/README.md.

* The command changed after creating a custom effects module.

PiperOrigin-RevId: 474777823
(cherry picked from commit fd6b0d1551af6db9de49dd17c30937a4b292357d)

* Fix instrumentation tests not working via Gradle

PiperOrigin-RevId: 475560401
(cherry picked from commit 6015f052ba1b21bea4ded5bfc4924dc1c096b07a)

* Use golden bitmaps in contrast pixel tests.

PiperOrigin-RevId: 475805421
(cherry picked from commit 06c0040ab43820164bc048d85556727aaa9fa4f8)

* 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 08bb01b218461506352ae4c2f17efd27989553e5)

* Add RGB Adjustments to transformer demo.

PiperOrigin-RevId: 476049125
(cherry picked from commit cfc0eef24ec4a24bc00b0a657f3dad07e9c29ade)

* 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 331d4d626fcb1b65088c7ab849c0a0a3f5f6ba0e)

* 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 afd829e5db17c48abccea30842eec20b702aa330)

* Add HSL Adjustments to the effects module.

PiperOrigin-RevId: 476144167
(cherry picked from commit 2c27cd82f1e97d14f609ea5bb6924398a9dddfd6)

* HDR: Assert output C.ColorTransfer for tests.

To confirm that tone mapping did or did not happen.

PiperOrigin-RevId: 476354606
(cherry picked from commit df58107eae0dd7e19f9b551751d1fbb19ca05e6d)

* 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 94a88e93d91e86c93239639a65612eab297efa9b)

* Remove TODOs for merging RGB and MatrixTransformation processors.

PiperOrigin-RevId: 476362571
(cherry picked from commit af19f82f994e5820889a9166c0a97606496fd17d)

* Fix broken links on https://exoplayer.dev/troubleshooting.html

#minor-release

PiperOrigin-RevId: 476366214
(cherry picked from commit 0969118041e9fb0a8641240282c91959805c271d)

* Add HSL Adjustments to the demo.

PiperOrigin-RevId: 476373520
(cherry picked from commit 5725ebbeeaf1cbb1a1ffc156d67472640059bd0a)

* Add example CLUT to demo.

PiperOrigin-RevId: 476390089
(cherry picked from commit 29cf09316e8056e3703809d6b6ac8eea890e2e4e)

* 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 ccb820dd2f43ff20dff06a92a4e29c13676e647d)

* HDR: Update gamma comments to linear.

Comment-only change.

PiperOrigin-RevId: 476873286
(cherry picked from commit f3d132141e2c40797b80fab674e9ed8f4062e7ba)

* Fix badly formatted AudioProcessor javadoc.

PiperOrigin-RevId: 476909855
(cherry picked from commit 9b1909e56362a5b44ba41d8cad9c3d927bdb650b)

* Fix checkboxes on configuration  page

PiperOrigin-RevId: 477166507
(cherry picked from commit bcea7bd355b7c33e6c56b4c911817de1f2f34e0e)

* Add a troubleshooting section about slow seeking

#minor-release

PiperOrigin-RevId: 477432256
(cherry picked from commit f8f2ec64c9b8ba8c19e95cd68e52cc67fb0094fa)

* HDR: Add tests for tone mapping.

Also, add checks for output file color.

PiperOrigin-RevId: 477439139
(cherry picked from commit 507a1be61d24baf8fd26047938360db48dffabdb)

* HDR: Add period to end of error message.

For tone mapping error messages.

PiperOrigin-RevId: 477447799
(cherry picked from commit 05ce639ea05b8806f6c8bae7d1816ddae5d99fb7)

* Demo: Split video Effect generation out of createTransformer.

PiperOrigin-RevId: 477524540
(cherry picked from commit 26a73605f811acad1bc5de6dbc5f651036f35e13)

* 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 97868025275e5fb6dd62e8407a7384ff44e204f6)

* Tests: Statically import BitmapTestUtil methods.

Per go/java-practices/imports#static

No functional changes intended.

PiperOrigin-RevId: 477974779
(cherry picked from commit da2c6376cd86b7b8e9fd450cd61ed8fbc3a739dd)

* 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 7286155fc327b1ffcd72903a739368b4bdeebcf8)

* HDR: Add tests with HLG10 input.

PiperOrigin-RevId: 478019046
(cherry picked from commit b9a3aa5ca1b7fb01fc6500a57d9ddcbba6ff9b54)

* Add second player for input video

PiperOrigin-RevId: 478510687
(cherry picked from commit 6f2bc16b609265160154b173df6bd687bc5bcb17)

* 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 36e41059ea9e98aeab105375a683f7cd7481c5a8)

* Add button to show/hide input player in TransformerActivity

PiperOrigin-RevId: 479003655
(cherry picked from commit 20c1ae141185d8f0e69977c82598488ae12e3b30)

* 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 ff8dd0b4b9aa498a831c9721c530e77bf099a4ed)

* 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 088958994776a65666045b3e7b332f5f0c336bcf)

* 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 4c73241058041fd978e9748b2158168d4e6e702d)

* 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 ccab9fba0369ea9709a6987024177e8b73a5c7ac)

* Document the allowed values of TsPayloadReader.Flags IntDef

PiperOrigin-RevId: 479569806
(cherry picked from commit 7c68b8d4500cb25779a473b52029944ec4d29543)

* 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 faa796d7365330d1f1d4f5b17901d6b1a78ce868)

* Bump dexmaker version

PiperOrigin-RevId: 479579252
(cherry picked from commit a6b9772f0e6f5a31baafb6965c3386d819d3c1e9)

* 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 2188685c465aa6d641e78ab33eaa93fbb92185b8)

* 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 a366590a0425ff138520752e2fc94c70429c20ab)

* 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 af19e0ea890e7b274b6f75f409f00f11e11c1c81)

* Add local file picker to ConfigurationActivity

PiperOrigin-RevId: 480349627
(cherry picked from commit 225d0dcdd1e7e7f1f41d8ac1d2dee7340c40cf3a)

* Demo: Read long values from trim slider.

Before, slider values were read as `floor()`'ed `longValue()`s, so that trimming to
intervals less than one second would be interpreted as a request for a zero-
duration trim.

Also, rename `radiusRange` references here to `trimRange`, since this is not a
radius range.

PiperOrigin-RevId: 480401556
(cherry picked from commit 6c59f9ece40f6450405d29acd559492145158409)

* Demo: Hide player controls by default.

Player controls are somewhat distracting when showing the difference between the
input and output video, as they obscure and darken the video players.

PiperOrigin-RevId: 480597804
(cherry picked from commit 91a61cecbe37f4c5595f534ee237011289c0ac18)

* Demo: Shorten trim range from 60 seconds to 10 seconds.

Most demo videos aren't very long, and the default demo video is only 10 seconds.

Shorten the maximum trim duration to 10 seconds, to demonstrate transformer functionality more easily, and allow this to be used more easily when trimming short sections of a longer video (ex. to make test clips)

PiperOrigin-RevId: 480602037
(cherry picked from commit 3142a2127dc224e4c2124989b952a8bd1e06d510)

* Add Cea608DecoderTest

When debugging and fixing Issue: google/ExoPlayer#10666 I wanted to write a regression
test, but needed to add a test first... This is just a small bit of
coverage to start with. It checks the field/channel filtering works
correctly, but doesn't check any styling info. It also doesn't test
'pop on' subtitles (i.e. when the subtitle isn't shown until a 'end of
subtitle' signal is received).

PiperOrigin-RevId: 480644568
(cherry picked from commit 6052212c15b89d71846f1f3855728ce863304bca)

* Remove supportsSampleMimeType from Muxer.Factory

- This method is redundant with getSupportedSampleMimeTypes().
- This is to prepare the Muxer class to become public.

PiperOrigin-RevId: 480840902
(cherry picked from commit 8962f5a3f4b505224ceb22ac5771b85f24e30358)

* Fix blank toast in Transformer Demo

PiperOrigin-RevId: 480847967
(cherry picked from commit 446c9943f935541d7b76fc1dfa62ee969d775f60)

* Migrate media constants from androidx.media.util.MediaConstants

Adds root extras and metadata extras to MockMediaLibraryService and MockMediaBrowserCompatService and completed test cases for asserting
interoperability with a media1 or Media3 browser.

PiperOrigin-RevId: 480854842
(cherry picked from commit f95406e75d1eca9b96477132d33d752e2485bee6)

* Ensure sessions without MediaPeriodId are ended after seek to new item

We already have logic to end all session except the current one if the
current one doesn't have a MediaPeriodId yet. This is assuming that this
only happens after a seek on the app side where the player doesn't have
detailled knowledge about the MediaPeriodIds yet.

Currently this logic isn't triggered if the window we are coming from
doesn't have its MediaPeriodId either as we run into another check that
keeps sessions around until we have a valid windowSequenceNumber.

Swapping both conditions fixes this case without breaking any of the
other known transition scenarios.

Issue: androidx/media#180
PiperOrigin-RevId: 480866465
(cherry picked from commit 6070d9110a9cec61f6073c7669f2f8185a635767)

* Mark effectively-final PlayerControlView fields as actually final

This means the null checker can be more sure that these fields don't
get reassigned between a null-check and a usage.

PiperOrigin-RevId: 481142004
(cherry picked from commit 248ee469ad243a86b66445f96782b915296eec4c)

* Effect: Remove unused private int ouptutTexId in pixel tests.

PiperOrigin-RevId: 481143798
(cherry picked from commit 026699bafc6d73bc63b6cf416ea183fc3d506039)

* Fix the position of IntDef annotations on fields in the UI module

PiperOrigin-RevId: 481150758
(cherry picked from commit 871a5e685e9bc78544107c803306320e7d53ee53)

* Fix display settings window UI bug for foldable devices.

PiperOrigin-RevId: 481215581
(cherry picked from commit 6cdaf2c031258221939eead3b11075a90e2c742c)

* Add copybara annotated import statement for special cases

PiperOrigin-RevId: 481605567
(cherry picked from commit fd315dadebe479f2cc75fb4fa482cb414270bdcf)

* Add manifest to make gradle build work

PiperOrigin-RevId: 481606248
(cherry picked from commit 325e973ace929efa193b114271d844f20814705a)

* Add DefaultMuxer forwarding to FrameworkMuxer

- The naming DefaultMuxer is more consistent with the rest of
Transformer codebase (e.g. DefaultEncoderFactory).
- By hiding the implementation details of DefaultMuxer, the transition
to in-app Muxer will be seamless for apps using DefaultMuxer.
- The current plan is that DefaultMuxer will become the in-app muxer.

PiperOrigin-RevId: 481838790
(cherry picked from commit b4d7f066dd31cce1e3d7ab14cc47d3b7be364a88)

* Remove more references to overriding layouts from Player(Control)View

In exoplayer2 this affects StyledPlayer(Control)View

#minor-release

PiperOrigin-RevId: 481878940
(cherry picked from commit a5583c04bb6c199633e2b1edf036060c0d33b616)

* Fix parameter comment block.

#cleanup

PiperOrigin-RevId: 481882181
(cherry picked from commit b6bd35860cda60f27439df737fdee815060ed6fe)

* Remove deprecated setOutputMimeType

This is to prepare Muxer to become public

PiperOrigin-RevId: 481893842
(cherry picked from commit bd9181e6ba5daf865f9c2f4338f1238b108dafd8)

* GL: Move loadAsset to GlProgram, where it's used.

(Also, make some public methods private)

PiperOrigin-RevId: 481912071
(cherry picked from commit a404fde4fa9d9d16b0be3c6e08dabd059c07f471)

* 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 76ce0cc69fa12a9b2592103da97dd45c15bfe4d3)

* Test: Update MatrixProcessorPixelTest to use input width and height.

Before, they used `width` and `height`, which was inconsistent with other pixel tests, and less descriptive.

Refactoring change only. No functional change intended.

PiperOrigin-RevId: 481970243
(cherry picked from commit 620d8c9479469f11bdd372e80d231a64e0132808)

* Remove ForwardingPlayer special case from PlayerControlView.setPlayer

This was originally added in https://github.com/google/ExoPlayer/commit/4fd7d777b669f6adacc3737a7e15b04a57f030fb, but it hasn't done anything
since https://github.com/google/ExoPlayer/commit/98ee159df161c7c8806c0b0490b642738822f6a7 (when the instanceof ExoPlayer check was removed).

PiperOrigin-RevId: 482161662
(cherry picked from commit 7d5f1a24be204321961aba81f2de5b1ce1328c71)

* Effect: Remove unnecessary "this" qualifier

`transformationMatrix` is not ambiguous, as there's no other local
transformationMatrix variable nearby.

PiperOrigin-RevId: 482184602
(cherry picked from commit c698ec51a24bdf42e2affad181d2a6d812cbe47b)

* Make Muxer public

The reason for making the Muxer public is that we want to add an option
to disable or configure the timer that will throw when the muxer doesn't
receive any data for a given period of time.

PiperOrigin-RevId: 482199360
(cherry picked from commit d213b93958fce7e2a25851ec44b7c1938fcf0d7d)

* 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 9e1adee4cbc3386672f42d580734175c442bdbea)

* Corrected ordering of javadoc params

PiperOrigin-RevId: 482231370
(cherry picked from commit 897722071e90f7b79527a75ac667a4e2143fbdfd)

* Merge pull request #10570 from Artemych:fix/progressive_downloader_infinite_loop

PiperOrigin-RevId: 472475124
(cherry picked from commit 9c56b2c4b631062731ccfc0d8e5b5c105449074c)

* Merge pull request #10549 from ferhatparmak:release-requirementswatcher

PiperOrigin-RevId: 472488921
(cherry picked from commit 92cfa7467b8f74daab22276c6db4e885b76e7c28)

* 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 5a1223777c4d4ee2faa4043be2079971e44093a9)

* Merge pull request #123 from stoyicker:wrapping_media_source

PiperOrigin-RevId: 476376463
(cherry picked from commit 8623f1f01657abc6a1359f3677a59d1cbde07b37)

* 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 f745c6ee0ea0b610cfdf6a146818b0da7d06326a)

* Merge pull request #10578 from thucngv:release-v2

PiperOrigin-RevId: 481115402
(cherry picked from commit 9861f88f3db419553b893efd98a5e1a0c8c6287c)

* Use static import for Assertions in MCVR

PiperOrigin-RevId: 481122795
(cherry picked from commit 12f7174e1f8a2c2b1f36df749b43262efb88f60a)

* Merge pull request #183 from jasper-apps:bugfix/make-download-notification-appear-immediately

PiperOrigin-RevId: 482165983
(cherry picked from commit 405455b06c6d596552c695670664309319f5570c)

* Map lib-effect from androidx to exoplayer2

PiperOrigin-RevId: 482179761
(cherry picked from commit 28c4be2f6bd56205e3b8128bf710c34b3b3d65e9)

* Remove muxerFactory dependency on playerListener

This listener will need to be passed to the MuxerWrapper to throw when
the Transformer is stuck.

PiperOrigin-RevId: 482433552
(cherry picked from commit e3f28421fd85f1c44135f24c3df1fac000834f67)

* Change areSizeAndRateSupported to use PerfomancePoint.covers

PiperOrigin-RevId: 482461219
(cherry picked from commit 0eb30eacc7f65f84e34e038567d0dd86dc4b6e2c)

* Fix some incorrect comments in Cea608DecoderTest

Also used all-caps consistently

PiperOrigin-RevId: 483317405
(cherry picked from commit 6dcb9aaaa87d1a11a0eb41d1f80312796bceb55a)

* Merge pull request #10618 from vishnuchilakala:fix/do_not_send_content_complete_if_midroll_skipped

PiperOrigin-RevId: 482481703
(cherry picked from commit a413b478f7c45615d3fc7ebd31cacfc363e8ca31)

* Merge pull request #162 from ittiam-systems:rtp-mp4a-latm

PiperOrigin-RevId: 482490230
(cherry picked from commit fd2ba37b1d67576313aec0512d630331b7c99f4b)

* Add DAI specific methods to AdPlaybackState

PiperOrigin-RevId: 482755468
(cherry picked from commit a8e6894ad63271293a831d13419b1372fe0f387a)

* Add CanIgnoreReturnValue to AudioProcessor#configure + implementations

Although it can be useful to check the output format, it's not required or needed.

For some AudioProcessor implementations, it is stated/obvious that
the output format will match the input, in which case there is no
a need to check the return value.

#cleanup

PiperOrigin-RevId: 483403679
(cherry picked from commit a7bfa12eecb42cbdd13bd7e612603a4d400ebda4)

* Use int for an unsigned byte value in Cea608Decoder

This is a no-op, but it's more 'correct' because it avoids any potential
sign mix-ups that come from storing an unsigned byte (with a
potentially set MSB) in a signed java byte variable.

PiperOrigin-RevId: 483409798
(cherry picked from commit 3d0f43a149c846670480c993e09def1a2d2eeeea)

* Clarify sideloaded subtitle example

#minor-release

PiperOrigin-RevId: 483633564
(cherry picked from commit eaf1f2153abca685fce6092a52eb4059bc61815a)

* Add GL utility methods to get 4x4 identity and set identity

PiperOrigin-RevId: 483671580
(cherry picked from commit f5ad4e098dd71bd4f99b87350e042acab4f95746)

* Move AudioProcessor to common.

PiperOrigin-RevId: 483699606
(cherry picked from commit dda17db261758f7211ffa793ee9cc6fea842addb)

* 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 ad52b68c738e8321b966b904d3cd2139f7a560ef)

* Fix `Cea608Decoder` handling of service switch commands in field 2

From ANSI-CTA-608-E R-2014 section 8.4:
> When closed captioning is used on line 21, field 2, it shall conform
> to all of the applicable specifications and recommended practices as
> defined for field 1 services with the following differences:
> 1. The non-printing character of the miscellaneous control-character
>    pairs that fall in the range of 0x14, 0x20 to 0x14, 0x2F in field 1,
>    shall be replaced with 0x15, 0x20 to 0x15, 0x2F when used in field
>    2.
> 2. The non-printing character of the miscellaneous control-character
>    pairs that fall in the range of 0x1C, 0x20 to 0x1C, 0x2F in field
>    1, shall be replaced with 0x1D, 0x20 to 0x1D, 0x2F when used in
>    field 2.

This basically means that `cc1=0x15` in field 2 should be interpreted as
`cc1=0x14` in field 1, and same for `0x1D -> 0x1C`.

The `isMiscCode`  method above already handles this by ignoring the LSB
(the only difference between `0x14` and `0x15`, and `0x1C` and `0x1D`)
by AND-ing with `0xF6` instead of `0xF7`. This change uses the same
trick in `isServiceSwitchCommand`.

Issue: google/ExoPlayer#10666
#minor-release
PiperOrigin-RevId: 483927506
(cherry picked from commit 7c6d492ff19b6aead4cc6f1f9a426145fc1faa0d)

* Mute input video player in transformer demo

PiperOrigin-RevId: 483969411
(cherry picked from commit 8181b3c6a1aba32459d4a5975cc708cbf224b397)

* Add AudioProcessor.AudioFormat equals method.

PiperOrigin-RevId: 483983486
(cherry picked from commit c9585d0154980c576710d035be51eb472fbd6665)

* Add muxer timer to detect when generating an output sample is too slow

This allows to throw when the Transformer is stuck or is too slow.

PiperOrigin-RevId: 484179037
(cherry picked from commit 376ee77f52bed47de54c6478b4006f1b25a543d0)

* Make adding ad live breaks more robust

This change makes adding ad events in live streams more robust by allowing ad
groups to grow in number of ads if more ad events are received than initially
announced by the SDK.

With the IMA prefetch feature, an AdPod can grow in size in certain conditions
like from initially 2 ads to 4 ads being part of the ad group. With this change,
if an additional ad event arrives while the ad group is still being played,
the ad group is expanded. If the event arrives late and the ad group is already
completed, a new group is created for the remaining ads.

This also covers the case where we join the live stream while an ad is being
played and we missed at least one LOADED event from the SDK. Ads of the group
before the first LOADED event are ignored in such a case.

PiperOrigin-RevId: 484214760
(cherry picked from commit 136addf640e451602163be9e4272d1e27b8ed5b8)

* Add test for muxer watchdog timer

PiperOrigin-RevId: 484298261
(cherry picked from commit 42057cc9f8f81e24c64c629d2e11e7102afd0f30)

* Upgrade dackka and fix some generation errors

#minor-release

PiperOrigin-RevId: 484483080
(cherry picked from commit fc1eca10f4934fd92c84db222815fc1e77ddd5f6)

* Disable the muxer watchdog if all tracks have ended.

PiperOrigin-RevId: 484512661
(cherry picked from commit 2390322a00a9e71f16dfe28088ae7cd3e462129f)

* Bump appTargetSDKVersion to 33

#minor-release

PiperOrigin-RevId: 484514123
(cherry picked from commit 1bbe7c11f8ad7dfbbf3fe30796414bd196f0df5a)

* Tighten the wording for sending a pull request.

PiperOrigin-RevId: 485036120
(cherry picked from commit 8030a492ff676fa32dc25fe48829c9a066529cd5)

* Disable failing tests of FlacExtractorSeekTest

PiperOrigin-RevId: 485061783
(cherry picked from commit 55b82ff8ae491f6bcc7f3901476d2b1571a10005)

* Enfore minCompileSdk version when depending on ExoPlayer/Media3 libs

If an app sets a compileSdkVersion that is lower than the one used to
create AARs of its dependencies, the build process may produce invalid
outputs, for example by stripping methods from the APK that are only
called when the app is running on a new API version.

To avoid this issue, we can enforce that the compileSdk of apps or
libraries depending on ExoPlayer/Media3 is at least the same as the
one we used for compilation when creating the AAR.

Issue: google/ExoPlayer#10684
PiperOrigin-RevId: 485100067
(cherry picked from commit 23d39caea0bee0143705191fd97ac7f0cf9a76f9)

* Removed move transformation for exoplayer2 audio package-info.java

https://github.com/google/ExoPlayer/commit/dda17db261758f7211ffa793ee9cc6fea842addb creation of audio/package-info.java introduced a copybara conflict with the exoplayer2/audio/package-info.java move transformation in copy.bara.sky. Solution was to remove original package-info-common-audio.java and the move transformation as https://github.com/google/ExoPlayer/commit/dda17db261758f7211ffa793ee9cc6fea842addb now covers it.

Tested with a copybara push to exoplayer github

PiperOrigin-RevId: 485329674
(cherry picked from commit 972e169bd85b14848dcae75e34f9e95fe87e1f4b)

* HDR: Generalize Pixel 6 workaround to TP

PiperOrigin-RevId: 485366659
(cherry picked from commit 6de5d9336db68cab7ffa886869fe882af6299223)

* Load bitmaps for `MediaMetadataCompat` and handle the metadata updates.

* Add `Listener` in `MediaSession` with method `onNotificationRefreshRequired(MediaSession)`.
* Add `MediaSessionService` as the listener of the `MediaSession` when `MediaSession` is added to `MediaSessionService`
* Load bitmap when update metadata in `MediaSessionLegacyStub` and call `onNotificationRefreshRequired` when bitmap asynchronously arrives.

PiperOrigin-RevId: 485376145
(cherry picked from commit 624238c6b6e621deed585cb19b63f117ae3f7e76)

* Apply tone mapping workaround to Pixel Watch as well.

Not sure what BUILD.ID the fix will first be applied on though.

PiperOrigin-RevId: 485389618
(cherry picked from commit 2ddd645a3484aed4b9e519f99f4ab1bc989b6a0e)

* Fix Dackka/Metalava…
@tonihei
Copy link
Collaborator

tonihei commented Jan 26, 2023

Issue was fixed by the commits above.

@tonihei tonihei closed this as completed Jan 26, 2023
guoen21 added a commit to DiceTechnology/ExoPlayer that referenced this issue Feb 23, 2023
* 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 40a28d5aeeb5f3c22e884690128182b68a9929f6)

* Remove clamp function in contrast fragment shader.

* OpenGL automatically clamps the output colors to the [0, 1] interval.

PiperOrigin-RevId: 465071999
(cherry picked from commit 30fab8c00891b2a5423c169dd75ef0b7d40fe5b7)

* AudioOffload recovery.

Avoids disabling Offload on a write error, and instead relies on this being disabled on the AudioTrack init. It will no longer recover by disabling offload.

PiperOrigin-RevId: 465248917
(cherry picked from commit 2fbe1bbfb3c533c370c07a4f45068c00ea9c6efb)

* Expose AudioOffload track state.

Adds a new event to AudioOffloadListener to get the offload state of the track, which indicates when software decoding is taking place.

PiperOrigin-RevId: 465264362
(cherry picked from commit fe2b846552e1dc0095a409a3407c328e38bd6a30)

* Factor out RTP timestamp to sample time method

PiperOrigin-RevId: 465337074
(cherry picked from commit a1be6d6eb39a40b91f9dee0524d13e5ac805246f)

* HDR: Add comment to clarify lack of support HDR10 for AVC

PiperOrigin-RevId: 465360186
(cherry picked from commit e63d594f490da6461bc5087d0526c5ca5215958d)

* Add RgbAdjustment class to build RgbaMatrices

* Add RgbaMatrix interface implementation.
* Add Builder class for easy adjustments.
* Adjust existing RgbaMatrixPixelTests to use new RgbAdjustment class.

PiperOrigin-RevId: 465545429
(cherry picked from commit 6502fce634913420af77ec78c275f97a61b8fac4)

* Use multiple output frames in transformer MediaPipe demo pre API 23.

PiperOrigin-RevId: 465545764
(cherry picked from commit 6da0a3543491a9d9bb3dbfaf1b203a04f7a19f5c)

* Fix frame processor reference

PiperOrigin-RevId: 465562260
(cherry picked from commit aafa31e996f30daebec12f5e9e61aab1dbd0ba81)

* Make AudioTrackBufferSizeProvider public.

Was getting "java.lang.IllegalAccessError: Illegal class access" in debug app.

PiperOrigin-RevId: 465562541
(cherry picked from commit c09b34a61be80f250bac6a5e1f56e8180f68b9e2)

* Fix ConcurrentHashMap usage in demo MediaPipeProcessor.

PiperOrigin-RevId: 465563540
(cherry picked from commit 6e4fc4752248f1a1d233dea041305718cae08cd0)

* Clarify SSIM request method name

`requestCalculateSsim` more clearly represents the intention of the caller.

Also rephrase the javadoc to simplify it and make it more precise.

PiperOrigin-RevId: 465575578
(cherry picked from commit d90d7d30789ec819d905fd98291f66ab7031f47b)

* Throw if tone-mapping is requested but not enabled

In the case where this check fails, the downstream frame processor chain won't be able to handle the incoming (SDR) data anyway as we've already set it up for HDR.

PiperOrigin-RevId: 465584814
(cherry picked from commit 0e99d28a79ddca5ba9517ffba73d2c36fc2679a7)

* Switch @param to @code tags in RgbAdjustment.

PiperOrigin-RevId: 465591877
(cherry picked from commit 650a9d21ec6582230f4cf0dc2120b17d86707715)

* Add support for multiple mid-track tempo changes

PiperOrigin-RevId: 466018462
(cherry picked from commit 4725cff70e3293f43bd11866f305041c6c18792e)

* Remove unused log tag constant

PiperOrigin-RevId: 466025324
(cherry picked from commit 273cf0866aad78018da3674ba1cbe11187d16afd)

* Add a custom MIME type for MIDI

PiperOrigin-RevId: 466032455
(cherry picked from commit 3aa99d5efbd87a410dd8177539e54185c6b17176)

* 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 e444eaa5b76074bbf77a6cab6dfe288665a20204)

* Split GlTextureProcessor.Listener into input/output/error listener.

This simplifies ChainingGlTextureProcessor as it now only connects a
consuming and a producing GlTextureProcessor rather than a previous,
current, and next GlTextureProcessor.

Also use default no-op implementations of the listeners in
SingleFrameGlTextureProcessor and MediaPipeProcessor to avoid
null-checks.

PiperOrigin-RevId: 466301642
(cherry picked from commit a2166a414212a4e10c31b72dfa21ff45367ee31a)

* 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 7075f78eb26daef44275a6fde5362d5139e6df37)

* Remove times(1) from effect and transformer tests as it is the default.

PiperOrigin-RevId: 466324322
(cherry picked from commit 95a7dcaedaf617802054e37acdb3d46d4923ccac)

* Add JSyn library build instructions for the MIDI module

PiperOrigin-RevId: 466370644
(cherry picked from commit 96a2b149b185206d9e5f079251f8808d39a52e48)

* Demo: Add legacy external storage permission for intents.

Without this permission, files in `/sdcard` or other directories cannot be read by the demo, as they're not in the transformer demo's scoped storage container.

For more information, see https://developer.android.com/training/data-storage/use-cases

Tested by uninstalling and re-installing the demo app, granting permission by
starting a transformation, and launching an intent using a local file in `/sdcard`
to start another transformation. Without this CL, this threw an error, and with
this CL it succeeded.

PiperOrigin-RevId: 466399023
(cherry picked from commit 051dee68e362b8d610a42ac01f7ed9cc5f6b894a)

* HDR: Update experimental_setEnableHdrEditing javadoc.

Previously, this feature interpreted SDR signals as HDR when called. Now, only HDR
streams are interpreted as HDR, so the javadoc should be updated. Not yet removing
this method, as there are still some loose ends to finish up (ex. PQ support, e2e
tests).

PiperOrigin-RevId: 466425738
(cherry picked from commit 2d2926b8c0b4cded25616558ed74cb30cc2932fd)

* Avoid spinning in between intermediate texture processors.

This change adds a new method onReadyToAcceptInputFrame to
GlTextureProcesssor.InputListener and changes maybeQueueInputFrame
to queueInputFrame, removing the boolean return value.
This avoids the re-trying in ChainingGlTextureProcessorListener
by allowing it to only feed frames from the producing to the consuming
GlTextureProcessor when there is capacity.

MediaPipeProcessor still needs re-trying when processing isn't 1:1.

PiperOrigin-RevId: 466626369
(cherry picked from commit 9c366b3cfdd06cad046dd5ce1b0ecad21c5c44ba)

* HDR: Clarify tone mapping fallback.

createSupportedTransformationRequest is more accurate than
createFallbackTransformationRequest, as a TransformationRequest will be returned
regardless of whether any fallback is applied.

PiperOrigin-RevId: 466641277
(cherry picked from commit 70972bbab0c884bcc2ef1dfef2177967499c36b6)

* Fix ChainingGlTextureProcessorListener field name.

PiperOrigin-RevId: 466735554
(cherry picked from commit 43aa89aa2ef04756f185738bbd7c17c236bff879)

* Add timeout for ad to load.

In some cases, the IMA SDK fails to call the expected loadAd
event to load the next ad to play. This is (potentially) the
only remaining case where playback can get stuck due to missing
calls from IMA as the player doesn't even have a MediaSource at
this stage and is only waiting for IMA to provide the ad URL.

We can reuse the existing adPreloadTimeoutMs that was added for
a similar purpose (when preloading the first ad in the group).
The JavaDoc matches this purpose as well and the default timeout
is appropriate since we expect to get the loadAd call immediately.

Issue: google/ExoPlayer#10510
PiperOrigin-RevId: 466953617
(cherry picked from commit 91fc5c4f3c52c02439d1e65f09fa2d2c1c5fcf05)

* Add additional build flags for ffmpeg on "arm64-v8a"

From NDK 23.1.7779620 and above, the arm64-v8a ABI needs additional
build flags to correctly link the ffmpeg libraries.

Issue: google/ExoPlayer#9933
PiperOrigin-RevId: 467161973
(cherry picked from commit 6ea1d0ecf068d866faf2f1c0f4624ae5de872497)

* Avoid spinning while queueing input to ExternalTextureProcessor.

This change adds ExternalTextureManager which implements
InputListener to only queue input frames to the
ExternalTextureProcessor when it is ready to accept an input
frame. This replaces the old retry-logic in GlEffectsFrameProcessor.

Before this change, the retrying in GlEffectFrameProcessor wasted
CPU time if input becomes available faster than the
ExternalTextureProcessor can process it.

PiperOrigin-RevId: 467177659
(cherry picked from commit 06ce5ec73898d5e56eb5a2e0f68d4910919c5ea7)

* Refactor RgbaMatrix to RgbMatrix.

* Rename all Rgba instances to Rgb.
* Remove alpha value from the RGBA Matrices and apply the 4x4 matrix
only to the R, G, B channels.
* Restore the alpha from the input unchanged.

PiperOrigin-RevId: 467208888
(cherry picked from commit 80f9ad9bf9631a61c06317df54a68be248e23b4f)

* Increase pixel difference threshold

PiperOrigin-RevId: 467610621
(cherry picked from commit ec7936f64d8019c94d69bcd7a31e2002fcaca695)

* 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 9a7fde8fde6e194b92ec67095b7b889ee23a3d77)

* Update CMake version for AV1 extension

The specified CMake version doesn't work with the latest
Android Studio releases. Updating to a more recent version
fixes the problem.

Issue: google/ExoPlayer#9933
PiperOrigin-RevId: 467634063
(cherry picked from commit 80b635e7abf3a980b801c49c7975c4963aed7518)

* Increase max sample size for HEVC.

Increase the estimated max sample size for HEVC by 2x, and set a minimum
size of 2MB. The 2MB will be applied for resolutions up to 1080p, after
which the new calculation takes effect. This is in par with the
platform's HEVC software decoder.

PiperOrigin-RevId: 467641494
(cherry picked from commit d3d5ffce91452ebf1edf51a0c0c9d80ad29fe0b6)

* Allow high-priority tasks to be executed before other tasks.

This is needed as a pre-requisite for allowing MCVR to control
FrameProcessor frame release for previewing.

Submitting a high-priority task is conceptually different from
posting at the front of a single queue of tasks, as the high-priority
tasks are executed in FIFO order among themselves. This will ensure
that frame release tasks submitted in close succession are executed
in the order they are submitted but before any lower priority tasks.

PiperOrigin-RevId: 467675137
(cherry picked from commit 4d81a6db240b0f5b92936d894d59b53cc493e3b2)

* HDR: Update limited range and add full range YUV to RGB color transforms.

PiperOrigin-RevId: 467910378
(cherry picked from commit 130a536287f705ea823c9351d053f01512bf7e3c)

* 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 29208ec1ed4d78fa86af33b81a2b32f3151b9004)

* Compact a RGB Matrix chain into a singular RGB Matrix.

PiperOrigin-RevId: 468013019
(cherry picked from commit 977370e9db8fda16388a56f8979df9f6f6737b60)

* Fix typo

PiperOrigin-RevId: 468152718
(cherry picked from commit c6a10ad2270ecf295dc06ac338eae6367b7887ca)

* Defensively cancel frame processing tasks on error.

FrameProcessingTaskExecutor should be released on error.
There can be a delay until this happens, so
FrameProcessingTaskExecutor will cancel any pending tasks
and drop new tasks until it is released.

PiperOrigin-RevId: 468171820
(cherry picked from commit d11c3be952d4a5cd31b7f629b427bdddcbf3f15c)

* HDR: Clamp YUV to RGB conversion.

Manually tested using transformer demo HLG videos. Before this CL, RGB values after the YUV to RGB conversion reached up to 1.025. After this CL, RGB values correctly clamp at 1.0.

PiperOrigin-RevId: 468426092
(cherry picked from commit 32ee44805b33d3fedf9d36905fa22d20a2800d78)

* 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 2c063546a1ac8607eb4632acb88506b9a0d46b9e)

* Fix the command sample size given to trackOutput.

Remove the manual overwriting of Note ON events that have 0 velocity with Note OFF. JSyn handles this already.

- The implementation of "running status" means that the amount of bytes read from the file differ from the size of the sample that ends up in the decoder. The decoder sample contains the applied running status (status of previous event), which the file bytes don't contain.

PiperOrigin-RevId: 468537659
(cherry picked from commit 53218b50d465939b74a64fdc87ecaca5f1a95b57)

* 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 4e7f9c575d9ff003f1cc4d4a9f464c6df6b4077a)

* Add device info to CastPlayer

Issue: androidx/media#142
PiperOrigin-RevId: 468666737
(cherry picked from commit d6442f63fa9cb3e5197109d11cadcd482ef5c6a4)

* Reassign TODO to new bug.

PiperOrigin-RevId: 468672505
(cherry picked from commit 010ecec89dcaf74d9536f92a5b99152d99816dfa)

* Handle initial RTSP seek

PiperOrigin-RevId: 469143613
(cherry picked from commit c611435521a868d6675556f05bd2e325355b7e02)

* Replace usage of `android_binary` with `build_test` for libraries

`android_binary` is only required when building an application.

PiperOrigin-RevId: 469413752
(cherry picked from commit f01896af156efdafeaef6a5eb13e9d251a2e1d57)

* Bind contrastFactor in constructor instead of drawFrame method.

PiperOrigin-RevId: 469438747
(cherry picked from commit 9a1e7fbdf41e9de1f5d69590a305ebfafaa3ad07)

* Fix outdated RtpDataLoadable javadoc

PiperOrigin-RevId: 469443086
(cherry picked from commit 5cf166c15767eaac16ce29df9d08d589946d6cae)

* 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 a2139109e3e67d830be8fd5a342687a569009270)

* Fix missing id error

PiperOrigin-RevId: 469750922
(cherry picked from commit 2c70383d38a50482df57f6558b55b2057cbe56c7)

* HDR: Rename GL_COLOR_TRANSFER instances to COLOR_TRANSFER

PiperOrigin-RevId: 469959215
(cherry picked from commit 0f48c89f1f500d211cf6b118214d4bcbf9ef3e13)

* Delete glPrograms in Contrast and RgbMatrix.
Remove unecessary null checks.

PiperOrigin-RevId: 469999952
(cherry picked from commit f454c9aa7490e40d0ea5fdda6aa5698e7e6f6065)

* Switch incorrectly configured native multidex to legacy

Native multidex can only be used for binaries with minSdkVersion of 21 or higher, but minSdkVersion was specified to 16.

PiperOrigin-RevId: 470003836
(cherry picked from commit 142d1c062c4ed4fba450465588217ae5506fece3)

* Switch incorrectly configured native multidex to legacy for demos

Native multidex can only be used for binaries with minSdkVersion of 21 or higher, but minSdkVersion was specified to 16.

PiperOrigin-RevId: 470004102
(cherry picked from commit a395b23d985dd4a118b125c3d121a7e39e2e5435)

* Fix ExternalTextureManager: repeated queueing input frame in preview

TL;DR: we should check if there are new frames available to queue to the
ExternalTextureProcessor before actually queueing a frame.

The overall flow on the external texture processor:

- `SurfaceTexture.onFrameAvailable` is called on `ExtTexMgr`, and
  - it calls `updateTexImage()`, and sets `frame`
  - it calls `maybeQueueFrameToExtTexProc()`
    - the frame is queued to `ExtTexProc` if `frame` is set

  - From `ExtTexProc.queueInputFrame()`:
    - notifies the `frameProcessorListener` of available frame
    - notifies the `inputListener` of `onReadyToAcceptInputFrame`
      - (`ExtTexMgr` is the listener), it calls `maybeQueueFrameToExtTexProc()`
       again

-- Parallelly --
- `ExtTexProc` calls `inputListener.onInputFrameProcessed`, when the frame is
released
  - (`ExtTexMgr` is the listener), sets `frame` to `null`

*Problem*

This logic relies on `frame` to be cleared at the right time.

In transformer, it's OK b/c `ExtTexProc` release the frame immediately in
`queueInputFrame()` and calls `onInputFrameProcessed` which also reset `frame`

But in previewing, the frame is not released for a while, up to 10 ms.
In this case, `frame` will not reset in this 10 ms, and
`maybeQueueFrameToExtTexProc()` is repeatedly queueing the same input frame.

PiperOrigin-RevId: 470211620
(cherry picked from commit a8c54dd378577cc472a1e56fff062b7959e00268)

* Log instead of throwing for transfer mismatch

PiperOrigin-RevId: 470354448
(cherry picked from commit f1a3a40eb1d8a640fed0d7735088a30d00038234)

* Update color info mismatch test

This should now expect transformation to succeed.

PiperOrigin-RevId: 470950411
(cherry picked from commit 1023254d8e8b9bab6001ab550676adac96ae0c50)

* Fix 1 ErrorProneStyle finding:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 470953422
(cherry picked from commit f26e5d4c21d34da840152452f648051322d505eb)

* Remove media3-only line from exoplayer2 `build.gradle` file

#minor-release

PiperOrigin-RevId: 470999044
(cherry picked from commit e285e7078545435e86e3d43219ad9f6fc8373755)

* Update first frame instructions.

PiperOrigin-RevId: 471008623
(cherry picked from commit cb60f506d1f6283e2790ee631c01c5c4128967a2)

* Add static Grayscale and Inverted RGB Filter.

PiperOrigin-RevId: 471017440
(cherry picked from commit 9f67ce4e4c1d6e26a0920bf9bed89c38cecbdaeb)

* Fix 19 ErrorProneStyle findings:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment) (19 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 471022923
(cherry picked from commit 674b3d4575ae6fdb59ae9db58be52151bbcae3a6)

* HDR: Use factory for MatrixTransformationProcessor.

Separate MatrixTransformationProcessor constructors by color input and output.

PiperOrigin-RevId: 471034768
(cherry picked from commit a8e814abbd435755077b2f92cf709d5417494db7)

* 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 e6a1936ba9e210555eaa61a9b6d206bdfa753f09)

* Add @SuppressWarnings to nullness errors detected by a newer version of the Checker Framework

PiperOrigin-RevId: 471137219
(cherry picked from commit 90e684a6dcd5d92470780060feb2099c2f905bbd)

* Fix 3 ErrorProneStyle findings:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment) (3 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 471198016
(cherry picked from commit bac7d697c3620195f8895068369099466fb7bd1c)

* Skip transcoding if HDR video does not need encoding.

https://github.com/google/ExoPlayer/commit/3b0d2c15867b3698f130476736785d427b28b7bd made `shouldPassthrough` always return false for `enableHdrVideoEditing`:

>We force using `FrameEditor` (no passthrough) to avoid the need to select another edit operation, and use the new shaders. The `EGLContext` and `EGLSurface` also need to be set up differently for this path.

However, this was introduced before the `videoNeedsEncoding` setting was introduced in https://github.com/google/ExoPlayer/commit/3f615040c033a37f81b1d73605cd1f7d420b47b5. That setting should apply to HDR videos as much as SDR videos.

PiperOrigin-RevId: 471569853
(cherry picked from commit 94713a8ffb6ba4e83a05bb50921b4cf2ab2eab75)

* Rename shouldPassthrough to shouldTranscode

shouldPassthrough's internal checks seem to be check whether we should *not*
pass through, which seemed a bit like a confusing double-negative to me.

shouldTranscode is slightly more clear, by instead returning true when we do
want to transcode.

No functional changes intended.

PiperOrigin-RevId: 471753771
(cherry picked from commit 1a4cd549a426881474014a02b595382b375864ee)

* Add sepia, grayscale, and inverted filters to the demo app.

PiperOrigin-RevId: 471782565
(cherry picked from commit 87926f0ba8480f39baeb9f9d0ccf8f3576e4fd0e)

* Minor javadoc and scoping cleanup.

No functional changes.

PiperOrigin-RevId: 472245797
(cherry picked from commit 8e14611d60d40f0db41063a5e537638b76c2d46a)

* Fix 1 ErrorProneStyle finding:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 472252461
(cherry picked from commit dfdcf76daf7762fd40f593662bbb1f5141db1da7)

* Fix 3 ErrorProneStyle findings:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment) (3 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 472254253
(cherry picked from commit 83966478960ae6c0f882e523d73848edab95fd3a)

* Merge RgbProcessor and MatrixTransformation.

PiperOrigin-RevId: 472325145
(cherry picked from commit daa77da17de156ea9921914aad791882c4393b84)

* Use super class for toGlProcessor in RgbFilter.

PiperOrigin-RevId: 472405147
(cherry picked from commit c0ad9f51faa5b61e281178666c2cad75329b37f6)

* Make MatrixTransformationsProcessor constructor to take in Lists.

* Replace ImmutableLists to List interface for constructors

PiperOrigin-RevId: 472433434
(cherry picked from commit ce0e3a4fa3e829c987e541f30694a73d8abbc25b)

* Include CamcorderProfile resolution in encoder capability test

PiperOrigin-RevId: 472459423
(cherry picked from commit 6e45824992c8fe72ffd2f4edb726aa0cd8f8c29e)

* Bump IMA SDK version for gradle

PiperOrigin-RevId: 472500789
(cherry picked from commit 60a3ea48b8abf3949a87a2b3bc930ce83cf4ce3f)

* Remove redundant constant definition

PiperOrigin-RevId: 472522846
(cherry picked from commit 9a9baa54a5cdf701695556a91436b2778868cddd)

* Discard backbuffer before playback gets stuck.

If the back buffer is using too much memory, there is a risk
playback could get stuck because LoadControl refuses to load
further data. This eventually results in a stuck-buffering
playback error.

We can detect this case, clear the back buffer and then ask
the LoadControl again to avoid failing playback in such a case.

PiperOrigin-RevId: 472679797
(cherry picked from commit 125646e4c98e80b35d1a8b195300d324a9aaf2b5)

* Add withAvailableAd for server side inserted ad groups

#minor-release

PiperOrigin-RevId: 472714732
(cherry picked from commit 072f376b4839b6d4e71bcd09366695b3b9fc2c02)

* Clarify GlTextureProcessor.InputListener contract

PiperOrigin-RevId: 472745311
(cherry picked from commit 32a21641a2de5fe1fac1c6f1d1a0d644101a4c0b)

* Remove conditional check for no-longer flaky API version

PiperOrigin-RevId: 472949850
(cherry picked from commit caefa565f76912922011155cc580d45243e86ecc)

* HDR: Add fallback MH tests.

Test that HDR editing succeeds on devices supporting HDR editing, tone maps on
devices supporting tone mapping, and throws exceptions on all other devices.

Also, only restrict HDR editing and tone mapping support to API 31+ only when
transcoding, not for all transformations.

PiperOrigin-RevId: 472958965
(cherry picked from commit 8ee2121627c2702419402b514fa93dbe8ac19b8b)

* Add caching for compositeRgbMatrixArray.

* Refactor caching for matrix transformations to reuse it for rgb matrices.

PiperOrigin-RevId: 473042194
(cherry picked from commit 593370bb69ca5db1d693d42509da78ad496218db)

* Decoder: Reduce max pending frame count limit down to 5.

PiperOrigin-RevId: 473212543
(cherry picked from commit 41963fce9b7ad7d2cd9d0fdb428c44eb2bddf5f1)

* Handle int instead of byte in SSIM.

The value of pixels are converted to integers at the point of use,
move this logic to the initialisation step.

This is a prerequisite step for testing SSIM calculation, which
will lead on to some SSIM improvements being verifiable.

Tested manually and SSIM values match for the same video
before and after this change.

PiperOrigin-RevId: 473231779
(cherry picked from commit eb6c1183b69d319a610d79ef57028f62e74a7614)

* Rollback of https://github.com/google/ExoPlayer/commit/eb6c1183b69d319a610d79ef57028f62e74a7614

*** Original commit ***

Handle int instead of byte in SSIM.

The value of pixels are converted to integers at the point of use,
move this logic to the initialisation step.

This is a prerequisite step for testing SSIM calculation, which
will lead on to some SSIM improvements being verifiable.

Tested manually and SSIM values match for the same video
before and after this change.

***

PiperOrigin-RevId: 473259446
(cherry picked from commit 8f9c9d0f88374573f32d76cf7d3a8fde9ca83f87)

* Rename MatrixTransformationProcessor to MatrixTextureProcessor.

PiperOrigin-RevId: 473283967
(cherry picked from commit 40f1bd345a601648bac8f812b4e247140bc420b1)

* Split decoding out of the test

This method is useful for other tests also.

PiperOrigin-RevId: 473574282
(cherry picked from commit f770324f31cd1d63f229b3d536d7f5a58a0fc511)

* Add rgb matrices to java docs for public constructors.

PiperOrigin-RevId: 473699927
(cherry picked from commit 75f920bf25bf052630a16d1d983516409e797363)

* Add java docs for ContrastProcessor constructor.

* Add docs for the public constructor for consistency with all the
other frame processors.

PiperOrigin-RevId: 473726586
(cherry picked from commit 696ef2a5e718ac8df1edf54ad5359389686267b0)

* Add MssimCalculatorTest to verify SSIM calculations.

As part of this change, MssimCalculator is moved from androidTest/ to main/

PiperOrigin-RevId: 473771344
(cherry picked from commit 20aa22c9fad2c1e2d237dc9a8bee81781a729445)

* Change ContrastProcessor java doc for consistency.

PiperOrigin-RevId: 474002026
(cherry picked from commit 7c435621ae3b3ea870fe16524ff7aaa5bd54e931)

* Clarify the replaceOutputBuffer parameter because count is unclear.

PiperOrigin-RevId: 474279220
(cherry picked from commit 3e0ad6d8042c9e6604c281e283885b9e07eb8786)

* Add support for skipping windows in MssimCalculator.

By skipping every other row and column, SSIM calculation time reduces by 10-30%.

PiperOrigin-RevId: 474286702
(cherry picked from commit 6dd2a6dac655f538020a4057e3ab6d997449a9fe)

* Fix testId and match it to the test name.

PiperOrigin-RevId: 474363545
(cherry picked from commit 0e2b6a03b5f91eda6d307b63f49986dfdcc97bfe)

* Add LUT functionalities to transformer.

* Adds SDR 3D LUT functionalities with OpenGL 2.0 support.

PiperOrigin-RevId: 474561060
(cherry picked from commit 702419dd227cec4b23cd6e723a6a15908313f7c9)

* Fix tracing under offload.

Currently doSomeWork is never closed and so tracing is deceiving.

See https://screenshot.googleplex.com/eZDzn5APpBNnhe5

PiperOrigin-RevId: 474755816
(cherry picked from commit 005b73c82a1a3264a7167ffdf93a9387c4d22b95)

* Fix outdated command in bitmap/README.md.

* The command changed after creating a custom effects module.

PiperOrigin-RevId: 474777823
(cherry picked from commit fd6b0d1551af6db9de49dd17c30937a4b292357d)

* Fix instrumentation tests not working via Gradle

PiperOrigin-RevId: 475560401
(cherry picked from commit 6015f052ba1b21bea4ded5bfc4924dc1c096b07a)

* Use golden bitmaps in contrast pixel tests.

PiperOrigin-RevId: 475805421
(cherry picked from commit 06c0040ab43820164bc048d85556727aaa9fa4f8)

* 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 08bb01b218461506352ae4c2f17efd27989553e5)

* Add RGB Adjustments to transformer demo.

PiperOrigin-RevId: 476049125
(cherry picked from commit cfc0eef24ec4a24bc00b0a657f3dad07e9c29ade)

* 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 331d4d626fcb1b65088c7ab849c0a0a3f5f6ba0e)

* 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 afd829e5db17c48abccea30842eec20b702aa330)

* Add HSL Adjustments to the effects module.

PiperOrigin-RevId: 476144167
(cherry picked from commit 2c27cd82f1e97d14f609ea5bb6924398a9dddfd6)

* HDR: Assert output C.ColorTransfer for tests.

To confirm that tone mapping did or did not happen.

PiperOrigin-RevId: 476354606
(cherry picked from commit df58107eae0dd7e19f9b551751d1fbb19ca05e6d)

* 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 94a88e93d91e86c93239639a65612eab297efa9b)

* Remove TODOs for merging RGB and MatrixTransformation processors.

PiperOrigin-RevId: 476362571
(cherry picked from commit af19f82f994e5820889a9166c0a97606496fd17d)

* Fix broken links on https://exoplayer.dev/troubleshooting.html

#minor-release

PiperOrigin-RevId: 476366214
(cherry picked from commit 0969118041e9fb0a8641240282c91959805c271d)

* Add HSL Adjustments to the demo.

PiperOrigin-RevId: 476373520
(cherry picked from commit 5725ebbeeaf1cbb1a1ffc156d67472640059bd0a)

* Add example CLUT to demo.

PiperOrigin-RevId: 476390089
(cherry picked from commit 29cf09316e8056e3703809d6b6ac8eea890e2e4e)

* 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 ccb820dd2f43ff20dff06a92a4e29c13676e647d)

* HDR: Update gamma comments to linear.

Comment-only change.

PiperOrigin-RevId: 476873286
(cherry picked from commit f3d132141e2c40797b80fab674e9ed8f4062e7ba)

* Fix badly formatted AudioProcessor javadoc.

PiperOrigin-RevId: 476909855
(cherry picked from commit 9b1909e56362a5b44ba41d8cad9c3d927bdb650b)

* Fix checkboxes on configuration  page

PiperOrigin-RevId: 477166507
(cherry picked from commit bcea7bd355b7c33e6c56b4c911817de1f2f34e0e)

* Add a troubleshooting section about slow seeking

#minor-release

PiperOrigin-RevId: 477432256
(cherry picked from commit f8f2ec64c9b8ba8c19e95cd68e52cc67fb0094fa)

* HDR: Add tests for tone mapping.

Also, add checks for output file color.

PiperOrigin-RevId: 477439139
(cherry picked from commit 507a1be61d24baf8fd26047938360db48dffabdb)

* HDR: Add period to end of error message.

For tone mapping error messages.

PiperOrigin-RevId: 477447799
(cherry picked from commit 05ce639ea05b8806f6c8bae7d1816ddae5d99fb7)

* Demo: Split video Effect generation out of createTransformer.

PiperOrigin-RevId: 477524540
(cherry picked from commit 26a73605f811acad1bc5de6dbc5f651036f35e13)

* 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 97868025275e5fb6dd62e8407a7384ff44e204f6)

* Tests: Statically import BitmapTestUtil methods.

Per go/java-practices/imports#static

No functional changes intended.

PiperOrigin-RevId: 477974779
(cherry picked from commit da2c6376cd86b7b8e9fd450cd61ed8fbc3a739dd)

* 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 7286155fc327b1ffcd72903a739368b4bdeebcf8)

* HDR: Add tests with HLG10 input.

PiperOrigin-RevId: 478019046
(cherry picked from commit b9a3aa5ca1b7fb01fc6500a57d9ddcbba6ff9b54)

* Add second player for input video

PiperOrigin-RevId: 478510687
(cherry picked from commit 6f2bc16b609265160154b173df6bd687bc5bcb17)

* 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 36e41059ea9e98aeab105375a683f7cd7481c5a8)

* Add button to show/hide input player in TransformerActivity

PiperOrigin-RevId: 479003655
(cherry picked from commit 20c1ae141185d8f0e69977c82598488ae12e3b30)

* 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 ff8dd0b4b9aa498a831c9721c530e77bf099a4ed)

* 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 088958994776a65666045b3e7b332f5f0c336bcf)

* 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 4c73241058041fd978e9748b2158168d4e6e702d)

* 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 ccab9fba0369ea9709a6987024177e8b73a5c7ac)

* Document the allowed values of TsPayloadReader.Flags IntDef

PiperOrigin-RevId: 479569806
(cherry picked from commit 7c68b8d4500cb25779a473b52029944ec4d29543)

* 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 faa796d7365330d1f1d4f5b17901d6b1a78ce868)

* Bump dexmaker version

PiperOrigin-RevId: 479579252
(cherry picked from commit a6b9772f0e6f5a31baafb6965c3386d819d3c1e9)

* 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 2188685c465aa6d641e78ab33eaa93fbb92185b8)

* 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 a366590a0425ff138520752e2fc94c70429c20ab)

* 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 af19e0ea890e7b274b6f75f409f00f11e11c1c81)

* Add local file picker to ConfigurationActivity

PiperOrigin-RevId: 480349627
(cherry picked from commit 225d0dcdd1e7e7f1f41d8ac1d2dee7340c40cf3a)

* Demo: Read long values from trim slider.

Before, slider values were read as `floor()`'ed `longValue()`s, so that trimming to
intervals less than one second would be interpreted as a request for a zero-
duration trim.

Also, rename `radiusRange` references here to `trimRange`, since this is not a
radius range.

PiperOrigin-RevId: 480401556
(cherry picked from commit 6c59f9ece40f6450405d29acd559492145158409)

* Demo: Hide player controls by default.

Player controls are somewhat distracting when showing the difference between the
input and output video, as they obscure and darken the video players.

PiperOrigin-RevId: 480597804
(cherry picked from commit 91a61cecbe37f4c5595f534ee237011289c0ac18)

* Demo: Shorten trim range from 60 seconds to 10 seconds.

Most demo videos aren't very long, and the default demo video is only 10 seconds.

Shorten the maximum trim duration to 10 seconds, to demonstrate transformer functionality more easily, and allow this to be used more easily when trimming short sections of a longer video (ex. to make test clips)

PiperOrigin-RevId: 480602037
(cherry picked from commit 3142a2127dc224e4c2124989b952a8bd1e06d510)

* Add Cea608DecoderTest

When debugging and fixing Issue: google/ExoPlayer#10666 I wanted to write a regression
test, but needed to add a test first... This is just a small bit of
coverage to start with. It checks the field/channel filtering works
correctly, but doesn't check any styling info. It also doesn't test
'pop on' subtitles (i.e. when the subtitle isn't shown until a 'end of
subtitle' signal is received).

PiperOrigin-RevId: 480644568
(cherry picked from commit 6052212c15b89d71846f1f3855728ce863304bca)

* Remove supportsSampleMimeType from Muxer.Factory

- This method is redundant with getSupportedSampleMimeTypes().
- This is to prepare the Muxer class to become public.

PiperOrigin-RevId: 480840902
(cherry picked from commit 8962f5a3f4b505224ceb22ac5771b85f24e30358)

* Fix blank toast in Transformer Demo

PiperOrigin-RevId: 480847967
(cherry picked from commit 446c9943f935541d7b76fc1dfa62ee969d775f60)

* Migrate media constants from androidx.media.util.MediaConstants

Adds root extras and metadata extras to MockMediaLibraryService and MockMediaBrowserCompatService and completed test cases for asserting
interoperability with a media1 or Media3 browser.

PiperOrigin-RevId: 480854842
(cherry picked from commit f95406e75d1eca9b96477132d33d752e2485bee6)

* Ensure sessions without MediaPeriodId are ended after seek to new item

We already have logic to end all session except the current one if the
current one doesn't have a MediaPeriodId yet. This is assuming that this
only happens after a seek on the app side where the player doesn't have
detailled knowledge about the MediaPeriodIds yet.

Currently this logic isn't triggered if the window we are coming from
doesn't have its MediaPeriodId either as we run into another check that
keeps sessions around until we have a valid windowSequenceNumber.

Swapping both conditions fixes this case without breaking any of the
other known transition scenarios.

Issue: androidx/media#180
PiperOrigin-RevId: 480866465
(cherry picked from commit 6070d9110a9cec61f6073c7669f2f8185a635767)

* Mark effectively-final PlayerControlView fields as actually final

This means the null checker can be more sure that these fields don't
get reassigned between a null-check and a usage.

PiperOrigin-RevId: 481142004
(cherry picked from commit 248ee469ad243a86b66445f96782b915296eec4c)

* Effect: Remove unused private int ouptutTexId in pixel tests.

PiperOrigin-RevId: 481143798
(cherry picked from commit 026699bafc6d73bc63b6cf416ea183fc3d506039)

* Fix the position of IntDef annotations on fields in the UI module

PiperOrigin-RevId: 481150758
(cherry picked from commit 871a5e685e9bc78544107c803306320e7d53ee53)

* Fix display settings window UI bug for foldable devices.

PiperOrigin-RevId: 481215581
(cherry picked from commit 6cdaf2c031258221939eead3b11075a90e2c742c)

* Add copybara annotated import statement for special cases

PiperOrigin-RevId: 481605567
(cherry picked from commit fd315dadebe479f2cc75fb4fa482cb414270bdcf)

* Add manifest to make gradle build work

PiperOrigin-RevId: 481606248
(cherry picked from commit 325e973ace929efa193b114271d844f20814705a)

* Add DefaultMuxer forwarding to FrameworkMuxer

- The naming DefaultMuxer is more consistent with the rest of
Transformer codebase (e.g. DefaultEncoderFactory).
- By hiding the implementation details of DefaultMuxer, the transition
to in-app Muxer will be seamless for apps using DefaultMuxer.
- The current plan is that DefaultMuxer will become the in-app muxer.

PiperOrigin-RevId: 481838790
(cherry picked from commit b4d7f066dd31cce1e3d7ab14cc47d3b7be364a88)

* Remove more references to overriding layouts from Player(Control)View

In exoplayer2 this affects StyledPlayer(Control)View

#minor-release

PiperOrigin-RevId: 481878940
(cherry picked from commit a5583c04bb6c199633e2b1edf036060c0d33b616)

* Fix parameter comment block.

#cleanup

PiperOrigin-RevId: 481882181
(cherry picked from commit b6bd35860cda60f27439df737fdee815060ed6fe)

* Remove deprecated setOutputMimeType

This is to prepare Muxer to become public

PiperOrigin-RevId: 481893842
(cherry picked from commit bd9181e6ba5daf865f9c2f4338f1238b108dafd8)

* GL: Move loadAsset to GlProgram, where it's used.

(Also, make some public methods private)

PiperOrigin-RevId: 481912071
(cherry picked from commit a404fde4fa9d9d16b0be3c6e08dabd059c07f471)

* 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 76ce0cc69fa12a9b2592103da97dd45c15bfe4d3)

* Test: Update MatrixProcessorPixelTest to use input width and height.

Before, they used `width` and `height`, which was inconsistent with other pixel tests, and less descriptive.

Refactoring change only. No functional change intended.

PiperOrigin-RevId: 481970243
(cherry picked from commit 620d8c9479469f11bdd372e80d231a64e0132808)

* Remove ForwardingPlayer special case from PlayerControlView.setPlayer

This was originally added in https://github.com/google/ExoPlayer/commit/4fd7d777b669f6adacc3737a7e15b04a57f030fb, but it hasn't done anything
since https://github.com/google/ExoPlayer/commit/98ee159df161c7c8806c0b0490b642738822f6a7 (when the instanceof ExoPlayer check was removed).

PiperOrigin-RevId: 482161662
(cherry picked from commit 7d5f1a24be204321961aba81f2de5b1ce1328c71)

* Effect: Remove unnecessary "this" qualifier

`transformationMatrix` is not ambiguous, as there's no other local
transformationMatrix variable nearby.

PiperOrigin-RevId: 482184602
(cherry picked from commit c698ec51a24bdf42e2affad181d2a6d812cbe47b)

* Make Muxer public

The reason for making the Muxer public is that we want to add an option
to disable or configure the timer that will throw when the muxer doesn't
receive any data for a given period of time.

PiperOrigin-RevId: 482199360
(cherry picked from commit d213b93958fce7e2a25851ec44b7c1938fcf0d7d)

* 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 9e1adee4cbc3386672f42d580734175c442bdbea)

* Corrected ordering of javadoc params

PiperOrigin-RevId: 482231370
(cherry picked from commit 897722071e90f7b79527a75ac667a4e2143fbdfd)

* Merge pull request #10570 from Artemych:fix/progressive_downloader_infinite_loop

PiperOrigin-RevId: 472475124
(cherry picked from commit 9c56b2c4b631062731ccfc0d8e5b5c105449074c)

* Merge pull request #10549 from ferhatparmak:release-requirementswatcher

PiperOrigin-RevId: 472488921
(cherry picked from commit 92cfa7467b8f74daab22276c6db4e885b76e7c28)

* 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 5a1223777c4d4ee2faa4043be2079971e44093a9)

* Merge pull request #123 from stoyicker:wrapping_media_source

PiperOrigin-RevId: 476376463
(cherry picked from commit 8623f1f01657abc6a1359f3677a59d1cbde07b37)

* 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 f745c6ee0ea0b610cfdf6a146818b0da7d06326a)

* Merge pull request #10578 from thucngv:release-v2

PiperOrigin-RevId: 481115402
(cherry picked from commit 9861f88f3db419553b893efd98a5e1a0c8c6287c)

* Use static import for Assertions in MCVR

PiperOrigin-RevId: 481122795
(cherry picked from commit 12f7174e1f8a2c2b1f36df749b43262efb88f60a)

* Merge pull request #183 from jasper-apps:bugfix/make-download-notification-appear-immediately

PiperOrigin-RevId: 482165983
(cherry picked from commit 405455b06c6d596552c695670664309319f5570c)

* Map lib-effect from androidx to exoplayer2

PiperOrigin-RevId: 482179761
(cherry picked from commit 28c4be2f6bd56205e3b8128bf710c34b3b3d65e9)

* Remove muxerFactory dependency on playerListener

This listener will need to be passed to the MuxerWrapper to throw when
the Transformer is stuck.

PiperOrigin-RevId: 482433552
(cherry picked from commit e3f28421fd85f1c44135f24c3df1fac000834f67)

* Change areSizeAndRateSupported to use PerfomancePoint.covers

PiperOrigin-RevId: 482461219
(cherry picked from commit 0eb30eacc7f65f84e34e038567d0dd86dc4b6e2c)

* Fix some incorrect comments in Cea608DecoderTest

Also used all-caps consistently

PiperOrigin-RevId: 483317405
(cherry picked from commit 6dcb9aaaa87d1a11a0eb41d1f80312796bceb55a)

* Merge pull request #10618 from vishnuchilakala:fix/do_not_send_content_complete_if_midroll_skipped

PiperOrigin-RevId: 482481703
(cherry picked from commit a413b478f7c45615d3fc7ebd31cacfc363e8ca31)

* Merge pull request #162 from ittiam-systems:rtp-mp4a-latm

PiperOrigin-RevId: 482490230
(cherry picked from commit fd2ba37b1d67576313aec0512d630331b7c99f4b)

* Add DAI specific methods to AdPlaybackState

PiperOrigin-RevId: 482755468
(cherry picked from commit a8e6894ad63271293a831d13419b1372fe0f387a)

* Add CanIgnoreReturnValue to AudioProcessor#configure + implementations

Although it can be useful to check the output format, it's not required or needed.

For some AudioProcessor implementations, it is stated/obvious that
the output format will match the input, in which case there is no
a need to check the return value.

#cleanup

PiperOrigin-RevId: 483403679
(cherry picked from commit a7bfa12eecb42cbdd13bd7e612603a4d400ebda4)

* Use int for an unsigned byte value in Cea608Decoder

This is a no-op, but it's more 'correct' because it avoids any potential
sign mix-ups that come from storing an unsigned byte (with a
potentially set MSB) in a signed java byte variable.

PiperOrigin-RevId: 483409798
(cherry picked from commit 3d0f43a149c846670480c993e09def1a2d2eeeea)

* Clarify sideloaded subtitle example

#minor-release

PiperOrigin-RevId: 483633564
(cherry picked from commit eaf1f2153abca685fce6092a52eb4059bc61815a)

* Add GL utility methods to get 4x4 identity and set identity

PiperOrigin-RevId: 483671580
(cherry picked from commit f5ad4e098dd71bd4f99b87350e042acab4f95746)

* Move AudioProcessor to common.

PiperOrigin-RevId: 483699606
(cherry picked from commit dda17db261758f7211ffa793ee9cc6fea842addb)

* 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 ad52b68c738e8321b966b904d3cd2139f7a560ef)

* Fix `Cea608Decoder` handling of service switch commands in field 2

From ANSI-CTA-608-E R-2014 section 8.4:
> When closed captioning is used on line 21, field 2, it shall conform
> to all of the applicable specifications and recommended practices as
> defined for field 1 services with the following differences:
> 1. The non-printing character of the miscellaneous control-character
>    pairs that fall in the range of 0x14, 0x20 to 0x14, 0x2F in field 1,
>    shall be replaced with 0x15, 0x20 to 0x15, 0x2F when used in field
>    2.
> 2. The non-printing character of the miscellaneous control-character
>    pairs that fall in the range of 0x1C, 0x20 to 0x1C, 0x2F in field
>    1, shall be replaced with 0x1D, 0x20 to 0x1D, 0x2F when used in
>    field 2.

This basically means that `cc1=0x15` in field 2 should be interpreted as
`cc1=0x14` in field 1, and same for `0x1D -> 0x1C`.

The `isMiscCode`  method above already handles this by ignoring the LSB
(the only difference between `0x14` and `0x15`, and `0x1C` and `0x1D`)
by AND-ing with `0xF6` instead of `0xF7`. This change uses the same
trick in `isServiceSwitchCommand`.

Issue: google/ExoPlayer#10666
#minor-release
PiperOrigin-RevId: 483927506
(cherry picked from commit 7c6d492ff19b6aead4cc6f1f9a426145fc1faa0d)

* Mute input video player in transformer demo

PiperOrigin-RevId: 483969411
(cherry picked from commit 8181b3c6a1aba32459d4a5975cc708cbf224b397)

* Add AudioProcessor.AudioFormat equals method.

PiperOrigin-RevId: 483983486
(cherry picked from commit c9585d0154980c576710d035be51eb472fbd6665)

* Add muxer timer to detect when generating an output sample is too slow

This allows to throw when the Transformer is stuck or is too slow.

PiperOrigin-RevId: 484179037
(cherry picked from commit 376ee77f52bed47de54c6478b4006f1b25a543d0)

* Make adding ad live breaks more robust

This change makes adding ad events in live streams more robust by allowing ad
groups to grow in number of ads if more ad events are received than initially
announced by the SDK.

With the IMA prefetch feature, an AdPod can grow in size in certain conditions
like from initially 2 ads to 4 ads being part of the ad group. With this change,
if an additional ad event arrives while the ad group is still being played,
the ad group is expanded. If the event arrives late and the ad group is already
completed, a new group is created for the remaining ads.

This also covers the case where we join the live stream while an ad is being
played and we missed at least one LOADED event from the SDK. Ads of the group
before the first LOADED event are ignored in such a case.

PiperOrigin-RevId: 484214760
(cherry picked from commit 136addf640e451602163be9e4272d1e27b8ed5b8)

* Add test for muxer watchdog timer

PiperOrigin-RevId: 484298261
(cherry picked from commit 42057cc9f8f81e24c64c629d2e11e7102afd0f30)

* Upgrade dackka and fix some generation errors

#minor-release

PiperOrigin-RevId: 484483080
(cherry picked from commit fc1eca10f4934fd92c84db222815fc1e77ddd5f6)

* Disable the muxer watchdog if all tracks have ended.

PiperOrigin-RevId: 484512661
(cherry picked from commit 2390322a00a9e71f16dfe28088ae7cd3e462129f)

* Bump appTargetSDKVersion to 33

#minor-release

PiperOrigin-RevId: 484514123
(cherry picked from commit 1bbe7c11f8ad7dfbbf3fe30796414bd196f0df5a)

* Tighten the wording for sending a pull request.

PiperOrigin-RevId: 485036120
(cherry picked from commit 8030a492ff676fa32dc25fe48829c9a066529cd5)

* Disable failing tests of FlacExtractorSeekTest

PiperOrigin-RevId: 485061783
(cherry picked from commit 55b82ff8ae491f6bcc7f3901476d2b1571a10005)

* Enfore minCompileSdk version when depending on ExoPlayer/Media3 libs

If an app sets a compileSdkVersion that is lower than the one used to
create AARs of its dependencies, the build process may produce invalid
outputs, for example by stripping methods from the APK that are only
called when the app is running on a new API version.

To avoid this issue, we can enforce that the compileSdk of apps or
libraries depending on ExoPlayer/Media3 is at least the same as the
one we used for compilation when creating the AAR.

Issue: google/ExoPlayer#10684
PiperOrigin-RevId: 485100067
(cherry picked from commit 23d39caea0bee0143705191fd97ac7f0cf9a76f9)

* Removed move transformation for exoplayer2 audio package-info.java

https://github.com/google/ExoPlayer/commit/dda17db261758f7211ffa793ee9cc6fea842addb creation of audio/package-info.java introduced a copybara conflict with the exoplayer2/audio/package-info.java move transformation in copy.bara.sky. Solution was to remove original package-info-common-audio.java and the move transformation as https://github.com/google/ExoPlayer/commit/dda17db261758f7211ffa793ee9cc6fea842addb now covers it.

Tested with a copybara push to exoplayer github

PiperOrigin-RevId: 485329674
(cherry picked from commit 972e169bd85b14848dcae75e34f9e95fe87e1f4b)

* HDR: Generalize Pixel 6 workaround to TP

PiperOrigin-RevId: 485366659
(cherry picked from commit 6de5d9336db68cab7ffa886869fe882af6299223)

* Load bitmaps for `MediaMetadataCompat` and handle the metadata updates.

* Add `Listener` in `MediaSession` with method `onNotificationRefreshRequired(MediaSession)`.
* Add `MediaSessionService` as the listener of the `MediaSession` when `MediaSession` is added to `MediaSessionService`
* Load bitmap when update metadata in `MediaSessionLegacyStub` and call `onNotificationRefreshRequired` when bitmap asynchronously arrives.

PiperOrigin-RevId: 485376145
(cherry picked from commit 624238c6b6e621deed585cb19b63f117ae3f7e76)

* Apply tone mapping workaround to Pixel Watch as well.

Not sure what BUILD.ID the fix will first be applied on though.

PiperOrigin-RevId: 485389618
(cherry picked from commit 2ddd645a3484aed4b9e519f99f4ab1bc989b6a0e)

* Fix Dackka/Metalava errors in the effects module

Public methods may only refer to public types in their signature. This
change ensures that by switching to a public supertype everywhere.

PiperOrigin-RevId: 485568625
(cherry picked from commit 3fdfe585ffe927c90f412b892101dbe01119b8df)

* Fix Dackka javadoc errors in protected methods

If there's an @param javadoc tag in a supertype then all overrides
of this method that don't also override the javadoc must use th…
guoen21 added a commit to DiceTechnology/ExoPlayer that referenced this issue Mar 21, 2023
* 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 4c73241058041fd978e9748b2158168d4e6e702d)

* 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 ccab9fba0369ea9709a6987024177e8b73a5c7ac)

* Document the allowed values of TsPayloadReader.Flags IntDef

PiperOrigin-RevId: 479569806
(cherry picked from commit 7c68b8d4500cb25779a473b52029944ec4d29543)

* 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 faa796d7365330d1f1d4f5b17901d6b1a78ce868)

* Bump dexmaker version

PiperOrigin-RevId: 479579252
(cherry picked from commit a6b9772f0e6f5a31baafb6965c3386d819d3c1e9)

* 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 2188685c465aa6d641e78ab33eaa93fbb92185b8)

* 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 a366590a0425ff138520752e2fc94c70429c20ab)

* 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 af19e0ea890e7b274b6f75f409f00f11e11c1c81)

* Add local file picker to ConfigurationActivity

PiperOrigin-RevId: 480349627
(cherry picked from commit 225d0dcdd1e7e7f1f41d8ac1d2dee7340c40cf3a)

* Demo: Read long values from trim slider.

Before, slider values were read as `floor()`'ed `longValue()`s, so that trimming to
intervals less than one second would be interpreted as a request for a zero-
duration trim.

Also, rename `radiusRange` references here to `trimRange`, since this is not a
radius range.

PiperOrigin-RevId: 480401556
(cherry picked from commit 6c59f9ece40f6450405d29acd559492145158409)

* Demo: Hide player controls by default.

Player controls are somewhat distracting when showing the difference between the
input and output video, as they obscure and darken the video players.

PiperOrigin-RevId: 480597804
(cherry picked from commit 91a61cecbe37f4c5595f534ee237011289c0ac18)

* Demo: Shorten trim range from 60 seconds to 10 seconds.

Most demo videos aren't very long, and the default demo video is only 10 seconds.

Shorten the maximum trim duration to 10 seconds, to demonstrate transformer functionality more easily, and allow this to be used more easily when trimming short sections of a longer video (ex. to make test clips)

PiperOrigin-RevId: 480602037
(cherry picked from commit 3142a2127dc224e4c2124989b952a8bd1e06d510)

* Add Cea608DecoderTest

When debugging and fixing Issue: google/ExoPlayer#10666 I wanted to write a regression
test, but needed to add a test first... This is just a small bit of
coverage to start with. It checks the field/channel filtering works
correctly, but doesn't check any styling info. It also doesn't test
'pop on' subtitles (i.e. when the subtitle isn't shown until a 'end of
subtitle' signal is received).

PiperOrigin-RevId: 480644568
(cherry picked from commit 6052212c15b89d71846f1f3855728ce863304bca)

* Remove supportsSampleMimeType from Muxer.Factory

- This method is redundant with getSupportedSampleMimeTypes().
- This is to prepare the Muxer class to become public.

PiperOrigin-RevId: 480840902
(cherry picked from commit 8962f5a3f4b505224ceb22ac5771b85f24e30358)

* Fix blank toast in Transformer Demo

PiperOrigin-RevId: 480847967
(cherry picked from commit 446c9943f935541d7b76fc1dfa62ee969d775f60)

* Migrate media constants from androidx.media.util.MediaConstants

Adds root extras and metadata extras to MockMediaLibraryService and MockMediaBrowserCompatService and completed test cases for asserting
interoperability with a media1 or Media3 browser.

PiperOrigin-RevId: 480854842
(cherry picked from commit f95406e75d1eca9b96477132d33d752e2485bee6)

* Ensure sessions without MediaPeriodId are ended after seek to new item

We already have logic to end all session except the current one if the
current one doesn't have a MediaPeriodId yet. This is assuming that this
only happens after a seek on the app side where the player doesn't have
detailled knowledge about the MediaPeriodIds yet.

Currently this logic isn't triggered if the window we are coming from
doesn't have its MediaPeriodId either as we run into another check that
keeps sessions around until we have a valid windowSequenceNumber.

Swapping both conditions fixes this case without breaking any of the
other known transition scenarios.

Issue: androidx/media#180
PiperOrigin-RevId: 480866465
(cherry picked from commit 6070d9110a9cec61f6073c7669f2f8185a635767)

* Mark effectively-final PlayerControlView fields as actually final

This means the null checker can be more sure that these fields don't
get reassigned between a null-check and a usage.

PiperOrigin-RevId: 481142004
(cherry picked from commit 248ee469ad243a86b66445f96782b915296eec4c)

* Effect: Remove unused private int ouptutTexId in pixel tests.

PiperOrigin-RevId: 481143798
(cherry picked from commit 026699bafc6d73bc63b6cf416ea183fc3d506039)

* Fix the position of IntDef annotations on fields in the UI module

PiperOrigin-RevId: 481150758
(cherry picked from commit 871a5e685e9bc78544107c803306320e7d53ee53)

* Fix display settings window UI bug for foldable devices.

PiperOrigin-RevId: 481215581
(cherry picked from commit 6cdaf2c031258221939eead3b11075a90e2c742c)

* Add copybara annotated import statement for special cases

PiperOrigin-RevId: 481605567
(cherry picked from commit fd315dadebe479f2cc75fb4fa482cb414270bdcf)

* Add manifest to make gradle build work

PiperOrigin-RevId: 481606248
(cherry picked from commit 325e973ace929efa193b114271d844f20814705a)

* Add DefaultMuxer forwarding to FrameworkMuxer

- The naming DefaultMuxer is more consistent with the rest of
Transformer codebase (e.g. DefaultEncoderFactory).
- By hiding the implementation details of DefaultMuxer, the transition
to in-app Muxer will be seamless for apps using DefaultMuxer.
- The current plan is that DefaultMuxer will become the in-app muxer.

PiperOrigin-RevId: 481838790
(cherry picked from commit b4d7f066dd31cce1e3d7ab14cc47d3b7be364a88)

* Remove more references to overriding layouts from Player(Control)View

In exoplayer2 this affects StyledPlayer(Control)View

#minor-release

PiperOrigin-RevId: 481878940
(cherry picked from commit a5583c04bb6c199633e2b1edf036060c0d33b616)

* Fix parameter comment block.

#cleanup

PiperOrigin-RevId: 481882181
(cherry picked from commit b6bd35860cda60f27439df737fdee815060ed6fe)

* Remove deprecated setOutputMimeType

This is to prepare Muxer to become public

PiperOrigin-RevId: 481893842
(cherry picked from commit bd9181e6ba5daf865f9c2f4338f1238b108dafd8)

* GL: Move loadAsset to GlProgram, where it's used.

(Also, make some public methods private)

PiperOrigin-RevId: 481912071
(cherry picked from commit a404fde4fa9d9d16b0be3c6e08dabd059c07f471)

* 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 76ce0cc69fa12a9b2592103da97dd45c15bfe4d3)

* Test: Update MatrixProcessorPixelTest to use input width and height.

Before, they used `width` and `height`, which was inconsistent with other pixel tests, and less descriptive.

Refactoring change only. No functional change intended.

PiperOrigin-RevId: 481970243
(cherry picked from commit 620d8c9479469f11bdd372e80d231a64e0132808)

* Remove ForwardingPlayer special case from PlayerControlView.setPlayer

This was originally added in https://github.com/google/ExoPlayer/commit/4fd7d777b669f6adacc3737a7e15b04a57f030fb, but it hasn't done anything
since https://github.com/google/ExoPlayer/commit/98ee159df161c7c8806c0b0490b642738822f6a7 (when the instanceof ExoPlayer check was removed).

PiperOrigin-RevId: 482161662
(cherry picked from commit 7d5f1a24be204321961aba81f2de5b1ce1328c71)

* Effect: Remove unnecessary "this" qualifier

`transformationMatrix` is not ambiguous, as there's no other local
transformationMatrix variable nearby.

PiperOrigin-RevId: 482184602
(cherry picked from commit c698ec51a24bdf42e2affad181d2a6d812cbe47b)

* Make Muxer public

The reason for making the Muxer public is that we want to add an option
to disable or configure the timer that will throw when the muxer doesn't
receive any data for a given period of time.

PiperOrigin-RevId: 482199360
(cherry picked from commit d213b93958fce7e2a25851ec44b7c1938fcf0d7d)

* 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 9e1adee4cbc3386672f42d580734175c442bdbea)

* Corrected ordering of javadoc params

PiperOrigin-RevId: 482231370
(cherry picked from commit 897722071e90f7b79527a75ac667a4e2143fbdfd)

* Merge pull request #10578 from thucngv:release-v2

PiperOrigin-RevId: 481115402
(cherry picked from commit 9861f88f3db419553b893efd98a5e1a0c8c6287c)

* Use static import for Assertions in MCVR

PiperOrigin-RevId: 481122795
(cherry picked from commit 12f7174e1f8a2c2b1f36df749b43262efb88f60a)

* Merge pull request #183 from jasper-apps:bugfix/make-download-notification-appear-immediately

PiperOrigin-RevId: 482165983
(cherry picked from commit 405455b06c6d596552c695670664309319f5570c)

* Map lib-effect from androidx to exoplayer2

PiperOrigin-RevId: 482179761
(cherry picked from commit 28c4be2f6bd56205e3b8128bf710c34b3b3d65e9)

* Remove muxerFactory dependency on playerListener

This listener will need to be passed to the MuxerWrapper to throw when
the Transformer is stuck.

PiperOrigin-RevId: 482433552
(cherry picked from commit e3f28421fd85f1c44135f24c3df1fac000834f67)

* Change areSizeAndRateSupported to use PerfomancePoint.covers

PiperOrigin-RevId: 482461219
(cherry picked from commit 0eb30eacc7f65f84e34e038567d0dd86dc4b6e2c)

* Fix some incorrect comments in Cea608DecoderTest

Also used all-caps consistently

PiperOrigin-RevId: 483317405
(cherry picked from commit 6dcb9aaaa87d1a11a0eb41d1f80312796bceb55a)

* Merge pull request #10618 from vishnuchilakala:fix/do_not_send_content_complete_if_midroll_skipped

PiperOrigin-RevId: 482481703
(cherry picked from commit a413b478f7c45615d3fc7ebd31cacfc363e8ca31)

* Merge pull request #162 from ittiam-systems:rtp-mp4a-latm

PiperOrigin-RevId: 482490230
(cherry picked from commit fd2ba37b1d67576313aec0512d630331b7c99f4b)

* Add DAI specific methods to AdPlaybackState

PiperOrigin-RevId: 482755468
(cherry picked from commit a8e6894ad63271293a831d13419b1372fe0f387a)

* Add CanIgnoreReturnValue to AudioProcessor#configure + implementations

Although it can be useful to check the output format, it's not required or needed.

For some AudioProcessor implementations, it is stated/obvious that
the output format will match the input, in which case there is no
a need to check the return value.

#cleanup

PiperOrigin-RevId: 483403679
(cherry picked from commit a7bfa12eecb42cbdd13bd7e612603a4d400ebda4)

* Use int for an unsigned byte value in Cea608Decoder

This is a no-op, but it's more 'correct' because it avoids any potential
sign mix-ups that come from storing an unsigned byte (with a
potentially set MSB) in a signed java byte variable.

PiperOrigin-RevId: 483409798
(cherry picked from commit 3d0f43a149c846670480c993e09def1a2d2eeeea)

* Clarify sideloaded subtitle example

#minor-release

PiperOrigin-RevId: 483633564
(cherry picked from commit eaf1f2153abca685fce6092a52eb4059bc61815a)

* Add GL utility methods to get 4x4 identity and set identity

PiperOrigin-RevId: 483671580
(cherry picked from commit f5ad4e098dd71bd4f99b87350e042acab4f95746)

* Move AudioProcessor to common.

PiperOrigin-RevId: 483699606
(cherry picked from commit dda17db261758f7211ffa793ee9cc6fea842addb)

* 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 ad52b68c738e8321b966b904d3cd2139f7a560ef)

* Fix `Cea608Decoder` handling of service switch commands in field 2

From ANSI-CTA-608-E R-2014 section 8.4:
> When closed captioning is used on line 21, field 2, it shall conform
> to all of the applicable specifications and recommended practices as
> defined for field 1 services with the following differences:
> 1. The non-printing character of the miscellaneous control-character
>    pairs that fall in the range of 0x14, 0x20 to 0x14, 0x2F in field 1,
>    shall be replaced with 0x15, 0x20 to 0x15, 0x2F when used in field
>    2.
> 2. The non-printing character of the miscellaneous control-character
>    pairs that fall in the range of 0x1C, 0x20 to 0x1C, 0x2F in field
>    1, shall be replaced with 0x1D, 0x20 to 0x1D, 0x2F when used in
>    field 2.

This basically means that `cc1=0x15` in field 2 should be interpreted as
`cc1=0x14` in field 1, and same for `0x1D -> 0x1C`.

The `isMiscCode`  method above already handles this by ignoring the LSB
(the only difference between `0x14` and `0x15`, and `0x1C` and `0x1D`)
by AND-ing with `0xF6` instead of `0xF7`. This change uses the same
trick in `isServiceSwitchCommand`.

Issue: google/ExoPlayer#10666
#minor-release
PiperOrigin-RevId: 483927506
(cherry picked from commit 7c6d492ff19b6aead4cc6f1f9a426145fc1faa0d)

* Mute input video player in transformer demo

PiperOrigin-RevId: 483969411
(cherry picked from commit 8181b3c6a1aba32459d4a5975cc708cbf224b397)

* Add AudioProcessor.AudioFormat equals method.

PiperOrigin-RevId: 483983486
(cherry picked from commit c9585d0154980c576710d035be51eb472fbd6665)

* Add muxer timer to detect when generating an output sample is too slow

This allows to throw when the Transformer is stuck or is too slow.

PiperOrigin-RevId: 484179037
(cherry picked from commit 376ee77f52bed47de54c6478b4006f1b25a543d0)

* Make adding ad live breaks more robust

This change makes adding ad events in live streams more robust by allowing ad
groups to grow in number of ads if more ad events are received than initially
announced by the SDK.

With the IMA prefetch feature, an AdPod can grow in size in certain conditions
like from initially 2 ads to 4 ads being part of the ad group. With this change,
if an additional ad event arrives while the ad group is still being played,
the ad group is expanded. If the event arrives late and the ad group is already
completed, a new group is created for the remaining ads.

This also covers the case where we join the live stream while an ad is being
played and we missed at least one LOADED event from the SDK. Ads of the group
before the first LOADED event are ignored in such a case.

PiperOrigin-RevId: 484214760
(cherry picked from commit 136addf640e451602163be9e4272d1e27b8ed5b8)

* Add test for muxer watchdog timer

PiperOrigin-RevId: 484298261
(cherry picked from commit 42057cc9f8f81e24c64c629d2e11e7102afd0f30)

* Upgrade dackka and fix some generation errors

#minor-release

PiperOrigin-RevId: 484483080
(cherry picked from commit fc1eca10f4934fd92c84db222815fc1e77ddd5f6)

* Disable the muxer watchdog if all tracks have ended.

PiperOrigin-RevId: 484512661
(cherry picked from commit 2390322a00a9e71f16dfe28088ae7cd3e462129f)

* Bump appTargetSDKVersion to 33

#minor-release

PiperOrigin-RevId: 484514123
(cherry picked from commit 1bbe7c11f8ad7dfbbf3fe30796414bd196f0df5a)

* Tighten the wording for sending a pull request.

PiperOrigin-RevId: 485036120
(cherry picked from commit 8030a492ff676fa32dc25fe48829c9a066529cd5)

* Disable failing tests of FlacExtractorSeekTest

PiperOrigin-RevId: 485061783
(cherry picked from commit 55b82ff8ae491f6bcc7f3901476d2b1571a10005)

* Enfore minCompileSdk version when depending on ExoPlayer/Media3 libs

If an app sets a compileSdkVersion that is lower than the one used to
create AARs of its dependencies, the build process may produce invalid
outputs, for example by stripping methods from the APK that are only
called when the app is running on a new API version.

To avoid this issue, we can enforce that the compileSdk of apps or
libraries depending on ExoPlayer/Media3 is at least the same as the
one we used for compilation when creating the AAR.

Issue: google/ExoPlayer#10684
PiperOrigin-RevId: 485100067
(cherry picked from commit 23d39caea0bee0143705191fd97ac7f0cf9a76f9)

* Removed move transformation for exoplayer2 audio package-info.java

https://github.com/google/ExoPlayer/commit/dda17db261758f7211ffa793ee9cc6fea842addb creation of audio/package-info.java introduced a copybara conflict with the exoplayer2/audio/package-info.java move transformation in copy.bara.sky. Solution was to remove original package-info-common-audio.java and the move transformation as https://github.com/google/ExoPlayer/commit/dda17db261758f7211ffa793ee9cc6fea842addb now covers it.

Tested with a copybara push to exoplayer github

PiperOrigin-RevId: 485329674
(cherry picked from commit 972e169bd85b14848dcae75e34f9e95fe87e1f4b)

* HDR: Generalize Pixel 6 workaround to TP

PiperOrigin-RevId: 485366659
(cherry picked from commit 6de5d9336db68cab7ffa886869fe882af6299223)

* Load bitmaps for `MediaMetadataCompat` and handle the metadata updates.

* Add `Listener` in `MediaSession` with method `onNotificationRefreshRequired(MediaSession)`.
* Add `MediaSessionService` as the listener of the `MediaSession` when `MediaSession` is added to `MediaSessionService`
* Load bitmap when update metadata in `MediaSessionLegacyStub` and call `onNotificationRefreshRequired` when bitmap asynchronously arrives.

PiperOrigin-RevId: 485376145
(cherry picked from commit 624238c6b6e621deed585cb19b63f117ae3f7e76)

* Apply tone mapping workaround to Pixel Watch as well.

Not sure what BUILD.ID the fix will first be applied on though.

PiperOrigin-RevId: 485389618
(cherry picked from commit 2ddd645a3484aed4b9e519f99f4ab1bc989b6a0e)

* Fix Dackka/Metalava errors in the effects module

Public methods may only refer to public types in their signature. This
change ensures that by switching to a public supertype everywhere.

PiperOrigin-RevId: 485568625
(cherry picked from commit 3fdfe585ffe927c90f412b892101dbe01119b8df)

* Fix Dackka javadoc errors in protected methods

If there's an @param javadoc tag in a supertype then all overrides
of this method that don't also override the javadoc must use the same
parameter name.

PiperOrigin-RevId: 485857711
(cherry picked from commit b8e5d708fc77a06e831abd7f2c2e57f68bb3720f)

* 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

* HDR Test: Add link to tested method.

PiperOrigin-RevId: 485890141
(cherry picked from commit bd4e58d68bd219154e3d90b0a1031236f8608e96)

* Disable publishing block when media3 included in another build.

From https://github.com/androidx/media/pull/127/files

PiperOrigin-RevId: 485921271
(cherry picked from commit 36a51ac9163fdea5e85e1308a7acd0b945918992)

* Add  @SuppressWarnings to unblock T SDK for <unknown commit>

LSC: https://docs.google.com/document/d/16tpK6aXqN68PvTyvt4siM-m7f0NXi_8xEeitLDzr8xY/edit?usp=sharing

TESTED=NA
BEGIN_PUBLIC/END_PUBLIC
PiperOrigin-RevId: 486180995

(cherry picked from commit 88445d213a3ebfd30b32994dbdacc9488923041e)

* HDR: Update test FileUtil to handle null ColorInfo.

PiperOrigin-RevId: 486706595
(cherry picked from commit 0b53c934d8f391000c72a0a9d6ced9c2bdb77a95)

* HDR: Set decoder codec profile and level if available.

This should be necessary to ensure decoders see fewer errors.

Setting this resulted in removing native_dequeueOutputBuffer errors on OMX.MTK decoders for in-app tone mapping prototyping.

PiperOrigin-RevId: 486715941
(cherry picked from commit 0b7e5bbad287053d56720ad682c1a5015eedb9cf)

* Move muxer initialization off application thread

Problem: We are initialising muxer as soon as we start the transformation. Now the startTransformation() method can be called from main thread, but muxer creation is an I/O operation and should be not be done on main thread.

Solution: Added lazy initialisation of muxer object. The actual transformation happens on background thread so the muxer will be initialised lazily from background thread only.

Another way was to provide an initialize() method on MuxerWrapper which will explicitly initialise muxer object but with this approach the caller need to call the initialise method before calling anything else. With current implementation the renderers are calling MuxerWrapper methods on various callbacks (Not sequentially) and also we are sharing same muxer with multiple renderers so It might become confusing for the caller on when to call the initialise() method. Also there are few methods on MuxerWrapper which dont really need muxer object. So in short it might make MuxerWrapper APIs more confusing.

Validation: Verified the transformation from demo app.
PiperOrigin-RevId: 486735787
(cherry picked from commit b10b4e6d4694c7240073b81c3a09227042b58c21)

* Move muxing inside sample pipelines

This logic is currently in the player renderers. With multi-asset, the
renderers will go into the AssetLoader, which shouldn't be responsible
for muxing.

PiperOrigin-RevId: 486860502
(cherry picked from commit d8754b6642d0a99e2705f3e21ff8b83d50472bbd)

* Set targetSdkVersion of main demo app back to 29

#minor-release

PiperOrigin-RevId: 486969194
(cherry picked from commit 21724665283a29133f5d77f5321bcdf182e6aafd)

* Move slow mo logic to sample pipelines

This is to avoid having this logic in TransformerInternal once it is
added.

PiperOrigin-RevId: 487159941
(cherry picked from commit b59fdf5e98bf5ec3cd0800edb5fb2e6ebd9da5c3)

* Merge Issue: google/ExoPlayer#10762: Fix ffmpeg jni wrapper returning invalid result codes

Imported from GitHub PR Issue: google/ExoPlayer#10762

This ensure that ffmpeg error code are properly translated to values that the ExoPlayer decoder understand.
The main gain is that it allows the decoder to properly ignore more cases of invalid data and recover.
The second gain is that the other errors are now proper ExoPlayer errors and no more obscure buffer ones.

Fixes: Issue: google/ExoPlayer#10760
Merge 82ceeb77d6df71f5ffb0474db66a36fd6eb8e51a into 972e169bd85b14848dcae75e34f9e95fe87e1f4b
COPYBARA_INTEGRATE_REVIEW=go/exoghi/10762 from Tolriq:ffmpeg_error_code 82ceeb77d6df71f5ffb0474db66a36fd6eb8e51a
PiperOrigin-RevId: 487189910

(cherry picked from commit 6d2e7a1b5760a05eade18b1a028b3d27f714715c)

* Add ExoPlayerAssetLoader

Just move some code around for now, to start setting up the overall
structure.

PiperOrigin-RevId: 487229329
(cherry picked from commit 5d1cab0cf50e31e5886310dd55e6de7c4b3523ba)

* Change UnsupportedEncodingException to IllegalArgumentException

In startTransformation method we were throwing UnsupportedEncodingException (IOException) when mediaItem with unsupported arguments is passed.
Changed this to IllegalArgumentException which seems more logical here.

PiperOrigin-RevId: 487259296
(cherry picked from commit 4598cc92485c149f5c613d3c926ae4493a457668)

* Set HDR color info on FrameworkMuxer

Not setting the color info results in a missing "colr" box in the produced
container, under file/moov/trak/mdia/minf/stbl/stsd/hvc1. This means extractors
will not be able to find out the transcoded file is HDR.

In `Transformer`, this means it can't transcode this transcoded file, because
it currently relies on the container bearing HDR info to construct the
transcoding sample pipeline.

PiperOrigin-RevId: 487276712
(cherry picked from commit d6c8e3a8aff07be5c184473826753047bf4b2387)

* HDR: Implement ForceInterpretHdrVideoAsSdr

Also, document that we tone map when no HDR features are explicitly set

PiperOrigin-RevId: 487310971
(cherry picked from commit 8bdd2784d330c0c9f493f092825d08f8a5cc4305)

* Fix Dackka/Metalava errors in the ExoPlayer module

This makes two types of fix:
1. Align parameter names on overridden methods where the superclass
   has `@param` javadoc.
2. Use `@hide` on `protected final` methods that refer to package-private
   types. This will hide these symbols from Dackka javadoc generation
   but not (currently) from the artefacts distributed on Maven. These
   methods are currently unusable outside their package anyway (e.g. by
   external developers) because of the dependency on a package-private
   type.

This also changes some HLS, SmoothStreaming, and IMA code where I've renamed
parameters of overridden methods to be consistent across the type
hierarchy.

#minor-release

PiperOrigin-RevId: 487472665
(cherry picked from commit 10c4a4dfc172cfac77528c7cb746fe827ca6f78c)

* Fix Dackka/Metalava errors in the HLS and RTSP modules

This makes two fixes:
1. Remove `HlsSampleStreamWrapper.Callback` (package-private) from the
   list of interfaces implemented by `HlsMediaPeriod` (`public`) and
   move the implementation to a private inner class instead. This avoids
   Metalava complaining about a public class that inherits from a
   package-private type.
2. Reduce the visibility of
   `RtpPayloadFormat.isFormatSupported(MediaDescription)` from `public`
   to package-private. The `MediaDescription` type is already
   package-private, so this method was already unusable outside the
   package.

#minor-release

PiperOrigin-RevId: 487472781
(cherry picked from commit 9041d7b979f3b998758d74279f5d281088d879a8)

* Fix Dackka/Metalava errors in av1, flac, ffmpeg, midi, and opus modules

This uses `@hide` on `protected final` methods to hide them from Dackka
javadoc generation, since these methods are inaccessible to developers
anyway. These symbols will still (currently) be included in artefacts
distributed on Maven (because we don't run Metalava as part of
generating these artefacts).

In some cases I had to change the visibility/finality of methods to make
them `protected final` before adding the `@hide` annotation (but
the impact should be very low, since most of these methods were either
already unusable by app developers, or they shouldn't have been used).

#minor-release

PiperOrigin-RevId: 487472907
(cherry picked from commit 1cd488ac9a1e838139495f55aa32eb951f1e8d8f)

* Fix Dackka/Metalava errors in test_utils module

This involves reducing the visibility of methods/constructors that
are already unusable outside the `androidx.media3.test.utils` package.

#minor-release

PiperOrigin-RevId: 487473005
(cherry picked from commit ca8de0e49b03339b03a6e048e7e7a27df86e5ff5)

* Fix Dackka parameter name error in `Gav1Decoder` and `VpxDecoder`

These aren't caught by presubmit because the classes are annotated
`@VisibleForTesting` and are therefore stripped out by Metalava. However
Metalava doesn't run when we're generating javadoc for real.

#minor-release

PiperOrigin-RevId: 487476260
(cherry picked from commit 14e23d34e17afa076cd912264bb60685961c58e3)

* Set targetSdkVersion of main demo app to 29

#minor-release

PiperOrigin-RevId: 487479366
(cherry picked from commit 09bee98b8f94a608fc994f96f2f538458a96b8d9)

* Fix parameter name mismatch in MappingTrackSelector.selectTracks

It's not clear to me why presubmit didn't catch this, I briefly
investigated but couldn't work it out - so I'm just going to fix
it and move on.

#minor-release

PiperOrigin-RevId: 487497827
(cherry picked from commit 13ee34faccaf98ff90850601f40c95622b1e878b)

* Configure Dackka to generate javadoc for protected methods

#minor-release

PiperOrigin-RevId: 487497923
(cherry picked from commit 7cb2e1130326a3a802b439185210004268d96b31)

* Add missing IntDef on MediaSource.Factory.getSupportedTypes overrides

Without this the annotation isn't shown in javadoc (same in Dackka)

No annotation:
https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.html#getSupportedTypes()

Annotation present:
https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/source/MediaSource.Factory.html#getSupportedTypes()

#minor-release

PiperOrigin-RevId: 487498450
(cherry picked from commit 4949fbe5edc9dbbf1a713b152907cc3a175956d5)

* Reformat demo build.gradle file

PiperOrigin-RevId: 487539107
(cherry picked from commit 0383b723b7c26da107a719a16a05da459ae971ee)

* Add `@ForOverride` to `DecoderAudioRenderer` `protected` methods

PiperOrigin-RevId: 487779266
(cherry picked from commit a34fdcf168a3704babdb6b7d96c60344ab89c17c)

* Reformat demo build.gradle file

PiperOrigin-RevId: 488376715
(cherry picked from commit 30b73c85c53cce0d21e8df21ee680406aa0ad1d7)

* Calculate SSAI window duration for live periods with unset duration.

We currently skip this calculation entirely, but it can be added by
calculating the window duration using the wrapped window's duration
and the provided AdPlaybackState.

Issue: google/ExoPlayer#10764
PiperOrigin-RevId: 488614767
(cherry picked from commit 20151b9930f1b54d7894ec41465a2e85df92462d)

* 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

#minor-release

PiperOrigin-RevId: 488645089
(cherry picked from commit 3e5103a3e55e2dc545b4a2442beaa49f307ecfdc)

* 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 1b24e6fd14774d5c8b3e7b8084b30204581d13ce)

* 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 8438daca1f8cbea24aa414ee500044baf1a28367)

* Filter bogus AndroidX core jar file when creating javadoc

#minor-release

PiperOrigin-RevId: 489202167
(cherry picked from commit 7e82d4ec44b88a54ac022acf1cccdcd383457e1a)

* Remove @hide javadoc annotation from ExoPlayer GitHub

This tag is only understood by Dackka, which is used to generate the media3 javadoc.

PiperOrigin-RevId: 489233200
(cherry picked from commit 058cba95d40db83c77f4dd0aa8cb561221463b3a)

* Version bump to exoplayer:2.18.2 and media3:1.0.0-beta03

#minor-release

PiperOrigin-RevId: 489959918
(cherry picked from commit ca190c084bd9ef8c281fac7655344d48f265042c)

* Update JavaDoc for exoplayer:2.18.2

#minor-release

PiperOrigin-RevId: 490202192
(cherry picked from commit 6f1cf6dab4dd7e37e5d2ea15ad0cc34eafba601c)

* Reorder some release notes in other sections.

#minor-release

PiperOrigin-RevId: 490224795
(cherry picked from commit e567594cf7640bd96ec13d071c4523f7898b55be)

* Fix compilation error in ffmpeg JNI layer

PiperOrigin-RevId: 490263003
(cherry picked from commit 202e03fc64dac568955ce00684368cbea9b244f7)

* Remove two media3-only release notes from the ExoPlayer release notes

Issue: google/ExoPlayer#10811
PiperOrigin-RevId: 490726544
(cherry picked from commit bb270c62cf2f7a1570fe22f87bb348a2d5e94dcf)

* Update migration script

Issue: google/ExoPlayer#10854
PiperOrigin-RevId: 496922055
(cherry picked from commit 8e9f83867b5c9536488cf74f06c4cf2535ef848f)

* Changed decoder list sort to order by functional support of format

Added new method to check if codec just functionally supports a format. Changed getDecoderInfosSortedByFormatSupport to use new function to order by functional support. This allows decoders that only support functionally and are more preferred by the MediaCodecSelector to keep their preferred position in the sorted list.

UnitTests included
-Two MediaCodecVideoRenderer tests that verify hw vs sw does not have an effect on sort of the decoder list, it is only based on functional support

Issue: google/ExoPlayer#10604
PiperOrigin-RevId: 487779284
(cherry picked from commit 1eb8a6b36ed98bd66a5bad5273526a918511a39f)

* Fix NPE when listener is not set

PiperOrigin-RevId: 488970696
(cherry picked from commit f52bb274b8b54df2404ab485c7d277150005b679)

* Add setPlaybackLooper ExoPlayer builder method

The method allows clients to specify a pre-existing thread
to use for playback. This can be used to run multiple ExoPlayer
instances on the same playback thread.

PiperOrigin-RevId: 488980749
(cherry picked from commit 79b809b5563260cd20541afe607e36ae351fbbed)

* Mark broadcast receivers as not exported

They are called from the system only and don't need to be exported
to be visible to other apps.

PiperOrigin-RevId: 489210264
(cherry picked from commit c1fd03df7403019143f503bbe208d73cabc11243)

* Throw exception if a released player is passed to TestPlayerRunHelper

I considered moving this enforcement inside the ExoPlayerImpl
implementation, but it might lead to app crashes in cases that apps
(incorrectly) call a released player, but it wasn't actually causing a
problem.

PiperOrigin-RevId: 489233917
(cherry picked from commit d4c9199a6175a6c89f7a3d3900af1b9dfcb075f0)

* Add additional codecs to the eosPropagationWorkaround list.

Issue: google/ExoPlayer#10756
PiperOrigin-RevId: 489236336
(cherry picked from commit cbcdbfe021d9ffb453ed0e67a9ca1ea5f8691f51)

* Pass correct frame size for passthrough playback

When estimating the AudioTrack min buffer size, we must use a PCM
frame of 1 when doing direct playback (passthrough). The code was
passing -1 (C.LENGTH_UNSET).

PiperOrigin-RevId: 489238392
(cherry picked from commit d9d716869b7df2cd95704e9ac24a5f9a376afa2c)

* 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 b81cd08271cd94f244ca5d7c995cd29523057a60)

* Add `set -eu` to all shell scripts

These flags ensure that any errors cause the script to exit (instead of
just carrying on) (`-e`) and that any unrecognised substitution variables
cause an error instead of silently resolving to an empty string (`-u`).

Issues like Issue: google/ExoPlayer#10791 should be more quickly resolved with
`set -e` because the script will clearly fail with an error like
`make: command not found` which would give the user a clear pointer
towards the cause of the problem.

#minor-release

PiperOrigin-RevId: 490001419
(cherry picked from commit f83441974411dca5673a34548b11bc6e6cb809ff)

* Fixed missing imports for Metadata and AdPlaybackState for Exoplayer

PiperOrigin-RevId: 490012573
(cherry picked from commit 1551bea3983196272d1a8e836103a77fd9090568)

* Fixed Exoplayer imports for SimpleBasePlayerTest

PiperOrigin-RevId: 490181547
(cherry picked from commit 788f74740b2e560af255ab948a4bc64d116633ca)

* Add `DefaultExtractorsFactory.setTsSubtitleFormats`

ExoPlayer is unable to detect the presence of subtitle tracks in some
MPEG-TS files that don't fully declare them. It's possible for a
developer to provide the list instead, but doing so is quite awkward
without this helper method. This is consistent for how
`DefaultExtractorsFactory` allows other aspects of the delegate
`Extractor` implementations to be customised.

* Issue: google/ExoPlayer#10175
* Issue: google/ExoPlayer#10505

#minor-release

PiperOrigin-RevId: 490214619
(cherry picked from commit 4853444f0dc90163c257d0e20962604510557df4)

* Reorder some release notes in other sections.

PiperOrigin-RevId: 490224795
(cherry picked from commit e567594cf7640bd96ec13d071c4523f7898b55be)

* Merge pull request #10786 from TiVo:p-aacutil-test-impl

PiperOrigin-RevId: 490465182
(cherry picked from commit 8a9a66c288d5ee2749a29de133e598f326e518dd)

* 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 f262e9132b32ad89f65853086f30389925b61422)

* Parse and set `peakBitrate` for Dolby TrueHD(AC-3) and (E-)AC-3

#minor-release

PiperOrigin-RevId: 490527831
(cherry picked from commit 01eddb34f555903c576c79b02a7b34a53e0272cb)

* Rollback of https://github.com/google/ExoPlayer/commit/01eddb34f555903c576c79b02a7b34a53e0272cb

*** Original commit ***

Parse and set `peakBitrate` for Dolby TrueHD(AC-3) and (E-)AC-3

#minor-release

***

PiperOrigin-RevId: 490570517
(cherry picked from commit ea3552c1a030d8b14c0cd0093f7eaa6242f969eb)

* Rollback of https://github.com/google/ExoPlayer/commit/ea3552c1a030d8b14c0cd0093f7eaa6242f969eb

*** Original commit ***

Rollback of https://github.com/google/ExoPlayer/commit/01eddb34f555903c576c79b02a7b34a53e0272cb

*** Original commit ***

Parse and set `peakBitrate` for Dolby TrueHD(AC-3) and (E-)AC-3

#minor-release

***

***

PiperOrigin-RevId: 490707234
(cherry picked from commit 8c91a31ced401ce14911fbfdf58dda3c7ee8e643)

* Remove two media3-only release notes from the ExoPlayer release notes

Issue: google/ExoPlayer#10811
PiperOrigin-RevId: 490726544
(cherry picked from commit bb270c62cf2f7a1570fe22f87bb348a2d5e94dcf)

* Use `ParsableBitArray` instead of `ParsableByteArray`

To avoid complicated bit shifting and masking. Also makes the code more readable.

PiperOrigin-RevId: 490749482
(cherry picked from commit 89e4b8d049507efeb610f437429f25cf18df8f8b)

* Convert bitrates to bps before setting it

Format expects the values of `averageBitrate` and `peakBitrate` in bps and the value fetched from AC3SpecificBox and EC3SpecificBox is in kbps.

PiperOrigin-RevId: 490756581
(cherry picked from commit 67955e0ce331481bcb3fd94c9ffb9632f27eae6e)

* Remove flakiness from DefaultAnalyticsCollectorTest

Our FakeClock generally makes sure that playback tests are fully
deterministic. However, this fails if the test uses blocking waits
with clock.onThreadBlocked and where relevant Handlers are created
without using the clock.

To fix the flakiness, we can make the following adjustments:
 - Use TestExoPlayerBuilder instead of legacy ExoPlayerTestRunner
   to avoid onThreadBlocked calls. This also makes the tests more
   readable.
 - Use clock to create Handler for FakeVideoRenderer and
   FakeAudioRenderer. Ideally, this should be passed through
   RenderersFactory, but it's too disruptive given this is a
   public API.
 - Use clock for MediaSourceList and MediaPeriodQueue update
   handler.

PiperOrigin-RevId: 490907495
(cherry picked from commit 7d62943bcd149eecce77cb44e4f867128ca374d3)

* Clean up javadoc on `Metadata.Entry.populateMediaMetadata`

Remove self-links, and remove section that is documenting internal
ordering behaviour of
[`SimpleBasePlayer.getCombinedMediaMetadata`](https://github.com/google/ExoPlayer/blob/bb270c62cf2f7a1570fe22f87bb348a2d5e94dcf/library/common/src/main/java/com/google/android/exoplayer2/SimpleBasePlayer.java#L1770)
rather than anything specifically about this method.

#minor-release

PiperOrigin-RevId: 490923719
(cherry picked from commit ed8c196e2eb36eefef9952d255cb6355807b9e9f)

* Ensure messages sent on a dead thread don't block FakeClock execution

FakeClock keeps an internal list of messages to be executed to
ensure deterministic serialization. The next message from the list
is triggered by a separate helper message sent to the real Handler.
However, if the target HandlerThread is no longer alive (e.g. when
it quit itself during the message execution), this helper
message is never executed and the entire message execution chain
is stuck forever.

This can be solved by checking the return values of Hander.post or
Handler.sendMessage, which are false if the message won't be
delivered. If the messages are not delivered, we can unblock the
chain by marking the message as complete and triggering the next
one.

PiperOrigin-RevId: 491275031
(cherry picked from commit 2977bef872d7f3a1611fd6e8a45931388ea21c9f)

* Merge pull request #10799 from OxygenCobalt:id3v2-multi-value

PiperOrigin-RevId: 491289028
(cherry picked from commit c827e46c3db2691b1b5fed57fa5b67890331aa85)

* Split up `Id3DecoderTest` methods

It's clearer if each test method follows the Arrange/Act/Assert pattern

PiperOrigin-RevId: 491299379
(cherry picked from commit bf77290fbe78aa25698c1a7082b2a18cd7f1b06c)

* Remove impossible `UnsupportedEncodingException` from `Id3Decoder`

The list of charsets is already hard-coded, and using `Charset` types
ensures they will all be present at run-time, hence we will never
encounter an 'unsupported' charset.

PiperOrigin-RevId: 491324466
(cherry picked from commit 043546a03475356764cf8b754bd0fff87a0c6e1a)

* Merge pull request #10776 from dongvanhung:feature/add_support_clear_download_manager_helpers

PiperOrigin-RevId: 491336828
(cherry picked from commit 3a7f940f41e278cde88c29201191229ed7d39e49)

* Bump cast sdk version and remove workaround for live duration

The fix for b/171657375 (internal) has been shipped with 21.1.0 already (see https://developers.google.com/cast/docs/release-notes#august-8,-2022).

PiperOrigin-RevId: 491583727
(cherry picked from commit 04f031d16805a6d6786d135f77d0f6e79c77c8f7)

* Add configuration to support OPUS offload

To support OPUS offload, we need to provide a few configuration values
that are currently not set due to the lack of devices supporting
OPUS offload.

PiperOrigin-RevId: 491613716
(cherry picked from commit 4cf877b81428021c4eb2dfa1a743178f280aceb5)

* Use audio bitrate to calculate AudioTrack min buffer in passthrough

Use the bitrate of the audio format (when available) in
DefaultAudioSink.AudioTrackBufferSizeProvider.getBufferSizeInBytes() to
calculate accurate buffer sizes for direct (passthrough) playbacks.

#minor-release

PiperOrigin-RevId: 491628530
(cherry picked from commit e219ac21ae604f182769d69f6f590191a92100d0)

* Rename SimpleBasePlayer.PlaylistItem to MediaItemData

This better matches the terminology we use elsewhere in the Player
interface, where items inside the playlist are referred to as
"media item" and only the entire list is called "playlist".

PiperOrigin-RevId: 491882849
(cherry picked from commit 6c467590d0fdc27dd5afeefe479c3d4414483de5)

* Parse and set bitrates in `Ac3Reader`

PiperOrigin-RevId: 492003800
(cherry picked from commit 5f73984823b943d750f41519d431ad3b12dada65)

* Add media type to MediaMetadata

This helps to denote what type of content or folder the metadata
describes.

PiperOrigin-RevId: 492123690
(cherry picked from commit 1ac72de551a07d37c3b80d96028463244407a5b4)

* Add support for most setters in SimpleBasePlayer

This adds the forwarding logic for most setters in SimpleExoPlayer
in the same style as the existing logic for setPlayWhenReady.

This change doesn't implement the setters for modifying media items,
seeking and releasing yet as they require additional handling that
goes beyond the repeated implementation pattern in this change.

PiperOrigin-RevId: 492124399
(cherry picked from commit e598a17b3628e1179fa4219ca3212407fb3fdeb1)

* Merge pull request #10750 from Stronger197:subrip_utf_16

PiperOrigin-RevId: 492164739
(cherry picked from commit 496cfa420d7dd23fb5913c9ecf7b0b1e04cc65ff)

* Split SubripDecoder and ParsableByteArray tests

In some cases we split a test method, and in other cases we just add
line breaks to make the separation between arrange/act/assert more
clear.

PiperOrigin-RevId: 492182769
(cherry picked from commit 02fa8aa784b518f0ffad5c44da6eec1a94def4ee)

* Removed ExoPlayer specific states from SimpleBasePlayer

PiperOrigin-RevId: 492443147
(cherry picked from commit 08f6fe172732f8a3327746f249888368c39265bc)

* Fix `TextRenderer` exception when a subtitle file contains no cues

Discovered while investigating Issue: google/ExoPlayer#10823

Example stack trace with the previous code (I added the index value for
debugging):

```
playerFailed [eventTime=44.07, mediaPos=44.01, window=0, period=0, errorCode=ERROR_CODE_FAILED_RUNTIME_CHECK
  androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:635)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loopOnce(Looper.java:202)
      at android.os.Looper.loop(Looper.java:291)
      at android.os.HandlerThread.run(HandlerThread.java:67)
  Caused by: java.lang.IllegalArgumentException: index=-1
      at androidx.media3.common.util.Assertions.checkArgument(Assertions.java:55)
      at androidx.media3.extractor.text.webvtt.WebvttSubtitle.getEventTime(WebvttSubtitle.java:62)
      at androidx.media3.extractor.text.SubtitleOutputBuffer.getEventTime(SubtitleOutputBuffer.java:56)
      at androidx.media3.exoplayer.text.TextRenderer.getCurrentEventTimeUs(TextRenderer.java:435)
      at androidx.media3.exoplayer.text.TextRenderer.render(TextRenderer.java:268)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1008)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:509)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loopOnce(Looper.java:202)
      at android.os.Looper.loop(Looper.java:291)
      at android.os.HandlerThread.run(HandlerThread.java:67)
]
```

#minor-release

PiperOrigin-RevId: 492464180
(cherry picked from commit 5f6fde4d2a90d78a8d58430c88d7dc12849fe163)

* Fix `ExoPlayerTest` to use `C.TIME_UNSET` instead of `C.POSITION_UNSET`

This inconsistency was exposed by an upcoming change to deprecate
`POSITION_UNSET` in favour of `INDEX_UNSET` because position is an
ambiguous term between 'byte offset' and 'media position', as shown
here.

PiperOrigin-RevId: 492470241
(cherry picked from commit 2f8cf947c71db6be9459492117fe95b1a8bc7178)

* Fix threading of onFallbackApplied callback

The callback is currently triggered on the ExoPlayer playback thread
instead of the app thread that added the listener.

PiperOrigin-RevId: 492474405
(cherry picked from commit f3fc4fb9735a4b67a3740b3796495017eb5c978c)

* Add javadoc links to README files

Fix some other link titles and destinations spotted along the way.

#minor-release

PiperOrigin-RevId: 493276172
(cherry picked from commit c006575d4306f9bfad9c6f27d964fab00a6e1718)

* Support release in SimpleBasePlayer

This adds support for the release handling. To align with the
established behavior in ExoPlayer, the player can only call
listeners from within the release methods (and not afterwards)
and automatically enforces an IDLE state (without listener call)
in case getters of the player are used after release.

PiperOrigin-RevId: 493543958
(cherry picked from commit 3a66c28d4f0fc6bbd7af3f5846a5645aa3ccf778)

* Replace MediaMetadata folderType by isBrowsable

The folder type has a mix of information about the item. It shows
whether the item is browsable (type != FOLDER_TYPE_NONE) and
which Bluetooth folder type to set for legacy session information.

It's a lot clearer to split this into a boolean isBrowsable and
use the existing mediaType to map back to the bluetooth folder type
where required.

folderType is not marked as deprecated yet as this would be an API
change, which will be done later.

PiperOrigin-RevId: 493544589
(cherry picked from commit 9d059352cff0a75f0f9c4e37010bbfa2fc6079fd)

* Remove debug timeout multiplier.

It looks like this was added accidentally in <unknown commit>.

PiperOrigin-RevId: 493834134
(cherry picked from commit f8e4e1765f3bc956e1e6e9eb17d72cb6c152282c)

* Clarify and correct allowed multi-threading for some Player methods

Some Player methods like getting the Looper and adding listeners
were always allowed to be called from any thread, but this is
undocumented. This change makes the threading rules of these
methods more explicit.

Removing listeners was never meant to be called from another thread
and we also don't support it safely because final callbacks may
be triggered from the wrong thread. To find potential issues, we
can assert the correct thread when releasing listeners.

Finally, there is a potential race condition when calling addListener
from a different thread at the same time as release, which may lead to
a registered listener that could receive callbacks after the player is
released.

PiperOrigin-RevId: 493843981
(cherry picked from commit e9364b0f6e1a104de9cf4393daab521edc4eccf4)

* Forward seek command details to seekTo method in BasePlayer

BasePlayer simplifies implementations by handling all the various
seek methods and forwarding to a single method that can then be
implemented by subclasses. However, this loses the information about
the concrete entry point used for seeking, which is relevant when
the subclass wants to verify or filter by Player.Command. This
can be improved by adding the command as a new parameter. Since
we have to change the method anyway, we can also incorporate the
boolean flag about whether the current item is repeated to avoid
the separate method.

PiperOrigin-RevId: 494948094
(cherry picked from commit 6e0f1f10b3666e6c2c74fc5a154dec3f0e03fecb)

* Reset isLoading when calling SimpleBasePlayer.stop/release

isLoading is not allowed to be true when IDLE, so we have to set to
false when stopping in case it was set to true before.

PiperOrigin-RevId: 494975405
(cherry picked from commit e4f0b73aa325d096b493bd646c63bc6a4bf5880b)

* Document the reason for defining private method `defaultIfNull`

PiperOrigin-RevId: 495004732
(cherry picked from commit c3ca71fda738772dccc5a5e07293c884d2194f0a)

* Remove parameters with default values from bundle in `MediaItem`

This improves the time taken to construct PlayerInfo from bundle from ~600ms to ~450ms.

PiperOrigin-RevId: 495055355
(cherry picked from commit 7de47fe2a1493da1b0720ddeb357052d2b1dc5bb)

* Clear one-off events from state as soon as they are triggered.

This ensures they are not accidentally triggered again when
the state is rebuilt with a buildUpon method.

PiperOrigin-RevId: 495280711
(cherry picked from commit fa5aaf958d616d831d50fdaceb02d3ff3cbad0fa)

* Allow unset index and position values + remove period index

This simplifies some position tracking needs for an app implementing
SimpleBasePlayer.
 - The period index can always be derived from the media item index
   and the position. So there is no need to set it separately.
 - The media item index can be left unset in the State in case the app
   doesn't care about the value or wants to set it the default start
   index (e.g. while the playlist is still empty where UNSET is
   different from zero).
 - Similarly, we should allow to set the content position (and buffered
   position) to C.TIME_UNSET to let the app ignore it or indicate the
   default position explictly.

PiperOrigin-RevId: 495352633
(cherry picked from commit 91557ac9d4eaf83e68f563373541dc8e12043e00)

* Remove parameters with `null` values from bundle in `MediaMetadata`

Improves the time taken to construct `playerInfo` from its bundle from ~450 ms to ~400 ms. Each `MediaItem` inside `Timeline.Window` contains `MediaMetadata` and hence is a good candidate for bundling optimisations. There already exists a test to check all parameters for null values when unset.

PiperOrigin-RevId: 495614719
(cherry picked from commit 8dea624c980ff65aece63c6aeecdeef894470231)

* Use theme when loading drawables on API 21+

Issue: androidx/media#220
PiperOrigin-RevId: 495642588
(cherry picked from commit 33f8f406929c739e98bbea475b3609beb7db2b5f)

* Rename `EMPTY_MEDIA_ITEM` to `PLACEHOLDER_MEDIA_ITEM`

The `MediaItem` instances in the following cases are not actually empty but acts as a placeholder. `EMPTY_MEDIA_ITEM` can also be confused with `MediaItem.EMPTY`.

PiperOrigin-RevId: 495843012
(cherry picked from commit 74559b4a188e476378f3f0df908598ce763d909a)

* Clarify behavior for out-of-bounds indices and align implementations

Some Player methods operate relative to existing indices in the
playlist (add,remove,move,seek). As these operations may be issued
from a place with a stale playlist (e.g. a controller that sends
a command while the playlist is changing), we have to handle out-
of-bounds indices gracefully. In most cases this is already
documented and implemented correctly. However, some cases are not
documented and the existing player implementations don't handle
these cases consistently (or in some cases not even correctly).

PiperOrigin-RevId: 495856295
(cherry picked from commit a1c0b10482baffc3721561446ee4bb788d8a1231)

* Check if codec still exists before handling tunneling events

The tunneling callbacks are sent via Handler messages and may be
handled after the codec/surface was changed or released.

We already guard against the codec/surface change condition by
creating a new listener and verifying that the current callback
happens for the correct listener instance, but we don't guard
against a released codec yet.

PiperOrigin-RevId: 495882353
(cherry picked from commit 5e23b8bfd5a9a9542c2ab8d23ae51c1689d8ff51)

* Add playlist and seek operations to SimpleBasePlayer

These are the remaining setter operations. They all share the same
logic that handles playlist and/or position changes. The logic to
create the placeholder state is mostly copied from ExoPlayerImpl's
maskTimelineAndPosition and getPeriodPositonUsAfterTimelineChanged.

PiperOrigin-RevId: 496364712
(cherry picked from commit 09d37641d1ef3b8cf26dc39cfcd317ebe3ef5c79)

* Remove ellipsis from Player javadoc

PiperOrigin-RevId: 496377192
(cherry picked from commit 844428ea329754118b8c0a2d58373415f539d725)

* Fix Dackka error due to param name mismatch

https://developer.android.com/reference/androidx/leanback/media/PlayerAdapter#seekTo(long)

#minor-release

PiperOrigin-RevId: 496378709
(cherry picked from commit d2a3d8f6fabb6d22ac28a76379725d0915344cba)

* Clarify some Player command and method javadoc

#minor-release

PiperOrigin-RevId: 496661152
(cherry picked from commit f47ad3c2d097a557bd2222a5b104e7867aef585d)

* Document the relationship between Player methods and available commands

#minor-release

PiperOrigin-RevId: 496668378
(cherry picked from commit 54e79689e925a2a18bc02522d4f7f73dcfb35d83)

* Add error messages to correctness assertions in SimpleBasePlayer

Users of this class may run into these assertions when creating the
State and they need to check the source code to understand why
the State is invalid. Adding error messages to all our correctness
assertions helps to understand the root cause more easily.

PiperOrigin-RevId: 496875109
(cherry picked from commit b7e887a58dff7615926f8002ee3210b3071c5537)

* Fix recursive loop when registering controller visibility listeners

There are two overloads of this method due to a type 'rename' from
`PlayerControlView.VisibilityListener` to
`PlayerView.ControllerVisibilityListener`. Currently when you call one
overload it passes `null` to the other one (to clear the other listener).
Unfortunately this results in it clearing itself, because it receives
a null call back!

This change tweaks the documentation to clarify that the 'other'
listener is only cleared if you pass a non-null listener in. This solves
the recursive problem, and allows the 'legacy' visibility listener to be
successfully registered.

Issue: androidx/media#229

#minor-release

PiperOrigin-RevId: 496876397
(cherry picked from commit 37fd65a8e51ddba92584109217114d9f2c2f009d)

* Update migration script

Issue: google/ExoPlayer#10854
PiperOrigin-RevId: 496922055
(cherry picked from commit 8e9f83867b5c9536488cf74f06c4cf2535ef848f)

* Bump IMA SDK version to 3.29.0

Issue: google/ExoPlayer#10845
PiperOrigin-RevId: 496947392
(cherry picked from commit 8ed515880a0b6c05b766e868e2ef931b886925cc)

* Check `MediaMetadata` bundle to verify keys are skipped

Added another check in test to make sure we don't add keys to bundle for fields with `null` values.

PiperOrigin-RevId: 496948705
(cherry picked from commit 890fd0a9fb135e938dc465d936b24065c65dbb98)

* Optimise bundling for `AdPlaybackState` using `AdPlaybackState.NONE`

Did not do this optimisation for `AdPlaybackState.AdGroup` as its length is zero for `AdPlaybackState` with no ads.

No need to pass default values while fetching keys, which we always set in `AdPlaybackState.AdGroup.toBundle()`.

PiperOrigin-RevId: 496995048
(cherry picked from commit f2eac2df711cad579f3042568a24c1f51a119428)

* Fix order of playback controls in RTL layout

Issue: androidx/media#227

#minor-release

PiperOrigin-RevId: 497159283
(cherry picked from commit 8313af1677507fb0cc51d53e81bf930f1a954c87)

* Enable RTL support in the demo app

We might as well keep this enabled by default, rather than having to
manually toggle it on to investigate RTL issues like Issue: androidx/media#227.

PiperOrigin-RevId: 497159744
(cherry picked from commit 010c6b96e74979370f139f8126c176ea7b279313)

* Remove player listener on the application thread of the player

PiperOrigin-RevId: 497183220
(cherry picked from commit 965606f7a7626b95087845191f9b6d4c33ced2e7)

* Check bundles in `MediaItem` to verify keys are skipped

Added another check in each of these tests to make sure we don't add keys to bundle for fields with default values.

Also fixed comments of similar changes in `AdPlaybackStateTest` and `MediaMetadataTest`.

PiperOrigin-RevId: 499463581
(cherry picked from commit 9d431a52ef7a39772f65b8de170a225848be5251)

* Optimise bundling for `Timeline.Window` and `Timeline.Period`

Improves the time taken to construct playerInfo from its bundle from ~400 ms to ~300 ms.

Also made `Timeline.Window.toBundle(boolean excludeMediaItem)` public as it was required to assert a condition in tests.

PiperOrigin-RevId: 499512353
(cherry picked from commit 2a77f1e2f96684c8c2e0b27e4118635af0724811)

* Throw a ParserException instead of a NullPointerException if the sample table (stbl) is missing a required sample description (stsd).

As per the javadoc for AtomParsers.parseTrack, ParserException should be "thrown if the trak atom can't be parsed."

PiperOrigin-RevId: 499522748
(cherry picked from commit bbe78b10c125529d039fea9bf0117cc04d2a3532)

* Fix typo in `DefaultTrackSelector.Parameters` field

PiperOrigin-RevId: 499905136
(cherry picked from commit bdd6818c14f97ba305d008c963fd2c369fab312c)

* Initialise fields used for bundling as String directly

Initialising the fields as Integer and then getting a String on compute
time is slow. Instead we directly initialise these fields as String.
Improves the time taken in bundling PlayerInfo further to less than
200ms from ~300ms.

Also modified a test to improve productive coverage.

PiperOrigin-RevId: 500003935
(cherry picked from commit d49437c6e112e60e9c85edeef73a73bce7de939a)

* Update bandwidth meter estimates

PiperOrigin-RevId: 501010994
(cherry picked from commit 09a15fb73103c406965856de4d120a5028bb37b5)

* Add focusSkipButtonWhenAvailable to focus UI on ATV

For TV devices the skip button needs to have the focus to be accessible with
the remote control. This property makes this configurable while being set to
true by default.

PiperOrigin-RevId: 501077608
(cherry picked from commit d2898b70ead3b2ad1244a730c3b456146755c138)

* Request notification permission in demo app for API 33+

Starting with API 33 the POST_NOTIFICATION permission needs to be
requested at runtime or the notification is not shown.

Note that with an app with targetSdkVersion < 33
but on a device with API 33 the notification permission is automatically
requested when the app starts for the first time. If the user does not
grant the permission, requesting the permission at runtime result in
an empty array of grant results.

Issue: google/ExoPlayer#10884
PiperOrigin-RevId: 501320632
(cherry picked from commit 6bacbaac548d612e85647b4d13c22dae0401447e)

* Document that `DownloadService` needs notification permissions

Starting with Android 13 (API 33) an app needs to request the
permission to post notifications or notifications are suppressed.
This change documents this in the class level JavaDoc of the
`DownloadService`.

Issue: google/ExoPlayer#10884
PiperOrigin-RevId: 501346908
(cherry picked from c…
@androidx androidx locked and limited conversation to collaborators Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants