21647 Commits

Author SHA1 Message Date
rohks
52e45e0864 Prepare for CryptoInfo support by removing cached size
Currently, `size` is cached in `SampleMetadata` when samples are committed in `SampleQueue`, which worked because we didn't support reading files with `CryptoInfo`. This change prepares for future `CryptoInfo` support, as the size changes when reading samples with encrypted data. Caching the size at commit time could lead to incorrect buffer `size` calculations.

Existing tests verify the correctness of the `getSampleSize()` API.

PiperOrigin-RevId: 700714178
2024-11-27 08:47:37 -08:00
Copybara-Service
bff5523bb6 Merge pull request #1823 from MGaetan89:remove_outdated_sdk_check
PiperOrigin-RevId: 700706152
2024-11-27 08:16:02 -08:00
ibaker
60133b0c7e Recommend ForwardingSimpleBasePlayer in ForwardingPlayer javadoc
Also add an explicit warning about how fiddly `ForwardingPlayer` can be
to use correctly.

PiperOrigin-RevId: 700698032
2024-11-27 07:42:24 -08:00
rohks
a371824dbc Remove unnecessary @SuppressLint("Override")
The Android SKD version 30 is stable, allowing us to remove the `@SuppressLint("Override")` annotations from `InputReaderAdapterV30` and `OutputConsumerAdapterV30`.

PiperOrigin-RevId: 700681115
2024-11-27 06:32:24 -08:00
ibaker
6cf3004d62 Bump IMA dependency to 3.35.1
The previous version (3.33.0) is known to have some bugs, and the latest
version (3.36.0) is also known to be buggy.

PiperOrigin-RevId: 700657484
2024-11-27 04:56:28 -08:00
shahddaghash
d5d5771cd2 Add custom MediaSource.Factory attribute to CompositionPlayer
Introduced a `mediaSourceFactory` attribute to CompositionPlayer. This allows for the use of a custom MediaSource.Factory when creating media sources, providing more flexibility and control over media source creation. Previously, the default `MediaSource.Factory` was used in all cases.

PiperOrigin-RevId: 700391911
2024-11-26 10:48:22 -08:00
claincly
96c35966d8 Remove unnecessary parentherses
PiperOrigin-RevId: 700356007
2024-11-26 08:49:20 -08:00
claincly
de76d7932f Add missing test cases in SeekTest
PiperOrigin-RevId: 700354445
2024-11-26 08:43:06 -08:00
ibaker
465873ac28 Add androidx.compose.foundation:foundation to deps with AAR files
Also remove a dependency that is no longer used.

PiperOrigin-RevId: 700341461
2024-11-26 07:55:29 -08:00
ibaker
b19b6ccc60 MP3 VBRI: Use sampleCountToDurationUs() and samplesPerFrame
PiperOrigin-RevId: 700340564
2024-11-26 07:52:18 -08:00
ibaker
46578ee0a6 MP3: Use bytes field from VBRI frame instead of deriving from ToC
The previous code assumed that the `VBRI` Table of Contents (ToC)
covers all the MP3 data in the file. In a file with an invalid VBRI ToC
where this isn't the case, this results in playback silently stopping
mid-playback (and either advancing to the next item, or continuing to
count up the playback clock forever). This change considers the `bytes`
field to determine the end of the MP3 data, in addition to deriving it
from the ToC. If they disagree we log a warning and take the max value.
This is because we handle accidentally reading non-MP3 data at the end
(or hitting EoF) better than stopping reading valid MP3 data partway
through.

Issue: androidx/media#1904

#cherrypick

PiperOrigin-RevId: 700319250
2024-11-26 06:18:29 -08:00
claincly
2a4bae01ef Add two missing test cases in seeking
PiperOrigin-RevId: 700284751
2024-11-26 03:44:23 -08:00
claincly
e357629400 Make back button pause player instead of quitting app
PiperOrigin-RevId: 700282443
2024-11-26 03:33:45 -08:00
ibaker
f257e5511f MP3: Exclude VBRI frame from ToC position calculations
The current code assumes that the first Table of Contents segment
includes the `VBRI` frame, but I don't think this is correct and it
should only include real/audible MP3 ata - so this change updates the
logic to assume the first ToC segment starts at the frame **after** the
`VBRI` frame.

Issue: androidx/media#1904

#cherrypick

PiperOrigin-RevId: 700269811
2024-11-26 02:34:33 -08:00
kimvde
6a3def3ccb Turn off repeat mode on Composition demo app
This is to make debugging easier.

PiperOrigin-RevId: 700265039
2024-11-26 02:14:04 -08:00
Gaëtan Muller
2fc379a61b Fix documentation for Format.Builder.setTileCountHorizontal and Format.Builder.setTileCountVertical 2024-11-26 10:05:16 +00:00
ibaker
3eb36d67bd Add MP3 test asset with VBRI frame
This was hand-crafted with a 4-entry ToC by modifying
`bear-vbr-xing-header.mp3` in a hex editor.

The output difference from 117 samples to 116 samples is due to the
calculation in `VbriSeeker` assuming that the ToC includes the VBRI
frame itself, which I don't think is correct (fix is in a follow-up
change).

Issue: androidx/media#1904

#cherrypick

PiperOrigin-RevId: 700254516
2024-11-26 01:33:39 -08:00
dancho
bb20eb4975 Frame Extractor HDR: tone map to SDR
Support extracting frames from HDR input by tone mapping
to SDR (BT.709).

ExperimentalFrameExtractor must be public because HDR tests
live in a different package.

PiperOrigin-RevId: 699994112
2024-11-25 08:41:42 -08:00
dancho
0d8f1d5ab9 Add Frame Extractor configuration for mediacodecselector
Adds a configuration option to Frame Extractor to choose MediaCodecSelector.
Add a MediaCodecSelector that lists software decoders first

PiperOrigin-RevId: 699962365
2024-11-25 06:40:28 -08:00
claincly
7ef1a7ab8b Support renderer joining in CompositionPlayer
Renderers join when they can start processing but not produce output.

In CompositionPlayer before this change, the VideoSink will be flushed when
position is reset regardless. This is useful for seeking, as seeking triggers position reset. But with pre-warming, a video renderer can be joining -  it is
enabled (which also triggers position reset) before the previous image renderer
is disabled. At this moment, as the image renderer is still producing frames,
we should not flush the video sink just now.

PiperOrigin-RevId: 699943882
2024-11-25 05:22:22 -08:00
kimvde
25a782e10a Stop delaying registering input stream on VideoFrameProcessor
We are currently waiting until stream 1 is completely rendered on screen
before registering stream 2 but that is not necessary anymore because
VideoFrameProcessor supports registering stream 2 before stream 1 is
fully processed.

PiperOrigin-RevId: 699929943
2024-11-25 04:17:32 -08:00
dancho
c0fb4b7aff Composition demo app: show extended brightness
Request COLOR_MODE_HDR and show HDR content
as brighter-than-SDR.

PiperOrigin-RevId: 699887643
2024-11-25 01:22:54 -08:00
ibaker
827966b7a4 Add pixel aspect ratio to Format.toLogString
#cherrypick

PiperOrigin-RevId: 698770714
2024-11-21 07:21:11 -08:00
shahddaghash
73c4bb6e1f Bump Media3 version to 1.5.0
PiperOrigin-RevId: 698761734
2024-11-21 06:47:36 -08:00
kimvde
52dfe25542 Fix flushing issue in DefaultVideoFrameProcessor
Before this CL, the following scenario could happen:
- A new input stream is registered to the DefaultVideoFrameProcessor.
- Before the pipeline is reconfigured, a seek is issued andd the
  DefaultVideoFrameProcessor is flushed.
- As a result, the new input stream registration is never taken into
  account.

As a result:
- If an input stream is registered after the seek (before queueing any
  frame), registerInputStream will block indefinitely because
  inputStreamRegisteredCondition will be closed.
- If a frame is queued after the seek, it will be linked to the input
  stream information of the previous frames.

This CL makes sure that any pending input stream is registered after a
flush.

PiperOrigin-RevId: 698736866
2024-11-21 05:00:32 -08:00
kimvde
79effe7b60 Remove call to getFrameReleaseAction prior to applying effects
This call does 2 things:
1. It's used to estimate the frame rate early but this is incorrect as
   the frame rate can be changed by effects. I have tested playback on
   my device and I don't see any difference.
2. For ExoPlayer.setVideoEffects() only: it allows dropping all the
   frames until the next key frame in case the input frame is "very
   late". This doesn't seem really necessary though because because we
   do the same thing after applying effects.

This change is also a step towards moving all the calls to
VideoFrameRelease/RenderControl to DefaultVideoSink.

PiperOrigin-RevId: 698732161
2024-11-21 04:38:54 -08:00
michaelkatz
5282fe3125 Rollback of 854566dbfe
PiperOrigin-RevId: 698730105
2024-11-21 04:29:19 -08:00
shahddaghash
754dfd76c8 Simplify use of defaultMediaSourceFactory in CompositionPlayer
Changes includes making sure the same `defaultMediaSourceFactory` is used when creating a new media source in `setPrimaryPlayerSequence` and `setSecondaryPlayerSequence`.
This is pre-work for introducing a new attribute `mediaSourceFactory` that can be optionally used instead of the default one. This will allow developers to pass a customized media source factory to CompositionPlayer.

PiperOrigin-RevId: 698721139
2024-11-21 03:52:58 -08:00
shahddaghash
e5110e6442 Merge release notes for media3 1.5.0 stable release
PiperOrigin-RevId: 698713460
2024-11-21 03:16:14 -08:00
sheenachhabra
407bc4fec9 Manage all color value conversions in ColorInfo class
This CL also aligns supported color space in `media3 common` and `media3 muxer`.

Earlier `muxer` would take even those values which are considered invalid
in `media3` in general.

Earlier muxer would throw if a given `color standard` is not recognized
but with the new change, it will rather put default `unspecified` value.

#cherrypick

PiperOrigin-RevId: 698683312
2024-11-21 01:09:02 -08:00
Copybara-Service
089eaa1d5d Merge pull request #1898 from DolbyLaboratories:dlb/ac4-level4-dash/dev
PiperOrigin-RevId: 698456089
2024-11-20 11:18:59 -08:00
shahddaghash
cf4488aa1f Move misplaced release note to Unreleased changes section
PiperOrigin-RevId: 698426838
2024-11-20 10:01:03 -08:00
dancho
d92c9aa8a1 Add a Frame Extractor test with rotated input
Adds a Frame extractor test that verifies decoder
respects rotation metadata from the mp4 container.

Do not rely on the MediaCodec decoder rotate the input.
Rotate via a video effect instead.

PiperOrigin-RevId: 698381282
2024-11-20 07:20:50 -08:00
ivanbuper
66e8b53b43 Make SpeedChangingAudioProcessor direct subclass of AudioProcessor
This non-functional refactor inlines and simplifies the logic of
`BaseAudioProcessor` used by `SpeedChangingAudioProcessor`, and makes
the latter implement `AudioProcessor` directly.

`SpeedChangingAudioProcessor` acts as a wrapper over
`SonicAudioProcessor` and does not actually modify any samples,
so it had very little use for the affordances provided by
`BaseAudioProcessor`.

PiperOrigin-RevId: 698342962
2024-11-20 04:27:27 -08:00
claincly
3c01500a4e Use dynamic scheduling to speed up rendering the first image frame
3P app reported it's slow to see the first image frame on the screen, when
`playWhenReady` is false. This is because the player would wake up less
frequently when `playWhenReady` is false. This CL adds a runnable to wake up
the player any time a new frame is made available.

PiperOrigin-RevId: 698066887
2024-11-19 10:33:59 -08:00
dancho
dc7a0ca22f Move SDK == 33 tests to SDK 33+
Ensure tests run on any recent emulator.

PiperOrigin-RevId: 698015529
2024-11-19 07:55:32 -08:00
ivanbuper
646a6352a2 Remove bypass of SonicAudioProcessor in SpeedChangingAudioProcessor
SpeedChangingAudioProcessor is redundantly bypassing SonicAudioProcessor
when the speed is set to 1f. SpeedChangingAudioProcessor should not make
assumptions about the underlying audio processing and moreover should
not be bypassing any AudioProcessor based on parameter values. Default
parameter values are a valid state for an active AudioProcessor.

Sonic already handles the "default case" state by just copying the input
buffer onto the output buffer.

This CL also simplifies SonicAudioProcessor, which would mark itself as
inactive when configured with a valid set of default parameters. The API
contract for `isActive()` makes no mention about parameter state, which
makes changes in `isActive()` after applying new valid parameters quite
unintuitive.

PiperOrigin-RevId: 698000500
2024-11-19 07:02:20 -08:00
rohks
d702e1d496 Add getPsshInfo() API to MediaExtractorCompat
This method retrieves PSSH (Protection System Specific Header) data from the media as a map of UUID-to-bytes.

PiperOrigin-RevId: 697974134
2024-11-19 05:14:55 -08:00
bachinger
b9c9d95b90 Add JSON asset list parser
PiperOrigin-RevId: 697966021
2024-11-19 04:41:17 -08:00
Copybara-Service
98723dc0a8 Merge pull request #1888 from DolbyLaboratories:dlb/dash-parser/dev
PiperOrigin-RevId: 697956473
2024-11-19 04:01:30 -08:00
dancho
ccc7b22ff4 Implement custom Frame Extractor renderer
Render only one frame per seek to reduce the amount of work done

PiperOrigin-RevId: 697946350
2024-11-19 03:14:57 -08:00
dancho
26f10effc2 Add frame extractor tests for decoder counters.
Right now, decoders produce an unspecified (but large)
number of frames. This will be resolved in a follow-up

PiperOrigin-RevId: 697945076
2024-11-19 03:10:17 -08:00
bachinger
c7ca9fbe7d Sanitize duration parsing for HLS interstitials
PiperOrigin-RevId: 697941445
2024-11-19 02:54:53 -08:00
kimvde
b782cdff52 Don't drop frames to ignore in RenderControl
The following was happening:
- VideoFrameRenderControl.render() was calling
VideoFrameReleaseAction.getFrameReleaseAction().
- VideoFrameReleaseAction.getFrameReleaseAction() was calling
FrameTimingEvaluator.shouldIgnoreFrame(), which is implemented in
MediaCodecVideoRenderer.
- MediaCodecVideoRenderer.shouldIgnoreFrame(), when returning true,
was also flushing the VideoSink, which was flushing the
VideoFrameRenderControl.
- VideoFrameRenderControl.render() was removing the frame from the
presentationTimestampsUs queue, but the frame had already been removed
by the flush operation, causing an exception to be thrown.

This fix removes the last step.

PiperOrigin-RevId: 697915692
2024-11-19 01:15:17 -08:00
claincly
9c6d9e9e47 Reduce test name lengths
Some parametrized names are too long (>255 chars). Remove putting parameter
info in the test name and instead log them.

PiperOrigin-RevId: 697677513
2024-11-18 10:34:06 -08:00
bachinger
9ae136becb Add context as a parameter to shouldStartForegroundService
Issue: androidx/media#1887
PiperOrigin-RevId: 697650546
2024-11-18 09:15:46 -08:00
ivanbuper
fff6e2e169 Fix incorrect Media3 1.5.0-rc01 release notes
PiperOrigin-RevId: 697626185
2024-11-18 07:57:57 -08:00
ibaker
66ec022bf0 Fix broken anchor in 1.5.0-rc02 release notes
PiperOrigin-RevId: 697596494
2024-11-18 05:54:28 -08:00
kimvde
8be2556efd Implement DefaultVideoSink.setStreamTimestampInfo
To do this, refactor stream start position handling so that
VideoFrameRenderControl is only passed a start position when it should
be applied, and therefore doesn't need to take a timestamp associated
with each start position anymore

PiperOrigin-RevId: 697544416
2024-11-18 02:01:52 -08:00
kimvde
2568ff73cb Remove unnecessary checkStateNotNull checks
LongArrayQueue.remove() throws a NoSuchElementException if the queue is
empty.

PiperOrigin-RevId: 697531458
2024-11-18 01:05:34 -08:00