Commit Graph

147 Commits

Author SHA1 Message Date
Sandra Lokshina 2e86da6995 Add TTML XML parser plugin
This adds support for TTML in XML form only.  TTML embedded in MP4 will
be added later.

Issue #111

Change-Id: Ic44cbcc57c6105c398778e676565f2511bfd8a73
2016-06-28 16:48:21 +00:00
Andy Hochhaus 87a62d717e Add missing goog.require() dependencies 2016-06-25 15:45:15 -07:00
Jacob Trimble 6cc9613803 Add support for storing protected content offline.
Now the Storage class can store protected content and play it back.
When deleting it, the offline EME sessions will be removed.  Also
now offline support appears in Player.support().

Closes #343

Change-Id: Ic5b5a0e0854d80f7821e04e751275abf40ee6eb6
2016-06-16 18:30:25 +00:00
Jacob Trimble 387ed49e92 Add offline storage manager and manifest parser.
This contains two major parts: the Storage class, which manages
storing, listing, and deleting the stored content, and the offline
manifest parser, which loads the stored content into a manifest so the
Player can play it.

This does not include support for storing encrypted content.  The
EME sessions will not be stored properly and will fail to play.

Issue #343

Change-Id: I7ecb3400391ec8100155aa972f9b09bb7ae24d9d
2016-06-09 23:10:46 +00:00
Joey Parrish 4234dd758e CancelableChain - cancel simple Promise chains
This adds a new abstraction to cancel simple Promise chains.
It is intended to help resolve load/unload/destroy issues.  At this
time, only player.load() is cancelable, and only by destroy(),
unload(), or other calls to load().

Change-Id: Ib82dbef863cb2edc6881a8d433d5a02096e06aed
2016-06-07 00:44:26 +00:00
Jacob Trimble 0530362b97 Add separate error for missing key system URI.
Before, the same error was used for no available configurations or
key systems and for missing key system URI.  Now there are two
different errors.  Also elaborated on the error in the documentation.

Closes #371

Change-Id: I9b72daa0a99b4761714a74c3ceba60c873c89a77
2016-06-03 00:11:41 +00:00
Joey Parrish 0acc6deb5b Filter based on both mime type and codec
Some streams have the same mime type, but incompatible codecs.  For
example, mp4a.40.2 and ec-3.  Once a stream has been selected, filter
out incompatible codecs.

Closes #391

Change-Id: Id3f5521cb3f995d88d93255c0bc5cfda8e239fcd
2016-06-01 11:32:51 -07:00
Timothy Drews fe9189e413 Allow Representations without Segment* elements.
Representations without Segment* elements or which do not
specify "text" as their type are now ignored instead of causing
failure.

Issue #368

Change-Id: Ica6490442dc38c7fdbc778eb0650dd7909d764c5
2016-05-25 00:18:01 +00:00
Jacob Trimble c7c2b41ac9 Add DBEngine to manage IndexedDB connections.
This is part of the v2 equivalent of the ContentDatabase.  This only
manages low-level interactions with the IndexedDB and wraps all
actions in Promises.

This also adds an in-memory version that is used for testing.

Issue #343

Change-Id: I0d296639e74c1d4cab232ce7248b03a353b38b3c
2016-05-20 11:22:50 -07:00
Jacob Trimble 8251fbaa19 Player.configure will ignore function argument count.
Before, Player.configure would check the number of arguments for
the functions being set and reject those with an incorrect count.
However, this does not work with jasmine spies.  So instead allow
it but log a warning.

Change-Id: I0f03ae9a22bf6a6e427c2a26a6f055dcaa40b3ec
2016-05-17 15:28:22 -07:00
Jacob Trimble d7824550d2 Drm support testing can be used to detect offline support.
Change-Id: I4a9ce4302583e84e2ff9613f790a63bdc5b57e3c
2016-05-17 20:06:19 +00:00
Timothy Drews be09f52f03 Fix "parser" property & improve load/unload.
* Set this.parser_ to the correct property in load()
  (stops old manifests from being fetched).
* Stop load() from unloading first when the Player is a new instance.
* Handle multiple repeated calls to load().
* Fully cleanup after partial loads.
* Add additional destruction checks.

Issue #369

Change-Id: I43d5ed90c8119b1040b87a0dc187f52738e1c683
2016-05-15 06:17:50 +00:00
Timothy Drews ddbc13d4f8 Handle QuotaExceededError from appendBuffer().
MediaSource may throw QuotaExceededError if it cannot append a
segment. Now, StreamingEngine will catch these errors from
MediaSourceEngine and reduce the buffering goals to avoid
encountering additional errors.

Closes #258

Change-Id: I1d957831424a4a6fb2681ee2c4f9ed7db7bf1711
2016-05-12 18:12:17 +00:00
Timothy Drews b83a9c0a27 Handle output-restricted key status.
If a key is output-restricted it may still be usable.
So, instead of disabling these tracks, indicate that they
may be playable.

Issue #199

Change-Id: Ic13a02d97ccc21533118f17aa907c16d1cda05ce
2016-05-09 15:10:31 -07:00
Jacob Trimble acfb7c6d41 Moved code out of Player into utility files.
This moves a bunch of code out of Player into different files.  This
is needed to allow the new Storage class to have the same behavior
as Player.  This also reduces the size of player.js.

This moves the following code:
* Determining the manifest parser to use.
* Period filtering.
* Application track restrictions.
* Configuration object merging.
* Choosing initial stream sets.
* Track creation.

Change-Id: I84d68d39b487447d6f8d61a145cd034a88165739
2016-05-04 17:18:15 +00:00
Jacob Trimble 77a987e8e0 Fix Player deferred switches WRT clear buffer.
Now when using deferred switches in Player, it will track whether
to clear the buffer.  This is needed because during startup,
StreamingEngine will append the first media segment; the old code
assumes that the buffer is empty.  This is especially important for
text tracks which may only be one segment.

Change-Id: I03d97e2a674c8e713145dbc619b15d7c9402fb7f
2016-04-25 20:28:36 +00:00
Jacob Trimble 7c1e7eaa56 Fixed stack overflow with StringUtils.
Because we were using Function.apply to create strings, large arrays
were causing problems with browser argument count limits.  This
now splits the arrays up before calling.

Closes #335

Change-Id: Ic94a950997e2f17563ecba8fb628f62c0ed18fc2
2016-04-19 23:13:28 +00:00
Jacob Trimble e1d834f3c2 Add track restrictions to Player.
Now the application can restrict the kinds of tracks that the Player
will play.  This is done through player.configure().  This also
allows restricting the playable tracks based on the EME key status.

Closes #326
Closes #327

Change-Id: I88210ece6fd1db886c49d4599fbe5814d394132d
2016-04-15 12:21:24 -07:00
Timothy Drews d2a812cd98 Do not use drift when looking up segments.
* Instead of using drift when looking up segment positions,
  just fetch the segment before the one needed.
* Handle missing segments by polling instead of failing right away.

Closes #330

Change-Id: Ia7bb74d0120ee3ee965e351f87fc5f170ad585bd
2016-04-15 18:40:38 +00:00
Jacob Trimble 6ec2771aad Emit an error if the wrong keys are retrieved.
Now there will be an error if the wrong keys are retrieved from the
license server.  This can happen if the manifest is incorrect or if
the license server returns the wrong keys.

Closes #301

Change-Id: Id141cb74d02513f8e83205fd5d3242c887468d4e
2016-04-13 19:24:50 +00:00
Joey Parrish cb64d7646d Add response text to HTTP errors
Requested in #319

Change-Id: I2f52519d7a45769a0d2db3c038c9c04cf7fb59c1
2016-04-12 21:59:03 +00:00
Joey Parrish 32e351d060 Add @namespace annotations to static classes
Without @namespace annotations, static classes do not show up in the
generated API docs.  Although I stumbled over one instance while
writing tutorials, the rest were discovered programmatically by:

for x in $(find lib/ -name '*.js'); do
  grep -Eq '@(constructor|interface|namespace)' $x || echo $x
done

Change-Id: I97dd2bb4bf3faad5ac8d952a28837fa1f594deb9
2016-04-01 11:37:41 -07:00
Jacob Trimble 8b85e58f73 Add several utility functions.
Change-Id: Ifbd2582747d2cb54d4abda789b0989b7a6b77aa6
2016-03-29 20:17:44 +00:00
Timothy Drews c0a6d7f238 Add additional compilation checks.
Adds additional compilation checks using Closure's
conformance framework.

Change-Id: Ifa868fc0379e5a8ef90cc36936d289f834f53625
2016-03-28 16:44:07 +00:00
Jacob Trimble e74f43bb94 Add clear key to ContentProtection key system list.
This also changes DrmEngine to reject key systems that do not have
any license servers, this causes init() to fail.

Change-Id: I10148c2caa2ffc57bf6c5f16421ed0600d98be95
2016-03-17 23:09:50 +00:00
Timothy Drews 415414154d Remove the receipt buffer from StreamingEngine.
The receipt buffer mechanism allowed us use byte-based
eviction; however, it increased the complexity of StreamingEngine
and required us to make strict assumptions about the manifest.

With the receipt buffer gone, we will now do time-based eviction.
Applications can specify a maximum "buffer tail" length instead of a
maximum byte limit.

Change-Id: Iafdbe2e71516ea0ae18254b9767ecfc1d6813644
2016-03-17 22:33:24 +00:00
Jacob Trimble 19973d63f4 Changed copyright headers from 2015 to 2016.
Change-Id: I429ff27e4794c03b7ea392e38415075077f9bfb1
2016-03-15 16:32:13 -07:00
Joey Parrish f9008c7b0f Report extended errors from MS browsers
When the video element dispatches an error on MS and IE, there is
additional information that may be critical to diagnosing problems.

Change-Id: I5da621e414ea8c16a7240b2f64fb8555aef54588
2016-03-14 22:46:48 +00:00
Jacob Trimble 8daf53e329 Renamed shaka.asserts to goog.asserts.
Using goog.asserts will work with the compiler.  So rather than
simply casting a nullable value when passing to a method, we can use
an assert which will correct the type and print a log if it somehow
is null.

This is not the same goog.asserts found in closure library, this
simply calls console.assert, but it is not required to do anything
for the compiler help.

Change-Id: I2548e39e772f0aa7ec41437cf9f5a2be383e0fbd
2016-03-11 15:29:20 -08:00
Jacob Trimble 846e7beb48 Unified comment spacing.
Before there were two style to indent comments after an annotation,
using 2 and 4 spaces.  Now this only uses 2 spaces.

Change-Id: Id06415d7193cc154a2768fb3932aff7a06b7ed32
2016-03-10 16:27:45 -08:00
Joey Parrish edc9bc8d49 Reject with Error objects in MediaSourceEngine
Instead of rejecting Promises with either exceptions or empty error
events, build full Error objects in MediaSourceEngine.

Change-Id: Ib4317f0ffe66c0292b3560f89f7a07e74e474dd3
2016-03-07 21:53:32 +00:00
Joey Parrish 78e996d090 Fix issues found by the newest Closure compiler
Fixes the following issues:
=====

lib/player.js:106: ERROR - Property id never defined on TextTrack

lib/util/xml_utils.js:42: ERROR - inconsistent return type
found   : (Node|null)
required: (Element|null)

lib/dash/content_protection.js:256: ERROR - Parameter must have JSDoc.
      function(element) {

lib/dash/content_protection.js:284: ERROR - Parameter must have JSDoc.
      function(elem) {

lib/media/drm_engine.js:47: ERROR - Private property configuration_ is never read

lib/polyfill/patchedmediakeys_20140218.js:269: ERROR - Private property keySystem_ is never read

lib/polyfill/patchedmediakeys_20140218.js:389: ERROR - Private property type_ is never read

lib/util/language_utils.js:84: ERROR - The value 0.0 is duplicated in this enum.
  MIN: 0, MAX: 2

lib/util/language_utils.js:84: ERROR - The value 2.0 is duplicated in this enum.
  MIN: 0, MAX: 2

demo/assets.js:171: ERROR - Value assigned to local variable headers is never read

lib/dash/content_protection.js:188: ERROR - Value assigned to local variable repUnknown is never read

lib/dash/dash_parser.js:400: ERROR - Value assigned to local variable suggestedDelay is never read

lib/dash/segment_base.js:41: ERROR - Value assigned to local variable SegmentBase is never read

lib/dash/segment_template.js:291: ERROR - Value assigned to local variable periodStart is never read

lib/media/drm_engine.js:172: ERROR - Value assigned to local variable onEncrypted is never read

test/dash_parser_live_unit.js:358: ERROR - Value assigned to local variable manifest is never read

test/drm_engine_unit.js:383: ERROR - Value assigned to local variable cert1 is never read

test/drm_engine_unit.js:384: ERROR - Value assigned to local variable cert2 is never read

test/media_source_engine_unit.js:24: ERROR - Value assigned to local variable dummyData is never read

test/media_source_engine_unit.js:504: ERROR - Value assigned to local variable p2 is never read

test/media_source_engine_unit.js:505: ERROR - Value assigned to local variable p3 is never read

test/media_source_engine_unit.js:506: ERROR - Value assigned to local variable p4 is never read

test/media_source_engine_unit.js:535: ERROR - Value assigned to local variable p2 is never read

test/media_source_engine_unit.js:601: ERROR - Value assigned to local variable p2 is never read

test/media_source_engine_unit.js:602: ERROR - Value assigned to local variable p3 is never read

test/media_source_engine_unit.js:603: ERROR - Value assigned to local variable p4 is never read

test/media_source_engine_unit.js:632: ERROR - Value assigned to local variable p2 is never read

test/mpd_utils_unit.js:20: ERROR - Value assigned to local variable HUGE_NUMBER_STRING is never read

test/streaming_engine_integration.js:55: ERROR - Value assigned to local variable onSeek is never read

test/streaming_engine_unit.js:1263: ERROR - Value assigned to local variable reportedContentType is never read

test/streaming_engine_unit.js:1264: ERROR - Value assigned to local variable reportedPeriodIndex is never read

test/streaming_engine_unit.js:1540: ERROR - Value assigned to local variable size is never read

test/util/dash_parser_util.js:77: ERROR - Value assigned to local variable retry is never read

test/util/dash_parser_util.js💯 ERROR - Value assigned to local variable retry is never read

test/vtt_text_parser_unit.js:272: ERROR - Value assigned to local variable result is never read

Change-Id: I707700250541e04ccbfe81d7298b3f0c5a82dcdc
2016-03-03 16:04:58 -08:00
Joey Parrish 55f9d6423f Add event dispatch to Player
Also improves shaka.util.Error docs.

Change-Id: I62080acfc4ff658eec1f4a72e36f4bac8c934267
2016-03-01 23:12:32 +00:00
Joey Parrish 9d70cad0ea Simplify FakeEvent and FakeEventTarget
We now avoid tricky things like CustomEvent and setting properties on
native Events.  This gives us better cross-browser compatibility and
less complexity.

Change-Id: Idc9fcc69c33257e4540d956bcbc949de6d992cf0
2016-02-29 17:58:55 +00:00
Joey Parrish f02bff9018 Player.load, integration with streaming & DRM
This implements Player.load and integrates with StreamingEngine and
DrmEngine.

Change-Id: I28b80d835c3c07706bdd69059991e97390d590d8
2016-02-23 12:54:59 -08:00
Joey Parrish 282218a5c3 Spread out error codes
Each category now has its own range of 1000 error codes.  Using codes
in the thousands rather than the hundreds will help avoid confusion
between our error codes and HTTP error codes.

Change-Id: I8defd0ecbbbff7ef1b06e18419f29f16a85b2555
2016-02-22 16:23:40 -08:00
Jacob Trimble 49b238b3c9 Fix support for UTF-8 encoded data.
Before, we simply converted each byte from an ArrayBuffer into a
character; however, this is only valid for ASCII characters.  This
changes it to fully support UTF-8 encoded network responses.

Change-Id: I9c49f29b09960501d345b98aa7af1bb711972abf
2016-02-23 00:12:43 +00:00
Timothy Drews 77b3480c3a Introduce new StreamingEngine API.
* Replace onBufferNewPeriod() with onChooseStreams().
* Remove newPeriod()
* When transitioning Periods, only call onChooseStreams(p) once
  Period p has been setup.
* Refactor documentation.

Change-Id: Ic341dd018302bf46fdd071072e5facb0e0fccb3b
2016-02-18 16:47:12 -08:00
Timothy Drews a0c35403e5 Add StreamingEngine tests and fix several bugs.
* Tidy up unit tests, and add more eviction tests and drift tests.
* Add integration tests.
* Handle end-of-stream and end-of-Period scenarios when segments
  are not perfectly aligned to Period boundaries.
* Use segment receipts to determine which segment to buffer next.
* Handle drift with eviction and other drift corner cases.
* Handle additional errors and improve overall robustness.

Change-Id: Ib57a255cda7a6e8c5857eb82accc14697983b893
2016-02-13 01:57:09 +00:00
Joey Parrish 813b746160 DrmEngine and associated tests
This is mostly complete, but needs additional integration with an
as-yet-unwritten AbrManager.

Change-Id: I3836040c6891fb774be800b53679f49e365c7e1c
2016-02-12 16:06:31 -08:00
Jacob Trimble 8e21f46159 Fix ContentProtection parsing for non-IOP manifests.
This fixes the ContentProtection parsing to support non-IOP-compliant
manifests.  This enables the unit tests for it, as well as adding
several more.

b/26982075

Change-Id: I0da2dbaa24ea2a6acf657b97f0a2e2d24ee3a16d
2016-02-12 21:48:19 +00:00
Joey Parrish beb99ff8d4 Show error enum names in uncompiled mode
Change-Id: I69b1fc52c452ae4cc0647689a1a4c4863597b8e0
2016-02-12 18:16:56 +00:00
Jacob Trimble bfa42a8d1e Fix argument bug in Dash parser.
This also changes from using Node types to using Element types.  This
is more correct since the code only deals with XML elements and not
with other Node types (e.g. text content nodes).

Change-Id: I0e8c7bf2adc1800a494e575b16661e8c69a7deb0
2016-02-11 15:14:52 -08:00
Joey Parrish d03021603b Make types nullable, use HTMLMediaElement
Non-nullability on some types forces us to use casts everywhere, at
which point the compiler is just trusting us.  So they might as well
be nullable and save us some typing.

Also, change HTMLVideoElement to the more general HTMLMediaElement.

Change-Id: Iaf111835bfbf230b99ad8cd7a7a06a6caffd16bc
2016-02-10 19:00:42 +00:00
Joey Parrish 6d57a9181b Improve jasmine/karma formatting of util.Error
Add extra info to util.Error in non-compiled builds so that we have
meaningful stack traces in test failures.

Change-Id: I351d2f65ef764947f8318372a47eeb6f014d7b16
2016-02-09 14:44:59 -08:00
Timothy Drews f8b7b01fb0 Implement byte limits and segment eviction.
* StreamingEngine now limits buffers to a specified byte limit
  and evicts old segments as it appends new ones.

Change-Id: Id3e65bc45e782bf9d1214a6b52df0b92892606cb
2016-01-28 14:23:32 -08:00
Joey Parrish b822efcb86 Integrate Player with manifest parsers
Change-Id: I2388c8275a886709b35e7ec600fd6fa1340a6635
2016-01-16 05:10:48 +00:00
Joey Parrish 33c957298b Stringify Errors for better reporting in tests
This fixes unreadable test failures like "Failed: [object Object]"

Change-Id: I61d5abf273bd49f9b972c1a7adeab99e459f378d
2016-01-15 22:42:32 +00:00
Timothy Drews a4ff2711f2 Add StreamingEngine and Playhead.
Closes #101
Closes #186

Change-Id: I8d1a8d6c0f8cfb5abdd81a149318377282b2bea0
2016-01-15 14:30:27 -08:00
Jacob Trimble 54fa88f6f0 Added Dash manifest parser.
b/25851171

Change-Id: I4fbd6410d579899b749b50c8819fa8c17ac80658
2016-01-13 19:29:07 +00:00