Commit Graph

77 Commits

Author SHA1 Message Date
Jacob Trimble 26bacb1489 Disallow unknown properties (3/5).
This is part of adding a new conformance rule to add additional type
safety.  This will disallow using properties of unknown types or using
unknown properties.

The first parts will be fixing errors caused by the new rule.  These
are backwards compatible, so can be applied before the rule is enabled.
Once all the errors and bugs are fixed, the rule will be enabled.

Change-Id: Ic37437a1ad2305bc50a814cdcc562e74703222ac
2017-07-05 17:47:03 +00:00
Jacob Trimble d8a3d8d2f7 Change jasmine.Spy type definition.
The old definition using a union with a Function causes problems.  The
compiler tends to treat this as an unknown type, so we loose type
safety.  The new types ensure full type safety, at the cost of needing
to "convert" the spy when it is used as a function.

Change-Id: I98ebd9dffd9cb865d0cf5d03db0fb5d6ea001ed3
2017-06-27 12:18:48 -07:00
Jacob Trimble 7a5991a01d Fix date parsing when timezone is missing.
In DASH, when parsing a date, it should default to UTC.  When we pass
the date string to Date.parse(), it will use the local timezone.  So
if we don't see a timezone, we need to manually add the UTC timezone
so Date.parse() will parse the correct timezone.

Closes #901

Change-Id: Ica0433042e9bfd42b0cbf62653bdbd2b97b56297
2017-06-20 12:43:23 -07:00
Michelle Zhuo 00b440f376 Support audio track selection by role and language
Exposing the roles of tracks, which come from the manifest, in the
select audio language method. This is a follow up on commit
b27861050c11451db57d87270ec1385c1906627a.

Closes #767.

Change-Id: Iebb873f1db8834c7275a8a9fc01c3b855c0288aa
2017-06-15 22:41:21 +00:00
Jacob Trimble 8835f7b898 Fix bug when trying to load when there are pending failures.
If you attempt to load an asset and then the first load fails, then
the second load will hang forever.  This was caused by the second load
trying to cancel the first, but the CancelableChain not handling this
case.

Closes #782

Change-Id: I79e201db44cbf47485e7221cc148bbfdde6276f7
2017-06-07 13:29:28 -07:00
Jacob Trimble 575f2ad109 Add an indicator for critical errors.
This adds a severity field to Error objects.  This can be used to
detect whether an error is recoverable.  All the same errors are still
reported so the field can be ignored.

There are two possible values:
* RECOVERABLE means that the Player will try to recover from the error
* CRITICAL means the Player will be unable to continue and must call
  load() again

Closes #564

Change-Id: Ie2c5468340c13e7a288b99690ab65b7ecc0a6b29
2017-04-04 23:57:59 +00:00
Aaron Vaage ca87772a60 Define Mp4Box Using Strings
When defining a box, the box would be defined as a four
byte integer. Now there is a "fromString" function that
can be used to convert a four character assci string to
a four byte integer.

Change-Id: I78c704e012620c94ae681efb450977305bdb84aa
2017-03-22 23:13:24 +00:00
Aaron Vaage 924e396a18 Added readInt32 to DataViewReader
Change-Id: Ib54b4997df19902c35ada8aaadbacba7292e2198
2017-03-20 12:50:55 -07:00
Aaron Vaage 62e4b1efcd Added Unit Tests for MP4 Parser
Change-Id: I79f8b9e6be608e5688277240e6051f83abfe0e27
2017-03-20 18:03:16 +00:00
Sandra Lokshina 0b12937520 Replace content type strings with constansts.
Change-Id: I4fda583915766b40ee7a5c7451d037077d9f2582
2017-03-08 21:41:59 +00:00
Jacob Trimble fc5fe61bae Fix copyright headers.
We only use 2016 in the copyright headers for our files.  If we use
different years for different files, then the compiled library will
include copies of all of them, bloating the library.

Change-Id: Ia894601cbd660f9e7cbe84264b421ff60e847dcd
2017-02-15 23:36:45 +00:00
Sandra Lokshina 87073c9afa Create ManifestParserUtil common to dash and hls parsers.
Both DASH and HLS parsers will be using resolveUris() and possibly
other methods in the future.
Create a ManifestParserUtil for the shared methods.

Issue #279.

Change-Id: Iaa5e32ec543a390341a54752563a9f27251f0832
2017-01-19 23:34:25 +00:00
Sandra Lokshina 23a23b9b36 Make language selection explicit. Split text and variant selection.
Add UI options to select current audio and text language.
Split selectTrack() into selectText() and selectVariant().
Stop automatically disabling ABR manager when a variant is selected.
Add a warning if selectVariant() is called while abr is enabled.

Issue #412.
Issue #626.

Change-Id: I15f1c3c4fdc6d6b641f708fbef19dbcf10cbcfc6
2017-01-18 00:05:52 +00:00
Jacob Trimble ded62a8205 Add more tests and remove dead code.
This brings 9 classes over 80% branch coverage.

Change-Id: Id9edf22022c3f99d21fa6cad6df6994ee751079d
2017-01-11 01:20:19 +00:00
Joey Parrish e093ab2f3b Fix text filtering and cleanup MIME computation
During recent refactoring, we introduced a bug in which we would
filter out any text stream with a non-empty codecs parameter.

Replaces PR #639

Change-Id: I9a45ef7e1bc250fd989e3972c0670f3e48336511
2017-01-04 14:28:42 -08:00
Sandra Lokshina e95d7b9de4 Refactor shaka internals to use variants instead of stream sets.
Issue #279

Change-Id: Idf4241b4e2490876bdc6275685361a5c9bf132b0
2016-12-28 17:49:24 +00:00
Joey Parrish 894c56d3c9 Remove suppression of "unnecessaryCasts"
This no longer seems to be needed.

Change-Id: I8f9ed03f97b235d4652930745d4416f6c8f77445
2016-11-04 19:40:55 +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
Joey Parrish 2585464faa Extend test timeouts to reduce flakiness
Based on several rounds of experiments, the timing on these tests was
determined to be too strict.  Extending delays and timeouts on these
tests reduces flakiness across browsers and platforms.

Change-Id: Ie36c86f3afcb615991454d098e690199ca063f96
2016-07-09 00:00:41 +00: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
Leandro Moreira a8c44da4b1 restructures test files 2016-07-01 09:53:30 -03:00
Timothy Drews 833101f57a Improve fakeEventLoop() robustness.
* Decrease Promise delay to reduce timeouts on Safari.
* Stop timedout tests from running their fake
  event loops after the tests have actually ended.

Change-Id: I5104396e916cfbca8b2e796f9bc8f2dcb8149042
2016-06-27 21:23:20 +00:00
Jacob Trimble a3c1ed29d4 Defer filling URI template until request is made.
Instead of filling the URI templates when parsing the manifest,
wait until the request is made to fill it.  This reduces the time
it takes to parse the manifest.

This was tested using a stream with a 24-hour timeShiftBufferDepth.
Using a Chromebook pixel running Chrome 51.  The average manifest
parse time was about 1 second before, now it is about 200ms.

Issue #405

Change-Id: I89f36085441f6c6b7d6281b24b671dc668f23fe5
2016-06-23 21:15:19 +00:00
Jacob Trimble 7aab332e9b Correctly use suggestedPresentationDelay in seek range.
Before, we did not use suggestedPresentationDelay in the seek range.
This meant that seeking to the live edge would usually lead to a
buffering state because the seek range is the same as the availability
window.  Now the seek range is handled differently from the
availability window.

b/28938315

Change-Id: Iacfffe30778f7c63734fe24eeb95634611da86be
2016-06-22 22:06:51 +00: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 a644900f0f Overhaul load/unload/destroy
player.load() now uses our new CancelableChain abstraction for its
chain of events.  player.unload() and player.destroy() will both
cancel that chain.  player.unload() will wait on the cancelation to
complete before resetting the streaming system, to avoid a race.

Change-Id: I37fcbacde33f253982c3dd5ed246855d4e363c79
2016-06-07 14:56:28 -07:00
Joey Parrish 5edb34ec10 Verify parsers are stopped in load/unload tests
Change-Id: I982f78f4c95e2237e0c78f4d296931b1e8498135
2016-06-03 23:25:50 +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 9f078a4352 Allow getting DrmInfo from Player.
Now the DrmInfo used to initialize EME can be returned from Player.

Closes #272

Change-Id: Ie0f9d1a533eb28366991d9ee69193220ff66aeb4
2016-05-17 20:05:29 +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 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
Joey Parrish 0a3d6bd5b8 Add an option for default clock sync URI
Applications which cannot control their manifests may need to specify
a default clock sync URI for use when UTCTiming elements are missing.

Closes #290

Change-Id: I5704b25d2d3199ceb932f8102490a9b3e8a27dac
2016-05-04 07:44:15 +00:00
Timothy Drews 294bcca4e9 Treat absent timeShiftBufferDepth as infinity.
This patch also enables presentations to start in live mode
and end in VOD mode.

Issue #351

Change-Id: Idc0ad0c69887d61d080f844ef388222d1228a535
2016-05-02 14:22:38 -07:00
Joey Parrish bc17162407 Fix key system content type checks
Some browsers, such as Edge 13, do not report capabilities at all.

Not all encrypted streams have known key IDs, so we should not
use that as a predicate for the encrypted content type filter.

Since not all content has both audio and video, the requested and
reported capabilities may not have both either.  So we should
default capabilities to empty lists if missing.

This also adds an encrypted audio-only asset so that audio-only is
covered by our integration tests.

Closes #342
Closes #360

Change-Id: If5973c4ddea358d96ab305700e027021b1a7b65a
2016-05-02 18:22:52 +00:00
Jacob Trimble 50a43ffd55 Detect when key systems don't support a content type.
Sometimes a key system will not support the same content types that
MSE will.  We need to use the capabilities returned from EME to
detect what content types are supported.

Closes #342

Change-Id: I356f8ab33fca3a7b036e81f83051de2c3b2d2864
2016-04-27 20:01:41 +00:00
Timothy Drews 1108700f10 Use segment info to adjust the pres. timeline.
* Permit non-zero presentation start times for VOD: some
  presentations have segments which start too far from 0 to
  allow the video element to begin playback; now the player will
  start VOD presentations from the start of the first segment.
  However, segments of the 2nd, 3rd, 4th, etc., Period of a
  multi-Period presentation must still start close to 0 (the
  player will not jump any gaps in the presentation).
* Prohibit seeking to regions at the beginning of the segment
  availability window if segment information is missing from
  that region: sometimes live manifests do not contain all the
  segments in the segment availability window; now the player
  will prohibit seeking to these regions.
* Update definition of live in DashParser to match Player and
  Playhead.
* Simplify PresentationTimeline's constructor by just using setter
  functions.

Issue #341
Closes #348
Issue #357

Change-Id: I96c22774448476bea89ff4014f03b87bdb51ba07
2016-04-26 21:09:57 +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
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
Jacob Trimble 3bdfc7dfa1 Make default bandwidth estimate configurable.
Now, the default bandwidth estimate used is configurable and can be
set using Player.configure.

This also moves enableAdaptation and abrManager configuration values
to a subcategory 'abr'.

Closes #268

Change-Id: I11ab30452b20dc4fd9385210811185fe2969821e
2016-04-06 23:28:52 +00:00
Joey Parrish 8f14f3c91e Fix VOD with positive drift
This adds a tolerance for certain buffered range checks.  The browser
will jump small gaps, so we should not let small gaps interfere with
our buffering algorithm.

This also clamps lookup times to zero to avoid errors thrown on
positive drift.

Fixes #320

Change-Id: I2de9ef4850a96cac29bbcacaeb75285a358c230f
2016-04-04 23:18:20 +00:00
Joey Parrish 8df544637a Default track language to "und" - undetermined
The default language code should be "und", since a blank string is not
a valid language code.

Change-Id: I5c201d98492881658820c512332f23444c415504
2016-04-04 17:12:44 +00:00
Jacob Trimble fcad6ee666 Add mocking methods to Player.
Add simple mocks for types Player uses like StreamingEngine.  Also
adds methods on Player to allow it to be tested without loading
dependencies.

Change-Id: I99d920ce02b2bc685e0217b8861ca7e9bef89603
2016-04-04 16:20:54 +00:00
Jacob Trimble ea6829d5f4 Add a manifest generator (redux)
Add a helper type to generate valid manifests.  This can be used
to selectively set parts of a manifest without requiring a lot
of extra code to define the default field values.

Change-Id: I6cb8f44c5700a5ff3cb56a21bf3fdd4fb25291f1
2016-04-02 19:56:38 -07:00
Joey Parrish 83a50a5c06 Revert "Add a manifest generator."
This reverts commit 7d2c0a0293, which
broke tests on IE by using Promises at load-time.

Change-Id: Ic4618c3579d6da2b5f60fbb2bfc9ccc8a6a2898b
2016-04-02 15:48:33 +00:00
Jacob Trimble 7d2c0a0293 Add a manifest generator.
Add a helper type to generate valid manifests.  This can be used
to selectively set parts of a manifest without requiring a lot
of extra code to define the default field values.

Change-Id: Ia087e391249cdbea72e2c1c4a317759d5264b1a7
2016-04-01 22:27:05 +00:00
Timothy Drews 73c4bc7ad6 Add more live StreamingEngine tests.
* Refactor common parts of unit tests and integration tests.
* Allow StreamGenerator to offset segments to support multi-Period
  content.
* Add some additional logging for debugging.

Change-Id: I196c5e5eebd55cf1d6c5706ba9906c905bd21c2e
2016-03-30 00:20:48 +00:00
Joey Parrish 6dc9a9a657 Speed up StreamingEngine unit tests
This speeds up tests on browsers other than Edge and fixes timeouts
on Safari.

Change-Id: Iea45ebc6d8bb4a3e12f738700ae2dcf2356efe5d
2016-03-29 19:07:48 +00:00