15047 Commits

Author SHA1 Message Date
andrewlewis
7ebab0e182 Fix some release notes typos
PiperOrigin-RevId: 495262344
(cherry picked from commit c9e87f050303a78e39aa0c96eab48e30714f3351)
2023-01-25 18:17:15 +00:00
rohks
d91c005a21 Remove parameters with default values from bundle in MediaItem
This improves the time taken to construct PlayerInfo from bundle from ~600ms to ~450ms.

PiperOrigin-RevId: 495055355
(cherry picked from commit 395cf4debc52c9209377ea85a319d2e27c6533ce)
2023-01-25 18:17:15 +00:00
rohks
1e7480d78a Document the reason for defining private method defaultIfNull
PiperOrigin-RevId: 495004732
(cherry picked from commit 610e431c906d71fd684c5c7c8ff8a9aa171a55ef)
2023-01-25 18:17:15 +00:00
tonihei
11bd727ac5 Reset isLoading when calling SimpleBasePlayer.stop/release
isLoading is not allowed to be true when IDLE, so we have to set to
false when stopping in case it was set to true before.

PiperOrigin-RevId: 494975405
(cherry picked from commit 6e7de583bb42871267899776966575512152b111)
2023-01-25 18:17:15 +00:00
tonihei
cdc07e2175 Forward seek command details to seekTo method in BasePlayer
BasePlayer simplifies implementations by handling all the various
seek methods and forwarding to a single method that can then be
implemented by subclasses. However, this loses the information about
the concrete entry point used for seeking, which is relevant when
the subclass wants to verify or filter by Player.Command. This
can be improved by adding the command as a new parameter. Since
we have to change the method anyway, we can also incorporate the
boolean flag about whether the current item is repeated to avoid
the separate method.

PiperOrigin-RevId: 494948094
(cherry picked from commit ab6fc6a08d0908afe59e7cd17fcaefa96acf1816)
2023-01-25 18:17:15 +00:00
tonihei
80be30f511 Clarify and correct allowed multi-threading for some Player methods
Some Player methods like getting the Looper and adding listeners
were always allowed to be called from any thread, but this is
undocumented. This change makes the threading rules of these
methods more explicit.

Removing listeners was never meant to be called from another thread
and we also don't support it safely because final callbacks may
be triggered from the wrong thread. To find potential issues, we
can assert the correct thread when releasing listeners.

Finally, there is a potential race condition when calling addListener
from a different thread at the same time as release, which may lead to
a registered listener that could receive callbacks after the player is
released.

PiperOrigin-RevId: 493843981
(cherry picked from commit 927b2d6a435a236bb5db7646cf6402557db893f6)
2023-01-25 18:17:14 +00:00
tonihei
c32494a3e3 Remove debug timeout multiplier.
It looks like this was added accidentally in <unknown commit>.

PiperOrigin-RevId: 493834134
(cherry picked from commit 533f5288f4aec47a75357bf308907d1686ba493a)
2023-01-25 18:17:14 +00:00
tonihei
71a1254514 Replace MediaMetadata folderType by isBrowsable
The folder type has a mix of information about the item. It shows
whether the item is browsable (type != FOLDER_TYPE_NONE) and
which Bluetooth folder type to set for legacy session information.

It's a lot clearer to split this into a boolean isBrowsable and
use the existing mediaType to map back to the bluetooth folder type
where required.

folderType is not marked as deprecated yet as this would be an API
change, which will be done later.

PiperOrigin-RevId: 493544589
(cherry picked from commit ae8000aecaee725dea51a6ded06125884a5b8112)
2023-01-25 18:17:11 +00:00
tonihei
3b55ce2a60 Support release in SimpleBasePlayer
This adds support for the release handling. To align with the
established behavior in ExoPlayer, the player can only call
listeners from within the release methods (and not afterwards)
and automatically enforces an IDLE state (without listener call)
in case getters of the player are used after release.

PiperOrigin-RevId: 493543958
(cherry picked from commit 4895bc42ff656ba77b604d8c7c93cba64733cc7a)
2023-01-25 18:01:21 +00:00
ibaker
3df6949c52 Add javadoc links to README files
Fix some other link titles and destinations spotted along the way.

#minor-release

PiperOrigin-RevId: 493276172
(cherry picked from commit 636a4a8538ccfb235eeca7d9131d4b5d4d95e9aa)
2023-01-25 18:01:21 +00:00
tonihei
515b6ac595 Fix threading of onFallbackApplied callback
The callback is currently triggered on the ExoPlayer playback thread
instead of the app thread that added the listener.

PiperOrigin-RevId: 492474405
(cherry picked from commit 634c6161f11f33b960023350d418bd3493f5a4b9)
2023-01-25 18:01:17 +00:00
ibaker
f43cc38ce1 Fix ExoPlayerTest to use C.TIME_UNSET instead of C.POSITION_UNSET
This inconsistency was exposed by an upcoming change to deprecate
`POSITION_UNSET` in favour of `INDEX_UNSET` because position is an
ambiguous term between 'byte offset' and 'media position', as shown
here.

PiperOrigin-RevId: 492470241
(cherry picked from commit 2650654dd0d0654fc4cca67b0d3347d88431fa4e)
2023-01-25 17:50:39 +00:00
ibaker
5612f6924a Fix TextRenderer exception when a subtitle file contains no cues
Discovered while investigating Issue: google/ExoPlayer#10823

Example stack trace with the previous code (I added the index value for
debugging):

```
playerFailed [eventTime=44.07, mediaPos=44.01, window=0, period=0, errorCode=ERROR_CODE_FAILED_RUNTIME_CHECK
  androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:635)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loopOnce(Looper.java:202)
      at android.os.Looper.loop(Looper.java:291)
      at android.os.HandlerThread.run(HandlerThread.java:67)
  Caused by: java.lang.IllegalArgumentException: index=-1
      at androidx.media3.common.util.Assertions.checkArgument(Assertions.java:55)
      at androidx.media3.extractor.text.webvtt.WebvttSubtitle.getEventTime(WebvttSubtitle.java:62)
      at androidx.media3.extractor.text.SubtitleOutputBuffer.getEventTime(SubtitleOutputBuffer.java:56)
      at androidx.media3.exoplayer.text.TextRenderer.getCurrentEventTimeUs(TextRenderer.java:435)
      at androidx.media3.exoplayer.text.TextRenderer.render(TextRenderer.java:268)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1008)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:509)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loopOnce(Looper.java:202)
      at android.os.Looper.loop(Looper.java:291)
      at android.os.HandlerThread.run(HandlerThread.java:67)
]
```

#minor-release

PiperOrigin-RevId: 492464180
(cherry picked from commit 33bbb9511a9ac6ad6495d4e264f8e248c4342763)
2023-01-25 17:50:39 +00:00
michaelkatz
8844b4f646 Removed ExoPlayer specific states from SimpleBasePlayer
PiperOrigin-RevId: 492443147
(cherry picked from commit 2fd38e3912960c38d75bce32cc275c985a2722c1)
2023-01-25 17:50:39 +00:00
michaelkatz
c4f1c047ca Added cancellation check for MediaBrowserFuture in demo session app
When app is deployed with device's screen being off, MainActivity's onStart is called swiftly by its onStop. The onStop method cancels the browserFuture task which in turn "completes" the task. Upon task "completion", pushRoot() runs and then throws error as it calls get() a cancelled task.

PiperOrigin-RevId: 492416445
(cherry picked from commit 64603cba8db9fbd9615e19701464c4d0734a86dc)
2023-01-25 17:50:39 +00:00
tonihei
8618263b99 Write media type with a custom key to legacy components.
This allows legacy media controllers and browsers to access this
information and legacy sessions and browser services to set this
information.

PiperOrigin-RevId: 492414716
(cherry picked from commit ca4c6efdb7fdb50cef116d26360b79ed75a6401e)
2023-01-25 17:50:39 +00:00
bachinger
868e86cd3f Stop service when app is terminated while the player is paused
If the service ever has been started but is not in the foreground, the
service would be terminated without calling onDestroy(). This is because
when onStartCommand returns START_STICKY [1], the app takes the
responsibility to stop the service.

Note that this change interrupts the user journey when paused, because the
notification is removed. Apps can implement playback resumption [2] to give
the user an option to resume playback after the service has been terminated.

[1] https://developer.android.com/reference/android/app/Service#START_STICKY
[2] https://developer.android.com/guide/topics/media/media-controls#supporting_playback_resumption

Issue: androidx/media#175
#minor-release
PiperOrigin-RevId: 492192690
(cherry picked from commit 6a5ac19140253e7e78ea65745914b0746e527058)
2023-01-25 17:50:39 +00:00
christosts
1a9b1c4d35 Reduce log output for failing bitmap loads
Do not log the exception stack traces raised by the BitmapLoader when a
bitmap fails to load, e.g. when the artwork's URI scheme is not
supported by the SimpleBitmapLoader. The logs are kept in place but only
a single line is printed.

#minor-release

PiperOrigin-RevId: 492191461
(cherry picked from commit f768ff970ca15483bcb02c1cf41746b67ec8c3ac)
2023-01-25 17:50:39 +00:00
ibaker
102873b6e1 Split SubripDecoder and ParsableByteArray tests
In some cases we split a test method, and in other cases we just add
line breaks to make the separation between arrange/act/assert more
clear.

PiperOrigin-RevId: 492182769
(cherry picked from commit e4fb663b23e38eb6e41b742681bf80b872baad24)
2023-01-25 17:50:39 +00:00
Ian Baker
6e58ca6baa Merge pull request #10750 from Stronger197:subrip_utf_16
PiperOrigin-RevId: 492164739
(cherry picked from commit a9191418051a19681ddf884163ac5553871ec658)
2023-01-25 17:50:39 +00:00
tonihei
f8155f1cd4 Add support for most setters in SimpleBasePlayer
This adds the forwarding logic for most setters in SimpleExoPlayer
in the same style as the existing logic for setPlayWhenReady.

This change doesn't implement the setters for modifying media items,
seeking and releasing yet as they require additional handling that
goes beyond the repeated implementation pattern in this change.

PiperOrigin-RevId: 492124399
(cherry picked from commit f007238745850791f8521e61f6adaf8ed2467c45)
2023-01-25 17:50:39 +00:00
tonihei
ed38ec79bc Add media type to MediaMetadata
This helps to denote what type of content or folder the metadata
describes.

PiperOrigin-RevId: 492123690
(cherry picked from commit 32fafefae81e0ab6d3769152e584981c1a62fc60)
2023-01-25 17:50:35 +00:00
rohks
8932c52122 Parse and set bitrates in Ac3Reader
PiperOrigin-RevId: 492003800
(cherry picked from commit c7aa54cb411e485c2c17e630779d9e27d758a550)
2023-01-25 17:49:34 +00:00
Googler
93694b2283 Decomission ControllerInfoProxy in favor of ControllerInfo.
This CL makes it possible to create a media3 ControllerInfo in test code, which is needed to test several aspects of a media3-based media app. It does this by exposing a test-only static factory method. This is a hacky low-effort approach; a better solution could be to split ControllerInfo up into a public interface that was exposed to client logic, and that they could extend, and a package-private implementation with internal fields like the callback. That's a much bigger change, however.

PiperOrigin-RevId: 491978830
(cherry picked from commit 69093db7f5889037a3b55e3d1a7242c31ce62f2f)
2023-01-25 17:49:34 +00:00
tonihei
05f640ec7d Rename SimpleBasePlayer.PlaylistItem to MediaItemData
This better matches the terminology we use elsewhere in the Player
interface, where items inside the playlist are referred to as
"media item" and only the entire list is called "playlist".

PiperOrigin-RevId: 491882849
(cherry picked from commit ff7fe222b83c55c93cc9ee1a3763a11473168ece)
2023-01-25 17:49:34 +00:00
bachinger
665f04d70a Use the artist as the subtitle of the legacy media description
The Bluetooth AVRCP service expects the metadata of the item currently
being played to be in sync with the corresponding media description in
the active item of the queue. The comparison expects the metadata values
of `METADATA_KEY_TITLE` and `METADATA_KEY_ARTIST` [1] to be equal to the
`title` and `subtitle` field of the `MediaDescription` [2] of the
corresponding queue item.

Hence we need to populate the media description accordingly to avoid the
BT service to delay the update for two seconds and log an exception.

[1] https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/android/app/src/com/android/bluetooth/audio_util/helpers/Metadata.java;l=120
[2] https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/android/app/src/com/android/bluetooth/audio_util/MediaPlayerWrapper.java;l=258

Issue: androidx/media#148
PiperOrigin-RevId: 491877806
(cherry picked from commit 2a07a0b44582782b09a96b5819e9899308e79545)
2023-01-25 17:49:34 +00:00
rohks
4ecbd77442 Add public constructors to DefaultMediaNotificationProvider
Issue: androidx/media#213

Without a public constructor, it is not possible to extend this class and override its method.

PiperOrigin-RevId: 491673111
(cherry picked from commit f3e450e7833bbc62237c1f24f9a1f6c4eed21460)
2023-01-25 17:49:34 +00:00
christosts
bb7e6324d8 Use audio bitrate to calculate AudioTrack min buffer in passthrough
Use the bitrate of the audio format (when available) in
DefaultAudioSink.AudioTrackBufferSizeProvider.getBufferSizeInBytes() to
calculate accurate buffer sizes for direct (passthrough) playbacks.

#minor-release

PiperOrigin-RevId: 491628530
(cherry picked from commit d12afe0596b11c473b242d6389bc7c538a988238)
2023-01-25 17:49:34 +00:00
tonihei
e85e497911 Add configuration to support OPUS offload
To support OPUS offload, we need to provide a few configuration values
that are currently not set due to the lack of devices supporting
OPUS offload.

PiperOrigin-RevId: 491613716
(cherry picked from commit 568fa1e1fa479fd1659abf1d83d71e01227ab9cf)
2023-01-25 17:49:30 +00:00
bachinger
1d082ee9a7 Bump cast sdk version and remove workaround for live duration
The fix for b/171657375 (internal) has been shipped with 21.1.0 already
(see https://developers.google.com/cast/docs/release-notes#august-8,-2022).

PiperOrigin-RevId: 491583727
(cherry picked from commit 835d3c89f2099ca66c5b5f7af686eace1ac17eb8)
2023-01-25 17:42:21 +00:00
Rohit Singh
3bf99706dc Merge pull request #10776 from dongvanhung:feature/add_support_clear_download_manager_helpers
PiperOrigin-RevId: 491336828
(cherry picked from commit 3581ccde29f0b70b113e38456ff07167267b0ad9)
2023-01-25 17:41:44 +00:00
ibaker
289f0cf00b Remove impossible UnsupportedEncodingException from Id3Decoder
The list of charsets is already hard-coded, and using `Charset` types
ensures they will all be present at run-time, hence we will never
encounter an 'unsupported' charset.

PiperOrigin-RevId: 491324466
(cherry picked from commit 5292e408a6fd000c1a125519e22a7c18460eed59)
2023-01-25 17:41:44 +00:00
ibaker
26f5e9b83c Split up Id3DecoderTest methods
It's clearer if each test method follows the Arrange/Act/Assert pattern

PiperOrigin-RevId: 491299379
(cherry picked from commit fc5d17832f90f36eb30ee0058204d110e27adcc9)
2023-01-25 17:41:43 +00:00
Rohit Singh
887179f50a Merge pull request #10799 from OxygenCobalt:id3v2-multi-value
PiperOrigin-RevId: 491289028
(cherry picked from commit b81d5f304e2f5fc55577e31c31ff6df5ce7d0ef5)
2023-01-25 17:41:39 +00:00
tonihei
f9c6fb4e90 Ensure messages sent on a dead thread don't block FakeClock execution
FakeClock keeps an internal list of messages to be executed to
ensure deterministic serialization. The next message from the list
is triggered by a separate helper message sent to the real Handler.
However, if the target HandlerThread is no longer alive (e.g. when
it quit itself during the message execution), this helper
message is never executed and the entire message execution chain
is stuck forever.

This can be solved by checking the return values of Hander.post or
Handler.sendMessage, which are false if the message won't be
delivered. If the messages are not delivered, we can unblock the
chain by marking the message as complete and triggering the next
one.

PiperOrigin-RevId: 491275031
(cherry picked from commit 8fcc06309323847b47ed8ab225cd861335448d36)
2023-01-25 17:41:00 +00:00
ibaker
d5815c5ab0 Clean up javadoc on Metadata.Entry.populateMediaMetadata
Remove self-links, and remove section that is documenting internal
ordering behaviour of
[`SimpleBasePlayer.getCombinedMediaMetadata`](bb270c62cf/library/common/src/main/java/com/google/android/exoplayer2/SimpleBasePlayer.java (L1770))
rather than anything specifically about this method.

#minor-release

PiperOrigin-RevId: 490923719
(cherry picked from commit a6703285d0d1bedd946a8477cb68c46b1a097b09)
2023-01-25 17:41:00 +00:00
tonihei
8767605f5c Remove flakiness from DefaultAnalyticsCollectorTest
Our FakeClock generally makes sure that playback tests are fully
deterministic. However, this fails if the test uses blocking waits
with clock.onThreadBlocked and where relevant Handlers are created
without using the clock.

To fix the flakiness, we can make the following adjustments:
 - Use TestExoPlayerBuilder instead of legacy ExoPlayerTestRunner
   to avoid onThreadBlocked calls. This also makes the tests more
   readable.
 - Use clock to create Handler for FakeVideoRenderer and
   FakeAudioRenderer. Ideally, this should be passed through
   RenderersFactory, but it's too disruptive given this is a
   public API.
 - Use clock for MediaSourceList and MediaPeriodQueue update
   handler.

PiperOrigin-RevId: 490907495
(cherry picked from commit 6abc94a8b7180979c520fc581310b87bf297b1bb)
2023-01-25 17:41:00 +00:00
rohks
30dce91fc0 Convert bitrates to bps before setting it
Format expects the values of `averageBitrate` and `peakBitrate` in bps and the value fetched from AC3SpecificBox and EC3SpecificBox is in kbps.

PiperOrigin-RevId: 490756581
(cherry picked from commit 4066970ce7292642794f4a3954f8d0fde78dd310)
2023-01-25 17:41:00 +00:00
rohks
5ebbdc52cb Use ParsableBitArray instead of ParsableByteArray
To avoid complicated bit shifting and masking. Also makes the code more readable.

PiperOrigin-RevId: 490749482
(cherry picked from commit 3d31e094a9e802354dce2f3dc5f33062f7624248)
2023-01-25 17:41:00 +00:00
rohks
fda132f926 Rollback of 427329175e
*** Original commit ***

Rollback of 76df06a7a3

*** Original commit ***

Parse and set `peakBitrate` for Dolby TrueHD(AC-3) and (E-)AC-3

#minor-release

***

***

PiperOrigin-RevId: 490707234
(cherry picked from commit 82711630ed1afbe7417aad95244a91135e24c27f)
2023-01-25 17:41:00 +00:00
rohks
32f7a8b807 Rollback of 76df06a7a3
*** Original commit ***

Parse and set `peakBitrate` for Dolby TrueHD(AC-3) and (E-)AC-3

#minor-release

***

PiperOrigin-RevId: 490570517
(cherry picked from commit 427329175e87a7f3173791c59e6c2d4c4ed8dea4)
2023-01-25 17:41:00 +00:00
rohks
101a2498a0 Parse and set peakBitrate for Dolby TrueHD(AC-3) and (E-)AC-3
#minor-release

PiperOrigin-RevId: 490527831
(cherry picked from commit 76df06a7a364c580dfe07d9f069237cd77c5174c)
2023-01-25 17:41:00 +00:00
tianyifeng
d58b4fd6a6 Handle the bitmap loading result with applicationHandler
Before this change, the bitmap loading result with mainHandler, in which we set the metadata to `MediaSessionCompat`. However, the `MediaSessionCompat` is not thread safe, all calls should be made from the same thread. In the other calls to `MediaSessionCompat`, we ensure that they are on the application thread (which may be or may not be main thread), so we should do the same for `setMetadata` when bitmap arrives.

Also removes a comment in `DefaultMediaNotificationProvider` as bitmap request caching is already moved to CacheBitmapLoader.

PiperOrigin-RevId: 490524209
(cherry picked from commit 80927260fd46413b7d1efafed72360b10049af2a)
2023-01-25 17:41:00 +00:00
christosts
b495d21f04 Misc fix in gradle build file
Issue: androidx/media#209

#minor-release

PiperOrigin-RevId: 490492223
(cherry picked from commit 2424ee77926923fc1bf690e7e623ff9d57b9a200)
2023-01-25 17:41:00 +00:00
bachinger
8b0c0761f3 Exclude tracks from PlayerInfo if not changed
This change includes a change in the `IMediaController.aidl` file and needs
to provide backwards compatibility for when a client connects that is of an older or
newer version of the current service implementation.

This CL proposes to create a new AIDL method `onPlayerInfoChangedWithExtensions`
that is easier to extend in the future because it does use an `Bundle` rather than
primitives. A `Bundle` can be changed in a backward/forwards compatible way
in case we need further changes.

The compatibility handling is provided in `MediaSessionStub` and `MediaControllerStub`. The approach is not based on specific AIDL/Binder features but implemented fully in application code.

Issue: androidx/media#102
#minor-release
PiperOrigin-RevId: 490483068
(cherry picked from commit 3d8c52f28d5d3ef04c14868e15036563a9fc662d)
2023-01-25 17:41:00 +00:00
bachinger
0ba58cc634 Call future listener on the same handler that created the controller
The direct executor is not the proper way to determine on what thread to run the
`Future.Listener` and the `MediaControllerCreationListener` because the listener
may call the controller passed as argument which must happen on the same thread
that built the controller. This change makes sure this is the case.

PiperOrigin-RevId: 490478587
(cherry picked from commit 68908be18d0a46478be05ad406a5027c15c38723)
2023-01-25 17:41:00 +00:00
Ian Baker
a98efd8b97 Merge pull request #10786 from TiVo:p-aacutil-test-impl
PiperOrigin-RevId: 490465182
(cherry picked from commit a32b82f7bd14161b4ba204db28ca842f1dd0bb12)
2023-01-25 17:41:00 +00:00
tonihei
9829ff3d4c Add helper method to convert platform session token to Media3 token
This avoids that apps have to depend on the legacy compat support
library when they want to make this conversion.

Also add a version to both helper methods that takes a Looper to
give apps the option to use an existing Looper, which should be
much faster than spinning up a new thread for every method call.

Issue: androidx/media#171
PiperOrigin-RevId: 490441913
(cherry picked from commit 03f0b53cf823bb4878f884c055b550b52b9b57ab)
2023-01-25 17:40:56 +00:00
bachinger
782a69e38c Migrate BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_SUPPORTED_FLAGS to Media3
PiperOrigin-RevId: 490376734
(cherry picked from commit 1803d1cdb8cf429c3d0a3fdbbecbad25145db8c4)
2023-01-25 17:38:34 +00:00
tianyifeng
d3d99f0194 Load bitmaps for MediaSessionCompat.QueueItem.
When receiving the `onTimelineChanged` callback, we convert the timeline to the list of `QueueItem`s, where decoding a bitmap is needed for building each of the `QueueItem`s. The strategy is similar to what we did in <unknown commit> for list of `MediaBrowserCompat.MediaItem` - set the queue item list until the bitmaps decoding for all the `MediaItem`s are completed.

PiperOrigin-RevId: 490283587
(cherry picked from commit 8ce1213ddddb98e0483610cfeaeba3daa5ad9a78)
2023-01-25 17:38:34 +00:00