14438 Commits

Author SHA1 Message Date
tonihei
f5dc99f596 Forward legacy controller onPlay/PrepareFromXY calls to onAddMediaItems
These legacy callbacks are currently forwarded to onSetMediaUri which
will be removed in the future.

Also make sure to only call player.prepare/play after the items have
been set.

The calls to onAddQueueItem are also forwarded to onAddMediaItems to
actually allow a session to resolve these items to playable media, which
wasn't possible so far.

PiperOrigin-RevId: 453625204
(cherry picked from commit bd126ec5c5497615572bcdf259278a899b4574f8)
2022-06-09 18:36:35 +00:00
ibaker
926327ef4f Clarify that ShuffleOrder must be consistent in both directions
#minor-release

PiperOrigin-RevId: 453622964
(cherry picked from commit 4a6f431f01bd4cdb6754d5a897cad307eebe4d34)
2022-06-09 18:36:35 +00:00
Marc Baechinger
fd1eb4b466 Merge pull request #53 from ittiam-systems:rtp_opus
PiperOrigin-RevId: 453490088
(cherry picked from commit a2a450432904c3d8ecc25e00c7148e73f1923d6e)
2022-06-09 18:36:35 +00:00
christosts
2ed7efb1c3 Minor fix: remove final from methods of final class
#minor-release

PiperOrigin-RevId: 453408087
(cherry picked from commit 62497f23fd8f92de304e7a87ffa839e221bd78c6)
2022-06-07 17:54:55 +00:00
ibaker
240379cc02 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 814e43dbb9432e3adf6c4c278df50433260a461b)
2022-06-07 17:54:55 +00:00
ibaker
c22cd44900 Fix release notes formatting
#minor-release

PiperOrigin-RevId: 453384451
(cherry picked from commit 14ea2e4c5146ed57d51fe4a69f6b29a9f3954115)
2022-06-07 17:54:55 +00:00
ibaker
f3574f2354 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 247c2d845dbe0887f556fd3d44cdbc4d97f7451a)
2022-06-07 17:54:55 +00:00
bachinger
216d971518 Filter bogus AndroidX Media jar file when creating javadoc
#minor-release

PiperOrigin-RevId: 452282128
(cherry picked from commit bd9bc0f6b7349cf2c1477a6d7e3146555c3ead86)
2022-06-07 17:54:55 +00:00
ibaker
501ea8c563 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 39674bec78d45baa550df6807e4d49faf42dc25a)
2022-06-07 17:54:55 +00:00
bachinger
706e60346d Ignore decoding test cases when library not available
#minor-release

PiperOrigin-RevId: 452043577
(cherry picked from commit 55a194c575ba40dc0e156815f07ec854dc85bd3d)
2022-05-31 15:33:33 +00:00
andrewlewis
9cd84696c7 Create withMediaPipe variant only if AAR is present
This should fix running `./gradlew clean test` if MediaPipe hasn't been built, for example.

PiperOrigin-RevId: 452033698
(cherry picked from commit 208a9114a9f516f7034b75b4f21f9ded34de8501)
2022-05-31 14:07:20 +00:00
ibaker
f6f4bf5e6b 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 1282175808210f0496a4b18ae4e02312dbdf4553)
2022-05-31 14:07:20 +00:00
bachinger
7671e50d71 Remove deprecated calls
#minor-release

PiperOrigin-RevId: 452006137
(cherry picked from commit acb48a249564c5793cfadbee262e2eed29dea528)
2022-05-31 13:51:49 +00:00
bachinger
ad5788ef37 Use resource ID from drawable.xml as the notification icon
Issue: androidx/media#66
Issue: androidx/media#65

#minor-release

PiperOrigin-RevId: 452004492
(cherry picked from commit 839d4f43906f99002e3be71cdb7f90efb231754a)
2022-05-31 13:51:49 +00:00
ibaker
af91fdbf54 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 b8ca5b8951325ed89063b2e30e1c7fd3b78f5e97)
2022-05-31 13:51:49 +00:00
bachinger
00ae09f459 Add explicit cast to ByteBuffer for Java 8 compatibility
PiperOrigin-RevId: 451994696
(cherry picked from commit 5cdac6575e662bf575b4890f17b600e7b17bffac)
2022-05-31 13:51:49 +00:00
ibaker
711409ab51 Update the Gradle Wrapper and Android Gradle Plugin
The current verion of AGP warns it doesn't support Android API 32 [1].

The wrapper was upgraded with ([instructions](https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:upgrading_wrapper)):
```shell
$ ./gradlew wrapper --gradle-version 7.4.2 --distribution-type all
```

[1]
```
WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 32

This Android Gradle plugin (7.0.3) was tested up to compileSdk = 31

This warning can be suppressed by adding
    android.suppressUnsupportedCompileSdk=32
    to this project's gradle.properties

    The build will continue, but you are strongly encouraged to update your project to
    use a newer Android Gradle Plugin that has been tested with compileSdk = 32
```

#minor-release

PiperOrigin-RevId: 451893214
(cherry picked from commit 3ba9d7e125482aae236f2e9e60de7f8535d9f162)
2022-05-30 20:53:20 +00:00
Marc Baechinger
a626bcdb7c Remove FfmpegVideoRenderer from 2.18.0 release 2022-05-30 17:58:14 +00:00
aquilescanta
9d460023a2 Use fluent assertions
Gives a bit more information upon failures

PiperOrigin-RevId: 451882968
2022-05-30 16:55:07 +00:00
bachinger
40f5fb55cc Add constants for custom actions UI customization
PiperOrigin-RevId: 451875964
2022-05-30 16:54:22 +00:00
ibaker
a40d3e4c9a Fix release notes typo from PlaceHolder to Placeholder
The classes were renamed to `PlaceholderXXX` in
33373d0d0a

#minor-release

PiperOrigin-RevId: 451872006
2022-05-30 16:53:28 +00:00
bachinger
85a936ecb1 Implement session extras for Media3 and legacy controllers
This provides an (unstable) API for apps to broadcast session extras
Bundle to all connected controllers and set the extras in the legacy
session.

Similar to the custom layout, the extras Bundle is not part of the
Media3 session state. This means that when a Media3 controller
connects to the session after the broadcast, the extras needs to be
sent to that controller in  `MediaSession.Callback.onPostConnect(MediaSession session, ControllerInfo controller)`.

PiperOrigin-RevId: 451871731
2022-05-30 16:52:43 +00:00
claincly
a629d09458 Skip BitrateAnalysisTest if device is incapable.
Add bitrate check to the "can encode" criteria.

PiperOrigin-RevId: 451868042
2022-05-30 16:51:51 +00:00
bachinger
bf3d81c262 Add missing tests for custom layout notification
PiperOrigin-RevId: 451859199
2022-05-30 16:51:08 +00:00
bachinger
7af9f02067 Add a constant for the legacy controller version
PiperOrigin-RevId: 451857459
2022-05-30 16:50:22 +00:00
tonihei
581c6b5429 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 16:49:28 +00:00
tonihei
6b782d1011 Replace MediaItemFiller by asynchronous callback.
The MediaItemFiller is not flexible enough for most realworld usages
because:
 - it doesn't allow asynchronous resolution of MediaItems (e.g. to
   look up URIs from a database)
 - it doesn't allow to batch updates for multiple items or do more
   advanced customizations (e.g. expanding a mediaId representing
   a playlist to multiple items).

Both issues can be solved by passing in a list of items and
returning a ListenableFuture. The callback itself can also move
into MediaSession.Callback for consistency with the other
callbacks.

PiperOrigin-RevId: 451857319
2022-05-30 16:48:41 +00:00
tonihei
342be88d81 Improve playlist operation behavior of session test MockPlayer
The MockPlayer currently:
 - uses separate fields for single mediaItem vs multiple mediaItems
 - replaces all items on addMediaItem operations
 - does nothing on remove/move operations.

Fix all of this by using a single field that replicates the player
operations directly.

Some tests also need to be updated to make them more realistic
(for example only removing items from a playlist that have
previously been added).

PiperOrigin-RevId: 451857271
2022-05-30 16:47:44 +00:00
tonihei
c814f791d7 Add sessionImpl to PostSessionTask
In some cases it's helpful to have access to the session
(e.g. to get the PlayerWrapper) from within the PostSessionTask
implementations. This change forwards the existing sessionImpl
instance to all these callbacks.

PiperOrigin-RevId: 451857191
2022-05-30 16:46:49 +00:00
tonihei
6d776a5ae4 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 16:46:02 +00:00
andrewlewis
b25d00a795 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 16:45:15 +00:00
ibaker
cad1440e66 Wrap framework AudioAttributes in new AudioAttributesV21 class
PiperOrigin-RevId: 451831531
2022-05-30 16:44:27 +00:00
bachinger
8aec86bde0 Fix typo
PiperOrigin-RevId: 451824740
2022-05-30 16:43:34 +00:00
samrobinson
a1b89561c1 Treat pixels as unsigned and correct pixel count division.
PiperOrigin-RevId: 451428202
2022-05-30 16:42:38 +00:00
huangdarwin
67354cf2a7 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 16:41:41 +00:00
bachinger
9a70bbca05 Demonstrate how to use custom actions in the session demo app.
PiperOrigin-RevId: 451410714
2022-05-30 16:40:41 +00:00
samrobinson
6c4f6ecf46 Clarify variables and improve documentation of SSIM.
PiperOrigin-RevId: 451392021
2022-05-30 16:39:50 +00:00
samrobinson
224761833f Use updated test name in BUILD and docs.
PiperOrigin-RevId: 451384408
2022-05-30 16:39:01 +00:00
bachinger
01412f4a57 Unconditionally sleep for offload
Unconditionally sleep for offload, if the audio buffer is full.
Previously ExoPlayer would not sleep if the expected wake-up was
in 2s. This was to prevent underrun if the wake-up was delayed.

Experiments have shown that the wakup audio buffer is far more
than 2s (around 1min). Additionally,
the metric was incorrect because it measured both,
AudioTrack + DSP.

Finally, this metric was erroneous after a gapless transition,
when the head position would reset to 0 and thus the computed
delay until next wakeup was too large.

PiperOrigin-RevId: 451383701
2022-05-30 16:38:14 +00:00
hschlueter
9649411a4f Use video passthrough if clipping starts at key frame.
PiperOrigin-RevId: 451380267
2022-05-30 16:37:19 +00:00
hschlueter
3e8a2f104c Expand SSIM skipping to all Nexus API 21 devices.
PiperOrigin-RevId: 451371681
2022-05-30 16:36:28 +00:00
huangdarwin
099a542dac Transformer: Skip SSIM in tests when fallback is applied.
SSIM calculation requires the input and output dimensions to be identical.

For devices that can't encode the input dimensions, skip SSIM calculations and
log the cause. Only apply this on tests where the encoder may not support the
input file dimensions.

PiperOrigin-RevId: 451364904
2022-05-30 16:35:35 +00:00
hschlueter
fe3831c5b4 Fix handling clipping in transformer renderers.
Decode-only video frames (needed when the frame at / first frame after the
clipping start is not a key frame) need to be decoded but not passed to
the frame processor chain or encoder.

The clipping start offset needs to be removed from the frame timestamps
in the passthrough and video pipelines.
There are no changes needed for this in the audio pipeline, as it doesn't
use the input timestamps -- it uses its own timestamps derived from the
buffer sizes instead.

Also add demo option to try this out.

#minor-release

PiperOrigin-RevId: 451353609
2022-05-30 16:34:38 +00:00
bachinger
821615cea0 Avoid usage of MediaController in MediaNotification.Provider
PiperOrigin-RevId: 451155897
2022-05-30 16:33:49 +00:00
ibaker
3d2b335825 Simplify DefaultMediaSourceFactory instantiation in a test
There's no need to manually construct a 'default'
DefaultDataSource.Factory instance, we can just pass the `Context` to
`DefaultMediaSourceFactory` and let it construct the
`DefaultDataSource.Factory` internally.

PiperOrigin-RevId: 451155747
2022-05-30 16:32:59 +00:00
hschlueter
0705a4e34d Replace frame processor with texture processor in TODO comment.
PiperOrigin-RevId: 451142799
2022-05-30 16:32:06 +00:00
hschlueter
0eaf3d30c8 Rename GlFrameProcessor to SingleFrameGlTextureProcessor.
Also update names of implementations to match design doc.
In follow-ups, SingleFrameGlTextureProcessor will become
an abstract implementation of a new GlTextureProcessor
interface.

Texture processor makes sense as it processes OpenGL textures.
The term frame processor will be used for something else in
follow-ups.

PiperOrigin-RevId: 451142085
2022-05-30 16:31:13 +00:00
ibaker
8f3b4f590f Fix typos flagged by lint
PiperOrigin-RevId: 451135097
2022-05-30 16:30:11 +00:00
ibaker
591eaef756 Fix some inconsistencies in the MediaItem API
* Rename (via deprecation)
  `MediaItem.DrmConfiguration.Builder#forceSessionsForAudioAndVideoTracks`
  to `setForceSessionsForAudioAndVideoTracks`. This is more consistent
  with existing 'force' method names both in this class and in
  `TrackSelectionParameters.Builder`.
* Add missing `@Nullable` annotation to the parameter for
  `MediaItem.SubtitleConfiguration.Builder#setMimeType`. This annotation
  is already present on the `MediaItem.SubtitleConfiguration#mimeType`
  field that this setter corresponds to.

PiperOrigin-RevId: 450941336
2022-05-26 11:57:21 +00:00
hschlueter
de1dceedc1 Skip SSIM calculation on Nexus 5 API 21.
There is a problem with the ImageReader formats used by the
SSIM helper that only occurs for Nexus 5 API 21, so as a workaround
we can skip the SSIM calculation on Nexus 5 API 21.

This skips just the SSIM calculation (by setting the value to
1.0 instead and logging). The tests still run when SSIM is skipped
so that we can detect other failures.

PiperOrigin-RevId: 450903183
2022-05-26 11:56:20 +00:00