22150 Commits

Author SHA1 Message Date
ibaker
f739e2d68c Suppress some instrumentation tests on older API levels
PiperOrigin-RevId: 731257575
(cherry picked from commit 20ea05063bcccec8b83c9848fc5b3dbf4edc290c)
2025-03-03 16:26:31 +00:00
tonihei
fc4112beee Move audio focus management to ExoPlayerImplInternal
This ensures all AudioManager calls are moved off the main
thread.

Having the audio focus management on the playback thread
also allows future improvements like requesting audio focus
only just before the player becomes ready (which is recommended
but not currently done by ExoPlayer).

PiperOrigin-RevId: 730962299
(cherry picked from commit 19c7b2127568e05b829efe2d9943be04657cefd1)
2025-03-03 16:26:31 +00:00
Copybara-Service
9052313245 Merge pull request #2113 from colinkho:lastrebufferinssp
PiperOrigin-RevId: 730919539
(cherry picked from commit 2c866ce50be132858d9cb4c30c174790577f7560)
2025-03-03 16:26:31 +00:00
Copybara-Service
c4a77475c4 Merge pull request #2135 from bubenheimer:handleMoveMediaItems_docfix
PiperOrigin-RevId: 730886871
(cherry picked from commit 57d4f8354a90960adeb2241683c2b175c03b3ce7)
2025-03-03 16:26:31 +00:00
ibaker
954a1d44e4 Bump play-services-cast-framework cast dependency to 21.5.0
This resolves an app crash on devices with Google Play Services
installed but disabled due to `FLAG_MUTABLE` on a `PendingIntent`.

Issue: androidx/media#2178

#cherrypick

PiperOrigin-RevId: 730885329
(cherry picked from commit c4eef6042bbd814cbf25b3bb91ae1433618a290a)
2025-03-03 16:26:31 +00:00
ibaker
8b9e9203a1 Add missing call to adjustUuid in FrameworkMediaDrm
Before API 27, the platform DRM components incorrectly expected
`C.COMMON_PSSH_UUID` instead of `C.CLEARKEY_UUID` in order to perform
ClearKey decryption. `FrameworkMediaDrm` is responsible for doing this
adjustment on these API levels, but this call was missed when
refactoring some DRM code in
c872af4bc0.

This led to `MediaCodec$CryptoException: Operation not supported in this
configuration` errors when doing ClearKey playback on devices with
API < 27. This was because the earlier, clearer error from the
`MediaCrypto` constructor was being swallowed and transformed to
`requiresSecureDecoder = true` by the `catch` logic in
`FrameworkMediaDrm.requiresSecureDecoder`.

This change also makes the error handling in
`FrameworkMediaDrm.requiresSecureDecoder` more robust by assuming
`requiresSecure = false` for ClearKey (and true for all other DRM
schemes), since we know that ClearKey never supports secure decoding.
This will help avoid more ClearKey playback failures if we see other,
unrelated, errors at this point.

Issue: androidx/media#1732

#cherrypick

PiperOrigin-RevId: 730882278
(cherry picked from commit ecb83f3b738db25f503153617ba9db7bb9dc5b4b)
2025-03-03 16:26:31 +00:00
tonihei
317bf3c6c0 Add kotlin-stdlib to aar workaround list
#cherrypick

PiperOrigin-RevId: 730880594
(cherry picked from commit a3f281dff827cbc63482d5e2fbdbedb2427cbb95)
2025-03-03 16:26:31 +00:00
dancho
521c385d4b Add experimentalSetCodecsToParseWithinGopSampleDependencies to HLS
HLS extractors were missing
experimentalSetCodecsToParseWithinGopSampleDependencies prior to this patch.

PiperOrigin-RevId: 730878460
(cherry picked from commit da402cfd64ef3ae60607491730f01138177a077b)
2025-03-03 16:26:31 +00:00
Copybara-Service
a578d43324 Merge pull request #2115 from MGaetan89:use_objects_equals
PiperOrigin-RevId: 730860597
(cherry picked from commit cc44de8757501cab7e4bb70fd0b090c6dc9799e1)
2025-03-03 16:26:31 +00:00
Copybara-Service
28b70f7e85 Merge pull request #2145 from v-novaltd:dsparano-exo328
PiperOrigin-RevId: 730853667
(cherry picked from commit 85467b9b57ab8ee38cfcb6c9e0f484fd167df372)
2025-03-03 16:26:31 +00:00
ibaker
d755a0477d Fix casting in ParsableByteArray.peekCharacterAndSize
This was introduced in 841bdc6efe.

There's no need to cast the `char` (2 bytes) down to a `byte` in order
to pack it into an `int` (4 bytes) alongside a short (2 bytes).

We also don't need to use `short` to track the character count (max 4
with UTF-8) - a single byte is enough. This change also uses
`Ints.fromBytes` to avoid having to reason about how casting &
bit-shifting interact.

This change introduces a test which reproduces the failure reported in
Issue: androidx/media#2167.

#cherrypick

PiperOrigin-RevId: 730809219
(cherry picked from commit fe19d8c9be94bbf1a1be8d3f49b2de52f0e2f1ae)
2025-03-03 16:26:31 +00:00
tonihei
1f691106f1 Clarify that multiple LibraryParams fields can be set
Issue: androidx/media#2159
PiperOrigin-RevId: 730805485
(cherry picked from commit 3f493eaf9e01909094e99c173cec96b1256f5ca4)
2025-03-03 16:26:31 +00:00
ivanbuper
77c8ddd884 Rollback of 6e9a2cc0cd
PiperOrigin-RevId: 730482824
(cherry picked from commit ee6eb98d4bd4f63270744e25b606208a4a950288)
2025-03-03 16:26:31 +00:00
tonihei
50f6bdd1fd Do not change audio capabilities for error recovery without context
If the deprecated path without a context is used, the capabilities
are set externally and can't recover automatically back to the real
capabilities.

Issue: androidx/media#2168
PiperOrigin-RevId: 730427339
(cherry picked from commit 5610cc846589aafa416c39567f4f5599e98a77ef)
2025-03-03 16:26:31 +00:00
shahddaghash
ff65d7b05b Enable metrics collection by default
PiperOrigin-RevId: 730383523
(cherry picked from commit c90ca4e86ee042f6ce8c6971e075bf0f8d893901)
2025-03-03 16:26:31 +00:00
bachinger
6c143230d7 Avoid rare NPE in MediaSessionServiceTest
PiperOrigin-RevId: 730363453
(cherry picked from commit 76df13d390e57f4462e9e44b20997c6e7dfb8148)
2025-03-03 16:26:31 +00:00
dancho
62ef83b68e MCVR: limit the number of consecutive dropped input frame headers
Dropping too many consecutive input buffers reduces the update
frequency of MCVR.shouldDropDecoderInputBuffers and can lead to
dropping too many consecutive input buffers.

Discarding input buffers of type OBU_FRAME_HEADER with
show_existing_frame = 1 saves a smaller amount of resources
than discarding input buffers of type OBU_FRAME.
PiperOrigin-RevId: 730362707

(cherry picked from commit 67e99f46481dbc5fff9ffd04ff13119dac9199bb)
2025-03-03 16:26:30 +00:00
bachinger
8ee2532db3 Deflake MediaSessionServiceTest
`onConnect_controllerInfo_sameInstanceFromServiceToConnectedControllerManager`
was flaky because `onDestroy()` of `MockMediaSessionService` was cleaning
up the `TestServiceRegistry`. This includes releasing the session of the service
after which no further `MediaSession.Callback` methods are called. This created
a race between `Callback.onDisconnected` and the `Mediasession.release()` being
called.

`onDestroy()` is called unexpectedly early because the controller unbinds as the
last controller from the service that never was started (`onStartCommand` never
called). In such a case the service is immediately terminated by the system after
the last client unbinds from the service, which called `onDestroy()` on the mock
service.

This change making `MockMediaSessionService` optionally not clean up the
registry in `onDestroy()` prevents the session from being released too early.
Alternatively, starting playback and hence starting the service into the
foreground would prevent the problem as well for the purpose of the test.
Another alternative to fix the test would be removing the session from the
service before releasing the controller.

PiperOrigin-RevId: 730361199
(cherry picked from commit fbe186a70ccb588889d0909ccfc07affaf49ec51)
2025-03-03 16:26:30 +00:00
Copybara-Service
4d50e8a815 Merge pull request #2170 from wischnow:main
PiperOrigin-RevId: 729558029
(cherry picked from commit 7c2e8c1c4b608bc5da5649d7f2d7f9674dba5d36)
2025-03-03 16:26:30 +00:00
Copybara-Service
2c123dedbb Merge pull request #2149 from bubenheimer:util_postorrun_fix
PiperOrigin-RevId: 729495445
(cherry picked from commit 05c8a66dc256b2658bfc4cf43b7e9435dbc75b54)
2025-03-03 16:26:30 +00:00
Copybara-Service
7ed1ebea3a Merge pull request #2139 from bubenheimer:handleReplaceMediaItems_removerangecodefix
PiperOrigin-RevId: 729490370
(cherry picked from commit 2b12a574473c6304511f76325e1927ca50c264bf)
2025-03-03 16:26:30 +00:00
Copybara-Service
b8468bbee3 Merge pull request #2136 from bubenheimer:handleReplaceMediaItems_docfix
PiperOrigin-RevId: 729474558
(cherry picked from commit 378e70e15fe38eae33ab7ed74ea9614ba6ec45cb)
2025-03-03 16:26:30 +00:00
shahddaghash
a5d7be959b Update exporter and muxer name to match expected pattern
If the name does not match patten, it gets skipped when reporting.

PiperOrigin-RevId: 729463344
(cherry picked from commit 23ebea7ab4afe1cff4b4c3fce222e33639dfd34e)
2025-03-03 16:26:30 +00:00
tonihei
073e50a893 Ensure DataSource is closed in CacheWriter at non-IOException
We currently only catch IOExceptions to close the opened data source.
This means any other type of exception leaves the data source open,
which can caused SimpleCache to be blocked forever when another
data source tries to access the same cache area (which is still
locked by the open data source).

This problem was the cause for flakiness in DownloadManagerDashTest.

#cherrypick

Issue: google/ExoPlayer#9760
PiperOrigin-RevId: 729441817
(cherry picked from commit 72c85aa48393e47642688c8147bdf18d6e3d4bbf)
2025-03-03 16:26:30 +00:00
tianyifeng
8e5368a807 Mask ExoPlayer.isLoading when it transitions to IDLE or ENDED states
In some cases, the ExoPlayer immediately transitions to `STATE_IDLE` or `STATE_ENDED` on application thread, while `isLoading` can still remain as `true` before it is finally updated from playback thread.

Issue: androidx/media#2133

#cherrypick

PiperOrigin-RevId: 728724157
(cherry picked from commit daf8f9ff584e52128b94b4b08a1e9cf7ba94dee2)
2025-03-03 16:26:30 +00:00
shahddaghash
816a119617 Verify each export had its own session
This is done by getting the session ID for the `EditingSession` and making sure it's unique from the other session ID.

PiperOrigin-RevId: 728680628
(cherry picked from commit ae3eed234382d95bd9187c965c6b949be97fda63)
2025-03-03 16:26:30 +00:00
Googler
13e14b8e31 Update the list of supported video mimetypes.
Add VP9 and APV codecs to the list of supported video mimetypes for Mp4Muxer and Fragmented Mp4Muxer.

PiperOrigin-RevId: 728603222
(cherry picked from commit 1461e9e93a94e2cb27c096dea2c6c2eee934c3df)
2025-03-03 16:26:30 +00:00
jbibik
41062d3910 Fix Shuffle and Repeat references in tests
PiperOrigin-RevId: 728309204
(cherry picked from commit 4045acd13b17c68d7fe532cb7ba746517f83f089)
2025-03-03 16:26:30 +00:00
shahddaghash
e393587787 Add test for usePlatformDiagnostics disabled
PiperOrigin-RevId: 728276994
(cherry picked from commit 90844f11e88ad9dbb26c7fd4bd72d99c577b9c54)
2025-03-03 16:26:30 +00:00
tonihei
d880ab5d4f Make SimpleBasePlayer.State public
This ensures it's easier to handle these State updates in other
helper classes if needed.

Issue: androidx/media#2128

PiperOrigin-RevId: 728264396
(cherry picked from commit f1c62c12394e3c408b24d98ed2472ed88db3e918)
2025-03-03 16:26:25 +00:00
tonihei
75da514b7f Decouple gradle publish task from lint and test
The publish task currently forces to run lint and test
even though there is no technical dependency. If a
process (e.g. releasing a new library) wants to verify
lint and test work, it should run these steps explicitly.

#cherrypick

PiperOrigin-RevId: 728234811
(cherry picked from commit 4b991ad42f3139e7e528a87bf19056bfdb5d9f5a)
2025-03-03 16:25:01 +00:00
shahddaghash
cb2df35a5b Add EditingMetricsCollector test for export cancellation
PiperOrigin-RevId: 727885381
(cherry picked from commit 116fbeaa81b648b6a4bd2f8b202a2140f2450a98)
2025-03-03 16:25:01 +00:00
shahddaghash
ed05bc67c3 Move FrameBlockingMuxer into AndroidTestUtil
This allows it to be reused in upcoming tests.

PiperOrigin-RevId: 727835985
(cherry picked from commit f8d5f5a828d0783725696a27a12b78f577effaa0)
2025-03-03 16:25:01 +00:00
shahddaghash
4a8d28cef8 Add EditingMetricsCollector test for export error
PiperOrigin-RevId: 727835981
(cherry picked from commit 6f60aa2548c556370f1e0bb1aaf33a42c460f33c)
2025-03-03 16:25:00 +00:00
shahddaghash
16add9922d Add EditingMetricsCollector test for export success
PiperOrigin-RevId: 727826326
(cherry picked from commit 3ce6a2e6b8b0b7147a06c5ec38aaf2ee36282720)
2025-03-03 16:25:00 +00:00
shahddaghash
e58d9120bc Create a new MetricsReporter.Factory
This includes creating a new Factory for `MetricsReporter` and adding it to Transformer. This is done as we need to create a new `MetricsReporter` for each export operation, so it makes sense to have a Factory.

PiperOrigin-RevId: 727798528
(cherry picked from commit 6d408c2d31bddacb254bb0cc917e4ecd5d0e4b66)
2025-03-03 16:25:00 +00:00
bachinger
bb358241b9 Make setSessionActivity accept null
Issue: androidx/media#2109
PiperOrigin-RevId: 728160580
(cherry picked from commit 2b8700beaaabd51365daf9099c42bfa64a2dd4fe)
1.6.0-beta01
2025-02-18 14:11:51 +00:00
tonihei
bc872503b9 Ignore .kotlin directory
#cherrypick

PiperOrigin-RevId: 728119609
(cherry picked from commit 0a50741abec718c09e52c5f00cc241a00eeba23d)
2025-02-18 14:09:17 +00:00
tonihei
b49374c8fe Remove unreleased section from RELEASENOTES 2025-02-18 09:51:26 +00:00
tonihei
3f10fa92bb Version bump for Media3 1.6.0-beta01
#cherrypick

PiperOrigin-RevId: 727889651
(cherry picked from commit 78cf53c0b2f604b4d04ab749250f4e4fe88e240f)
2025-02-18 09:42:24 +00:00
Googler
625ff234e4 Update CSD and apvC box logic
Update the CSD to contain only the APVDecoderConfigurationRecord and the apvC box to be a full box. The apv clip is also updated to be consistent with the new [specification](https://github.com/AcademySoftwareFoundation/openapv/blob/main/readme/apv_isobmff.md#isobmff-binding-for-apv).

The clip is provided by the openAPV team under BSD-3 license.

PiperOrigin-RevId: 727868656
(cherry picked from commit 653470f73be98e01e972513ec80e58c2d36cbb3a)
2025-02-18 09:42:24 +00:00
tonihei
88e7636ae0 Use different authorities for AssetContentProvider
Otherwise it's impossible to install the androidTest apk
of both lib-datasource and lib-exoplayer on the same device

#cherrypick

PiperOrigin-RevId: 727867871
(cherry picked from commit 527e1d52aedbff53e3ba670d2b6a3cf0b0a84abb)
2025-02-18 09:42:24 +00:00
tonihei
57bbb6c5c6 Update release notes for 1.6.0-beta01
#cherrypick

PiperOrigin-RevId: 727862233
(cherry picked from commit 18f38647732c7fbbafce30d99ab8062da6be2aff)
2025-02-18 09:42:23 +00:00
kimvde
9ad06570b5 Transformer: fix gradle dependency type
PiperOrigin-RevId: 727760498
(cherry picked from commit c1eb381948d5e936bdc9cfb37ca529b816bfcc1b)
2025-02-18 09:42:23 +00:00
tonihei
7db4802f02 Update ignore files for most recent FLAC extension code
Following the README, a libflac directory is created, which
needs to be ignored in VCSs

#cherrypick

PiperOrigin-RevId: 727103140
(cherry picked from commit b306b1059772c2e279020f65ac60ae975fca3fbf)
2025-02-18 09:42:23 +00:00
tonihei
1ceafc7a61 Add timeout to foreground service handling
Currently, as soon as the playback is considered disengaged (not
ready and playing), the foreground service is stopped.
This causes problems if the app or the user attempts to restart
playback after a short amount of time, where apps may run into
foreground service start restrictions.

Almost all of these short-term interaction issues can be solved
by keeping the foreground service running for an additional
timeout period, which is chosen to be 10 minutes to match the
behavior of future Android system enforcements. For any longer
term interactions, apps need to implement playback resumption
paths that can restart the service with the previous playback.

One caveat is that we currently use player.pause() as a way to
stop the foreground service in onTaskRemoved() if the app wants
to abandon playback at this point. With the timeout, the service
can no longer be stopped immediately just by calling pause(),
so we need to explicitly disable the timeout in the corresponding
helper method.

Issue: androidx/media#1928
Issue: androidx/media#111
PiperOrigin-RevId: 726942625
(cherry picked from commit 8a888d0d1801ce018b5bca5dbab78be44507286e)
2025-02-14 18:41:15 +00:00
tonihei
3b897241d2 Increase timeout for AudioPositionAdvancingTest
500ms may not be enough to start playback on a slow device

#cherrypick

PiperOrigin-RevId: 726940099
(cherry picked from commit 792a2ae05dbade27d9cd5a8923a1f3cebf083a91)
2025-02-14 18:41:15 +00:00
tonihei
2a3e733161 Post initial media button preferences update
Controller and browsers are typically obtained with
Futures.addCallback(future, getMainExecutor()), which triggers
the onSuccess callback with a message post. We currently send
the initial media button preferences inline, causing the callback
in MediaController.Listener.onMediaButtonPreferencesChanged to
arrive before the FutureCallback.onSuccess callback.

In the test controller app, which causes crashed when
connecting to existing sessions for example. We can make this
more robust by also posting the initial update of the media button
preferences.

PiperOrigin-RevId: 726923498
(cherry picked from commit d5df227b3ae4d87ec4876cc19ecca814c91c5fd7)
2025-02-14 18:41:15 +00:00
tonihei
22e5f25648 Refine logic to set and interpret ACTION_PAUSE/ACTION_PLAY
We currently set both actions depending on the playWhenReady state
and we require both actions when converting a platform session to
a Media3 session (if ACTION_PLAY_PAUSE isn't set anyway).

This causes problems in two situations:
 - A controller using the platform ACTION_PAUSE/ACTION_PLAY to
   determine which button to show in a UI. This needs to be aligned
   to the existing Util.shouldShowPlayButton we already use when
   setting the PlaybackStateCompat state.
 - A session only setting either ACTION_PAUSE or ACTION_PLAY
   depending on its state. We should check if the action triggered
   by setPlayWhenReady(...) is possible and allow COMMAND_PLAY_PAUSE
   accordingly.

PiperOrigin-RevId: 726916720
(cherry picked from commit 28bfb27fb59ceb0cd209ac1eebd803d31f78afa4)
2025-02-14 18:41:15 +00:00
tonihei
71a2b7d72d Refine conversion logic from platform to Media3 state for STATE_ENDED
When converting to platform states, STATE_ENDED is mapped to
STATE_STOPPED, but the reverse mapping always assumes STATE_STOPPED
means STATE_IDLE at the moment. We can use the same logic we already
apply for STATE_PAUSED to figure out if we are ended.

PiperOrigin-RevId: 726902064
(cherry picked from commit 982403a0ccab31de1f293fb0b8591e2132e11dd2)
2025-02-14 18:41:15 +00:00