936 Commits

Author SHA1 Message Date
claincly
efb7bf2fc2 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)
2022-10-07 17:29:15 +00:00
huangdarwin
15e316da3f 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)
2022-10-07 13:57:06 +00:00
claincly
808180455a 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)
2022-10-06 18:30:14 +00:00
tonihei
e37f16a749 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)
2022-10-05 15:03:16 +00:00
claincly
92ceeda5b8 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)
2022-10-05 14:45:27 +00:00
huangdarwin
fdd72aed5a 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)
2022-09-30 13:24:26 +00:00
leonwind
0a1f30aba5 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)
2022-09-23 16:19:43 +00:00
bachinger
b47c7a37ac Add withAvailableAd for server side inserted ad groups
#minor-release

PiperOrigin-RevId: 472714732
(cherry picked from commit 072f376b4839b6d4e71bcd09366695b3b9fc2c02)
2022-09-07 14:01:26 +00:00
bachinger
d7d75a0157 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)
2022-09-06 17:40:52 +00:00
Googler
ba01d04ed5 Add @SuppressWarnings to nullness errors detected by a newer version of the Checker Framework
PiperOrigin-RevId: 471137219
(cherry picked from commit 90e684a6dcd5d92470780060feb2099c2f905bbd)
2022-08-31 01:09:09 +00:00
huangdarwin
53b1cabef8 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)
2022-08-30 18:01:11 +00:00
huangdarwin
c827c80b22 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)
2022-08-24 15:44:22 +00:00
Googler
5bdb165943 Reassign TODO to new bug.
PiperOrigin-RevId: 468672505
(cherry picked from commit 010ecec89dcaf74d9536f92a5b99152d99816dfa)
2022-08-19 11:30:19 +00:00
Googler
60d3e8e26b 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)
2022-08-19 09:47:28 +00:00
Googler
884e37633e 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)
2022-08-18 16:10:48 +00:00
tonihei
d5710d3171 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)
2022-08-16 16:27:56 +00:00
tonihei
d2000fd25f 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)
2022-08-15 08:54:27 +00:00
huangdarwin
c0bef3dbf7 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)
2022-08-09 11:28:31 +00:00
huangdarwin
2503c0ee95 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)
2022-08-08 16:55:22 +00:00
hmzh
fb85488d75 Add a custom MIME type for MIDI
PiperOrigin-RevId: 466032455
(cherry picked from commit 3aa99d5efbd87a410dd8177539e54185c6b17176)
2022-08-08 14:02:08 +00:00
andrewlewis
dce7c45cf0 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)
2022-08-03 16:06:45 +00:00
Googler
ff35958c54 Clean up FrameProcessor TODOs.
PiperOrigin-RevId: 465044342
(cherry picked from commit 245326a0433c82bf851e2fa556bb8399cf1ba2d6)
2022-08-03 13:53:53 +00:00
huangdarwin
153535a300 HDR: Have @C.ColorTransfer check consider NO_VALUE as SDR.
Format.NO_VALUE is a placeholder value for an invalid @C.ColorTransfer, used
for example when the decoder doesn't support this transfer function.

When encountering this invalid value, interpret this as COLOR_TRANSFER_SDR.

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

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

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

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

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

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

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

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

#minor-release

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

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

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

PiperOrigin-RevId: 460424154
(cherry picked from commit 413016f7efea9dbb1194558374d9b9a8777a0d8c)
2022-07-12 11:04:05 +00:00
rohks
bbb5cfb323 Add missing imports in Metadata
PiperOrigin-RevId: 459533055
(cherry picked from commit 320dcadfec6b9c7681b32255917f23ed0f62008c)
2022-07-07 16:36:59 +00:00
huangdarwin
c8b0e5e89b HDR: Remove ColorInfo.SDR constant
The SDR constant also specified a color space and range, in addition to
C.COLOR_TRANSFER_SDR. However, it turns out that SDR videos may use different color
space and range values, so following prior ExoPlayer conventions to have `null`
mean "generic SDR" is preferable here.

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

PiperOrigin-RevId: 459211106
(cherry picked from commit 77d353b58be1e23de9eea505c6b0e7a46d4e4d0b)
2022-07-06 10:25:30 +00:00
huangdarwin
065c12caf4 HDR: Remove unused EGL_GL_COLORSPACE_KHR attribute.
PiperOrigin-RevId: 459106221
(cherry picked from commit bbbb009608c9b2fa951d664f4e2478c2cac61459)
2022-07-05 18:47:29 +00:00
hschlueter
67439206f1 Fallback to SDR if encoder doesn't support HDR (HLG only).
If the input is HDR (HLG), check encoder capabilities for HDR support
and request tone-mapping to SDR during decoder configuration otherwise.
Capabilities are only checked for API 31 and above, as HDR editing is
not supported before.

As the encoder capabilities check needs to happen before selecting the
encoder to use (as this may depend on the resolution output by the
effects chain), the EncoderWrapper checks all candidate encoders
for the MIME type for HDR capabilities and only requests fallback to
SDR if none of them support it.

When the actual encoder is selected, the wrapper checks that it matches
one of the encoders is checked capabilities for.

PiperOrigin-RevId: 458511599
(cherry picked from commit 474e2f2c77cad4759645ec3320f756757c0882db)
2022-07-01 18:34:02 +00:00
huangdarwin
39047b5676 HDR: Configure GL shaders and encoder.
Configure the GL shaders and encoder to take in HDR metadata.

This mostly just consists of passing the Format.colorInfo through
the VideoTranscodingSamplePipeline down to the encoder, rather than passing
the PQ-ness down to the GL step.

Due to b/237674316, this will remove HDR10+ support temporarily to introduce
support for HLG10.

Manually tested to confirm that HLG10 operations that don't affect color display
correctly after this CL with "HDR editing" in the demo checked, and continue to display incorrectly (as before this CL) without the option unchecked.

PiperOrigin-RevId: 458490810
(cherry picked from commit 53db305612a84466b6712cc355dbf918424a968d)
2022-07-01 16:57:43 +00:00
rohks
76310ad40c Add timestamp to Metadata
`MetadataRenderer` is updated to output `Metadata` with its presentation time, in microseconds.

PiperOrigin-RevId: 457444718
(cherry picked from commit 6e9275c13d7c6e0fc8b6568662929c186395a33a)
2022-06-27 11:31:10 +00:00
rohks
1bc316dee1 Add timestamp to CueGroup
`TextRenderer` is updated to output `CueGroup`, which contains the presentation time of the cues, in microseconds.

PiperOrigin-RevId: 456531399
(cherry picked from commit bf11a8a83148f0d68c82cf22a5f978b1e6a5e299)
2022-06-22 17:19:55 +01:00
olly
54f72e733f Don't export broadcast receivers that don't require it
Issue: google/ExoPlayer#10287
PiperOrigin-RevId: 455131138
(cherry picked from commit 9267ba3f9e14da4436bfbfe76045f7d09af80feb)
2022-06-15 15:00:47 +00:00
olly
dc22f62ffb Suppress an ExtendsObjects violation
to support enabling this as a compile-time error.

More information: go/lsc-extends-object

PiperOrigin-RevId: 454582570
(cherry picked from commit d2f5f212b909fcbd81a48d84d805005724e5303e)
2022-06-13 12:34:43 +00:00
hschlueter
ddd8f4174f Combine all native GL errors in a GlException instead of logging.
The native GL errors are in an arbitrary order according to
https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glGetError.xml
This means any of them could contain the most useful message
so it's better to use all for the GlException's message rather than
picking the last message and logging all others.

PiperOrigin-RevId: 454130460
(cherry picked from commit 92c2a304e10d0da968cf341080de47566ce551ed)
2022-06-10 11:03:38 +00:00
hschlueter
9ecf722824 Make GlUtil.GlException checked and remove flag to disable it.
Transformer always enabled glAssertionsEnabled, so there should
be no functional change.

ExoPlayer previously disabled glAssertionsEnabled, so GlUtil logged
GlExceptions instead of throwing them. The GlExceptions are now
caught and logged by the callers so that there should also be no
functional change overall.

This change also replaces EGLSurfaceTexture#GlException with
GlUtil#GlException.

PiperOrigin-RevId: 453963741
(cherry picked from commit dc668f2b59bb0df12cdbb77cb88072babe0218eb)
2022-06-09 17:53:39 +00:00
hschlueter
df6c8f1d8a Implement default GlTextureProcessor in SingleFrameGlTextureProcessor.
SingleFrameGlTextureProcessor is now an abstract class containing a
default implementation of the more flexible GlTextureProcessor interface
while still exposing the same simple abstract methods for single frame
processing it previously did.

FrameProcessorChain and GlEffect will be changed to use
GlTextureProcessor in follow-ups.

PiperOrigin-RevId: 453633000
(cherry picked from commit 0b37d860d13df1ac638f5a75c7af32c840e02956)
2022-06-08 09:44:25 +00:00
rohks
064bbbff41 Version bump to exoplayer:2.18.1 and media3:1.0.0-beta02
#minor-release

PiperOrigin-RevId: 461162552
(cherry picked from commit 6d27ff862b0e8bc99b43dcc59c1d99760f1b0946)
2022-07-15 10:37:41 +00:00
Rohit Singh
77a3b16d6b Merge pull request #10185 from TiVo:p-custom-logger
PiperOrigin-RevId: 460689252
(cherry picked from commit 60437397f4984b5a5c64490fe88aa210d6547ce6)
2022-07-13 18:11:52 +00:00
ibaker
4b684b59d3 Group COMMAND_SET_MEDIA_ITEM and COMMAND_CHANGE_MEDIA_ITEMS together
I don't think it's useful to keep these in numerical order, it makes
more sense to keep them grouped into a 'logical' ordering.

#minor-release

PiperOrigin-RevId: 460453464
(cherry picked from commit 1b1e0f890da4de6055491730595f72afdde0811a)
2022-07-12 14:06:27 +00:00
Rohit Singh
ef96641558 Merge pull request #10260 from sr1990:clearkey_parse_licenseurl
PiperOrigin-RevId: 459215225
(cherry picked from commit 9521807681840f530ed4af17c4ab5c68dedaa13e)
2022-07-07 18:12:15 +00:00
ibaker
d3b5f71f25 Consider shuffle order in Timeline.equals()
Previously two timelines that differed only in shuffle order were
considered equal, which resulted in no call to
Player.Listener.onTimelineChanged when calling
ExoPlayer.setShuffleOrder. This in turn resulted in no call to
MediaControllerCompat.Callback.onQueueChanged.

Also make a small fix inside ExoPlayerImpl.setShuffleOrder, to ensure
that the new shuffle order is used when constructing the masked
timeline.

Issue: google/ExoPlayer#9889
#minor-release
PiperOrigin-RevId: 457703727
(cherry picked from commit 5c7ec13e85d32bdb464082069d462c740bc7cd55)
2022-06-28 12:15:54 +00:00