19372 Commits

Author SHA1 Message Date
tofunmi
d4b452d475 Use ProgressiveMediaSource and period for images
PiperOrigin-RevId: 555424664
2023-08-10 12:30:29 +00:00
huangdarwin
fd5784455c Compositor: Add test for correct input timestamps.
To ensure that for each output bitmap from the compostor, the right input
timestamps were used.

Only applied on a subset of tests to avoid needing to upload+maintain
too many files/size in the test binary, especially when it would test
duplicate behavior

PiperOrigin-RevId: 555222530
2023-08-10 12:29:21 +00:00
samrobinson
79725fd332 Use TestMuxer.Factory as the holder of the Dumpable test muxer.
PiperOrigin-RevId: 555222322
2023-08-10 12:28:18 +00:00
claincly
7e12d7619a Avoid create short lived object
PiperOrigin-RevId: 555204528
2023-08-10 12:27:00 +00:00
huangdarwin
3351f0387f Test: Use larger pixel diff on real devices, smaller on emulators.
PiperOrigin-RevId: 555178875
2023-08-10 12:25:59 +00:00
kimvde
266dc5a6d6 Add video speed change effect
This adds an effect to change the speed of the video track. The speed
of the audio track can already be changed using a SonicAudioProcessor.

Issue: androidx/media#559
PiperOrigin-RevId: 555155418
2023-08-10 12:24:41 +00:00
rohks
cf9f048a3d Enhance getNextChunk() API to allow passing more information
Modifies the `ChunkSource.getNextChunk(long, long, List, ChunkHolder)` method in the `ChunkSource` interface to `ChunkSource.getNextChunk(LoadingInfo, long, List, ChunkHolder)`.

LoadingInfo contains additional parameters, including `playbackRate` 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.

PiperOrigin-RevId: 555148768
2023-08-10 12:23:37 +00:00
andrewlewis
bf5c4d8078 Use golden data generated on emulator for tests based on london.jpg
PiperOrigin-RevId: 555148673
2023-08-10 12:22:31 +00:00
jbibik
f7c31bd3ef Fix Gradle Lint with @RequiresApi and SDK version
Gradle Lint doesn't recognise `checkState` assertion and TargetApi should only ever be used for suppressing a bug in Android Lint. Hence, we keep @RequiresApi and add an if-statement explicitly. Also, fixes >26 to >=26 for the version check.

#minor-release

PiperOrigin-RevId: 555144577
2023-08-10 12:21:27 +00:00
kimvde
2a645ac2b6 Add CompositionPlayer listener tests
PiperOrigin-RevId: 555139635
2023-08-10 12:20:03 +00:00
tofunmi
7bc213d3ef Set tile count in Pngextractor
Tile count must be set to make sure the image decoder recognises and supports the format.

PiperOrigin-RevId: 555136616
2023-08-10 12:19:03 +00:00
rohks
38eabdc9fc Bump IMA SDK version to 3.30.3
#minor-change

PiperOrigin-RevId: 555130308
2023-08-10 12:18:00 +00:00
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