15163 Commits

Author SHA1 Message Date
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
tonihei
5a96fc792f Reorder some release notes in other sections.
PiperOrigin-RevId: 490224795
(cherry picked from commit fa531b79249e5435af719bfbe168b999b5032b47)
2023-01-25 17:38:25 +00:00
ibaker
dddb72b269 Add DefaultExtractorsFactory.setTsSubtitleFormats
ExoPlayer is unable to detect the presence of subtitle tracks in some
MPEG-TS files that don't fully declare them. It's possible for a
developer to provide the list instead, but doing so is quite awkward
without this helper method. This is consistent for how
`DefaultExtractorsFactory` allows other aspects of the delegate
`Extractor` implementations to be customised.

* Issue: google/ExoPlayer#10175
* Issue: google/ExoPlayer#10505

#minor-release

PiperOrigin-RevId: 490214619
(cherry picked from commit ff48faec5f9230355907a8be24e44068ec294982)
2023-01-25 17:37:32 +00:00
tonihei
fa6b8fe06d Do not require package visibility when obtaining SessionTokens
The only reason this is required at the moment is to set the
process UID field in the token, that is supposed to make it easier
for controller apps to identify the session. However, if this
visibility is not provided, it shouldn't stop us from creating
the controller for this session.

Also docuement more clearly what UID means in this context.

PiperOrigin-RevId: 490184508
(cherry picked from commit c41a5c842080a7e75b9d92acc06d583bd20c7abb)
2023-01-25 17:37:32 +00:00
ibaker
3476ca9296 Add set -eu to all shell scripts
These flags ensure that any errors cause the script to exit (instead of
just carrying on) (`-e`) and that any unrecognised substitution variables
cause an error instead of silently resolving to an empty string (`-u`).

Issues like Issue: google/ExoPlayer#10791 should be more quickly resolved with
`set -e` because the script will clearly fail with an error like
`make: command not found` which would give the user a clear pointer
towards the cause of the problem.

#minor-release

PiperOrigin-RevId: 490001419
(cherry picked from commit 45b8fb0ae1314abdc5b0364137622214ac8e5b98)
2023-01-25 17:37:31 +00:00
tonihei
f4f801a809 Do not require package visibility when connecting to a Media3 session
When we currently call SessionToken.createSessionToken with a legacy
token, we call the package manager to get the process UID. This
requires visiblity to the target package, which may not be available
unless the target runs a service known to the controller app.

However, when connecting to a Media3, this UID doesn't have to be
known, so we can move the call closer to where it's needed to
avoid the unncessary visibility check.

In addition, a legacy session may reply with unknown result code
to the session token request, which we should handle as well.

One of the constructor can be removed since it was only used from
a test.

PiperOrigin-RevId: 489917706
(cherry picked from commit 2fd4aac310787d1a57207b5142a0ab08d5e1a2a5)
2023-01-25 17:37:31 +00:00
tonihei
9e42426645 Add remaining state and getters to SimpleBasePlayer
This adds the full Builders and State representation needed to
implement all Player getter methods and listener invocations.

PiperOrigin-RevId: 489503319
(cherry picked from commit 81918d8da7a4e80a08b65ade85ecb37c995934e7)
2023-01-25 17:37:31 +00:00
christosts
0e628fb487 Pass correct frame size for passthrough playback
When estimating the AudioTrack min buffer size, we must use a PCM
frame of 1 when doing direct playback (passthrough). The code was
passing -1 (C.LENGTH_UNSET).

PiperOrigin-RevId: 489238392
(cherry picked from commit 07d25bf41d9fa4d81daade6787a9b15682e9cf1f)
2023-01-25 17:37:31 +00:00
tonihei
68a1571c1e Add additional codecs to the eosPropagationWorkaround list.
Issue: google/ExoPlayer#10756
PiperOrigin-RevId: 489236336
(cherry picked from commit d1b470e4cc26a15525b583d1953529c8ec73a950)
2023-01-25 17:37:31 +00:00
ibaker
9ac5062041 Throw exception if a released player is passed to TestPlayerRunHelper
I considered moving this enforcement inside the ExoPlayerImpl
implementation, but it might lead to app crashes in cases that apps
(incorrectly) call a released player, but it wasn't actually causing a
problem.

PiperOrigin-RevId: 489233917
(cherry picked from commit cba65c8c61122c5f0a41bd95a767002e11a1bae4)
2023-01-25 17:37:31 +00:00
tonihei
91c51fe94d Mark broadcast receivers as not exported
They are called from the system only and don't need to be exported
to be visible to other apps.

PiperOrigin-RevId: 489210264
(cherry picked from commit 22ccc1a1286803868970fb2b1eafe63e9c669a5c)
2023-01-25 17:37:31 +00:00
tianyifeng
f3268ac8ae Load bitmaps for MediaBrowserCompat.
* Transforms the `ListenableFuture<LibraryResult<MediaItem>>` and `ListenableFuture<LibraryResult<List<MediaItem>>>` to `ListenableFuture<MediaBrowserCompat.MediaItem>` and `ListenableFuture<List<MediaBrowserCompat.MediaItem>>`, and the result will be sent out when `ListenableFuture` the `MediaBrowserCompat.MediaItem` (or the list of it) is fulfilled.
* Add `artworkData` to the tests in `MediaBrowserCompatWithMediaLibraryServiceTest`.

PiperOrigin-RevId: 489205547
(cherry picked from commit 4ce171a3cfef7ce1f533fdc0b7366d7b18ef44d1)
2023-01-25 17:37:31 +00:00
Googler
9ba059f73f Add setPlaybackLooper ExoPlayer builder method
The method allows clients to specify a pre-existing thread
to use for playback. This can be used to run multiple ExoPlayer
instances on the same playback thread.

PiperOrigin-RevId: 488980749
(cherry picked from commit e1fe3120e29a66ac2dcde6e9960756197bac6444)
2023-01-25 17:37:31 +00:00
Googler
c11b5cf91c Fix NPE when listener is not set
PiperOrigin-RevId: 488970696
(cherry picked from commit f3ed9e359dfdff2a99bf8766ffceb59a93d1bc93)
2023-01-25 17:37:31 +00:00
bachinger
73d40e1cfc Add bundling exclusions with unit tests
The exclusion will be used in a follow-up CL when sending PlayerInfo updates.

#minor-release

PiperOrigin-RevId: 488939258
(cherry picked from commit bae509009bd62554876ecb7485708e50af4eaa2a)
2023-01-25 17:37:31 +00:00
tianyifeng
bbf7324494 Update targetSdkVersion of demo session app to appTargetSdkVersion
PiperOrigin-RevId: 488884403
(cherry picked from commit cfe36af8478e78dd6e334298bcee425c61a9ba2a)
2023-01-25 17:37:31 +00:00
michaelkatz
537f8b2665 Changed decoder list sort to order by functional support of format
Added new method to check if codec just functionally supports a format.
Changed getDecoderInfosSortedByFormatSupport to use new function to
order by functional support. This allows decoders that only support
functionally and are more preferred by the MediaCodecSelector to keep
their preferred position in the sorted list.

Unit tests included
-Two MediaCodecVideoRenderer tests that verify hw vs sw does not have an
effect on sort of the decoder list, it is only based on functional
support.

Issue: google/ExoPlayer#10604
PiperOrigin-RevId: 487779284
(cherry picked from commit fab66d972ef84599cdaa2b498b91f21d104fbf26)
2023-01-25 17:35:11 +00:00
Michael Katz
c2cbb6370a
Merge pull request #210 from androidx/release-1.0.0-beta03
1.0.0-beta03
1.0.0-beta03
2022-11-23 11:38:16 +00:00
christosts
6661b757fd Fix compilation error in ffmpeg JNI layer
PiperOrigin-RevId: 490263003
(cherry picked from commit a9be38a339161c9a286c496ba48cdde1d1db5fdc)
2022-11-23 09:52:20 +00:00
tonihei
103b7cde30 Reorder some release notes in other sections.
#minor-release

PiperOrigin-RevId: 490224795
(cherry picked from commit fa531b79249e5435af719bfbe168b999b5032b47)
2022-11-22 15:05:41 +00:00
michaelkatz
fc505384c9 Version bump to exoplayer:2.18.2 and media3:1.0.0-beta03
PiperOrigin-RevId: 489959918
(cherry picked from commit 4ea72f0c739f4478cc99b73c5c3550eadaad32ab)
2022-11-22 11:08:15 +00:00
ibaker
ca5a0d7dad Remove @hide javadoc annotation from ExoPlayer GitHub
This tag is only understood by Dackka, which is used to generate the media3 javadoc.

PiperOrigin-RevId: 489233200
(cherry picked from commit 0388631ee22dd9ce0e8903653f8c1f3bf84030ea)
2022-11-22 11:05:15 +00:00
michaelkatz
5eddd9689f Filter bogus AndroidX core jar file when creating javadoc
#minor-release

PiperOrigin-RevId: 489202167
(cherry picked from commit 6e73fc545d7b38a0b89150c98a4c567d132551fb)
2022-11-22 11:05:15 +00:00
bachinger
4adfb5f50f Add pending sequence before sending the remote session task
#minor-release

PiperOrigin-RevId: 488885069
(cherry picked from commit e1eb8b6dd89fac48d62e80e95c0e959815720b35)
2022-11-17 10:06:29 +00:00
tonihei
8cc37db8e5 Rename getVideoSurfaceSize to getSurfaceSize
This better matches the callback name (onSurfaceSizeChanged) and
probably cause less confusion with getVideoSize.

PiperOrigin-RevId: 488669786
(cherry picked from commit 1143edc59ac96ec8524e8203d9445dbb0f006630)
2022-11-17 10:06:29 +00:00
christosts
c22c2bf0c0 Set valid channel masks for 8 and 12 channels on all Android versions
Util.getAudioTrackChannelConfig() maps a channel count to a
channel mask that is passed to AudioTrack. The method expected that
playback of 8-channel audio is possible from Android 5.1 and playback of
12-channel audio is only possible from Android 12L. However, there is no
restriction on the upper number of channels that can be passed to the
AudioTrack. google/ExoPlayer#10701 is an example where the audio decoder
outputs 12 channels on an Android 10.

This change removes the restrictions for 8 and 12 channels. Note, we still
do not support playback of arbitrary number of channels as it would require
further changes to DefaultAudioSink.

#minor-release

Issue: google/ExoPlayer#10701
PiperOrigin-RevId: 488659831
(cherry picked from commit 491b13622e79f5c2ef84771b1a29e40f47aca653)
2022-11-17 10:06:29 +00:00
tonihei
dab5b3c152 Mark iterationFinished when triggering release event.
When we currently trigger the iteration finished event during the
release, we don't mark the event as triggered. This means that
someone can trigger another release from within the callback,
which then tries to resend the event.

Issue: google/ExoPlayer#10758

PiperOrigin-RevId: 488645089
(cherry picked from commit 1def68bf3c00035aad0821d3997187317ce099dc)
2022-11-17 10:06:25 +00:00
tonihei
bf67d1cc11 Calculate SSAI window duration for live periods with unset duration.
We currently skip this calculation entirely, but it can be added by
calculating the window duration using the wrapped window's duration
and the provided AdPlaybackState.

Issue: google/ExoPlayer#10764
PiperOrigin-RevId: 488614767
(cherry picked from commit 7a7d08343af13a969744df2a70eb67adae3254b8)
2022-11-17 10:04:35 +00:00
ibaker
e4ff4a3b04 Reformat demo build.gradle file
PiperOrigin-RevId: 488376715
(cherry picked from commit adc993dc5713b92f40ada6683bfa0a532bfb75ed)
2022-11-17 10:04:35 +00:00
ibaker
50112671c0 Add @ForOverride to DecoderAudioRenderer protected methods
PiperOrigin-RevId: 487779266
(cherry picked from commit 9d6d30d81ddb7b34e8a54a7fa0f0f6a98655817a)
2022-11-17 10:04:35 +00:00
ibaker
dafbbf25e6 Reformat demo build.gradle file
PiperOrigin-RevId: 487539107
(cherry picked from commit 62d6c303c1a9fd56e27ffc7ad7cc39f92f957bd7)
2022-11-17 10:04:35 +00:00
tonihei
4296a8af88 Ensure listener invocations use final state variable.
The MediaControllerImplBase listener invocations currently use the
class member state that can change if one of the listener method
implementations changes the state recursively.

Updating the listener invocations to use a final local variable
ensures all listeners get consistent updates.

PiperOrigin-RevId: 487503373
(cherry picked from commit 33bea391d42cb5669e6d2c97c0553f3c0c63467b)
2022-11-17 10:04:25 +00:00
tonihei
7f17ff6d00 Ensure listener invocations use final state variable.
The MediaControllerImplBase listener invocations currently use the
class member state that can change if one of the listener method
implementations changes the state recursively.

Updating the listener invocations to use a final local variable
ensures all listeners get consistent updates.

PiperOrigin-RevId: 487503373
(cherry picked from commit 33bea391d42cb5669e6d2c97c0553f3c0c63467b)
2022-11-10 12:56:11 +00:00
tonihei
a9eb121169 Split test methods more clearly in arrange, act, assert.
The tests in MediaControllerCompatCallbackWithMediaSessionTest
don't follow this pattern very consistently at the moment.

PiperOrigin-RevId: 487501913
(cherry picked from commit c6a0ba25f996b77adf6bf0dd9921f429d5950437)
2022-11-10 12:47:12 +00:00
tonihei
58d670d941 Align PlaybackStateCompat states with logic in MediaSessionConnector
Creating the PlaybackStateCompat from a media3 Player state is done
already by the MediaSessionConnector (and used widely). The media3
session module should set the same states under the same circumstances
to ensure compatiblity and consistency.

PlaybackStateCompat changes made in media3 session:
 - Use STATE_STOPPED when player is ended instead of STATE_PAUSED
 - Use STATE_PLAYING when playback is suppressed temporarily.
 - Set the playback speed to 0 if the player is not playing.
 - Add extras for mediaId and user-set playback speed.

Part of the problem was that Player.isPlaying() was used to check
the state. Unfortunately, MockPlayer.isPlaying() is implemented in
a way that makes it hard to test these changes, because the value
is set independently of playbackState, playWhenReady and suppression
reason. To be able to write consistent, logical tests, this change
also removes the independent setting of isPlaying in MockPlayer to
align it better with a real player. This requires to update some
other tests to use alternative methods.

PiperOrigin-RevId: 487500859
(cherry picked from commit c5e071e556931331cc780fda5177d556d51ff3da)
2022-11-10 12:40:37 +00:00