18909 Commits

Author SHA1 Message Date
huangdarwin
c122c0ca05 Compositor: Add support for multiple bitmaps, and add testrunner
* Allow more than one input bitmap at a time.
* Allow Compositor to take in and set up an Executor. Otherwise,
Compositor resources may be created on one thread and accessed on another.
* Add a Compositor TestRunner to reuse test code more.
* Update VideoFrameProcessingTaskExecutor to use a new onError listener, so
that it's more reusable in non-DVFP contexts, like for Compositor.

PiperOrigin-RevId: 547206053
2023-07-13 15:45:30 +01:00
samrobinson
4983d4f339 Switch argument order passed to scaleLargeTimestamp.
durationUs is almost always going to be a larger number than the sample
rate, so pass as the main value, rather than the multiplier.

PiperOrigin-RevId: 547193927
2023-07-13 15:44:15 +01:00
andrewlewis
fcadecf2b1 Add note recommending OpenGL tone-mapping
PiperOrigin-RevId: 547192957
2023-07-13 15:43:01 +01:00
tonihei
5c8b142174 Fix inconsistency in SampleQueue seek for sync-sample-only formats
For sync-sample-only formats, we have an optimization to drop all buffers
with less than the start time when writing them to the queue.

For the same formats, if we set a new start time (=seek), we only seek
to the buffer at or before the start time. This means the first sample
in the queue is different depending on whether we seek to a start time
or set a start time and then write samples. This is inconsistent and
effectively means the first sample depends on a race condition between
the Loader thread (writing samples) and the playback thread (attempting
an initial seek in the already loaded samples).

The effect of this inconsistency is that we have to decode one sample
we don't need (and could have skipped) and that some tests become flaky
if the test setup runs into the mentioned race condition.

The fix is to change the SampleQueue seek method to also seek to
a sample at or after the specified time, to align the behavior to the
case where we write the same samples to an empty queue.

The change also clarifies the Javadoc of
MimeTypes.allSamplesAreSyncSamples to note that this should really only
return true if the samples have no "duration" that matters. Otherwise,
we could reasonably return true for most subtitle formats although it
would break subtitle display because we'd remove samples that start
before the seek time.

PiperOrigin-RevId: 547189941
2023-07-13 15:41:49 +01:00
ibaker
9039621588 Update docs to allow CuesWithTiming.startTimeUs to be C.TIME_UNSET
This is needed for several subtitle formats where the `data` passed to
`SubtitleParser` doesn't contain any cue timing, such as PGS, CEA-608,
CEA-708, and DVB.

PiperOrigin-RevId: 547177127
2023-07-13 15:40:33 +01:00
andrewlewis
7df09fe4b7 Disable codec tone-mapping on Fold 4 API 33
The codec plugin sets crop values incorrectly.

PiperOrigin-RevId: 547160088
2023-07-13 15:39:21 +01:00
ibaker
2afcf99591 Expand @UnstableApi javadoc with how to request stable API additions
Issue: androidx/media#503

#minor-release

PiperOrigin-RevId: 547143885
2023-07-13 15:38:08 +01:00
andrewlewis
f657fa8048 Add utility for deleting sync object without throwing
PiperOrigin-RevId: 547138887
2023-07-13 15:37:02 +01:00
samrobinson
9b06da8174 Remove redundant assertion.
TransformerAndroidTestRunner#run will throw any exception that occurs,
so there is no need to assert the result exception is null.

PiperOrigin-RevId: 546923823
2023-07-13 15:35:50 +01:00
andrewlewis
22b7a7dc39 Tidy handling of package not found exception in demo
PiperOrigin-RevId: 546900066
2023-07-13 15:34:37 +01:00
tonihei
7441c1f083 Add more data to e2etest dumps
We currently only log the input buffers to the codec, but the test
will be more complete and provide more insights into the playback
behavior if we also dump more information about these input buffers
(timestamps and flags) and also all output buffers with their
timestamps and whether they are rendererd (only relevant for video).
And also use the CapturingAudioSink to output the audio data we produce.

PiperOrigin-RevId: 546898937
2023-07-13 15:33:33 +01:00
ibaker
eed0e42ff8 Remove javadoc @link from non-javadoc comments
Also update type names to match the current names for these types.

PiperOrigin-RevId: 546884049
2023-07-13 15:32:21 +01:00
andrewlewis
6f4ef51727 Add support for big endian 24/32-bit PCM
Also parse the PCM encoding for lpcm in MP4, and update `MatroskaExtractor`
similarly.

Tested manually in the demo app using an MP4 with 24-bit big endian audio.

PiperOrigin-RevId: 546878505
2023-07-13 15:31:14 +01:00
huangdarwin
7c9e6ad2ea Effect: Only allow setExecutorService with @NonNull values.
PiperOrigin-RevId: 546828814
2023-07-13 15:30:07 +01:00
tonihei
d6f20455ac ServerSideAdInsertionMediaSourceTest adjustments
Some adjustments to the test to make it more correct and prevent it
from becoming flaky:
 - Use separate output dump files per test setup. Once we add more data
   to these files, they are not guaranteed to be the same anymore.
 - Use a seek position that is actually behind the midroll as described
   in the test setup.
 - Change ad insertion position to ensure the ad group duration doesn't
   exceed the underlying media duration.
 - Add a wait for isLoading to ensure the late insertion of an ad group
   happens consistently at the same processing stage.

PiperOrigin-RevId: 546825183
2023-07-13 15:28:54 +01:00
claincly
ddd000128f Add an Input interface to SampleExporter.
PiperOrigin-RevId: 546822962
2023-07-13 15:27:40 +01:00
tonihei
3d4bd7ce19 Make MediaItems updateable
This changes all MediaSources in our library to allow updates to
their MediaItems (if supported).

Issue: google/ExoPlayer#9978
Issue: androidx/media#33
PiperOrigin-RevId: 546808812
2023-07-13 15:26:30 +01:00
ibaker
a8520bdee6 Clarify that new ConditionVariable instances are closed
#minor-release

PiperOrigin-RevId: 546803592
2023-07-13 15:25:15 +01:00
bachinger
175c64a07b Track controllers that don't await the connection
This removes some stack traces in unit tests when a
`RemoveMediaController` was created with `waitForConnection=false`
in which case the missing controller in the
`MediaControllerProviderService` caused a `NullPointerException`.

PiperOrigin-RevId: 546795181
2023-07-13 15:24:12 +01:00
claincly
9c74e78f33 Revert DefaultCodec to final
The class is made non-final for a test in 12584fbb20.

PiperOrigin-RevId: 546718462
2023-07-13 15:23:07 +01:00
jbibik
ca483a3c2c SubripParser implementation - moved from SubripDecoder
`SubripDecoder` which used to be `SimpleSubtitleDecoder` will now be called `SubripParser` and implement `SubtitleParser` interface. For backwards compatibility, we will have the same functionality provided by `DelegatingSubtitleDecoder` backed-up by a new `SubripParser` instance.

PiperOrigin-RevId: 546538113
2023-07-13 15:21:55 +01:00
jbibik
377d8edf9c SsaParser implementation - moved from SsaDecoder
`SsaDecoder` which used to be `SimpleSubtitleDecoder` will now be called `SsaParser` and implement `SubtitleParser` interface. For backwards compatibility, we will have the same functionality provided by `DelegatingSubtitleDecoder` backed-up by a new `SsaParser` instance.

PiperOrigin-RevId: 546336035
2023-07-13 15:20:34 +01:00
jbibik
e1e956cdf3 DelegatingSubtitleDecoder wrapper for SubtitleParser
`DelegatingSubtitleDecoder` is a `SimpleSubtitleDecoder` that delegates to a `SubtitleParser` instance (e.g. future implementations like `WebvttParser`, `SubripParser`, `SsaParser`, `DvbParser` etc)

It will be in the `exoplayer` package, rather than `extractor` and only be used in the decoding flow which happens after SampleQueue (and to be deprecated). When this decoding flow is deprecated and removed, the class can be later deleted.

PiperOrigin-RevId: 546317528
2023-07-13 15:19:18 +01:00
huangdarwin
cd0b45092e Test: Rename bitmap test method from Current to Focused GlFrameBuffer
Frame buffers are focused, not current. EGL Contexts may be current but this
is a prerequisite for focusing a framebuffer, and this alone isn't
sufficient to make a bitmap.

Clear this up as it can make some complex tests harder to understand, if the
methods needed don't match up in naming.

PiperOrigin-RevId: 546305118
2023-07-13 15:15:34 +01:00
andrewlewis
a0bc8d95c2 Improve texture asset loader documentation
Add documentation for threading requirements at the class level (in
addition to existing documentation on the methods) to improve
discoverablility. Also fix a couple of nits in the javadoc (US English
spelling, avoid passive voice) and in `OnInputFrameProcessedListener`.

PiperOrigin-RevId: 546303732
2023-07-13 15:14:21 +01:00
huangdarwin
4adb5d771e Effect: Remove obsolete TODO
PiperOrigin-RevId: 546285094
2023-07-13 15:13:02 +01:00
bachinger
a884186e58 Add android unit test for setting playback speed of a legacy session
PiperOrigin-RevId: 546282819
2023-07-13 15:11:57 +01:00
huangdarwin
0b7d9a945c GL: Log error for checkGlError when no gluErrorString is present.
Otherwise, errors like `GL_INVALID_FRAMEBUFFER_OPERATION` will only
report a `null` error string, instead of the proper error string.

PiperOrigin-RevId: 546273328
2023-07-13 15:10:48 +01:00
tonihei
d4c5414eff Use Clock in audio renderers and sinks
This makes tests more realistic because the returned value matches
the rest of the simulated test time.

It also prevents test flakiness in (yet to be written) tests that
may not correctly advance the playback time in the position tracker.

PiperOrigin-RevId: 546011842
2023-07-13 15:09:37 +01:00
tonihei
a9be9caf40 Ensure SampleQueue seek only happens if needed
When selecting progressive and HLS tracks, we currently check if
we can either seek in the existing samples or are starting from the
beginning of the stream. In both cases, we don't need to reload the
stream and can continue reading.

Seeking to the beginning isn't side-effect free though because it
also sets the startTimeUs to zero. Whether a seek to the beginning
is successful also depends on whether we already loaded a sample or
not. This mean that the startTimeUs value is set (or not set) based
on the speed of the Loader thread even for the same input starting
from the beginning. This race condition means the actual samples
we write to the stream may differ if the stream has initial samples
with negative timestamps.

We can avoid this race condition by checking if the queue is empty
first, so that we only call seekTo if really needed.

PiperOrigin-RevId: 546010951
2023-07-13 15:08:27 +01:00
andrewlewis
1ef7579f5c Fix stale javadoc
The method no longer returns anything. We don't need javadoc for this as it's
default visibility.

PiperOrigin-RevId: 545981702
2023-07-13 15:07:17 +01:00
claincly
50c6efe95d Rename SamplePipeline to SampleExporter
PiperOrigin-RevId: 545974776
2023-07-13 15:06:10 +01:00
huangdarwin
99a143a74e Transformer: Add 8k disabling workaround to avoid timeouts.
PiperOrigin-RevId: 545970477
2023-07-13 15:04:59 +01:00
andrewlewis
bdbf3e29a1 Fix incorrect class name for MediaPipe demo
Issue: androidx/media#500

#minor-release

PiperOrigin-RevId: 545942450
2023-07-13 15:03:46 +01:00
ibaker
06a791620e Update TODO link for shrinking workaround in DefaultExtractorsFactory
PiperOrigin-RevId: 545930708
2023-07-13 15:02:33 +01:00
tonihei
2250ffe6c8 Change multidex dependency type to androidTestImplementation
This is only needed for instrumentation tests and should not
be included in regular builds.

#minor-release

Issue: androidx/media#499
PiperOrigin-RevId: 545913113
2023-07-13 15:01:22 +01:00
claincly
372cd7f952 Remove unused constructor parameter
PiperOrigin-RevId: 545909062
2023-07-13 15:00:12 +01:00
tonihei
c6e7c54140 Release surface in e2etests
Robolectric writes warnings to the log output because the Surfaces
we create are not released and pollute the test environment. This
causes performance issues if tests are run repeatedly.

PiperOrigin-RevId: 545906757
2023-07-13 14:58:55 +01:00
tonihei
c66adfeaaf Add customization option to disable same-release-time skipping
We have the optimization to skip buffers if the release time is
exactly the same as the one for the previous buffer. This makes
sense under the assumption that these buffers get released to
a visible Surface and will be ignored anyway.

However, it's also helpful to provide a customization option to not
do this for cases where the outputting MediaCodecAdapter is not
directly talking to a visible Surface or for tests where we can't
fully control the vsync timing of the Surface and want to ensure
we output all samples that are meant to be shown.

PiperOrigin-RevId: 545906113
2023-07-13 14:57:41 +01:00
Googler
5050171ff6 Rename "useHdr" to "useHighPrecisionColorComponents."
BaseGlShaderProgram and SingleFrameGlShaderProgram are technically color space agnostic. useHdr is passed to the TexturePool, which only uses the value to choose between high/regular precision. useHdr is therefore a bit misleading and should be generalized to "useHighPrecisionColorComponents."

PiperOrigin-RevId: 545726629
2023-07-13 14:56:37 +01:00
claincly
2b8c01de47 Remove stale TODO
PiperOrigin-RevId: 545711472
2023-07-13 14:55:23 +01:00
tonihei
63331dbd1b Use Clock in video renderers
This makes tests more realistic because the returned value matches
the rest of the simulated test time.

It also prevents test flakiness in (yet to be written) tests that
may accidentally drop output buffers or calculate the wrong values.

PiperOrigin-RevId: 545690008
2023-07-13 14:54:10 +01:00
rohks
07d4e5986b Replace BitArray.skipBytes() with BitArray.skipBits()
Based on the spec, ETSI TS 102 366 V1.4.1 Annex F, 6 bits should have skipped instead of 6 bytes.

This correction was pointed out in Issue: androidx/media#474.

PiperOrigin-RevId: 545658365
2023-07-13 14:52:54 +01:00
huangdarwin
7a368b9a11 Effect: Remove GlTextureInfo accessor methods.
The extra check was a bit excessive, especially as it's called multiple times
per frame.

PiperOrigin-RevId: 545657102
2023-07-13 14:51:38 +01:00
michaelkatz
11dec52b6a Update build.gradle dependencies for lib-ui tests
This was missed in abd1c006fc

PiperOrigin-RevId: 545654091
2023-07-05 14:01:47 +00:00
huangdarwin
756845426b HDR: Add SM-X900 to HLG10 tone mapping blocklist.
PiperOrigin-RevId: 545647083
2023-07-05 13:59:58 +00:00
huangdarwin
fa781782da Effect: Share ExecutorService and thread between VFP instances.
This allows us to simplify and reduce thread initialization, hops and the
synchronization cost associated with them, especially when more and more VFPs
are used.

PiperOrigin-RevId: 545622169
2023-07-05 13:58:43 +00:00
michaelkatz
5737e415b8 Cache rawPlaybackHeadPosition across reset due to track transition
Upon track transition of offloaded playback of gapless tracks, the framework will reset the playback head position. The AudioTrackPositionTracker must be made to expect the reset and cache accumulated sum of rawPlaybackHeadPosition.

#minor-release

PiperOrigin-RevId: 545602979
2023-07-05 13:57:29 +00:00
tonihei
aa57d48347 Add MediaSource.canUpdateMediaItem/updateMediaItem
This allows MediaSources to accept MediaItem updates after creation.

This CL adds the handling and plumbing logic in `ExoPlayerImpl`,
`ExoPlayerImplInternal`, `MediaSourceList` and `MaskingMediaSource`.

It also updates all forwarding/wrapping sources to forward these calls
to their wrapped instance.

The actual functionality is only added to `FakeMediaSource` instances in
tests so far.

PiperOrigin-RevId: 545450210
2023-07-05 09:21:22 +00:00
samrobinson
c33a17d89c Wrap AudioSamplePipeline input and processing within AudioGraph.
This is a no-op refactor.

PiperOrigin-RevId: 545421300
2023-07-05 09:20:12 +00:00