Commit Graph

52 Commits

Author SHA1 Message Date
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 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
Aaron Vaage 3e56d4ea1e Update Storage Unit Tests
Made some changes in how the unit tests were structured so
that it will be easier to identify problems with changes to
storage.

Issue #1248

Change-Id: I8331f18e9c9e360cf8057737ddfd71c7152a744b
2018-04-04 17:50:36 +00:00
Aaron Vaage 33547d071c Stubbing-in Mechanism & Cell Fields in Offline Uri
Adding "mechanism" and "cell" fields to offline uri. But since
they are not used anywhere, this change sets them to dummy values
so that all the constructors could be updated.

Moved the manifest reconstruction code into a instance class as
the mechanism and cell for the asset is needed in order to create
all the segment uris.

Change-Id: I2b5738805b17c4aa33d39b3166fddf1528aed489
2018-03-27 21:19:47 +00:00
Aaron Vaage 6ae49efc96 Move Offline Uri Functions in Class
The offline uri is going to soon contain more information (routing
information used by the storage muxer) so this change makes offline
uri a class so that all components can be accessed.

Change-Id: I5137f278e0dab059191d450876cab42745e4ed0b
2018-03-26 19:17:35 +00:00
Joey Parrish 3e8a83584d Update the compiler to v20180204
This unblocks conversion of tests to async.  We ran into issues in
compiler version v20171203 which have already been fixed upstream.

We are not, however, updating the linter.  The matching linter version
reports errors about our tests not using goog.require, which we do on
purpose.  We will wait to update the linter until we have resolved
that.

This change also fixes issues discovered by the upgraded compiler:
  1. Missing property definition in playhead_unit
  2. Wrong type name in storage_unit
  3. Wrong type name in FakeManifestParser

Change-Id: I4ba3f43e6a6471e182a69c85cfc619de3380c559
2018-03-21 13:57:46 -07:00
Jacob Trimble 064089152b Remove spacing around object definitions.
This is an automated fix to be inline with Google style guides, this
was created with eslint's --fix option.

Change-Id: I860eecbc8152603e730aa17a1393f16d26b3b6fc
2018-02-21 13:35:00 -08:00
Jacob Trimble 624acc66b8 Add curly braces to all blocks.
Google style guide requires adding curly braces to all block statements
even if it is only has one line.  This fixes it by using eslint's
--fix flag followed by running clang-format to reformat the change.

Change-Id: Idc086c2aa8c02df5ef8b2140a11bfb9128eeb4bd
2018-02-21 11:23:34 -08:00
Jacob Trimble cfbbe485e9 Use seek range in Playhead.
Rather than using the availability window, Playhead should use the
seek range to restrict the playhead's position.

Closes #1224

Change-Id: I8612bfafb53bbb214e32aae2d71af52d748a3aee
2018-02-20 23:42:12 +00:00
Jacob Trimble 4004bd42fd Convert 'var' to 'let'/'const' (7 of 9).
This is part of a change to convert all usages of 'var' with either
'let' or 'const'.  This takes a conservative approach for 'const' where
it will only be used for aliases and storing the "original" values in
tests.

Change-Id: Ib137fbfde50f1330c74c040fc062aa8e2c6d1e57
2018-02-15 21:16:33 +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 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
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 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 d90821a1a5 Isolated Manifest Creation in Storage Tests
For storage tests, this change isolates the creation logic
so that the data created can more accurately reflect real data.

Change-Id: I8b8a2002c29e5c9d3a41f4de0819ad923b6b14e5
2017-11-09 16:23:52 -08: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 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
Jacob Trimble 6069e76c4e Disallow ArrayBuffer.slice.
ArrayBuffer.slice isn't supported with two arguments on Tizen 2016.
This is a temporary fix that can be cherry-picked to v2.2.  A better
fix will be handled in a follow-up change.

Issue #1022

Change-Id: Iae6a0b2ef0cf17843f42f22f0ea0962a56e8be68
2017-09-25 17:28:19 +00:00
Sandra Lokshina b3586c193a Add stream bandwidth info to variant tracks.
Closes #834.

Change-Id: I3af66a227ad09f1686a7ca3f545c2bf9683d3c24
2017-07-07 10:20:54 -07: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
Jacob Trimble d8a3d8d2f7 Change jasmine.Spy type definition.
The old definition using a union with a Function causes problems.  The
compiler tends to treat this as an unknown type, so we loose type
safety.  The new types ensure full type safety, at the cost of needing
to "convert" the spy when it is used as a function.

Change-Id: I98ebd9dffd9cb865d0cf5d03db0fb5d6ea001ed3
2017-06-27 12:18:48 -07: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
Matias Russitto ace0e8cf49 add video and audio stream IDs for getStats().switchHistory (#846)
Closes #785, #823
2017-06-05 10:29:55 -07: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
Michelle Zhuo b65cf1de81 Separate audio codec and video codec in Track
The audio and video codecs were combined in Track, so it's hard to
detect whether the track variant has video or audio track.
Changing the combined codec to two separate fields.

Closes #758.

Change-Id: I9fbd0b85830cac306dc09db2d71cf96f77146cbe
2017-05-05 17:32:20 +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
Joey Parrish 58d9156be2 Update default track selection for offline
By default, we will now store all text tracks, regardless preferences.
This not only helps with our demo, but makes sense for applications
that have not bothered to configure the track callback for offline
storage.

This also fixes bugs in the default track selection algorithm,
changes the default audio track selection to fall back on primary
variants in cases where the audio language preference cannot be met,
and adds tests for the default selection algorithm to verify correct
behavior.

Change-Id: Iead0499039e9ec596514aa7577265a7472914621
2017-03-10 00:51:28 +00:00
Sandra Lokshina 0b12937520 Replace content type strings with constansts.
Change-Id: I4fda583915766b40ee7a5c7451d037077d9f2582
2017-03-08 21:41:59 +00:00
Jacob Trimble 6ba6b0631c Consolidate usages of fake video elements.
There are several tests that use fake <video> elements.  All of them
have a createMockVideo method.  This consolidates all of them into a
fake class that also provides more type safety.

Change-Id: I132c3e4a75676594bcefb60d0b115c00ede03067
2017-03-03 19:57:08 +00:00
Jacob Trimble cc3e34552f Fix track selection in Storage.
There was a bug where Storage would always store every track,
independent of what was chosen.  This fixes it and adds a test so this
doesn't happen again.

This also updates the ManifestParser API usage Storage.  It was
updated in 2ca962a3 and Storage was not updated.

Change-Id: Id3b8ee143cec6c4d099a9628c90dc3c927ea8625
2017-02-21 15:47:41 -08:00
Aaron Vaage 3db0f3357a Creating IStorageEngine Interface
To better support alternate storage mechanisms, this change abstracts
shaka.offline.DBEngine into an interface called
shaka.offline.IStorageEngine.

DBEngine has been changed to implement this interface, and allows the
addition of implementations that do not use IndexedDB.

Change-Id: I6a94067001ee53049df11cb68604bb57912300bb
2017-02-10 21:27:32 +00:00
Joey Parrish 4d5e668583 Expand player stats and track metadata
Visible changes:
 - Add loadLatency stat
 - Add mimeType to tracks
 - Track state changes (buffering, playing, paused, ended)

Internal changes:
 - Track switchHistory, playTime, bufferingTime in private Stats struct
 - Remove dead timer code

Change-Id: I4566373251b9876b0d4f762a9d77aa50aea8ed00
2017-01-20 22:54:05 +00:00
Sandra Lokshina 23a23b9b36 Make language selection explicit. Split text and variant selection.
Add UI options to select current audio and text language.
Split selectTrack() into selectText() and selectVariant().
Stop automatically disabling ABR manager when a variant is selected.
Add a warning if selectVariant() is called while abr is enabled.

Issue #412.
Issue #626.

Change-Id: I15f1c3c4fdc6d6b641f708fbef19dbcf10cbcfc6
2017-01-18 00:05:52 +00:00
Sandra Lokshina e95d7b9de4 Refactor shaka internals to use variants instead of stream sets.
Issue #279

Change-Id: Idf4241b4e2490876bdc6275685361a5c9bf132b0
2016-12-28 17:49:24 +00:00
Jonas Birmé a060050564 Provide framerate and codecs information on video tracks (#533)
Closes #516
2016-09-28 14:13:54 -07:00
Joey Parrish b7af879583 Remove hasOutputRestrictions
If a key status is 'output-restricted', treat the key as unusable.
In many cases it is, and we have no way of differentiating when it is
or is not.  So our treatment of this status should be conservative,
and we should treat the key as unusable.  This will prevent
HDCP-related failures that may be caused by adapting to a stream whose
output restrictions may not be met.  The hasOutputRestrictions flag on
streams and tracks is now gone.

The caveat to this change is that if content is encoded with the same
key for SD and HD, and HD streams have HDCP restrictions that cannot
be met, we will now consider both the SD and HD streams to be
unplayable, even though we could still play the SD streams.  Because
we can't separate the status of the two streams, we don't know for
sure if the SD streams can be played.

We will no longer support such content due to the complexity of doing
so, and due to the risk of playback failures on adaptation to
restricted streams.  Streams with different security requirements
should always be encrypted with different keys.  Content which does
not follow this best practice will no longer be playable in Shaka
without modifying the player.

Change-Id: Ia29db8efa0b6f83c0376199dea5210c9b468bc40
2016-07-13 10:40:24 -07:00
Jacob Trimble 858d3a55c7 Give warning when storing tracks of the same type.
When storing multiple tracks with the same type/kind/language, issue
a warning, since adaptation does not make much sense when playing
stored content.

Change-Id: I75d1625b2de680ae06728862d27b50272b951b7f
2016-07-13 16:16:04 +00:00
Jacob Trimble d17c9ddf22 Download different content types in parallel when storing.
Change-Id: Id66a6de7953e4c9678bbd39837d8b89601a43f8b
2016-07-11 16:10:44 -07:00