432 Commits

Author SHA1 Message Date
kimvde
703fb777c4 Optimize extractors sniffing order
Issue: #6410
PiperOrigin-RevId: 305436352
2020-04-08 21:47:58 +01:00
ibaker
8df6a4b301 Remove nullness warning suppressions from Matcher.group
These were introduced in c7164a30a0

In each case I checked that the groups are not optional,
so if they match they must be non-null.

PiperOrigin-RevId: 305213293
2020-04-07 13:39:13 +01:00
Oliver Woodman
2b44ff3c71 Merge pull request #7184 from TiVo:p-subtitle-format-from-codecs
PiperOrigin-RevId: 305137114
2020-04-07 13:38:53 +01:00
Oliver Woodman
8991586c3b Merge pull request #7034 from TiVo:p-exception-unreported-discontinuity
PiperOrigin-RevId: 305006564
2020-04-06 13:28:40 +01:00
Steve Mayhew
fbd97ad8de Fix merge mistake, wrong track type.
Fix mistake from the backport merge, should get TEXT track type for subtitles.  Also update testcase to match pattern in `dev-v2` branch.
2020-04-05 13:23:03 -07:00
Steve Mayhew
4ad4a826ab Cleanup to use getCodecsOfType()
Use the `Util.getCodecsOfType()` method rather than hard coded codec strings
2020-04-05 13:07:50 -07:00
Steve Mayhew
232820d3e1 Add HLS support for "stpp.*" codec support for SMPTE-TT fmp4 subtitle tracks
ExoPlayer needs a codec to decide among WEBVTT and TTML decoder mimeType.
Apple describes IMSC1 in MP4 in
[RFC-8216 Section 3.6](https://tools.ietf.org/html/draft-pantos-hls-rfc8216bis-04#section-3.6).

The DASH manifest specifies the SMPTE-TT captions in the codecs in the manifest
(from W3C [TTML Profiles for Internet Media Subtitles and Captions 1.1](https://www.w3.org/TR/ttml-imsc1.1/#general-0).
DASH just doesn't require the rendition linking, but HLS does.

Apple implies the CODECS attribute of the variant needs to be do this.  That is
with SHOULD and MAY language to imply the codec to use for it in the
[Authoring Guidelines](https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices)

This change defaults to WebVTT if no codec is specifed (same as current behavior) otherwise it picks it from the variants
referencing the media.
2020-04-03 19:41:23 -07:00
olly
6570d12c3c Remove re-entrancy from HlsMediaChunk initialization
HlsSampleStreamWrapper currently calls HlsMediaChunk.init, which calls back
to HlsSampleStraemWrapper.init. This re-entrancy seems a bit confusing.

PiperOrigin-RevId: 304139462
2020-04-01 22:38:10 +01:00
aquilescanta
41853169a7 Remove loadTaskId to Loader.Callback
Partial rollback of ca799716b8. We'll have to plumb
the id manually, like the rest of the LoadEventInfo
members.

PiperOrigin-RevId: 304067761
2020-04-01 22:37:43 +01:00
Steve Mayhew
48592071a3 Move back to UnexpectedDiscontinuityException extending a RuntimeException
This avoids massive changes to method signatures to add throws.  Also, took suggestion to make it an `IllegalStateException`.

Move the catch outside of the finally that sets `nextLoadPosition` (this allows for possible recovery by reseting the `Extractor` and `TimestampAdjuster`).

Lastly, took the suggestion to make a minimum value for the tolerance (especially usefull for very short i-Frame only segments).
2020-03-30 14:40:02 -07:00
ibaker
c7164a30a0 Suppress go/nullness warnings caused by Matcher#group(String) and Matcher#group(int)
This is required to align google3's stub (currently marked non-null) with Checker Framework's.

More information: go/matcher-nullness-lsc

Tested:
    TAP train for global presubmit queue
    http://test/OCL:303344687:BASE:303326748:1585344475427:29edc250
PiperOrigin-RevId: 303709053
2020-03-30 17:17:00 +01:00
aquilescanta
ca799716b8 Add loadTaskId to Loader.Callback
PiperOrigin-RevId: 303447837
2020-03-30 17:16:41 +01:00
bachinger
25d9f76a07 deprecate createMediaSource with uri argument
PiperOrigin-RevId: 303217607
2020-03-27 23:31:37 +00:00
Oliver Woodman
c251eac545 Merge pull request #7098 from matamegger:feature/webvtt_negative_media_timestamp
PiperOrigin-RevId: 301996778
2020-03-20 12:49:00 +00:00
aquilescanta
aa9eb5abc9 Remove generics from DRM components
PiperOrigin-RevId: 301798563
2020-03-20 12:48:50 +00:00
olly
920117b081 Drop prefix test- from test methods under v2/library
This CL removes the prefixes to the tests added after a6d0caaa3c.

This CL is generated by following command
$ find -name '*Test.java' | xargs -I{} sed -i 's/^\ \ public\ void\ test\([A-Z]\)\(.*\)$/  public void \L\1\E\2/' {}

PiperOrigin-RevId: 300547504
2020-03-19 00:46:48 +00:00
Matthias Tamegger
2f2fc8ca01 Update media timestamp regex to allow negative values 2020-03-17 11:28:58 +01:00
Steve Mayhew
ccf2ba3e1b Move HlsSampleQueue to be static inner-class
Backout making the original `FormatAdjustingSampleQueue` an outer class and combining the new timestamp checking logic.  This way the diff from `HlsSampleStreamWrapper` to dev-v2 are easier to see.
2020-03-16 13:51:22 -07:00
Steve Mayhew
e690979d92 Update with first round of code review suggestions
Update with code review suggestions:
1. rename to HlsCheckedSampleQueue to HlsSampleQueue and combine with format adjusting class.
2. Copywrite in added classes
3. Capture additional items useful for recovery and reporting in the exception class
4. Remove extraneous logging
5. eliminate magic number (50 seconds) and use percentage of duration

WIP:
 - eliminate null check for chunk (chunkless prepare starts load before sampleQueue are created)
 - work out recovery strategy
2020-03-13 09:59:27 -07:00
Steve Mayhew
f78cbd2c9e Add HlsCheckedSampleQueue to check timstamp range
Add a SampleQueue subclass that checks the timestamp range of media samples queued to it and reports an exception on load if the timestamp is outside of spec bounds.
(Smashed to a single commit prior to rebase)
2020-03-12 14:34:41 -07:00
bachinger
a5f0eb1e10 replace extension with mime type
This change uses mime types in a functionally equivalent way to how we used the extension hint so far.

Using a mimeType instead of the extension has some advantages. Most importantly mimeTypes are used by the cast SDK with which we want to achieve interoperability in the cast extension.

Using a mimeType instead of the extension hint further appears to be a bit more clear (which might be opinionated). Further mime types are a well known and widely used concept to identify file type on the internet and it provides asterix based generalizations (audio/*, */*) which could express the media type OTHER that ExoPlayer is using internally (no usage of asterix required so far though).

PiperOrigin-RevId: 300058945
2020-03-11 16:26:23 +00:00
bachinger
87405cb1c0 remove DefaultMediaSourceFactory.Delegate
PiperOrigin-RevId: 299943596
2020-03-10 10:21:37 +00:00
ibaker
eeab811301 Add EventDispatcher to DrmSession(Manager) acquire & release calls
This is passed in but not currently used. I'll use it in follow-up
changes.

Pre-work for issue:#6765

PiperOrigin-RevId: 299314341
2020-03-10 10:20:01 +00:00
aquilescanta
47b62e8c02 DataReader: replace InterruptedException with InterruptedIOException
PiperOrigin-RevId: 299092243
2020-03-10 10:19:45 +00:00
bachinger
4517829610 add DefaultMediaSourceFactory and use it in PlayerActivity
PiperOrigin-RevId: 298879027
2020-03-10 10:19:27 +00:00
tonihei
b5976a55ff Upgrade Kotlin annotations and fix gradle warnings
The new version fixes some warnings in Gradle builds. Also
add missing indirect compileOnly dependencies to fix some more warnings

Issue:issue:#7007
PiperOrigin-RevId: 298855510
2020-03-10 10:19:19 +00:00
bachinger
d1bbd3507a add media item to create media sources
This change adds the createMediaSource(MediaItem mediaItem) method to the MediaSourceFactory interface. It doesn't deprecate createMediaSource(Uri uri) to keep the cl smaller. Deprecation and removing calls to the deprecated method from within the library and extension follow in a separate CL.

PiperOrigin-RevId: 298352442
2020-03-10 10:17:03 +00:00
olly
a6d0caaa3c Drop prefix test- from test methods under v2/library
This is one step toward following the google3's test naming convention.
See go/java-testing/getting_started#basic-test-template for details
why prefix test isn't necessary.

This CL is generated by following command
$ find -name '*Test.java' | xargs -I{} sed -i 's/^\ \ public\ void\ test\([A-Z]\)\(.*\)$/  public void \L\1\E\2/' {}

and then manually modified following tests where test method names conflict with test target.
- VorbisUtilTest
- VorbisReaderTest
- UtilTest
- DownloadManagerDashTest
- DefaultOggSeekerTest
- OggPageHeaderTest
- HlsMasterPlaylistParserTest

PiperOrigin-RevId: 298074653
2020-03-10 10:15:43 +00:00
aquilescanta
a114a0ed7f Rename SampleDataReader to DataReader and move to common
PiperOrigin-RevId: 297603312
2020-02-27 17:16:53 +00:00
olly
c6a6e0d6f3 Migrate various call sites to Format.Builder
PiperOrigin-RevId: 297562889
2020-02-27 17:15:34 +00:00
olly
6fc5e6b905 Migrate HLS to Format.Builder
Issue: #2863
PiperOrigin-RevId: 296482726
2020-02-25 21:23:53 +00:00
olly
42d4afe7b6 Make Format.Builder, peakBitrate and averageBitrate public
- Deprecate old Format.createXXX methods
- Deprecate most Format.copyXXX methods
- Stop using deprecated Format.copyXXX methods in the library

Note: Replacing library usages of Format.createXXX method
will be done in follow up CLs. These changes aren't purely
mechanical because we need to decide which out of peakBitrate
and averageBitrate to set in each case where currently a
single bitrate is provided.

Issue: #2863
PiperOrigin-RevId: 296450935
2020-02-25 21:23:21 +00:00
aquilescanta
5c3c803460 Remove DRM management from Renderers
PiperOrigin-RevId: 295569075
2020-02-17 17:40:30 +00:00
olly
e606893ff8 Create a SampleDataReader interface for TrackOutput.sampleData().
Modify TrackOutput.sampleData() to accept SampleDataReader instead of ExtractorInput. SampleDataReader supports only read and skip calls, which all sampleData() implementations already restrict themselves to.

PiperOrigin-RevId: 294905155
2020-02-13 15:46:13 +00:00
olly
06f4983ffb Split bitrate into average and peak in VariantInfo
Issue: #2863
PiperOrigin-RevId: 294661214
2020-02-13 15:45:04 +00:00
olly
1cbe3f72e6 DataSpec: Deprecate most constructors
Keeping (Uri) and (Uri, position, length) to avoid needing
Builder for the trivial case.

PiperOrigin-RevId: 294530226
2020-02-13 15:43:54 +00:00
olly
829282fa12 Replace DataSpec.absoluteStreamPosition with uriPositionOffset
This is a preliminary step toward adding a DataSpec.Builder,
which is needed for sanity when adding DataSpec.customData.

The existing absoluteStreamPosition field is very error prone,
because anyone using a Builder to adjust the request position
will need to remember to adjust two values:

dataSpec
    .buildUpon()
    .setAbsoluteStreamPosition(x)
    .setPosition(x)
    .build();

Furthermore, the difference between position and
absoluteStreamPosition is irrelevant in nearly all cases. In
the core library, the difference is only relevant when initializing
AES encryption/decryption to write/read cache files.

Replacing absoluteStreamPosition with uriPositionOffset will
simplify the code block above to:

dataSpec
    .buildUpon()
    .setPosition(x)
    .build();

PiperOrigin-RevId: 294485644
2020-02-11 22:10:17 +00:00
olly
cfda4a5870 Add some nullness annotations to SampleQueue
PiperOrigin-RevId: 292921158
2020-02-11 17:07:18 +00:00
olly
3a702cf53a Change Format.createTextSampleFormat for common uses cases
PiperOrigin-RevId: 292863614
2020-02-03 11:20:56 +00:00
olly
a7c6cb4abb Add some missing local @Nullable annotations
PiperOrigin-RevId: 292564056
2020-02-03 11:20:31 +00:00
olly
d287e13d9e Add Format.createSampleFormat for common use case
PiperOrigin-RevId: 292562678
2020-01-31 17:52:51 +00:00
olly
ff822ff9fd HLS: Fix key rotation
Passing EXT-X-KEY DrmInitData through the FragmentedMp4Extractor
doesn't work for streams with key rotation, because an extractor
instance is used for multiple segments, but is only passed the
EXT-X-KEY DrmInitData corresponding to the first segment.

This change removes passing DrmInitData through the extractor,
and instead passes it via FormatAdjustingSampleQueue. This is
in-line with how manifest DrmInitData is handled during DASH
playbacks.

Issue: #6903
PiperOrigin-RevId: 292323429
2020-01-30 19:30:58 +00:00
olly
d75aa97c0c SampleQueue: Let subclasses easily invalidate format adjustment
This is a nice-regardless improvement to SampleQueue, which will
likely to used to fix the referenced issue. It makes it possible
for SampleQueue subclasses to support dynamic changes to format
adjustment in a non-hacky way.

Issue: #6903
PiperOrigin-RevId: 292314720
2020-01-30 19:30:38 +00:00
bachinger
c5e1169666 make media source factories reusable
First cl towards DefaultMediaSourceFactory (<unknown commit>) does not change the MediaSourceFactory interface except adding @Nullable anotations to setters.

PiperOrigin-RevId: 290269640
2020-01-17 16:12:41 +00:00
olly
775a17c498 Split SampleQueue.advanceTo for advance & seek use cases
This method has two use cases:

1. Seeking. Calls are immediately preceded by a call to rewind(), and
   the returned value isn't important unless it's ADVANCED_FAILED (i.e.
   the caller is only interested in success and failure).
2. Advancing. The return value is important unless it's ADVANCED_FAILED,
   in which case the caller wants to treat it as 0.

This change creates separate methods for each use case. The new seekTo
methods automatically rewind and return a boolean. The updated advanceTo
method returns 0 directly in cases where ADVANCED_FAILED was returned.
Arguments that were always hard-coded to true by callers have also been
removed.

This change is a step toward one possible solution for #6155. How we'll
solve that issue is still up for discussion, but this change seems like
one we should make regardless!

Issue: #6155
PiperOrigin-RevId: 290053743
2020-01-16 20:35:04 +00:00
olly
a225e887fa Move @MonotonicNonNull annotations to their correct positions
PiperOrigin-RevId: 289823804
2020-01-16 13:51:09 +00:00
aquilescanta
7f7632a38f Split HlsSampleStreamWrapper.init into two methods
As a result, onMediaChunkLoadStarted gets invoked on the loading thread, and
init on the playback thread, matching the thread access comments.

Issue:#6321
PiperOrigin-RevId: 289167981
2020-01-13 19:57:19 +00:00
ibaker
ed1de000e5 Unwrap all nested IntDef values
This seems to work with R8 but interact badly with ProGuard.

issue:#6771
PiperOrigin-RevId: 286215262
2019-12-18 18:54:44 +00:00
tonihei
021291b38f Add server-client time offset to Window.
This offset allows to improve the calculated live offset because it
can take known client-server time offsets into account.

PiperOrigin-RevId: 285970738
2019-12-18 18:52:11 +00:00
aquilescanta
61c43c30ac Make DownloadHelper pass DrmSessionManager to MediaSources
PiperOrigin-RevId: 283795201
2019-12-05 10:20:32 +00:00