19310 Commits

Author SHA1 Message Date
rohks
481ea4a274 Enhance continueLoading() API to allow passing more information
Modifies the `SequenceableLoader.continueLoading(long)` method in the `SequenceableLoader` interface to `SequenceableLoader.continueLoading(LoadingInfo)`.

`LoadingInfo` contains additional parameters, including `playbackSpeed` and `lastRebufferRealtimeMs` in addition to the existing `playbackPositionUs`. The additional parameters will allow us to pass these information to Common Media Client Data (CMCD) logging.

By using the `LoadingInfo` object, we ensure future flexibility to add more fields without causing any breaking changes to the API.

PiperOrigin-RevId: 555123961
2023-08-10 12:16:41 +00:00
claincly
2da3cc71e5 Fix mis-placed debug tracing call
PiperOrigin-RevId: 555118817
2023-08-10 12:15:35 +00:00
tonihei
20d2ce7ce8 Verify source is not released before updating ad playback state
Updates to the ad playback state are posted on the main handler,
so they may arrive after the source has already been released
(=the internal MediaSource is null). This can cause NPEs.

PiperOrigin-RevId: 555102426
2023-08-10 12:13:12 +00:00
jbibik
dedccc596e Fix PlayerWrapper's creation of VolumeProviderCompat
When hardware buttons are used to control the volume of the remote device, the call propagates to `MediaSessionCompat.setPlaybackToRemote(volumeProviderCompat)`. However, `volumeProviderCompat` was created incorrectly when the new device volume commands were present (COMMAND_SET_DEVICE_VOLUME_WITH_FLAGS and COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS), i.e. with volumeControlType = `VOLUME_CONTROL_FIXED`. This resulted in `VolumeProviderCompat` which doesn't call `onSetVolumeTo` or `onAdjustVolume` and hence doesn't propagate the calls to the `Player`. Instead, it only worked with the deprecated commands which ensured the volumeControlType was `VOLUME_CONTROL_ABSOLUTE`.

This bug was introduced in c71e4bf1ff (1.0 media 3 release) when `PlayerWrapper`'s call to `createVolumeProviderCompat` was mostly rewritten to handle the new commands, but the two if-statements were not amended. Note: this change fixes the bug only for Android 11 and below. For 12 and above, there is a tracking bug for the regression that was introduced: https://issuetracker.google.com/issues/201546605

http://Issue: androidx/media#554

#minor-release

PiperOrigin-RevId: 554966361
2023-08-10 12:12:09 +00:00
claincly
e8a18e208a Improve DebugTraceUtil logging
PiperOrigin-RevId: 554872827
2023-08-10 12:10:50 +00:00
Tianyi Feng
ef54364478 Merge pull request #528 from zgzong:patch-2
PiperOrigin-RevId: 554869426
2023-08-10 12:09:43 +00:00
samturci
821ec49049 Preserve the byte order when using read-only ByteBuffers.
`asReadOnlyBuffer` doesn't copy the original byte order but always sets it to big-endian. Replace calls to it with a utility method that manually sets the byte order after creating the read-only copy.

This fixes `TeeAudioProcessor` providing a `ByteBuffer` always in big-endian and hence causing `AudioBufferSink` to read wrong data.

PiperOrigin-RevId: 554861402
2023-08-10 12:08:19 +00:00
Googler
4fe55b8b63 Return the correct output buffer from audio processing pipeline
PiperOrigin-RevId: 554851456
2023-08-10 12:07:15 +00:00
rohks
3ec462d1cf Add field object type (ot)
Added this CMCD-Object field to Common Media Client Data (CMCD) logging.

#minor-release

PiperOrigin-RevId: 554843305
2023-08-10 12:06:13 +00:00
christosts
cba027c3b4 Util.getMaxPendingFramesCountForMediaCodecDecoders(): Remove unused arguments
PiperOrigin-RevId: 554838494
2023-08-10 12:05:08 +00:00
tofunmi
7be15b7603 Release overlay resources at end of frame processing
When implementing pause and resume, overlay appears as black frame on resume, suggesting the texture isn't being remade properly due to lack of proper deletion.

PiperOrigin-RevId: 554832580
2023-08-10 12:04:03 +00:00
kimvde
5c78290d5a Delete created GL programs
PiperOrigin-RevId: 554832238
2023-08-10 12:02:59 +00:00
kimvde
57086b6641 Make effect classes final
Making classes final when possible is good practice

PiperOrigin-RevId: 554776293
2023-08-10 12:01:53 +00:00
Googler
7d6f02dc50 Only set hadKeyframe flag to true if we end up muxing the frame.
If we throw away the first keyframe (because it does not contain any bytes to read), we shouldn't behave as if we had written a keyframe to our track. We should instead continue waiting for the first (valid) keyframe.

PiperOrigin-RevId: 554579146
2023-08-10 12:00:51 +00:00
kimvde
f43146718c Add CompositionPlayer unit test
Test the audio side only because the video side won't be testable with
unit tests once we add the OpenGL components.

PiperOrigin-RevId: 554508703
2023-08-10 11:59:42 +00:00
andrewlewis
691bf93032 Use lower resolution bitmap for tests
The test file decompresses to about 48 MB, which can cause an
`OutOfMemoryError` on lower end devices.

Also, a test appears to apply a rotation to this bitmap without downscaling
first, leading to exceeding a maximum texture width/height of 4096 on some
devices.

Replace the test file with one that has a quarter of the original's
width/height so that these tests can pass reliably even on lower end
devices.

PiperOrigin-RevId: 554507185
2023-08-10 11:58:25 +00:00
ibaker
6e91f0d4c5 Use ceiling divide logic in AudioTrackPositionTracker.hasPendingData
This fixes a bug with playing very short audio files, introduced by
fe710871aa

The existing code using floor integer division results in playback never
transitioning to `STATE_ENDED` because at the end of playback for the
short sample clip provided `currentPositionUs=189937`,
`outputSampleRate=16000` and `(189937 * 16000) / 1000000 = 3038.992`,
while `writtenFrames=3039`. This is fixed by using `Util.ceilDivide`
so we return `3039`, which means
`AudioTrackPositionTracker.hasPendingData()` returns `false` (since
`writtenFrames ==
durationUsToFrames(getCurrentPositionUs(/* sourceEnded= */ false))`).

#minor-release

Issue: androidx/media#538
PiperOrigin-RevId: 554481782
2023-08-10 11:57:15 +00:00
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