5575 Commits

Author SHA1 Message Date
tonihei
de915bd6a1 Handle potential timeline updates that switch from content to ad.
We currently don't test if an ad needs to be played in case we are already
playing content.

This is to prevent recreating the current content period when
an ad is marked as skipped. We prefer playing until the designated ad group
position and appending another piece of content. This is less likely to cause
visible discontinuities in case the ad group position is at a key frame
boundary.

However, this means we currently miss updates that require us to play an ad
after a timeline update.

PiperOrigin-RevId: 267553459
2019-09-10 10:26:59 +01:00
andrewlewis
b77688533b Fix init data handling for FLAC in MP4
Issue: #6396
PiperOrigin-RevId: 267536336
2019-09-10 10:26:51 +01:00
Yannick RUI
5f48871731 Count the number of matches for role flags.
Select a track with matching role flags even if someone specifies a preferred role flgs without providing a preferred language
Prefer track without captions or describing music and sound flag when no role flag preference is provided.
2019-09-05 17:31:24 +02:00
Toni
75435b4210 Merge pull request #6286 from sr1990:dev-v2
PiperOrigin-RevId: 267323559
2019-09-05 10:56:35 +01:00
sr1990
33eb49ca0d Support negative value of the @r attrbute of S in SegmentTimeline element 2019-09-05 10:48:46 +01:00
sr1990
b4a1d55fe4 Support negative value of the @r attrbute of S in SegmentTimeline element 2019-09-05 10:48:46 +01:00
tonihei
b57c556194 Remove deprecated Timeline.getWindow method.
Removing this method requires custom MediaSource implementations to switch
to the new version. While this breaks the implmentation, it also avoids problems
with accidentely forwarding to the wrong method or with accidental stack
overflows when none of the two methods gets implemented.

It's unlikely any callers are affected because this is only the extended version
with the defaultProjectionPositionUs parameter that no caller except the
internal player will use.

PiperOrigin-RevId: 267323042
2019-09-05 10:48:46 +01:00
olly
40870b8780 Prevent audio pops on audio format change. We'd like to switch opus audio bitrates in the middle of playback based on network conditions.
Changing between different bitrates on the same codec should not require decoder initialization.

PiperOrigin-RevId: 267208043
2019-09-05 10:48:45 +01:00
olly
0e7740f576 Clear FormatHolder before and after reading from the source.
PiperOrigin-RevId: 267135256
2019-09-05 10:48:45 +01:00
aquilescanta
578398c297 Move DefaultLoadErrorHandling creation to DefaultDrmSessionManager
Issue:#6334
PiperOrigin-RevId: 266910499
2019-09-05 10:48:45 +01:00
christosts
260db03167 Use DataSpec request params in HttpDataSource impls
Include Dataspec.httpRequestHeaders in CronetDataSource,
and OkHttpDataSource. Updated documentation of
HttpDataSource.open() to suggest that it should set request
headers (in decreasing priority) from (1) the passed DataSpec,
(2) parameters set with setRequestProperty() and (3) default
parameters set in the HttpDataSource.Factory. No mechanism
has been put in place to enforce this.

PiperOrigin-RevId: 266895574
2019-09-05 10:48:45 +01:00
bachinger
a12c6641d9 provide content description for shuffle on/off button
PiperOrigin-RevId: 266884166
2019-09-05 10:48:45 +01:00
bachinger
e4eb6b7ea9 move transparency values of buttons to resources to make it accessible for customization
PiperOrigin-RevId: 266880069
2019-09-05 10:48:45 +01:00
aquilescanta
64829a0373 Calculate loadDurationMs in DefaultDrmSession key and provisioning requests
PiperOrigin-RevId: 266812110
2019-09-05 10:48:45 +01:00
olly
0dc997103b Use constant to define androidx media version
PiperOrigin-RevId: 266802551
2019-09-05 10:45:24 +01:00
olly
2d0b10a73a Use constant to define androidx annotation version
PiperOrigin-RevId: 266801762
2019-09-05 10:45:08 +01:00
aquilescanta
d37c18abfe Clarify LoadErrorHandlingPolicy's loadDurationMs javadocs
PiperOrigin-RevId: 266797383
2019-09-05 10:44:59 +01:00
bachinger
d2c056eb91 move transparency of shuffle mode off button to bitmap
PiperOrigin-RevId: 266795413
2019-09-05 10:44:51 +01:00
olly
bcd7de5316 Fix exception message
PiperOrigin-RevId: 266790267
2019-09-05 10:44:43 +01:00
bachinger
eedf50fdca use isPlaying to determine which notification action to display in compact view
PiperOrigin-RevId: 266782250
2019-09-05 10:44:34 +01:00
aquilescanta
494b6f6f3b Re-use local variable in replacement of unnecessary indirections
PiperOrigin-RevId: 266772364
2019-09-05 10:44:26 +01:00
kimvde
82d10e2ea8 Bypass sniffing for single extractor
Sniffing is performed in ProgressiveMediaPeriod even if a single
extractor is provided. Skip it in that case to improve performances.

Issue:#6325
PiperOrigin-RevId: 266766373
2019-09-05 10:44:18 +01:00
tonihei
aff9e731b2 Move DefaultHttpDataSource request header explanation to class Javadoc.
The Javadoc for open() won't be read by anyone because it's an overridden method
of the interface and not called directly from application code.

Move doc to class documentation as this is a generic explanation about the
functionality of the class. Also added "all" to clarify that all the parameters
will be added and the order of preference just applies in case of key clashes.

PiperOrigin-RevId: 266753249
2019-09-05 10:44:09 +01:00
tonihei
d9042a2985 Move effectively private method further down.
@VisibleForTesting sets the actual visiblity to private (except for tests),
so the method should be further down in code.

PiperOrigin-RevId: 266746628
2019-09-05 10:44:01 +01:00
olly
a02237de20 Fix imports
PiperOrigin-RevId: 266676413
2019-09-01 22:03:52 +01:00
olly
d720d2c3f6 Simplify androidTest manifests & fix links to use https
PiperOrigin-RevId: 266396506
2019-09-01 22:02:17 +01:00
christosts
967abdf0f5 Use DataSpec request params in DefaultHttpDataSource
DefaultHttpDataSource.open() also includes the request parameters that
are inside the DataSpec.

PiperOrigin-RevId: 266350573
2019-08-30 14:42:22 +01:00
aquilescanta
9508146840 Introduce LoadErrorHandling policy in DefaultDrmSession
This is a no-op interim change to introduce key request error
handling customization. Following changes will allow users to
inject their own LoadErrorHandlingPolicy implementations.

Issue:#6334
PiperOrigin-RevId: 266344399
2019-08-30 14:42:22 +01:00
kimvde
48555550d7 Surface MediaCodecInfo methods added in Android Q
- Surface information provided by methods isHardwareAccelerated,
  isSoftwareOnly and isVendor added in Android Q in MediaCodecInfo
  class.
- Estimate this information based on the codec name for earlier API
  levels.

Issue:#5839
PiperOrigin-RevId: 266334850
2019-08-30 14:42:22 +01:00
olly
f5c1e8b5e3 Add HttpDataSource.getResponseCode to provide the status code associated with the most recent HTTP response.
PiperOrigin-RevId: 266218104
2019-08-30 14:42:21 +01:00
andrewlewis
1b3cb639b3 Signal when supplemental data is present for vp9
PiperOrigin-RevId: 266085854
2019-08-30 14:36:25 +01:00
olly
0a0ab8d5e7 Avoid infinite recursion if cache file modified underneath cache
This generalizes our "does file still exist" check to also check
that the file is the expected length. If it's not, we don't trust
it. This avoids infinite recursion in CacheDataSource if a cache
file is truncated underneath the cache.

Issue: #6165
PiperOrigin-RevId: 265707928
2019-08-30 14:36:06 +01:00
olly
aa6ead3d08 seenCacheError should be set for all errors
PiperOrigin-RevId: 265662686
2019-08-30 14:35:47 +01:00
tonihei
9ca5b0fc61 Add back deprecated getWindow to ForwardingTimeline.
Implementations of ForwardingTimeline may override any of the two variants of
this method. We need to ensure that the customized override is always called.

Add back the deprecated method and make it final to forward to the
non-deprecated method in all cases for ForwardingTimelines.

PiperOrigin-RevId: 265419830
2019-08-30 14:35:27 +01:00
christosts
ce37b7eea2 Add HTTP request parameters (headers) to DataSpec.
Adds HTTP request parameters in DataSpec. Keeps DataSpec behavior to be immutable as before.

PiperOrigin-RevId: 265087782
2019-08-30 14:35:07 +01:00
tonihei
d1084f2728 Do not compare bitrates of audio tracks with different languages.
The last selection criteria is the audio bitrate to prefer higher-quality
streams. We shouldn't apply this criterium though if the languages of the
tracks are different.

Issue:#6335
PiperOrigin-RevId: 265064756
2019-08-23 17:04:16 +01:00
andrewlewis
aae64151e0 Add @CallSuper annotations in SimpleDecoder
The implementation can't work properly unless these methods are called by
subclasses, so annotate them to require calling the super implementation when
overriding.

PiperOrigin-RevId: 265017433
2019-08-23 17:03:28 +01:00
tonihei
29af6899fe Move playback error into PlaybackInfo.
The error is closely related to the playback state IDLE and should be updated
in sync with the state to prevent unexpected event ordering and/or keeping the
error after re-preparation.

Issue:#5407
PiperOrigin-RevId: 265014630
2019-08-23 17:03:12 +01:00
olly
7883eabb38 Update comment to indicate correct int value of "FLAG_ALLOW_CACHE_FRAGMENTATION" in ExoPlayer2 upstream DataSpec
Currently the value of FLAG_ALLOW_CACHE_FRAGMENTATION is defined as "1 << 4" but commented as "8". Either the value of FLAG_ALLOW_CACHE_FRAGMENTATION should be "1 << 3", or the comment should be 16. Here I am modifying the comment since it does not affect any current behavior.

PiperOrigin-RevId: 265011839
2019-08-23 17:02:57 +01:00
andrewlewis
6748eeca6a Avoid potential ArrayStoreException with audio processors
The app is able to pass a more specialized array type, so the Arrays.copyOf call
produces an array into which it's not valid to store arbitrary AudioProcessors.

Create a new array and copy into it to avoid this problem.

PiperOrigin-RevId: 264779164
2019-08-23 17:02:41 +01:00
tonihei
6a1331f125 Gracefully handle chunkful preparation without chunks.
This situation happens if the first chunk to load is already behind the end
of the stream. In this case, the preparation never completes because
HlsSampleStreamWrapper gets stuck in a prepared=false and loadingFinished=true
state.

Gracefully handle this situation by attempting to load the last chunk if still
unprepared to ensure that track information is obtained as far as possible.
Otherwise, it wouldn't be possible to play anything even when seeking back.

Issue:#6314
PiperOrigin-RevId: 264599465
2019-08-23 17:02:10 +01:00
andrewlewis
f0aae7aee5 Support out-of-band HDR10+ metadata for VP9
Extract supplemental data from block additions in WebM/Matroska.

Allow storing supplemental data alongside samples in the SampleQueue and write
it as a separate field in DecoderInputBuffers.

Handle supplemental data in the VP9 extension by propagating it to the output
buffer.

Handle supplemental data for HDR10+ in MediaCodecVideoRenderer by passing it to
MediaCodec.setParameters, if supported by the component.

PiperOrigin-RevId: 264582805
2019-08-23 17:01:55 +01:00
tonihei
ebf8dc9973 Extend ExoPlayer builders with useLazyPreparations and AnalyticsCollector.
Both values are needed to set-up the ExoPlayer instances for playlists.

PiperOrigin-RevId: 264146052
2019-08-23 17:01:24 +01:00
ibaker
17d8e3728f Add support for the AOM scheme_id for ID3-in-EMSG
https://developer.apple.com/documentation/http_live_streaming/about_the_common_media_application_format_with_http_live_streaming

PiperOrigin-RevId: 264126140
2019-08-23 17:01:08 +01:00
tonihei
20fd4e16d2 Deprecate setTag parameter in Timeline.getWindow.
There is no point in having this parameter as the tag should always be a single
immutable object instantiated at the time the Timeline is created or earlier.

So there is no preformance benefit and it's error-prone in case people
forget to set setTag=true.

PiperOrigin-RevId: 264117041
2019-08-23 17:00:53 +01:00
tonihei
652c2f9c18 Advance playing period even if the next one isn't prepared yet.
This solves various issues around event association for buffering and
error throwing around period discontinuities.

The main changes are:
 - Logic around being "ready" at the end of a period no longer checks if the
   next period is prepared.
 - Advancing the playing period no longer checks if the next one is prepared.
 - Prepare errors are always thrown for the playing period.

This changes the semantics and assumptions about the "playing" period:
 1. The playing period can no longer assumed to be prepared.
 2. We no longer have a case where the queue is non-empty and the playing or
    reading periods are unassigned (=null).
Most other code changes ensure that these changed assumptions are handled.

Issue:#5407
PiperOrigin-RevId: 263776304
2019-08-23 17:00:37 +01:00
ibaker
14f77cb8b1 Unwrap SCTE-35 messages in emsg boxes
PiperOrigin-RevId: 263768428
2019-08-23 17:00:21 +01:00
ibaker
424f991079 Extend EventMessage.toString to include durationMs
This field is used in .equals(), so it makes sense to include it in toString() too.

PiperOrigin-RevId: 263768329
2019-08-23 17:00:06 +01:00
ibaker
01f484cbe9 Modify EventMessageDecoder to return null if decoding fails (currently throws exceptions)
This matches the documentation on MetadataDecoder.decode:
"@return The decoded metadata object, or null if the metadata could not be decoded."

PiperOrigin-RevId: 263767144
2019-08-23 16:59:50 +01:00
tonihei
89dd105034 Update window/period doc in Timeline.
Most users are likely to be only interested in the playlist items. So put the
Window definition first and explicitly mention that this is a playlist
item.

PiperOrigin-RevId: 263764515
2019-08-23 16:59:34 +01:00