1498 Commits

Author SHA1 Message Date
tonihei
82cb1d8ac7 Move AudioBecomingNoisyManager system calls off main thread
PiperOrigin-RevId: 722569306
2025-02-03 02:18:02 -08:00
Googler
d6844699c5 Recognize QC's secure MV-HEVC decoder.
PiperOrigin-RevId: 721749833
2025-01-31 06:20:49 -08:00
tonihei
39d0881083 Add option to ClippingMediaSource to clip unseekable media
This means we need convert some of the assertions in
ClippingMediaPeriod to contrain the output value to clipped
range instead, because unseekable media will return zero
as a start and seek position in all cases.

PiperOrigin-RevId: 721463824
2025-01-30 11:40:46 -08:00
tonihei
df575a8d19 Add ClippingMediaSource.Builder
This prevents complicated constructor changes when we add new options.

PiperOrigin-RevId: 721415339
2025-01-30 09:23:49 -08:00
Gilles Khouzam
8466a957c3 Make MediaCodecVideoRenderer::shouldUsePlaceholderSurface protected.
This enables a derived renderer to disable the placeholder surface.
2025-01-30 11:35:39 +00:00
tonihei
17100259cd Move Util.getCountryCode off main thread in DefaultBandwidthMeter
PiperOrigin-RevId: 721293354
2025-01-30 01:23:56 -08:00
tonihei
6b31b4620c Move NetworkTypeObserver operations off main thread
PiperOrigin-RevId: 721291681
2025-01-30 01:17:22 -08:00
kimvde
9af43c7381 CompositionPlayer: skip decode-only frames upstream of the VideoGraph
This is necessary for prewarming. With prewarming, in a sequence of 2
videos, the second renderer is enabled before the first one is disabled,
and decode-only frames should be skipped before the second renderer is
started. The problem is that the second renderer will forward frames to
a BufferingVideoSink before it is started, which  will delay the frame
handling and therefore not skip the frame before the renderer is
started.

PiperOrigin-RevId: 721032049
2025-01-29 10:44:56 -08:00
rohks
3c0e2ee198 Suppress UseSdkSuppress warning in MediaExtractorContractTest
The fix is included in Android Gradle Plugin `8.9.0-alpha05`. Remove this suppression after upgrading.

PiperOrigin-RevId: 721009745
2025-01-29 09:42:37 -08:00
ivanbuper
fc6df77831 Remove deprecated androidx.media3.exoplayer.audio.SonicAudioProcessor
Also, make `androidx.media3.common.audio.SonicAudioProcessor` final.

PiperOrigin-RevId: 720987023
2025-01-29 08:30:09 -08:00
rohks
dfef16d5c6 Restrict test to API 24+ in MediaExtractorContractTest
`MediaExtractor.setDataSource(AssetFileDescriptor afd)` requires API 24+.

#cherrypick

PiperOrigin-RevId: 720943416
2025-01-29 06:05:39 -08:00
rohks
e15438322d Fix ArrayIndexOutOfBoundsException in MP4 edit lists
The exception occurred when an edit list started at a non-sync frame with no preceding sync frame. The fix searches forward for the next sync frame in such cases, preventing the out-of-bounds access.

Issue: androidx/media#2062

#cherrypick

PiperOrigin-RevId: 720642687
2025-01-28 11:13:38 -08:00
rohks
8d22482f79 Add MediaExtractor contract test structure with one basic test
Additional tests will be added in future changes.

PiperOrigin-RevId: 720555580
2025-01-28 06:44:40 -08:00
tonihei
ddcf455d03 Convert context dependent TrackSelectionParameters to boolean
This avoids that these settings have to be resolved inline,
potentially blocking the main thread. They can be resolved at
the time of track selection on a background thread instead.

As a side effect, we can also remove the context parameter from
the Builder. Having the Context in the Builder is also a bad sign
in the first place because it implies the potentially blocking
calls can happen.

PiperOrigin-RevId: 720523139
2025-01-28 04:26:15 -08:00
tonihei
706c363104 Remove potentially blocking calls from DefaultTrackSelector UI thread
The calls to Util.isTV and the interactions with the spatializer are
potentially blocking and were triggered from the constructor,
setAudioAttributes and release.

setAudioAttributes and release are both documented to be called by
the Player and should be triggered on the playback thread anyway.

The constructor initialization can be delayed until the spatializer
might be needed to avoid the blocking call.

The threading clean-up also allows to remove the lock from the
audioAttributes and the spatializer fields as they are now
accessed on the playback thread only.

PiperOrigin-RevId: 720488979
2025-01-28 02:09:28 -08:00
dancho
80a734f4f1 AV1 bitstream parser that identifies frames with no dependencies
Usage:
* call queueInputBuffer() with initialization data or sample data in decode
order - updates the parser state
* call sampleLimitAfterSkippingNonReferenceFrame to identify if the sample
contains a frame without dependencies
PiperOrigin-RevId: 720098835
2025-01-27 03:19:36 -08:00
ibaker
a7a5d6e92b Suppress (and log) subtitle errors in SubtitleTranscodingTrackOutput
This is equivalent to the error suppression for legacy subtitles in
`TextRenderer`:
76088cd6af/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/TextRenderer.java (L357-L359)

This new suppression only affects errors thrown from files with
subtitles muxed together with audio/video. Standalone subtitle
files, and containers containing only text tracks, are handled
by the existing error suppression/reporting added in
49dec5db8b.

Issue: androidx/media#2052
PiperOrigin-RevId: 718930243
2025-01-23 10:49:23 -08:00
Copybara-Service
916018d9fe Merge pull request #1936 from colinkho:eval-buf
PiperOrigin-RevId: 718809019
2025-01-23 04:27:16 -08:00
ibaker
9bb254f697 Skip SSA cues where end time is before or equal to start time
The file in Issue: androidx/media#2052 contains a cue with the following timecode:

```
0:00:00:00,0:00:00:00
```

The content of this cue seems to be some 'converted by' metadata, i.e.
it's basically a comment and clearly not intended to be shown on
screen (since it has zero duration).

There is some fiddly logic later in `SsaParser` to support overlapping
cues with the old `Subtitle` structure [1], and this logic gets tripped
up by the start and end time being equal, which results in a
**single**, empty `List<Cue>` being added - which trips up another
assumption that every SSA cue line results in at least two `List<Cue>`
entries (one containing the cue text, and another containing an empty
list to signal the end of the cues).

This fiddly logic is no longer required, because overlapping
`CuesWithTiming` objects can now be merged in `TextRenderer`, so there
is a possible future simplification to `SsaParser` which removes a lot
of this complexity.

[1] Added in <unknown commit>

PiperOrigin-RevId: 718380386
2025-01-22 07:41:24 -08:00
Colin Kho
8b0cfda178 Move queue reevaluate buffer to only execute when playWhenReady is set to false 2025-01-22 15:18:16 +00:00
Colin Kho
15bdbf735d Reevaluate buffer during a playWhenReady change 2025-01-22 15:18:16 +00:00
ibaker
5421a74d06 Tighten two MediaCodecRenderer fields to @MonotonicNonNull
Remove some `checkNotNull` calls that are no longer needed.

PiperOrigin-RevId: 717597046
2025-01-20 12:14:56 -08:00
sheenachhabra
7c10ef03e4 Check full format support in decoder for Transformer
For the case where a hardware decoder does not fully
support the requested format, a software decoder will
be preferred.

PiperOrigin-RevId: 717584768
2025-01-20 11:27:13 -08:00
kimvde
8abd36fb27 Simplify MediaCodecRenderer.maybeInitializeProcessingPipeline
PiperOrigin-RevId: 717466577
2025-01-20 03:07:59 -08:00
tonihei
190563b8eb Move StreamVolumeManager system calls to playback thread
This requires some additional state handling to update the full
state atomically and guess placeholder states while updates are
in progress, using the newly added BackgroundThreadStateHander.

Some tests also needed to be adjusted to account for the fact
that the actual audio system change doesn't happen inline
anymore.

PiperOrigin-RevId: 716702141
2025-01-17 09:47:33 -08:00
tonihei
a4d9a3e096 Move Wake/WifiLockManager system calls to playback thread
PiperOrigin-RevId: 716235808
2025-01-16 07:58:32 -08:00
Copybara-Service
fda8b8a35d Merge pull request #2023 from DolbyLaboratories:dlb/dovi-format/dev
PiperOrigin-RevId: 716226613
2025-01-16 07:26:46 -08:00
tonihei
4328d29f34 Lazily initialize current audio capabilities in DefaultAudioSink
PiperOrigin-RevId: 716224052
2025-01-16 07:17:26 -08:00
bachinger
b49eaf9e87 Add two MetadataRenderer instances by default
To receive multiple schemes of metadata emitted by a stream, multiple
`MetadataRenderer` instances need to be used. This change makes
`DefaultRenderersFactory` add two metadata renderers by default.

PiperOrigin-RevId: 715790821
2025-01-15 07:31:13 -08:00
michaelkatz
fa4cc7c65c Reduce flakiness for MediaCodecAudioRendererTests past SDK 30
PiperOrigin-RevId: 715770321
2025-01-15 06:15:26 -08:00
michaelkatz
62341f31f9 Reduce flakiness for MediaCodecVideoRendererTests past SDK 30
PiperOrigin-RevId: 715761006
2025-01-15 05:37:40 -08:00
tonihei
a2016f03c6 Remove ExoPlayer components
They have been deprecated since ExoPlayer 2.16.0 and can be easily
replaced by the exact same call in ExoPlayer directly.

PiperOrigin-RevId: 715755105
2025-01-15 05:11:09 -08:00
dancho
ee4a0ea3df Remove deprecated experimentalParseWithinGopSampleDependencies
Remove deprecated API in favor of
experimentalSetCodecsToParseWithinGopSampleDependencies.

PiperOrigin-RevId: 715731718
2025-01-15 03:43:55 -08:00
ibaker
736c7528cb Ignore EOS buffer timestamps in CeaDecoder.queueInputBuffer
This is aligned with the documentation of `MediaCodec` which says the
timestamp of a buffer with `BUFFER_FLAG_END_OF_STREAM` should be
ignored:
https://developer.android.com/reference/android/media/MediaCodec#end-of-stream-handling

Add a test that exercises this by clipping off the end of a sample with
CEA-608 captions, because this creates an EOS-flagged buffer with a
non-EOS timestamp.

Also add a straightforward playback test for the
`fragmented_captions.mp4` sample.

PiperOrigin-RevId: 715716036
2025-01-15 02:40:07 -08:00
michaelkatz
2361624222 Make MediaCodecAudioRenderer.getDurationToProgressUs protected
This method is not intended to be exposed as 'public' as it was meant
to be internal to the class/subclasses.

PiperOrigin-RevId: 715402007
2025-01-14 09:00:37 -08:00
claincly
e9e0569425 Integrate MultiInputVideoGraph in CompositionPlayer
Currently doesn't support image/video transitions

PiperOrigin-RevId: 715393251
2025-01-14 08:33:39 -08:00
dancho
8f17ab84f8 Add API for sample dependency reading to DefaultMediaSourceFactory
PiperOrigin-RevId: 715372196
2025-01-14 07:28:03 -08:00
michaelkatz
2eb8e53f8c Fix getDurationToProgress for audio renderers to reset after seeking
Currently, if a seek occurs when the audio sink was providing back pressure, the audio renderers will provide a durationToProgress based on the last non-writable sample prior to the seek.

Solution is to reset the value used for the `getDurationToProgress` when onPositionReset occurs.

This CL also makes sure to reset the value whenever the audiosink is flushed or reset.

PiperOrigin-RevId: 715361834
2025-01-14 06:49:43 -08:00
tianyifeng
f05e6a7d6e Accurately determine hasPendingData after handling the end of stream
In `AudioTrackPositionTracker.hasPendingData()` method, `sourceEnded=false` is always passed. Thus, if the `AudioTimestampPoller` hasn't entered the `STATE_TIMESTAMP_ADVANCING` before the stream ends, then the current position can be inaccurately calculated in the absence of a correct `sourceEnded` value, and `AudioTrackPositionTracker.hasPendingData` will return a wrong result.

We used to avoid calling `getPlayheadPosition()` too often, which involves expensive binder request. However, here we need to adjust a bit back to compare the `writtenFrames` directly with `getPlayheadPosition()` after handling the end of stream, when not being able to declare `sourceEnded=true` can have significant difference.

PiperOrigin-RevId: 715358137
2025-01-14 06:37:02 -08:00
ibaker
eefad8cbfa Deprecate mutable static MediaParserChunkExtractor.FACTORY
Follow-up to <unknown commit>

PiperOrigin-RevId: 715329316
2025-01-14 04:46:32 -08:00
ibaker
6300a55eb2 Remove usage of mutable static BundledChunkExtractor.FACTORY
PiperOrigin-RevId: 715328246
2025-01-14 04:42:20 -08:00
dancho
1892435fb3 Parse within GOP sample dependencies in ExtractorsFactory
Add helper methods to Mp4Extractor and FragmentedMp4Extractor
to convert between VideoCodecFlags and *ExtractorFlags

PiperOrigin-RevId: 715307495
2025-01-14 03:16:49 -08:00
ibaker
a4d28b4f10 Add PGS test file
Transformed from `sample_with_srt.mkv` and provided in
https://github.com/androidx/media/pull/1979#issuecomment-2574007148

PiperOrigin-RevId: 714955725
2025-01-13 07:14:13 -08:00
Copybara-Service
d18ad57e30 Merge pull request #1979 from wischnow:main
PiperOrigin-RevId: 714911017
2025-01-13 04:09:58 -08:00
dancho
8b33a0a50f Add a ChunkExtractor API to select codecs for sample dependency parsing
Deprecate BundledChunkExtractor.experimentalParseWithinGopSampleDependencies
in favour of
ChunkExtractor.experimentalSetCodecsToParseWithinGopSampleDependencies
which takes a VideoCodecFlags IntDef flags that represent a set of codecs.

Add a DASH test using the new API with an H.265 video.

PiperOrigin-RevId: 714901602
2025-01-13 03:30:10 -08:00
Ian Baker
6658dc097b Rename new fixed test file to old name, and add output dump 2025-01-10 16:02:24 +00:00
Sven Wischnowsky
0254b2d16e Add Vobsub sample file 2025-01-10 16:02:24 +00:00
tonihei
c3b13a60a3 Mark internal BasePlayer.seekTo method as @ForOverride
This method is not meant to be called directly, it only needs to
be implemented by subclasses.

PiperOrigin-RevId: 714000806
2025-01-10 04:32:32 -08:00
tonihei
f6eb2e6dd5 Fix discontinuity reporting in ClippingMediaPeriod
The initial discontinuity is currently only reported if
the period is prepared at the clip start position. However,
we need the discontinuity whenever we prepare at a non-zero
position (unless we know all samples are sync samples).

PiperOrigin-RevId: 713994155
2025-01-10 04:04:03 -08:00
tonihei
b225383958 Don't force discontinuity when clipping a merged source duration
We only care about the duration and don't want to force an initial
discontinuity.

The problem is not currently visible due to a bug in
ClippingMediaPeriod that ignores all dicontinuities if they don't
happen at the clip start position.

PiperOrigin-RevId: 713686333
2025-01-09 08:47:33 -08:00