613 Commits

Author SHA1 Message Date
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
Steve Mayhew
6ef5dc08b7 Remove unused methods, comment cleanup. 2019-12-04 11:16:42 -08:00
Steve Mayhew
a8755b5c25 Update to save all sample queue write indexes
Finailzed logic to update the `SampleQueue` write positions (first index) to push these into `HlsMediaChunk` when the track is initially created (from the Extractor output) and as each new chunk is queued to load (`init()` callback).

Add lots of debuging prints that can come out for the final merge.

Code is very close to a clone of `ChunkSampleStream`.
2019-12-04 11:16:42 -08:00
Steve Mayhew
57d5160161 add support SequenceableLoader.reevaluateBuffer() for HLS
DASH implements this feature, extend the feature for HLS as well.  First change just drops video samples.
For demuxed audio the audio samples will continue to play out to match the
dropped video, so need to keep indexes in all the sample queues related to a chunk and discard them all.
2019-12-04 10:58:13 -08:00
olly
14cfb8039f Use peak rather than average bitrate for HLS
This is a minor change ahead of merging a full variant of
https://github.com/google/ExoPlayer/pull/6706, to make
re-buffers less likely.

Also remove variable substitution when parsing
AVERAGE-BANDWIDTH (it's not required for integer attributes)

PiperOrigin-RevId: 283554106
2019-12-04 10:00:17 +00:00
tonihei
65c4a58825 Use Util method to create Handler instead of using deprecated method.
Calls to new Handler() without arguments are deprecated as of the latest Android
version. Replace them by a Util.createHandler call similar to the ones we
already have.

PiperOrigin-RevId: 283532891
2019-12-04 09:59:44 +00:00
ibaker
79b7af656b Rollback of <unknown commit>
*** Original commit ***

Disable test coverage again

https://issuetracker.google.com/issues/37019591 causes local variables can't be found while debugging.

***

PiperOrigin-RevId: 280666758
2019-11-17 00:33:26 +00:00
andrewlewis
fbea71b0fe Fix detection of Dolby Atmos in HLS
E-AC3 with JOC is signaled using the CHANNELS attribute for HLS:
https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices/hls_authoring_specification_for_apple_devices_appendices

PiperOrigin-RevId: 277680300
2019-11-05 16:13:41 +00:00
tonihei
0c63362258 Add @Documented and JavaDoc to HlsMetadataType.
PiperOrigin-RevId: 277519718
2019-11-05 16:13:02 +00:00
ibaker
817772fcbd Add uncontroversial HLS nullness annotations
This helps get HlsMediaPeriod off the blacklist.

PiperOrigin-RevId: 277076633
2019-10-30 08:51:20 +00:00
ibaker
87c30c0ba8 Change HlsPlaylistParser.LineIterator#next()
Update it to throw if hasNext() is false, to match Java's Iterator
interface.

This also simplifies the null-checking annotations required

PiperOrigin-RevId: 277059766
2019-10-30 08:51:12 +00:00
aquilescanta
b68a698806 Make SampleQueue populate FormatHolder.drmSession
Also add unit tests for SampleQueue read for samples with
DRM requirements.

PiperOrigin-RevId: 277037826
2019-10-30 08:50:34 +00:00
ibaker
ac722a7a68 Remove HlsPlaylistParser from null-checking blacklist
PiperOrigin-RevId: 276671167
2019-10-30 08:49:55 +00:00
ibaker
3e6fe45885 Add test for FullSegmentEncryptionKeyCache
Pull it into a top-level package private class at the same time

As suggested in 0ba91811d1

PiperOrigin-RevId: 275870515
2019-10-30 08:47:44 +00:00
ibaker
3101a5df58 Tweak null-handling of trackGroupToSampleQueueIndex in HlsSampleStreamWrapper
PiperOrigin-RevId: 275814023
2019-10-30 08:46:58 +00:00
ibaker
e43658af1f Switch back from method ref to Runnable in HlsSampleStreamWrapper
This reverts a81dea6a47 and adds in the necessary nullness annotations

After a discussion that this:: method references allocate on every call:
https://dzone.com/articles/passing-thismethod-reference-within-a-loop-affects

PiperOrigin-RevId: 275813989
2019-10-30 08:46:50 +00:00
ibaker
b7f335c715 Remove HlsSampleStreamWrapper from the null checking blacklist
PiperOrigin-RevId: 275440589
2019-10-18 17:43:13 +01:00
ibaker
1317851535 Remove HLS WebVttExtractor from null-checking blacklist
The null-checker wasn't clever enough to understand the while-loop was safe
so I switched it to a for.

PiperOrigin-RevId: 275440464
2019-10-18 17:43:06 +01:00
tonihei
16a6946f3e Replace @MonotonicNonNull with @Nullable for final variables.
@MonotonicNonNull is not useful if the variable is final, because it's only
assigned once and guaranteed to keep it's current nullability in the same
way as @MonotonicNonNull ensures it's kept non-null after checking.

This way, the workarounds can also be removed.

PiperOrigin-RevId: 275428656
2019-10-18 17:42:43 +01:00
ibaker
9ec2d2fb36 Remove HlsMediaSource from null-checking blacklist
PiperOrigin-RevId: 275233915
2019-10-18 17:41:54 +01:00
ibaker
0d5b3c0fa4 Remove HlsMasterPlaylist from null-checking blacklist
PiperOrigin-RevId: 275052534
2019-10-17 11:52:34 +01:00
ibaker
e63d3b4b61 Add HlsSampleStreamWrapper#assertPreparationComplete
This gives a clear way to ensure all the preparation-related @MonotonicNonNull
fields have been set to something.

PiperOrigin-RevId: 274988280
2019-10-16 14:02:03 +01:00
ibaker
fc95d07a94 Remove HlsChunkSource from null-checking blacklist
PiperOrigin-RevId: 274789337
2019-10-15 23:08:00 +01:00