5032 Commits

Author SHA1 Message Date
tonihei
b68d455b5e Ensure session extras Bundle is copied at least once
If not copied, the extras Bundle can be accidentally changed by the
app if it modifies the instance passed into MediaSession. On the flip
side, the Bundle should be modifiable once created so that the session
can amend the extras if needed without crashing.

PiperOrigin-RevId: 688485963
(cherry picked from commit d9ca3c734aa1042731a3136712993277a45804f7)
2024-11-05 12:13:16 +00:00
rohks
8304c26e08 Improve error logging for IllegalClippingException
Added start and end time details to the error message for `REASON_START_EXCEEDS_END`, helping to debug cases where the start time exceeds the end time.

PiperOrigin-RevId: 688117440
(cherry picked from commit 0ecd35e24ccd4a290e147672ea352d7c8716464b)
2024-11-05 12:13:16 +00:00
ibaker
6611187316 Test ResolvingDataSource resolveReportedUri functionality
PiperOrigin-RevId: 688102934
(cherry picked from commit 40cd64ab19372d40198ff3c1bc99f013cceadf8b)
2024-11-05 12:13:16 +00:00
ibaker
ab4dff7530 DataSourceContractTest: Add tests for resolved vs original URI
PiperOrigin-RevId: 688076205
(cherry picked from commit 74bbd7727d30fbad1510e346a08ae1ce91bfefdd)
2024-11-05 12:13:04 +00:00
Copybara-Service
6f42f36c05 Merge pull request #1742 from colinkho:trackselection-playwhenready
PiperOrigin-RevId: 688050467
(cherry picked from commit f2ecca3b6a6cc3bec7c80d455b24c00a8293716e)
2024-11-05 12:07:18 +00:00
ibaker
eb2ef4d14b Fix some markdown-in-javadoc
PiperOrigin-RevId: 687354846
(cherry picked from commit 49337d966705d854091dfc26a3f2006d29231c97)
2024-11-05 12:07:18 +00:00
tonihei
2bf0138590 Let FakeTrackSelection extend BaseTrackSelection
This fixes a bug in getIndexInTrackGroup

PiperOrigin-RevId: 687336621
(cherry picked from commit ceac959c299efb2aa2fb89299bc3b50d530b9de9)
2024-11-05 12:07:18 +00:00
ibaker
b2b30249c6 Rename playback thread in MediaSourceTestRunner
This makes it more clearly "the playback thread" when logging its name
during tests. The 'real' playback thread used in
`ExoPlayerImplInternal` is [called
`ExoPlayer:Playback`](49dec5db8b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/PlaybackLooperProvider.java (L87)).

PiperOrigin-RevId: 687307440
(cherry picked from commit b64bf882726154118a66e24a973e5c4d08942737)
2024-11-05 12:07:18 +00:00
ibaker
6537a63f2b Release the Surface at the end of every playback test
Without this an error is logged which obfuscates real test failures.

PiperOrigin-RevId: 687302953
(cherry picked from commit 2f01900e83ef4d5e8b690d24b441d4b48e028ef3)
2024-11-05 12:07:17 +00:00
tonihei
e6c24087f8 Remove unneeded @Nullable from PlayerWrapper.legacyExtras
All values passed in via the constructor or setLegacyExtras
are guaranteed to be non-null.

PiperOrigin-RevId: 687245475
(cherry picked from commit 5fffe033121a75386e7132e8245b63becc85550a)
2024-11-05 12:07:17 +00:00
bachinger
88a78ade04 Accept resource URIs for command buttons
PiperOrigin-RevId: 687239119
(cherry picked from commit 3e556a4b53a4b5ae6feebe302b7b3c2813281943)
2024-11-05 12:07:17 +00:00
ibaker
ed6b822ff5 Remove unused Surface from DashPlaybackTest
Follow-up to cb90bb38ee

PiperOrigin-RevId: 687235908
(cherry picked from commit 13d6f37a841c4af9f758afb7613303227c550124)
2024-11-05 12:07:17 +00:00
ibaker
9c15ea5436 Add @ForOverride annotation to DataSourceContractTest
PiperOrigin-RevId: 687223500
(cherry picked from commit 3ba2fa6c076ee59629fcda6f35875bffd0fc0135)
2024-11-05 12:07:17 +00:00
bachinger
332aa7d34b Look for METADATA_KEY_ART_URI for legacy media items
PiperOrigin-RevId: 687222830
(cherry picked from commit 08e6f30b6841fc9876f34f9af452a24eb4accef6)
2024-11-05 12:07:17 +00:00
ivanbuper
0f739bc5fa Bump Media3 to 1.5.0-rc01
#cherrypick

PiperOrigin-RevId: 692221696
(cherry picked from commit 0b1695124ba28e5997d9ed6a1c965615686ba3ca)
2024-11-01 17:48:21 +00:00
rohks
fc32b7f281 Refactor OpusDecoderTest to use OpusLibrary.isAvailable()
Replaced the custom `LibraryLoader` instance with `OpusLibrary.isAvailable()` to verify the library loading. This simplifies the code by leveraging the existing library loading mechanism.

#cherrypick

PiperOrigin-RevId: 691457871
(cherry picked from commit 2b27e33784e9839e8c14fdddba90efc1435acb3a)
2024-10-31 14:41:24 +00:00
ibaker
b6baeb6cb0 Support CEA-608 subtitles in Dolby Vision
Issue: androidx/media#1820

#cherrypick

PiperOrigin-RevId: 691378476
(cherry picked from commit 27371db225c80316cdb8e6abdb9220da737ced31)
2024-10-31 14:41:24 +00:00
ibaker
bf15b93b60 Mark ProgressiveMediaSource.setSuppressPrepareError package-private
This method will likely be removed in the next release, and is currently
only needed from within the `source` package.

#cherrypick

PiperOrigin-RevId: 691351449
(cherry picked from commit 08a141328ddfbc64b2fe4991bd297b5909275467)
2024-10-31 14:41:24 +00:00
rohks
358a3c62fa Use assumeTrue for libiamf availability check in IamfDecoderTest
This change ensures that the test uses `assumeTrue` to avoid failures when the `libiamf` library is not pre-built.

#cherrypick

PiperOrigin-RevId: 691333564
(cherry picked from commit 129cf8ea72f468da9532029ce3d446e72d28b732)
2024-10-31 14:41:24 +00:00
ibaker
8d8a5211dd H264Reader: Add missing propagation of max_num_reorder_frames
This method is already called below in the
`else if (sps.isCompleted())` block which applies when
`hasOutputFormat == true`, but this is only ever entered if we are
parsing SPS and PPS NAL units **after** we've emitted a format, which
is only the case if
`DefaultTsPayloadReaderFactory.FLAG_DETECT_ACCESS_UNITS` is set (which
it isn't by default).

The equivalent call in `H265Reader` is already inside the
`if (!hasOutputFormat)` block, so doesn't need a similar fix.

#cherrypick

PiperOrigin-RevId: 689809529
(cherry picked from commit 39c734963f67f8ed3fa79820d573e6b3297c8d28)
2024-10-31 14:41:23 +00:00
rohks
895c69c08f Make minor improvements for IAMF decoder module
- Create `LibiamfAudioRenderer` with `DefaultRenderersFactory` in `ExoPlayerModuleProguard`.
- Remove redundant library availability check from `IamfModuleProguard`.
- Move `proguard-rules.txt` to the root folder.
- Removed unused `cryptoType` parameter from `setLibraries()` method in `IamfLibrary`.
- Added log when `LibiamfAudioRenderer` is loaded in `DefaultRenderersFactory`.
- Annotated missing classes with `@UnstableApi`.
- Check for library availability and throw exception in `IamfDecoder` constructor.

#cherrypick

PiperOrigin-RevId: 689330016
(cherry picked from commit 5f99955f319dd70b14017b7d050c179f9562c842)
2024-10-31 14:41:23 +00:00
rohks
6d0ef8bfe7 Add support for identifying h263 box in MP4 files for H.263 video
Issue: androidx/media#1821

#cherrypick

PiperOrigin-RevId: 688570141
(cherry picked from commit 7545a8929b9f859ae014eecfa2a67206de706b4c)
2024-10-31 14:41:23 +00:00
rohks
cc947dc690 Fix media duration parsing in mdhd box of MP4 files to handle -1 values
Treats the media duration as unknown (`C.TIME_UNSET`) when all bytes are
`-1` to prevent exceptions during playback.

Issue: androidx/media#1819

PiperOrigin-RevId: 688103949
(cherry picked from commit 457bc55a4d37a7762c819db76bd58468ab1ca8b3)
2024-10-31 14:40:55 +00:00
shahddaghash
7da2161a7b Bump Media3 version to 1.5.0-beta01
PiperOrigin-RevId: 688079507
(cherry picked from commit 5088e87195d0a1b485b15d0d08fc375c51de7bad)
2024-10-21 11:30:12 +00:00
tonihei
627b7a3e56 Add media button preferences
This adds the API surface for media button preferences in MediaSession
and MediaController. It closely mimics the existing custom layout
infrastructure (which it will replace eventually).

Compat logic:
 - Session:
     - When converting to platform custom actions, prefer to use
       media button preferences if both are set.
     - When connecting to an older Media3 controller, send the
       media button preferences as custom layout instead.
 - Controller:
     - Maintain a single resolved media button preferences field.
     - For Media3 controller receiving both values, prefer media
       button preferences over custom layouts.

Missing functionality:
 - The conversion from/to custom layout and platform custom actions
   does not take the slot preferences into account yet.

PiperOrigin-RevId: 686950100
2024-10-17 09:54:36 -07:00
tonihei
e851a1419d Add slots to CommandButton
These allow to define preferences for where a button should be
displayed.

PiperOrigin-RevId: 686938126
2024-10-17 09:16:44 -07:00
ibaker
8cb558e875 Add HALF_UP rounding TODO to scaleLargeTimestamp (and its usages)
PiperOrigin-RevId: 686921743
2024-10-17 08:25:03 -07:00
ibaker
64e0397811 De-flake new test for ProgressiveMediaSource.suppressPrepareError
This test was added in b3290eff10

#cherrypick

PiperOrigin-RevId: 686918104
2024-10-17 08:11:01 -07:00
ibaker
49dec5db8b Ignore renderer errors from text/metadata tracks
Before this change:

* With legacy subtitle decoding (at render time), load errors (e.g. HTTP
  404) would result playback completely failing, while parse errors
  (e.g. invalid  WebVTT data) would be silently ignored, so playback
  would continue without subtitles.
* With new subtitle decoding (at extraction time), both load and parse
  errors would result in playback completely failing.

This change means that now neither load nor parse errors in text or
metadata tracks stop playback from continuing. Instead the error'd track
is disabled until the end of the current period.

With new subtitle decoding, both load and parse errors happen during
loading/extraction, and so are emitted to the app via
`MediaSourceEventListener.onLoadError` and
`AnalyticsListener.onLoadError`. With legacy subtitle decoding, only
load errors are emitted via these listeners and parsing errors continue
to be silently ignored.

Issue: androidx/media#1722
PiperOrigin-RevId: 686902979
2024-10-17 07:15:22 -07:00
ibaker
191bc094a5 Propagate events from secondary children in MergingMediaSource
These events are always reported with the primary child period ID,
because this is the same ID used in the parent `MergingMediaSource`'s
Timeline.

This ensures that e.g. loading errors from sideloaded subtitles (which
uses `MergingMediaSource`) are now reported via
`AnalyticsListener.onLoadError`.

It results in non-error events being reported from these children too,
which will result in more `onLoadStarted` and `onLoadCompleted` events
being reported (one for each child).

Issue: androidx/media#1722
PiperOrigin-RevId: 686901439
2024-10-17 07:10:59 -07:00
ibaker
b3290eff10 Allow ProgressiveMediaSource to optionally suppress prepare errors
Use this for sideloaded subtitles, so preparation can still complete
despite an error from e.g. `DataSource.open`. In this case, no subtitle
tracks will be emitted.

Issue: androidx/media#1722
PiperOrigin-RevId: 686888588
2024-10-17 06:20:11 -07:00
ivanbuper
b78395b325 Extract method for calculating expected accumulated truncation error
This is prework for implementing
`RandomParameterizedSpeedChangingAudioProcessorTest`, which depends on
Sonic's resampling algorithm's behaviour.

This is a non-functional refactor.

PiperOrigin-RevId: 686874593
2024-10-17 05:24:04 -07:00
michaelkatz
2a1e71b203 Reduce needless loading period resets in clipping mediasource playlists
When a `SampleQueue` is prepared prior to playback, the start position may be less than the timestamp of the first sample in the queue and still be valid. This scenario can come about with specific clipping values and if all samples are sync samples. Currently, with `ClippingMediaPeriods` around `ProgressiveMediaPeriods`, if the `SampleQueue` has already been reset through the seekTo operation in `onPrepared`, then in the aforementioned scenario the seekTo operation in `handleDiscontinuity` will remove all samples and reset the loading periods unnecessarily.

The solution is that if the `ProgressiveMediaPeriod` has already handled a seekTo operation for the same position and the sample queue has not been read yet, then loading does not need to be reset.

The tests in `MergingPlaylistPlaybackTest` were specifically causing this behavior through its setup of `MergingMediaSources` around clipped `FilteringMediaSources`. Since the video content was not 'all sync samples', there would always be a discontinuity to handle and the audio content being 'all sync samples' would start with samples post start time.

These changes also remove the flakiness from the `MergingPlaylistPlaybackTest`.

PiperOrigin-RevId: 686858444
2024-10-17 04:20:50 -07:00
bachinger
8681109d1f Use SessionError error codes to make lint happy
#cherrypick

PiperOrigin-RevId: 686849343
2024-10-17 03:43:59 -07:00
kimvde
38c27d45f1 Make VideoGraph and VideoFrameProcessor listener methods optional
PiperOrigin-RevId: 686833280
2024-10-17 02:38:03 -07:00
ibaker
d2ccace75c Remove allocator param from MediaSourceTestRunner constructor
Currently every test in the library passes `null` here, which seems to
end up being passed into non-null places in the library. This change
removes the parameter and instead initializes the field to a
`DefaultAllocator` instance in the same way that `DefaultLoadControl`
creates one.

PiperOrigin-RevId: 686823273
2024-10-17 02:00:08 -07:00
shahddaghash
2e61c93dba Remove deprecated DefaultEncoderFactory constructors.
Use `DefaultEncoderFactory.Builder` instead.

PiperOrigin-RevId: 686821388
2024-10-17 01:53:23 -07:00
kimvde
31ef7ff088 Clarify Javadoc of EditedMediaItem.Builder.setDurationUs
PiperOrigin-RevId: 686521901
2024-10-16 08:48:10 -07:00
sheenachhabra
d3b7f7e114 Add VP9 test to Mp4MuxerEndToEndNonParameterizedAndroidTest
The test is currently disabled because the produced dump file
is different on different SDK versions.

PiperOrigin-RevId: 686518799
2024-10-16 08:37:41 -07:00
kimvde
363f71357b Handle output size changes inside DefaultVideoSink
PiperOrigin-RevId: 686507112
2024-10-16 07:59:35 -07:00
ibaker
e3f813cf0b Attach a Surface in HlsPlaybackTest.cmcdEnabled_withInitSegment
This ensures that the buffers are correctly marked as `rendered = true`
(and therefore `renderered = false` is meaningful when it's present).

This was accidentally missed in 387153fcf2

PiperOrigin-RevId: 686474869
2024-10-16 05:46:22 -07:00
rohks
692f1c78b3 Add ForwardingTrackOutput implementation
This allows users to extend and customize specific methods of the `TrackOutput` implementation while inheriting default behaviors for others.

PiperOrigin-RevId: 686454360
2024-10-16 04:20:33 -07:00
bachinger
075f311200 Cache children when subscribing
Childrens returned by the legacy service when a Media3
browser connects are cached and returned with the first
`getChildren` call in case the same `paranetid` is
requested.

In any other case the cache is immediately cleared.

#cherrypick

PiperOrigin-RevId: 686157511
2024-10-15 10:40:29 -07:00
rohks
91c56335ef Handle out-of-order frames in endIndices for MP4 with edit list
Updated logic to walk forward in the timestamps array to include all frames within the valid edit duration, accounting for out-of-order frames. This ensures that no frames with timestamps less than `editMediaTime` + `editDuration` are incorrectly excluded.

Issue: androidx/media#1797
PiperOrigin-RevId: 686075680
2024-10-15 06:09:15 -07:00
kimvde
9adb3aaf41 Transformer: add an entry point to disable automatic rotation
PiperOrigin-RevId: 686067527
2024-10-15 05:40:41 -07:00
sheenachhabra
643e16ca8f Handle invalid language codes in Boxes.java
When an invalid language code is give, write default value
instead of throwing.

This behaviour aligns with `MediaMuxer`.

PiperOrigin-RevId: 686066088
2024-10-15 05:36:04 -07:00
bachinger
5a827829b0 Call onChildrenChanged to close the legacy subscription error path
When receiving an error from a legacy `MediaBrowserService` after
having successfully subscribed to a given `parentId`, the callback
needs to be asked to load the children again to receive an error
from the service.

Before this change such an error was dropped as a no-op by Media3
without the `MediaBrowser` giving a chance to react on such an error
being sent by the legacy service.

#cherrypick

PiperOrigin-RevId: 686052969
2024-10-15 04:38:34 -07:00
sheenachhabra
407bd49ed5 Skip audio encoding bitrate setting test on API <= 23
The encoder output format on API 23 does not seem to contain bitrate,
hence the test fails.

PiperOrigin-RevId: 686047480
2024-10-15 04:15:38 -07:00
ibaker
cb90bb38ee Remove unused CapturingRenderersFactory from DASH playback test
The `CapturingRenderersFactory` is only needed if the output is
asserted on, e.g. by using `PlaybackOutput` and
`DumpFileAsserts.assertOutput()`.

PiperOrigin-RevId: 686046545
2024-10-15 04:11:42 -07:00
sheenachhabra
0b47e93df5 Update FragmentedMp4Muxer and Mp4Muxerdocumentation to include VP9
PiperOrigin-RevId: 686041467
2024-10-15 03:53:08 -07:00