2778 Commits

Author SHA1 Message Date
tonihei
da99f9937d Rollback of 7996766b22
*** Original commit ***

Rollback of b69b33206e

*** Original commit ***

Mark output sample as decode-only based on start time

We currently do the same check on the input timestamps and
expect the output timestamps to match. Some codecs produce
samples with modified timestamps and the logic is a lot safer
when the comparison with the start time is done on the output
side of the codec.

Issue: google/ExoPlayer#11000

***

***

PiperOrigin-RevId: 549019403
2023-07-20 10:26:25 +01:00
huangdarwin
747b31b3c5 Test: Add non-mh androidTest tests to MH_TESTS / triage.
PiperOrigin-RevId: 549005874
2023-07-20 10:25:30 +01:00
tonihei
8064c6df83 Declare foreground service type for DownloadService
This ensures the DownloadService stays functional on Android 14
where defining this type is required. On Android 14 and above,
the app also needs to define the DATA_SYNC permission, which is
added to the demo app as well. In the future, this service type
will no longer be supported and DownloadService needs to be
rewritten with another background scheduling framework.

Issue: google/ExoPlayer#11239
PiperOrigin-RevId: 548994842
2023-07-20 10:23:56 +01:00
samrobinson
035934c6d4 Combine audio mixing logic across Transformer.
AudioMixingUtil#mix handles input & output in float or Int16 PCM. Given
Float and Int16 use different sample ratnes, this util handles
conversion between the two, based on the encoding being mixed to.

Migrate AudioMixer to use the util, removing AudioMixingAlgorithm
interface and implementation. ChannelMixingAudioProcessor will be
migrated after additional performance checks.

PiperOrigin-RevId: 548994584
2023-07-20 10:22:58 +01:00
jbibik
9520180fbb DelegatingSubtitleDecoder tests refactor
PiperOrigin-RevId: 548991428
2023-07-20 10:21:43 +01:00
tonihei
b0ec2cc701 Remove timestamp clipping in MergingMediaPeriod.TimeOffsetSampleStream
This was done because it was deemed correct to only start at timestamp
zero when the code was originally written. However, in case of
prerolling from a keyframe, many samples will get the same timestamp,
which is not correct and interferes with downstream logic
that deals with timestamps.

PiperOrigin-RevId: 548986160
2023-07-20 10:20:22 +01:00
rohks
1b2a2fcde0 Add fields top bitrate(tb) and object duration(d)
Added these CMCD-Object fields to Common Media Client Data (CMCD) logging.

#minor-release

PiperOrigin-RevId: 548950296
2023-07-20 10:19:26 +01:00
ibaker
0fa66534fe Use CuesWithTiming.durationUs in SubripParser instead of empty cues
This fixes two things in one go:
1. In order to indicate 'end of a cue' **without** relying on
   `CuesWithTiming.durationUs`, `SubripParser` should have been emitting
   an empty `List<Cue>` instead of the current behaviour of a
   single-item list with `cue.text=""`.
2. There's no need for the empty cue (or cue list), we can use
   `durationUs` to indicate the end of each list of cues.

There's no real need to ever have a `Cue` with `text=""`, so also
deprecate `Cue.EMPTY`.

PiperOrigin-RevId: 548938874
2023-07-20 10:18:09 +01:00
tonihei
8655429af7 Reset loading period after reading discontinuity that requires loading
Reading a discontinuity from a media period indicates that a position
reset is required. As part of this event, the media period may need
further loading (e.g in a MergingMediaPeriod where one stream reported
a discontinuity and the other need to reload from this position).

This currently fails if the media periods was already fully loaded and
we started loading further items in the playlist. As a result, playback
is stuck forever. We can fix this by detecting that further loading is
needed and resetting the loading period to the current one.

The existing MergingPlaylistPlaybackTest already covers this case
reliably, because it combines all the right preconditions (merging
source, clipping to get a discontinuity and a playlist).

PiperOrigin-RevId: 548735177
2023-07-20 10:17:11 +01:00
Googler
7adc0af8a6 Save to TestStorage when saving Bitmap
PiperOrigin-RevId: 548733979
2023-07-20 10:15:47 +01:00
ibaker
34768c2399 Add MKV test assets with overlapping SSA and SRT subtitles
This is a step towards adding general support for overlapping
subtitles in these formats (and others), both muxed and sideloaded:
* Issue: google/ExoPlayer#10295
* Issue: google/ExoPlayer#4794

This change adds these files to the end-to-end playback tests too, but
the subtitle track is currently disabled because renderer-side subtitle
parsing causes flaky tests (due to an uncontrolled thread in
`SimpleSubtitleDecoder`). The subtitle track will be re-enabled in
a follow-up change when loading-side subtitle parsing is added (so the
tests will no longer be flaky). At this point the overlapping subtitles
**still** won't be supported end-to-end, but a second change will
resolve this will changes in `TextRenderer` - which will change the
end-to-end playback dumps to reflect the overlapping subtitles.

PiperOrigin-RevId: 548705032
2023-07-20 10:14:50 +01:00
huangdarwin
836720ebfa Compositor: Use timestamps for compositing.
For now, just identical timestamps. A follow-up CL will allow for different
framerates. Prior tests already send identical timestamp frames, so no new
tests were added

PiperOrigin-RevId: 548676759
2023-07-20 10:13:28 +01:00
andrewlewis
81ef52763d Fix @RequiresApi annotations in GlUtil
`EGL14` was added in API 17, so move all references into the `Api17` wrapper
class. `GLES30` requires API 18.

Remove some defensive calls to check that a context is current. Checking for GL
errors after calls should catch the case of calling GL methods without a
context (which is also only likely to come up early in development), and these
checks were not done consistently across all methods anyway. That allows
removing the API 17 requirement from `SceneRenderer` (where previously it
wasn't documented).

PiperOrigin-RevId: 548669946
2023-07-20 10:12:14 +01:00
tonihei
c64d9fd6da Fix race condition in clipped sample streams
The streams return end-of-input if they read no samples, but know that
they are fully buffered to at least the clipped end time. This helps to
detect the end of stream even if there are no new buffers after the end
of the clip (e.g. for sparse metadata tracks).

The race condition occurs because the buffered position is evaluated
after reading the sample. So between reading "no sample" and checking
the buffered position, the source may have loaded arbitrary amounts
of data. This may lead to a situation where the source has not read
all samples, reads NOTHING_READ (because the queue is empty) and then
immediately returns end-of-stream (because the buffered position
jumped forward), causing all remaining samples in the stream to be
skipped. This can fixed by moving the buffered position check to
before reading the sample, so that it never exceeds the buffered
position at the time of reading "no sample".

#minor-release

PiperOrigin-RevId: 548646464
2023-07-20 10:10:00 +01:00
ibaker
89972dbc38 Update DelegatingSubtitleDecoder to use CuesWithTiming.durationUs
Also re-use the `CuesWithTimingSubtitle` implementation (previously a
private class inside `DelegatingSubtitleDecoder`) in `ExoPlayerCuesDecoder`.

PiperOrigin-RevId: 548612040
2023-07-20 10:08:40 +01:00
jbibik
4ed01c42bd DefaultSubtitleParserFactory that creates supported SubtitleParsers
It will act similarly to `SubtitleDecoderFactory`, but return parsers instead of decoders. In turn `SubtitleDecoderFactory.createDecoder()` cab wrap those parsers with `DelegatingSubtitleDecoder`.

PiperOrigin-RevId: 548528054
2023-07-20 10:07:16 +01:00
jbibik
7d4848ece2 PgsParser implementation - moved from PgsDecoder
`PgsDecoder` which used to be `SimpleSubtitleDecoder` will now be called `PgsParser` and implement `SubtitleParser` interface. For backwards compatibility, we will have the same functionality provided by `DelegatingSubtitleDecoder` backed-up by a new `PgsParser` instance.

PiperOrigin-RevId: 548520549
2023-07-20 10:05:52 +01:00
huangdarwin
0c29dacde3 Compositor: Use timestamps to release frames.
Also, implement back-pressure to avoid requesting more than all of the
compositor's texturepool textures

PiperOrigin-RevId: 548179800
2023-07-20 10:04:55 +01:00
huangdarwin
8c4aa6b75d Compositor: Add 10 frame test.
This serves as a sort of test with more frames for the compositor for now
(before more varied video system tests come later when integrating with
Transformer), showing it doesn't error out and outputs the right
amount of frames.

Due to the VFPTestRunner having a 5s timeout, and mostly due to presubmit
emulators being very slow with OpenGL, there is a sort of limitation
to how many frames this type of test can have, depending on the test target

PiperOrigin-RevId: 548159762
2023-07-20 10:03:55 +01:00
jbibik
2261756d3a DvbParser implementation to adhere to SubtitleParser interface
`DvbDecoder` which used to be `SimpleSubtitleDecoder` will now be called `DvbParser` and implement `SubtitleParser` interface. There was, however, already a `DvbParser`, used by `DvbDecoder` behind the scenes. Hence, the refactoring only requires the existing `DvbParser` to adhere to the new `SubtitleParser` interface.

For backwards compatibility, we will have the same functionality as `DvbDecoder` provided by `DelegatingSubtitleDecoder` backed-up by a new `DvbParser` instance, available from the `SubtitleDecoderFactory`.

PiperOrigin-RevId: 548155759
2023-07-20 10:02:34 +01:00
jbibik
7537e692c6 Tx3gParser implementation - moved from Tx3gDecoder
`Tx3gDecoder` which used to be `SimpleSubtitleDecoder` will now be called `Tx3gParser` and implement `SubtitleParser` interface. For backwards compatibility, we will have the same functionality provided by `DelegatingSubtitleDecoder` backed-up by a new `Tx3gParser` instance.

PiperOrigin-RevId: 548144492
2023-07-20 10:01:21 +01:00
tofunmi
453431fef2 Fix TextOverlay's overlay width measuring strategy
Before this CL, the text with a scale span would wrap text, with because the scale wasn't taken into account when measuring the width of the overlay.

PiperOrigin-RevId: 548123626
2023-07-20 10:00:05 +01:00
Googler
46482e0384 Avoid resetting suppression reason with play/pause on MediaController
Unlike ExoPlayer, when play/pause is called on MediaController, the playback suppression reason is set to default causing a change in it and subsequent callbacks on the Player.Listener.

PiperOrigin-RevId: 548088931
2023-07-20 09:57:51 +01:00
michaelkatz
847f6f24d3 Prepend Ogg ID and Comment Header Pages to offloaded Opus stream
Add Ogg ID Header and Comment Header Pages to the Ogg encapsulated Opus for offload playback. This further matches the RFC 7845 spec and provides initialization data to decoders.

PiperOrigin-RevId: 548080222
2023-07-20 09:56:31 +01:00
rohks
11e3219e6d Add tests for DefaultSsChunkSource
Added tests for Common Media Client Data (CMCD) logging in SmoothStreaming(SS)

PiperOrigin-RevId: 548072725
2023-07-20 09:55:16 +01:00
tonihei
af0069dead Update initial bandwidth meter estimates
PiperOrigin-RevId: 548064930
2023-07-20 09:53:54 +01:00
rohks
4d40f2e7dd Fix dependencies for UI module
PiperOrigin-RevId: 548063325
2023-07-14 10:24:15 +01:00
tonihei
568817f756 Add e2etests for merged sources in a playlist
These tests allow to verify the samples sent for decoding,
when decoders are reset, which samples are dropped as decode-only
for video and which samples are sent to the AudioTrack for playback.

The test exercises all combinations of merges where audio or video
is the primary track and where audio, video or both are clipped.

PiperOrigin-RevId: 548061254
2023-07-14 10:23:01 +01:00
ibaker
06132c6778 Update DelegatingSubtitleDecoder to handle startTimeUs = TIME_UNSET
Also add a test to enforce this when `Tx3gDecoder` is migrated to
`Tx3gParser`.

PiperOrigin-RevId: 547856968
2023-07-14 10:21:58 +01:00
huangdarwin
da68b9391d Add underscores to numbers for readability.
No-op change just to marginally improve readability and reduce
counting zeroes.

PiperOrigin-RevId: 547844999
2023-07-14 10:20:48 +01:00
samrobinson
847cc9b841 Use asset with encoded video & raw audio for Robolectric test.
Test requires file to have video track for forcing silence.

PiperOrigin-RevId: 547839076
2023-07-14 10:19:29 +01:00
huangdarwin
952086174a Test: Remove unused DecodeOneCacheFileFrame method.
PiperOrigin-RevId: 547821350
2023-07-14 10:18:17 +01:00
rohks
ca10204b2d Replace Dummy with Placeholder
`Dummy` is a non inclusive language.

PiperOrigin-RevId: 547815680
2023-07-14 10:17:05 +01:00
tonihei
989607aa04 Add e2etest for clipped sources in playlists
These tests allow to verify the samples sent for decoding,
when decoders are reset, which samples are dropped as decode-only
for video and which samples are sent to the AudioTrack for playback.

The test exercises all combinations of clipping transitions for
sources that are either clipped at the start, the end, or both.

PiperOrigin-RevId: 547730824
2023-07-13 16:00:16 +01:00
tonihei
d8498f3ecb Set signal on renderer once it's allowed to render start of stream
When a renderer is pre-enabled (while another playback is still
ongoing), we pass mayRenderStartOfStream=false to Renderer.enable.
This ensures we don't show any first frames while the previous media
is still playing.

Currently, we never tell the renderer when we actually stop playing
the previous media so that it could render the start of the stream,
because we allow this as soon as the renderer is in STATE_STARTED and
we assume that we have to be in STATE_STARTED to make this stream
transition.

While this assumption is true, there are also cases where we can't
start the renderers because they are not ready yet and the video
renderer can't become ready because it didn't render its first frame.
This effectively blocks playback forever.

The most direct way of solving this, is to tell the renderer that
playback has transitioned and that it is now allowed to render the
start of the stream. This means it can never get blocked as described
above.

PiperOrigin-RevId: 547727347
2023-07-13 15:59:00 +01:00
claincly
18033c9c1b Add basic SingleInputVideoGraph by wrapping DefaultVideoFrameProcessor
SingleInputVideoGraph implements GraphInput now, so the asset loaders would
interface directly with SIVG, rather than VideoSampleExporter. This is to pave
way for multi-asset video processing.

PiperOrigin-RevId: 547561042
2023-07-13 15:57:47 +01:00
siroberts
ab904bde2d Prevent the creation of CommandButtons without commands.
The setPlayerCommand and setSessionCommand builder methods contain assertions to ensure that at most one of these fields is set, but this left it possible to create a command button with no command by calling build on an empty builder.

PiperOrigin-RevId: 547488248
2023-07-13 15:56:43 +01:00
andrewlewis
2bfc6c7740 Add support for extracting Vorbis audio in MP4
PiperOrigin-RevId: 547474958
2023-07-13 15:53:55 +01:00
claincly
e81ae0a8eb Remove stale (incorrect) javadoc lines from transformer.java
PiperOrigin-RevId: 547451166
2023-07-13 15:51:28 +01:00
rohks
0412a36564 Add fields streaming format(sf), stream type(st) and version(v)
Added these CMCD-Session fields to Common Media Client Data (CMCD) logging.

#minor-release

PiperOrigin-RevId: 547435498
2023-07-13 15:50:16 +01:00
claincly
bbdc64a732 Remove stale TODO
The said test is added in `TransformerMixedInputEndToEndTest` and
`TransformerSequenceEffectTest`.

PiperOrigin-RevId: 547407374
2023-07-13 15:48:58 +01:00
bachinger
ea21d27a69 Add custom layout to the state of the MediaController
This change also marks the buttons of the custom layout as
enabled/disabled according to available commands in the controller.
Accordingly, `CommandButton.Builder.setEnabled(boolean)` is deprecated
because the value is overridden by the library.

Issue: androidx/media#38

#minor-release

PiperOrigin-RevId: 547272588
2023-07-13 15:47:50 +01:00
jbibik
02b9d8d8b7 Mp4WebvttParser implementation - moved from Mp4WebvttDecoder
`Mp4WebvttDecoder` which used to be `SimpleSubtitleDecoder` will now be called `Mp4WebvttParser` and implement `SubtitleParser` interface. For backwards compatibility, we will have the same functionality provided by `DelegatingSubtitleDecoder` backed-up by a new `Mp4WebvttParser` instance.

PiperOrigin-RevId: 547248157
2023-07-13 15:46:44 +01:00
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