21452 Commits

Author SHA1 Message Date
shahddaghash
cc8439db93 Bump Media3 version to 1.5.0
PiperOrigin-RevId: 698761734
(cherry picked from commit 73c4bb6e1f0853c138f281844741304c09962c35)
1.5.0
2024-11-21 06:44:25 -08:00
shahddaghash
46a5f0f9b2 Merge release notes for media3 1.5.0 stable release
PiperOrigin-RevId: 698713460
(cherry picked from commit e5110e6442025582cc66c4c3d552cd67c4868a86)
2024-11-21 15:35:44 +00:00
shahddaghash
f63069e266 Move misplaced release note to Unreleased changes section
PiperOrigin-RevId: 698426838
(cherry picked from commit cf4488aa1ffeddf4a09c1fc814791043fac6a203)
2024-11-21 15:20:23 +00:00
ibaker
8bab42334e Bump media3 version to 1.5.0-rc02
PiperOrigin-RevId: 696912494
(cherry picked from commit cbb8e2f1e6daee0346f771950fc6a57a0e3d45f5)
1.5.0-rc02
2024-11-19 11:11:51 +00:00
tianyifeng
737fdd8693 Deflake the DefaultPreloadManagerTest
From [ the last change in `DefaultPreloadManagerTest`](2b54b1ebbe), the preloadManager began to use a separate `preloadThread` in `release_returnZeroCount_sourcesAndRendererCapabilitiesListReleased`, which unveils a bug in `PreloadMediaSource`. When `PreloadMediaSource.releasePreloadMediaSource` is called, `preloadHandler` will post a `Runnable` on the preload looper to release the internal resources. Before this `Runnable` is executed, it is possible that the [`stopPreloading`](https://github.com/androidx/media/blob/main/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/preload/PreloadMediaSource.java#L442) method is executed just as the result of preloading has completed. This is expected to remove the posted `Runnable`s for further preloading, however, the posted `Runnable` for releasing will also be removed from the message queue.

Ideally we should use `postDelayed(runnable, token, delayMillis)` to post the runnables so that the token will be useful to identify which messages to remove in `removeCallbacksAndMessages(token)`, but that `postDelayed` method is only available from API 28. So in this change we are using a separate handler for releasing, and then the call of `preloadHandler.removeCallbacksAndMessages` won't impact the runnable for releasing.

#cherrypick

PiperOrigin-RevId: 696894483
(cherry picked from commit 0143884cd7ac06b042532e328ea69c5ac7da2cb3)
2024-11-19 11:11:51 +00:00
ibaker
fd02ee182c Release notes for 1.5.0-rc01
PiperOrigin-RevId: 696879276
(cherry picked from commit c50867c81debda332dd654e386b4e7ffce82bfce)
2024-11-19 11:11:48 +00:00
ibaker
ef90f501bf Don't assume MP4 keyframe metadata is correct for CEA re-ordering
The content in Issue: androidx/media#1863 has every sample incorrectly marked as a
sync sample in the MP4 metadata, which results in flushing the
re-ordering queue on every sample, so nothing gets re-ordered, so the
subtitles are garbled.

There are currently two "uses" for this call on every keyframe:
1. It offers a safety valve if we don't read a `maxNumReorderSamples`
value from the video. Without this, the queue will just keep growing
and end up swallowing all subtitle data (similar to the bug fixed by
39c734963f).

2. When we do read (or infer) a `maxNumReorderSamples` it means we can
emit samples from the queue slightly earlier - but this is pretty
marginal, given i think the max possible value for
`maxNumReorderSamples` is 16, so the most benefit we would get is 16
frames (~0.53s at 30fps) - in most cases we will have more than 0.5s
of buffer ahead of the playback position, so the subtitles will still
get shown at the right time with no problem.

(1) is resolved in this change by setting the queue size to zero (no
reordering) if we don't have a value for `maxNumReorderSamples`.

(2) has minimal impact, so we just accept it.

We may be able to inspect the NAL unit to determine IDR vs non-IDR
instead - we will consider this as a follow-up change, but given the
minimal impact of (2) we may not pursue this.

PiperOrigin-RevId: 696583702
(cherry picked from commit e6448f34983f58188e97e08976f219efb10e0178)
2024-11-19 11:04:53 +00:00
Copybara-Service
47f3aab231 Merge pull request #1265 from DolbyLaboratories:dlb/ac4-level4/dev_new2
PiperOrigin-RevId: 696157037
(cherry picked from commit 74611bbdc009b3c143a556a74f0e84f386fb5e19)
2024-11-19 11:04:53 +00:00
tianyifeng
57d0721fd6 Resolve the memory leaks in demo short-form app
Issue: androidx/media#1839
PiperOrigin-RevId: 696080063
(cherry picked from commit c3d4722197fdc2b6f37e52d98c435e144b0262ab)
2024-11-19 11:04:53 +00:00
ibaker
a46716c0e9 Handle C.TIME_END_OF_SOURCE buffer timestamps in CeaDecoder
The behaviour was changed in 1.4.0 with 0f42dd4752,
so that the buffer timestamp is compared to `outputStartTimeUs` when
deciding whether to discard a "decode only" buffer before decoding
(instead of the deprecated/removed `isDecodeOnly` property). This breaks
when the buffer timestamp is `TIME_END_OF_SOURCE` (which is
`Long.MIN_VALUE`), because `TIME_END_OF_SOURCE < outputStartTimeUs` is
always true, so the end-of-stream buffer is never passed to the decoder
and on to `TextRenderer` where it is used to
[set `inputStreamEnded = true`](40f187e4b4/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/TextRenderer.java (L434-L436))
and so playback hangs.

Issue: androidx/media#1863
PiperOrigin-RevId: 695767247
(cherry picked from commit 19b38c83b6ce1d13effc08da834cc8ff284cb969)
2024-11-19 11:04:52 +00:00
bachinger
f109a8167b Fix supportedCommands in MediaMetadata
#cherrypick

PiperOrigin-RevId: 695304782
(cherry picked from commit fa790bd73c36706f66b1f7997cfc5a5562a61654)
2024-11-19 11:04:52 +00:00
ibaker
0e37bd08be Re-define 'max size' of SEI queue to operate on unique timestamps
This ensures it works correctly when there are multiple SEI messages per
sample and the max size is set from e.g. H.264's
`max_num_reorder_frames`.

PiperOrigin-RevId: 694526152
(cherry picked from commit 53953dd37713efe03a8dd7446610ed01fc7ac630)
2024-11-19 11:04:52 +00:00
tianyifeng
dba31108a3 Release internal components on preload thread in DefaultPreloadManager
The `RendererCapabilities` and `TrackSelector` objects are accessed on the preload thread during the preloading, when releasing them, they need to be released on the same thread. Otherwise, it is possible that they have already released on the application thread, while the PreloadMediaSource still tries to access them on the preload thread before the source is released.

#cherrypick

PiperOrigin-RevId: 694173131
(cherry picked from commit 2b54b1ebbeb6f13abb6944b7ff593c168c927192)
2024-11-19 11:04:52 +00:00
rohks
461a1fa037 Fix wrong class name in error message of MediaExtractorCompatTest
PiperOrigin-RevId: 693685232
(cherry picked from commit 3d51b36e99c19e07bab8c95899ab8bf3f6f3846c)
2024-11-19 11:04:52 +00:00
rohks
09be7b0b25 Move MediaExtractorCompatTest from test/ to androidTest/
The test has been moved to an instrumentation test as it relies on APIs that vary by SDK version. Robolectric’s emulation lacks sufficient realism in some cases, which impacts test accuracy. By using an instrumentation test, we ensure that the tests run in a real Android environment, providing reliable results for SDK-dependent APIs.

PiperOrigin-RevId: 692933259
(cherry picked from commit 261ca326c5aaa41e3acdea0ababc30622301096a)
2024-11-19 11:04:52 +00:00
sheenachhabra
761cf4a001 Fix color info conversion in vpccBox method
The color space should be used to determine the color
primaries and matrix coefficients, not the video range.

PiperOrigin-RevId: 688489212
(cherry picked from commit 31ece8cbd2047024af243d18205cc6ce03924e31)
2024-11-19 11:04:52 +00:00
ivanbuper
ca010231a8 Fix incorrect Media3 1.5.0-rc01 release notes
PiperOrigin-RevId: 697626185
(cherry picked from commit fff6e2e169d2b9a8afdd5a11e9a19a525a6cde18)
1.5.0-rc01
2024-11-18 16:12:23 +00:00
tonihei
caf7c2b7f1 Fix position tracking bug for inaccurate audio processors
If audio processors report a drifting position, we currently update
the media position parameters to correct this drift. However, this
means we pass in the wrong value to
audioProcessorChain.getMediaDuration, which reuqires the time since
the last flush.

To fix this problem, we can instead save the drift seperately and
apply it where needed.

PiperOrigin-RevId: 692202219
(cherry picked from commit 06718c5df36519bd80f895d7f5a0cedecda5a501)
2024-11-05 13:10:08 +00:00
Copybara-Service
7839f420ab Merge pull request #1225 from Kekelic:support-for-parsing-rtsp-packets-with-header-extension
PiperOrigin-RevId: 692156233
(cherry picked from commit 4910b2cdc081bd3e0131f6930fa6845d7e761ece)
2024-11-05 13:10:08 +00:00
tonihei
aad746b05c Annotate parameters in RepeatModeUtil
PiperOrigin-RevId: 692129684
(cherry picked from commit 544d7aa2dc5147ec4e04501269f89f96a7397a09)
2024-11-05 13:10:08 +00:00
rohks
664dc6e482 Add missing DefaultRenderersFactoryTest for decoder extensions
Added `DefaultRenderersFactoryTest` for `IAMF`, `AV1`, and `MIDI` decoder extensions.

PiperOrigin-RevId: 691381816
(cherry picked from commit 27de9f02e0a56996a5ac570bec5c35d4b4c7c157)
2024-11-05 13:10:08 +00:00
tonihei
4b6e886ad2 Improve position estimate when transitioning to another checkpoint
When transitioning to the next media position parameter checkpoint
we estimate the position because the audio processor chain no longer
provides access to the actual playout duration.

The estimate using the declared speed and the last checkpoint may
have drifted over time, so we currently estimate relative to the
next checkpoint, which is closer and presumably provides a better
estimate. However, this assumes that these checkpoint are perfectly
aligned without any position jumps.

The current approach has two issues:
 - The next checkpoint may include a position jump by design, e.g.
   if it was set for a new item in the playlist and the duration of
   the current item wasn't perfectly accurate.
 - The sudden switch between two estimation methods may cause a jump
   in the output position, which is visible when we add new media
   position checkpoints to the queue, not when we actually reach the
   playback position of the checkpoint.

We can fix both issues by taking a slightly different approach:
 - Continuously monitor the estimate using the current checkpoint. If
   it starts drifting, we can adjust it directly. This way the estimate
   is always aligned with the actual position.
 - The change above means we can safely switch to using the estimate
   based on the previous checkpoint. This way we don't have to make
   assumptions about the next checkpoint and any position jumps will
   only happen when we actually reach this checkpoint (which is more
   what a user expects to see, e.g. at a playlist item transition).

Issue: androidx/media#1698
PiperOrigin-RevId: 690979859
(cherry picked from commit 7c0cffdca8e51223df96bda77b7b516eedb38a34)
2024-11-05 13:10:06 +00:00
rohks
7ec61f13ce Fix handling of cues that exceed total duration in MatroskaExtractor
Adjusted logic to accurately calculate sizes and durations for the last valid cue point when cue timestamps are greater than the total duration.

Fixes the issue where the reported duration of the MKV file was greater than the total duration specified by the duration element. Verified this using `mkvinfo` and `mediainfo` tools.

PiperOrigin-RevId: 690961276
(cherry picked from commit b1f2efd218c80a0c6b3134a3d57fdff0a16e64b1)
2024-11-05 13:09:10 +00:00
ibaker
c44d509ea8 Remove // Do nothing overrides from EventLogger
These methods are marked `default` on the `AnalyticsListener` interface
with an empty implementation, so there's no need to override them just
to re-define the empty implementation.

PiperOrigin-RevId: 689416584
(cherry picked from commit 757f223d8aaf7a496ebd6bb42f0cd838a11860d9)
2024-11-05 13:09:10 +00:00
ibaker
8ca80a6b71 Remove some un-needed proguard-rules.txt symlinks
PiperOrigin-RevId: 689344803
(cherry picked from commit b36de302f7b01352707fa53c52256b7d39b98b4e)
2024-11-05 13:09:10 +00:00
ibaker
26cbf9444d DataSourceContractTest: Tighten assertions around 'not found' URIs
This change:
1. Updates `DataSourceContractTest` to allow multiple "not found"
   resources, and to include additional info (e.g. headers) on them.
2. Updates the contract test to assert that `DataSource.getUri()`
   returns the expected (non-null) value for "not found" resources
   between the failed `open()` call and a subsequent `close()` call.
   The `DataSource` is 'open' at this point (since it needs to be
   'closed' later), so `getUri()` must return non-null.
    * This change also fixes some implementations to comply with this
      contract. It also renames some imprecisely named `opened`
      booleans that **don't** track whether the `DataSource` is open
      or not.
3. Updates the contract test assertions to enforce that
   `DataSource.getResponseHeaders()` returns any headers associated
   with the 'not found' resource.
4. Configures `HttpDataSourceTestEnv` to provide both 404 and "server
   not found" resources, with the former having expected headers
   associated with it.

PiperOrigin-RevId: 689316121
(cherry picked from commit 4a406be1bf8c787c4882815560a644a37792a2fb)
2024-11-05 13:09:10 +00:00
Copybara-Service
08e55d81ef Merge pull request #1794 from stevemayhew:p-fix-ntp-time-update-main
PiperOrigin-RevId: 689121191
(cherry picked from commit b5615d5e919b297def6450b45320a3165c34548c)
2024-11-05 13:08:52 +00:00
tonihei
a44079b516 Removed unused constructor
PiperOrigin-RevId: 688960856
(cherry picked from commit 21526588be691c5459bb5ade31b23f217eb4e7ea)
2024-11-05 12:13:17 +00:00
tonihei
bc7c901969 Suppress not-applicable lint warning
PiperOrigin-RevId: 688948857
(cherry picked from commit dfb7636138039180b9849a8939ab8ec518999d03)
2024-11-05 12:13:17 +00:00
ibaker
fbbe48cd47 Add missing overrides in DefaultTrackSelector.Parameters.Builder
Also add a test for this to avoid missing any others in future. Also
flesh out the existing test for the deprecated builder, to assert the
return type is correctly updated.

PiperOrigin-RevId: 688948768
(cherry picked from commit 7b66209bca233c6a115a5ecdc59fe0620cbdd2f2)
2024-11-05 12:13:17 +00:00
rohks
a03bd8248c Fix duration calculation for AVI files
The duration is now correctly calculated as the maximum of all track durations, instead of being overwritten by the last track's value. This aligns with how other Extractor implementations handle durations for multiple tracks.

PiperOrigin-RevId: 688896743
(cherry picked from commit e677c8dccda196551e090f58e4d1014f907a9bfd)
2024-11-05 12:13:17 +00:00
bachinger
57f0c0d368 Fix flakiness of MediaBrowserListenerWithMediaBrowserServiceCompatTest
PiperOrigin-RevId: 688870397
(cherry picked from commit 0038dda3c36568d1f8582db48bd85cd27728f2ff)
2024-11-05 12:13:17 +00:00
ibaker
70c7ee2e0c Use Guava's HttpHeaders consistently in HTTP testing machinery
PiperOrigin-RevId: 688576776
(cherry picked from commit cabc541a6fbdd90286bb425abbf147bf94d10b73)
2024-11-05 12:13:17 +00:00
jbibik
e6849e082c Align spelling of fullScreen to fullscreen
Currently most of the public APIs use `fullscreen` (apart from the deprecated `PlayerControlView.OnFullScreenModeChangedListener` which will have to remain as is). This code changes mostly private variable naming.

PiperOrigin-RevId: 688559509
(cherry picked from commit ee4f0c40bc2575f55f89c4a22f26dabcdc75775a)
2024-11-05 12:13:16 +00:00
ibaker
8fdb233a7d DataSourceContractTest: Add expected response headers
PiperOrigin-RevId: 688556440
(cherry picked from commit 219565c15e9aaee90266b9d07d94286e0423d49c)
2024-11-05 12:13:16 +00:00
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