14882 Commits

Author SHA1 Message Date
tonihei
481205a88f Use Futures for MediaSession command queue instead of Runnables
Some commands may be asynchronous and subsequent commands need to
wait for them to complete before running. This change updates the
queue to use (and listen to) Futures instead of calling Runnables
directly. The commands are currently still added as Runanbles
though, so this change is a no-op.

Also moves the permission check in MediaSessionImpl to before
queueing the command because the permission should be check at
the time of calling the method.

When executing the comamnds in the queue, we need to be careful
to avoid recursion in the same thread (which happens when both
the Future is immediate and running on the correct thread already).
To avoid recursion, we detect this case and loop the commands
instead.

Issue: androidx/media#85
PiperOrigin-RevId: 461827264
(cherry picked from commit dee80788e4fc5e82739ae014a5d2759b77f03daa)
2022-07-19 08:59:30 +00:00
huangdarwin
54cdec4614 HDR: Use FP16 color representation for texture processors.
* Introduced `useHdr` for `GlEffect#toGlTextureProcessor`, so
  `TextureProcessor` implementations can decide how to handle HDR.
* Creating FP16 color textures for HDR input.

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

PiperOrigin-RevId: 461613117
(cherry picked from commit ba9c9bb96471a9589d391ae498ebb0c194a5b41e)
2022-07-18 14:21:17 +00:00
huangdarwin
add44470cf HDR: Throw when unexpected color transfer encountered.
This may happen when a containers' color transfer incorrectly does not match
the video's color transfer.

An example of a file with such a mismatch is the current Transformer demo HDR10
sample file.

Manually tested by confirming that no errors are emitted for SDR and HLG sample
files, and that errors are emitted for our incorrect HDR10 sample file.

PiperOrigin-RevId: 461583532
(cherry picked from commit 9f7a159bc4c8a82653fdbb6d62e4f79b020cff06)
2022-07-18 11:20:31 +00:00
bachinger
24bfe3a5e0 Implement getCurrentTracks in MediaController
After this change the current tracks are sent to the controller as part of
`PlayerInfo` and call `Listener.onTracksChanged()` in case of a change in tracks.

PiperOrigin-RevId: 461578695
(cherry picked from commit 9a895cd18f020a4f9df24c142406e91507a76605)
2022-07-18 10:47:57 +00:00
bachinger
db25954dfd Use the current overrides of the player as preset
Issue: google/ExoPlayer#10429
PiperOrigin-RevId: 461577039
(cherry picked from commit 5c2aabca660e7618ebe410d8ab7de95acc76ee1a)
2022-07-18 10:36:01 +00:00
andrewlewis
04fa2fda2a Make minor fixes to HDR handling
- Update profile selection logic to pick an HDR-compatible profile when doing HDR editing on H.264/AVC videos.
- Handle doing the capabilities check for all MIME types that support HDR (not just H.265/HEVC).
- Fix a bug where we would pass an HDR input color format to the encoder when using tone-mapping.
- Tweak how `EncoderWrapper` works so decisions at made at construction time.

Manually tested cases:
- Transformation of an SDR video.
- Transformation of an HDR video to AVC (which triggers fallback/tone-mapping on a device that doesn't support HDR editing for AVC).
- Transformation of an HDR video with HDR editing.

PiperOrigin-RevId: 461572973
(cherry picked from commit 604ab7fcdaa759025536feb673a3abb93196a829)
2022-07-18 10:09:35 +00:00
andrewlewis
c4e64c3d0d Update demo HDR10 video URL
The old URL doesn't correctly signal the HDR10 color info in the container.

The new URL signals ST2084 (PQ) transfer function and BT.2020 color space as expected.

PiperOrigin-RevId: 461560107
(cherry picked from commit 794e366b3661e9dfec01abcbd4598a26bec9e235)
2022-07-18 08:51:54 +00:00
olly
6eb30ce233 Add TODOs for registerReceiver calls without flag
PiperOrigin-RevId: 461165173
(cherry picked from commit 9271572e950230a24da69a6ec5838dd838ea672d)
2022-07-15 10:34:53 +00:00
samrobinson
ac2a5e56b0 Add additional video files.
These are providing more variety and complexity.

All files are okay to be public.

PiperOrigin-RevId: 460935247
(cherry picked from commit b87fa45fea56a50b5c035c7ca18eaf19697e60bf)
2022-07-14 12:27:05 +00:00
hschlueter
4e92c4260a Use COLOR_Format32bitABGR2101010 for HDR encoder configuration.
Also remove VideoEncoderSettings.colorProfile as there are no
concrete use cases for customizing this and it clashes with picking
the color format automatically based on SDR vs. HDR.

PiperOrigin-RevId: 460746987
(cherry picked from commit 7954eeb3c2fa274d9343cbf51963a3cccf3270c7)
2022-07-13 17:20:33 +00:00
tonihei
45f1473dcd Use SingleThreadExecutor to release AudioTracks
We currently start a simple Thread to release AudioTracks
asynchronously. If many AudioTracks are released at the same
time, this may lead to OOM situations because we attempt to
create multiple new threads.

This can be improved by using a shared SingleThreadExecutor.
In the simple case of one simmultaneous release, it's exactly
the same behavior as before: create a thread and release it
as soon as it's done. For multiple simultanous releases we
get the advantage of sharing a single thread to avoid creating
more than one at the same time.

Issue: google/ExoPlayer#10057
PiperOrigin-RevId: 460698942
(cherry picked from commit 9a616c0cee447b7bd809c0dfc4c9d864fc9fee56)
2022-07-13 13:24:04 +00:00
samrobinson
00aea7519b Fix assertion error when using high quality targeting API.
Add test that verifies SSIM with API enabled.

#minor-release

PiperOrigin-RevId: 460692420
(cherry picked from commit f903869eb880508812c0dc2e1a8b01ecf0597f45)
2022-07-13 12:48:02 +00:00
samrobinson
9ae0f6c5c1 Clarify format is supported by encoder.
#cleanup
#minor-release

PiperOrigin-RevId: 460688226
(cherry picked from commit a88426ae58dc2ce31e1c4c0b7838f5e464107dcd)
2022-07-13 12:16:59 +00:00
claincly
8f79af8155 Fix two typos in RtpVp8Reader and test
PiperOrigin-RevId: 460662425
(cherry picked from commit 40fd3ffa6c3ea058e58e59b533fcaadb377c94d2)
2022-07-13 09:27:06 +00:00
claincly
4655b7b8f7 Fix a mis-match in encoder priority.
PiperOrigin-RevId: 460500666
(cherry picked from commit e56219f1f6ba4d3d3b7e579ba48c6a661761ee3f)
2022-07-12 17:43:55 +00:00
rohks
396b55a341 Ignore reserved bit in parsing NAL unit type
`HevcConfig.parse` misreads reserved bit to determine NAL unit type. This is currently meant to be always set to 0, but could be given some kind of meaning in a future revision.

Issue: google/ExoPlayer#10366
PiperOrigin-RevId: 460487613
(cherry picked from commit 704aa2531adac1a73cc284baa1a2f5e22f0c2a0b)
2022-07-12 16:53:03 +00:00
tonihei
95fcaf0742 Add method to check if tunneling is enabled.
Issue: google/ExoPlayer#2518
PiperOrigin-RevId: 460482615
(cherry picked from commit 549496f1fa308fc229f539823573610bc0d06871)
2022-07-12 16:31:38 +00:00
tonihei
570208d576 Fix DefaultAudioSinkTest flakiness.
Some calls to handleBuffer return false while a previous
flush is still handled in the background.

Fix this by either asserting the method returns true if
we don't expect any delay, or calling it repeatedly until
it returns true (within a timeout).

PiperOrigin-RevId: 460474419
(cherry picked from commit 223922fb11f9af7510364f212939f1af65c3b5af)
2022-07-12 15:54:18 +00:00
claincly
414be2ef5b Verified encoding performance, removing TODO.
PiperOrigin-RevId: 460459378
(cherry picked from commit 776c8a5544357bed1c92399f3ab47fc245c0b878)
2022-07-12 14:41:02 +00:00
hschlueter
2ea90e7abd Set ColorInfo in decoder configuration format.
Pass the color info and HDR static metadata when configuring the decoder
using MediaFormatUtil.maybeSetColorInfo.

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

PiperOrigin-RevId: 460424154
(cherry picked from commit a5ff4ef17f78b64735d82c6b16f0b69af5a570a3)
2022-07-12 11:04:05 +00:00
hschlueter
04ca9a2d38 Merge MatrixTransformationProcessor and ExternalTextureProcessor.
This saves an intermediate texture copy step for use-cases
where matrix transformations are the first or only effects
in the chain.

PiperOrigin-RevId: 460239403
(cherry picked from commit 7dc54efdb9c751aff14660fca38889ba2007e4d5)
2022-07-11 17:04:11 +00:00
claincly
627f26adef Apply priority/operating rate settings for video encoding.
- Added setter to disable this feature.
- Added accompanying tests.
- Plan to run tests on the same set of settings on H265.

PiperOrigin-RevId: 460238673
(cherry picked from commit 18f4068c06a27ceedce8ee951b3832235a96f75e)
2022-07-11 17:01:33 +00:00
samrobinson
65d653c577 Move Encoder quality API to VideoEncoderSettings.
Some other minor nits and adjustments to the API logic.

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

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

PiperOrigin-RevId: 459211106
(cherry picked from commit ab7747d9533c0ed1c5d096743741607b0e08c609)
2022-07-06 10:25:30 +00:00
huangdarwin
5ab53d3dc1 HDR: Remove unused EGL_GL_COLORSPACE_KHR attribute.
PiperOrigin-RevId: 459106221
(cherry picked from commit 1869855c90f67e8735f3a58361e36db2c421f838)
2022-07-05 18:47:29 +00:00
samrobinson
ebf1ae49b7 Implement device based encoder bitrate mapping.
This feature is disabled by default for now.

PiperOrigin-RevId: 458932471
(cherry picked from commit 7d2eb7601947570245dcd2ff86b7dcf1c8393d40)
2022-07-04 17:32:27 +00:00
hschlueter
3bdecf2ac9 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 9c8dcb402b45620174ae6be2d943ff8f32e4da14)
2022-07-01 18:34:02 +00:00
huangdarwin
28cf112e01 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 a0870a42be5336b313f79f596e94411563e14720)
2022-07-01 16:57:43 +00:00
claincly
379ecd198f Fix error in frame rate handling.
The old getString() will throw because FRAME_RATE can only be float or int.

PiperOrigin-RevId: 458481251
(cherry picked from commit deea5c927a61da5a84c534b485ad8a249d10cbd6)
2022-07-01 16:05:39 +00:00
claincly
e0752a3a7a Find only REGULAR_CODECS in EncoderUtil.
We used "ALL_COOECS" previously, and it is not necessary because "ALL_CODECS"
additionally the codecs that support tunneling/secure decoding, which there
is no use case in Transformer.

PiperOrigin-RevId: 458470278
(cherry picked from commit 3df4f3eb19aaa3486d2b3f8153be9167bd31027d)
2022-07-01 14:58:47 +00:00
claincly
f2b4701e92 Round the frame rate in MediaFormat
Although MediaCodec claims supporting float frame rate, encoder init failed on
API21 Nexus 5. Since it's just a performance hint to the codec, it's OK to
generalize it to other API versions.

PiperOrigin-RevId: 458434650
(cherry picked from commit 1f47fa832c6228a5545d8a15c9c09fe76c17dfc5)
2022-07-01 11:06:12 +00:00
hmzh
8b0fe16821 Fix MIDI command timestamp calculations and synthesization duration.
- Improve variable naming to include time units for clarity
- Fix existing timestamp calculations to respect time units as well as track tempo (default values for now)
- Ensure the synthesizer produces PCM for the correct amount of time (including gaps between commands).

PiperOrigin-RevId: 458428243
(cherry picked from commit da0a208b89a7914dae577900c990b0f36c23df14)
2022-07-01 10:18:50 +00:00
rohks
39d04cf2ac Fix formatting in release notes.
PiperOrigin-RevId: 458283415
(cherry picked from commit c0359cad927bc83e567c39a6107b17028d6cb7c1)
2022-06-30 19:10:22 +00:00
hschlueter
d48507a2d1 Move DebugViewProvider out of Transformer class.
The GlEffectsFrameProcessor that will be part of the effects module
uses the DebugViewProvider. So it does not make sense for it
to be an inner interface of Transformer.

PiperOrigin-RevId: 458014932
(cherry picked from commit cd0e5b99de9577ff1af0da15a9ea6c9041f38361)
2022-06-29 17:56:53 +00:00
hschlueter
1a1c6e94bb FrameProcessor: Replace SurfaceInfo.Provider with setter.
The FinalMatrixTransformationProcessorWrapper ensures that the
surface is only replaced when it is not being rendered to and vice
versa.

PiperOrigin-RevId: 458007639
(cherry picked from commit 234015cb952fbdaf274f1fa9005ddc0d2b4ba17a)
2022-06-29 17:27:05 +00:00
rohks
5ac982b9d0 Make MetadataRenderer configurable to output metadata early.
PiperOrigin-RevId: 457974611
(cherry picked from commit 621617f98103f67082e47bf585460d90c00ea32f)
2022-06-29 14:47:12 +00:00
hschlueter
129cfb6eeb Fix outputHeight pass-through condition.
The outputHeight in the TransformationRequest is the height of
the frame as it would be displayed (i.e., after applying any
rotation specified in the format). So pass-through should only
be used if the requested outputHeight matches the input
format's height after applying the rotation.

PiperOrigin-RevId: 457934867
(cherry picked from commit 87beb273e464d291423ccb4129c83f36195343f1)
2022-06-29 10:28:54 +00:00
hschlueter
c250d2d791 Allow changing input pixelWidthHeightRatio for GlEffectsFrameProcessor.
pixelWidthHeightRatio is now passed to setInputFrameInfo instead of
the factory.

PiperOrigin-RevId: 457696703
(cherry picked from commit b7b5f20e592bee772772eb1b009c7f5a96077520)
2022-06-28 11:22:45 +00:00
rohks
87d91ed19e Add timestamp to Metadata
`MetadataRenderer` is updated to output `Metadata` with its presentation time, in microseconds.

PiperOrigin-RevId: 457444718
(cherry picked from commit b2831d8559713b757feb3f15a2c828db0e5ecd7c)
2022-06-27 11:31:10 +00:00
hschlueter
864230fd11 Rename setVideoFrameEffects to setVideoEffects.
PiperOrigin-RevId: 457023382
(cherry picked from commit 4819b28587c41e75c716ba3fa84fa84a8934c78e)
2022-06-24 17:04:45 +01:00
hschlueter
928036523a Allow FrameProcessor input surface size changes.
This will be useful for downgrading to a lower resolution during
a slow preview and for processing slide-shows once sequential
multi-asset editing is supported.

PiperOrigin-RevId: 457017255
(cherry picked from commit 30c52c58f0772e43ca4e4639120d95f41ea8a9b5)
2022-06-24 16:31:31 +01:00
hschlueter
71f3ebb79c Extract FrameProcessor interface from GlEffectsFrameProcessor.
PiperOrigin-RevId: 456814150
(cherry picked from commit f3893c146d5e4521b84af45551ea5fda4d9c66bd)
2022-06-23 19:00:01 +01:00
hschlueter
4fc36bafdd Disable flaky transformer emulator test on API 31.
videoEncoderFormatUnsupported_completesWithError() has recently
been flaky on API 31 emulators on presubmit because a different
exception than the expected exception is thrown.
This disables it on those emulators to reduce testing noise
until the underlying problem is investigated and resolved.

PiperOrigin-RevId: 456765512
(cherry picked from commit 938d3c2e5b6f016f7075a3d2d162d37c1951d825)
2022-06-23 15:44:02 +01:00
hschlueter
498123da68 Rename FrameProcessorChain to GlEffectsFrameProcessor.
This change is just renaming. There is no functional change intended.
The FrameProcessor interface will be created in a follow-up.

PiperOrigin-RevId: 456741628
(cherry picked from commit 709224fb1ed3a1dab1433a5dc7fbb33a04eecaae)
2022-06-23 13:13:56 +01:00
samrobinson
90c904b089 Add a Builder for DefaultEncoderFactory.
PiperOrigin-RevId: 456728032
(cherry picked from commit 352967f65661296ff5551138fd6346fce0c52a3f)
2022-06-23 11:37:19 +01:00
rohks
49f4c9342d 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 74d61bbffb834cdb50d003a8de66af0e094ef702)
2022-06-22 17:19:55 +01:00
hschlueter
26ee3d32b2 Use GlTextureProcessor to avoid redundant copy in MediaPipeProcessor.
After this change GlEffects can use any GlTextureProcessor not just
SingleFrameGlTextureProcessor.
MediaPipeProcessor now implements GlTextureProcessor directly which
allows it to reuse MediaPipe's output texture for its output texture
and avoids an extra copy shader step.

PiperOrigin-RevId: 456530718
(cherry picked from commit 69ab79418ef21033ca25cebdf5a5e80752818ab5)
2022-06-22 17:16:54 +01:00
hschlueter
0007a47365 Support chaining async GlTextureProcessors in FrameProcessorChain.
After this change, FrameProcessorChain chains any GlTextureProcessors
instead of only SingleFrameGlTextureProcessors.

The GlTextureProcessors are chained in a bidirectional manner using
ChainingGlTextureProcessorListener to feed input and output related
events forward and release events backwards.

PiperOrigin-RevId: 456478414
(cherry picked from commit 555ab97e34d6586d38a9979bc0595a4818b7ecb8)
2022-06-22 12:03:41 +01:00