9055 Commits

Author SHA1 Message Date
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
andrewlewis
a56a02d2c5 Add tests for resuming ad playbacks
This is in preparation for refactoring the logic to support not
playing an ad before the resume position (optionally).

PiperOrigin-RevId: 315431483
2020-06-09 16:05:00 +01:00
samrobinson
83758577e3 Temporary fix for gapless regression for MP3.
PiperOrigin-RevId: 315334491
2020-06-09 16:04:49 +01:00
kimvde
b1e56304a1 Add support for inferring file format from MIME type
PiperOrigin-RevId: 315283926
2020-06-08 17:41:16 +01:00
bachinger
99d805f6a8 Make media item of SinglePeriodTimeline non-null
This change makes the media item argument in any constructors of the SinglePeriodTimeline non-null. Further a dummy media item is created for deprecated constructors using a tag only.

PiperOrigin-RevId: 315283842
2020-06-08 17:41:06 +01:00
aquilescanta
c37af0b543 Make ChunkExtractor return a ChunkIndex instead of a SeekMap
PiperOrigin-RevId: 315283645
2020-06-08 17:40:55 +01:00
ibaker
770df8636a CEA-608: Don't assume roll-up captions are at the bottom of the screen
ANSI/CTA-608-E R-2014 Annex B.5 says:
"The concept of a movable base row for a roll-up caption is new."

It means "new" compared to TC1 and TC2 (released in or before 1985).

Issue: #7475
PiperOrigin-RevId: 315258859
2020-06-08 17:40:44 +01:00
ibaker
b7486f4883 Add a test for 33-bit HLS WebVTT wraparound
This also gives some general test coverage for HLS' WebvttExtractor

Issue: #7462
PiperOrigin-RevId: 315257252
2020-06-08 17:40:33 +01:00
andrewlewis
bc7310240d Suppress repeated logging for invalid MP3 headers
PiperOrigin-RevId: 315243493
2020-06-08 17:40:22 +01:00
samrobinson
680d955851 Adjust input timestamps for the Codec2 MP3 decoder.
Output timestamps are calculated by the codec based on the buffers,
which is offset in Codec2. This adjusts the input timestamps as they
are passed in so they will match the output timestamps produced by
the MediaCodec.

PiperOrigin-RevId: 314963830
2020-06-08 17:40:11 +01:00
andrewlewis
f16803de69 Improve ImaAdsLoaderTest ad duration handling
Previously the fake ads loader listener would always pass the same ad
durations to the fake player, but actually the known ad durations can
change during playback.

Make the fake behavior more realistic by only exposing durations for
ads that have loaded.

PiperOrigin-RevId: 314956223
2020-06-08 17:40:00 +01:00
sravan1213
c3282c9a37 Propagate download exception through onDownloadChanged callback 2020-06-08 18:51:54 +05:30