1478 Commits

Author SHA1 Message Date
olly
8c5af10ab0 Don't pass INDEX_UNSET to ExoPlayer seek methods
It's not valid, and will cause IllegalSeekPositionException to be thrown

PiperOrigin-RevId: 327301325
2020-08-21 12:50:20 +01:00
olly
ee743870d8 Media2 extension: Make DefaultMediaItemConverter more useful
- Remove throwing of IllegalStateException
- Make it non-final so additional metadata can be more easily filled in

PiperOrigin-RevId: 327292208
2020-08-21 12:50:11 +01:00
jaewan
bddb29c431 Ban FileMediaItem and CallbackMediaItem
PiperOrigin-RevId: 327268964
2020-08-21 12:50:01 +01:00
jaewan
2299c4e609 Update SessionPlayerConnector documentation
ExoPlayer is now the trusted source of playlist and can be
used by other components without breaking
SessionPlayerConnector's cached playlist.

PiperOrigin-RevId: 327266929
2020-08-21 12:49:52 +01:00
jaewan
4782e227eb Rename androidX MediaItem to media2 MediaItem
In AndroidX, both media1 and media2 have MediaItem classes,
so change the naming to remove ambiguity.

PiperOrigin-RevId: 327261260
2020-08-21 12:49:43 +01:00
jaewan
e6d36e8b92 Add SessionPlayerConnector ctor that use DefaultMediaItemConverter
PiperOrigin-RevId: 327258863
2020-08-21 12:49:34 +01:00
jaewan
b39721f4b5 Make ExoPlayer as the trusted source of playlist
Playlist can now be obtained directly from Timeline windows
in any state. So make ExoPlayer as the trusted source of
playlist, instead of SessionPlayerConnector.

PlayerWrapper still need to keep the list of media items.
It's used to detect whether the Timeline change is caused by
changes in media items or not, and only notify
SessionPlayer.PlayerCallback#onPlaylistChanged() only when
the playlist is really changed.

PiperOrigin-RevId: 327231820
2020-08-21 12:49:25 +01:00
jaewan
be98509e03 Workaround test failure with stable release of media2.session
MediaSession requires prepared Looper in 1.0.3-stable release,
which is the latest stable release for now.

The requirement would be removed in 1.1.0-stable, but workaround
is needed meanwhile.

PiperOrigin-RevId: 327220042
2020-08-21 12:48:57 +01:00
ibaker
f0ae8afd80 Separate the dump files from the test assets
This allows us to more easily create different dumps derived from the
same assets.

This moves media/source files from `assets/` to `assets/media/` and
dump files from `assets/` to `assets/extractordumps/` and
`assets/audiosinkdumps/` as appropriate. I intend to add
`assets/playbackdumps/` in a future CL.

PiperOrigin-RevId: 326986283
2020-08-17 16:13:53 +01:00
olly
49bf83a169 Media2: Remove MediaSourceFactory + DataSourceCallback
- Applications should generally use DefaultMediaSourceFactory,
  or their own custom implementation if they need one. Having the
  media2 extension implement its own version directly doesn't seem
  that useful.
- Remove support for CallbackMediaItem. This type of MediaItem
  doesn't go cross-process, and it seems like there would never
  be a use case where an app would need to generate one locally.
  If an app needs to provide data from a custom source, it should
  hook into ExoPlayer's way of doing this (i.e., use a UriMediaItem
  with a custom scheme, and inject a custom DataSource that can
  handle this scheme).

PiperOrigin-RevId: 326914465
2020-08-17 16:13:34 +01:00
olly
42cf213aea Media2 tests: Simplify code
- Use ExoPlayer DataSource instrumentation to intercept reads
- Use ExoPlayer Resource URIs
- Use ExoPlayer DefaultMediaSourceFactory

PiperOrigin-RevId: 326912324
2020-08-17 16:13:25 +01:00
jaewan
c2ac33af1b Clean up PlayerWrapper exception log
PlayerWrapper throws Exception if getters is called in the
STATE_IDLE. In that case, log may print 50+ lines of stack
traces. It's verbose and can be considered as serious issue.

This CL include folloing changes
  - Change to use ExoPlayer's log class
  - Adjust log level, because it would be consumed by caller
  - Leave log when the debug flag is turned on.

Another CL will remove exceptions between PlayerWrapper and
and SessionPlayerConnector, not to use Exception for ordinary
control flow as the Effective Java suggests.

PiperOrigin-RevId: 326614559
2020-08-17 16:12:48 +01:00
olly
cdf07f1745 Media2 tests: Clean up assets
Even after this change, it's unclear to me why we need so many
assets for these tests. Just doing a minimal pass for now though!

PiperOrigin-RevId: 326613941
2020-08-17 16:12:39 +01:00
jaewan
e6bf7bd0ff Migrate to use Player's top level playlist API
Being specific, this includes following changes
  - Remove PlaylistManager and TimelinePlaylistManager
    and use Player's playlist API directly.
  - Replace ConcatenatingMediaSource uses with
    ExoPlayer MediaItem.
  - Replace PlaybackPreparer uses with Player#prepare()
  - Add MediaItemConverter for developers to customize
    converting AndroidX MediaItems to ExoPlayer MediaItems
    and vice-versa.
  - Add DefaultMediaItemConverter for providing default
    implementation of both MediaItemConverter
    and MediaSourceFactory.

Note that removing PlaylistManager loses the ability
to suppress individual playlist API. But decided to remove
for simpler API set. The feature can be added back later
via explicit request.

PiperOrigin-RevId: 326463492
2020-08-17 16:12:21 +01:00
ibaker
da4d55635c Create a DumpFileAsserts from the dumpfile logic in FakeExtractorOutput
Also use it to replace the same logic in CapturingAudioSink

PiperOrigin-RevId: 325969455
2020-08-17 16:08:24 +01:00
tonihei
ad346fbdbe Fix FfmpegVideoRenderer tag
PiperOrigin-RevId: 325857202
2020-08-17 16:08:06 +01:00
andrewlewis
acc8453628 Add support for audio-only ad display containers
Issue: #7689
PiperOrigin-RevId: 325752377
2020-08-17 16:05:56 +01:00
jaewan
f2866a4942 Notify current media item to legacy controllers
This is the workaround for b/159147455.

The issue will be fixed in media2-session 1.1.0-stable, but we'd
better to have workaround until it's ready.

PiperOrigin-RevId: 325434543
2020-08-07 19:04:56 +01:00
olly
5de56cd618 Opus: Add utility for handling header and initialization data
PiperOrigin-RevId: 325202386
2020-08-07 19:02:14 +01:00
gyumin
6e11d32092 Use static import for TimeUnit
PiperOrigin-RevId: 324941042
2020-08-07 19:01:07 +01:00
olly
4d03d30890 Audio extension decoders: Pass decoder to getOutputFormat
It seems generally useful to have access to the decoder in
getOutputFormat. We're currently working around lack of access
by using member variables in the concrete audio extension
renderers. In the case of the Ffmpeg extension, holding a
reference to the decoder is preventing it from being garbage
collected when the decoder is released by the base class.

PiperOrigin-RevId: 324799670
2020-08-07 19:00:18 +01:00
claincly
ea01489c8b Added float output mode for Opus extension
The working of libOpus is different from ffmpeg. With ffmpeg, the decoder can
be configured to output floating point PCM. While in libOpus, floating samples
are acquired by calling a different function. This is the reason the new JNI
functions and the logic in OpusDecoder/LibopusAudioRenderer is added to
support float output.

PiperOrigin-RevId: 324661603
2020-08-07 18:59:50 +01:00
andrewlewis
9392dff225 Call VideoAdPlayerCallback.onLoaded
This callback was not notified before, which could theoretically lead to ad
loading timing out. In practice it doesn't currently happen because the timeout
appears to start when the ad cue point is reached, not when loadAd is called.

We notify onLoaded when the ad media period is prepared (for HTML5 the
recommendation is to notify on the HTMLMediaElement 'canplay' event, which this
roughly corresponds to).

PiperOrigin-RevId: 324568407
2020-08-07 18:58:31 +01:00
krocard
7b300ca411 Build cmake AV1 outside of CITC
PiperOrigin-RevId: 323988640
2020-08-01 12:56:12 +01:00
aquilescanta
867d45ca62 Simplify the av1 extension build system
Also add cpu_features to .hgignore.

PiperOrigin-RevId: 323804458
2020-08-01 12:55:36 +01:00
aquilescanta
684994fe61 Remove Renderer references to Format.drmInitData
PiperOrigin-RevId: 323392470
2020-07-28 00:00:27 +01:00
ibaker
fda3b3d8ec Use static imports for methods that make sense without their class name
PiperOrigin-RevId: 323349585
2020-07-27 23:59:52 +01:00
ibaker
ce2e6e2fd6 Hide ParsableByteArray#data behind a getter
This allows us to enforce the limit because the array can only be
reassigned through reset(byte[]) or reset(byte[], int) (which update
the limit)

PiperOrigin-RevId: 323339960
2020-07-27 23:59:34 +01:00
ibaker
478f59fd08 Replace ExoPlayer's functional types with Guava alternatives
This removes Supplier, Function and Predicate. Consumer is kept because
Guava doesn't have an equivalent (Java 8 does, but we can't use that
yet).

#exofixit

PiperOrigin-RevId: 323324392
2020-07-27 23:59:25 +01:00
jaewan
9743e47f1f Remove unncessary TODOs
PiperOrigin-RevId: 323286632
2020-07-27 23:59:07 +01:00
andrewlewis
f24ba73b80 Add setter for companion ad slots
PiperOrigin-RevId: 322965540
2020-07-27 23:58:30 +01:00
aquilescanta
19602ca4ca Use CMake to build the ffmpeg audio extension
PiperOrigin-RevId: 322793308
2020-07-24 10:48:16 +01:00
olly
6d92eebe51 Revert Format back to only containing audio encoding for PCM
PiperOrigin-RevId: 322683545
2020-07-24 10:46:37 +01:00
ibaker
84e13e3bd0 Replace media2 SettableFuture with Guava version
PiperOrigin-RevId: 322530026
2020-07-24 10:44:11 +01:00
olly
d77ce9eda0 Remove deprecated calls to external APIs
PiperOrigin-RevId: 322346067
2020-07-24 10:43:44 +01:00
olly
576ef82191 Remove explicit use of Robolectric PAUSED looper mode
It's now the default everywhere, so there's no need to specify it
explicitly.

PiperOrigin-RevId: 322153319
2020-07-24 10:41:00 +01:00
olly
df1536ab24 Migrate WorkManagerScheduler to non-deprecated WorkManager.getInstance
PiperOrigin-RevId: 322143769
2020-07-24 10:40:33 +01:00
olly
0cd15d9158 Proactively check listener arguments are non-null
PiperOrigin-RevId: 322143359
2020-07-24 10:40:24 +01:00
ibaker
c669756f7d Add a missing deprecation suppression in CastPlayer
PiperOrigin-RevId: 322115322
2020-07-24 10:39:21 +01:00
andrewlewis
7fce04a67f Depend on the IMA extension in noExtensions variant
Also use the cronet extension in the demo app.

PiperOrigin-RevId: 322108530
2020-07-24 10:39:03 +01:00
ibaker
3074365348 Suppress deprecation warning in CastPlayer
PiperOrigin-RevId: 321774583
2020-07-24 10:38:26 +01:00
ibaker
b755df1338 Update PlayerWrapper methods to return void where possible
Suggested during the review of 437d1b6e9a

This keeps the Runnable -> Callable<Boolean> conversion encapsulated
inside SessionPlayerConnector which makes it clearer why it's needed.

PiperOrigin-RevId: 321553744
2020-07-24 10:37:32 +01:00
olly
363a2a3b45 DefaultRenderersFactory: Add setting to enable float output
This also renders https://github.com/google/ExoPlayer/pull/7625 redundant.

PiperOrigin-RevId: 321544195
2020-07-24 10:37:05 +01:00
ibaker
e682f53b3c Migrate overrides of deprecated onPlaybackParametersChanged
This method has been replaced by onPlaybackSpeedChanged

PiperOrigin-RevId: 321369921
2020-07-24 10:36:02 +01:00
ibaker
437d1b6e9a Migrate usages of deprecated Player#set/getPlaybackParameters()
PiperOrigin-RevId: 321166822
2020-07-24 10:33:36 +01:00
ibaker
93c9e93a09 Migrate usages of renderer constants in C.java to the Renderer ones
PiperOrigin-RevId: 321157794
2020-07-24 10:33:00 +01:00
ibaker
f83d478cc3 Migrate uses of prepare(MediaSource) to setMediaSource() & prepare()
PiperOrigin-RevId: 321147910
2020-07-24 10:31:57 +01:00
ibaker
b48a762f20 Migrate overrides of deprecated AdsViewProvider.getAdOverlayViews
PiperOrigin-RevId: 321121735
2020-07-24 10:31:31 +01:00
ibaker
e9a8335381 Migrate callers to pass MediaItem to createMediaSource()
createMediaSource(Uri) is deprecated.

PiperOrigin-RevId: 321121383
2020-07-24 10:31:22 +01:00
ibaker
23d680a4b4 Suppress deprecation warnings in deprecated places
PiperOrigin-RevId: 320970814
2020-07-24 10:30:53 +01:00