19093 Commits

Author SHA1 Message Date
tonihei
71591782f0 Adjust periodEnded logic further
Periods that are not the last in the manifest are always ended
and non-dynamic periods are also always ended by definition.

Also, some periods may not be able to declare their final duration
accurately and we need to account for some inaccuracy. This can be
done by testing whether no further full segment within the duration
can be expected.
2023-08-08 17:47:23 +01:00
tonihei
88e921ced1 Format with google-java-format 2023-08-08 17:42:57 +01:00
zgzong
fb847cad66 Update dash chunk source to handle in-progressive recording dash stream.
Using calculated segments timeline duration to compare with period duration to update whether period has reach it the end of stream.
2023-08-08 17:42:57 +01:00
claincly
670658f3ae Use a larger pixel difference on real devices
PiperOrigin-RevId: 554452842
2023-08-07 14:04:36 +00:00
kimvde
117b18f54c Check command availability before getting tracks in PlayerView
#minor-release

PiperOrigin-RevId: 554451569
2023-08-07 14:03:27 +00:00
tianyifeng
ff3902debb Update translations
PiperOrigin-RevId: 554439196
2023-08-07 14:02:25 +00:00
samrobinson
cc141f7bf4 Use specific type for SequenceAssetLoader internal logic.
PiperOrigin-RevId: 554431024
2023-08-07 11:36:43 +00:00
samrobinson
42425334ae Mark always passing test as @Ignore.
Added a TODO inline linking to the created bug to address this.

PiperOrigin-RevId: 554422990
2023-08-07 11:35:34 +00:00
michaelkatz
aed21e464e Fix last sample detection issue for ClippingMediaSource
If stream is not considered final and `ClippingMediaSource` is read to `endUs`, then `BaseRenderer.readSource` returns `C.RESULT_NOTHING_READ`. In that case, the `lastBufferInStreamPresentationTimeUs` is not set and the last frame is not rendered.

PiperOrigin-RevId: 554418971
2023-08-07 11:34:34 +00:00
samrobinson
82387ccfe6 Remove unneeded check against silence generator remaining.
PiperOrigin-RevId: 553771328
2023-08-07 11:33:37 +00:00
huangdarwin
80d63a32d3 Test: Generalize Compositor tests for multi-input, and add more tests.
Tests are added for offset streams with gaps in the middle

PiperOrigin-RevId: 553510171
2023-08-07 11:32:38 +00:00
tonihei
57f327840b Remove old workaround for timestamp jumps
This workaround was added for TS streams that do not adjust their
timestamps to start from zero. Over time, the default audio sink
logic has become more robust towards unexpected timestamps and
we no longer need this workaround to jump forward in time.

The workaround also actively caused issues by adjusting the audio
timestamps backwards if the stream starts with large negative
values. See Issue: androidx/media#291. This caused playback to get stuck due
to another bug in the first-frame rendering logic in the video
renderer that is now fixed.

PiperOrigin-RevId: 553493618
2023-08-07 11:31:34 +00:00
tonihei
a3c1d5be9d Reset loading period after reading discontinuity that requires loading
This is the same change as 8655429af7, just on the second call site
of readDiscontinuity. The tests didn't cover this case yet because
they never queued more than 2 items in a playlist.

PiperOrigin-RevId: 553485244
2023-08-07 11:30:38 +00:00
huangdarwin
05782a7e99 Compositor: Add support for mismatched timestamps.
This means we now require 2+ input frames per input, and compare the primary
stream timestamp with secondary stream timestamps in order to select the
correct output timestamp. We also must release frames and back-pressure as
soon as possible to avoid blocking upstream VFPs.

Also, improve signalling of VFP onReadyToAcceptInputFrame

PiperOrigin-RevId: 553448965
2023-08-07 11:29:44 +00:00
claincly
ed1ff222bb Remove unnecessary setInputFormat
setInputFormat calls registerInputStream and will cause VideoFrameProcessor to
reconfigure. We don't need to call it when setting up the VFP
(in `onReadyToInitCodec()`). Rather, we wait until `onOutputFormatChanged()`
called (this output format refers to mediaCodec's outptut format) to register
the input stream.

PiperOrigin-RevId: 553448633
2023-08-07 11:28:43 +00:00
tofunmi
dfd668238a Create SingleSampleSeekMap and use in pngExtractor
PiperOrigin-RevId: 553191571
2023-08-07 11:27:27 +00:00
ibaker
133bf29668 Add demo app test stream with overlapping SSA subtitles muxed in MKV
This doesn't currently work by default, but upcoming changes in
`TextRenderer` will make it work as expected.

Issue: google/ExoPlayer#10295
PiperOrigin-RevId: 553161628
2023-08-07 11:26:18 +00:00
sheenachhabra
876b767356 Fix nit issues in muxer tests
PiperOrigin-RevId: 553145104
2023-08-07 11:25:20 +00:00
claincly
af546b8eda Fix decoder is queued buffer with timestamp TIME_END_OF_SOURCE
ExoPlayer queues the EOS buffer to the decoder with offset/size/timestamp all
equal to zero, and a EOS flag.

69769c77b3 set TIME_END_OF_SOURCE on the EOS buffer from the extractor.
Queueing the EOS buffer to the decoder with TIME_END_OF_SOURCE causes some
decoders to output wrong timestamps in its output.

This CL replicates what ExoPlayer does in Transformer.

PiperOrigin-RevId: 553104213
2023-08-07 11:24:11 +00:00
samrobinson
fec6252065 Add basic volume scaling to the Transformer demo app.
PiperOrigin-RevId: 553086635
2023-08-07 11:23:14 +00:00
huangdarwin
4302102cf0 Test: Use TestName in media3.effects tests.
Instead of duplicating strings

PiperOrigin-RevId: 552865414
2023-08-07 11:22:02 +00:00
tonihei
69656774f9 Only use first frame stream start position check at stream transitions
We currently only force the first frame if the frame timestamp is
greater than the stream *offset*.

This is wrong for two reasons:
 1. The timestamp and the offset are not comparable and it should be
    the stream start position.
 2. The check should only be applied at stream transitions where we
    need to make sure that a new first frame isn't rendered until we
    passed the transition point.

We have to fix both issues together, because fixing just issue (1)
causes seeks to before the start position to no longer render the
frame (and playback will be stuck). A new test covers this case.

We also amend the stream transition test case to actually test what it
promises to test and add a test for prerolling samples at the
beginning, to ensure the first frame is still renderered.

Issue: androidx/media#291
PiperOrigin-RevId: 552858967
2023-08-07 11:21:08 +00:00
tonihei
79e05ad049 Simplify first frame logic
We currently use 3 different booleans to track the state of the first
frame rendering, which implies that there are 8 distinct possible
overall states. However, this is actually a staged process and there
are only 3 different overall states in the current code. This means
it's clearer and easier to reason about if the variables are combined
to a single state value. Overall, this should be a complete no-op.

State mapping:
 - rFFAReset=false, rFFAEnable=false, mayRenderFFAEINS=false
   => FIRST_FRAME_NOT_RENDERED_ONLY_ALLOWED_IF_STARTED
 - rFFAReset=false and/or rFFAEnable=false, mayRenderFFAEINS=any
   => FIRST_FRAME_NOT_RENDERED
 - rFFAReset=true, rFFAEnable=true, mayRenderFFAEINS=any
   => FIRST_FRAME_RENDERED

PiperOrigin-RevId: 552857802
2023-08-07 11:19:56 +00:00
rohks
11648e6c8e Simplify and accurately compute chunk duration
Refactored `CmcdLog` to `CmcdHeadersFactory` for improved representation of its purpose and updated implementations.

#minor-change

PiperOrigin-RevId: 552831995
2023-08-07 11:19:00 +00:00
claincly
6633b05c0a Reorder DebugTraceEvent
PiperOrigin-RevId: 552818752
2023-08-07 11:18:04 +00:00
Googler
e87f0d5580 Add a thumbnail strip effect that tiles frames horizontally.
The size of the thumbnail strip and the timestamp of the video frames to use must be specified by the user of the effect.

PiperOrigin-RevId: 552809210
2023-08-07 11:15:10 +00:00
rohks
267d4164a9 Fix wrong documentation and add missing annotations
#minor-release

PiperOrigin-RevId: 552749407
2023-08-01 14:36:42 +01:00
huangdarwin
f389a85eea Compositor: Extract interface.
This allows for custom implementations of this interface, like
a TestVideoCompositor or partner-implemented implementation

PiperOrigin-RevId: 552541631
2023-08-01 14:35:29 +01:00
sheenachhabra
8c2d047b71 Add validation for empty csd data
PiperOrigin-RevId: 552541399
2023-08-01 14:34:17 +01:00
tofunmi
87a020a154 Add PngExtractor to DefaultExtractorsFactory
PiperOrigin-RevId: 552506545
2023-08-01 14:32:58 +01:00
jbibik
b8e6f27caf Update SubtitleExtractor to use SubtitleParser directly
`SubtitleExtractor` used to rely on a `SubtitleDecoder`. However, now all SubtitleDecoders that are used for side-loaded subtitles have been migrated to a `SubtitleParser` interface. We can therefore refactor the extractor.

The `SubtitleExtractor` is only used for side-loaded subtitles which means we do not require the migration of the CEA-608/708 `SubtitleDecoders`.

PiperOrigin-RevId: 552471710
2023-08-01 14:31:58 +01:00
samrobinson
9e975b25d1 Define TestMuxer Factory and Holder as inner classes.
PiperOrigin-RevId: 552469061
2023-08-01 14:29:38 +01:00
claincly
c16840573b Format DebugTraceUtil report to output JSON string
PiperOrigin-RevId: 552455533
2023-08-01 14:28:23 +01:00
tofunmi
499dd5b84e remove redundant identity setting in the OverlayShaderProgram
PiperOrigin-RevId: 552416606
2023-08-01 14:26:07 +01:00
tofunmi
bb699e41c9 Add png extractor
Implementing a basic extractor that reads the whole png file into the trackOutput as one sample.

PiperOrigin-RevId: 551897619
2023-08-01 14:24:47 +01:00
ibaker
a700974d8c Mark x-media3-cues MIME type as text type
PiperOrigin-RevId: 551853336
2023-08-01 14:23:44 +01:00
andrewlewis
ddb0f86604 Fix parsing of H.265 sequence parameter sets
Fix short term reference picture list parsing. Before this change, `deltaPocS0`
was derived by adding one to the value of the syntax element
`delta_poc_s0_minus1`, but (maybe surprising) the specification actually says
that `DeltaPocS0[stRpsIdx][i]` should be assigned the negation
`-(delta_poc_s0_minus1[i] + 1)` on the first iteration, then that value added
to the previous value on previous iterations. See equations (7-67) to (7-70) in
the 2021-08 version of the H.265/HEVC specification.

Also read the number of long term reference pictures once rather than on every
loop iteration (subsection 7.3.2.2.1).

PiperOrigin-RevId: 551852999
2023-08-01 14:22:29 +01:00
simakova
415b17c1e1 Allow an empty video effects array
PiperOrigin-RevId: 551829203
2023-08-01 14:21:20 +01:00
christosts
444f0023a4 Define the VideoSink interface
PiperOrigin-RevId: 551825940
2023-08-01 14:20:18 +01:00
samrobinson
b15e7553e5 Add the hasSource method to the AudioMixer interface.
PiperOrigin-RevId: 551804976
2023-08-01 14:19:04 +01:00
claincly
c221958889 Remove setInputFrameInfo
After this change, every queued bitmap is treated as an individual input stream
(like a new MediaItems).

This change merges the FrameDropTest and FrameDropPixelTest into one (while maintaining all the test cases)

- This is accomplished by generating bitmaps with timestamps on it in FrameDropTest and compare them with goldens (one may call this a pixel test, please lmk if you want this to be renamed)
- The most part of the change comes from DefaultVideoFrameProcessorVideoFrameRenderingTest. The overall working is
  - We bypass the input manager
  - The TestFrameGenerator generates frames based on timestamps. In this case, we generate frames with timestamps on it
  - The generated frame is sent to texture output and in turn saved to bitmaps
  - We then compare the generated bitmap with the goldens

PiperOrigin-RevId: 551795770
2023-08-01 14:17:59 +01:00
tofunmi
ebbcec9a20 Add imageDurationMs to MediaItem
PiperOrigin-RevId: 551776350
2023-08-01 14:16:48 +01:00
samrobinson
ccdde8806e Account for endTimeUs when outputting with no sources.
When endTimeUs is set, restrict output to that point.

PiperOrigin-RevId: 551555392
2023-08-01 14:15:34 +01:00
claincly
5ba0ec9b40 Remove stale TODO
It says RTSP doesn't support this in the javadoc.

PiperOrigin-RevId: 551541942
2023-08-01 14:14:34 +01:00
huangdarwin
bd6a36033e Compositor: Move shared test logic to TestRunner.
Move shared test logic to the test runner.

This does increase indirection, which isn't usually preferable in tests.
However, we will have many different tests that would use logic
like this, so this allows us to reduce repetition.

PiperOrigin-RevId: 551536438
2023-08-01 14:13:25 +01:00
claincly
e77c318d96 Create Util method for SparseArray.contains()
And fixed usages in Transformer and Effect.

PiperOrigin-RevId: 551484860
2023-08-01 14:12:10 +01:00
bachinger
17ee5277d5 Only use result.sendError where supported by legacy media library
`MediaLibraryServiceLegacyStub` handles various edge cases by calling
`result.sendError(null)` with the intention to send back an error to
the legacy browser [1].

`MediaBrowserServiceCompat` of the legacy media1 Compat library has an
inner base class `Result` that has a default implementation of
`onErrorSent` that throws an `UnsupportedOperationException` [2].
However, most anonymous inner classes for `Result` created in
`MediaBrowserServiceCompat` do not override `onErrorSent` [3].

Hence Media3 must not call `sendError` in these cases. Instead we call
`sendResult(null)` according to what the default implementation of
the callbacks in `MediaBrowserServiceCompat` do ([4] as an example).

Issue: androidx/media#78
Issue: androidx/media#334

[1] https://github.com/androidx/media/blob/release/libraries/session/src/main/java/androidx/media3/session/MediaLibraryServiceLegacyStub.java#L200
[2] https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:media/media/src/main/java/androidx/media/MediaBrowserServiceCompat.java;l=872
[3] https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:media/media/src/main/java/androidx/media/MediaBrowserServiceCompat.java;l=578-604?q=MediaBrowserServiceCompat&ss=androidx
[4] https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:media/media/src/main/java/androidx/media/MediaBrowserServiceCompat.java;l=1395

PiperOrigin-RevId: 551210137
2023-08-01 14:11:08 +01:00
tonihei
f766936140 Fix ms to us conversion bug in DecoderVideoRenderer
The current code multiplies the value by 1000 twice,
effectively converting to nanoseconds.

#minor-release

PiperOrigin-RevId: 551129750
2023-08-01 14:09:56 +01:00
samrobinson
b7d7027424 Update Composition javadoc for expanded audio support.
PiperOrigin-RevId: 550922961
2023-08-01 14:08:46 +01:00
tonihei
782f5b2a0e Fix last sample detection issues
1. For codecs that change timestamps, we need to use greater
   or equal instead of just equal for comparison.
2. We should only make this comparison once a value has been
   set.
3. The largest queue timestamp isn't updated before using it
   for this detection, meaning that we also mark the
   second-to-last sample as the last one.

PiperOrigin-RevId: 550901978
2023-08-01 14:06:55 +01:00