Commit Graph

173 Commits

Author SHA1 Message Date
Theodore Abshire 087c1ba247 Allow offline downloads to be aborted.
You can either abort downloads one at a time, using the
AbortableOperation interface, or you can implicitly abort them all at
once by destroying the storage instance.

Closes #2417
Closes #1362
Issue #1301

Change-Id: I0ba102e5bf60a063f0e2f6ecd3f135445226996f
2020-04-24 20:43:54 +00:00
Álvaro Velad Galván 2807971e4e Add creationTime to offline assets (#2406) 2020-04-10 09:58:45 -07:00
Theodore Abshire a2a988d876 Allow for multiple concurrent storage operations.
In the process, this removes the in-progress flag, which should fix
issues where the storage instance can't be re-used after an error.

Closes #1432
Closes #2432

Change-Id: I51018e170fb9ab262b5c70125a03d979c8ccfb08
2020-04-10 04:33:11 +00:00
Joey Parrish ba5d062be6 Fix missing segments in offline storage
In Change-Id If885e828b4761528e40abdbc601a11cf13849a1e, I fixed a
memory leak, but broke offline storage.

The fix for the memory leak was to release SegmentIndexes and
SegmentReferences when the DASH parser stops, but offline storage was
stopping the parser before making use of the parsed manifest.

This changes offline storage to keep the parser alive until after the
storage operation is complete.

This bug did not affect any release versions.

Change-Id: I88b86d250b4407cc0740d35eaf4a7ef3d5a67798
2020-04-09 17:40:44 -07:00
Joey Parrish c4a5513ca5 Rename offline StreamDB.contentType to type
This brings the field name in line with the Stream objects from the
manifest types, allowing for more general processing of Stream and
StreamDB for period-flattening.

Issue #1339

Change-Id: Ic5d0e5d69a6560d475a19f5d3ecb0b1b40b8d271
2020-04-09 19:22:16 +00:00
Joey Parrish e8ac57f36c Move drmInfos array to Stream
Period-flattening will concatenate Stream objects, so this information
should be available per-Stream instead of at the Variant level.

Issue #1339

Change-Id: I96195fea48cab1e4a349b2ab0b16064a443e928a
2020-04-09 19:22:16 +00:00
Joey Parrish 99de217c23 Remove periods from manifest structure
This removes periods from the internal manifest structure and cleans
up code and tests accordingly.  This leaves us unable to play
multi-period DASH & offline streams until the main period-flattening
algorithm is completed in shaka.util.Periods.

Three test cases have been disabled for the moment.

Multi-period playback will be restored in a smaller, more focused
follow-up commit, with disabled tests re-enabled.

Issue #1339 (flatten periods)
Issue #1698 (rapid period transitions issue)
Issue #856 (audio change causes bitrate change)
Closes #892 (refactor StreamingEngine)

Change-Id: I0cbf3b56bfdb51add15229df323b902f0b2e643a
2020-04-09 19:22:16 +00:00
Theodore Abshire ae568e0649 Fix offline picking high-bandwidth codecs.
When playing an asset, the player will first choose a codec, based
on the lowest average bandwidth.
However, the storage mechanism did not have any such filtering;
instead, all it did (if using the default track filtering plugin) was
pick the middle-bandwidth audio track. This lead to it sometimes making
different codec decisions than the player would have.
This CL breaks the codec filtering logic out into a helper function, and
calls it both for playback and storage.

It also adds headers comments to some functions in the demo page.

Closes #2390

Change-Id: I09f1a24753121afd0e7500577c0f64ccffe5a4d1
2020-04-02 22:46:10 +00:00
Joey Parrish 6202b9372e Revert "Move next-segment tracking to SegmentIndex"
This reverts commit 235e4e11ad.

The effort to remove SegmentReference's position field will be handled
in a different way.

Issue #892 (refactor StreamingEngine)
Issue #1339 (period flattening)

Change-Id: I62b115137abc89f498b30467e574b0401dcad05d
2020-03-23 10:09:35 -07:00
michellezhuo c82ff51d1f Add a presentationDelay config for HLS live
Closes #2373

Change-Id: I627bbd226ed9cab9bc476e2c2a3257d2e2dbc0e9
2020-03-11 18:41:15 +00:00
Joey Parrish 235e4e11ad Move next-segment tracking to SegmentIndex
As part of Period-flattening, I'm trying to reduce our dependence on
the "position" field of SegmentReference.  If it can be eliminated, we
can more easily concatenate Arrays of SegmentReferences without
modifying them.

SegmentIndex can now track the last reference you asked for and
iterate through the list of references.  This means we don't need the
"position" field of SegmentReference, which means we don't need to
know positions in advance or globally.  StreamingEngine will no longer
use position to request segments.

The old methods find(time):position and get(position):SegmentReference
have been replaced with seek(time), current(), and next(), all of
which return a SegmentReference and maintain an internal pointer to
the "current" reference.  Care has been taken to maintain that pointer
during the evict() and fit() operations.  Recent changes to merge()
made sure that the pointer does not need to change during that
operation.

All test updates are related to the SegmentIndex API change, not
changing expectations or behavior.

Issue #892 (refactor StreamingEngine)
Issue #1339 (period flattening)

Change-Id: I1682dcc2dd625c6e390711538e46d31e6eb6cea8
2020-03-11 18:14:14 +00:00
Jacob Trimble c49f24b31b Remove remaining deprecated features for v2.6.
Change-Id: I2199e3c960fe6319eb9ab342291dfd9a62d9090e
2020-02-24 15:57:05 -08:00
Álvaro Velad Galván b2672e305d Fix download contents with Widevine and Playready in the manifest. (#2400) 2020-02-21 13:12:46 -08:00
Jacob Trimble bc45564721 Remove deprecated ability to pass factories to load.
Player.load and Storage.store used to accept the manifest parser factory
directly.  But now they should only accept the MIME type string.  This
removes the deprecated functionality in preparation for v2.6.

Change-Id: I1b4c5a4a9f0b6edbea909d18111ddc87a39da331
2020-02-20 23:44:51 +00:00
Jacob Trimble 3f63021a2f Avoid using "new" with factories.
Instead of having the "factories" use "new" to construct them, now they
will be plain functions.

Closes #1521

Change-Id: Ia6151ad679a78a5c6db128d43094c82add0af348
2020-02-19 09:57:51 -08:00
Joey Parrish b1e13fa658 Fix async tracks callback
PR #2387 introduced a bug. It awaited the track selection callback,
but that was done in a loop, the results of which were not awaited.
This would cause storage to continue before the complete list of
tracks was available.

Closes #2383

Change-Id: I18a429cf0f40b829020c520c622ffdae8b12622e
2020-02-14 15:13:03 -08:00
Joey Parrish 0406bc0da9 Fix duplicate stream storage in offline content
Since v2.5.0, we have been storing duplicate streams for multi-period
offline content.  For example, instead of storing one stream per
period, a 3-period manifest would have 3 streams per period.  The
segment data would also be duplicated, leading to 3x the storage used
for a 3-period manifest.

This fixes the error for future content and ensures that the correct
number of variants are still shown when this broken content is loaded.

This change also tweaks the frameRate field in the existing database
dumps, which for some reason contained the wrong value for the
existing v1-v3 dumps.  This must have been a bug we fixed already.  To
make the expected results consistent across dumps, the frameRate value
in the old dumps has been updated.

Closes #2389

Change-Id: Ibf7db7543f25ad23cecd12efad1eb039630e381c
2020-02-14 19:59:12 +00:00
Álvaro Velad Galván 059e2a9a08 Make trackSelectionCallback async (#2387)
Resolves #2383
2020-02-12 13:11:17 -08:00
Jacob Trimble 011749e95f Standardize argument comments.
This changes the eslint rule to enforce a strict pattern for the
argument comments.  The comment must appear before the argument and
must be /* foo= */.  This still ignores line comments.

Change-Id: I3afb01c65e1088eda13facb3aeeaa7595a2f5aee
2020-01-06 19:40:52 +00:00
Álvaro Velad Galván bdca05ff4b Add pixelAspectRatio property from DASH (#2294) 2020-01-06 10:56:28 -08:00
Joey Parrish 41a8664dba Make segment references independent of periods
This is a step along the way to flattening periods, and also
simplifies a few small things in StreamingEngine and tests.

Issue #1339 (flatten periods)
Issue #892 (refactor StreamingEngine)

Change-Id: Ie17cd5e15ed6ec9290a918c3a69c05c74581e0fc
2020-01-02 19:03:18 +00:00
Joey Parrish c13830e535 Augment SegmentReference with offset and window
SegmentReference used to have presentationTimeOffset, which,
subtracted from the period start time, was then _added_ to the
timestamps in the segment by MediaSource.

Now, SegmentReference has a timestampOffset field, which is exactly
what MediaSource's timestampOffset field is set to on the SourceBuffer
before this segment is appended.  For DASH, this is periodStart minus
presentationTimeOffset.

This also adds append window start & end times to the
SegmentReference.  Now segments can be appended to SourceBuffers
without reference to the period.

Note that start & end times of the SegmentReference in each segment
index are still relative to the period.  This will change in a
follow-up.

Issue #1339 (flatten periods)
Issue #892 (refactor StreamingEngine)

Change-Id: I9d54eb2b529ec643c9475b8e9d218c3e2e826a26
2019-12-19 11:35:14 -08:00
Joey Parrish 64896d70b0 Use shorter license header
This reflects changes in Google's policy on JavaScript license
headers, which should be smaller to avoid increasing the size of the
binary unnecessarily.

This also updates the company name from "Google, Inc" to "Google LLC".

Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
2019-11-22 18:18:36 +00:00
Jacob Trimble c56fe7db19 Fix and cleanup offline without init data.
The PR to add support for pulling EME init data from the segments was
incorrect and had some bugs.  This stops re-initializing DrmEngine since
this isn't needed and could cause problems with the offline licenses.
This also just uses the Pssh helper once to parse and extract the
init data.  Lastly this throws the old error if we don't have any
sessions when we are done;  if we try to store WebM content, we should
still throw if there is no init data in the manifest.

Issue #1531

Change-Id: Ie524abda993a076397e233008709f11a2e68a8f8
2019-11-05 23:33:54 +00:00
Álvaro Velad Galván 5eaca0aebd Offline license support for manifests without inline init data (#2164)
Closes #1531
2019-10-17 14:53:34 -07:00
Joey Parrish 625938e2f9 Revert offline PSSH support for manifest that are missing inline init data
This reverts commit 6e5a0797de, #2042.

The PR as it landed broke some test cases and functionality for storing persistent licenses, and it doesn't seem to work even for its intended use case.
2019-08-02 16:56:24 -07:00
Joey Parrish 7fe97b841b Move fields to SegmentReference
To prepare for flattening out the manifest structure to remove
periods, this change moves initSegmentReference and
presentationTimeOffset fields into the SegmentReference object.  This
way, the segments on either side of a period transition or HLS
discontinuity can have different offsets or init segments, eventually
allowing us to create a single array of SegmentReferences for
multi-period content.

Issue #1339

Change-Id: Ic7eff0483789644881247ecf8044c5fb6a48f0e6
2019-08-01 11:04:36 -07:00
Ante Wall 6e5a0797de feature: Offline PSSH support for manifest that are missing inline init data (#2042)
* fix: Reference issue with SegmentReference createUris

* test: Added Segment GetUris Test for timeline

* feat: Get PSSH from segements if not initdata exists

* feat: Get PSSH from segements if not initdata exists

* fix: JSDoc comments and moved drmEngine update to storage

* fix: Remove comments

* fix: Remove unused import

* fix: Lint erros and dedup initData code

* fix: remove no init data test and add check for use persistent license
2019-07-26 11:01:05 -07:00
Joey Parrish 08cec995c9 Replace find/get callbacks with SegmentIndex
This replaces find/get callbacks in Stream with a SegmentIndex.  With
the exception of DASH's SegmentTemplate+duration, all manifests were
already backed by SegmentIndex.  Now, all manifests are backed by
SegmentIndex.  This will simplify Period-flattening, in which all
tracks will be represented by a list of segments, some of which come
from different Periods.

The SegmentIndex in Stream will not be created until
createSegmentIndex is called.  Prior to this change, the find/get
callbacks could be invoked without createSegmentIndex() in some cases
(excluding DASH's SegmentBase), which some lazy tests took advantage
of.  Now that find/get are methods on SegmentIndex, createSegmentIndex
must be called in all cases.  The tests have been updated accordingly.

Making SegmentIndex generation async in all cases exposed some issues
with the parser context being modified in-place between one
Representation and the next.  So the parser now makes a shallow copy
of the context before it is bound into an async callback.

To facilitate updating the SegmentIndex for SegmentTemplate+duration
content, SegmentIndex now has a method to update its list on a timer.
Once per segment duration, the index will be updated to add and remove
SegmentReferences.

The initial expansion of SegmentTemplate+duration will be limited to a
relatively small number of segments, to avoid excessive CPU or memory
consumption.  This defaults to 1000 segments, but is configurable.

Issue #1339

Change-Id: I99c007b1096c3b396d04a729750cd7b743cb899d
2019-07-08 22:22:13 +00:00
Jacob Trimble 001c3c7b8c Add check for common misspellings.
Change-Id: Iaf546678ed787724513ed21b19a78cc895f069e8
2019-07-08 12:08:45 -07:00
Jacob Trimble 28cc9f6f9d Favor includes over indexOf.
Change-Id: I78a8334c025fe11d485cb2f9cb7cb4cb7dcb6c2c
2019-06-27 11:54:11 -07:00
Jacob Trimble f6d0f15fa6 Refactor handling of destroy().
This changes several classes to use the Destroyer class to handle
destroy().  This also changes the behavior to not ignore destruction
and instead throw a new error.  This is more clear for callers and
ensures we propagate errors.

Change-Id: I756c085639558509c22e5c43d69ddf4acd28d46f
2019-06-19 20:39:20 +00:00
Jacob Trimble 4c2469ce5e Convert offline files to ES6.
Issue #1157

Change-Id: I74e8db322bfcff7d502307d12108e9b4157a11e1
2019-05-21 16:03:53 +00:00
Jacob Trimble f130dffcef Enable eslint indentation rule.
This is a fully automated change.  The linter will fail because the
extra indentation caused line-length errors.  These won't be fixed
automatically.  They are fixed in a follow-up to make this one fully
automated.

Change-Id: I4d8cf9c998985add2bcd24a81c8d65495668c4f3
2019-05-13 22:31:09 +00:00
Jacob Trimble 0dd64074b9 Only allow one statement per line.
With the new style rule, we cannot have two statements on the same line.
So we can no longer have an "if" on a single line and we cannot have
an arrow function with a body on the same line as when it is used.
This is mostly a manual change.

Change-Id: I2285202dd5ecbad764308bc725e6d317ff2ee7f0
2019-05-13 22:11:50 +00:00
Jacob Trimble ded2b84313 Require consistent return values.
This enables the eslint rule that requires all functions to consistently
either return a value or not return a value.

Change-Id: I98b579f3689c3b6c74968116824231bb792bd9dd
2019-05-09 20:34:47 +00:00
Joey Parrish ab6f9cfd3d Allow short-form config for UI and offline
With this change, offline and UI config can use the same two-argument
short form that the Player config interface offers.

Change-Id: I5f40ef58da76f3aab1d7178fe7d6e82097352b9a
2019-05-09 19:34:01 +00:00
Jacob Trimble 47daf49f31 Use arrow functions for callbacks.
This is an automated change to convert use of "function" functions
to arrow functions.  This doesn't change all uses of bind() that
could be converted.  This also doesn't remove all "function" functions.

Change-Id: I40ac7d086bcef947a1be083359c8fd1d4499a9c3
2019-05-09 16:40:46 +00:00
Jacob Trimble c81389741f Prefer const over let.
A coming update to the Google eslint config will require using "const"
over "let".  This makes that one change to isolate the big changes.

Change-Id: I7d0974c3ae15c53cc45a6b07bf9f6586e2d34aca
2019-05-08 09:22:10 -07:00
Theodore Abshire 0ddff4f7ea Add support for multiple concurrent downloads.
At the moment, the storage manager does not support multiple concurrent
downloads. This modifies the demo to create a new storage instance every
time a storage operation is desired, then dispose of that instance after
the operation is complete.
This also refactors out the shaka-main-offline-changed event, which was
no longer necessary after allowing asset cards to re-load their buttons.

Issue #1432

Change-Id: I1312cf74a92f877279adb461e423a38e93bcfa0f
2019-05-07 16:31:15 -07:00
Joey Parrish 61735055a9 Ban storage on non-MSE browsers
Without MediaSource, we can't play back stored content.

Issue #1911

Change-Id: Ifb01b8ca3f837e923f5afd6aefae2e0687743cf4
2019-05-06 16:13:43 +00:00
Joey Parrish 685e9d57cf Eliminate free calls of static methods
It is type-safe to alias a class, but not one of its static methods.
Aliasing the method without the class makes it a "free call" to invoke
the aliased method.

A "free call" is when you call a method without the context of its
instance of class.  There were several cases of this with static
methods.

This will be enforced by a future release of the compiler, which I
believe will lead into compiler support for "this" in static ES6
methods.  In ES6, you can use "this" in static methods to refer to the
class and call other static methods.  Closure compiler doesn't support
static "this" yet, but we will start using it as soon as it is
supported.

Change-Id: I4249db8b6dda9231ebba60ee0d4ad734a692c2fe
2019-05-03 18:43:35 +00:00
Joey Parrish 2fa3cf39de Silence errors about deprecated configs
We support these older ones and warn about the deprecation, so do not
also leave the older configs and trigger an error from configure.

Change-Id: I49e25e43ce556ff54ad3c1f1408699ff36c31833
2019-04-17 23:12:35 +00:00
Aaron Vaage 25710b6c33 Refactor Segment Request Creation To Be Shared
In four different places in our code base, we did the same
work to create a segment request. The bulk of the work was
based on setting-up the range header.

This CL creates a common utility that will create the request
for us while keeping networking engine as ignorant to segments
as it was before.

Issue #1788

Change-Id: Ie3dc2a99a34b3925fecbfdaae7b1e178a0b7a3b6
2019-03-12 21:18:27 +00:00
Aaron Vaage 2c33d519ff Remove Destroyer.with
Replace the last use of |Destroyer.with| in the library. The final use
was in Storage, and this CL replaces that last usage with try-finally.

Close #1516

Change-Id: Ic0946a564b66a48b567ffd6d1cfd4b9ec76fc039
2019-03-08 01:28:55 +00:00
Aaron Vaage 9f0b16da16 Use try-finally in |Storage.remove_|
To make it easier to work with destroyable objects, we defined
|Destroyable.with|, but it looks like using try-finally may be easier.
This CL replaces the use of |Destroyer.with| in |Storage.remove_| with
try-finally.

Issue #1516

Change-Id: I75563335f5a5865f93bc1eb21346300c36e0a13e
2019-03-08 00:57:36 +00:00
Aaron Vaage 3c4a6e2e9a Use try-finally in Storage.list
To make it easier to work with destroyable objects, we defined
|Destroyable.with|, but it looks like using try-finally may be easier.
This CL replaces the use of |Destroyer.with| in |Storage.list| with
try-finally.

Issue #1516

Change-Id: I29dcda7e8990402f0edb5885eed1c546ab28400e
2019-03-07 18:10:17 +00:00
Aaron Vaage 71e8c4936d Refactor getAllVariants
Refactored |StreamUtils.getAllVariants| to get variants from a collection
of periods (rather than a manifest). This allows us to avoid needing to
assert that the manifest exists (when we know it will).

Looking long-term, as part of the refactor the method was moved to a
period-focused utility class. The goal of this is to make it easier to
see what methods may go away when we flatten periods.

Change-Id: I50aa97583892361ee4714a7beaf61e4cd95fb6b4
2019-02-26 17:22:15 +00:00
Aaron Vaage 2cef461cb7 Refactor Manifest Parser Creation
Rather than have the manifest parser class return the factory
that we then need to call "new" on, we can just have the manifest
parser class return the parser.

This makes the call-sites in Player and Storage simpler and moves
the use of factory+new to one spot so that it will be easier to
remove in 2.6.

Change-Id: I2abb8da603c9226c230bb761a20eb8dd20fc8455
2019-02-15 21:50:50 +00:00
Aaron Vaage 2d00211dda Refactor DownloadManager to limit internal complexity
Download manager would previously queue all the requests and
then start them after |download| was called.

By making download manager start downloading each group once
the group is created, it allowed for the internals of download
manager to be simplified.

With this simplification, it is far easier to understand how the
destroy flow works.

Change-Id: Ie2d7776eae4224e2ff1c607353c22750daa4c14f
2019-01-22 23:06:45 +00:00