9070 Commits

Author SHA1 Message Date
tonihei
84280c8530 Only consider enabled tracks in ProgressiveMediaPeriod.bufferedPosition
ProgressiveMediaPeriod loads all available tracks into SampleStreams
(because it needs to read the data anyway and it allows easy activation
of tracks without reloading). However, the SampleStreams for disabled
tracks are not read and no one if waiting for them.

The buffered position is used for user-visible state (e.g. in the UI)
and to check how much data is already buffered to decide when to stop
buffering (using LoadControl). Both values benefit from only
using the actually enabled tracks to better reflect what is available
for playback at the moment.

Issue:Issue: google/ExoPlayer#10361
PiperOrigin-RevId: 458475038
(cherry picked from commit 577e19168d981a92c18eff7f7a045c925d80ca8d)
2022-07-01 15:28:39 +00:00
rohks
3d79536f80 Fix MP4 parser issue in reading bitrates from esds boxes.
As per MP4 spec, bitrates in esds boxes can be a 32 bit number which doesn't fits in Java int type, so now reading it as a long value. Our class for holding media format, only allows bitrates value to be an int as we don't expect the bitrates to be greater than or equal to 2^31. So we're limiting the values for bitrates to Integer.MAX_VALUE.

#minor-release

PiperOrigin-RevId: 458423162
(cherry picked from commit 9e10286b5ea624b8a7533e5fc452b19476589764)
2022-07-01 09:52:45 +00:00
rohks
3709e90e34 Fix MP4 parser issue in reading length of URL array from esds boxes.
As per MP4 spec, the length of URL array is a 8 bit number.

#minor-release

PiperOrigin-RevId: 458421436
(cherry picked from commit 5095ff160bec2fdad21a51351373a03073236ffd)
2022-07-01 09:39:11 +00:00
ibaker
315bf6b898 Ensure TalkBack announces the selected playback speed in the UI menu
Issue: google/ExoPlayer#10298
#minor-release
PiperOrigin-RevId: 457991028
(cherry picked from commit bf86b603a30211ec2b48a78223683f758e6d5f83)
2022-06-29 16:10:11 +00:00
ibaker
d3b5f71f25 Consider shuffle order in Timeline.equals()
Previously two timelines that differed only in shuffle order were
considered equal, which resulted in no call to
Player.Listener.onTimelineChanged when calling
ExoPlayer.setShuffleOrder. This in turn resulted in no call to
MediaControllerCompat.Callback.onQueueChanged.

Also make a small fix inside ExoPlayerImpl.setShuffleOrder, to ensure
that the new shuffle order is used when constructing the masked
timeline.

Issue: google/ExoPlayer#9889
#minor-release
PiperOrigin-RevId: 457703727
(cherry picked from commit 5c7ec13e85d32bdb464082069d462c740bc7cd55)
2022-06-28 12:15:54 +00:00
ibaker
f3a350d651 Use a helper function and Truth Correspondence instead of NoUidTimeline
NoUidTimeline still exists as a private detail of TestUtil, but it no
longer extends ForwardingTimeline because the interactions are quite
hard to reason about.

#minor-release

PiperOrigin-RevId: 457703593
(cherry picked from commit 292f6de6305fa7fbbd2b80223e7860aa1f69118a)
2022-06-28 12:15:03 +00:00
tonihei
0d83c44699 Clean up offload state tracking
1. The offloadSchedulingEnabled value doesn't need to be in
   PlaybackInfo because it's never updated in EPII.
2. The sleepingForOffload value in EPII wasn't updated explicitly
   (just via the return value of a method). It was also only
   meant to be enabled while the player is actively playing, but
   confusingly triggered from a path where the player may
   theoretically be buffering as well.
3. The offload sleeping (=not scheduling doSomeWork) was interwoven
   into the actual scheduling code making it slightly hard to follow.
   This can be improved slightly by keeping the offload sleeping
   decision and the scheduling separate.

PiperOrigin-RevId: 457427293
(cherry picked from commit aedde2de396995e4354f3110cc37e86b48525892)
2022-06-27 10:34:56 +01:00
tonihei
0b75c254ae Rename shouldUseDummySurface to shouldUsePlaceholderSurface
This was likely missed in 33373d0d0a.

PiperOrigin-RevId: 457422574
(cherry picked from commit aaa01529052bb299be41d5c56b2ea58abf738ce7)
2022-06-27 10:04:19 +01:00
olly
27538370d0 Inform ProgressiveMediaPeriod of known length earlier
PiperOrigin-RevId: 456753343
(cherry picked from commit 531f03a36964f47342f4049e0269b12bd7fb7511)
2022-06-23 14:31:27 +01:00
tonihei
de78cfa362 Clear pending doSomeWork messages when sleeping for offload
The offload sleeping stops as soon as a new DO_SOME_WORK message
is handled (because this indicates an expected change in rendering
and we want to stop sleeping until we know it's safe to do so).

Every exit path from doSomeWork needs to clear other pending
DO_SOME_WORK messages as these requests have already been handled by
the current method invocation. This currently doesn't happen from the
offload sleeping return path and a previously queued DO_SOME_WORK
message can immediately wake up the rendering loop again.

Fix this by moving the message removal to the beginning of the
doSomeWork method (as it prevents forgetting it in one of the
exit paths later).

PiperOrigin-RevId: 456259715
(cherry picked from commit 251389d7447d26b46783428133790d06daca2fd7)
2022-06-21 15:58:04 +01:00
olly
3727385555 Fix parsing H265 short term reference picture sets
Issue: google/ExoPlayer#10316
PiperOrigin-RevId: 456084302
(cherry picked from commit d86bc1078c8f95f8420253e8e8ad7550d09b03f1)
2022-06-20 16:46:15 +01:00
christosts
5051b47f4c Misc improvement in Util
#minor-release

PiperOrigin-RevId: 455380010
(cherry picked from commit 4f5e99c5432a4fadf64e242fb74d31bc614f7487)
2022-06-16 14:39:46 +00:00
christosts
643e78c4b0 Misc javadoc fix.
PiperOrigin-RevId: 455157744
(cherry picked from commit 91de5fa0cbbb976defd18bfd7d5d9981ce2dc577)
2022-06-15 17:05:54 +00:00
olly
92c3535de7 Cleanup: Remove unnecessary self-refs in Util
PiperOrigin-RevId: 455121899
(cherry picked from commit 545cd1eb461e504ff64d8d72295230824b4a6603)
2022-06-15 14:08:00 +00:00
olly
996f94754d Fix permissions request for media provider content URIs
We need to request the external storage permission to access these

PiperOrigin-RevId: 454160546
(cherry picked from commit a90d5230e2856d08d1f7275b3d7244ed03fec466)
2022-06-10 14:29:55 +00:00
Ian Baker
85d8682bc0 Add lint baseline for spurious API-level warnings
The API 32 SDK has incorrect versioning metadata for Spatializer. It
reports the whole class has only been present since API 33 (which is
surely impossible given it's present in the API 32 SDK):
https://issuetracker.google.com/234009300

The metadata seems to be correct in the API 33 SDK, so this baseline
will no longer be needed when we bump to `compileSdkVersion = 33`.
2022-06-17 10:04:57 +01:00
bachinger
da127923c3 Add lint base xml file for string.xml files
Fixing lint errors in the string.xml files makes no sense because these are
overridden with the next automated string import. Adding a lint-baseline.xml
instead for the ui module.

See https://issuetracker.google.com/208178382

#minor-release

PiperOrigin-RevId: 455354304
(cherry picked from commit 495480a66adacff26fb0c9c10f4d44191656bbd0)
2022-06-16 13:04:42 +00:00
bachinger
3dcc24ef2e Version bump to exoplayer:2.18.0 and media3:1.0.0-beta01
#minor-release

PiperOrigin-RevId: 455350486
(cherry picked from commit 209d3085b710665d5659aaedd2290866f4561f7a)
2022-06-16 11:41:28 +00:00
Marc Baechinger
0a4684d045 Merge pull request #63 from ittiam-systems:rtp-h263
PiperOrigin-RevId: 455347182
(cherry picked from commit e220f5377bf8e72454218e8c13e297f0257bc49a)
2022-06-16 11:41:28 +00:00
tonihei
fb6e3ea24b Update initial bitrate estimates
#minor-release

PiperOrigin-RevId: 455140203
(cherry picked from commit 05b69a7a1cbfba4d79a91f4bd2b160625a7a9615)
2022-06-15 16:51:04 +00:00
bachinger
cdd2157f5c Updating translations
#minor-release

PiperOrigin-RevId: 455128997
(cherry picked from commit 499d3f94a504c06fcd06de7518ea6fff2a943873)
2022-06-15 16:51:04 +00:00
Marc Baechinger
a785fbe014 Merge pull request #9915 from dburckh:avi
PiperOrigin-RevId: 455094147
(cherry picked from commit 1ca382d138b30ecebe3d1ceab2442e0e53bdd388)
2022-06-15 16:51:04 +00:00
bachinger
4739e4d2f1 Add lint base to make gradle lint run without errors
PiperOrigin-RevId: 454951844
(cherry picked from commit 8b65c6a0aa5fe9e9e797633b47f0d6dfd6a44cd1)
2022-06-15 16:51:04 +00:00
bachinger
341f158f3b Add many quantity for fr an fr-CA
See https://issuetracker.google.com/208178382

PiperOrigin-RevId: 454949204
(cherry picked from commit 6fd777c5ca9805816c689fd9ad65a27083c07942)
2022-06-15 16:51:04 +00:00
christosts
fd1fb96aa0 Spatializer: Assume linear channel count for E-AC3 JOC streams
#minor-release

PiperOrigin-RevId: 454884692
(cherry picked from commit 6dc4b39cb7165577bfa862675c8111c10df843e1)
2022-06-14 17:42:21 +00:00
Marc Baechinger
941c5d84b0 Merge pull request #10322 from DolbyLaboratories:dev-v2-multichannel
PiperOrigin-RevId: 454641746
(cherry picked from commit 1c373d515991f5aef15d75f6a6de80492fe14d70)
2022-06-14 17:42:21 +00:00
tonihei
c1f1eb7831 Use correct placeholder PlayerID value in test
The default constructor is only allowed to be called on
API < 32 and the test should use the defined UNSET constant
to be API independent.

#minor-release

PiperOrigin-RevId: 454568893
(cherry picked from commit 0ed53215c212753826d93daa7fb503e9aaf4ae8d)
2022-06-13 11:54:01 +00:00
ibaker
31e6ba9c71 Ensure DRAIN_ACTION_FLUSH_AND_UPDATE_DRM_SESSION is always executed
`codecDrainAction` is set to `DRAIN_ACTION_NONE` in 3 places in
`MediaCodecRenderer`:
* The constructor (so there's no prior state to worry about)
* `updateDrmSessionV23()`: Where `mediaCrypto` is reconfigured based
  on `sourceDrmSession` and `codecDrmSession` is also updated to
  `sourceDrmSession`.
* `resetCodecStateForFlush()`: Where (before this change) the action
  is unconditionally set back to `DRAIN_ACTION_NONE` and so any
  required updated implied by
  `DRAIN_ACTION_FLUSH_AND_UPDATE_DRM_SESSION` is not done.

This change ensures that `flushOrReleaseCodec()` handles
`DRAIN_ACTION_FLUSH_AND_UPDATE_DRM_SESSION` before calling .

This probably also resolves Issue: google/ExoPlayer#10274

#minor-release

PiperOrigin-RevId: 454114428
(cherry picked from commit c736a72c75ba5460de8db79482e920ff923dc580)
2022-06-13 11:54:01 +00:00
christosts
9a793dab70 DefaultTrackSelector: Constrain audio channel count
The track selector will select multi-channel formats when those can be
spatialized, otherwise the selector will prefer stereo/mono audio
tracks. When the device supports audio spatialization (Android 12L+),
the DefaultTrackSelector will monitor for changes in the platform
Spatializer and trigger a new track selection upon a
Spatializer change event.

Devices with a `television` UI mode are excluded from audio channel
count constraints.

#minor-release

PiperOrigin-RevId: 453957269
(cherry picked from commit 9f3c595e022bc98fd776a16dcad10adc66b37e67)
2022-06-09 18:51:27 +00:00
christosts
64d33adc2d Minor fix: remove final from methods of final class
#minor-release

PiperOrigin-RevId: 453408087
(cherry picked from commit 527db57b26e5d6ea46320d203c1e402078321d1b)
2022-06-09 18:51:27 +00:00
christosts
b7cf772afb Fix bug: playback is frozen with HLS chunkless preparation
This change fixes a bug where the player is frozen with HLS chunkless
preparation because the audio stream wrappers are not marked as master
timestamp sources before preparation.

#minor-release

PiperOrigin-RevId: 453941815
(cherry picked from commit 917484100db2be8681f5a122d876012c1dd0f36b)
2022-06-09 18:08:16 +00:00
Marc Baechinger
56079ba84e Merge pull request #69 from ittiam-systems:rtp_amr_test
PiperOrigin-RevId: 453905355
(cherry picked from commit 8a31e33d41c198279e7c6008fcad43f39202c837)
2022-06-09 18:08:16 +00:00
tonihei
c1aff0dc8f Add COMMAND_SET_MEDIA_ITEM to Player.Commands
Some Player implementations have no playlist capability but can still
set a MediaItem for playback. Examples are a MediaController connected
to a legacy MediaSession, ExoPlayer up to 2.12 or MediaPlayer.

To indicate this capability, we need an allowed command in addition
to COMMAND_CHANGE_MEDIA_ITEMS that just allows to set a single item
that replaces everything that is currently played.

#minor-release

PiperOrigin-RevId: 453879626
(cherry picked from commit 2056152824512bcd8f2f09b2f7c1a752e913feac)
2022-06-09 18:08:16 +00:00
christosts
4e3617c2f1 Audio passthrough: handle unset audio format channel count
With HLS chunkless preparation, audio formats may have no value
for channel count. In this case, the DefaultAudioSink will either query
the platform for a supported channel count (API 29+) or assume a max
channel count based on the encoding spec in order to decide whether the
audio format can be played with audio passthrough.

Issue: google/ExoPlayer#10204

#minor-release

PiperOrigin-RevId: 453644548
(cherry picked from commit b3b57bc93df659c41412164bdc0df164c0c23041)
2022-06-09 18:08:16 +00:00
ibaker
2e2bbdd7b5 Clarify that ShuffleOrder must be consistent in both directions
#minor-release

PiperOrigin-RevId: 453622964
(cherry picked from commit 2c2be2da92b5cbefa81e5960d7f39f01979a2a78)
2022-06-09 18:08:16 +00:00
Marc Baechinger
68054de481 Merge pull request #53 from ittiam-systems:rtp_opus
PiperOrigin-RevId: 453490088
(cherry picked from commit ade3452e17773ae553f3e8ab6b0f6e6e6d6acc17)
2022-06-09 18:08:16 +00:00
ibaker
5030145c8f Use a shared keyForField implementation in track selection parameters
The current setup with distinct, private `keyForField` implementations,
leaves open the (theoretical) possibility of a clash in the `Bundle`
keys used by the superclass and subclass. This change brings
consistency with our only other extensible `Bundleable` type
(`PlaybackException`).

#minor-release

PiperOrigin-RevId: 453385875
(cherry picked from commit a056f08a3d06992ee59e596c80d13a7cc628a12a)
2022-06-07 17:54:38 +00:00
ibaker
dd27a9a8df Rename DefaultTrackSelector.ParametersBuilder to Parameters.Builder
We generally nest the `Builder` for `Foo` inside `Foo`. In this case,
there's already a `DefaultTrackSelector.Parameters.Builder` type visible
to a developer, it just happens to be the 'common'
`TrackSelectorParameters.Builder`, so using it is a bit weird. For
example this code snippet doesn't compile because
`DefaultTrackSelector.Parameters.Builder#build()` returns
`TrackSelectionParameters`. This CL fixes that problem and the code
snippet now compiles.

```java
DefaultTrackSelector.Parameters params =
   new DefaultTrackSelector.Parameters.Builder(context).build()
```

#minor-release

PiperOrigin-RevId: 453215702
(cherry picked from commit 881622385d073c816663dc24079b0a6f68ed06c5)
2022-06-07 17:54:38 +00:00
ibaker
c107b94941 Fix HiddenTypedefConstant Metalava error on PlaybackException
This is done by removing the `@FieldNumber` IntDef completely. It's not
really adding much value anyway, because it's `open` so there's no real
enforcement to prevent passing 'incorrect' values.

#minor-release

PiperOrigin-RevId: 452108972
(cherry picked from commit 97210b5aa08ba662a33e9f2f91620ec80fe51902)
2022-06-07 17:54:38 +00:00
ibaker
27e0c80792 Permit duplicate Opus headers
This reinstates the permissive behaviour removed by
fe7e5b8181

Test file created by opening bear.opus in a hex editor and naively
duplicating the two header packets, starting at (and including) the
first `OggS` in the file and ending just before the third `OggS`.

#minor-release

Issue: google/ExoPlayer#10038
PiperOrigin-RevId: 452015662
(cherry picked from commit b6b282672c45263d0f9e2b6ece4f6de1083812cb)
2022-05-31 14:06:59 +00:00
ibaker
b0a9b9017e Add some imports required for javadoc
#minor-release

PiperOrigin-RevId: 452002758
(cherry picked from commit f76baaee77035c6aa5ab6315c3e8263f2f082c12)
2022-05-31 13:50:40 +00:00
ibaker
30bed6cdc5 Add @deprecated javadoc to all @Deprecated @Override methods
This ensures the 'use X instead' message is easily visible in the
generated HTML for the overriding method. Currently it's not, e.g.:
https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/BasePlayer.html#getCurrentWindowIndex()

#minor-release

PiperOrigin-RevId: 452002224
(cherry picked from commit d711dee003c9f7d8a3f31031b35a4121d0db6f09)
2022-05-31 13:50:40 +00:00
Marc Baechinger
b332d66cf7 Remove FfmpegVideoRenderer from 2.1.18 release 2022-05-30 18:22:06 +00:00
claincly
d411461dfa Skip BitrateAnalysisTest if device is incapable.
Add bitrate check to the "can encode" criteria.

PiperOrigin-RevId: 451868042
2022-05-30 17:57:29 +00:00
tonihei
8e015c4f91 Remove MediaMetadata.mediaUrl
This value only existed to allow setting media URLs from external sources
(e.g. in a MediaController) so that a player can start playing this item.
Now that we have MediaItem.RequestMetadata.mediaUrl we can remove this value
from MediaMetadata because it's request metadata, not media metadata.

PiperOrigin-RevId: 451857413
2022-05-30 17:54:00 +00:00
tonihei
38248af5cf Add RequestMetadata to MediaItem
These fields can be used to transport additional request properties
when the requester doesn't know the details needed for the actual
playback (i.e. the LocalConfiguration).

PiperOrigin-RevId: 451857093
2022-05-30 17:50:30 +00:00
andrewlewis
84efc5e8d0 Retain stream time offsets through codecs
ExoPlayer applies a large time offset to buffers so that, if the input has negative timestamps, generally buffers seen by the decoders should have positive timestamps. Modify how the offset is handled in `Transformer` so that decoders and encoders generally see positive timestamps, by leaving the offset on samples when reading them in the base renderer (remove the code that removed the offset), and then removing the offset when muxing. Also update the frame processor chain and slow motion flattening code to retain the existing behavior after this change (these both need original media presentation timestamps)

Tested via existing end-to-end tests and manually verified that the overlay frame processor shows the expected original media timestamps.

Aside: we don't need the same logic as ExoPlayer to track stream offsets across the decoder yet, because we don't try to handle stream changes during playback in single asset editing. (There is an edge case of multi-period DASH that may not work but I doubt anyone will use that as input to `Transformer` before we change the code to handle multi-asset properly.) In future we should try to refactor interaction with the decoder to use the same code for Transformer and ExoPlayer.
PiperOrigin-RevId: 451846055
2022-05-30 17:47:03 +00:00
ibaker
6dd065a128 Wrap framework AudioAttributes in new AudioAttributesV21 class
PiperOrigin-RevId: 451831531
2022-05-30 17:43:36 +00:00
samrobinson
38720a6b6d Treat pixels as unsigned and correct pixel count division.
PiperOrigin-RevId: 451428202
2022-05-30 17:40:06 +00:00
huangdarwin
983e074fc9 Transformer: Add 8k24fps transform test.
Most devices won't support 8k decoding, so they'll skip this test entirely.

As the video is quite short, this test shouldn't be any longer than the nearby,
long-running 4k60 test.

PiperOrigin-RevId: 451423368
2022-05-30 17:36:38 +00:00