Commit Graph

46 Commits

Author SHA1 Message Date
Joey Parrish f539147d48 fix: Correct license headers in compiled output
This fixes all the license headers in the main library, which corrects
the appearance of the main license in the compiled output.

It seems that the `!` in the header forces the compiler to keep it in
the output.  I believe older compiler releases did this purely based
on `@license`.

Issue #2638

Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
2020-06-09 16:05:09 -07:00
Joey Parrish aba5e2583c Rename v2.6 to v3.0 and v2.7 to v3.1
We have decided to bump the major version number instead of the minor
number, based primarily on the fact that this release breaks
compatibility with our previous manifest structure.

Change-Id: I67e4c8267c6e103cfc7278e09daac186ae5cbbc6
2020-05-29 17:50:22 +00:00
Joey Parrish 1076b78465 Unfork Closure base and update the compiler
The Closure Library's base.js, the Closure Compiler, and the Closure
deps-writer are all now loaded via NPM instead of commiting them
directly to the repo.  This also updates both the library and compiler
to the latest version: 20200406.

We still have a fork of the Closure Library's URI parser.  The latest
upstream version of that has too many dependencies on the rest of the
library to import directly from NPM.

Some internals of the build system have been refactored, and the
"complete" set of files in the build system now includes third_party.

Our forked URI parser does not pass lint checks yet, so the linter
does not run over third_party yet.

A couple of overly-severe sets of compiler checks have been disabled,
since even the latest Closure Library's base.js doesn't pass them.

The script-loader in load.js had to be updated for compatibility with
the new Closure Library.  If you don't return "true" now, Closure's
base.js will stop loading subsequent source files.

Some local externs that we had written are now available from the
compiler, so our local copies have been deleted.

A few type-related changes have been made as well, removing casts that
were necessary with the old compiler, but not necessary with the new
one.

Finally, this corrects some type issues in the tests using the new
"typeof" annotation from the compiler.  This allows us to type a
variable as a class defined elsewhere.  For example, after loading the
compiled library, we can reference compiledShaka.Player, which has the
type "typeof shaka.Player".  The compiler can then type-check all uses
of it in the tests.

Closes #2528 (bad polyfill code generated by the old compiler)

Change-Id: I62ec61e82d4edf342b2c576c2d4f89f11562ee65
2020-04-30 19:32:30 -07:00
Joey Parrish 7917348fbe Correct out-of-date comment in lib/offline/
Change-Id: Id3087eeb897a7d4184d5a2b03f469247e1a3f9d1
2020-04-30 17:30:44 +00:00
Joey Parrish 3ac75b04ab Fix IndexedDB types
The built-in externs for IndexedDB in Closure Compiler are missing
some type info.  This overrides them to add what's missing.

This also tweaks type information in a few places in lib/offline/ to
match.

This was caught by a compiler upgrade.

Issue #2528

Change-Id: I97096656f53b426067219e2d4e3aa16f32b87188
2020-04-30 15:59:50 +00:00
Joey Parrish 13202cecae Fix storage cell constructor args
When we changed the constructors for the V2 cells with the
introduction of V5 format, these call sites didn't get updated.  This
doesn't seem to be a user-facing bug, and did not affect any releases.

This was caught by a compiler upgrade.

Issue #2528

Change-Id: I77228d17631ef44a6b85a81b88054790461617bc
2020-04-28 20:57:59 +00:00
Álvaro Velad Galván 2807971e4e Add creationTime to offline assets (#2406) 2020-04-10 09:58:45 -07:00
Joey Parrish e24fec4b08 Flatten periods
This creates a new utility used by DashParser and old offline DB
formats to combine Streams across Periods.  This allows multi-Period
DASH content to be played without period-specific structures in the
manifest format, StreamingEngine, or Player.  This also makes the
Tracks stable across Periods.

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

Change-Id: Icb04c8e47e36eacf7ac024a5063130d85a115e54
2020-04-09 19:22:16 +00:00
Joey Parrish c84676c7ee Make offline manifest conversion async
This will be used in period-flattening, where we will need to create
segment indexes before combining Streams.  Although the operation
would be synchronous for DB types, the general interface will need to
be async.

Issue #1339

Change-Id: Ibedb267118462cbaf3ca599ab6a67c8f355965f6
2020-04-09 19:22:16 +00:00
Joey Parrish 6e3dfa40ba Deduplicate key IDs with Set
When period-flattening combines Streams, key ID arrays would get very
long with duplicates.

This changes keyIds in the manifest and offline structures from Array
to Set.

Issue #1339

Change-Id: I003d23e567efafa771ecd2ad597900181604ad18
2020-04-09 19:22:16 +00: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 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
Joey Parrish dbc9ea9772 Add externs for V1 database format
This will make it easier to ensure conversions are done correctly,
which will be increasingly important as we change the database format
as part of #1339 (period flattening).

Change-Id: I1114b1a9a0d341589f7f1026ec23ad93af38a6b0
2020-02-14 19:59:19 +00:00
Joey Parrish d16865b304 Add tests for v2 and v3 offline content
Before this, we only had tests in place for loading and converting the
v1 format for offline storage.  We had database dumps already for v2
and v3, but no tests exercising them.  This adds some basic tests and
fixes a bug in the loading of expiration times for v2 and v3,
equivalent to what we already had for v1.

Note that here, v1, v2, and v3 do not refer to major versions of Shaka
Player.  Instead, they refer to IndexedDB storage formats used in v2.x
versions of Shaka Player.

Change-Id: If32d1f1131b935eb191101463c4152317e711c5c
2020-02-13 20:30:28 +00:00
Joey Parrish 4ffcbc6188 Fix pixelAspectRatio types for backward compatibility
For backward compatibility, the new pixelAspectRatio field in Stream
should be string|undefined rather than being nullable.  This ensures
that manifest parser plugins that do not output that field will still
compile against the externs.

PR #2294

Change-Id: I1aae03994a213c8ce52dc64e8a34bf179045f4fb
2020-01-15 19:04:14 +00:00
Álvaro Velad Galván bdca05ff4b Add pixelAspectRatio property from DASH (#2294) 2020-01-06 10:56:28 -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 79aae2aeaf Fix protected member names.
According to the style guide, protected members should not end with
an underscore.  This renames them to fix it.  This also marks some
members as private that aren't used outside the class.  Lastly, this
fixes a possible bug with the use of "this".

Issue #1553

Change-Id: I6c7ecdcd228ec4e4aded4af52e2262d0bf5beaf4
2019-08-13 19:08:03 +00:00
Joey Parrish d6d9fa9250 Refactor IndexedDB storage cells into a base class
To prepare for an upcoming change to the format of the data stored in
IndexedDB, refactor the storage cells to remove common functionality.
This will make it easier to add a third cell type.

The format will change as we move fields in the manifest structure and
ultimately flatten out periods.

Issue #1339

Change-Id: Ibaeb35596180b2e2362b4d53734019599d6fff77
2019-07-09 16:36:25 +00:00
Jacob Trimble 28cc9f6f9d Favor includes over indexOf.
Change-Id: I78a8334c025fe11d485cb2f9cb7cb4cb7dcb6c2c
2019-06-27 11:54:11 -07:00
Jacob Trimble 43e798870f Misc ES6 conversions.
Issue #1157

Change-Id: Ia25a6cae84575f003980e9694b2769f2976e1342
2019-06-03 15:31:57 +00:00
Jacob Trimble a0392286b2 Convert offline tests to ES6.
This also fixes some bugs in the errors that were thrown from the
offline code.

Issue #1157

Change-Id: Ia0a0df458e764df5693ea3e6c1f38f91712e5280
2019-05-22 16:34: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
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
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
Jacob Trimble 65e9c36f6c Add database for storing session IDs.
This new database will store EME session IDs that need to be removed
at a later time.  For example, this can happen if we fail to remove
the session when deleting content.

Issue #1326

Change-Id: I808103535d93c9070e13e30b8cd939fea757cafe
2018-09-27 17:49:27 +00:00
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
Jacob Trimble bf6fcf0222 Add a wrapper around IDB cursors.
Change-Id: Iaf97caefde0264e6efdbd61aa9a048921243d98f
2018-09-07 10:25:14 -07: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
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
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
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
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 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
Sandra Lokshina 8065bd54a8 Change namespace from shakaExterns to shaka.externs
Change-Id: I16432351e2a266aa8fd175669aa27c44bfdffeae
2018-04-11 17:26:26 +00:00
Aaron Vaage e6302f5d73 Make Update Expiration Simpler
The only time we ever need to update a manifest value is when
we update the expiration time. To make it easier to support
updating expiration time across different version, only allow
that one value to be updated.

Change-Id: I621ec744019802edc65b059baa7f5cf0c476b0b1
2018-03-26 20:13:15 +00:00
Theodore Abshire f58afd21da Typo fixes and rewording in comments, part 5
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.

This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.

Change-Id: Ibcaf21382bd78b91e589122983dd14e001bfdad5
2018-03-21 17:25:13 +00:00
Aaron Vaage 85bdf8ca23 Fix Errors in IndexedDB Code
Fixed an issue where an update call the IndexedDB was not replacing
the correct value because the key was getting changed to a string.

IndexedDB will count a missing key as a success, so check that the
value is undefined.

Issue: #1248
Change-Id: Icdd6ae263374c655170c6470df85c656b8bd3ba2
2018-03-14 00:06:04 +00:00
Aaron Vaage b92d8f31e7 IndexedDB Storage Cell for IDB Version 2 and 3
Since the database schemes for idb versions 2 and 3 used the same
data types (shaka offline version 2) this storage cell can be used
for both. The only difference is that idb version 2 has a fixed
key space.

Issue: #1248

Change-Id: Iac5cb1d57f93fdb81729b59d67d6736e29c9968c
2018-03-06 21:47:37 +00:00
Aaron Vaage 2bdb032e4c Created Base Classes for Working With IndexDB
Created base classes that will be used when working with indexeddb.
These classes are used to manage connections and transaction is a
more promise-friendly way.

Issue: #1248
Change-Id: Iafd001072bee8572f41af7069532f3a1ccd39fbc
2018-03-06 12:40:40 -08:00