Commit Graph

280 Commits

Author SHA1 Message Date
Aaron Vaage 85b61a3a78 Remove Use of MapUtils.values in shaka/offline
Went through all the class in shaka/offline and removed all uses
of |MapUtils.values|. This required changing many uses of Object
to Map.

Change-Id: I6bd6d37009e7b32ea38e9cbabd64c2d36ffeabbc
2018-09-14 21:41:45 +00:00
Joey Parrish 7091275cbf Replace indexOf with includes, startsWith
This replaces almost every instance of indexOf on both String and
Array.  There are very few places where we really wanted an index.
Mostly, indexOf was used to check for inclusion.

Change-Id: I08e299768b6ffdb4bfc30b39b5d82a058c6d1b56
2018-09-14 19:10:56 +00:00
Michelle Zhuo 5de57c0725 Revert "Change closed captions to an array"
This reverts commit 59920fa80b.
Issue #1404

Change-Id: I90cf8a274949c15779f0193783076ab687fcb9fb
2018-09-12 13:15:49 -07:00
Jacob Trimble bf6fcf0222 Add a wrapper around IDB cursors.
Change-Id: Iaf97caefde0264e6efdbd61aa9a048921243d98f
2018-09-07 10:25:14 -07:00
Michelle Zhuo 59920fa80b Change closed captions to an array
Changed the ClosedCaptions field in Stream from an object to an
array of ClosedCaption objects, so that it can be iterated through
and accessed easier.

Issue: #1404.
Change-Id: I67980cf4d5b5746785ba29f95718970fe89056f4
2018-08-31 17:10:36 -07:00
Aaron Vaage 0310c78b92 Isolate Util Method To Be Near Usage
There was a stream utilty was that only be used in one class
(another utility class). The method was to get tracks, but it
sat along side other methods that look similar but were different
in very small ways.

This change moves that function to be in the same class as where
it is used so that it will be less distracting from the other
getTrack methods.

Change-Id: I21737b6b1341c06b41e6016e24b2b20ce5d40e77
2018-08-30 19:39:37 -07:00
Aaron Vaage f2c73721fd Correct Error Not Thrown in Storage
When moving the manifest validation code, an error that was
meant for no periods got moved to no variants.

Change-Id: I2049e527baf247a7ec0281bcb443da6a2f20710b
2018-08-28 13:26:41 -07:00
Aaron Vaage e25aa0b17b Refactor Ugly Promise Chain in Storage
There was an ugly promise chain in Storage.loadInternal. This change looks
to clean up that promise chain and to use async syntax instead.

Part of the refactoring splits |loadInternal| into two more focused methods
as an effort to make the code easier to understand.

Change-Id: Ica113344c6c4ba1d82b6cee281268e20be1aa411
2018-08-27 16:31:32 -07:00
Jacob Trimble 79fc9e4596 Fix storage configuration bug.
Fixes: 113277647
Change-Id: Idc61402b205504dff6381751d6cb4aa05e987cbc
2018-08-27 14:57:36 -07:00
Joey Parrish f6fd524bcf Add newly missing @private annotations
Issue #1553

Change-Id: I72cd2ab5b133d33b5f2f58747b071d008539232d
2018-08-24 16:40:49 +00:00
Aaron Vaage 7cadde0d61 Filter Manifest Before Downloading
I was looking at some of the storage code and got confused with
when and where we were filtering the manifest. After spending
a lot of time trying to map it all out, I found that it would be
easier to understand if we:
  1. Did all the filtering at one time.
  2. Did all the filtering before trying to download anything.

Change-Id: I377fbeaa1873ae3fccff438ffcb10b3fb53f48d9
2018-08-23 11:29:21 -07:00
Aaron Vaage 07fb0642b2 Pass Variants To DrmEngine
Before, we would need to pass a manifest to DrmEngine to initialize
it. This was a problem as we look to support playback via src=.

When looking at how DrmEngine used the manifest, it appears to just be
a simple way to pass in the variants and the offline session ids. By
changing DrmEngine to accept the variants and offline sessions ids, we
can break the association between DrmEngine and Manifest.

Issue #816

Change-Id: Ie0dc82aaec871d7e6e002fe59b3a984449eda8c7
2018-08-23 17:53:57 +00:00
Damien Levin 6117125f2b Emsg not referenced in MPD should be ignored.
Fixes #1548

Change-Id: Ib65957fa43b97e7c8ad61c08923a30de86febb6c
2018-08-22 16:48:02 +00:00
Joey Parrish 6577a6e2ce Fix lingering references to shakaExtern
We renamed the extern namespace, but these references were in comments
that were not examined by the compiler.

Change-Id: If232953f678fba703c5355445f4f0cf180b46749
2018-08-21 10:42:10 -07:00
Aaron Vaage 927e68adc1 Split DRM Init Function
There are two intents when we initialize Drm Engine and the meaning
of the parameters are nuances depending on what you are trying
to do.

This change creates two different initializing methods so that
initializing drm engine for the intended purpose can be more
clear.

With this, some internal naming was change to better reflect how
some variables were being used to give them a bit more context.

Change-Id: Id8925eca53a34fe870ba5c973f9f0bb584f6e2d6
2018-08-20 21:41:38 +00:00
Joey Parrish ca3119dfba Correct segment timestamps in PresentationTimeline
Before, segment timestamps were used in PresentationTimeline without
regard for the period start.  This means they were not truly relative
to the presentation, but to the period.

The "isFirstPeriod" argument was also broken.  It was meant to be true
for segments from the first period *ever*, but was passed true for the
first period *in the latest manifest update*.  So data calculated from
that was bogus for live streams.

Now, notifySegments() is supplied with a period start time, so that
segment references can be combined with the period start to give
presentation timestamps.  This fixes a major issue with the original
fix for #999.

Closes #999

Change-Id: Id0fe450f3ce4f90a2387d7103c75eb88f0c69c72
2018-08-20 19:10:02 +00:00
Michelle Zhuo 5ef31d4bab Add closedCaptions field to stream
Dash and Hls manifests have tags and values to indicate that the content
may have CEA608/708 closed captions embedded in the video content.
Adding a closedCaptions field in Stream to represent that, and adding
parsing closed captions tag for DASH parser.

Reference:
HLS: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.4.2
DASH: https://dashif.org/wp-content/uploads/2018/04/DASH-IF-IOP-v4.2-clean.pdf

Issue: #1404.

Change-Id: I3c58b6043f7fe294dd642bdada8d2451caec9b55
2018-08-17 21:20:09 +00:00
Aaron Vaage 2191534a23 Initialize Storage Without Player
This change allows storage to be initialized without a player instance.
Since Storage is the same post initialization, the only test being added
is a test that checks that the storage instance was successfully
initialized.

Close #1297

Change-Id: Id2588696eac2a866bba74278322727b1d91f56eb
2018-08-14 00:56:55 +00:00
Aaron Vaage bf8bb0ac74 Change Storage To Use Destroyer
This changes Storage to use the destroyer object to manage
clean-up. This will later be used to change how we destroy
storage depending on how it was initialized.

Issue #1297

Change-Id: I7e8c4f959a6764859504b0259bd5e815e5fd3dc8
2018-08-14 00:56:28 +00:00
Joey Parrish bb646befca Fix issues found by newer compilers and linters
Some of these issues were found by the Closure Compiler linter,
which we are not currently using here.  I will try to re-enable it
in a follow-up change.

Change-Id: Ie6e75f2b5a1e0f888c3dfbc78ed9cf254d2738bb
2018-08-09 12:22:34 -07:00
Joey Parrish 2aacdd25c9 Expose DASH Representation IDs in new field
The DASH parser will now expose Representation IDs via new fields in
the Stream and Track objects.  The "id" field will continue to be a
unique, auto-generated numerical ID, and will be supplemented by a
nullable string containing whatever was originally in the manifest.

The HLS parser will now expose the NAME attribute in the originalId
field as well.

Bug: 112087288

Change-Id: I6b8107d27780fb97ab18de767f7abdc6c7110fe7
2018-08-09 17:08:42 +00:00
Aaron Vaage 34fe983ea0 Stop using Player inside Storage
We store the references to player's networking engine and
configuration in Storage, so there is no reason to call player
anymore. This change removes those lingering calls.

Issue #1297

Change-Id: I3486ffcb60cd80fd765259d690091cc3267bb8ba
2018-08-08 16:01:29 +00:00
Aaron Vaage 05b071d7fa Add Stream Utils for Common Practices
Added two new stream utils for practices that pop up multiple
times in our code base.

  1. getAllVariants - Get all the variants in a manifest.
  2. getVariantStreams - Get all the streams (audio and/or video) back
                         as an array.

Change-Id: I87fa4959e4a17dcfff20d5aa0678e6dc346d413e
2018-08-06 16:52:33 +00:00
Aaron Vaage 6cefea5a37 Remove cast in deleteAll
There was a cast in Storage.deleteAll that really should not
have been there. This changes it to use an assert to ensure
that the case is exposed if done wrong.

Issue #1297

Change-Id: I21f9737c0fc79c2b4324a7385a2814f94f40f884
2018-08-02 00:08:32 +00:00
Aaron Vaage 36ecbb1912 Share Networking Engine From Storage
Allow users to get access to the networking engine that storage
instances are using.

This is part of allowing storage to be used without a player instance
as it will allow users to configure the networking engine when they
create a storage instance without a player instance.

The code still assumes that Storage should never destroy the networking
engine. This is something that will need to change when storage can
be initialized without player.

Issue #1297

Change-Id: If8d1642259e0cf24cb43f2ca7936227e8d939260
2018-08-01 16:13:39 -07:00
Aaron Vaage 272e6bd922 Merge Offline Config into Player Config
As part of the effort to allow storage to be initialized with or
without a player instance, this change moves the offline config
into the player config and changes storage to share a configuration
object with a player instance.

We opted to share the instance between the two classes because if
storage was initialized with player, the initializer is implying a
relationship between the two objects and therefore configuration
changes should be shared.

Issue #1297

Change-Id: I991365255e63c284fbfcf147cf63c9588dd764ab
2018-07-31 22:07:02 +00:00
Aaron Vaage bbb7a83563 Add mime type option to Player.load
Added an option for the mime type to be passed to the load function.
Going forward this will replace the option to pass in a manifest
parser factory.

This is to help with issue #816 as passing in the mime type will be
one way for the player to know if it should use src= over MSE.

Issue #816

Change-Id: Ic356bb9f52c3977620debc8d4a09b7115a81d516
2018-07-31 21:15:44 +00:00
Aaron Vaage 44bfce73fd Limit Scope of applyRestrictions
When reading through player I saw we did something like:
let variants = period.variants;
...
shaka.util.StreamUtils.applyRestrictions(period, ...);
...
doSomething(variants);

This causes some confusion as it was not clear if |variants| would
still be valid to use (i.e. could applyRestrictions) change the
reference in period like we do in some other filter functions.

So to help make it clear that it doesn't, I have changed
applyRestrictions to accept a variant array rather than the period.

Change-Id: I6dc080a1b1e563e5dd2789bd00fb0cfeb7de41de
2018-07-19 20:33:32 +00:00
Aaron Vaage 48019c9dc8 Make Storage Only Accept Non-Null Player
Make sure that only non-null player instances can be given to
storage.

Change-Id: Ib0a6f2992eb18f2ae4360408445274c3d63d0063
2018-07-17 22:53:47 +00:00
Aaron Vaage e9f6e58d89 Track open operations in |shaka.offline.Storage|
Track all open operations in |shaka.offline.Stroage| so that we
can wait on them in |shaka.offline.Storage.Destroy|.

Change-Id: I648cb18545f9f1e0745ffddd70baac8fc316b0cb
2018-07-16 23:45:25 +00:00
Aaron Vaage 546942fc3a Created Destroyer Class To Handler IDestroyable
Created the Destroyer class to handle working with IDestroyable so that
IDestroyable can be a simple interface (no more static methods).

Change-Id: I5afd915b895a4c60d758475a2b879bf0eb0096c9
2018-07-09 22:19:19 +00:00
Joey Parrish fd0449d8f7 Re-enable some disabled style rules
This re-enables the following style rules:
  - "block-spacing"
  - "brace-style"
  - "comma-dangle"
  - "comma-spacing"
  - "new-cap"
  - "no-multi-spaces"
  - "no-multiple-empty-lines"
  - "one-var"
  - "padded-blocks"
  - "prefer-rest-params"

Change-Id: I15d616e8d5b88b273ded6128b4f9ad86bdb26bd1
2018-07-09 19:44:56 +00:00
Jacob Trimble 759eef9685 Change goo.gl links to bit.ly.
https://goo.gl is being turned-down, so we can't use it for new URLS.
So we have consistent short links, this converts them to be
https://bit.ly.

Change-Id: I07a86cba807b67157664893341f648023918d0de
2018-06-22 20:20:00 +00:00
Joey Parrish 321896db3f Fix private annotations and names
These errors were discovered by a more up-to-date compiler.

Change-Id: Ic678e259406ac6fa43c4cb355ad72118cd563f57
2018-05-23 14:29:12 -07:00
Aaron Vaage f3f2c757fc Remove Licenses with Storage delete all
Before, when clearing storage with Storage.deleteAll, offline
licenses were not released. Now before erasing storage, all
sessions ids are collected and requested to be removed.

Closes #1277

Change-Id: Ib88a14f5132d3b2a34bd339cc45f121792b65ebc
2018-05-14 19:02:18 +00:00
Joey Parrish a915af11aa Add missing @private annotations and goog.requires
Change-Id: Ieacf51e9c82eb1c5fa72d4d8594055a785e829ef
2018-05-10 15:33:11 -07:00
Aaron Vaage 03fc0bca99 Add Back Progress on Remove
Tracking progress when removing an asset was missing from the new storage
system. This CL adds that support back.

Issue #1248

Change-Id: Iab275cd75af817cfc34ee0888ddeea257b1ead56
2018-05-10 19:37:15 +00:00
Aaron Vaage 8040f78883 Integrate StorageMuxer and Player
This CL replaces the old storage system with the storage muxer system.
In addition to replacing the old system, this CL removes all the
code that was only used by the old system.

As of this change Storage Muxer support shaka player's V1, V2, and V2
indexeddb schemes and exposes a plug-in system for other offline storage
components.

Issue #1248
Change-Id: I1a4914477ad8db29fd0e7ad7de2f149b6497f67e
2018-05-09 18:41:21 +00:00
Michelle Zhuo 535de4db84 Refactor: Remove underscore from parameter names
Change-Id: Ie9e6fb59763f454f245175f23c6444f919ba8135
2018-05-08 19:21:51 +00:00
Aaron Vaage 272c4ba89e Create V1 Storage Cell For IndexedDB
Created the V1 storage cell for Shaka Player's original offline
data scheme.

Issue #1248

Change-Id: Ib564ec0670c56ba1b455f198133b118a21fd0a27
2018-04-25 20:18:03 +00:00
Aaron Vaage 647a8c6064 Changes To Storage Muxer to Increase Ease-of-Use
While working with integrating storage muxer into the codebase, there
were some painful points in the API. This change addresses those
painful points.

1. Getting cells - many times we know that the cell should be under
                   a specific path. So resolving the path and
                   checking for null got annoying. This adds
                   a call that assume it should find the cell.

2. Get active cell - when getting the active cell, we often need
                     the cell and the path to the cell. So this
                     creates a "Handle" which pairs the cell and
                     path together.

3. Adjusting registry - when testing we need to change what storage
                        cells are actually available. Instead of
                        unregistering and registering cells, this
                        adds methods to add and remove a temporary
                        override.

Issue #1248

Change-Id: Ifd45ee5912f53b1da444476b560cf03669a19b11
2018-04-23 15:52:16 +00:00
Aaron Vaage e67f851851 Close Database Connection
Need to close database connections when destroying the
indexeddb storage mechanism or else it will get in the
way of deleting the database.

Issue #1248

Change-Id: I56466851e8172282c60c3128e5b4113001a10970
2018-04-18 17:02:49 -07:00
Aaron Vaage 189129b596 Create IndexedDB Storage Mechanism
Create the indexeddb storage mechanism which will allow us to
connect to indexeddb storage cells. As we don't have a V1 Cell
yet, this only connects V2 and V3 cells. However the code does
assume that V1 will be added and only omits connecting the cell
when it sees the V1 object stores indexeddb.

Issue #1248

Change-Id: I7395b8a334cd68795aab02ff656a5b49d1f5742b
2018-04-16 16:18:17 -07:00
Joey Parrish ff082ee9d4 Upgrade closure compiler and drop closure linter
This upgrades to the latest compiler release and drops the linter.

Since we adopted it, the closure linter has produced far more problems
than it has caught.  It takes no command-line arguments and can't be
configured.  Eslint takes care of traditional linting tasks, and it is
unclear what we would stand to gain by conforming to the demands of
newer versions of the closure linter.

This also fixes a few issues caught by the new compiler:
  - Type adjustments for the evolving Fetch externs
  - Drops our custom extern for AbortController, which the compiler
    now has built-in
  - Adds a type annotation to player.js to fix a type inference
    failure in the new version of the compiler
  - Drops more non-nullable annotations on functions, which are
    implicitly non-nullable

Change-Id: Ia03936a5426277d970612c0eacef40fbaf6ee35d
2018-04-13 17:49:18 +00:00
Aaron Vaage bf0d107630 Add Missing "."
Add missing "." after "Array", "Object", and "Promise".

Change-Id: I86f6bd6ea38ce6531b71d22923622ccda07fc6aa
2018-04-11 21:36:44 +00:00
Aaron Vaage 476fbf3df6 Limit Storage and Downloader Scopes
Limit the scope of storage and download manager to |store|. This
will make it easier to swap it with storage muxer.

Issue #1248

Change-Id: I3ec5de4457cbb534eb0c9b44d518602a1295d709
2018-04-11 21:24:07 +00:00
Aaron Vaage ef5c92c720 Added GetCell to StorageMuxer
Added a method to get a cell from storage muxer. Unlike resolve path
this will return a rejected promise if the cell can not be found.

Issue #1248

Change-Id: Ia594b7741351d515e564e574321e49ad51073005
2018-04-11 21:09:25 +00:00
Aaron Vaage 21efc65973 Add toString to StorageCellPath
Added a toString method to StorageCellPath so that it will be
easier to read when added to a string.

Issue #1248

Change-Id: Iad7c2e633b6327bd39475d29d23426217f042ee3
2018-04-11 21:09:01 +00:00
Aaron Vaage 68c4445ae9 Change findAll to forEachCell
Changed |findAll| to |forEachCell| as it provides better usability in the
codebase where we would have used |findAll|.

Issue #1248
Change-Id: I6ca993ffb85aa0bf15d6ac250ac85a00e966fcbe
2018-04-11 20:16:11 +00:00
Aaron Vaage 74bf086535 Made Storage Muxer implement IDestroyable
Make storage muxer implement the IDestroyable interface so that
it can be used with |shaka.util.IDestroyable.with|.

Issue #1248
Change-Id: I6e8c71b57e939ea30d5c24c75ede9c2de80026db
2018-04-11 20:15:42 +00:00