Commit Graph

582 Commits

Author SHA1 Message Date
Joey Parrish d97e9829b2 Add missing requires
Caught by an upcoming version of the Closure Compiler

Change-Id: I0f76146c04d7b9d0d433d5f7058c78d806f50384
2016-12-14 14:25:33 -08:00
Joey Parrish 7dc98a7d6b Fix DASH content type parsing
The DASH parser was not always correctly deducing the content type.

For unspecified content types, the type can be deduced from the MIME
type.  For example, video/mp4 is video, and audio/webm is audio.

For text, things are a little more complicated.  Text types do not
always start with text/.  In particular, embedded text, such as VTT
in MP4, have a MIME type that starts with application/mp4.

To deal with that, if we see an unknown type, we ask TextEngine if it
supports it.  If so, we deduce that the content type should be text.

This check against TextEngine was only happening for MIME types
specified on the Representation, but not on AdaptationSet.  This
replaces a weaker deduction in the general frame parser with the same
TextEngine check we were using elsewhere.

Furthermore, Player mishandled the content types it passed to
AbrManager.  AbrManager will only choose audio, video, and text
streams.  It ignores all other types.  Player, meanwhile, threw a
confusing error if AbrManager failed to choose some of the types
passed to it.  Therefore, Player should only pass audio, video, and
text types to AbrManager.

This fixes both issues and adds new unit tests for both.

Closes #631

Change-Id: Ib1311d37d00c3989367fd066f66e1eba85652e40
2016-12-14 22:10:14 +00:00
Jozef Chutka be0d4b56cb Add support for Toshiba dTV (#605)
Toshiba has EME v0.1b, but without the webkit prefix.  This generalizes
the WebKit MediaKeys polyfill to work with or without a prefix.
2016-12-14 09:53:29 -08:00
Joey Parrish 9dda7a9c73 Add placeholders for all retired error codes
Error codes do not get reused, because that could create confusion in
bug reports.

To make it easier to add new error codes, we should keep track of
retired error codes.  This adds placeholder comments for all of the
error codes which are no longer in use.

Change-Id: I70eca30d3108e35d9db388f4372189ab7c014f92
2016-12-06 18:35:48 +00:00
Joey Parrish e6a6e980cb Throw explicit error on empty manifests
Before this, an empty manifest (no periods) would result in a
TypeError from the containsInband computation.  This corrects the
computation and introduces an explicit error for empty manifests.

Closes #618

Change-Id: Ie9b740dbfa4ffcafbf99541bf03fa68cfae2bf88
2016-12-05 15:16:46 -08:00
Ross-cz 3b7328b530 Fix playback when IE11 modifies the XML DOM (#611)
When there is a hypen contained inside manifest Location/BaseUri element and the application uses MutationObserver, IE11 can change the XML DOM of the manifest and break playback.

This changes the way the document is parsed so that it is resilient to these unintended changes.

Related IE bug: https://connect.microsoft.com/IE/feedback/details/1398926/ie11-does-not-parse-cdata-containing-hyphens-correctly

Closes #608
2016-11-29 13:39:15 -08:00
Joey Parrish 4c9ee5db76 Allow text parsers to change during playback
Text parsers can easily be changed during playback, unlike the
browser's media decoders.  Whenever we change text tracks,
reinitialize the text parser.

This also removes restrictions on text tracks of different types
when we filter manifests.

Closes #571

Change-Id: I3c243dde951cd04554c2fa1be2c8ebf06988791b
2016-11-21 17:50:08 +00:00
Joey Parrish 09d221de16 Update the Closure Compiler to v20161024
Change-Id: I6642b1e386667028c1adbcce97ab64b21a9104b9
2016-11-11 22:08:43 +00:00
Joey Parrish 1d2929ab00 Add extra exports for the sake of generated externs
An upcoming compiler release will allow us to generate externs from
exports.  Because of that, we are adding some extra exports which are
otherwise not needed at runtime.

 - Export properties which implement an interface
 - Export classes which are referenced in external APIs
 - Export base classes of other exported classes

Change-Id: I78b3a4569b4b82b0a9d8993978faf268c2a791d9
2016-11-04 17:12:16 +00:00
Sandra Lokshina fade7d291d Fix handling of internal-error key status.
Closes #539.

Change-Id: I3ff30167034b4aed2bd390fc901e9466f6dd12c6
2016-10-06 20:14:24 +00:00
Sandra Lokshina addece6098 Log and ignore non-standard WebVTT settings instead of erroring out.
Closes #509

Change-Id: I1aced2ea8828c4ca6a9afee6ea28b0144a832029
2016-10-05 18:06:51 +00:00
Jonas Birmé a060050564 Provide framerate and codecs information on video tracks (#533)
Closes #516
2016-09-28 14:13:54 -07:00
Joey Parrish 1fa69b2375 Filter text streams for compatibility
Type compatibility checks are important for multicodec or
multicontainer content, and there's no good reason to exclude text
from those checks.  The new Axinom v7 test vectors have multicodec
text (both mp4+VTT and mp4+TTML).

Change-Id: I999aaf5b37cda8a9243538b4dd21c503df33dcb9
2016-08-29 23:27:30 +00:00
Joey Parrish 3cad924cf1 In-progress recording (IPR) support, phase 2
Behavior for IPR streams:
 * offline storage disallowed
 * segment references will not be stretched to the period
 * seek range starts at 0
 * seek range end is calculated like the live edge
 * seek bar is from 0 to duration, not the seek range

Closes #477

Change-Id: Ia36874bb7208c2473c79cb817395ce03925b8c95
2016-08-29 19:57:15 +00:00
Joey Parrish eafe954d0c Replace Number.POSITIVE_INFINITY with Infinity
This is supported on all browsers, is more compact, and is easier to
read.

Change-Id: I96576dc341e093b7be9ef94fe36595c945b063c1
2016-08-29 18:56:54 +00:00
Joey Parrish e4e200388c Fix encoding issues with Chinese subs
In many places we tried to guess the encoding of a piece of text.
This guess fails for Chinese UTF-8 text, and probably text in many
other languages.

However, DASH manifests, TTML files, WebVTT files, and VTTC box
payloads are all specified to be in UTF-8.  Rather than guess and
possibly fail, treat all text in these contexts as UTF-8.

Change-Id: I00c652a9f1dd20855e94abfac84275e41dd9e266
2016-08-25 22:29:37 +00:00
Sandra Lokshina b9c362808d Define order of AdaptationSet preference.
When a piece of content has several StreamSets with the same
language and role, pick an audio set with lower average bandwidth,
pick a video set with the highest top resolution. Pick the first one
when the above is not applicable.

Closes #476

Change-Id: Id2cb9095994e8aa6b205024504a5d665f8656437
2016-08-15 18:56:32 +00:00
Sandra Lokshina b069edae83 Create a new error code for 'internal-error' key status.
Closes #468

Change-Id: I5353e981e1831a300a1ef020668f013c334bba8a
2016-08-09 16:56:45 +00:00
Sandra Lokshina f1a4e25151 Add support for EMSG box.
Look for EMSG boxes in segments if the manifest signals their presence.
Update the manifest when a DASH EMSG box is encountered.
Dispatch an event with the content of the box for all other EMSG boxes.

Closes #259

Change-Id: I874121207c2419e756980ac858fba0d56e68e07e
2016-08-01 14:32:23 -07:00
Joey Parrish 56ebf6286c Drop WRONG_KEYS
For content without a clear lead, the order of 'waitingforkey' and
'keystatuseschange' is inconsistent and causes false positives for the
WRONG_KEYS error.  Without an obvious inverse for 'waitingforkey', we
will have to drop the WRONG_KEYS diagnostic error.

See also: w3c/encrypted-media#284

Change-Id: Icc1c420ff5d177a0329db244a6b28e99820a5221
2016-07-27 15:18:24 -07:00
Joey Parrish 1c4d7bbd85 Improve HDCP error handling
* Suppress WRONG_KEYS errors when output is restricted.  This is a
   false alarm in these cases anyway.
 * Throw a restriction error when the ABR manager fails to choose
   streams for some content types.
 * Rename ALL_STREAMS_RESTRICTED to RESTRICTIONS_CANNOT_BE_MET to
   reflect the way restrictions actually work.  We cannot play if all
   streams of any one type are restricted, not just all streams in the
   period.  (e.g., all video restricted is a failure, even if audio is
   still playable.)

b/30290503

Change-Id: I6de48950d33f241b7df1161052d60b89f962649f
2016-07-25 16:33:08 -07:00
Joey Parrish c6ea804e2a Closure cleanup
* Drop unnecessary type alternation in SegmentIndex unit tests
 * Drop unnecessary bind in StreamingEngine unit tests
 * Drop unnecessary expose annotations in Pssh
 * Add comments about quoted access in cast unit tests
 * Move afterAll() position in cast unit tests
 * Make return type for PublicPromise constructor more specific
 * Define a type for Util.eventLoop return value

Related to PR #421

Change-Id: I092a8ff366b4ac4ea868dd3f4fbe4e3d63a2167f
2016-07-24 16:33:28 -07:00
Andy Hochhaus 69ad05a63c Fix JSDoc annotations 2016-07-24 11:23:56 -07:00
Sandra Lokshina 7b6a140512 Refactor lib/util/pssh.js to use Mp4Parser
Change-Id: Ib6d5668f21596a87b388258059fa09b4987fd25a
2016-07-19 22:54:31 +00:00
Joey Parrish bf544fd4c9 Defer DRM events, redesign DRM errors
Wait to send a WRONG_KEYS error until key statuses have propagated.

Also, check for expired keys and fire the EXPIRED error from the key
status handler, not from 'waitingforkeys', which is not yet available
everywhere.  The EXPIRED error will suppress any WRONG_KEYS error that
might otherwise fire when 'waitingforkeys' happens.

Finally, do not trigger track restrictions based on expired keys.  This
means EXPIRED will never be followed by ALL_TRACKS_RESTRICTED.

This provides more deterministic behavior in tests and clearer
diagnostic signals for app developers.

Change-Id: Idd0f91fdd6442125661b9593ecaad0b57b81625c
2016-07-19 17:16:13 +00:00
Sandra Lokshina 8b767df6a1 Implement parsing for WebVTT subtitles embedded in mp4.
Closes #277

Change-Id: If74bb81b66a78939b4f87e4f9f793328d50ed069
2016-07-18 23:52:56 +00:00
Sandra Lokshina 259777fe9f Implement parser for segmented TTML in MP4
Closes issue #278

Change-Id: I2f454a2c2f63d8ce6682cd4593c1d843b2967978
2016-07-13 21:49:43 +00:00
Joey Parrish b7af879583 Remove hasOutputRestrictions
If a key status is 'output-restricted', treat the key as unusable.
In many cases it is, and we have no way of differentiating when it is
or is not.  So our treatment of this status should be conservative,
and we should treat the key as unusable.  This will prevent
HDCP-related failures that may be caused by adapting to a stream whose
output restrictions may not be met.  The hasOutputRestrictions flag on
streams and tracks is now gone.

The caveat to this change is that if content is encoded with the same
key for SD and HD, and HD streams have HDCP restrictions that cannot
be met, we will now consider both the SD and HD streams to be
unplayable, even though we could still play the SD streams.  Because
we can't separate the status of the two streams, we don't know for
sure if the SD streams can be played.

We will no longer support such content due to the complexity of doing
so, and due to the risk of playback failures on adaptation to
restricted streams.  Streams with different security requirements
should always be encrypted with different keys.  Content which does
not follow this best practice will no longer be playable in Shaka
without modifying the player.

Change-Id: Ia29db8efa0b6f83c0376199dea5210c9b468bc40
2016-07-13 10:40:24 -07:00
Joey Parrish 6daa7f3b83 Allow AbrManager to clear ahead of the playhead
SimpleAbrManager will now leave 5s of video ahead of the playhead and
clear the rest when upgrading to a higher resolution.

Also smooths transitions for overlapping segments by scheduling an
abort() call to reset MediaSource internals after removing content or
changing the append window.

Related to issue #435

Change-Id: Ie036515388e1e7e4b3b8f3ab9922e3d5e7ed2627
2016-07-13 04:01:11 +00:00
Jacob Trimble d17c9ddf22 Download different content types in parallel when storing.
Change-Id: Id66a6de7953e4c9678bbd39837d8b89601a43f8b
2016-07-11 16:10:44 -07:00
Sandra Lokshina 134119ecfa Add new time formats and refactor time parsing logic for TTML parser.
Issue #111

Change-Id: Ia9ebcd9be19ebdc452d9554ace116265d5a7d59c
2016-07-07 13:07:02 -07:00
Joey Parrish 3624d8e079 Limit Chromecast playback to 1080p
Original Chromecast devices can output a max of 1080p, and may have
issues digesting higher resolution content.  Since higher resolution
content would be downscaled for display anyway, limit Chromecast to
1080p to avoid both decoder issues and wasted bandwidth.

Some Cast devices may support UHD content, but the max res for
Chromecast is currently hard-coded until we have a way to detect a
device's capabilities at runtime.

Issue #261

Change-Id: I3dd093b07f9a964116f81422f3c298dfbf7e2e52
2016-07-07 19:28:48 +00:00
Joey Parrish 0c8f74493c v2 Chromecast support
This introduces Chromecast support directly in the v2 library, as well
as in the demo app.

See the included design doc for details.

Issue #261

Change-Id: I26a707e7fa6bd829c3ebc70e4c9345ec25eed000
2016-07-06 11:47:04 -07:00
Joey Parrish d68e8dd27f Fix key status and session expiration in DrmEngine
Also involves some cleanup:
 - Differentiate between WRONG_KEYS and EXPIRED.
 - Fix session expiration detection for CDMs without sub-second
   time resolution.
 - Export accumulated key status over all active sessions.
 - Update DrmEngine workarounds with bug links.

b/29919059

Change-Id: Ia4f12657285b0d431ed7a0c22ee4312375fdd40e
2016-07-01 20:24:06 +00:00
Sandra Lokshina 63823ae8f6 Add tests for Ttml Parser
Change-Id: Ic92cee8608f7fcbc24ecebf9ffbed77e7888a9c8
2016-06-30 22:39:13 +00:00
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