5579 Commits

Author SHA1 Message Date
sheenachhabra
a31c7ad9a8 Move Muxer.java interface into transformer module
Muxer interface is used only in transformer.

PiperOrigin-RevId: 717538306
2025-01-20 08:13:42 -08:00
sheenachhabra
fb58bdfd52 Refactor: Mp4Muxer and FragmentedMp4Muxer no longer implement Muxer
Mp4Muxer and FragmentedMp4Muxer has different contracts
and they can not implement same interface.

PiperOrigin-RevId: 717526288
2025-01-20 07:20:48 -08:00
sheenachhabra
c22798f99c Removing redundant call to setLastSampleDurationBehavior on muxer
The default value is already
LAST_SAMPLE_DURATION_BEHAVIOR_SET_FROM_END_OF_STREAM_BUFFER_OR_DUPLICATE_PREVIOUS

PiperOrigin-RevId: 717497116
2025-01-20 05:14:47 -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
sheenachhabra
c797249998 Move supported sample mime types list in specific muxer
This will reduce the risk of list becoming stale
(its already stale, to be fixed).

PiperOrigin-RevId: 716685242
2025-01-17 08:51:44 -08:00
claincly
a0618eb0ec Adds a test on using composition level effects
Also simplifies the test a bit.

PiperOrigin-RevId: 716683585
2025-01-17 08:46:44 -08:00
sheenachhabra
4ac4f7e2e0 Split InAppMuxer into InApp Mp4Muxer and FragmentedMp4Muxer
This is pre work required to remove `Muxer.java` interface
from the muxer module.
`Mp4Muxer` and `FragmentedMp4Muxer` will no longer implement
the `Muxer` interface.

PiperOrigin-RevId: 716669531
2025-01-17 08:01:28 -08:00
tonihei
a4d9a3e096 Move Wake/WifiLockManager system calls to playback thread
PiperOrigin-RevId: 716235808
2025-01-16 07:58:32 -08:00
tonihei
297b2b9956 Add util to handle background state updates and placeholder states.
This is a common pattern in media3 libraries where tasks are handled on a
background thread, but the calling thread sees an immediate state update
with a best-guess placeholder. This makes the integration for the caller
very easy as the API surface appears to be synchronous.

This util is a helper class to handle this logic and test it separately.

PiperOrigin-RevId: 716233966
2025-01-16 07:53:15 -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
claincly
1732892927 Add tests for multi input video
PiperOrigin-RevId: 716208222
2025-01-16 06:19:47 -08:00
kimvde
b2c31b0743 Small nits in SequenceRenderersFactory
PiperOrigin-RevId: 716187537
2025-01-16 04:56:49 -08:00
claincly
0d8e42238e Stop checking all inputs ended when releasing compositor
This could happen when the player is released before ending so not all input
has ended.

PiperOrigin-RevId: 716173884
2025-01-16 04:11:21 -08:00
shahddaghash
f5f5b63bf7 Pass video data space to MediaItemInfo
The `DataSpace` contains the Color Standard, Range, and Transfer. These values were mapped as follows:
* Standard: From `@C.ColorSpace` to `@DataSpace.DataSpaceStandard`
* Range: From `@C.ColorRange` to `@DataSpace.DataSpaceRange`
* Transfer: From `@C.ColorTransfer` to `@DataSpace.DataSpaceTransfer`

PiperOrigin-RevId: 716157142
2025-01-16 03:03:19 -08:00
Googler
492574bded Rollback of 871381288c
PiperOrigin-RevId: 715891934
2025-01-15 12:08:40 -08:00
shahddaghash
e9b82ee951 Pass video frame rate and video size to MediaItemInfo
The frame rate, height, and width are extracted from the format of processedInput.

PiperOrigin-RevId: 715843086
2025-01-15 10:09:12 -08:00
shahddaghash
04c2d22178 Pass containerMimeType and sampleMimeType to MediaItemInfo
If a format is passed to `ExportResult.ProcessedInput`, the `containerMimeType` and `sampleMimeType` are extracted from the Format and passed inside the `MediaItemInfo` object.

PiperOrigin-RevId: 715840400
2025-01-15 10:03:57 -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
dancho
0936b549ae Enable non-reference frame skipping in FrameExtractor
Speed up FrameExtractor for videos with non-ref frames

PiperOrigin-RevId: 715789816
2025-01-15 07:27:54 -08:00
kimvde
c5feb28838 Increase FrameExtractorTest timeout
FrameExtractorTest.extractFrame_pastDuration_returnsLastFrame is
sometimes timing out on emulator because it's too slow.

PiperOrigin-RevId: 715771071
2025-01-15 06:18:10 -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
Googler
2b9c7f8392 Add minimum size for OpusDecoder's streamMap.
PiperOrigin-RevId: 715453498
2025-01-14 11:17:09 -08:00
shahddaghash
465399b57e Disable default collection of platform diagnostics
This is to prevent facing errors in apps using Transformer. It will be enabled again once the project is done and comprehensive tests are added.

PiperOrigin-RevId: 715435613
2025-01-14 10:33:50 -08:00
sheenachhabra
1b2e391971 Change muxer instrumentation tests to robolectric
These tests were earlier using `MediaExtractor`, hence
they were in androidTest. Now `MediaExtractor` has been
replaced with `media3 MediaExtractorCompat` so these
test can be robolectric.

PiperOrigin-RevId: 715424470
2025-01-14 10:09:25 -08:00
kimvde
fbf9be2f00 Fix composition player repeat mode
Some checks in SingleInputVideoGraph were causing CompositionPlayer to
throw for a single media item sequence when repeat mode was enabled. The
reason was that, in this case, no new input stream is registered to the
VideoFrameProcessor.

PiperOrigin-RevId: 715409509
2025-01-14 09:20:14 -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
shahddaghash
adb9306e2d Add format of media item to Transformer's ExportResult.ProcessedInput
This will allow us to collect info from the Format for metrics.

PiperOrigin-RevId: 715336943
2025-01-14 05:16:08 -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
shahddaghash
b25d6ef249 Rollback of 72a71e8b9c
PiperOrigin-RevId: 714997645
2025-01-13 09:30:39 -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
jbibik
52387bb975 [ui-compose] Rename showSurface to coverSurface in PresentationState
This renaming helps prevent the consumer from including `PlayerSurface` in a Compose tree based on `state.showSurface`. This field intuitively felt like the default would be not to show the surface (correct), but had an unintended consequence of not initialising `AndroidExternal(Embedded)Surface` (since the PlayerSurface Composable would be omitted).

To avoid this confusion, the `PresentationState` should communicate to the consumer when the Surface is not ready and hence should be covered with some overlay (shutter) to prevent poor UX from observing Surface resizing/freezing/flickering.

PiperOrigin-RevId: 714951607
2025-01-13 06:59:44 -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
andrewlewis
0a27e7946f When reregistering frames automatically, drop after signaling EOS
In this mode there isn't an explicit signal from upstream that an input frame
is going to arrive at the `SurfaceTexture`. This means that when end-of-stream
is signaled we don't know when there won't be any more input frames.

Reject new frames in `onFrameAvailable` after input EOS is handled for the case
of reregistering frames automatically. This avoids those frames entering the
pipeline and causing us to unexpectedly handle frames after EOS.

PiperOrigin-RevId: 714858039
2025-01-13 00:43:45 -08:00
kimvde
b183bfb0cb CompositionPlayerTest: use correct video duration
PiperOrigin-RevId: 714847208
2025-01-13 00:01:42 -08:00
sheenachhabra
36be62ee8c Skip duplicate chunks in stsc box writing
Earlier muxer wrote a different entry for every chunk but as
per the spec (ISO 14496-12) exact same chunks can be combined
and only the first chunk number can be written.

PiperOrigin-RevId: 714154531
2025-01-10 13:27:02 -08:00
jbibik
28027c64fd [ui-compose] Add aspect ratio to PresentationState
It captures the information needed for the UI logic related to rendering of the video track (and later images) to the surface.

The video size will be correct only after the Player decoded the video onto the surface and can't be reliably extracted from MediaItem's metadata. The information about the video's true aspect ratio helps inform the UI elements (such as PlayerSurface Composable) how to customize the Modifiers.

Use this state in demo-compose to show off functionality of changing `PlayerSurface`'s aspectRatio

PiperOrigin-RevId: 714104260
2025-01-10 10:50:53 -08:00
sheenachhabra
33c3d5140e Rollback of 750baf2c05
PiperOrigin-RevId: 714097260
2025-01-10 10:34:56 -08:00