15090 Commits

Author SHA1 Message Date
tonihei
abf1eb8b8a Use more realistic time values for MediaCodecVideoRendererTest
This test became flaky after ab7e84fb34 because some of the
unrealistic frame times ended up on the same release time.

Using realistic numbers avoids the flakiness.

PiperOrigin-RevId: 512566469
(cherry picked from commit 0c8ce183fe7e2f065ca4dea33818566e9aeff48f)
2023-02-28 18:00:55 +00:00
tonihei
a09bb70053 Do not specify export flags for protected system broadcasts.
Protected system broadcasts should not specify the export flag.
Marking them as NOT_EXPORTED breaks sticky broadcasts in some
cases.

Issue: google/ExoPlayer#10970

PiperOrigin-RevId: 512020154
(cherry picked from commit 93e117928c157ef338faa46dea25ee114f18d3eb)
2023-02-28 18:00:52 +00:00
tonihei
5ab4223f2a Use ArrayDeque for pending output stream changes.
The current logic uses manual array operations to keep track of pending
changes. Modernize this code by using an ArrayDeque and a data class.
This also allows to extend the output stream information in the future.

This also fixes a bug where a position reset accidentally assigns a pending
stream offset instead of keeping the current one.

PiperOrigin-RevId: 511787571
(cherry picked from commit f0420124954527e7f3eb529ca24f2a51dc7319f9)
2023-02-28 17:57:41 +00:00
christosts
58a977e0c0 Skip rendering multiple frames on the same vsync
When rendering frames at a rate higher than the screen refresh rate,
e.g. playing at 8x, the player is releasing multiple frames at the same
release time (nanos) which are then dropped by the platform. The output
buffers are available later and as a result MediaCodec cannot keep up
decoding fast enough.

This change skips releasing multiple video frames on the same vsync
period and proactivelly drops the frame. The frame is counted as skipped
rather than dropped to differentiate with frames dropped due to slow
decoding.

PiperOrigin-RevId: 510964976
(cherry picked from commit ab7e84fb34b7ef4b13e492e1f8918345c712ec30)
2023-02-28 17:56:21 +00:00
tonihei
0e5dad5269 Reduce number of calls to AudioTrack.getPlaybackHeadPosition
This call may cause performance overhead in some situations,
for example if the AudioTrack needs to query an offload DSP
for the current position. We don't need to check this multiple
times per doSomeWork iteration as the value is unlikely to
change in any meaningful way.

PiperOrigin-RevId: 510957116
(cherry picked from commit 9eccf09165f39d89d502065f897d120b97f47f66)
2023-02-28 17:56:21 +00:00
bachinger
629a75ed1c Map PLAYER_STATE_LOADING to STATE_BUFFERING
#minor-release
Issue: androidx/media#245
PiperOrigin-RevId: 510456793
(cherry picked from commit ba49b6b81b9a6a01aa16381cca70886bc205c5c5)
2023-02-28 17:56:21 +00:00
Googler
3b00561b49 Fix error in documentation string
The current javadoc refers to the SessionCallback#onConnected, which doesn't exist.

PiperOrigin-RevId: 510261965
(cherry picked from commit fc642eb45f6c997a2a501bcc3ea19043cd9911eb)
2023-02-28 17:56:21 +00:00
Googler
6a273a5f90 Add exception cause to thrown exception
PiperOrigin-RevId: 509473556
(cherry picked from commit 56803bf1ad3e4df2ebd8d7b38f5a9f4740dc702f)
2023-02-28 17:56:21 +00:00
michaelkatz
cfe861ed89 Catch IllegalArgumentExceptions in RTSP Response parsing
In parsing Describe RTSP response messages, IllegalArgumentExceptions are thrown for invalid parameters and values. These exceptions were not caught and crashed the Playback thread. Now these exceptions will be caught and their errors forwarded to the proper error handling listeners.

Issue: google/ExoPlayer#10971
PiperOrigin-RevId: 509207881
(cherry picked from commit a8c87453db02658a21293b44b017a70d5ae1125d)
2023-02-28 17:56:16 +00:00
bachinger
f2753e2e27 Add ad event listeners in the Looper event of the ad manager callback
#minor-release

PiperOrigin-RevId: 509189206
(cherry picked from commit 51929625cfeff17af413c1a06c87e10e72f218d1)
2023-02-28 17:55:45 +00:00
christosts
3696076f0f AsynchronousMediaCodecAdapter: surface queueing errors sooner
The AsynchronousMediaCodecAdapter's queuing thread stores any exceptions
raised by MediaCodec and re-throws them on the next call to
queueInputBuffer()/queueSecureInputBuffer(). However, if MediaCodec
raises and error while queueing, it goes into a failed state and does
not announce available input buffers. If there is no input available
input buffer, the MediaCodecRenderer will never call
queueInputBuffer()/queueSecureInputBuffer(), hence playback is stalled.

This change surfaces the queueing error through the adapter's dequeueing
methods.

PiperOrigin-RevId: 508637346
(cherry picked from commit 706431059cadf1b503ea8f95fd482d41f48e1a1c)
2023-02-28 17:55:45 +00:00
ibaker
3cc93b1f1d Add null check to ExoPlayerImpl.isTunnelingEnabled
`TrackSelectorResult.rendererConfigurations` can contain null elements:
> A null entry indicates the corresponding renderer should be disabled.

This wasn't caught by the nullness checker because `ExoPlayerImpl` is
currently excluded from analysis.

#minor-release

Issue: google/ExoPlayer#10977
PiperOrigin-RevId: 508619169
(cherry picked from commit a6dfcf779942cb76c495fb5f7bc5444da6147b9d)
2023-02-28 17:55:44 +00:00
tonihei
0ebb8ff367 Document spatialization behavior constants.
PiperOrigin-RevId: 508602059
(cherry picked from commit 6066ce43f66317f708e6e0076580e1bc1182186d)
2023-02-28 17:55:44 +00:00
christosts
70db687134 Merge pull request #10959 from balachandarlinks:handle-sql-exception-in-cached-content-index
PiperOrigin-RevId: 508323432
(cherry picked from commit 1249dcdc47a4c3b4dbd642c3991945b23de8112b)
2023-02-28 17:55:44 +00:00
microkatz
e89c14aaf3 Merge pull request #248 from lemondoglol:update-segment-size
PiperOrigin-RevId: 507784608
(cherry picked from commit ecd91d865c0888c6cc1aa3554877f4df798f5379)
2023-02-28 17:55:44 +00:00
tonihei
ba2b9b3d67 Fix AudioTrackPositionTracker logic for playback speed adjustments
The AudioTrackPositionTracker needs to correct positions by
the speed set on the AudioTrack itself whenever it makes
estimations based on real-time (=the real-time playout
duration is not equal to the media duration played).

This happens for the main playback path already, but not for
the mode in which the position is estimated from the playback
head position and also not in the phase after the track has
been stopped. Both cases are not very noticeable during
normal playback, but become relevant when playing in offload
mode.

PiperOrigin-RevId: 507736408
(cherry picked from commit 01d7bc72794b98d19cad2be5c70de2f755bff9f1)
2023-02-28 17:55:44 +00:00
christosts
bd664ad786 Detect HEVC HDR10 codec profile more accurately
In MediaCodecUtil, use Format.colorInfo, besides the codec string,
to accurately map to a 10bit HEVC profile.

PiperOrigin-RevId: 507500071
(cherry picked from commit a50ea94525d2522436fbc812dec12aee53b3c1bf)
2023-02-28 17:55:37 +00:00
christosts
f17e846d3d
Merge pull request #251 from androidx/release-1.0.0-rc01
1.0.0 rc01
2023-02-16 17:03:01 +00:00
christosts
98bf30d2af Version bump for ExoPlayer 2.18.3 & media3-1.0.0-rc01
#minor-release

PiperOrigin-RevId: 509501665
(cherry picked from commit 20eae0e041e1922fd79ca36218054b293a9da7da)
2023-02-14 18:52:54 +00:00
christosts
9f432499fb Minor fixes in release notes
PiperOrigin-RevId: 509222489
(cherry picked from commit a90728fdc66cc2a8929cce9d67081681e0168115)
2023-02-14 18:52:51 +00:00
christosts
3fdaf78fc4 Prepare media3 release notes for rc01
PiperOrigin-RevId: 509218510
(cherry picked from commit 73909222706c6d7a56e0fb2d09ed8b49eca5b2be)
2023-02-14 18:49:26 +00:00
christosts
f983d912e5 Fix release note entry 2023-02-02 16:49:56 +00:00
christosts
9bf18dbb4e Session: advertise legacy FLAG_HANDLES_QUEUE_COMMANDS
This change includes 3 things:
- when the legacy media session is created, FLAG_HANDLES_QUEUE_COMMANDS
  is advertised if the player has the COMMAND_CHANGE_MEDIA_ITEMS
  available.
- when the player changes its available commands, a new
  PlaybackStateCompat is sent to the remote media controller to
  advertise the updated PlyabackStateCompat actions.
- when the player changes its available commands, the legacy media
  session flags are sent accoridingly: FLAG_HANDLES_QUEUE_COMMANDS is
  set only if the COMMAND_CHANGE_MEDIA_ITEMS is available.

#minor-release

PiperOrigin-RevId: 506605905
(cherry picked from commit ebe7ece1eb7e2106bc9fff02db2666410d3e0aa8)
2023-02-02 16:47:10 +00:00
bachinger
065418cc28 Publish ConcatenatingMediaSource2
Can be used to combine multiple media items into a single timeline window.

Issue: androidx/media#247
Issue: google/ExoPlayer#4868
PiperOrigin-RevId: 506283307
(cherry picked from commit fcd3af6431cfcd79a3ee3cc4fee38e8db3c0554e)
2023-02-02 16:47:09 +00:00
christosts
d49bd456b6 Merge pull request #10793 from fraunhoferfokus:dash-thumbnail-support
PiperOrigin-RevId: 506261584
(cherry picked from commit c6569a36fbce6fc3ece55c9a904508bd4a4c45da)
2023-02-02 16:47:09 +00:00
ibaker
791c05b57a Fix (another) LeanbackPlayerAdapter param name mismatch
I missed this when fixing `positionInMs` for Dackka in aae6941981

This time I manually verified that all the `@Override` methods have
parameter names that match [the docs](https://developer.android.com/reference/androidx/leanback/media/PlayerAdapter).

#minor-release

PiperOrigin-RevId: 506017063
(cherry picked from commit d1a27bf2a81709bc7b03ad130bc9abd4d8b27164)
2023-02-02 13:22:39 +00:00
bachinger
5528baaad9 Do not assume a valid queue in 3rd party sessions
This change fixes an issue that can be reproduced when
a controller `onConnect` creates a `QueueTimeline` out
of the state of a legacy session and then `prepare` is called.

`activeQueueItemId`, `metadata` and the `queue` of the legacy
session are used when a `QueueTimeline` is created. The change
adds unit tests to cover the different combinatoric cases these
properties being set or unset.

PiperOrigin-RevId: 505731288
(cherry picked from commit 4a9cf7d069b1b35be807886d59d87c396b19876c)
2023-02-02 13:22:38 +00:00
bachinger
bfc4ed4dd4 Inline method in PlayerService that is used from on call site only
#cleanup
#minor-release

PiperOrigin-RevId: 505146915
(cherry picked from commit d7ef1ab5bd5a4508c0913011f5990bb03a57585a)
2023-02-02 13:22:38 +00:00
tonihei
631ff809f5 Fix timestamp comparison for seeks in fMP4
When seeking in fMP4, we try to extract as little samples as possible
by only starting at the preceding sync frame. This comparison should
use <= to allow sync frames at exactly the seek position.

Issue: google/ExoPlayer#10941

PiperOrigin-RevId: 505098172
(cherry picked from commit 00436a04a4f0fec8ee9154fc1568ca4013ca5c7d)
2023-02-02 13:22:33 +00:00
bachinger
bcdedb719d Double tap detection for Bluetooth media button events only
Issue: androidx/media#233
#minor-release
PiperOrigin-RevId: 505078751
(cherry picked from commit 5c82d6bc18429842160bb64a851bb1ab5c89ec39)
2023-02-02 13:18:30 +00:00
michaelkatz
c37442b24d Match MergingMediaPeriod track selection by period index in id
MergingMediaPeriod creates its track groups with ids concatenating position in its periods array and the underlying child track group id. The ids can be used in selectTracks for matching to periods list.

Issue: google/ExoPlayer#10930
PiperOrigin-RevId: 505074653
(cherry picked from commit 542a1ef03f361b29ec731a7334b2922cb54ef4c9)
2023-02-02 13:18:30 +00:00
tonihei
5e6f79ae63 Tweak UI behavior when commands are missing.
For most missing commands, we already disable the corresponding
controls. This change extends this to more UI elements that are
disabled in case the corresponding action is unavailable.

#minor-release

PiperOrigin-RevId: 505057751
(cherry picked from commit b3e7696ba7d66a2d3c477858194a20789f4d75c7)
2023-02-02 13:18:29 +00:00
tonihei
55312e1257 Add missing command checks in UI module
The commands are partly checked already before enabling
features or calling player methods, but the checks were
still missing in many places.

#minor-release

PiperOrigin-RevId: 504589888
(cherry picked from commit e2ece2f5bcda0cea436d782d58fa6f1d9a4d1f99)
2023-01-26 14:26:00 +00:00
ibaker
d6c9fdb210 Add missing } to publish.gradle
This was missed in 47349b8c4b

#minor-release

PiperOrigin-RevId: 504548659
(cherry picked from commit 50beec56f4188e46f67e561ac4bb4ace5bb95089)
2023-01-26 14:26:00 +00:00
ibaker
3708e7529a Publish gradle attributes for AndroidX compatibility
These attributes are required when importing our artifacts into
androidx-main in order to generate reference documentation (JavaDoc and
KDoc).

#minor-release

PiperOrigin-RevId: 504502555
(cherry picked from commit 47349b8c4bd69415da8895061be71ef748c4a2d3)
2023-01-26 14:26:00 +00:00
tonihei
c357e67dd1 Filter available commands based on PlaybackStateCompat actions
This allows a MediaController to understand which methods calls
are available on a legacy session.

PiperOrigin-RevId: 504306806
(cherry picked from commit 067340cb0a03dede0f51425de00643fe3789baf2)
2023-01-26 14:26:00 +00:00
christosts
207d67b7af Suppress warnings in ImaUtil
ImaUtil calls VideoProgressUpdate.equals() which is annotated as hidden,
which causes lint errors with gradle.

#minor-release

PiperOrigin-RevId: 504306210
(cherry picked from commit 5f6e172c8fce652adf2c05e8f2d041c793e900ea)
2023-01-26 14:26:00 +00:00
michaelkatz
846258b69c Deduplicate onSetMediaItem handler logic
Created unified MediaUtils method to handle various logic for calling Player.setMediaItems from MediaSessionStub and MediaSessionLegacyStub

PiperOrigin-RevId: 504271877
(cherry picked from commit 7fbdbeb6cafe075f04b6a4321ef826643b3482e1)
2023-01-26 14:26:00 +00:00
christosts
2adcfd9b15 Add missing # in release notes
PiperOrigin-RevId: 504013985
(cherry picked from commit 5147011772286778e84410012a24e329fde12040)
2023-01-26 14:25:34 +00:00
michaelkatz
e266051fbe Add onSetMediaItems listener with access to start index and position
Added onSetMediaItems callback listener to allow the session to modify/set MediaItem list, starting index and position before call to Player.setMediaItem(s).

Added conditional check in MediaSessionStub.setMediaItem methods to only call player.setMediaItem rather than setMediaItems if player does not support COMMAND_CHANGE_MEDIA_ITEMS

PiperOrigin-RevId: 503427927
(cherry picked from commit bb11e0286eaa49b4178dfa29ebaea5dafba8fc39)
2023-01-25 18:18:42 +00:00
bachinger
107a481356 Add the MediaSession as an argument to getMediaButtons()
Issue: androidx/media#216
#minor-release
PiperOrigin-RevId: 503406474
(cherry picked from commit e690802e9ecf96dfbb972864819a45ae92c47c90)
2023-01-25 18:18:42 +00:00
ibaker
967224c1aa Explicitly document most Player.Listener methods in terms of getters
This makes it implicitly clear that if the value of a getter changes due
to a change in command availability then the listener will be invoked,
without needing to explicitly document every command on every listener
method.

#minor-release

PiperOrigin-RevId: 503178383
(cherry picked from commit 280889bc4a5b7ddc1b1c9fe15e222cad7f2e548a)
2023-01-25 18:18:42 +00:00
tonihei
43677b95eb Add command check for metadata in DefaultMediaNotificationProvider
PiperOrigin-RevId: 503172986
(cherry picked from commit 052c4b3c1a6b72efd7fcbf433c646fed9ea91748)
2023-01-25 18:18:42 +00:00
tonihei
28e37808ed Update media controller position before pausing.
We stop estimating new position when pausing until we
receive a new position from the player. However, this
means that we will continue to return a possible stale
previous position. Updating the current position before
pausing solves this issue.

PiperOrigin-RevId: 503153982
(cherry picked from commit e961c1b5e9bb4a6f63458b1bdcb49e97f415fabf)
2023-01-25 18:18:42 +00:00
tonihei
5b18c2d89f Extend command GET_CURRENT_MEDIA_ITEM to more methods.
We currently only document it for the getCurrentMediaItem(), but
the command was always meant to cover all information about the
current media item and the position therein.

To correctly hide information for controllers, we need to filter
the Timeline when bundling the PlayerInfo class if only this
command is available.

PiperOrigin-RevId: 503098124
(cherry picked from commit f15b7525436b45694b5e1971dac922adff48b5ae)
2023-01-25 18:18:42 +00:00
tonihei
b8b6ddf347 Correctly filter PlayerInfo by available getter commands.
When bundling PlayerInfo, we need to remove information if the
controller is not allowed to access it. This was only partially
done at the moment.

PiperOrigin-RevId: 502852798
(cherry picked from commit 69cfba7c53b563577390e4074fd270f078bf6069)
2023-01-25 18:18:42 +00:00
rohks
0606ab0cbb Fix javadoc references to writeSampleData
PiperOrigin-RevId: 502821506
(cherry picked from commit 6c14ffc1ecd13393930b9f5ee7ad7a52391d0f65)
2023-01-25 18:18:42 +00:00
tonihei
2eab93d5c5 Make availableCommands known when bundling PlayerInfo
When bundling PlayerInfo, we remove data when the controller is not
allowed to access this data via getters. We also remove data for
performance reasons. In the toBundle() method, it's currently hard to
make the connection between allowed commands and filtering, because
the values are checked at a different place. This can be made more
readable by forwarding the applicable Commands directly.

The only functional fix is to filter the Timeline when sending the
first PlayerInfo after a connecting a controller if the command to
get the Timeline is not available. This also allows us to remove a
path to filter MediaItems from Timelines as it isn't used.

PiperOrigin-RevId: 502607391
(cherry picked from commit c90ca7ba5fb9e83956e9494a584ae6b0620e3b14)
2023-01-25 18:18:42 +00:00
Googler
d41eedecb4 Disables play/pause button when there's nothing to play
PiperOrigin-RevId: 502571320
(cherry picked from commit d49a16e094d6d4bde0d1dc1ec42876c156b9c55a)
2023-01-25 18:18:42 +00:00
christosts
dd462e8cdb Filter what PlaybackStateCompat actions are advertised
PlayerWrapper advertises PlaybackStateCompat actions to the legacy
MediaSession based on the player's available commands.

PiperOrigin-RevId: 502559162
(cherry picked from commit 39f4a17ad4ac3863af22e12711247c7a87b8613e)
2023-01-25 18:18:42 +00:00