Commit Graph

84 Commits

Author SHA1 Message Date
Joey Parrish a17e904261 Add upgrade guide for v2.2 => v2.3
Issue #1183

Change-Id: Ib933603dd5ea35e1aa2c600970ce71a9a0a37b2e
2017-12-20 03:02:52 +00:00
Joey Parrish cbdbfbdec7 Update changelog for v2.3
Issue #1183

Change-Id: Ia25fba9e5f8149c12f55a8486ca3eb6bcd4131ea
2017-12-20 03:02:52 +00:00
Aaron Vaage 1cf0a38843 Support Upgrading from Version 1 to Version 2
Added a DB Upgrade path for converting content from version 1
to the version 2 format.

Issue #1047

Change-Id: Id8dc626d8289b08ca300c40b137173c0c6ec9d35
2017-12-18 19:04:04 +00:00
Aaron Vaage 967f339934 Mark Version 2 of DB Engine
externs/shaka/offline.js now represents the data types for Shaka Player
Offline V2. All offline shaka player code uses the new version and all
V1 and transitional code has been removed.

Issue #1047

Change-Id: Ia43f8d8d11426e823629e5fcd27c4e1e0ce400d3
2017-12-16 00:11:04 +00:00
Aaron Vaage cbaefcf475 Use Auto Increment For IndexedDB
Changed our stores in IndexedDB to use auto increment for the keys
so that we no longer need to track current ids anymore.

Issue #1047

Change-Id: I765ba19810fce03ec8e4d968cbf8cf383355be6d
2017-12-14 15:47:31 -08:00
Aaron Vaage 14e6b3a230 Create Upgrade Pattern
Create the pattern for how to handle database upgrades. As of this
change the only upgrade supported is from version 0 (no database).

Issue #1047

Change-Id: I9f889a9e39a190e926cf06f0720a5371bc3c59af
2017-12-14 14:53:48 -08:00
Aaron Vaage 80c5fff4b2 Create DBUtils
Create DBUtils to hold code that will be useful to updating code
outside of DBEngine.

Issue #1047

Change-Id: If759fd0d778f42e6114e82e9274a053af420ad35
2017-12-14 22:51:55 +00:00
Joey Parrish 4ce963415e Fix offline storage with temporary license issues
This change:
 - Fixes the use of temporary licenses with manifests without init data
 - Re-enables an integration test which was accidentally disabled
 - Makes that test use a manifest without init data, to cover #1159
 - Makes the test less flaky
 - Reduces the minBufferTime of offline manifests, which both speeds
   up load of offline content and makes the test faster / less flaky

Closes #1159

Change-Id: I3342e5112564a607f16f5d10c457a032443c57cb
2017-12-14 21:36:08 +00:00
Aaron Vaage c927300045 Store keys instead of uris in DB objects
Instead of storing uris for SegmentDataDB in SegmentDB, store the
actual key so that we don't need to convert back-and-forth so
often.

Issue #1047

Change-Id: I2f6d1bc1e58abd7a210097dea757d1e2fc9d4cac
2017-12-14 21:34:49 +00:00
Aaron Vaage 46685fbd15 Moving Offline Uri
Moving offline uri code to avoid an upcoming circular dependency in
the upgrade code.

Change-Id: I952386f17c6d4e7806d97e2f540887b915f68de7
2017-12-14 00:00:23 +00:00
Aaron Vaage 3399292d49 Changed Storage Remove API
Changed the storage remove API to use the offline uri instead of
the stored content as that is all that is needed to remove the
content.

Updated the demo app to remove using the Uri and not stored content.

Change-Id: I72a1049838759452eb16c78c8f1f7f4170e4e841
2017-12-12 22:12:56 +00:00
Aaron Vaage dff382b9a3 Remove reserve id from StorageEngine
Removed the reserve id from storage engine. Now adding an item to a
storage engine will return a promise that resolves with the id it
was stored under.

Change-Id: Id4d2c4c51a359593f1308aeb5fe580ab460ebeb8
2017-12-12 13:28:33 -08:00
Aaron Vaage b53f5a0816 Isolate download logic from error handling
In |Storage.store| there was download logic hidden by error handling.
This change moves the logic into its own function so that the error
handling does not hide the logic as much.

Change-Id: I3fc911573937f4543837015cf2500a1447d923ef
2017-12-12 12:43:54 -08:00
Aaron Vaage 8f45f7939d Changed Stored Content to not always need an offline uri
Before, stored content always needed an offline uri. As the id
will soon not be available before saving to storage, stored
content needed a way to represent content that was being
downloaded.

This change allows the offline uri to be null to represent content
that is being downloaded. It also allowed stored content to be
created from a Manifest (for content to be downloaded) and to be
created from a ManfiestDB (for content already downloaded).

Change-Id: I3039069995f0b061112ed0c636a53ceef5673389
2017-12-11 23:21:12 +00:00
Aaron Vaage 6a03ceb30f Isolate Progress Code
Isolated all progress code into functions in Storage to help abstract
progress from the storage logic.

Change-Id: I7a72c25dbd126cb4a5e682763fb1e46afa0703ef
2017-12-08 21:17:20 +00:00
Joey Parrish 0a59da4146 Free segment memory after storage
Although DownloadManager clears the segment list as soon as it has
started the download Promise chain, the entire list is bound into the
each download function.  This is subtle and difficult to address
directly.

Instead, we set the segment data to null explicitly after the segment
is stored.  In this way, we are sure to only have one segment buffer
in memory at a time during a storage operation.

Note that there is no regression test to go along with this, because
ArrayBuffer memory consumption cannot be directly instrumented from
JavaScript, weak references cannot be used to track which buffers are
garbage collected, and the buffer references are bound into anonymous
functions and therefore cannot be found by exploring object
hierarchies.

Closes #1167

Change-Id: Ifeccbfb2d15a1a0243524c92e36512f9308fd5c6
2017-12-08 12:12:47 -08:00
Aaron Vaage 834d960f88 Use Manifest Duration for Offline Manifest Duration
Use the duration from the original manifest as the duration for the
offline manifest.

Change-Id: I1b31888ecf25126e4a4794f73ea3aeaf101e5820
2017-12-07 21:38:43 +00:00
Aaron Vaage 2f47e6d769 Moved Legacy Variant Ids Resolution into DBEngine
Before we added variants, there was no variant ids field on
StreamDB. To support legacy downloads, we created variants
for streams with no variantIds.

This change moves that conversion into DBEngine so that outside
DBEngine, streams will always have variantIds.

Change-Id: I85d050dac0b5f82fe00947380587dd7af4401dee
2017-12-06 00:39:07 +00:00
Aaron Vaage b98ce99f08 Add Type Structure to Storage Engine
Changed the Storage Engine interface to know about the types that it
is expected to store. This allow the implementation to do more internally
as the scope of the object has been limited.

Change-Id: I388e2bde5e7e3f99e8b28bd16e08a8f6d5fc6453
2017-12-04 22:41:23 +00:00
Aaron Vaage b68623180c Simplified Offline Schema
Before, segments required knowledge of the manifest and stream to
be created but that information was never used. This change removes
that information from the segments and breaks the circular dependency
between manifests, periods, and segments.

Change-Id: I94064220dd8e3693ff69f5c9100ec1b91aa3c34d
2017-11-27 21:17:07 +00:00
Aaron Vaage ee006d4523 Consolidate Mocking IStorageEngine In Tests
To make it easier (and more consistent) to mock the default storage
engine in our tests, this change introduces StorageEngineFactory and
MockStorageEngineFactory.

StorageEngineFactory is now used to create instances of IStorageEngine
in the library. MockStorageEngineFactory makes it easy to override
specific parts of StorageEngineFactory.

Change-Id: Icd28b7f4913add1318a24f436e54b3c694312d2c
2017-11-08 16:28:16 -08:00
Aaron Vaage 3cd9b6af3e Clean-up recreateVariants
Before if a stream was used on multiple variants, it would be created
multiple times. This change ensures that each stream is only created
once.

This change also makes use of standard array functions rather than
manual indexing with the goal to be easier to understand.

Change-Id: I87e3414ac8b63f6f45ef670f863325c920688f87
2017-11-03 11:47:23 -07:00
Aaron Vaage ddf8cb838e Renamed getStoredContent to createStoredContent
Since getStoredContent created a StoredContent from a ManifestDB
instance, createStoredContent better described the action of the
method.

Change-Id: I9893b956e08761d8bb3c4073626ed840240e2ac8
2017-11-03 18:09:32 +00:00
Aaron Vaage 9e04388292 Regression Test for Variant Recreation
Added tests for how we recreate variants from StreamDB instances.

This change does make createVariants public, but as it does not use any
internal state, there should be no reason to hide it especially as it allows
us to test it directly.

This change renames createVariants to recreateVariants to better represent
what it is doing.

Change-Id: I5a770d690e582d95b7f31a4b656f86a4bbfce7bb
2017-11-02 17:30:31 +00:00
Aaron Vaage f4d655deb1 Changed filterNewPeriods to take audio and video separately
To prevent us from packing and unpacking audio and video from an object
this changes filterNewPeriod to just take audio and video rather than
a map.

Change-Id: I152f2b1762d4ff9ce21cb5b501579bca315e4e4a
2017-11-01 17:18:22 -07:00
Aaron Vaage 07e81f7bc9 Move all uri parsing and creation to Scheme
Moved all the logic that is used to construct and parse uris for
manifests and segments into the offline scheme file.

Change-Id: Ie4dbd12256667296e3c67ed0ecf47f1752dd86eb
2017-10-27 20:08:28 +00:00
Chris Fillmore d1ddd720c2 Publish an event from DrmEngine if the CDM accepts the license. (#1049)
Closes #1035
2017-10-04 15:37:25 -07:00
Joey Parrish c6e5be493e Fix filtering in offline storage
The offline storage system did not completely implement the interface
used by the manifest parsers.  This fixes the interface and makes sure
that existing tests will cover the use of this interface.

Closes #988

Change-Id: Ib8ccae56b144edbfdc9d3fcd865924faf620eb44
2017-08-24 22:03:23 +00:00
Michelle Zhuo d67764b5ff New Error Code for Content unsupported by Browser
Previously "UNPLAYABLE_PERIOD" exception is thrown when a browser
doesn't support the container or codecs in a piece of content, which is
confusing to developers and customers.
Changing it to "CONTENT_NOT_SUPPORTED_BY_BROWSER" exception.

Test manifest:
https://media-ci.foxford.ru/dist/hls-issue/issue.master.m3u8

Closes #868.

Change-Id: Ied135b687190919abbeb1561c2bff36a7203136e
2017-08-04 11:07:07 -07:00
Joey Parrish 015b4f456f Revert timeline correction code.
This reverts commit 478fb1a473
("Detect and attempt to correct timeline sync issues") and commit
4334b6ea90 ("Add mediaSegmentReferences
 to shakaExtern.Stream").

Timeline correction only addresses one class of broken live content,
while actually making it more difficult to diagnose other classes of
broken live content.

Issue #933

Change-Id: Ie71b8a45600ed0994626f53268fb90e336c3c62b
2017-07-31 10:42:33 -07:00
Joey Parrish 4334b6ea90 Add mediaSegmentReferences to shakaExtern.Stream.
This will allow us, in many cases, to detect time sync issues in
content by comparing the media segment references to the presentation
timeline.  If the references are outside the timeline, it may indicate
a common form of bad content, and we may be able to attempt to correct
it.

In some cases, the references are not available upfront.  We can't
detect time sync issues in DASH with SegmentTemplate+duration, because
the references are not explicitly described by the manifest.  We can't
detect time sync issues in DASH with SegmentBase, because the segment
index requires additional fetching and parsing.  (SegmentBase is not
used with live content, so this should be a non-issue.)

This only introduces the new data, but does not use it for detection
or correction yet.

Issue #933

Change-Id: If70b1bdbd3b08a7c8b7ae296da209737492dfe17
2017-07-25 20:13:42 +00:00
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