Commit Graph

1360 Commits

Author SHA1 Message Date
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
Joey Parrish 1cf27b9064 Fix support for startTime of 0
During a recent refactor, startTime || null got introduced.
This would not only use null as a default, but would also convert 0
into null, which changes the meaning of 0 from "exactly timestamp 0"
to "default start position" (which is non-zero for live streams).

This fix adds a regression test that fails without the fix.

Change-Id: I01e1628df9d141697fdb7d9fb5e77a16ac3dab5b
2018-05-10 18:08:17 +00:00
Sandra Lokshina 1cca1d0ea2 Allow users to more easily set single config fields.
Closes #763

Change-Id: I1918f2a5286781e81f2619296e3201f02b91128f
2018-05-09 19:03:28 +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
Joey Parrish bc9a9f23f9 Revert name change in Player startTime param
Change-Id: Ief83eab55434c1a48266a27ed9937364848e4adb
2018-05-09 10:51:55 -07:00
Joey Parrish f0b9beb5a9 Fix small typos and formatting
Change-Id: Iaece5250c3d6ed9922852cfe71ee0e63c93a73fe
2018-05-09 10:40:06 -07:00
Michelle Zhuo 535de4db84 Refactor: Remove underscore from parameter names
Change-Id: Ie9e6fb59763f454f245175f23c6444f919ba8135
2018-05-08 19:21:51 +00:00
Michelle Zhuo 1e3ad7cfa0 Keep text track visibility and createMediaState cosistent
Only create Text media state when the subtitle is visible.

As a follow up for commit Icaa1477d35633fc3afabcf7baf38acde0cd775ef.
Closes #1412.

Change-Id: I4810c4790fd904f4e45dfd1481dab19c7c887920
2018-05-03 17:03:42 -07:00
Sandra Lokshina c3952b267d Don't create media state for external text when it's added.
For non-external subtitles we wait to create media state until
the captions are actually enabled. This change adds logic to treat
external text the same way.

Closes #1412

Change-Id: Icaa1477d35633fc3afabcf7baf38acde0cd775ef
2018-04-30 20:25:09 +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
Jacob Trimble 3d877d7ac5 Return false if player configuration is invalid.
If the value passed to |player.configure| has errors in it, the method
will now return false.  This allows the app to programmatically detect
errors in the config object.

Change-Id: I7236f565320e8fd39afcb3224b7901c601d211ba
2018-04-20 11:46:38 -07:00
Joey Parrish c54f4f445f Consider channel preference before choosing codecs
Previously, we would choose codecs based on bandwidth alone.  This
would lead to 2-channel audio being preferred over 6-channel audio
when the two used different codecs.  (Content with different channel
counts using the same codec are not affected.)

Now, we consider the channel preference before choosing a codec.  This
fixes app selection of 6-channel codecs over 2-channel codecs when
they differ.

Closes #1013

Change-Id: Iee6058b2df04b8b8036f59909fd82df26b1173ae
2018-04-19 22:23:15 +00:00
theodab a039c66cac Increase MIN_SEEK_RANGE to 3s
On Chromecast, some streams were unable to keep up with the narrow
seek window, and got stuck perpetually seeking forward.
This change increases the seek window to 3 seconds long, which some
initial testing has shown to be the shortest value to play without
uncomfortable choppiness.
Unfortunately, v1 Chromecasts still have issues, even with this.
It seems like they have a separate issue.

Issue #1411

Change-Id: I597315cd418861b18e63a859197a8c2585cb4fd0
2018-04-19 11:28:00 -07: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
Joey Parrish 75e072491e Fix a few small issues with channel count config
1. The channel preference was not correctly used for the initial
   content selection if the config was changed between construction
   and load().
2. The AbrManager's options were not updated if the user manually
   chose a track with a different number of channels. When Abr was
   re-enabled, the channel count reverted to its configured setting.
3. If tracks changed due to a key status change, the current channel
   count and config were ignored, and AbrManager got to choose from
   all tracks again.

Tests were added/updated for all three issues.

Closes #1013

Change-Id: Iec49361aa6e8c7193a572ad7914dfd853454791d
2018-04-13 17:28:25 +00:00
Jacob Trimble ba0b72dc7e Use rolling average for delaying manifest updates.
If a single manifest update takes a long time, it should not hinder
future ones; but if there are repeated slow updates, we should delay
updates.  This uses an EWMA to keep a rolling average of update times.

Closes #1399
Issue #1408

Change-Id: I6a662ce51ba9c3e1e4a87b2418e35fc3948043c1
2018-04-13 16:43:14 +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
Aaron Vaage 410789e2be Correct Return Type That Closure Missed
It appears that closure did not notice that a return type
was not consistent. This corrects the return type to match
what the download method in download manager actually
returns.

Issue #1248

Change-Id: I796e31d9e7ad1d812bd53a55f5f1c745ac0b187c
2018-04-11 18:34:18 +00:00
Sandra Lokshina 8065bd54a8 Change namespace from shakaExterns to shaka.externs
Change-Id: I16432351e2a266aa8fd175669aa27c44bfdffeae
2018-04-11 17:26:26 +00:00
Joey Parrish 8985f5cfa5 Remove non-nullable annotations on function
Function is implicitly non-nullable.

Change-Id: I6a86f20bcb3e9cf7886b8f352eee377968e2460f
2018-04-11 08:23:07 -07:00
Joey Parrish 0b75b8c974 Bump version numbers for v2.4
Change-Id: I55d42050ba0f6c648049546f8135cf64980f1c0d
2018-04-11 08:04:45 -07:00
Joey Parrish 79a6146b5f Revert change to Track and Stream structures
In the initial fix for #1013, we changed the name of the channelsCount
field in both the Track and Stream structures.  This would break
compatibility for applications.  So even though the new name was in
some ways preferable, we must revert the name to avoid more breaking
changes in v2.4.

Issue #1013

Change-Id: Ie8f3d211c42c8046039a3db9f0926c68ad1315d9
2018-04-10 23:45:53 +00:00
Joey Parrish 08af438d32 Track Download Progress With Bandwidth Estimates
Using variant bandwidth to estimate download progress. We use a constant
bandwidth estimate for audio, as most of a variant's bandwidth will be used
by video.

Since we normally don't have bandwidth for text, we use a constant bandwidth
estimate for text so that it can influence progress.

Even through we some times have the actual audio and video bandwidth (DASH)
we choose to use always used the combined amount so that we can have
consistent behaviour between manifest types.

Issue #1248

Change-Id: Ibffe95e2c8d141659855b54949a50ae84c51dded
2018-04-10 17:18:31 +00:00
Joey Parrish 772dc231c9 Remove non-nullable on implicit non-nullable types
This is a style cleanup to pass stricter checks from future versions
of the Closure linter.

Change-Id: Icca8f974af7c9f4834acf6bba69e4cef1f89e502
2018-04-09 14:52:59 -07:00
Aaron Vaage 2ba27a681b Moved Storage Out of Download Manager
Move the use of storage engine out of download manager and back into
storage. Storage creates and manages the life of storage engine, so
it is easier for it to handle all storage functions.

Now, the callback that is given to download manager is used to pass
the downloaded array buffer back to storage so that it can be saved
into storage engine.

This moves all uses of storage engine into storage which will make it
easier to replace with Storage Muxer.

Issue #1248

Change-Id: I555788478af09d1d79c3db7534431e1d9daf4e20
2018-04-09 20:42:45 +00:00
Joey Parrish e7587cc361 Add a test util for dumping and restoring from IDB
This makes it easy to dump and restore databases from IndexedDB. This,
in turn, makes it easy for us to test that all database versions can
be read. Before we close the backward compatibility issue that has
plagued v2.3, we will add tests that use this utility to load DB
snapshots from various older schemas and prove that they can still be
read.

This also adds dumps of all database versions to the assets folder,
including a snapshot of a what our broken upgrade in v2.3.0 did to the
v2 database schema.

Issue #1248

Change-Id: If7e8995f50abbdee67e3fa93e79f07a49582c5e8
2018-04-09 19:06:35 +00:00
Aaron Vaage 316b3ea573 Remove Unused Optional Method Parameter
Because we changed how we collect the streams before downloading we
no longer used the variant id parameter. This change removes the
parameter.

Issue: #1248
Change-Id: Iab4323c7b358ed83812b2ff36e9632022e65f88a
2018-04-09 18:14:35 +00:00
Aaron Vaage 4a4050d223 Change Download Manager To Take Requests
Changed download manager to take |shakaExtern.Request| as input
instead of |shaka.media.SegmentReference| and |shaka.media.InitSegmentReference|
as it really does not need to know about those types.

Issue #1248

Change-Id: I797c437f4339cf670b5eddad14952b0526b72ea5
2018-04-09 18:13:28 +00:00
Aaron Vaage 612d248d4c Clean-up Downloading Groups
Went through the download code and tried to make it easier to read
and understand.

Issue #1248

Change-Id: I74316d3337248f0d16f2fb6cc1734e1e57739966
2018-04-09 18:13:16 +00:00
Aaron Vaage 0a3f4d6566 Group Downloads By Stream
Group downloads by stream id so that download manager does not
need to know about the stream types.

Issue: #1248
Change-Id: Id61df4e67a419ee085dfd96a863bb56f01a4b732
2018-04-09 18:13:11 +00:00
Joey Parrish 6bdbebfa47 Minor cleanup of null checks on non-nullables
Change-Id: I924c267be2b8fc689391ed888f08707e0bd574e0
2018-04-09 18:05:04 +00:00
Michelle Zhuo a09ae24b85 Add audio channels count configuration
Added a preferred audio channel count to configuration, default set
to 2.
Choose the codec with the largest number of audio channels less than
or equal to the configured number of output channels. If this is not
possible, choose the smallest number of channels.

Closes #1013.
Issue #1071.

Change-Id: I6c6a956e33637cf34bd4bd79af563dc10a595e94
2018-04-06 20:51:28 +00:00
Aaron Vaage d86713cf0d Group Streams Before Downloading
To make it easier to understand, we collect all the streams within a
period using a map. This ensures that we will have a set of streams.

We then download each stream in the map. Since the map is indexed by
stream id, we can easily connect the variants and streams.

Issue #1248

Change-Id: I65ae01733b5d9dbf8b6d73c37f802320fffa03d1
2018-04-06 20:15:52 +00:00
Joey Parrish 2e7c25ab67 Export shaka.util.AbortableOperation
This exports shaka.util.AbortableOperation, which plugin writers will
realistically need to update their scheme plugins.

Change-Id: Idfc149f06d22699a78c4d989d331619d5e74f097
2018-04-05 22:03:11 +00:00
Aaron Vaage 21f032a1cd Clean-up Similar Track Check Loops
Changed the loops used to check for similar tracks to be simpler. Yes,
there are some double checks, but over all it is easier to read. Since
this code is ran very rarely, the minor redundant checks should not be
a problem to the user.

Issue #1248

Change-Id: I6589dda233e94defb5729934ee859b78e3af193f
2018-04-05 21:51:29 +00:00
Aaron Vaage b27b649f6f Create IDestroyable.with
Created a static method that will handle destroying a destroyable
object when you are done with it.

Issue #1248

Change-Id: I4df0569f5f5e00002600702cf24caf1ed2da7c5b
2018-04-05 14:05:29 -07:00
Aaron Vaage 8c988fa4bc Wrap Getting Network Engine in Storage
Every time we would get network engine in storage we would need
to assert that it was not null. To make this easier (especially)
with promises, we add a function that will only return an non-null
networking engine.

Issue #1248

Change-Id: Iba415426ea42007addbb26c7a6b99a54a5064440
2018-04-05 13:32:39 -07:00
Jacob Trimble f13acd6ac5 Fix ABR selecting key-system restricted streams.
ABR should not select key-system restricted tracks since we can't play
them.  Rather than updating AbrManager to do it, the Player should
just filter out the restricted tracks so a custom AbrManager doesn't
need to worry about it.

Change-Id: I5fa5cdcd9a035136fdccf9bee1a54752a0cacf1f
2018-04-04 14:50:57 -07:00
Joey Parrish 309bd915c0 Rename "getUse" to "using" EmbeddedTextTrack
This name reads a bit more naturally.  Also rewords some of the method
descriptions.

Change-Id: I03a9cb78f88637b6076d64b4c5cd852a69b37f99
2018-04-04 16:51:34 +00:00
Joey Parrish 18b171f5ee Add missing quotes on exported enum
Change-Id: I61a92a389ed0d79e5de8db19f461596f269f1502
2018-04-03 14:58:16 -07:00
Theodore Abshire f32767578a Handle segment tags before playlist tags in HLS
Normally, we expect that only media playlists contain segment tags
(EXT-X-KEY, EXTINF, etc).  We determine if a playlist is a media
playlist by the presence of an appropriate playlist tag (EXT-X-MAP,
EXT-X-PLAYLIST-TYPE, etc).
However, we were checking tags one-by-one, on a single while loop.
This meant that we would reject manifests where a segment tag appears
before a playlist tag, as we did not yet know that the playlist was a
media playlist.

This changes the manifest text parser so that it checks for playlist
type first.

Issue #1382

Change-Id: I1b9f674a58c60ab291d6d004462b0c0cae49631d
2018-03-30 16:30:16 -07:00
Theodore Abshire c5de6cb115 Add option to force TS transmuxing
Our support for CEA 708 closed captions only works if the container
video file is transmuxed. Because of that, we were not successfully
reading such captions on platforms with native TS support.
This change adds a configuration option to force TS to be transmuxed
even when unnecessary, to account for that situation.
It also adds an integration test to ensure that CEA 708 captions can
be extracted on every platform.

Closes #276

Change-Id: Id8b2a67f2327d1b69c9cdfc443e9592c99baf0db
2018-03-30 11:04:03 -07:00