Commit Graph

78 Commits

Author SHA1 Message Date
Jacob Trimble 5637962073 Offline now doesn't use data URI for init data.
Also now uses the same ContentDatabaseReader for offline segment
requests.

Change-Id: I9cebc90b46ca9067467a8a343d48b264abc7cf26
2015-10-19 23:10:22 +00:00
Joey Parrish 3a552b808f Remove Uint8ArrayUtils.key
These keys cannot always be used as keys, for example on IE11 where
very large init datas are found in PlayReady content.  Since there
should not be a large number of unique init datas, a linear
suppression pass and a quadratic removeDuplicates should not be a
problem in practice.

Related to pull #176

Change-Id: I9dd9b5e45422544c86dd95686766625a0b336963
2015-10-14 18:09:07 +00:00
Jacob Trimble ee872017ed Added 'app' error type.
Change-Id: I1c56d875ec92291af408a10e01e7d2c8fae24749
2015-10-07 22:28:24 +00:00
Jacob Trimble f8d0028b1a Clock synchronizing no longer allows caching.
Closes #191

Change-Id: I66086ad247a0deec34756ae70ea4e3ddfc5fd264
2015-10-07 22:27:45 +00:00
Jacob Trimble 9b50f2ad94 Deleting offline content now deletes persistent session.
Closes #171

Change-Id: Ia0ff2c9892f53c2ceeddb2b589e2e2c886aea54a
2015-09-24 22:05:01 +00:00
Timothy Drews 1fac67cb29 Don't cache responses in FailoverUri.
Issue #184

Change-Id: If7137f96ac4994d593615ef6baecadb668218403
2015-09-23 16:42:35 -07:00
Joey Parrish 4cc4e96dbd Overhaul license comments and file annotations
* Updates all Copyright years to 2015.
* Adds licenses annotations to all JS.
* Makes all licenses identical to avoid repeated appearance in the
  compiled output.
* Drops fileoverview annotations, which do not affect docs output.
* The linter still requires fileoverview on externs.

This patch required a newer closure compiler, since the previous
version we used had a bug regarding license annotations that caused
the license comment block to appear in the output once per file
regardless of uniqueness.

Change-Id: I2e9272db680cba7ecc4613d97f1d3a94ac2244cc
2015-09-08 12:02:34 -07:00
Joey Parrish 4d9177240a Revert "Adding license annotation to js files."
This reverts commit 8cb24652cb, due to
the fact that the new annotations caused our binary size to jump
by 52%.

The compiler preserves all 'unique' licenses, which causes trouble
since the comment blocks with the license annotations are not unique
and contain file overview comments as well.

We can re-examine this once we have restructured the license headers.

Change-Id: I418e407a0e0253630633697f30cf496a7fc2ddfc
2015-09-04 18:36:39 -07:00
Yohann Connell 8cb24652cb Adding license annotation to js files.
Change-Id: Id10592ccaf35608ac4f01844cae2fec4a2030d65
2015-09-04 00:05:17 +00:00
Joey Parrish 12f2cb18d7 Fix storage of duplicate session IDs
If a session becomes "ready" more than once, there is a race where
it can wind up in the database multiple times.  This eliminates
duplicate session IDs on both load and store, which avoids an
"unexpected completion" error from Chrome's EME implementation.

Change-Id: I749364cb12787a9c72324b2ad95adaf8ce1a00af
2015-09-01 17:03:43 -07:00
Joey Parrish 97769bd413 Clean up exceptions on Player.destroy()
This introduces a new method on PublicPromise called destroy(),
which does for Promises what destroy() does for the other classes:
shuts down async processes and cleans up references.

In addition to catching errors and shutting down more cleanly in a
wider array of circumstances, this may also help with GC, since we
no longer leave pending Promises around with handlers attached to
them.

Closes #151

Change-Id: I205c5979418fbc18cd7e35d91d0de2746f337137
2015-09-01 00:16:05 +00:00
Timothy Drews 689c2a47aa Use 'keystatuseschange' events and support @group.
Use 'keystatuseschange' events from EME together with cenc:default_KID
from the MPD so StreamVideoSource can determine if the key system
can/will decrypt a stream before it attempts to play it. This enables
the Player to safely (and automatically) switch between streams that
are encrypted with different keys.

Support AdaptationSet @group, which is the preferred approach to safely
use multiple encryption keys over multiple Representations.

* Squash AdaptationSets from the same group into one StreamSetInfo.
  This enables support for @group without introducing special case code
  into StreamVideoSource and EmeManager.
* Fire 'trackchanged' events when tracks becomes available/unavailable
  either from application restrictions or key status changes.
* Pull key IDs out of DrmInfo and put them into StreamInfo so key status
  changes can drive per stream availability instead of per StreamSet
  (AdaptationSet) availability.

Closes #67
Issue #160

Change-Id: Ife0814deb65715923a572b45880137a99b378035
2015-08-31 23:13:17 +00:00
Timothy Drews 7ed4d11318 Fix SegmentReference parsing error message.
Change-Id: Idd802abcb5ad60e5817434b815a9f268a9731710
2015-08-31 18:00:20 +00:00
Joey Parrish e4d36265cb Fix off-by-one error storing offline content
The final chunk was only being stored when the endTime of the final
segment happened to be null.  An index with explicit end times for
all segments, even on one stream, would trigger this bug.

For example, the end time of the final video segment may be null, but
the end time of the final audio segment may be equal to the content
duration.  The stored audio would be missing a chunk, causing the
computed stream limit to be too short on playback.

This corrects the off-by-one error in the storage code by explicitly
signalling when a segment is the last one, rather than checking for
a null endTime.

Closes #157

Change-Id: Ic99d53b9e2b071409d4d9472b8bc4ae0cf76f940
2015-08-26 22:26:30 +00:00
Jacob Trimble 603fae9695 Added disable live build option.
A new build option --disable-live added to disable the ability to
play live content.

Issue #116

Change-Id: I35876f51bddc3689d60ff6dc1b736d74c8ed4f80
2015-08-25 14:29:51 -07:00
Timothy Drews 1c58dee0c2 Add new ContentProtection interpretation API.
Add new ContentProtection interpretation API that allows applications to
return multiple DRM configurations for each ContentProtection element
and to parse raw ContentProtection XML elements.

This patch deprecates DrmSchemeInfo in favor of DrmInfo. Furthermore,
DrmSchemeInfo will be removed post v1.5.0.

* Replace DrmSchemeInfo with DrmInfo.
* Move Restrictions class definition into its own file.
* Populate initData values from explicit PSSHs without application
  intervention.
* Allow explicit PSSHs to differ between Representations

Issue #71
Issue #137
Closes b/23428584

Change-Id: Ib8d6ba630b930ee64f923a3f4a3e518abacccf88
2015-08-24 10:41:41 -07:00
Jacob Trimble e74ad98eaa Added setNetworkCallback method to dash and offline video sources.
This allows the app to intercept media requests to modify its URLs.
The callback accepts the URL for the request and returns a modified
URL or null to use the original.

Closes #148

Change-Id: I08352754ace05f318706fd93910097c0fa7696f0
2015-08-24 09:35:27 -07:00
Timothy Drews c741b69df6 Fix typo in failover_uri.js
Change-Id: I6f48d3ed0f79974cac06f419f3c542b55d332101
2015-08-20 10:58:58 -07:00
Jacob Trimble 671611ef37 Added build options to disable unneeded features
build.sh now accepts several arguments that will  disable features
that will not be needed.  The default is to include all features.
Part of #116.

--disable-offline
--disable-dash
--disable-http

Change-Id: Icdaf82b322debbdc1e898e93c539e35894678a8d
2015-08-14 15:58:00 -07:00
Timothy Drews 97809a008a Rename RangeRequestTimeout opt. & fix unit convs.
* Rename the RangeRequestTimeout option to SegmentRequestTimeout
  since the RangeRequest class no longer exists.
* Fix a few unit conversion errors between seconds and
  milliseconds and vice versa.

Change-Id: I8695c3bfb79ae0e20ec5bc75d9ae9f941bccd023
2015-08-13 16:41:27 +00:00
Jacob Trimble 899c322995 Added support for multiple BaseURL elements.
Added a new class called FailoverUri which handles multiple URLs and
switches to others when one fails.  This is also handles the request
itself.  This replaces SegmentMetadata as well as a number of manual
requests.

The MPD parser now produces arrays of URIs rather than just one.  The
MPD Processor then converts it to a FailoverUri inside the manifest.

Added unit tests to test the new functionality and updated the old ones
to the new changes.

This does not support failover on subtitles since subtitles are handled
by the browser.

Closes #68

Change-Id: I5410104827b9e4102b243444b1b5a3f01dcaf10d
2015-08-10 16:01:06 -07:00
Timothy Drews 7623b58fea Fix ContentDatabase/AjaxRequest circular dep.
The circular dependency,
ContentDatabase -> RangeRequest -> AjaxRequest -> ContentDatabase,
causes issues for the upstream Closure compiler. This patch breaks that
cycle by factoring out reading and writing operations from ContentDatabase
into ContentDatabaseReader and ContentDatabaseWriter respectively.

The following minor changes have been made to code that has moved:
* Removed retrieveInitSegment() since it's not used.
* Changed .stream_ids to ['stream_ids'] in retriveGroup().
* Reworked deleteGroup() so that it doesn't depend on retrieveGroup().
* Made deleteStream() private.
* Made minor formatting changes to meet the 80 character limit.

Change-Id: Idfc5d04ad32225a915b1531e0f4205137de5cc73
2015-08-10 14:23:32 -07:00
Natalie Harris 3936bfafb6 Player configuration should not use static variables.
Closes #126.

Change-Id: Ib8ef19e46918276f28d6539a158517f8558867d1
2015-08-04 08:51:22 -07:00
Timothy Drews 8880a8e378 Add more options for license request processing.
* Add a URL override and an HTTP method override to LicenseRequestInfo.
* Use LicenseRequestInfo objects as dictionaries so the pre-processor
  interface works like the Player.configure() interface.
* Ensure LicenseRequestInfo fields are valid after the pre-processor
  is called.
* Improve pre-processor integration test.
* Add @expose to some typedefs so they are included in the documentation.

Closes #134
Closes #135

Change-Id: Ia29d36d70fa661d58196d166cbc60b281c679594
2015-07-27 21:22:05 +00:00
Timothy Drews c8cf08f477 Add map getter functions that check types.
These may be used to sanity check arguments coming from outside
the library.

* Use new getter functions in Player.configure().
* Add additional tests for Player.configure().

Change-Id: Ib0b907cde46aeb65ca1273fb424e3f13872fa5da
2015-07-22 16:06:41 +00:00
Timothy Drews 38f70c5aeb Recover from failed segment requests.
* Reject Task Promise if one of its stages fails so that the caller's
  catch handler is invoked.
* Use TypedBind consistently in affected Promise chains.

Closes #131

Change-Id: I94fa6688949444212fa0b1edd3a94e0de4d6956f
2015-07-21 20:05:15 +00:00
Joey Parrish 6669cfbc12 Remove Promise workarounds
Now that google/closure-compiler#715 is fixed and we have upgraded to
a newer compiler, we can remove these casts.

b/21559591

Change-Id: I7769d95d7b440c648eb78e026d94544c640c41b4
2015-07-14 03:31:11 +00:00
Joey Parrish 9af15bc166 Fix typo
Change-Id: I2db2c9efbced8791cfdf22b6d1b311b4172a622f
2015-07-14 03:29:55 +00:00
Joey Parrish 328aa27c59 Fix type-inference issues with newer compilers
Newer versions of the Closure Compiler issue warnings for several
anonymous functions due to what appears to be a failure to infer
certain types.  This patch uses TypedBind to mollify the compiler.

This patch also fixes another issue raised by the newer compiler,
which is that index does not have duration and key_system properties.

b/21559591

Change-Id: Icff84ad084bfcd049f962bd4a0698b3fc78fc279
2015-07-13 13:56:16 -07:00
Joey Parrish 2ca10eff3a Update catch extern
This updates the extern for Promise.prototype.catch to match the ES6
Promise externs in newer versions of the Closure Compiler.

b/21559591

Change-Id: I796d8293f7be3170e465eaf3f30ceb8c9c5698b6
2015-07-13 20:54:41 +00:00
Timothy Drews e8fdcc2eb3 Enable BandwidthEstimators to allow caching.
Adds an API to IBandwithEstimator to enable BandwithEstimator
implementations to allow/disallow caching.

Issue #76

Change-Id: I842994981a0821e22de412478f094850414b6289
2015-06-26 03:41:18 +00:00
Timothy Drews fbea2279b3 Re-work stream switching.
* Allow segments from different streams (Representations) to coexist
  in buffer.
* Only fetch a single segment at a time.
* Remove id field from SegmentReference and remove SegmentRange.
* Only start the Streams once the buffer is "full".
* Stop DashVideoSource from triggering an extra resync during startup.
* Make Task.abort call order deterministic.

A follow-up patch is required to handle certain seek patterns in
live streams.

Issue #51

Change-Id: Ib7c9021471f1ed89323f19764463202b119cb491
2015-06-18 12:54:25 -07:00
Joey Parrish 4114342cba Enhance FakeEvent assert output
This makes it easier to see which key is failing when debugging.

Change-Id: I236219d93c833d2de2a92a232414309e20f09b15
2015-06-13 18:50:37 +00:00
Joey Parrish 8efe577459 Fix offline percentage
This was broken by a bad reduce, in which the initial value of "sum"
was an object.

Change-Id: I3ce2d723e9274dd7c3c86340d321ef8e3d030792
2015-06-12 22:12:55 +00:00
Timothy Drews 22c57e99e4 Rework SegmentIndex functionality.
This patch reworks SegmentIndexes so that any SegmentReference they
contain is guaranteed to be available. This makes SegmentIndexes work
consistently between static content and live content (specifically
content specified using SegmentTemplate with @duration).

* Rework StreamInfo to use a ISegmentIndexSource and a ISegmentInitSource,
  which construct a SegmentIndex and an intiailization segment
  respectively.
* Make ManifestInfo destructible and various async operations in
  StreamVideoSource safer.
* Introduce LiveSegmentIndex, which manages SegmentReference eviction.
* Introduce DynamicLiveSegmentIndex, which manages SegmentReference
  eviction and generation.
* Implement improved segment availability logic for segment eviction.
* Move SegmentIndex construction from MpdProcessor to several
  ISegmentIndexSource implementations.
* Use a SegmentIndex to represent subtitles to simplify Stream creation
  in StreamVideoSource.
* Move manifest update code from StreamVideoSource to ManifestUpdater.
* Move PeriodInfo.duration determination in MpdProcessor to StreamVideoSource.
* Since "forced" manifest updates are no longer required for content
  specified using SegmentTemplate with @duration, simplify manifest update
  code in DashVideoSource.
* Make Stream continue to update even if it runs out of
  SegmentReferences, this simplifies previous resync logic and makes
  DynamicLiveSegmentIndex work seamlessly.
* Refactor SegmentIndex and initialization fetch code in ContentDatabase.
* Download all SegmentIndexes in the background after the initial streams
  have started.

Follow up work is required to remove seek range logic from
DashVideoSource.

Change-Id: I4a908195aba632a911a6e55213fc41d41428162b
2015-06-09 11:46:40 -07:00
Timothy Drews 6d08f0b97a Add a license pre-processor.
Allow applications to pre-process license requests; also makes
the license post-processor an optional parameter.

Closes #62

Change-Id: Idb57f101c3a5f08da85d37ec7e252ffca886a6ae
2015-06-09 15:58:14 +00:00
Joey Parrish 1e400f536f Avoid load-time uses of Uint8Array.
This is inteded to fix a couple of the load-time exceptions seen
when loading the library on IE9.  Eliminating load-time exceptions
will make it possible to use isBrowserSupported() as intended, to
avoid use of the library on older browsers.

Issue #87

Change-Id: I993d4f955e80a7401bea182ae90df43a8a022ca2
2015-06-02 16:31:27 -07:00
tdrews 202799a9db Merge pull request #79 from swilly22/ajax_timeout
Handle Ajax Request timeouts issue #78
2015-05-12 14:30:27 -07:00
swilly22 4a542cafdb Helper function which re-sends ajax request 2015-05-12 10:28:43 +03:00
swilly22 860adfac7c Handle Ajax Request timeouts issue #78 2015-05-11 17:22:17 +03:00
Natalie Harris 99e16661bf Make XHR timeout runtime-configurable.
Closes #50.

Change-Id: I812192cdcb3a272977f418c8853a052fa7f650fa
2015-05-05 10:36:59 -07:00
Natalie Harris 23e7a8e11f Progress events for Offline storage. Issue #22
Change-Id: Ic8c24241b8a55a42c4207084491e5a3e2a0d0a86
2015-04-24 16:45:24 +00:00
Joey Parrish d3a5daf2ad Refactor 404 handling for live streams.
* Remove the acceptableErrors system and replace with a status check
  in SBM on request failure.
* End an SBM fetch task early on 404 or 410, but only during start
  and switch.
* Retry segment fetch to recover from 404/410 errors sooner.
* Set retry delay based on segment duration.
* Remove the 'truncated' fetch mechanism and the 'pleasebuffer'
  mechanism.  (Retry is more robust than entering a buffering state.)
* Retry MPD requests as well.  (Some live streams seem to experience
  very transient 404 errors when requesting updates.)

Issue #21.

Change-Id: I2d3b838a9afe950e9ed0a91da9b952d8a30bf0a1
2015-04-15 10:24:49 -07:00
Joey Parrish bbf1f21a2d Correct calling of Task.end() cannot be enforced.
Since a task stage is asynchronous, some async part of it may need to
call end().  Because of this, we cannot realistically know if the
caller is part of the stage or not.

Change-Id: I2a31515b9a4c6dd1bf246079fb42effe7a2da622
2015-04-14 14:49:38 -07:00
Joey Parrish 4afdc4cc53 Correct throws annotations for Task.
Change-Id: I1a2f8ab5923ee6f93b0894ba584465d8e4cd5cca
2015-04-13 11:35:41 -07:00
Timothy Drews 8c0d93009c Enable injecting custom IBandwidthEstimator impls.
* Export FakeEventTarget so IBandwidthEstimator implementations
  can use it.
* Expose IBandwidthEstimator methods so they do not get renamed
  in compiled mode.

Change-Id: Ib4c58d2357afdf402482202dc9fb8cf42dbbfad1
2015-04-10 15:29:58 -07:00
Joey Parrish 51563c118f Use start time as reference ID.
Since SegmentTimeline streams may not have segment numbers, we should
not use segment numbers as reference IDs.  These IDs must be unique
for the buffering and streaming systems to function properly.

This also adds assertions to check that reference IDs are unique.

Issue #21.

Change-Id: Ia94a48c68149283f87d27c6595a4f5a6cca07a27
2015-04-09 10:10:38 -07:00
Joey Parrish 72046285df Correct FakeEventTarget exception handling.
If an event handler throws an exception, this should not affect the
caller of dispatchEvent.  This corrects FakeEventTarget's behavior to
more closely resemble EventTarget, and makes many of our asynchronous
processes more resilient to errors in application-level handlers.

Change-Id: I41202aa24650ebdba3310f20864568eea32b74ce
2015-04-09 17:09:35 +00:00
Timothy Drews d414d4eaa7 Fix load stream in compiled mode.
* Move retrieveGroupIds to OfflineVideoSource.
* Quote properties of stored objects to avoid variable
  renaming issues.

Issue #22

Change-Id: I31ca1261411de5ff5ae4859da571d0029ed77f42
2015-04-09 16:16:40 +00:00
Natalie Harris a0aa5e51c6 Retrieve list of currently stored group ids. Issue #22
Change-Id: Ifeaa4085ec289679ccd9cb1fc22bd400c9cd8198
2015-04-07 15:32:36 +00:00