6079 Commits

Author SHA1 Message Date
bachinger
a3b721e680 Make SsMediaSource add the media item to the timeline
PiperOrigin-RevId: 313573424
2020-05-29 18:33:34 +01:00
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
bachinger
f84bd4635a Replace manifest uri without changing the media item
We aim to have the same media item instance published in the timeline that is passed to the createMediaSource(mediaItem) method. This means when the manifest uri is manually replaced by a developer, the media item published in the next timeline update is still the same.

Note: This leads to the fact that the manifest published in that timeline is loaded from a different URI than the URI of the media item in the same timeline.
PiperOrigin-RevId: 313375421
2020-05-27 19:01:22 +01: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
tonihei
f099f570e6 Update TrackSelectionDialogBuilder to use androidx compat Dialog.
This ensure style themes are correctly applied.

issue:#7357
PiperOrigin-RevId: 313145345
2020-05-27 18:59:51 +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
tonihei
d487170eb0 Comment out unused code.
The code that uses these variables is already commneted out. Android Studio
complains about unused variables and code and it's better to comment them
out as long as they are not used.

PiperOrigin-RevId: 312660512
2020-05-21 17:10:40 +01:00
bachinger
2d52b0d5cf Add createMediaSource method with manifest and media item
This change adds an overloaded createMediaSource method which allows developers to pass in a media item with a in-memory manifest. Without this method the developer would not have a chance to pass in a non-dummy media item when using the factory for creting a DASH media source with an in-memory manifest.

PiperOrigin-RevId: 312660418
2020-05-21 17:10:30 +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
bachinger
634634f8e3 Make DashMediaSource add the media item to the timeline
PiperOrigin-RevId: 312646461
2020-05-21 17:09:51 +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
olly
0de9c007af Fix naming to reflect that CEA-708 is supported too
PiperOrigin-RevId: 312131816
2020-05-18 22:39:51 +01: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
Oliver Woodman
3db703a983 Merge pull request #7370 from jruesga:embedded-cea-708-support
PiperOrigin-RevId: 312090461
2020-05-18 22:38:10 +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
andrewlewis
ef615754db Fix handling of fetch errors for post-rolls
The ad break time in seconds from IMA was "-1" for postrolls, but this didn't
match C.TIME_END_OF_SOURCE in the ad group times array.

Handle an ad break time of -1 directly by mapping it onto the last ad group,
instead of trying to look it up in the array.

PiperOrigin-RevId: 312064886
2020-05-18 16:14:19 +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
olly
b667a0e7e2 Rename closed caption variables to be non-608 specific
This is the rename-only part of https://github.com/google/ExoPlayer/pull/7370

PiperOrigin-RevId: 312057896
2020-05-18 16:14:01 +01:00
samrobinson
cda9417aa6 Allow MP3 files to play with size greater than 2GB.
Issue:#7337
PiperOrigin-RevId: 312042768
2020-05-18 16:13:52 +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
aquilescanta
f6d0e34cea Fix Extractor.read throws documentation
PiperOrigin-RevId: 311755157
2020-05-18 16:13:25 +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