Tags: DiceTechnology/androidx-media
Tags
Feat/migrate media3 1.8 (#43) * Format with google-java-format * Add release notes * minor cleanup * Minor cleanup * Ensure equality of interstitial * internal change PiperOrigin-RevId: 761291735 * Fix typo * Resolve warnings from internal linter * Allow apps to override MediaButtonReceiver.onReceive Apps are on their own when doing that. The main reasons to do may be that an app needs to get information whether to start the service or not from an async call. The system may have stopped the app or process before the async call returns. This behaviour is considered risky by Media3 so app can do that but we don't provide support for that. Issue: androidx/media#2443 PiperOrigin-RevId: 761462217 * Minor reformatting for consistency * Set sync flag for audio samples in the trun box For audio samples, all samples are sync samples. https://github.com/androidx/media/issues/2435 PiperOrigin-RevId: 761462725 * Add custom playback exception to session This allows apps to set a custom `PlaybackException` for a specific controller or all connected controllers. PiperOrigin-RevId: 761482879 * Add ExoPlayerFrameDropAnalysisTest test Add an analysis test to evaluate ExoPlayer frame dropping algorithms. Uses a custom Clock that skips forward to force dropped frames PiperOrigin-RevId: 761487984 * Implement `getVolume()`/`setVolume()` on `CastPlayer` * Update release notes * remove redundant @NonNull annotation * Move release notes to unreleased * Make miscellaneous style changes in preparation for internal review * Add API to reserve free space after ftyp PiperOrigin-RevId: 761536934 * Move FakeDownloader to test-utils-robolectric for reuse in other tests This could be useful for enhancing PreCacheHelperTest. PiperOrigin-RevId: 761549917 * Update the CodecDB Lite Dataset PiperOrigin-RevId: 761674017 * Fix reference release link for 1.8.0-alpha01 1.6.1 and 1.7.1 are the same code, but for consistency and avoiding that it looks like a missed update, we can reference the latest released version in the link. PiperOrigin-RevId: 761881248 * Fix `RtspClient` not remove the user info from the redirect uri. The redirection location uri provided in an HTTP 302 response should be used as is. Issue: androidx/media#2398 PiperOrigin-RevId: 761937190 * Ignore empty FLAC seek tables This also ignores seek tables that only contain placeholder seek points. This change adds two tests which assert that the seeking behaviour is the same for a file with no seek table and a file that only contains placeholder seek points. `bear_no_seek_table.flac` was generated by copying `bear.flac` then modifying it with: ```shell $ metaflac --remove --block-type=SEEKTABLE bear_no_seek_table.flac ``` Then this was copied to `bear_placeholder_seek_point_only.flac` and modified to add a single placeholder seek point: ```shell $ metaflac --add-seekpoint=X bear_empty_seek_table.flac ``` I couldn't work out how to convince `metaflac` to either remove all seek points, or to add an empty seek table, but a seek table containing only a single placeholder seek point is effectively empty, because placeholder points are removed here: https://github.com/androidx/media/blob/839de45e8ac200c38c44b2d720ee798047c34739/libraries/extractor/src/main/java/androidx/media3/extractor/FlacMetadataReader.java#L202-L209 PiperOrigin-RevId: 761959629 * Add tests that custom plain type extras are preserved Converting from MediaMetadata to MediaMetadataCompat needs to transfer custom extras via the limited typing capabilities of MediaMetadataCompat. Adding tests for all type transfers of custom values that should be supported. PiperOrigin-RevId: 761977884 * Address review comments * DemoPlaybackService: catch exception when loading an artwork bitmap When there is an error loading the bitmap we want to skip the bitmap population instead of throwing an error that crashes the app. PiperOrigin-RevId: 761995989 * Wire CodecDB Lite into DefaultEncoderFactory By default, CodecDB Lite is disabled, but can be enabled by calling `DefaultEncoderFactory.Builder#setEnableCodecDbLite(true)` PiperOrigin-RevId: 762136230 * Automated Code Change PiperOrigin-RevId: 762343724 * Should skip SEI payload when SEI type mismatch * Add release note * Fix bug in DefaultGainProvider#isUnityUntil() The method should not return TIME_UNSET if the sample position points to a unity gain factor. Otherwise, GainProcessor will crash on a failed assertion. We cannot efficiently estimate the duration of the unity region, so we assume the region is only one sample long. PiperOrigin-RevId: 762365724 * Suppress lint errors in `MediaCodecRenderer` PiperOrigin-RevId: 762385597 * Add a test for an MP4 file with an HEVC SEI NAL unit This is a follow-up to Issue: androidx/media#2457 using the test file provided in Issue: androidx/media#2456. PiperOrigin-RevId: 762387987 * Address internal review comments * Update Av1SampleDependencyParser visibility PiperOrigin-RevId: 762499563 * Allow setting `mime_type` in demo app JSON media lists This is already [supported](https://github.com/androidx/media/blob/ae9a2339679826f870690092509a135dffc0d7e4/demos/main/src/main/java/androidx/media3/demo/main/IntentUtil.java#L56) (and [documented](https://developer.android.com/media/media3/exoplayer/demo-application#3-firing)) in the `Intent` API. PiperOrigin-RevId: 763686881 * Fix non-IDLE CastPlayer with empty timeline bug PiperOrigin-RevId: 763711782 * Parse missing interstitials attributes Attributes are parsed for completion but not yet used by an ads loader or similar. Apps that access the manifest are able to get these values and can be sure they have been validated. PiperOrigin-RevId: 763736914 * Add "realme" devices to the detached surface workaround list The brand is part of OPPO, which is already on the list. Issue: androidx/media#2059 PiperOrigin-RevId: 763750385 * Limit discarding on DASH period duration change to unread samples When a DASH period duration is shortened by a manifest udpate, we discard already loaded data upstream that is beyond the new duration. However, we shouldn't attempt to discard samples that are already read by the renderers. Issue: androidx/media#2440 PiperOrigin-RevId: 763792259 * Put controller in error state when connecting during session error When an app sets a custom `PlaybackException` on the session level, a controller that connects should receive an initial state that is in error. PiperOrigin-RevId: 763810053 * Add missing renderer capabilities changed forwarding Issue: androidx/media#2258 PiperOrigin-RevId: 763819705 * Inform AudioCapabilitiesReceiver about temporary capability overrides If the receiver is not informed, it can't trigger change callbacks the next time something happens (like adding a device) that might help to recover from issues. Issue: androidx/media#2258 PiperOrigin-RevId: 763855380 * Clean up and extend HlsChunkSourceTest Half of the tests were already overriding the setUp step, so it's cleaner to just execute the setup inline with the right parameters in all tests via a util method. Also adding new tests for correctly throwing playlist load errors before and after being blocked on a playlist, but not if loading isn't blocked. One of the tests is failing at the moment because of Issue: androidx/media#2401. PiperOrigin-RevId: 764152270 * Remove double-inverted return value HlsChunkSource confusingly returns true if the playlist can't be excluded because of a C.TIME_UNSET exclusion period, only to invert this again at the next level. This can be simplified by moving the condition into HlsChunkSource directly. PiperOrigin-RevId: 764165563 * Remove TODOs about removing deprecated symbols These comments are stale since we renamed 1.7.0 as 1.8.0, and in most cases we don't need to tie a TODO for removing a deprecated symbol to a specific release. PiperOrigin-RevId: 764180589 * Add VideoFrameReleaseEarlyTimeForecaster to predict early time Add a new class that predicts the video frame release early time for future frames, based on previously processed frames. PiperOrigin-RevId: 764193783 * Publish dynamic scheduling test that relies on Robolectric 4.14 PiperOrigin-RevId: 764201917 * Fix logic to throw playlist load error when getting stuck The current logic sets a boolean and also compares if the loaded playlist matches the one that had a playlist load error. However, the logic is a bit convoluted and relies on the error being reported after getting stuck on the playlist reload. This doesn't work if the loader already gave up (e.g. because the load error handling policy doesn't allow further retries). Issue: androidx/media#2401 PiperOrigin-RevId: 764207757 * Use VideoFrameReleaseEarlyTimeForecaster in MCVR Replace the existing experimental logic for dropping input buffers with VideoFrameReleaseEarlyTimeForecaster. VideoFrameReleaseEarlyTimeForecaster is integrated in MCVR in order to disable it more easily during A/B experiments. In future, the forecaster may move to VideoFrameReleaseControl for easier use with CompositionPlayer. PiperOrigin-RevId: 764211846 * Mitigate race condition with GlShaderProgram.release Always recreate InputSwitcher's sampling shader program when switching inputs. Do not throw when PassthroughShaderProgram is used after release() See b/417680219 PiperOrigin-RevId: 764269227 * Use published duration of preload parts in getNextChunk Preload parts don't have a duration initially and startTime==endTime in the HlsMediaChunk. However, we get a proper duration later once the playlist has been updated again. If the last loaded chunk was a preload part, we currently pass in its wrong end time to getNextChunk (potentially selecting a new chunk at an earlier time than we have to), and also use the wrong end time to decide if the chunk needs to be spliced in. This can be fixed by retrieving the updated duration at the point of marking the chunk as published, and then using this duration when calculating the loadPositionUs for getNextChunk. And also use the same loadPositonUs when deciding if the new chunk needs to be spliced in. PiperOrigin-RevId: 764279432 * Discard trailing preload hint data when switching tracks When switching tracks, the preload hint data won't be marked as "published" because we no longer load its playlist (as we switched to another one). As we can't really tell whether this part still exists, we should discard its data during the track switch. This prevents playback from getting stuck as we do not allow reading into unpublished chunk data. Issue: androidx/media#2299 PiperOrigin-RevId: 764285460 * Change PlayerWrapper's default for volume without command The command check is executed before bundling the volume into PlayerInfo. A zero will be bundled because the check against 1f fails in toBundleForRemoteProcess. Therefore we always end up passing the zero for the field we shouldn't even be accessing because we don't have the correct Player.Command. Making the volume check return 1f brings the two systems in sync and also returns a more reasonable default (it's unlikely the Player is muted). PiperOrigin-RevId: 764286512 * Enable dynamic scheduling in scrubbing mode PiperOrigin-RevId: 764294247 * Add full cookie handling to CronetDataSource This is a copy of https://github.com/androidx/media/commit/814d368d9f54f47f6f0372c7905846104c549322 and https://github.com/androidx/media/commit/d0d76f214a3417ec39f86b1003dd0850a88638d9, moving the same utils to the shared HttpUtil class. Issue: google/ExoPlayer#5975 PiperOrigin-RevId: 764324403 * Add CodecDB Lite to the Transformer Demo App PiperOrigin-RevId: 764340114 * Add background to demo app scrollview PiperOrigin-RevId: 764341409 * Limit the output of `BitmapFactoryImageDecoder` to the display size This avoids wasting computation and memory decoding very large (e.g. 50MP) images into full resolution `Bitmap` objects, only to downscale them later when showing them on screen (or not downscaling them, in which case the app can crash with an error like `Canvas: trying to draw too large(200540160bytes) bitmap.`). If the display size is not available, default to a 4k limit. If an app wants to decode images to a larger resolution they can provide a custom `ImageDecoder` implementation by overriding [`DefaultRenderersFactory.getImageDecoderFactory()`](https://developer.android.com/reference/androidx/media3/exoplayer/DefaultRenderersFactory#getImageDecoderFactory()). Issue: androidx/media#2417 PiperOrigin-RevId: 764631521 * Remove unused glide version PiperOrigin-RevId: 764646819 * Avoid splicing into HLS chunks if the splice point is already read When splicing data into existing SampleQueues, we need to find the first keyframe in the new data after the current reading position. If we already read too much data and the new chunk starts before our current reading position, the splice will fail and only the data from the following chunk will be written to the queue, causing a gap in the data where playback will appear stuck. To avoid this issue mostly, we can check if the new chunk starts from a position before the current reading position, and if so, we can ignore the new track selection and continue loading the current format instead to avoid the gap. PiperOrigin-RevId: 764650636 * Simplify `ExoPlayerScrubbingTest` set-up Also ensure the sync sample timestamps are consistently set. PiperOrigin-RevId: 764685280 * Suppress lint warning in `MediaCodecVideoRenderer` PiperOrigin-RevId: 764694026 * Fix MediaCodec tone mapping in CompositionPlayer Previously an incorrect ColorInfo was being set on the VideoGraph when the input was tone mapped with MediaCodec. PiperOrigin-RevId: 765093463 * Make dav1d extension publicly available for use with Media3 PiperOrigin-RevId: 765118027 * Fix ProGuard rule for `Libdav1dVideoRenderer` PiperOrigin-RevId: 765132313 * Upgrade protobuf for demo-session to 4.31.1 Version 3.0.0 doesn't seem to have binaries for building on osx-aarch64 in the current repository, leading to build errors like: ``` Execution failed for task ':demo-session-service:generateDebugProto'. > Could not resolve all files for configuration ':demo-session-service:protobufToolsLocator_protoc'. > Could not find protoc-3.0.0-osx-aarch_64.exe (com.google.protobuf:protoc:3.0.0). ``` PiperOrigin-RevId: 765185558 * [b/372449691] Remove `packagingOptions` from `build.gradle` files AGP is now set to 8.8.1, so the `packagingOptions` setup can be removed. * [b/306324391] Remove `try`/`catch` in `AudioCapabilities.Api33#getDefaultRoutedDeviceForAttributes()` This mentioned commit (https://github.com/robolectric/robolectric/commit/442dff) was released in Robolectric 4.12. Media3 now uses Robolectric 4.14.1, so this `try`/`catch` is not needed anymore. * Remove some unused locals in `ExoPlayerScrubbingTest` These were missed in https://github.com/androidx/media/commit/07218bd0c2a9c4beeeac4a002931bc352f03f9f8 PiperOrigin-RevId: 765206279 * Add encrypted SVT-AV1 test asset This is Big Buck Bunny, transcoded with SVT-AV1 PiperOrigin-RevId: 765215067 * Fix connection race condition in MediaControllerImplLegacy When connecting to a framework or media1 controller, we ask the session for its "extra" binder that is used to exchange information. Once this is done we get a callback and mark the controller as connected. For framework-only sessions however, we won't get a callback. The only way to know is to wait for a bit and see if any callback (onSessionReady/onSessionDestroyed) arrives. At the moment, the only waiting is sending a handler message to the main thread to accept the controller as a framework controller. In about 70% of cases in the tests, this triggers the connection too early before the onSessionReady callback comes back. We can fix this by using a longer wait (same timeout as in SessionToken for a similar problem). Since raw platform MediaSession instances are rare, this is not expected to influence many practical scenarios. Added a new test to confirm that connecting a new controller to a released session throws a SecurityException as explained in the Javadoc. This test fails in 70% of the time without this fix as the session is falsely marked as connected even though it's already released. PiperOrigin-RevId: 765238374 * Add missing onPostConnect callback for legacy controllers This callback isn't particularly useful for these controllers as the main purpose of the callback is to set custom per-controller settings, which isn't possible for legacy controllers. However, we should still call the method for full consistency. PiperOrigin-RevId: 765238862 * Rollback of https://github.com/androidx/media/commit/5a7d545fd667500f3b1e68d26fd8b0a1466e21ea PiperOrigin-RevId: 766081925 * Wrap edited media item indices in SequenceRenderersFactory PiperOrigin-RevId: 766098042 * MCVR: Do not discard parts of encrypted AV1 input buffers experimentalSetParseAv1SampleDependencies allows discarding parts of compressed AV1 input buffers ISO BMFF common encryption allows decrypting full samples, as present in the container: full AV1 buffer discarding is supported. However, the more advanced AV1 bitstream rewriting done by MCVR is not correct. PiperOrigin-RevId: 766110138 * Allow setting composition multiple times and not re-prepare the players But all internal pipelines will be reconfigured. The optimizations not to reconfigure will be in follow up CLs. Also for video, Composition effect and VideoCompositorSettings won't be updated for changed composition, this will also be addressed later. PiperOrigin-RevId: 766165097 * [b/353490583] Remove outdated TODO in `libraries/muxer/build.gradle` I've ran `./gradlew :lib-muxer:lintDebug` locally, and it didn't report any issue. So I've enabled Lint for the test source set and removed the corresponding TODO. * Allow enabled BufferingVideoSinks to feed InputVideoSink when ready When prewarming video renderers, there is a period where the first media item is fully input into the VideoGraph but not fully played yet, and the second renderer is enabled but not yet started. This change means we will now activate the second BufferingVideoSink on the secondary renderer at this point and start feeding frames from the second media item into the VideoGraph. PiperOrigin-RevId: 766557694 * Clean up some legacy/platform wording in the session module All public documentation should usually refer to platform media sessions (which are not legacy per se). In many cases the docs refer to backwards compatibility with androidx.media and we can refer to those classes as legacy while mentioning them explicitly. PiperOrigin-RevId: 766563920 * Make show notification behavior for IDLE players configurable Apps may have different requirements and expectations. Make the behavior configurable between always showing, never showing, or only showing after we had a notification before and it wasn't dismissed (default). Issue: androidx/media#2423 PiperOrigin-RevId: 766585563 * Rollback of https://github.com/androidx/media/commit/20c130260a55456e3b47a504d4083a362d33d23a PiperOrigin-RevId: 766608871 * Note that `isMediaCodecFlushEnabled` default when scrubbing may change PiperOrigin-RevId: 766635440 * Fix seeking behavior for externally loaded media Previously, seeking within `ExternallyLoadedMediaPeriod` failed because sample streams weren't reset. This reset is crucial to update the stream state from "end of stream" to "send," enabling proper seeking. PiperOrigin-RevId: 766638277 * Fix WavHeaderReader to parse the format from the extension if provided Currently, the Wav Extractor logic, for a Wav file with the format `WAVE_FORMAT_EXTENSIBLE`, will assume an `ENCODING_PCM_XBIT` encoding with X being the extracted bitdepth. The Extractor should retrieve the correct audio format from the subformat field in the header's extension data. PiperOrigin-RevId: 766678514 * Assume seeking to the end inside the queue can work if loading finished When checking if loading is possible inside the SampleQueue, we don't usually assume that samples beyond the largest queued timestamp are acceptable because there are likely some missing samples that haven't been loaded yet. However, we should be able to assume that the sample could be found in the SampleQueue if loading already finished. For DASH's ChunkSampleStream, we already had similar logic for assuming that samples before the end of the current chunk are all loaded. PiperOrigin-RevId: 767144080 * Split EPII scheduleNextWork more cleanly into dynamic and static The current logic is quite hard to follow due to multiple conditions using isDynamicSchedulingEnabled(). Splitting the logic into two helper methods makes the individual paths easier to read. PiperOrigin-RevId: 767146514 * More explicitly define version number for service SessionTokens Right now it returns version 0, even though it's documented that versions below 1000000 indicate a platform or legacy session. This can be improved by returning a more defined constant for both the platform version as well as the yet-unknown-but-guaranteed- to-be-Media3 version. PiperOrigin-RevId: 767154229 * Enable scrubbing mode in CompositionPlayer Add scrubbing mode methods to CompositionPlayer.java and forward to the sequence players. Add CompositionPlayer reflection to PlayerControlView Forward track selection parameters in CompositionTrackSelection so that scrubbing mode can disable the audio track on-demand Enable scrubbing mode in CompositionPreviewActivity PiperOrigin-RevId: 767156589 * Add ForwardingSimpleBasePlayer#setPlayer It makes the forwarded player replaceable. PiperOrigin-RevId: 767205978 * Publish `VideoDecoderOutputBuffer.initForOffsetFrames` This is used by the recently published `dav1d_jni.cc`, but was accidentally marked internal-only. PiperOrigin-RevId: 767500124 * [b/181312195] Make `CuesWithTimingSubtitle` package-private `ExoplayerCuesDecoder` doesn't seem to exist anymore, so `CuesWithTimingSubtitle` can be made package-private. * Fix: Make cue setText and setBitmap null the other field. * Refactor: Removed randomly inserted whitespace * Add (and tweak) tests * Create an `IdlingMediaCodecAdapterFactory` for Robolectric tests This automatically idles the queueing and callback threads on every ms of the `Looper` that it is instantiated on. This helps to de-flake playback tests using MediaCodec in async mode, by ensuring the buffers are reliably queued and dequeued as the playback thread advances. The factory also provides an explicit `idleQueueingAndCallbackThreads()` method. PiperOrigin-RevId: 767603635 * Use `MediaCodec.FLAG_DECODE_ONLY` in scrubbing mode PiperOrigin-RevId: 767627401 * Clear input buffer on flush in ExternallyLoadedImageDecoder The ExternallyLoadedImageDecoder's flush() method now explicitly clears the inputBuffer. Previously, the inputBuffer was only cleared when queueInputBuffer was called. This could lead to a stale input buffer being held across flushes if dequeueInputBuffer had returned the buffer but queueInputBuffer hadn't been called yet. PiperOrigin-RevId: 767651418 * Use MediaMetadata.Builder in MediaMetadataCompat.getMediaMetadata() In MediaMetadataCompat.getMediaMetadata(), a parcel is used to parcel the data from MediaMetadataCompat, and then the data is unparceled to create a MediaMetadata object out of it. This has an issue of creating intermediate ashmem bitmaps during the parceling and unparceling depending on how many bitmaps are in the metadata. This can be avoided by passing the bitmap objects along using MediaMedata.Builder without parceling/unparceling the bitmaps. There are a few benefits of doing this: * it saves allocations of intermediate ashmem bitmaps * it avoids pixel copies between the bitmaps * it avoids creating an intermediate parcel PiperOrigin-RevId: 767664123 * Reset state when disabling a renderer in bypass mode When bypass-related `MediaCodecRenderer` state is reset during `onDisabled`/`onPositionReset`, then so should the general `MediaCodecRenderer` state fields that are still utilized in bypass mode(ex: `largestQueuedPresentationTimeUs`). PiperOrigin-RevId: 767675787 * Align bitmap decoding size in `CompositionPlayer` and `Transfomer` This removes the use of the deprecated `ImageDecoder.Factory.DEFAULT` in `CompositionPlayer`, and instead limits the max size to 4096 (via a constant shared with Transformer's `DefaultAssetLoaderFactory`). PiperOrigin-RevId: 767979254 * Fix DASH is not caching HTTP 302 redirection when CMCD is enabled in query parameter mode * Move Util to CmcdData and add test * Formatting fixes * Add Uri helper method and remove helper from DashMediaSource * Add release notes * Reduce number of images in test The test was timing out on some emulators. PiperOrigin-RevId: 767995572 * Refactor creating the MediaSources. PiperOrigin-RevId: 768014363 * Throw when PreloadMediaSource is not played on the preload thread The `PreloadMediaSource` has to be preloaded and played on the same thread. This change allows it to signal the thread inconsistency early and informatively. PiperOrigin-RevId: 768046638 * Fix DASH thumbnail decoding downscaling We recently limited bitmap decoding to the screen size by default: https://github.com/androidx/media/commit/80b7045efe9d3863067c37fc3bf98d91129b6abb This inadvertantly also affected whole DASH thumbnail grid images, but it's more correct to limit the size of each thumbnail to the screen size. This issue was revealed when removing the deprecated usage of `ImageDecoder.Factory.DEFAULT` in the test-only `CapturingRenderersFactory`, so this change also fixes that to make the test more realistic. PiperOrigin-RevId: 768094880 * Add support for `ipcm` and `fpcm` boxes in MP4 files PiperOrigin-RevId: 769170156 * notify ShuffleOrder when media item(s) are moved Issue: #1932 Issue: #1381 * Merge release notes * Make default implementation of cloneAndMove a no-op * Rollback of https://github.com/androidx/media/commit/4efbd5b8c0b34903d82c787549a79ec882d7b4a1 PiperOrigin-RevId: 769514726 * Suppress lint error in deliberate test of invalid value PiperOrigin-RevId: 769517985 * Group subtitle renditions by name This is the same logic as already applied to audio renditions (see <unknown commit>). This step doesn't affect track selection since text tracks always use single track selection without adaptation, but it does affect the user-visible grouping (e.g. when track groups are presented in a UI with one choice per group). Issue: androidx/media#1666 PiperOrigin-RevId: 769572756 * Stop exposing internal compat session This exposes too many internal controls. Most cases can live with the platform token that can be exposed more directly. PiperOrigin-RevId: 769616000 * Log track group id in EventLogger tracks output PiperOrigin-RevId: 769618289 * Automated Code Change PiperOrigin-RevId: 770038553 * Remove some unused dependencies * Fix composition demo BUILD file PiperOrigin-RevId: 770107228 * Move platform session logic from PlayerWrapper to MSLegacyStub PlayerWrapper keeps a lot of state and helper methods for the platform session even though the actual user of this data is almost exclusively MediaSessionLegacyStub where the platform session state is handled. And for the few usages outside of this class, it becomes clearer that this refers to the platform session if the data is accessed through MediaSessionLegacyStub. PiperOrigin-RevId: 770128118 * Use existing PlayerInfo when connecting controllers We currently create a new instance from scratch even though we already have one with the latest state available. This is slightly error-prone because the method to create a PlayerInfo from scratch is only meant to be used for the initial state where we have to guess some values (like change reasons). PiperOrigin-RevId: 770129353 * Fix MediaController state masking for seeking in live streams When seeking in live streams, we currently use the period position as the window position, which may crash the controller on the long to integer conversion in Util.percentInt when attempting to use this position to calculate a buffered percentage. Also increase test coverage for more complicated media setups by introducing a period-window-offset in PlaylistTimeline (which makes the corresponding tests in MediaControllerStateMaskingTest fail). PiperOrigin-RevId: 770169767 * Reset frame release forecaster on position reset The previous version of the code assumed incorrect renderer state transitions on a seek. The correct order of events is: 1. onStopped() 2. onPositionReset() 3. drain and feed decoder 4. render first frame 5. onStarted() Resetting the forecaster in onStarted() means input buffers are incorrectly dropped at step 3. feedInputBuffer(). PiperOrigin-RevId: 770211589 * Mark `WebServerDispatcher` and nested classes as `final` The constructors for `WebServerDispatcher` and `Resource` are already private, so this is a no-op for these types. The constructor for `Resource.Builder` is public, but it seems clear that subclassing this would be unexpected, so forbidding it seems reasonable. Adding this keyword to all the classes makes the intention to disallow subclassing clearer and more future-proof. PiperOrigin-RevId: 770214319 * MediaFormatUtil: set profile and level. Set Profile and level key of MediaFormat using codec string of Format object. PiperOrigin-RevId: 770484426 * Add parameterized CompositionPlayer test PiperOrigin-RevId: 770533023 * Restore muxer instrumentation test deps and add explanatory comment * Disable audio session id change reporting after creating audio track PiperOrigin-RevId: 770588095 * Update platform session position compat logic for live streams For live streams, we already clear out the position from the platform session to prevent the live window duration from being shown to users via the platform session. However, we still publish the position within this live window, which should also be reset. In addition, the playback speed needs to be set to zero to prevent controller UIs from interpolating the position forward. The duration should also not just be cleared (as it will default to zero), but explicitly set to a negative value according to METADATA_KEY_DURATION. Finally, if there is no position and duration, we also need to remove the ACTION_SEEK_TO to disable scrubber elements in the UI because seeking in the current item isn't possible without a position and duration. None of this affects Media3 controllers who can already check if a stream is live and provide a better experience to the user. Issue: androidx/media#1758 PiperOrigin-RevId: 770590067 * Move logic for speed changing MediaSource into separate file PiperOrigin-RevId: 770593763 * Disable sleeping for Offload if conditions enabling sleep change Currently we trigger sleeping for offload if sleep has been requested(underlying audio track buffers are full) and we are "playing". We are "playing" if the player is in a READY state, playWhenReady is `true`, and playback is not being suppressed. If "playing" becomes false then the player is no longer "sleeping for offload". PiperOrigin-RevId: 770608824 * Move image output capturing to `PlaybackOutput` This tests the path through `ExoPlayer`, instead of capturing the data earlier at the `ImageRenderer` level. It also more clearly makes `CapturingRenderersFactory` focussed on only audio & video data that doesn't "escape" the player in any other way, so has to be captured directly at the `Renderer` level (or similar, e.g. `AudioSink`). A follow-up change will allow registering a `PlaybackOutput` without a `CapturingRenderersFactory` that doesn't dump audio & video data, to keep tests that only care about subtitle data from a muxed stream clear & focussed. PiperOrigin-RevId: 770654221 * Improve the threading logics in PreCacheHelper and enhance its tests This CL includes below main changes: * Make `downloader.download()` and `downloader.remove()` called on a download thread (`Task` extends `Thread`), which is similar to the `DownloadManager`. Previously `download()` and `remove()` are called on pre-cache thread, but the `Downloader` implementations do not guarantee that their `download()` and `remove()` implementations are executed on the worker thread. For example, the [`ProgressiveDownloader.remove()`](https://github.com/androidx/media/blob/release/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/offline/ProgressiveDownloader.java#L155). Thus, the pre-cache will easily be blocked upon calling such methods. * Add `listenerToken` mechanism to avoid notify the listener with stale events. We allow the `preCache()` to be called for multiple times. At the time that this listener event is executed on application thread, the caller of PreCacheHelper may already initiated another `preCache()` request, which makes the current listener event stale. We use listenerToken to determine whether the current listener event is stale. * Add `PreCacheHelper.release()` to permanently remove all the messages from pre-cache thread, which clearly marks it as end of the lifecycle of this instance. * Add more tests and improve the existing ones with using `FakeDownloader`, which makes the test executions more controllable. PiperOrigin-RevId: 770658958 * Allow a `PlaybackOutput` to be registered without renderer capture This allows tests that only care about text or metadata output to keep their dump files small and focussed. PiperOrigin-RevId: 770670610 * Add deprecation warning suppression to test (utils) using androix.media PiperOrigin-RevId: 771048740 * Move `SpeedProviderMediaPeriod` to where it's used PiperOrigin-RevId: 771080912 * Prevent lingering messages in handler when releasing ExoPlayer This change ensure we are also removing all the messages in the player's handler when releasing it. Previously, we just explicitly removed all the `MSG_DO_SOME_WORK` as the result of `resetInternal()`. This change also fix the javadoc of `TestExoPlayerBuilder.setLooper`. Previously, the expression of "used by the player" easily gave an wrong impression that this will be used as the playback looper. PiperOrigin-RevId: 771102494 * MCVR reset forecaster when stopped or stream replaced The playback position is likely to become discontinuous after stop/start, or when the stream is replaced (in started state). Ensure the forecaster state is reset. PiperOrigin-RevId: 771118522 * Resolve rotation from rotate+reflect `tkhd` transform matrices `sample_rotate_and_reflect.mp4` was created by manually editing the `tkhd` box in a hex editor to be `0,65536,0,65536,0,0,0,0,1073741824`. Issue: androidx/media#2012 PiperOrigin-RevId: 771398625 * `TextRenderer`: Only check for a stream error when there are no cues This is a more complete fix for the inconsistent state introduced in https://github.com/androidx/media/commit/49dec5db8b1b220f7c9a3e805e0087d775239a0b and partially fixed in https://github.com/androidx/media/commit/ecfd9d1e92ec12aba85139f14e91de51da3605da. This change removes the `streamError` field completely, so there's no need to clear it in other methods, and it only checks for an error when we have no future cue change events. Issue: androidx/media#2517 The test data in this change was created by: 1. Modifying `standalone-webvtt/sample.vtt` to have a subtitle in the 1st, 2nd and 5th seconds (so that the 3rd and 4th segments will be empty). 2. Re-encoding `preroll-5s.mp4` to have an I-frame every 1s 3. Creating the DASH stream with shaka packager: ```shell $ packager \ 'in=../5s.mp4,stream=video,segment_template=video$Number$.m4s,init_segment=video_init.mp4' \ 'in=../standalone-webvtt/sample.vtt,stream=text,segment_template=text$Number$.m4s,init_segment=text_init.mp4' \ --mpd_output manifest.mpd \ --segment_duration=1 \ --generate_static_live_mpd ``` PiperOrigin-RevId: 771916959 * Handle empty `Subtitle` instances in `TextRenderer.isReady` PiperOrigin-RevId: 771951038 * Remove #flush() call from #reset() in BaseAudioProcessor In a follow up change, #flush() will provide information about the upcoming stream so that position-based AudioProcessor instances can handle seeks. Thus, preparing an AudioProcessor for a stream/position change when resetting the processor will make less sense. PiperOrigin-RevId: 771965436 * Rollback of https://github.com/androidx/media/commit/4c5e19cc45fb8c87d17fe0f765a00dc237774ea2 PiperOrigin-RevId: 772005058 * Add new chipsets to CodecDbLite Adds the Google Tensor G4 and Qualcomm 8 Elite to CodecDB Lite. Additionally, chipsets are now ordered alphabetically by manufacturer and model for better readability. PiperOrigin-RevId: 772032225 * Add DefaultVideoCompositorListenerTest PiperOrigin-RevId: 772369694 * Disable flaky PreCacheHelperTest This test is flaky, making presubmit and postsubmit workflows unstable. This commit disable it until a fix is implemented. PiperOrigin-RevId: 772406963 * Add duration support and instance-based API to MetadataRetriever This change introduces media duration retrieval to `MetadataRetriever` and migrates its API from static methods to an instance-based, `AutoCloseable` design using a `Builder` pattern. The existing static methods are now deprecated. To use the new API, create a `MetadataRetriever` instance for a specific `MediaItem` via its `Builder`. Since the retriever is `AutoCloseable`, it should be used with a `try-with-resources` block (or Kotlin's `.use` function). Call the `retrieveTrackGroups()`, retrieveTimeline(), and `retrieveDurationUs()` methods to get separate `ListenableFutures` for the corresponding metadata. Tests have been added to cover the new API and features, and existing tests for the deprecated static methods have been preserved to ensure backward compatibility. PiperOrigin-RevId: 772412227 * Hide buffering bar in scrubbing mode Without this, the buffering bar flickers quite distractingly, and behaves differently when scrubbing backwards and forwards. PiperOrigin-RevId: 772439925 * Fix `use-after-free` in `ffmpegReset` for TrueHD It would call `releaseContext(context)` to free the memory, and then subsequently access `context->request_sample_fmt` from the now invalid pointer. This change fixes the bug by reading the `request_sample_fmt` value into a local variable before the `context` is released, ensuring the pointer is valid at the time of access. Fixes: Issue: androidx/media#2514 PiperOrigin-RevId: 772454630 * Fix issue where audio session id updates can cause infinite updates This re-enables reporting of audio session id updates coming from DefaultAudioSink, fixing an issue where this can cause infinite update loops. The infinite loops are caused because the source of truth of the player-wide audio session id is ExoPlayerImpl, but updates originating in DefaultAudioSink are generated on the playback thread. This means we need to avoid sending or accepting updates that are already known. Concretely: 1. DefaultAudioSink.setAudioSessionId shouldn't parrot the update back to the listener, assuming the caller is already aware of the change. This avoids repeated calls to setAudioSessionId with a value that is already known. A test with multiple consecutive updates from the player fails with the infinite loop without this fix. Also updated the documentation of `onAudioSessionIdChanged` to note the callback is for internal changes only. 2. When an internal change is reported, we shouldn't accept new audio session ids until this internal change has been fully acknowledged by the caller. This avoids repeatedly sending new contradictory updates and continuously recreating the AudioTrack. We can test this by sending simultanuous updates from the player while the internal update is already pending. Also clarify the Javadoc again that this internal update needs to be acknowledged before further updates can be accepted. PiperOrigin-RevId: 772466126 * Stabilize CommandButton.extras and .iconUri PiperOrigin-RevId: 772473505 * Avoid preloading next source after DefaultPreloadManager.release called PiperOrigin-RevId: 772477665 * Automated Code Change PiperOrigin-RevId: 772477769 * Refactor VideoGraph This is to make composition settings and effects non-static PiperOrigin-RevId: 772504617 * Ensure getMinDurationToProgress is always called if enabled/started Right now, we make some exceptions: - We don't call the method if STATE_BUFFERING && !playWhenReady. The maximum interval for STATE_BUFFERING is 10ms anyway, so there is no harm in letting the renderer choose a lower value if it wants to (it's already allowed to do that if STATE_BUFFERING and playWhenReady==true, so has to handle the case of not being ready). - If STATE_READY && !playWhenReady, we enforce a wait time of 1 second without giving the renderer a chance to say it needs to be called more often still. This causes a bug, e.g. when seeking to the end of an item where the renderer has read, but not yet decoded all data. This makes the player go into STATE_READY, potentially delaying the first frame by over a second. Moving this timeout into the Renderer gives it more control for this type of case. - This means we need to adjust the default logic of getMinDurationToProgress to only use 1 second if not started and the individual renderer is ready or ended. - The audio renderer logic also needs to add this case speficically, where we can stop calling render frequently once the buffer is full if not started (=same bug, ensure renderer keeps getting called frequently until the buffer is full instead of using 1 second as soon as the renderer reports itself as ready if it has any data). PiperOrigin-RevId: 772512769 * Fix PreCacheHelperTest flaky tests PiperOrigin-RevId: 772948940 * Revert "Automated Code Change" This reverts commit e7ab78141895a540b28f97879420f25c492666d7. * Remove decoder_dav1d and related references * Use MediaMetadata constants to make Lint happy #cherrypick PiperOrigin-RevId: 773670933 (cherry picked from commit 0d688be2489cf880d80fc3d3f2242744a530c112) * Fix release notes link syntax #cherrypick PiperOrigin-RevId: 774689870 (cherry picked from commit 449542ad8305963df6ea9861616b481507020d2d) * Update release notes for Media3 1.8.0-beta01 release PiperOrigin-RevId: 775249072 (cherry picked from commit 03d9f89526286605506a79ca6c84e7a9bb09d040) * Bump Media3 version to 1.8.0-beta01 PiperOrigin-RevId: 775360918 (cherry picked from commit 2677db318e37ea89e8853bcb9b0865ce431f03e7) * Fixes in release notes for 1.8.0-beta01 PiperOrigin-RevId: 775255316 (cherry picked from commit fa106a1a647d289fd84ccb5d47ee66534c8b7a30) * Add `skipLeb128` utility method to `ParsableByteArray` Provides a utility method for skipping LEB128 values without reading them, avoiding the need to declare unused variables when the value is not needed. PiperOrigin-RevId: 773382281 (cherry picked from commit d00f370beb649ffb7087379cb28c8f08e8c21f8d) * Merge pull request #2531 from bennettpeter:vobsub-mp4 PiperOrigin-RevId: 773649256 (cherry picked from commit 0b2f694f5440e74e3e4c78148770f1778d52844e) * Remove unused logic The (dis)connect messages and their replies were only sent from MediaBrowserCompat instances before API 21. This means we can remove the constants and their handling completely. PiperOrigin-RevId: 773652726 (cherry picked from commit fdb17387b815e862392efff286a9fc16a80a0cb7) * Add support for `setIsContentSpatialized` to `AudioAttributes` This change adds support for `android.media.AudioAttributes.setIsContentSpatialized()` which was introduced with android API level 32. Fixes: Issue: androidx/media#2540 PiperOrigin-RevId: 773747168 (cherry picked from commit 6daf7111dbd2cec7d5e2bb5c4b33035a627e38ba) * Support motion photos without Exif at the start The motion photo metadata is stored in XMP which can be stored in a JPEG without an Exif segment, so there's no need to look for an Exif segment. Issue: androidx/media#2552 PiperOrigin-RevId: 774705930 (cherry picked from commit 4242b0e794145fe108befdf9f0de5d5645ebcfb8) * Check package name validity for incoming Media3 session connections The same is already done in the Android platform MediaBrowserService, but needs to be repeated for Media3 only connections that are not verified via this path. #cherrypick PiperOrigin-RevId: 774720837 (cherry picked from commit 311f76d92735a9172928f11b8f0a8d68d8f40b31) * Ensure PlayerSurface views can be reused in reusable containers When the AndroidView created instances are reused, it currently fails to assign the surface to the player correctly. - The local remembered `view` variable is reset and wasn't assigned to the already existing view because the `factory` wasn't run again. Instead we should assign the local variable in `update`, which is run at the point of reusing the view. - To avoid assigning the same surface to multiple players, we need to know which player it was assigned to previously. Since the remembered Compose states are all cleared, we can instead store the currently assigned player as a `tag` in the View itself. This removes the need to have the `registeredPlayer` local state as it now trackes the assigned player within a single usage and across reuses. - The LaunchedEffect can now be run when the view is reused, but the player hasn't actually changed. So we can add an extra check to avoid clearing the player if it hasn't changed. It's still useful to keep setting the same player twice as it re-triggers size callbacks and first frame callbacks which might be needed by the new usage. Also add new test coverage to capture the usage in reusable containers like LazyColumn, both with different players, the same player, and two players (so that the same player reuses the same surface as before). All 3 tests can also be done with `null` assignments to the invisible elements to ensure that the transition via `null` doesn't cause any issues. To actually assert everything works as expected, we need to track all surface interactions more closely and then check the test setup assumptions, and the correct and effective usage via helper methods. This is needed as we can't know exactly how many instances are reused by the LazyColumn in the test and when they are reset, etc. Issue: androidx/media#2493 PiperOrigin-RevId: 774743304 (cherry picked from commit 3ca261842fc57ce2ea3d2f46f5828f1fbe707de5) * Check if target thread is still alive before sending message This avoids logcat warnings about sending messages to dead threads. PiperOrigin-RevId: 775172292 (cherry picked from commit 73c7227eb4d8707d62921a3538b47de6aec7df6e) * Store CommandButton.iconUri in platform CustomAction extras This allows legacy clients to obtain this icon uri and the information won't get lost even when doing a roundtrip conversion between platform and Media3 data. #cherrypick PiperOrigin-RevId: 775178792 (cherry picked from commit 3dc8f90b721f210e22158ad638c80880eb69b534) * Add Codec string for IAMF codec. PiperOrigin-RevId: 775197832 (cherry picked from commit 3d68fa9088286d67710979c6ce36c2f5d7e6de68) * Avoid splice in HLS chunks if it can be fulfilled by discarding This is an extension to https://github.com/androidx/media/commit/6c24cc1f446d9e142cc7d8cb3d52e7a0d4f97f61. While the previous change prevents selecting a new chunk that forces an impossbile splice operation caused by having already read too far, it doesn't prevent the player from reading into the to-be-replaced data later before the chunk can be spliced in. This may still cause stuck playbacks while we are waiting for a suitable splice-in point. Since the most common case during low-latency playback for this situation is going back to a previous independent part or segment, we should be able to avoid the splice entirely by discarding the chunks we are going to replace anyway. If we do this, then we don't need to worry reading into them later. The main conditions that need to be fulfilled for this to work are: - The new chunk must be independent (= we know the first sample could be spliced in successfully anyway) - The replaced chunk must be declared to start at the same time (=we don't need samples of a previous chunk to remain and can discard it entirely). Note that we use the declared start time from the playlist (not the actual sample times) so that this works in the same way as any other ABR switch even if the actual sample times are not perfectly aligned. Issue: androidx/media#2299 #cherrypick PiperOrigin-RevId: 775615562 (cherry picked from commit be6e438e05e8b7b3acb9794fc0cd2aa848aaee08) * Merge pull request #2530 from MGaetan89:fix_warnings PiperOrigin-RevId: 775675121 (cherry picked from commit 929faf1e915a88c7dac35912d903dad4352b3099) * Clarify intended meaning of FORMAT_UNSUPPORTED_SUBTYPE PiperOrigin-RevId: 775728985 (cherry picked from commit 1d976adec900329b21b4ebf41f364c1ea4aa285c) * Merge pull request #2413 from ArtsemKurantsou:rtap-h265-aggregation-packet-support PiperOrigin-RevId: 776088856 (cherry picked from commit 5dc4d94daec9799cad5ad5caf71b75ab2e18897b) * Add back accidentally removed isTv check This was removed in https://github.com/androidx/media/commit/706c3631043f28e276d80b39d4507718097108ad causing non-stereo and non-Dolby tracks to be marked as unsupported on TVs PiperOrigin-RevId: 776155573 (cherry picked from commit 4d22aaa447a96ba94bcf318dd83913b6abb31cb8) * Ensure masking PlayerInfos are not merged into real PlayerInfo updates The masking process in MediaController sends pending actions and creates placeholder PlayerInfo objects. Once all pending actions are received and we got a final new PlayerInfo from the session, the masking stops and we should continue using the real PlayerInfo from session again. The current tracking wasn't quite accurate, leading to some cases where we accidentally merge a masking PlayerInfo with a real one, which may cause exceptions since they may not be compatible. To solve this, we can - Clearly start the masking process by setting pendingPlayerInfo to the currently known PlayerInfo (not just when receiving intermediate updates). This has the nice side effect that we no longer need the pendingBundlingExclusions as we start off with no exlusions already and never have to deal with a pending state that has values excluded. - When ending the masking process, clearly copy over the last real PlayerInfo (without any exclusions), so that no merging with any placeholder/masking PlayerInfo object happens. There is a remaining bug where no-op updated never send a real PlayerInfo, meaning the controller stays in its masking state forever. This causes some of the test flakiness, which we can temporarily work around by sleeping to ensure the order of events in the remote process is guaranteed. PiperOrigin-RevId: 776629604 (cherry picked from commit 6c5c5f2b770524318f0fb0dadabb31805e56b42b) * Merge pull request #2330 from nift4:mbrstrict PiperOrigin-RevId: 777492666 (cherry picked from commit e807fe5f6b6e5f41edb9de3646fd5804c15aa851) * Ensure trick play tracks are not merged with incompatible main group We can only merge groups if they have a clear role flag and language. If the trick play adaptation set differs, don't merge it to avoid logcat warnings about invalid track groups. Issue: androidx/media#2148 PiperOrigin-RevId: 777539261 (cherry picked from commit 7c000e65dcdfbf6da7e6a30976374797a77260ec) * Merge pull request #2453 from nift4:fmp4metadata PiperOrigin-RevId: 777751247 (cherry picked from commit 32716326d42987d903e3b60b07c0bddadd6b54d1) * Add missing request header forwarding in OfflineLicenseHelper There was currently no convenient way to pass down the headers. This can be achieved by accepting a MediaItem.DrmConfiguration directly. Also updated the demo app to forward these values correctly. It currently wrongly forwards the request headers to the MediaDrm key request data. Issue: androidx/media#2169 PiperOrigin-RevId: 777975958 (cherry picked from commit 92ca7aa81957a9f66e190a71ecd02bf678de6c46) * Merge pull request #2317 from mojsdev:feature/prevent-infinite-reloads-for-ll-hls PiperOrigin-RevId: 777992405 (cherry picked from commit 9a0fd5b8b02406d2418d63da93ad1a8bb1b52398) * Merge pull request #2526 from DolbyLaboratories:dlb/ac4-channel-count/dev PiperOrigin-RevId: 778009402 (cherry picked from commit a53f3c6178b77b0eaeb36470cecd567a4a1ea257) * Require flush on seek when `maxNumReorderSamples > 0` If the decoder is reordering samples as the content contains B-Frames, then a flush is required on a seek. #cherrypick PiperOrigin-RevId: 778022166 (cherry picked from commit 5a14369938970909b258d61c591ed182b20721a4) * Make `FakeMediaPeriod.seekToUs` more realistic This change passes `allowTimeBeyondBuffer = isLoadingFinished()`, [similar to `ProgressiveMediaPeriod`](https://github.com/androidx/media/blob/5a14369938970909b258d61c591ed182b20721a4/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ProgressiveMediaPeriod.java#L986). This causes `DefaultAnalyticsCollectorTest.dynamicTimelineChange` to fail because it was expecting is `isLoading` to toggle twice, once in the first period and once in the second period. This was happening before because the `moveMediaItems` call results in seeking to `132900000`, which is beyond the end of the first item's sample stream, which fails with `allowTimeBeyondBuffer = false`, causing the `SampleStream` to be reset, and the data to be loaded again. After this change, the seek succeeds and the sample stream isn't reset, and since loading is instantaneous it all happens during the first period, so this change updates the test to reflect this. PiperOrigin-RevId: 778084324 (cherry picked from commit fce36acd8116608a96d27a2272d803725164abf8) * Rename `ScrubbingModeParameters.isMediaCodecFlushEnabled` The previous name was confusing/problematic for a couple of reasons: 1. It didn't control **all** calls to `MediaCodec.flush()`, we still flushed in some cases (and we are likely to start flushing in more cases too). 2. The default scrubbing value being `false` (as in, that's different/improvement over normal ExoPlayer playback behaviour) was a bit confusing. #cherrypick PiperOrigin-RevId: 778096691 (cherry picked from commit c7ebbb45116ded40bf2ca1a6e4237e50af8e00b4) * Ensure every controller call is eventually finished with new PlayerInfo When controllers send commands, they start masking their state until all these commands have been acknowledged and a new PlayerInfo arrived after they've been acknowledged. This usually works because all these calls change the PlayerInfo in the session in some way. However, if the PlayerInfo stays unchanged, no such update is sent and the controller stays in a masking state forever. To fix this, we can ensure a PlayerInfo is sent by scheduling one when acknowledging a command. This should not trigger additional messages in the normal case as we would trigger a PlayerInfo update anyway. For backwards-compatibility we can fix this issue is a more fuzzy way on the controller side by assuming after 500ms that no real update from the session is arriving and ending the masking state manually. In the masking state tests, this actually highlights a source of flakiness caused by receiving such updates in test listeners even though the listeners don't care about updates beyond the initial masking state update. To fix this, we can only act on these callbacks while we are still waiting for them. This completely removes the flakiness of this class as well. PiperOrigin-RevId: 778415541 (cherry picked from commit bf8d3ec45c2783bd8d0a8f3af95297b1fd2a0338) * Fix race condition in `MetadataRetriever` While `removeCallbacksAndMessages()` is called during release, it doesn't prevent new messages from being posted immediately after, for instance from an asynchronous `MediaSource` callback. This could lead to a race condition where a message is processed after resources have been released, causing errors. This change introduces a released flag to `MediaSourceHandlerCallback`. Once the release message is processed, the flag is set, causing the handler to ignore all subsequent messages. #cherrypick PiperOrigin-RevId: 778467675 (cherry picked from commit 46664da6ca14a131fe1f255f67079203d16a724c) * Move release note to unreleased changes The StrictMode fix didn't go into 1.8.0-beta01 release, but the release note was kept there by mistake. PiperOrigin-RevId: 778499464 (cherry picked from commit 868ff78cef243bc618e90323854a7eb7fa851772) * Add PreCacheHelperTest for HLS and DASH streams PiperOrigin-RevId: 778522928 (cherry picked from commit 858a3ff7dfbfb1d036a23d72c026dbc5bed7af8f) * Fix asset list resolution when joining stream Issue: androidx/media#2558 #cherrypick PiperOrigin-RevId: 778525499 (cherry picked from commit 8e8e1a9a3da88395aca62a57b19a087ba1f290a4) * Fix flakiness in `MetadataRetrieverTest` The `MetadataRetrieverTest` contained flaky tests involving `ListenableFuture` cancellation. A race condition could occur where a future completed before the test was able to call `cancel()` on it, causing an `assertThrows(CancellationException.class, ...)` check to fail. This change makes the cancellation tests deterministic by using a `FakeMediaSource`. Controlling the media source preparation with `setAllowPreparation(false)` ensures the futures are still pending when cancellation is asserted, allowing for reliable verification of the cancellation behavior. #cherrypick PiperOrigin-RevId: 778530526 (cherry picked from commit 138e9e253644b890411869d3e776bb3c6ad1323f) * Require flush when tunneling. In tunneling mode, the decoder handles processing and scheduling of frames. Therefore flushing is required during seeking to inform the decoder to drop all buffers. #cherrypick PiperOrigin-RevId: 778544810 (cherry picked from commit af44f27db7c28bf84f8233a6c7739532f376e543) * Don't add `DECODE_ONLY` flag to buffers which are probably last We need the last buffer to be decoded even if it's before the target seek time, so that we have it available when seeking to the end of a piece of media. #cherrypick PiperOrigin-RevId: 778838574 (cherry picked from commit 6a05bebfcd1a9ee176ede11a85a161faa82e4d41) * [PreCacheHelper] Start downloader after loaders for preparing released This is only applied to progressive media only. #cherrypick PiperOrigin-RevId: 778856425 (cherry picked from commit b8066f9844d7b4bca7b576154b6345932ec2f56d) * Merge pull request #2477 from NoNews:detached_surface_vendors_workaround PiperOrigin-RevId: 778900891 (cherry picked from commit 471075a87adfaebb67c0ce8b7040a8d924a4f757) * Update release notes for Media3 1.8.0-rc01 release PiperOrigin-RevId: 780053771 (cherry picked from commit 0909e893ec8e6e779d34ff4eb02e5c0801b7c1df) * Bump Media3 to 1.8.0-rc01 #cherrypick PiperOrigin-RevId: 780095206 (cherry picked from commit c9ce948ea0b05fd2763f0e85ff6a5eb1dd2cf734) * Move release note to unreleased changes Adding `PlayerTransferState` didn't go into 1.8.0-beta01 release, but the release note was kept there by mistake. It also wasn't cherry-picked into 1.8.0-rc01, so moving it to Unreleased notes section. PiperOrigin-RevId: 780118060 (cherry picked from commit a80f55142f2777aa68c545617a055669d6d70fb4) * Clean up some preload timeout logic values in ImaAdsLoader We used two different preload timeouts, one hardcoded to 4 seconds and one configurable (default 10 seconds) to detect slightly different versions of the same problem that IMA doesn't preload or fail an ad metadata load. This can be aligned to use the same (configurable) timeout. Secondly, this timeout should not be less than the timeout we configured on the IMA SDK itself to load the VAST data. Otherwise IMA has no chance of timing out internally first to potentially provide a better experience (e.g. loading part of the ads instead of marking the entire ad group as failed). PiperOrigin-RevId: 783298825 (cherry picked from commit f894cd5b804aa4bcebb02dedba53c064000cd670) * Fix duration clipping when updating placeholder period != first When we receive a new Timeline while the player is still using placeholder data, we only re-resolve the originally requested position if it's in the first period because the period-window-offset may have changed. For all other periods, this isn't needed because they start at position 0 by definition. Calling Timeline.getPeriodPositionUs has another side effect though to trim the position to be within the duration of the period. This still needs to be done even for subsequent periods in case they changed their duration from a placeholder to a new value. This can be nicely tested in ConcatenatingMediaSource2Test, with a test case seeking beyond the overall duration. The test setup already has a version where the duration gets resolved later. PiperOrigin-RevId: 783347448 (cherry picked from commit bf46c0ed3aeb5100e29281d03d3742c801398942) * Fix HDR sequence being accidentally tonemapped to SDR `PlaybackVideoGraphWrapper` checks if the color transfer of a format is supported; if not, it tonemaps to SDR. The color transfer check happens using `GlUtil.isExtensionSupported()` method, which retrieves the display by calling `EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY)`. This call only retrieves the display without initializing it. When previewing a composition for the first time, the EGL display was not initialized when doing the check, so GlUtil.isExtensionSupported() returned false. This showed as if HDR is not supported on the device so it tonemapped to SDR. The solution is to get the display by calling `GlUtil.getDefaultEglDisplay()` as it initializes the display before getting it. PiperOrigin-RevId: 783369637 (cherry picked from commit cd45020cc456654a0689c23e1fc4be96aa4414b7) * Fix bug in SimpleBasePlayer logic for period offsets When not specifying explicit PeriodData, we use the available data from the MediaItemData object to populate the Timeline.Period. However, there is a bug where this process does not fill in the period-in-window offset correctly. PiperOrigin-RevId: 783744487 (cherry picked from commit dd4d293f9b0ec6eb07d3ebea87552d9aa865ce20) * [HLS] Do not try to seek inside buffer when no chunks are in the buffer When a `HlsSampleStreamWrapper` has no tracks enabled after track selection, it will clear the `mediaChunks` as well as the the sample queue. However, when the tracks of it are newly re-enabled, we should not attempt to seek inside buffer while there is still no chunks at least partially in the buffer. Issue: androidx/media#2598 PiperOrigin-RevId: 783754042 (cherry picked from commit ded7742e92b800f46240d57de6b2711b0d8ac968) * Avoid calling audioTrack.play() on stopped AudioTrack We already avoid calling pause() because it has no effect once the AudioTrack is stopped. But still call play(), leaving the platform AudioTrack in a strange perpetual playing state that does not match our internal state tracking. Also simplify the flow a bit by letting DefaultAudioSink decide that by itself without going via return values from AudioTrackPositionTracker. PiperOrigin-RevId: 784190418 (cherry picked from commit 3f0385246fdf3909b4f442eb9cb79bc14d64e65d) * Rollback of https://github.com/androidx/media/commit/311f76d92735a9172928f11b8f0a8d68d8f40b31 PiperOrigin-RevId: 785381545 (cherry picked from commit 2345eabfdcd201013e2c6694348dec14afd66ae2) * Merge pull request #2633 from MGaetan89:remove-httpengine-datasource PiperOrigin-RevId: 785403247 (cherry picked from commit 9c5e046c1eeb4f056e6d68eb5c3cb4a65cf264d0) * Catch SecurityException when binding to Service This method can throw directly (instead of just returning false) if we are not allowed to bind to the target service. PiperOrigin-RevId: 785426174 (cherry picked from commit eeae96c30542ca1d2abec53935ff350db3e26cd0) * Don't override playback exception when creating the playback state PiperOrigin-RevId: 785793329 (cherry picked from commit b82be5b82f626ee6dbc8c7753a64a85d6a7080c7) * Try to officially disconnect controller in more cases In cases where we intentionally ignore a connection request, we don't currently attempt to call onDisconnected on the controller in all cases. This means such controllers may not be aware they are ignored. Even if some cases only happen with malformed or malicious connection attempts, it's still useful to try and disconnect the connection officially. PiperOrigin-RevId: 785814501 (cherry picked from commit 74872d134a68599c8218678da991a5e086b293d9) * Fix missing onPositionAdvancing callback after AudioTrack is stopped It's currently not triggered at all if the advancing state is not detected before stopping the AudioTrack. This can be fixed by also triggering the callback once stopped, but with fewer checks, as the position is simulated anyway at this point. PiperOrigin-RevId: 785817439 (cherry picked from commit c3e8fc53ce9993c3ee45b0a945e9dff6001e4d2e) * Merge pull request #2425 from MGaetan89:fix_relea…
PreviousNext