114 Commits

Author SHA1 Message Date
andrewlewis
b9f9232b9d Release Extractors on the loading thread
Releasing the player released the internal playback thread once renderers were
released. Releasing a MediaPeriod queued a Loader.ReleaseTask on the loading
thread which would post back to the playback thread. If the playback thread had
been quit by the time this happened, the release task wouldn't be run.

Release on the loading thread instead of the playback thread. This avoids
needing to block releasing the player until the loading threads have ended, and
ensures that release tasks will run eventually. As part of this change,
ExtractorMediaPeriod's call to Extractor.release will now run on the loading
thread (which means that all Extractor methods are called on that thread) and
other cleanup in ReleaseCallback will run on the loading thread instead of the
playback thread.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185651320
2018-02-16 11:53:51 +00:00
eguven
73e3e16949 Fix SmoothStreaming manifest url for downloading
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185526653
2018-02-16 11:51:19 +00:00
eguven
2c2aaf0a4b Make SegmentDownloadAction constructor keys parameter simpler
Removed option to pass null keys parameter.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185134822
2018-02-16 11:42:21 +00:00
andrewlewis
e437248f4f Refer to E-AC3 JOC rather than Atmos in MIME type/comments
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184501752
2018-02-08 14:49:00 +00:00
eguven
b3da82dc1c Open source DownloadService, DownloadManager and related classes
Issue: #2643

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184844484
2018-02-08 14:47:54 +00:00
olly
1bf4926338 Stop using Map<Integer, X>
Lint recommends switching to SparseArray<X> instead.
This is done for the DASH case. For the Cast case it's
easier to use a switch statement.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184119312
2018-02-01 15:21:08 +00:00
eguven
1dde2adbf3 Add SegmentDownloader.getAllRepresentationKeys method
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183656655
2018-02-01 14:59:11 +00:00
aquilescanta
8ba3335145 Use long segment indices for DASH
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183389701
2018-02-01 14:34:41 +00:00
tonihei
e6d25a9cb6 Keep replaced manifest uri in DashMediaSource after release.
This is only allowed for user-replaced manifest uris. If the manifest
itself forwards to another manifest, we keep the original manifest in
case the forwarding changes.

Also removed the initialManifest as it can be simplified by using the
sideloadedManifest indicator.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183376209
2018-02-01 14:29:58 +00:00
aquilescanta
677fc291cf Use long for HLS media sequences
Issue:#3747

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183366339
2018-02-01 14:25:01 +00:00
tonihei
bc9dbdb49e Make DashMediaSource reusable.
GitHub:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183253017
2018-02-01 14:23:28 +00:00
eguven
8b79028880 Add filtering manifest parsers for DASH, HLS and SmoothStreaming
These parsers can be used to get a manifest which includes only the
representations identified by the given keys.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182932874
2018-01-23 19:36:41 +00:00
tonihei
e991a8015b Use Truth instead of framework asserts in all tests.
This achieves two things:
1. All our tests use the same type of assertions.
2. The tests currently run as instrumentation test can be moved to
   Robolectric without changing the assertions.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182910542
2018-01-23 19:29:12 +00:00
hoangtc
a06a670d63 Use same logic for DASH manifest reloading for all cases when manifest is invalid.
When a loaded DASH manifest is invalid (either some periods were removed
illegally, or a manifest for a live event is stale), we will retry using 1
logic:
- Retry loading with back-off up-to a limit.
- Throw a DashManifestExpiredException() if we exceed retry limit.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182770028
2018-01-23 19:23:11 +00:00
eguven
05e55f37eb Fix DashDownloaderTest.testDownloadManifestFailure
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182754993
2018-01-23 19:21:43 +00:00
eguven
b3d1635ac4 Fix CacheDataSource and SimpleCache issues
This fixes a very specific case where the data read has non-cached gaps
and a read-only CDS switches to read from upstream in a gap then the
cached data is deleted. When the CDS reaches the end of the gap, it
tries to open the next source. As there is no cached data, it tries to
continue with the already opened upstream data source but as it reached
end of the gap range, the code starts looping.

Also fixes infinite lock which occurs when in the previous case CDS isn't
readonly. It locks the content while filling the gap in the cache. At the
end of the gap, as the following data is deleted it tries to lock the
content for writing but the content is already locked by itself.

The last fix is preventing removal of CachedContent entry from
CachedContentIndex while associated key is locked.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182595426
2018-01-23 19:18:09 +00:00
olly
24f866e788 Fix DashMediaSource NPE
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182534505
2018-01-23 19:15:06 +00:00
olly
cf27bc84e6 DashMediaSource cleanup
- Get handling of "stale" and "out of sync" manifests so
  they're right next to each other (to be merged)
- Move startLoadingManifest to be next to the methods that
  schedule it, and actually start loading stuff.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182530683
2018-01-23 19:12:10 +00:00
olly
65597e0db8 DashMediaSource variable name cleanup
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182261649
2018-01-23 18:57:18 +00:00
hoangtc
6749623cd1 Handle DASH `emsg' events targeting player.
For live streaming, there are several types of DASH `emsg' events that directly
target the player. These events can signal whether the manifest is expired, or
the live streaming has ended, and should be handle directly within the player.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182034591
2018-01-23 18:42:49 +00:00
tonihei
cfed8791b0 Send downStreamFormatChanged notification for embedded streams.
This allows listeners to get notified of any change to the embedded tracks.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=181969023
2018-01-23 18:38:17 +00:00
olly
ff1bb2f702 Apply SeekParameters to DASH + SmoothStreaming playbacks
Issue: #2882

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=181314086
2018-01-15 11:34:48 +00:00
tonihei
4867748c50 Add assertions to check that media sources are not prepared twice.
This lets apps fail-fast when they try to reuse media source instances.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=180934445
2018-01-15 11:23:31 +00:00
olly
a1bac99f3b Fix loadDrmInitData given DASH manifest parser changes
DASH manifests can now contain non-null but incomplete
DRM init data. Hence using the manifest init data when
non-null is not always the correct thing to do. This
change merges the sample and manifest formats (which
correctly merges the DRM init data) and then uses the
result.

Issue: #3630

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=180787784
2018-01-04 15:56:44 +00:00
andrewlewis
682953c411 Fix typos
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=180778084
2018-01-04 15:54:01 +00:00
olly
7314e9bddc DRM fixes
- Parse multiple kids from default_KID. It's specified as a whitespace
  separated list of UUIDs rather than a single UUID.
- Opportunistically proceed with playback in cases where the manifest
  only defines a single SchemeData with the common PSSH UUID. In such
  cases the manifest isn't saying anything about which specific DRM
  schemes it supports.

Issue: #3630

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=180675056
2018-01-04 15:49:34 +00:00
olly
2e3667eeff Expose ability to get adjusted seek position from MediaPeriod
Issue: #2882

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178606133
2017-12-12 19:16:34 +00:00
andrewlewis
e419154b86 Make DashMediaSource.Builder a factory for DashMediaSources
This is in preparation for supporting non-extractor MediaSources for ads in
AdsMediaSource.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178377627
2017-12-12 19:08:25 +00:00
hoangtc
88dea59cd2 Add ability for media period to discard buffered media at the back of the queue
In some occasions, we may want to discard a part of the buffered media to
improve playback quality. This CL adds this functionality by allowing the
loading media period to re-evaluate its buffer periodically (every 2s) and discard
chunks as it needs.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177958910
2017-12-12 18:43:26 +00:00
olly
9c63d37791 Support timezone offsets in ISO8601 timestamps
Issue: #3524

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177808106
2017-12-04 17:39:43 +00:00
andrewlewis
fd938fb454 Update internal usages of deprecated AdaptiveMediaSourceEventListener
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177786580
2017-12-04 17:38:11 +00:00
andrewlewis
2282527821 Allow setting supported formats on AdsLoaders
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177175377
2017-12-04 17:38:11 +00:00
Pavel Stambrecht
28d709aa8f Iso8601Parser improved to be able to parse timestamp offsets from UTC 2017-12-04 15:52:12 +01:00
Pavel Stambrecht
ad16efdf56 Iso8601Parser improved to be able to parse timestamp offsets from UTC 2017-12-04 15:45:54 +01:00
hoangtc
e575af3ac3 Parse DASH manifest's publish time.
Parse DASH manifest's publishTime node as defined by ISO/IEC 23009-1:2014,
section 5.3.1.2.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176525922
2017-11-22 18:21:13 +00:00
hoangtc
e619079a0d Let EventMessage encloses its presentationTimeMs.
Currently EventMessage's presentationTimeMs is kept separately in
EventSampleStream. However, EventMessage's presentationTimeMs maybe used in
other places besides EventSampleStream, such as when handling `emsg' messages
targeting the player. This CL let EventMessage object to holds its
presentationTimeMs for such use cases.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176502938
2017-11-22 18:16:58 +00:00
olly
c06fe73b66 Bump target API level to 27
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176366693
2017-11-21 13:03:28 +00:00
hoangtc
0de57cbfae Allow more flexible loading strategy when loading multiple sub streams.
Currently for a DASH ChunkSource that consists of multiple sub-streams, we
always use a CompositeSequenceableLoader, which only allows the furthest behind
loader or any loader that are behind current playback position to continue
loading.
This changes allow clients to have more flexibility when deciding the loading
strategy:
- They can construct a different kind of composite SequenceableLoader from
the sub-loaders, and use it by injecting a different CompositeSequeableLoaderFactory accordingly.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176363870
2017-11-21 12:59:11 +00:00
andrewlewis
c4fe0e6482 Add support for Dolby Atmos
Issue: #2465

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176341309
2017-11-20 13:43:31 +00:00
tonihei
3f6b4d18a9 Move MockitoUtils to testutils and use it for all Mockito set-ups.
In particular this allows to have the workaround for
https://code.google.com/p/dexmaker/issues/detail?id=2 in one place only.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176340526
2017-11-20 13:40:28 +00:00
olly
82d0a27fd9 Fix some lint issues.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176337058
2017-11-20 13:39:03 +00:00
aquilescanta
a7c424a15c Add time unit and javadocs to fields in DashManifest
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176335667
2017-11-20 13:37:35 +00:00
aquilescanta
d856d0f056 Use consistent case for sideloaded
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176333544
2017-11-20 13:36:16 +00:00
olly
bd0bc03f64 Inject toKeyframe discard parameter from ExoPlayerImplInternal
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175805139
2017-11-17 18:45:51 +00:00
hoangtc
fee6cf5cd8 Continue adding Builder to MediaSource.
Add Builder pattern to SsMediaSource and mark existing constructors as
deprecated.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175659618
2017-11-17 18:29:50 +00:00
olly
afe6f667b2 Move all buffer discard to MediaPeriod.discardBuffer
This is a step toward retaining a back-buffer in a way that
works for all MediaSource implementations. It's not possible
to adjust the discardBuffer calls in ExoPlayerImplInternal
to discard up to (position - backBufferDurationUs). Next steps
are to:

1. Find an appropriate place to specify the back buffer value,
   to be passed to the discardBuffer calls. I guess the
   LoadControl is the appropriate place to define such values.
2. Enhance discardBuffer to support a toKeyframe argument to
   pass through to discardTo.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175565363
2017-11-13 20:07:25 +00:00
arnaudberry
db7e9a548c Make it possible to extend DashManifestParser to parse revision-id.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175554723
2017-11-13 20:04:40 +00:00
hoangtc
0be4b46bb4 Introduce Builder pattern to create MediaSource.
Start with DASH MediaSource. The number of injected arguments is getting
out-of-control.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175529031
2017-11-13 17:08:24 +00:00
hoangtc
735af5c0b0 Update several minor code/test style issues.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175180089
2017-11-13 15:15:07 +00:00
hoangtc
3171c86bdb Supports Out-of-band, in MPD EventStream.
MPD file may include multiple EventStreams in its Periods, which contains Events
that the application may need to handle/respond to.
This change adds support for parsing the EventStream/Event nodes from MPD
file, and exposing these EventStreams as a metadata sample stream that application
can respond in a similar way to other metadata events.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175017697
2017-11-13 15:08:09 +00:00