Commit Graph

53 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 adb8da4764 Disallow unknown properties (1/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: Iefde089b2f62ddfdf43944cda5badab438577561
2017-06-27 19:43:00 +00:00
Joey Parrish 1eb5a41d6f Fix failed assertion tearing down offline tests
Discovered while working on #894

Change-Id: Icf74cd4bf804df0b055033f9c1113971e1644202
2017-06-22 20:14:21 +00:00
Michelle Zhuo f09999aa80 Add channel count information for HLS audio tracks
Adding the count of channels, as a new field for tracks and streams.
Used for HLS audio tracks.

Resolves #826.

Change-Id: I1448b4a8cfaf6dd798670bb2f0f3981d6c7e40c3
2017-06-22 11:34:36 -07:00
Joey Parrish 8b54c7b758 Define, document and rename new option for offline
The new isPersistentLicense option was not documented in #878.
This adds docs and renames it to usePersistentLicense.

Closes #873

Change-Id: I59ed32c98660ad7c155392a1708eab98f63131c3
2017-06-21 14:56:05 -07:00
Graham Scragg 59fe4e5d40 Support for offline data with a temporary license (#878)
Based on app configuration, we could store protected content offline
without a persistent license.  The offline content would then require
a network connection, but only briefly for licensing.  This makes
sense in a lot of commuter or airplane WiFi scenarios.

Closes #873
2017-06-21 14:44:02 -07:00
Joey Parrish 8fdd2921dc Fix offline storage offline in compiled mode
We were giving Storage a Player proxy from CastProxy instead of a
local Player instance.  This fixes the mistake and adds a new error
code to make it clear when this mistake is made by other apps.

Change-Id: I4f2d49adc45ef5ca3a942a72192a09f001f5100c
2017-06-05 18:03:32 +00:00
Michelle Zhuo afb0ded49c Expose Roles of Audio Tracks
This change is to expose an audio track's role in order to differentiate
among a main / caption / commentary track that shares the same
language.

Issue #767.

Change-Id: I05d38cba2170d0005611cf160b7ae45996fe77dd
2017-05-26 13:51:43 -07:00
iKinnrot 151930284a Add support for DASH label and HLS NAME attributes (#811)
* add support for non-standard DASH label attribute
* add support for HLS NAME attribute

Closes #825
2017-05-25 10:43:07 -07:00
Aaron Vaage 730fd9e44f Replacing Cursor Delete In DBEngine
After looking into the speeds for removing data from IndexedDB, it was
found that using a cursor was slower than the other methods. This change
takes the remove logic and changes it to remove each key as part of
one transaction.

Closes #756

Change-Id: Iec3916650d8a4fe2b6353b604c070d8a0af7426c
2017-05-11 21:42:53 +00:00
Aaron Vaage 0698987836 Fix Offline Download Stalls on Android
On android the quota for offline content is much smaller than on
desktop. It was observed that when this quote was exceeded that
downloading offline content would stall but not throw and error.
It was found that instead of an error, IndexDB called onabort for
the transaction.

To fix this we now route onabort through the same code path as
onerror so that the abort will be treated and communicated as an
error back to the application.

Closes #747

Change-Id: I10d536a4edc29d51790f0588f6163a5d83eccf33
2017-05-04 18:02:18 +00:00
Jacob Trimble 0c6ae65908 Move storing segment logic to DownloadManager.
Now DownloadManager will handle the storing of the media segments.
This will make it easier for forks to handle download/storing segments
using background features (e.g. service workers).

Change-Id: I15bd548e30437094d4948a22752cd37ae6ed3c06
2017-04-20 17:29:59 +00:00
Jacob Trimble e5ce395f37 Implement gap jumping.
The bulk of the logic for gap jumping is handled in Playhead.  It
tracks the current buffered ranges and jumps over any gaps that appear.
It listens for a special browser event ('waiting') for when the video
element runs out of playable frames.

This change also removes the logic for jumping gaps at the beginning
of the timeline.  This is handled by the more general gap jumping
logic and works cross-browser.

Finally, this updates the buffering logic to only count the amount of
content buffered (i.e. ignoring the gaps).  This fixes some bugs where
gaps in the content can result in StreamingEngine buffering forever
since it thinks only a little is buffered.

This includes full implementation of the logic, but this doesn't close
the issue since there aren't any integration tests yet.  Those will
be added next.

Issue #555

Change-Id: Id99eb9fe469e8cf2c7464a3d70c3733791e806e0
2017-04-17 18:15:23 +00: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
Jacob Trimble b4d0fa4901 Expose license expiration times through Player.
This adds a method on Player to get the license expiration times for
the current EME sessions.  This also adds the expiration times to the
stored content structure for offline content.  This will update the
stored expiration while playing content (e.g. license duration changes
when playback starts).

Closes #727

Change-Id: I18770a79413423695bbb2ed5f31f6b19038a33d2
2017-04-03 18:25:43 +00:00
Joey Parrish 86ee271384 Improve Storage test coverage
Change-Id: I123d6703201e8d9bcfe71aa161b3a2180452e93c
2017-03-21 19:08:17 +00:00
Jacob Trimble 7dbc6c4b12 Workaround IndexedDB race on IE/Edge.
This implements the workaround for a race in IndexedDB on IE/Edge.
If we don't get an 'upgradeneeded' event when we expect it, we will
close the connection and retry.

b/35993864

Change-Id: I78d1c18e4798c098167a1a6a184623780002a34f
2017-03-20 21:32:32 +00:00
Jacob Trimble 7b729a0778 Add assertions for IndexedDB race on IE/Edge.
On IE/Edge, it is possible for the IndexedDB database to not be deleted
when the success callback is fired.  If we immediately create a new
connection to that database, it will connect to the old database.  Once
the database is deleted, the connection will no longer have the data.

This adds some assertions that we get an upgrade event.  This also adds
the framework for the workaround, but doesn't add it so we can give
this revision in the bug report.  This deliberately increases the
failure rates on IE/Edge.

b/35993864

Change-Id: I3d142bdee6386fbe63f1b2def462a0e039723a38
2017-03-17 19:03:31 +00:00
Jacob Trimble ca2f61d6bc Add support for 'emsg' based manifest updates.
b/36072752

Change-Id: I00c19be71e81b15b5d3f33d5e2dafb17a6f8acee
2017-03-16 18:46:05 +00:00
Joey Parrish 58d9156be2 Update default track selection for offline
By default, we will now store all text tracks, regardless preferences.
This not only helps with our demo, but makes sense for applications
that have not bothered to configure the track callback for offline
storage.

This also fixes bugs in the default track selection algorithm,
changes the default audio track selection to fall back on primary
variants in cases where the audio language preference cannot be met,
and adds tests for the default selection algorithm to verify correct
behavior.

Change-Id: Iead0499039e9ec596514aa7577265a7472914621
2017-03-10 00:51:28 +00:00
Sandra Lokshina 0b12937520 Replace content type strings with constansts.
Change-Id: I4fda583915766b40ee7a5c7451d037077d9f2582
2017-03-08 21:41:59 +00:00
Jacob Trimble fc46b29ed8 Move 'emsg' handling to StreamingEngine.
Rather than having it in the DashParser as a network response filter,
we should have it in StreamingEngine.  This will give it access to the
segment times so we can calculate the presentation times for the event.
Otherwise, there is no way to know when the event should actually occur
since the app can't know which segment is being downloaded or which it
came from.

This also adds startTime and endTime fields to the event so the app
doesn't have to calculate them.  For reverse compatibility, the old
fields will still exist.

Closes #698

Change-Id: Icbaf3619aedfca7ea06bc8b1fe49e9cce65b0cc2
2017-02-23 19:36:06 +00:00
Jacob Trimble cc3e34552f Fix track selection in Storage.
There was a bug where Storage would always store every track,
independent of what was chosen.  This fixes it and adds a test so this
doesn't happen again.

This also updates the ManifestParser API usage Storage.  It was
updated in 2ca962a3 and Storage was not updated.

Change-Id: Id3b8ee143cec6c4d099a9628c90dc3c927ea8625
2017-02-21 15:47:41 -08:00
Aaron Vaage 3db0f3357a Creating IStorageEngine Interface
To better support alternate storage mechanisms, this change abstracts
shaka.offline.DBEngine into an interface called
shaka.offline.IStorageEngine.

DBEngine has been changed to implement this interface, and allows the
addition of implementations that do not use IndexedDB.

Change-Id: I6a94067001ee53049df11cb68604bb57912300bb
2017-02-10 21:27:32 +00:00
Joey Parrish 8ba088a38f Generate externs automatically
We were not able to get our externs generated by the Closure compiler.
There were many issues with the Closure-generated externs, including
the order of the externs and the replacement of record types and enums
with their underlying types.

We made a few attempts to patch the compiler, but could not get our
patches accepted upstream.

This change introduces a new script to generate our externs from
scratch.  It uses a JavaScript parser called 'esprima'.

Some interfaces need to be exported to the generated externs, but are
not actually attached to the namespace by the compiler.  For this, we
introduce a new annotation.  These are the currently-supported export
annotations:

 - @export: truly exported (attached to namespace) by the compiler
 - @expose: truly exposed (not renamed) by the compiler
 - @exportDoc: considered part of the exports in the docs
 - @exportInterface: considered part of the exports in generated externs

These annotations are now documented in docs/design/export.md

Change-Id: I33bf7384889c14c9edb0fa5f11caa7c4f4d79af6
2017-02-01 11:42:16 -08:00
Jacob Trimble 2ca962a33c Refactor ManifestParser.start to accept an object.
Rather than accepting multiple callback methods as separate arguments,
now start() will accept an object.  This will allow us to add new
callbacks without breaking backwards compatibility or adding
additional arguments.

Change-Id: I839cbb12e71c2e7270aa218802c79440c458e964
2017-01-19 22:54:09 +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
Joey Parrish efa1108a19 Add additional docs for offline storage
This adds additional text explaining how to use the Storage API.

Change-Id: Icff55d6fe19e91f983ffb3e4a786f2beefe9ae8f
2017-01-13 00:56:49 +00:00
Jacob Trimble 66963dc232 Add tests for OfflineUtils.reconstructPeriod.
Change-Id: I936a0667de97b2210e9d32cde89c43561c81b4c8
2017-01-12 20:03:26 +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 c6451690e6 DASH trick mode support
Parses DASH trick mode tracks and puts the extra trick mode Stream
into the manifest.  StreamingEngine can now use this info to optimize
streaming during trick play mode.

Includes:
 - a new demo asset with a trick mode track
 - updates to tests (we now require at least one audio or video stream
   and we require bandwidth attributes on them)
 - updates to the parser's trickmode test
 - a new StreamingEngine test

Closes #538

Change-Id: Id38264ca64bc7905a5c33a269269741cfd12dd4d
2017-01-05 04:45:10 +00:00
Joey Parrish 1bfdecf311 Ban ES6 Array and String methods
This bans the use of Array and String methods introduced in ES6.
These are not implemented in IE11, so their use is not allowed.

This also replaces our recently-introduced use of these methods to
fix test failures on IE11.

Change-Id: I3175a2e60b708d490997387a41d42ca4662e5fa8
2017-01-03 15:39:35 -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 18da8e04dc Export all plugins
This exports all plugins from the library, to make delegating and
subclassing easier for applications.

This also fixes a couple of issues with the generated documentation.

Closes #551

Change-Id: I23798f6117e1944d7ffc67bcb50ae36f3943710a
2016-11-14 23:58:09 +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 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
Sandra Lokshina 05a5fb9d19 Revert use of new Function() in player config.
Chrome App Content Security Policy prohibits use of new Fuction()
method. Revert the change that introduced it.

Closes #487

Change-Id: Id38522318affb9c5be8f6d2f4446e2967b43f58b
2016-08-26 22:32:14 +00:00
Joey Parrish 3715c9a435 Merge pull request #459 from hochhaus/nontrivial_return
Add JSDoc to functions with non-trivial return values
2016-07-24 11:32:37 -07:00
Andy Hochhaus 2381e27406 Add JSDoc to functions with non-trivial return values 2016-07-23 23:35:51 -07:00
Andy Hochhaus 6a00ee8a31 Add missing goog.require 2016-07-23 14:42:38 -07: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
Jacob Trimble 858d3a55c7 Give warning when storing tracks of the same type.
When storing multiple tracks with the same type/kind/language, issue
a warning, since adaptation does not make much sense when playing
stored content.

Change-Id: I75d1625b2de680ae06728862d27b50272b951b7f
2016-07-13 16:16:04 +00:00
Jacob Trimble d17c9ddf22 Download different content types in parallel when storing.
Change-Id: Id66a6de7953e4c9678bbd39837d8b89601a43f8b
2016-07-11 16:10:44 -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
Jacob Trimble beb902e826 Move common code in offline to offline_utils.
Added new offline_utils.js to hold utility methods for offline
support.  This also removes a circular dependency between
Storage and DownloadManager.

Closes #431

Change-Id: I98842c63c7ba57d4d02d7fe6bace57227982317c
2016-06-30 19:49:51 +00:00
Jacob Trimble ad6a9daa68 Change the offline UI for demo app.
Now the demo assets can only be stored once, if an asset is stored
the store button will disable.  Combined the store and delete buttons
into one.  Added a text box to set the name of the asset when
storing custom assets.  Also add export to Storage.destroy so it
works in the compiled version.

b/29777213

Change-Id: I7972a7931166c67efcffe70f5017a920cca617ef
2016-06-29 20:30:05 +00:00
Jacob Trimble 85fe4438b6 Various fixes for offline playback.
* Remove warnings for incorrect argument counts in configure.
* Duration incorrect for multi-Period.
* Multi-Period does not always work with multi-codec.
* Progress meter visible from start and after done.
* Offline buttons enable while storing if asset is switched.

b/29777213

Change-Id: I934bec0e6b5be2d69a908629b187459a6289f7a7
2016-06-28 23:29:10 +00:00
Andy Hochhaus 87a62d717e Add missing goog.require() dependencies 2016-06-25 15:45:15 -07: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