8916 Commits

Author SHA1 Message Date
andrewlewis
ed0778d0ef Workaround unexpected discard of preloaded ad
After an ad pod coming up has preloaded, if the user seeks before it
plays we get pauseAd/stopAd called for that ad pod. Also, the ad will
not load again. Work around this unexpected behavior by handling
pauseAd/stopAd and discarding the ad.

In future, it's likely that the IMA SDK will stop calling those
methods, and will loadAd again for the preloaded ad that was
unexpectedly discarded. This change should be compatible with that,
because the ad won't be discarded any more due to not calling stopAd.

Issue: #7492
PiperOrigin-RevId: 316873699
2020-06-17 14:33:05 +01:00
andrewlewis
2546be51fe Remove some ad playback state change requirements
Ads can appear due to asynchronous ad tag requests completing after
earlier ads in a pod have loaded, so remove the requirement that the
ad count can't change. The MediaPeriodQueue should handling discarding
buffered content if an ad appears before already buffered content, so
I think this case is actually handled correctly by the core player
already.

Also remove the requirement that an ad URI can't change. This is a
defensive measure for now, but it's likely that a later fix in the IMA
SDK for an issue where loadAd is not called after preloading then
seeking before a preloaded ad plays will result in loadAd being called
more than once, and I think it's possible that the second call to
loadAd may have a different URI. Because the ad URI should only change
after an intermediate seek to another MediaPeriod, there shouldn't be
any problems with buffered data not getting discarded.

Issue: #7477
PiperOrigin-RevId: 316871371
2020-06-17 14:32:48 +01:00
tonihei
99954b4ca0 Deflake DecoderVideoRendererTest
The test was trying to synchronize a background decoding thread by
waiting for pending decode calls. However, the background thread needs
to fully queue the newly available output buffer before we can stop
waiting to ensure it's actually fully predictable. So we change the
pending wait to wait until the input buffer is cleared, which only
happens after the decoder is definitely done with it.

Also properly clean-up decoder (including shutting down the background
thread).

PiperOrigin-RevId: 316870659
2020-06-17 14:32:32 +01:00
andrewlewis
28695d9ab5 Move IMA SDK callbacks into inner class
The release() method was added in the recent IMA API changes for
preloading and now 'collides' with the ExoPlayer AdsLoader release
method. This led to all ads completing being treated as a call to
completely release the ads loader, which meant that the ad playback
state was not updated on resuming after all ads had completed, which
in turn led to playback getting stuck buffering on returning from the
background after all ads played.

Move the IMA callbacks into an inner class to avoid this.

Issue: #7508
PiperOrigin-RevId: 316834561
2020-06-17 14:32:15 +01:00
olly
f85098a88f Update deprecation JavaDoc for ExoPlayer DataSpec
constructor to note that the builder does NOT
infer the http method from the existence of the
post body.

PiperOrigin-RevId: 316765677
2020-06-17 14:31:59 +01:00
olly
c808db9935 Add MIME types for which every sample is known to be a sync sample.
- Leaving the TODO, since there are still MIME types we're unsure about.
- Removing AAC because xHE-AAC does not have this property. We may re-add
  it with an additional profile check to exclude xHE-AAC in the future.

PiperOrigin-RevId: 316715147
2020-06-17 14:31:43 +01:00
olly
e6b6a86a77 Remove support for MKV invisible flag
We haven't seen it used anywhere in practice. It's a niche feature not
supported by any other extractors, and is one of the very few things
stopping us from simplifying MediaSource implementations to not set the
decodeOnly sample flag. This is a simplification that we want to make,
since the current mechanism doesn't work properly for cases where a
downstream decoder adjusts the buffer presentation timestamps so that
they're different on the output side than on the input side.

PiperOrigin-RevId: 316712302
2020-06-17 14:31:27 +01:00
aquilescanta
2273b00a53 Create HlsMediaChunkExtractor
To be the abstraction to use for integrating with MediaParser.

PiperOrigin-RevId: 316710421
2020-06-17 14:31:10 +01:00
tonihei
aed8cad8c3 Remove unused waitingForKeys in renderers.
This flag isn't needed anymore because the waiting for keys happens on
the source side and the source just returns NOTHING_READ under the
same conditions.

PiperOrigin-RevId: 316704214
2020-06-17 14:30:54 +01:00
tonihei
cc97bcb469 Move runUntil method to TestUtil as it's used by multiple tests.
We started using this method from other tests unrelated to
TestExoPlayer, so the method is better placed inside a generic Util
class.

PiperOrigin-RevId: 316675067
2020-06-17 14:30:37 +01:00
bachinger
b7233c28e9 Add Player.getCurrentMediaItem()
PiperOrigin-RevId: 316650017
2020-06-17 14:30:21 +01:00
bachinger
5b28cb5209 Add getMediaItem() to MediaSource
This change adds MediaSource.getMediaItem and deprecates MediaSource.getTag. For backwards compatibility, the tag is made available through the Window with `mediaItem.playbackProperties.tag` as well as in the deprecated `tag` attribute.

PiperOrigin-RevId: 316539752
2020-06-17 14:30:04 +01:00
ibaker
9719b66d20 Pull IMA cuePoints -> adGroupTimesUs logic into a helper class
We're then able to use this same helper class from tests, to avoid
running into spurious failures caused by long microseconds being
round-tripped through float seconds.

PiperOrigin-RevId: 316435084
2020-06-17 14:29:47 +01:00
tonihei
cd54e3e584 Clarify usage of default period-in-window offset in tests.
Using the default offset as a magic constant makes tests hard to
understand. Improve that by looking up the value from the timeline or
setting it explicitly in multiple places, so the relationship becomes
clear.

PiperOrigin-RevId: 316421977
2020-06-17 14:29:31 +01:00
aquilescanta
3ec4ec4dac Make ChunkExtractor.read return a boolean instead of an int
PiperOrigin-RevId: 316172860
2020-06-17 14:29:14 +01:00
christosts
41d4a132c4 Add configure() in MediaCodecAdapter
The correct order of initializing the MediaCodec should be (as per
documentation
https://developer.android.com/reference/android/media/MediaCodec#initialization)

"create -> setCallback -> configure -> start"

but the MediaCodecRenderer currently does

"create -> configure -> setCallback -> start"

MediaCodec implementations did not complain about this so far, but the
wrong sequence does not work with the MediaCodec in block mode (new mode
in Android R) and also the ShadowMediaCodec won't operate in
asynchronous mode otherwise. To initialize the MediaCodec in the correct
order, this commit adds configure() in the MediaCodecAdapter so the
MediaCodecRenderer can do:

adapter.configure(); // sets the callback and then configures the codec
adapter.start();     // starts the codec

PiperOrigin-RevId: 316127680
2020-06-17 14:28:57 +01:00
olly
0a617146b0 Remove duplicate DECODE_ONLY check
PiperOrigin-RevId: 316119460
2020-06-12 18:11:48 +01:00
andrewlewis
f1b94f6f90 Add AdPlaybackState toString
This is useful for debugging both in tests and via logging.

PiperOrigin-RevId: 316102968
2020-06-12 18:11:39 +01:00
andrewlewis
5a88e0bc1d Handle errors in all VideoAdPlayer callbacks
Some but not all VideoAdPlayer callbacks from the IMA SDK included
defensive handling of unexpected cases. Add the remaining ones.

Issue: #7492
PiperOrigin-RevId: 316082651
2020-06-12 18:11:30 +01:00
andrewlewis
c5144dc777 Fix catch type in ImaAdsLoader defensive checks
PiperOrigin-RevId: 316079131
2020-06-12 18:11:21 +01:00
andrewlewis
28a7e59d7b Fix javadoc
PiperOrigin-RevId: 316071392
2020-06-12 18:11:12 +01:00
Oliver Woodman
df86278289 Merge pull request #7451 from szaboa:dev-v2-4511
PiperOrigin-RevId: 315995776
2020-06-12 00:26:45 +01:00
andrewlewis
5612ac50a3 Rollback of e1beb1d194
*** Original commit ***

Expose experimental offload scheduling

Add a new scheduling mode that stops ExoPlayer main loop
when the audio offload buffer is full and resume it when
it has been partially played.

This mode needs to be enabled and dissabled manually by the app
for now.

#exo-offload

***

PiperOrigin-RevId: 315948869
2020-06-12 00:26:35 +01:00
andrewlewis
fc0e0d4cb8 Rollback of 2aac0717d7
*** Original commit ***

Propagate format in supportsOutput

It is needed to know if gapless is needed,
as gapless offload might not be supported.

***

PiperOrigin-RevId: 315947888
2020-06-12 00:26:26 +01:00
andrewlewis
8afc0c3424 Rollback of 962e08d3be
*** Original commit ***

Add Offload gapless support

Confirmed to work on a Pixel 4 after enabling the feature:
 `setprop vendor.audio.offload.gapless.enabled true`

***

PiperOrigin-RevId: 315946947
2020-06-12 00:26:17 +01:00
olly
5324dc37e3 Support passing custom manifest parsers to Downloaders
Issue: #5978
PiperOrigin-RevId: 315941765
2020-06-12 00:26:08 +01:00
tonihei
73283d495a Add test that asserts correct offsets are used in renderer.
The test uses two items with period-in-window offsets and a non-zero default start position. The test also prepares the first item lazily so
that the start position (and thus the renderer offsets) need to change.
This is arguably the most complicated setup that needs to be tested.

PiperOrigin-RevId: 315903958
2020-06-12 00:26:00 +01:00
krocard
962e08d3be Add Offload gapless support
Confirmed to work on a Pixel 4 after enabling the feature:
 `setprop vendor.audio.offload.gapless.enabled true`

PiperOrigin-RevId: 315889054
2020-06-12 00:25:51 +01:00
tonihei
0b608dd19c Fix order of events in ProgressiveMediaPeriod.
The order of source info refresh and onPrepared was accidentally
changed by ed88f4f1dd. This changes it back to the correct order
and adds a test

PiperOrigin-RevId: 315885164
2020-06-12 00:25:42 +01:00
krocard
2aac0717d7 Propagate format in supportsOutput
It is needed to know if gapless is needed,
as gapless offload might not be supported.

PiperOrigin-RevId: 315877127
2020-06-12 00:25:33 +01:00
christosts
285cce629f Rename DedicatedThreadAsyncMediaCodecAdapter
Rename the DedicatedThreadAsyncMediaCodecAdapter to
AsynchronousMediaCodecAdapter as it is the only asynchronous adapter
implementation left after the clean-up.

PiperOrigin-RevId: 315873431
2020-06-12 00:25:24 +01:00
andrewlewis
e111f850d0 Allow skipping the ad before the start position
PiperOrigin-RevId: 315867160
2020-06-12 00:25:06 +01:00
krocard
e1beb1d194 Expose experimental offload scheduling
Add a new scheduling mode that stops ExoPlayer main loop
when the audio offload buffer is full and resume it when
it has been partially played.

This mode needs to be enabled and dissabled manually by the app
for now.

#exo-offload

PiperOrigin-RevId: 315860373
2020-06-12 00:24:57 +01:00
ibaker
032bb0498d Move FakeRenderer's DrmSession releasing from onReset() to onDisable()
This seems to match DecoderVideoRenderer more closely:
b1e56304a1/library/core/src/main/java/com/google/android/exoplayer2/video/DecoderVideoRenderer.java (L300)

Although MediaCodecRenderer does it in onReset() and then calls that
from onDisable():
b1e56304a1/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java (L754)

PiperOrigin-RevId: 315859212
2020-06-11 10:11:49 +01:00
kimvde
88b36abce6 Sniff all inferred extractors in DefaultHlsExtractorFactory
PiperOrigin-RevId: 315857270
2020-06-11 10:11:40 +01:00
Oliver Woodman
2fcd759edb Merge pull request #7479 from sravan1213:dev-v2
PiperOrigin-RevId: 315794031
2020-06-11 10:11:30 +01:00
aquilescanta
e7da26368a Add MediaParser-based implementation of ChunkExtractor
PiperOrigin-RevId: 315720712
2020-06-11 10:11:20 +01:00
christosts
3ce57ae2e8 Remove dropped MediaCodecAdadpters
Delete the AsynchronousMediaCodecAdapter, the
MultiLockAsyncMediaCodecAdapter and their tests.

PiperOrigin-RevId: 315694296
2020-06-11 10:11:11 +01:00
tonihei
95b61eb835 Split TrackSelection.evalauteQueueSize in discard and cancelation.
The option to cancel ongoing loads as part of the queue size evalation
was added recently. This split out the decision to a new method so that
a TrackSelection implementation can independently cancel loads and
discard upstream data. It also clarifies that evaluateQueueSize will
only be called if there is no ongoing load.

Issue: #2848
PiperOrigin-RevId: 315659735
2020-06-11 10:11:02 +01:00
tonihei
2a9144fa56 Fix loadCompleted flag in MediaChunk implementations.
This flag was always set even if the load was canceled and not completed.

PiperOrigin-RevId: 315659262
2020-06-11 10:10:53 +01:00
tonihei
b0d98a2e22 Find correct next chunk if previous one didn't finish loading.
If the previous chunk didn't finish loading, we need to find the appropriate
next chunk based on the current loading position (or the previous chunk's
start time if not independent).

PiperOrigin-RevId: 315658435
2020-06-11 10:10:45 +01:00
andrewlewis
b0457da038 Simplify timestamp tracking
An integer multiple/divide can be removed without loss of precision.

PiperOrigin-RevId: 315653905
2020-06-11 10:10:36 +01:00
krocard
0caada8b8c Fix formating in javadoc
PiperOrigin-RevId: 315516836
2020-06-11 10:10:27 +01:00
olly
5aa8a7a507 Prevent shutter closing for within-window seeks to unprepared periods
Issue: #5507
PiperOrigin-RevId: 315512207
2020-06-11 10:10:18 +01:00
andrewlewis
9ef9b56bcd Separate ads rendering and AdsManager init
In a later change it will be necessary to be able to destroy the ads
manager if all ads are skipped while creating ads rendering settings.
This change prepares for doing that by not having the ads manager
passed into the method (so the caller can null or initialize it).

PiperOrigin-RevId: 315488830
2020-06-11 10:10:09 +01:00
kimvde
1f17756ad2 Optimize DefaultExtractorsFactory order using MIME types
PiperOrigin-RevId: 315485985
2020-06-11 10:10:00 +01:00
olly
c759b5b1a9 Add option to hide Prev/Rwnd/Ffwd/Next buttons
Issue: #7410
PiperOrigin-RevId: 315480798
2020-06-09 16:05:44 +01:00
aquilescanta
a11f7b8cdd Document DataSource.getResponseHeaders case-insensitivity
PiperOrigin-RevId: 315480048
2020-06-09 16:05:33 +01:00
ibaker
947485e2b7 CEA-608: Position top-of-screen roll-up cues with bottom-line=row
Reasoning and screenshots here:
https://github.com/google/ExoPlayer/issues/7475#issuecomment-640770791

Issue: #7475
PiperOrigin-RevId: 315475888
2020-06-09 16:05:22 +01:00
christosts
d23ca7b11a Set MediaCodec operation mode for audio/video
Add experimental APIs to set the MediaCodecOperationMode separately
for audio and video.

PiperOrigin-RevId: 315467157
2020-06-09 16:05:11 +01:00