3318 Commits

Author SHA1 Message Date
tonihei
4419a26bbb Use assertThrows in CacheWriterTest.
PiperOrigin-RevId: 313556143
2020-05-29 18:33:15 +01:00
olly
a01fd007cb Change setOutputSurfaceV23 visibility.
PiperOrigin-RevId: 313481722
2020-05-29 18:33:06 +01:00
Joris de Groot
2af9b4b066 Updated documentation 2020-05-28 14:55:02 +02:00
Oliver Woodman
82e199445a Merge pull request #7422 from noamtamim:bandwidthmeter-5g
PiperOrigin-RevId: 313372995
2020-05-27 19:01:12 +01:00
aquilescanta
32c356177f Extract a ChunkExtractor interface
A future implementation will depend on MediaParser.

PiperOrigin-RevId: 313367998
2020-05-27 19:01:02 +01:00
olly
d88f5f47e6 Turn CacheUtil into stateful CacheWriter
- The new CacheWriter is simplified somewhat
- Blocking on PriorityTaskManager.proceed is moved out of
  CacheWriter and into the Downloader tasks. This is because
  we want to shift only the caching parts of the Downloaders
  onto their Executors, whilst keeping the blocking parts on
  the main Downloader threads. Else we can end up "using"
  the Executor threads indefinitely whilst they're blocked.

Issue: #5978
PiperOrigin-RevId: 313222923
2020-05-27 19:00:53 +01:00
ibaker
a1c72c0daf Add .inOrder() to most AnalyticsCollectorTest asserts
I skipped it where it didn't make sense (e.g. singleton lists, or lists
where all elements are identical).

PiperOrigin-RevId: 313217398
2020-05-27 19:00:44 +01:00
krocard
151ea531b1 Make constants more readable with _ separator
Add an `_` in long constants.
Eg: 10000 => 10_000.

I'm proposing this change because I have had multiple
missread due to confusing the number of 0 in a long number.

More specifically, added an underscore to all number matching:
`final.*\ [0-9]{2,}000;`

PiperOrigin-RevId: 313186920
2020-05-27 19:00:36 +01:00
tonihei
45b574d593 Fix flaky test.
The test was flaky because it didn't wait for pending commands to finish
after pausing the test playback.

Also add more debug information to the toString() method because the
expected and actual state only differed in the nextAdGroupIndex in the
flaky case.

PiperOrigin-RevId: 313175919
2020-05-27 19:00:27 +01:00
tonihei
0add067eaa Make fallback value more explicitly unset.
PiperOrigin-RevId: 313171970
2020-05-27 19:00:18 +01:00
olly
03ea39b175 ConditionVariable: Add uninterruptible block
Sometimes it's useful to be able to block until something on some other thread
"really has finished". This will be needed for moving caching operations onto
the executor in Downloader implementations, since we need to guarantee that
Downloader.download doesn't return until it's no longer modifying the
underlying cache.

One solution to this is of course just to not interrupt the thread that's
blocking on the condition variable, but there are cases where you do need to do
this in case the thread is at some other point in its execution. This is true
for Downloader implementations, where the Download.download thread will also
be blocking on PriorityTaskManager.proceed. Arranging to conditionally
interrupt the thread based on where it's got to is probably possible, but seems
complicated and error prone.

Issue: #5978
PiperOrigin-RevId: 313152413
2020-05-27 19:00:09 +01:00
tonihei
ee11d9d6fb Make manifest loads on timeline refresh optional in FakeMediaSource.
Every timeline refresh currently assumes that it corresponds to a manifest
refresh and issues the respective load events. However, there are other
timeline updates that don't have a manifest refresh (e.g. ad state updates)and thus shouldn't issue these events.

PiperOrigin-RevId: 313150489
2020-05-27 19:00:00 +01:00
Noam Tamim
cf2214ddaa
Assume default 4G (instead of Wifi) bitrate for 5G 2020-05-24 15:20:18 +03:00
tonihei
dac3dde7bb Fix comparison in ChunkSampleStream.
A recent change tried to make this condition clearer by using Integer.MAX_VALUE, but
this only works if the comparison also compares against larger values.

PiperOrigin-RevId: 312697530
2020-05-21 18:43:13 +01:00
tonihei
80eb5d4235 Merge pull request #7244 from tvarga-dss:cancel-hls-chunk-download-and-discard-upstream
PiperOrigin-RevId: 312679454
2020-05-21 17:10:51 +01:00
andrewlewis
1bc8503a9b Check DefaultAudioSink supports passthrough
Previously if the AudioCapabilities reported that an encoding/channel count was
supported, DefaultAudioSink could try to play it via passthrough. However,
DefaultAudioSink does not support passthrough of every possible format (for
example, it's likely that AAC passthrough does not work given it's never been
tested and recent GitHub issues indicate that trying to use it leads to no
audio being played).

Add additional checks to make sure the encoding is in the list of encodings that
are known to work with passthrough in DefaultAudioSink.

issue:#7404
PiperOrigin-RevId: 312651358
2020-05-21 17:10:20 +01:00
olly
4384ef5b73 Make CacheUtil only about writing
A subsequent change will rename it to CacheWriter and make it instantiable.

Issue: #5978
PiperOrigin-RevId: 312648623
2020-05-21 17:10:11 +01:00
christosts
1154e8098a Rollback of 78c850a885
*** Original commit ***

Remove set timeout on release() and setSurface()

Removes the experimental methods to set a timeout when
releasing the player and setting the surface.

***

PiperOrigin-RevId: 312647457
2020-05-21 17:10:01 +01:00
olly
63522ea554 Improve CacheKeyFactory documentation
- To make it clear that cache keys are for whole resources
- To explicitly make it clear to implementors that deriving a cache key
  from position and length is invalid. We've seen at least one developer
  trying to do this [1], so it seems worthwhile to be explicit!

[1] https://github.com/google/ExoPlayer/issues/5978#issuecomment-618977036

Issue: #5978
PiperOrigin-RevId: 312643930
2020-05-21 17:09:41 +01:00
ibaker
2397e7f67a Replace TestUtil.joinByteArrays() with Guava's Bytes.concat()
PiperOrigin-RevId: 312481058
2020-05-21 17:09:22 +01:00
samrobinson
9035f1d701 Update getPcmEncoding return type to PcmEncoding rather than Encoding.
PiperOrigin-RevId: 312479370
2020-05-21 17:09:12 +01:00
ibaker
02e74d6c94 Fix Guava deps from compileOnly to implementation
PiperOrigin-RevId: 312479354
2020-05-21 17:09:03 +01:00
bachinger
d233c04582 Simplify DownloadHelper
PiperOrigin-RevId: 312467496
2020-05-21 17:08:43 +01:00
ibaker
b9157a9e23 Add Guava dependency to ExoPlayer
Guava is heavily optimized for Android and the impact on binary size
is minimal (and outweighed by the organic growth of the ExoPlayer
library).

This change also replaces Util.toArray() with Guava's Ints.toArray()
in order to introduce a Guava usage into a range of modules.

PiperOrigin-RevId: 312449093
2020-05-21 17:08:33 +01:00
olly
e87221c938 Add Cache.getCachedBytes
This will replace the need to use CacheUtil.getCached, and is part of refactoring
CacheUtil to only do writing (it will be renamed to CacheWriter in a subsequent
change).

PiperOrigin-RevId: 312366040
2020-05-21 17:08:24 +01:00
olly
a42a1f49ed Allow passing C.LENGTH_UNSET to getCachedLength
The caller will often have C.LENGTH_UNSET already, and
it's awkward to force them to do the conversion themselves.

PiperOrigin-RevId: 312276810
2020-05-21 17:08:14 +01:00
olly
1be295ab0c Fix SimpleCache.getCachedLength rollover bug & improve test coverage
PiperOrigin-RevId: 312266156
2020-05-21 17:08:04 +01:00
ibaker
6e02a81501 Cleanup WebvttCueParser and WebvttCssStyle
- Remove scratchStyleMatches output parameter from WebvttCueParser.
- Switch from String[] to Set<String> for representing classes.
- In-line WebvttCssStyle.reset() since it's not used anywhere else.

PiperOrigin-RevId: 312249552
2020-05-21 17:07:54 +01:00
Joris de Groot
86b31e2954 Added storage not low as download requirement
Added monitoring storage levels in RequirementsWatcher
Added dependency on extension-workmanager to the demo app to be able to test with WorkManagerScheduler
Added getSupportedRequirements method to Scheduler interface
Implemented getSupportedRequirements for schedulers
2020-05-19 15:22:43 +02:00
olly
be098401e9 Cache: Improve documentation and terminology
PiperOrigin-RevId: 312130813
2020-05-18 22:39:35 +01:00
aquilescanta
ba33f60485 Deprecate LoadErrorHandlingPolicy methods without loadTaskId
Issue: #7309
PiperOrigin-RevId: 312115330
2020-05-18 22:39:19 +01:00
olly
cccb9e1ae8 CacheUtil: Remove confusing remove(DataSpec) method
- The remove(DataSpec) method was confusing because it ignored
  the DataSpec position and range, and instead removed all data
  with a matching cache key.
- The remove(String) method seems better put directly on the
  Cache interface.

PiperOrigin-RevId: 312113302
2020-05-18 22:39:02 +01:00
ibaker
377bf27f47 Extend WebVTT ruby-position support to include <rt> tags
PiperOrigin-RevId: 312096467
2020-05-18 22:38:45 +01:00
ibaker
38fc7d8c0d Add WebVTT support for ruby-position CSS property
This is currently only parsed if the CSS class is specified directly on
the <ruby> tag (e.g. <ruby.myClass>)

PiperOrigin-RevId: 312091710
2020-05-18 22:38:29 +01:00
ibaker
9c8cd4b575 Add DRM data to AnalyticsCollectorTest
This requires lots of new DRM plumbing in FakeMedia{Period,Source} and
FakeSampleStream.

Part of issue:#6765

PiperOrigin-RevId: 312072332
2020-05-18 16:14:36 +01:00
bachinger
5b0e971f0e Make SingleSampleMediaSource provide a media item
This is part of go/exoplayer-playlist-retrieval which aims for all MediaSources to associate the media item to the corresponding window. Media items need to be added to the timeline which then assigns it to the window.mediaItem attribute.

PiperOrigin-RevId: 312065023
2020-05-18 16:14:28 +01:00
ibaker
786edf8ecd Tweak DefaultDrmSession acquire & release event behaviour
The new behaviour:
- If the session is successfully opened, an acquire event is dispatched
  to all attached dispatchers.
- If acquire() is called but the session is already open, the acquire
  event is dispatched only to the dispatcher provided in to acquire()
- If the session is successfully released, a release event is dispatched
  to all attached dispatchers (in theory at most one should ever be
  attached at this point).
- If release() is called but the session isn't released (because
  referenceCount > 0) then a release event is dispatched only to the
  dispatcher provided to release().

PiperOrigin-RevId: 312062422
2020-05-18 16:14:10 +01:00
ibaker
8188c29279 Shorten the string form of AnalyticsCollectorTest internal objects
This makes test failures with lists of items much easier to read

PiperOrigin-RevId: 312035040
2020-05-18 16:13:43 +01:00
andrewlewis
ceddc60296 Publish MediaCodec-based renderer tests
Switch to snapshot Robolectric to pick up the latest version of shadows
required by MediaCodecVideoRendererTest and MediaCodecAudioRendererTest.

PiperOrigin-RevId: 312030332
2020-05-18 16:13:34 +01:00
andrewlewis
793f12da6d Add support for timing out ad preloading
Detect stuck buffering cases in ImaAdsLoader, and discard the ad group after
a timeout. This is intended to make the IMA extension more robust in the case
where an ad group unexpectedly doesn't load.

The timing out behavior is enabled by default but apps can choose to retain
the old behavior by setting an unset timeout on ImaAdsLoader.Builder.

PiperOrigin-RevId: 311729798
2020-05-18 16:13:15 +01:00
tonihei
f3d331c9f7 Extend EventTime with full current position info.
EventTime contains information about when an event happened and where
it belongs to. Both places can be fully described using timeline, window
index, media period id and position.

Right now, only the information for where the event belongs to is fully
contained in EventTime, whereas the time when the event happened only has
the position, and none of the other information (timeline, window, period).

This change adds the missing information, so that the EventTime can easily
be used without having access to the Player. This also ensures Event
metadata is self-contained and can be stored and reused later.

issue:#7332
PiperOrigin-RevId: 311727004
2020-05-18 16:13:06 +01:00
christosts
78c850a885 Remove set timeout on release() and setSurface()
Removes the experimental methods to set a timeout when
releasing the player and setting the surface.

PiperOrigin-RevId: 311703988
2020-05-18 16:12:57 +01:00
olly
f91cfb12e8 Attach ExoMediaCryptoType for progressive streams
PiperOrigin-RevId: 311628160
2020-05-15 10:58:58 +01:00
ibaker
a39233d2fd Limit CEA-608 captions to 32 chars per line
ANSI/CTA-608-E R-2014 spec defines exactly 32 columns on the screen,
and limits all lines to this length.

See 3.2.2 definition of 'Column'.

issue:#7341
PiperOrigin-RevId: 311549881
2020-05-14 22:24:49 +01:00
aquilescanta
758e99e3f1 Remove last references to old load error handling methods
PiperOrigin-RevId: 311531734
2020-05-14 22:24:40 +01:00
bachinger
9e35c6c28c Make all segment downloader use the media item
PiperOrigin-RevId: 311527440
2020-05-14 22:24:31 +01:00
bachinger
c1aa9b917b Make use of MediaItem in ProgressiveDownloader
PiperOrigin-RevId: 311513746
2020-05-14 22:24:21 +01:00
aquilescanta
6abec07a07 Update DefaultDrmSession load error handling
Issue:#7309
PiperOrigin-RevId: 311504497
2020-05-14 22:24:04 +01:00
tonihei
7b552d7786 Move common init steps into SimpleExoPlayer builder.
Some player setup steps that are likely to be only done once
should be moved into the Builder so that player setup can use
a consistent style (builder vs setters).

This also prevents some threading warning issues when the player
is built on a background thread (e.g. for dependency injection
frameworks) and setters can't be used due to threading restrictions.

PiperOrigin-RevId: 311487224
2020-05-14 22:23:55 +01:00
aquilescanta
025a2c2b62 Make MediaDrmCallback surface more error information
Issue:#7309
PiperOrigin-RevId: 311324242
2020-05-14 22:23:37 +01:00