21843 Commits

Author SHA1 Message Date
dancho
229aadc91b Update javadoc for FLAG_READ_WITHIN_GOP_SAMPLE_DEPENDENCIES
Reflects that FLAG_READ_WITHIN_GOP_SAMPLE_DEPENDENCIES only parses
H.264 bitstream, and that H.265 parsing will be controlled with
another flag.

PiperOrigin-RevId: 712921990
2025-01-07 08:33:14 -08:00
bachinger
ec50358784 Do not override pending info when masking
PiperOrigin-RevId: 712919739
2025-01-07 08:26:19 -08:00
andrewlewis
e11aabb794 Allow RawAssetLoader media to have unset duration
This will be useful for recording use cases, including screen recording with
audio queued via `RawAssetLoader`, where the duration is unknown.

PiperOrigin-RevId: 712895577
2025-01-07 06:59:21 -08:00
ivanbuper
871381288c Use static methods for getSpeedAdjustedTimeAsync and getMediaDurationUs
This change simplifies SpeedChangingAudioProcessor by removing unneeded
heuristics and synchronization added as workarounds to estimate input
and output frame counts.

The synchronization between the video processing and audio processing
threads cannot be completely removed yet because the static methods
depend on the input sample rate for the calculations. However, once
`SpeedChangingAudioProcessor` has been configured, then
`#getSpeedAdjustedTimeAsync()` should invoke the callback immediately.

PiperOrigin-RevId: 712893246
2025-01-07 06:49:49 -08:00
jbibik
2dc6af1fae [ui-compose] Add PresentationState for first-frame info
It captures some information needed for the UI logic related to rendering of the video track (and later images) to the surface.

Supporting `EVENT_RENDERED_FIRST_FRAME` helps improve the UX by covering the surface with an overlay (scrim/shutter) until the first frame is ready. This helps avoid sudden flickering during MediaItem transitions.

PiperOrigin-RevId: 712889568
2025-01-07 06:34:02 -08:00
ibaker
31e5142b72 Restrict SubRip and WebVTT parsing to exactly 3 decimal places
We previously parsed an arbitrary number of decimal places, but assumed
the value was in milliseconds, which doesn't make sense if there is
greater or fewer than 3. This change restricts the parsing to match
exactly 3, meaning the millisecond assumption is always true.

The WebVTT spec requires there to be exactly 3 decimal places:
https://www.w3.org/TR/webvtt1/#webvtt-timestamp

The SubRip spec is less clearly defined, but the Wikipedia article
defines it as having exactly 3 decimal places
(https://en.wikipedia.org/wiki/SubRip#Format) and ExoPlayer has always
assumed 3 decimal places (anything else is already handled incorrectly),
so this change just ensures we don't show subtitles at the wrong time.

Issue: androidx/media#1997
PiperOrigin-RevId: 712885023
2025-01-07 06:13:15 -08:00
andrewlewis
9ac91aaadd Return concrete SurfaceAssetLoader from factory
If the caller is another asset loader (or another asset loader factory) that is
delegating to a `SurfaceAssetLoader`, it may want to call methods on the
`SurfaceAssetLoader`. Return the concrete type so that a cast isn't necessary
at the call site.

PiperOrigin-RevId: 712881130
2025-01-07 06:02:24 -08:00
Copybara-Service
38363acc8d Merge pull request #1785 from DolbyLaboratories:dlb/dovi-supplemental-codecs/dev
PiperOrigin-RevId: 712867412
2025-01-07 04:58:21 -08:00
tonihei
a9f9928eb3 Temporarily remove test class to avoid build breakage
PiperOrigin-RevId: 712862960
2025-01-07 04:40:28 -08:00
andrewlewis
5a87aab2f7 Use Util to request permissions in Transformer demo
This avoids requesting storage permissions for URLs that don't require it.

Also tidy clean-up into `cleanUpExport`, rename `releasePlayer` to
`releasePlayers` as there are players for both input and output, and reduce
live range of `uri` variable.

PiperOrigin-RevId: 712857115
2025-01-07 04:13:36 -08:00
shahddaghash
0074a97333 Remove unnecessary released condition in getProgress
Removed the check for `released` flag to be able to pass the actual progress when the export completes.

Also, removed resetting the `progressState` and `progressValue` to be able to get the actual progress. This block is also not necessary to have at this point.

PiperOrigin-RevId: 712851526
2025-01-07 03:53:06 -08:00
andrewlewis
0044d0cebc Fix GLES31 javadoc reference to be unambiguous and link correctly
PiperOrigin-RevId: 712848161
2025-01-07 03:35:30 -08:00
Googler
b2aa8d6d21 Add sample rate fallback to AudioSampleExporter
After this change, if the sample rate supported by the encoder differs from the requested sample rate and enableFallback is true, the AudioSampleExporter will convert audio to a sample rate supported by the encoder. This fixes a bug where the audio track is distorted when an unsupported sample rate is requested.

PiperOrigin-RevId: 712822358
2025-01-07 01:52:57 -08:00
Googler
6c2d25184c Make FragmentedMp4Muxer use OutputStream instead of FileOutputStream.
This lets us provide a append-only output stream with overridden write() methods - unlocking use cases where we process the muxed data in a streaming fashion, as it's generated by the fragmented muxer.

PiperOrigin-RevId: 712581859
2025-01-06 10:46:00 -08:00
jbibik
575a2ebbd8 [ui-compose] Add gradle version to androidx.compose.foundation
This will ensure that the new `ui-compose` module gets published on Maven

The fix is not necessary for `demo-effect` and `demo-compose` because they are not publishable

PiperOrigin-RevId: 712555702
2025-01-06 09:34:44 -08:00
Copybara-Service
8fe0b7ac69 Merge pull request #1987 from ojoNetgem:Support_for_origin_and_extent_declared_in_ttml_styles
PiperOrigin-RevId: 712554507
2025-01-06 09:30:15 -08:00
jbibik
ff80ab220f [demo-compose] Add Activity lifecycle methods
Take care of releasing the player and re-initialising when returning to the app to prevent memory leaks.

Instead of overriding onStart, onPause, onResume, onStop - use Lifecycle*Effects for a more native compose cleanup. Requires a higher version of the lifecycle library.

PiperOrigin-RevId: 712542884
2025-01-06 08:49:41 -08:00
Ian Baker
8d9cb7e5d0 Resolve some TODO comments that are now fixed by the new parsing support 2025-01-06 15:13:32 +00:00
Ian Baker
618c2cf952 Add a release note and format with google-java-format 2025-01-06 15:13:32 +00:00
Olivier Jouvenaux
82bed39140 Add unit tests for TTML region attrs in style, chained styles UT 2025-01-06 15:13:32 +00:00
Olivier Jouvenaux
026700a9d9 Add unit tests for region attrs in style 2025-01-06 15:13:32 +00:00
Olivier Jouvenaux
fbd6dfa439 Add support for TTML origin and extent attributes defined in style instead of region 2025-01-06 15:13:32 +00:00
jbibik
d8333b37cf Upgrade compose bom to 2024.12.01
The latest version of `androidx.compose.foundation:foundation` fixed an issue where `AndroidEmbeddedExternalSurface` would not reset properly. This in turn prevented PlayerSurface Composable with type `SURFACE_TYPE_TEXTURE_VIEW` from being redrawn after returning to a stopped activity.

PiperOrigin-RevId: 712501647
2025-01-06 06:05:30 -08:00
jbibik
d01d10ce0e [demo-compose] Refactor MediaPlayerScreen() into ComposeDemoApp()
PiperOrigin-RevId: 712495147
2025-01-06 05:33:32 -08:00
Copybara-Service
871c15946b Merge pull request #1947 from totallyunknown:fix/dash-playlist-infinite-loop
PiperOrigin-RevId: 712494399
2025-01-06 05:28:26 -08:00
shahddaghash
115f09dd6d Report ErrorCode and elapsed time metrics for Transformer
Added reporting 2 values from Transformer:
- elapsed time since creation of the `editingSession` in milliseconds.
- the `ErrorCode` for export errors. The error codes were mapped from `@ExportException.ErrorCode` int to `@EditingEndedEvent.ErrorCode`.

PiperOrigin-RevId: 712472849
2025-01-06 03:55:32 -08:00
sheenachhabra
750baf2c05 Rollback of 9cc4532f84
PiperOrigin-RevId: 711804077
2025-01-03 11:18:03 -08:00
ivanbuper
7ecaebe3d6 Fix underflow in Sonic#getOutputSize() after #queueEndOfStream()
For the [0.5; 1) speed range, the combination of having a "slow down"
speed (i.e. more output frames than input frames), and Sonic potentially
needing to copy more input frames that are available in the input buffer
can lead to an unexpected underflow.

Specifically, the underflow happens in Sonic#queueEndOfStream() when the
following conditions are met (skipping some minor ones):

1. `inputFrameCount < remainingInputToCopyFrameCount`
2. `0.5f <= speed < 1`.
3. `outputFrameCount <
    (inputFrameCount / remainingInputToCopyFrameCount) / 2`.

This underflow caused `SonicAudioProcessor#isEnded()` to return a false
negative (because `getOutputSize() != 0`), which would stall the
`DefaultAudioSink` waiting for processing to end after EOS.

In practical terms, the underflow is relatively easy to reproduce if we
consume all of Sonic's output and then immediately queue EOS without
queueing any more input in between. This should cause both
`inputFrameCount` and `outputFrameCount` to drop to 0.

PiperOrigin-RevId: 711773565
2025-01-03 09:26:32 -08:00
shahddaghash
cd5d5bde27 Implement basic Metrics Collector in Transformer
Added a new `EditingMediaMetrics` class that interacts with the platform's `MediaMetricsManager` through an `EditingSession` created when export starts.

Currently, only the `finalState` of the export event is reported to the `EditingSession`. Future changes will collect additional metrics based on the export operation's output.

PiperOrigin-RevId: 711721801
2025-01-03 05:27:20 -08:00
dancho
9b71f2a3ba Mp4Extractor: allow zero length NAL units
Some videos include zero length NAL units in the
length-delimited MP4 samples.
Empty NAL units are not spec-compliant (see ISO/IEC 14496-15 section 4.3.3.3),
but other players are able to play these videos (with warnings or errors).

With this change, we check track.sampleTable.sizes[sampleIndex] before
reading a byte from the NAL unit itself.

PiperOrigin-RevId: 711720621
2025-01-03 05:21:10 -08:00
ivanbuper
682889f91d Implement Sonic method to get input frame count from output frame count
The static method can estimate the number of input frames needed to get
a given number of output frames with a given Sonic configuration.

This CL is prework to remove the dependency of
`SpeedChangingAudioProcessor#getMediaDurationUs()` on non-static output
based heuristics and simplify `SpeedChangingAudioProcessor`.

PiperOrigin-RevId: 711446999
2025-01-02 09:36:12 -08:00
sheenachhabra
01c51d8475 Allow dolby vision transcode test to use alternative output mime type
On many devices (for example pixel 7) a dolby vision file can be
decoded (either using dolby vision decoder or H265 decoder)
but they can't be re-encoded to dolby vision.
Allow test to encode to H265.

The test now passes on pixel 7. It was getting skipped earlier.

PiperOrigin-RevId: 711383794
2025-01-02 04:15:27 -08:00
sheenachhabra
9cc4532f84 Use same decoder selection logic is test as in DefaultDecoderFactory
The decoder selection logic in DefaultDecoderFactory is more mature
and can find alternative decoders.

PiperOrigin-RevId: 711378121
2025-01-02 03:49:52 -08:00
sheenachhabra
969c50d60f Fix HDR editing support check in dolby vision test
A device (for example pixel 7) might support HDR encoding
but with H265 sample mime type but the existing condition made
assumption false on such devices.

The test still does not pass on pixel 7 because the format
matching condition is incorrect. It will be fixed in a separate CL.

PiperOrigin-RevId: 711368798
2025-01-02 03:00:08 -08:00
Googler
2caa0d39eb Mp4Extractor: Update APV clip
Replaced an existing APV file as bitstream syntax has now changed and
previous clip is not a valid bitstream anymore.

This clip was provided by the openAPV team and is under BSD-3 license.

PiperOrigin-RevId: 711318578
2025-01-01 22:34:31 -08:00
ivanbuper
48e3c6fd75 Rollback of f60d2b4146
PiperOrigin-RevId: 710998501
2024-12-31 10:26:16 -08:00
ivanbuper
d6e4642bcf Rollback of 5ab9a7856f
PiperOrigin-RevId: 710770581
2024-12-30 12:24:05 -08:00
jbibik
afd601f670 Refactor non-ripple Modifier into a separate file
Modifiers.kt will be a place for other extensions on Modifier class

PiperOrigin-RevId: 709416429
2024-12-24 15:27:21 -08:00
jbibik
6da58758a8 Add vertical videos to demo-compose
Useful for future testing of aspect ratio functionality.

PiperOrigin-RevId: 709354104
2024-12-24 08:47:42 -08:00
rohks
3b9737f88a Fix release notes based on Devsite linter warnings
PiperOrigin-RevId: 709329498
2024-12-24 06:17:43 -08:00
sheenachhabra
16617f5a8b Improve javadoc in Mp4LocationData and Mp4OrientationData class
PiperOrigin-RevId: 709061777
2024-12-23 07:57:58 -08:00
claincly
515de89973 Support MediaCodec tonemapping in CompositionPlayer
PiperOrigin-RevId: 708995517
2024-12-23 02:06:08 -08:00
sheenachhabra
f22d91d9e5 Clarify the stream closing responsibility in muxer
PiperOrigin-RevId: 708359779
2024-12-20 10:24:48 -08:00
claincly
8188f7a865 Repect Composition's HDR mode setting using OpenGL
Subsequent CLs will add support for other HDR modes

PiperOrigin-RevId: 708340216
2024-12-20 09:11:00 -08:00
rohks
5c40498054 Fix quotes around parameter name in release notes
PiperOrigin-RevId: 708334464
2024-12-20 08:47:17 -08:00
sheenachhabra
1b0e2fb75e Rename "setSampleCopyEnabled" to "setSampleCopyingEnabled" in muxer
PiperOrigin-RevId: 708322440
2024-12-20 07:57:59 -08:00
sheenachhabra
684c394019 Fix java doc of setSampleBatchingEnabled method
PiperOrigin-RevId: 708310532
2024-12-20 06:58:54 -08:00
Googler
f06bfc2e15 Log errors in BaseGlShaderProgram and QueueingGlShaderProgram.
PiperOrigin-RevId: 708297631
2024-12-20 05:59:18 -08:00
Googler
c12b1768a6 Add sample rate fallback to DefaultEncoderFactory
After this change if a sample rate is requested that is not supported by the available encoders and enableFallback is true, DefaultEncoderFactory will fall back to the encoder with the closest matching sample rate.

In the case when an encoding profile is included in requestedAudioEncoderSettings, an encoder matching that profile will continue to be preferenced.

PiperOrigin-RevId: 708295869
2024-12-20 05:50:25 -08:00
rohks
5c3c3b91f3 Remove publishing for media3-ui-compose temporarily
This is due to a missing version error for the `androidx.compose.foundation` dependency.

PiperOrigin-RevId: 707944220
2024-12-19 09:54:59 -08:00