Commit Graph

616 Commits

Author SHA1 Message Date
Joey Parrish 186e3e69c4 Consistently take Uint8Array in text plugins
Instead of taking Uint8Array for media segments and ArrayBuffer for
init segments, take Uint8Array for everything.

Clean-up after #1022, discovered while preparing the upgrade guide for
v2.3.

Change-Id: I1f284f6f51f345e663c06d96d788bd9cfb941c52
2017-12-19 22:29:43 +00:00
Aaron Vaage c78e4a258b Close Database After Upgrade Test
On Safari it seems that deleting a database that was opened in a
previous test causes the delete call to hang. This makes sure
we close the database after each upgrade test.

Change-Id: Ie98a13515bd071cef044ee862f86d8a1a1050548
2017-12-19 09:56:36 -08:00
Sandra Lokshina 2b920e228f Add role selection to the demo app
Closes #967

Change-Id: I3a83a85b327901a6ab071b355e6cd890a13d7550
2017-12-18 11:31:17 -08:00
Aaron Vaage 1cf0a38843 Support Upgrading from Version 1 to Version 2
Added a DB Upgrade path for converting content from version 1
to the version 2 format.

Issue #1047

Change-Id: Id8dc626d8289b08ca300c40b137173c0c6ec9d35
2017-12-18 19:04:04 +00:00
Aaron Vaage 967f339934 Mark Version 2 of DB Engine
externs/shaka/offline.js now represents the data types for Shaka Player
Offline V2. All offline shaka player code uses the new version and all
V1 and transitional code has been removed.

Issue #1047

Change-Id: Ia43f8d8d11426e823629e5fcd27c4e1e0ce400d3
2017-12-16 00:11:04 +00:00
Joey Parrish f4d89cb5a1 Quick fix for Player unit tests
The player unit test setup creates a fake StreamingEngine, which
responds to a request for the current period by returning a value
captured in an anonymous function.

Because of this, any test which loads a manifest other than the
"var manifest" at the top will result in inconsistencies between
the current period known to the fake StreamingEngine and the manifest
loaded by the Player instance.

This makes sure all tests in this file are using the same "var
manifest", even if they overwrite it.

This is not the best fix.  The Player unit tests should be
restructured so that the fake StreamingEngine is always consistent
with the Player instance it belongs to.

Change-Id: Iad3b61006de3dcf902334f5348cd51fe7b5f8db4
2017-12-16 00:10:03 +00:00
Joey Parrish 4ce963415e Fix offline storage with temporary license issues
This change:
 - Fixes the use of temporary licenses with manifests without init data
 - Re-enables an integration test which was accidentally disabled
 - Makes that test use a manifest without init data, to cover #1159
 - Makes the test less flaky
 - Reduces the minBufferTime of offline manifests, which both speeds
   up load of offline content and makes the test faster / less flaky

Closes #1159

Change-Id: I3342e5112564a607f16f5d10c457a032443c57cb
2017-12-14 21:36:08 +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
theodab 8ed316d3c2 Reduced frequency of some getters on cast updates
Not all values need to be updated twice a second. This change modifies
the list of player getters so that each value also includes an update
frequency, and only updates that property once in that many updates.
This acts as a configurable way to ensure that some properties update
in different amounts, without having to have multiple update timers or
compose multiple update messages in the same timeframe.

Change-Id: I90e75e3e73f6c633d91b1799307ec2b15587327b
2017-12-14 21:02:48 +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 b8e0f8028d Do not allow null array buffers in offline segments
Do not allow a segment data object hold a null array buffer because
it should never happen.

Change-Id: Id80a5a7558ccee6aa5533a280edbe951c94e1afc
2017-12-14 00:00:11 +00:00
theodab 31b2984f6b Stopped proxying getManifest()
getManifest() hugely increased the message size when casting, to the
point where we were having message size problems.
This CL stops that property from being proxied.

This also adds an integration test that makes sure update messages do not get
too large.

Closes #1128

Change-Id: I3c4bfabb4d35ee870a603c38f784cb226366a28b
2017-12-13 22:16:30 +00:00
Aaron Vaage e7c5a3a8aa Fixed DBEngine Test Failures
It looks like some browsers don't do equality checks on ArrayBuffers
the same way as others. So to fix this, we checking that segments
are the same, convert each ArrayBuffer into an Uint8Array.

Change-Id: Iceb6e39e326ced4e86c52968e364bf927116c250
2017-12-13 21:44:55 +00:00
Joey Parrish b08ea87f7e Add support for legacy avc1 codec strings
Closes #1186

Change-Id: I87c24ee28f2c83b392a1887e77b9f2110953ef11
2017-12-13 11:37:59 -08:00
Joey Parrish 2e5b856f79 Do not require EXT-X-MEDIA-SEQUENCE in HLS live
Closes #1189

Change-Id: Iae6f4f4524bb9895f8b211491793cf7626661a5d
2017-12-13 18:49:03 +00:00
Joey Parrish 20750504fe Fix presentationTimeOffset in SegmentTemplate
We were not previously applying presentationTimeOffset in
SegmentTemplate w/ the duration attribute.  This fixes the DASH parser
to correctly apply the offset in this case.

This also fixes an issue in which segment times could stretch past the
end of the period or even past the end of the presentation, causing
StreamingEngine to fail period transitions afterward.

Closes #1164
Closes #1163 (PR to address 1164)

Change-Id: Ib16fc2b65117557a4ad9a05adc4a07f8bc90fd3c
2017-12-13 18:46:28 +00:00
Joey Parrish e669ad75ba Fix compiler renaming of destroy() on TextDisplayer
Includes an integration test that reproduces the issue.

Closes #1187

Change-Id: I15233fadcdadad8bd79dcad1fd2f1569d8de56f3
2017-12-12 15:38:20 -08: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
Michelle Zhuo d221339326 Remove empty lines in response header
Since IE/Edge returns the header with a leading new line('\n'), we need
to remove it from the response.

Closes #1172.

Change-Id: I133f9cfbada6486edc438f3dcbc37c7c78dbf36c
2017-12-12 18:03:01 +00: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
Joey Parrish 8351095ac4 Do not restrict tracks when 0 key statuses are known
For some platforms and CDMs, such as PlayReady on Chromecast, there
are no key statuses.  We still get a key status event, but there is
not even a synthetic key ID.  In these cases, do not restrict tracks,
as that would result in a 4012 error (RESTRICTIONS_CANNOT_BE_MET).

Closes #1070

Change-Id: Ib3a853418629433cc9be491a0cf7981dd41a3f59
2017-12-11 22:19:00 +00:00
Joey Parrish bc7b56d971 CastReceiver integration cleanup
Clean up several small things in the new integration test:
  - Do not use the _compiled suffix in test streams, since this test
    does not run against the compiled version of the library
  - Append the video element to the document
  - Set up wrappers in the order in which they will execute
  - Send the init message only after all other setup is complete

Change-Id: I62488474e83c44923ace9c533449794d62bc0f6f
2017-12-08 14:43:55 -08:00
Joey Parrish 5c364df655 Fix CastReceiver integration tests on Chromecast
Because we mocked out canDisplayType to return false, and because that
is actually used on Chromecast in the MediaSource polyfill, this
caused the receiver integration test to fail with
CONTENT_UNSUPPORTED_BY_BROWSER.  Because nothing was listening for
errors, this error was shown only as a timeout.

This fixes the mock and listens for errors.

Change-Id: I05a62c439666cfe1a282aa523a75e362e1674a4b
2017-12-08 22:43:06 +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
Joey Parrish 0a59da4146 Free segment memory after storage
Although DownloadManager clears the segment list as soon as it has
started the download Promise chain, the entire list is bound into the
each download function.  This is subtle and difficult to address
directly.

Instead, we set the segment data to null explicitly after the segment
is stored.  In this way, we are sure to only have one segment buffer
in memory at a time during a storage operation.

Note that there is no regression test to go along with this, because
ArrayBuffer memory consumption cannot be directly instrumented from
JavaScript, weak references cannot be used to track which buffers are
garbage collected, and the buffer references are bound into anonymous
functions and therefore cannot be found by exploring object
hierarchies.

Closes #1167

Change-Id: Ifeccbfb2d15a1a0243524c92e36512f9308fd5c6
2017-12-08 12:12:47 -08: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 540e533e69 Correct comment in DBEngine Tests
The code in the DBEngine tests were updated but the comment explaining the test
did not get updated. This change corrects the comment to match what the test
is doing.

Change-Id: I56b290c375f15eb2fba70634d1c7d4ab841af1fe
2017-12-07 18:44:00 +00:00
Michelle Zhuo 41ad98a99f Cancel text mediaState's update when not showing captions
When the user chooses not to show captions, we unload the text stream,
by canceling the update of text mediaState, and deleting the text
mediaState.

Since setupStreams_() is an async function, I'm adding a boolean
variable to mark the request of unloading text stream, so as to prevent
the race condition caused by quickly hiding and showing captions.

Closes #1058.

Change-Id: I554522b542bde5db037d74aa3a499d1ac0001151
2017-12-07 18:30:18 +00:00
theodab 5f612bd1d3 Added an integration test for cast receiver
This adds a single integration test for cast receiver, as well as a
framework for adding more in the future.
This particular test pauses at each stage in Player.load where the
player could theoretically be polled to compose an update message, and
waits for an update message to be polled. This should help catch any
further null exceptions in the cast receiver that prevent update
messages from being sent out.

Issue #1162

Change-Id: If24486dd821275ab674960e559bd6d10776955a7
2017-12-06 13:45:17 -08:00
Joey Parrish 8c80b6cefa Wait for close(), but timeout after 1s
An improved workaround for https://crbug.com/690583 and #1093, on top
of PR #1168.

If we don't wait at all, we end up trying to use the same session ID
too quickly, which causes a playback failure.

Change-Id: I8c9d1a0f09432054b862e033b80b0c2f47739c74
2017-12-05 16:47:54 -08:00
Joey Parrish 5cca0e573e Remove deprecated interfaces for v2.3
Closes #1091

Change-Id: I0c15a2bfd51c3074c749d88cd66b89ba64d1fa35
2017-12-06 00:39:11 +00:00
Aaron Vaage 2f47e6d769 Moved Legacy Variant Ids Resolution into DBEngine
Before we added variants, there was no variant ids field on
StreamDB. To support legacy downloads, we created variants
for streams with no variantIds.

This change moves that conversion into DBEngine so that outside
DBEngine, streams will always have variantIds.

Change-Id: I85d050dac0b5f82fe00947380587dd7af4401dee
2017-12-06 00:39:07 +00:00
Aaron Vaage 0e43b62f04 Fixed using wrong DBEngine name
The offline integration tests were writing to one DB Engine instance
but reading from another. This meant that it could never find what it
wrote.

Change-Id: I1d641e18401e27d906d437c70d7691f9ab448ff3
2017-12-06 00:11:20 +00:00
Joey Parrish 9759eddf54 Ignore style blocks in WebVTT
We do not support CSS embedded in WebVTT at this time.  Instead of
failing to parse the cues, skip the style block.

Closes #1104

Change-Id: I3d500ba11afe43e81bbdef9924e4dd9e05db2b85
2017-12-05 23:31:23 +00:00
Jacob Trimble bfe41a6da7 Don't always switch tracks in configure().
Configure should only switch tracks if the current variant can't be
played under the new configuration.

Closes #1138

Change-Id: I1acb8bdbb0c8b41252e978bd17ef52bec1095844
2017-12-05 18:33:02 +00:00
Joey Parrish 719ba3a2ef Do not allow seeking/startup at duration
Seeking to or starting playback at the duration does not work well
across browsers.  Any seek or startup time at or past the duration of
VOD or IPR content will be bumped back by a configurable amount
(default 1s).

Closes #1014
Bug: 69874888

Change-Id: I6d21ecd8e211f0f823a093b8eb8b95d329b4385f
2017-12-05 18:08:51 +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
Joey Parrish 45a1d71b8a Add more strict conformance checks
This adds extra conformance checks:
  - A ban on @expose, which we already got rid of in 775d7552
  - A ban on unresolved types, which did not generate any failures
  - A ban on global variables
  - A more comprehensive ban on console logging

None of these caught any real bugs in the existing code base.

In one test suite (MediaSourceEngine unit tests), the compiler was
unable to determine the type of one of the mocks, leading it to
suspect that it could possibly violate the new ban on console.error.

The goog.define('GIT_VERSION', ...) line in player.js was seen
(correctly) as a global variable.  This has been fixed and simplified
as a result.

The only custom conformance checks we are not using are "BanNullDeref"
(too many false negatives) and "BanThrowOfNonErrorTypes" (for which
we have our own, more restrictive version).

Since we have now tried all custom conformance rules provided by the
compiler today, this closes the associated issue.

Closes #1130.

Change-Id: Iad9040d0f5ee397c7d46b1d64bc5bebf2def57bc
2017-11-29 14:50:47 -08:00
Joey Parrish 07860ba4c7 Fix race condition between metadata and timeupdate
On Edge & IE, the timing of "loadedmetadata" and "timeupdate" events
is different, and exposed a race condition in the fix for #1105.
This solves the race by canceling any pending "early seek" handling
once "loadedmetadata" fires.

A fix for the fix of issue #1105

Change-Id: I5587a72e12c6b28beb0b3ea36f2665a0f1e39f08
2017-11-28 22:10:40 +00:00
Michelle Zhuo e6f675a448 Stop buffering live stream when paused
We shall not buffer live stream, when the video is paused and the
playhead falls out of the seek range.

Closes #1121.

Change-Id: I66bbe1e62017f6ae8d121f072f324763f73da0f4
2017-11-28 10:44:35 -08:00
Aaron Vaage 464a34ba4b Add events to Cancellable Chain
Added onComplete and onCancel events to CancellableChain so that someone
creating it can invoke their own code when it is cancelled or completed.

This is needed for the work on IDestroyable.

Change-Id: I5c274356e952ecbd43dd5e8809a6d4cb4e5e85c5
2017-11-27 23:44:10 +00:00
Joey Parrish d1070b4026 Allow Playhead to recover from drift
There are two ways Playhead should be able to recover from a drifting
stream:

1. Wait until the initial position is available
2. Seek to another position

Neither of these was working.  For one, we couldn't detect seeks
before content was loaded.  For another, we were constantly updating
the initial streaming position, so a drifted stream would never catch
up to our expectations.

This fixes both issues so that a drifting stream can at least recover.

Relates to issue #999 (drift tolerance)

Closes #1105

Change-Id: I8d2eedcff25b92b42ecd2e1f361d45ecbddd26ba
2017-11-27 22:43:24 +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
theodab ddd5c9f871 Don't return variant/text tracks before playhead
getVariantTracks and getTextTracks both check values on
player.playhead_, but don't check if the playhead exists beforehand.
This leads to problems when casting an encrypted asset; the cast status
update will check getVariantTracks and getTextTracks before the
playhead exists, and the error will make the status updates stop
coming.

Issue #1128

Change-Id: If38e586b1ea3006c01d3556216f5333d9eaf6e17
2017-11-27 09:14:06 -08:00
Jacob Trimble 59b48f0c8e Revert "Prevent gap jumping while seeking."
This also changes the tests so they mirror the |video.seeking|
property to reveal the problem that change created.  That change
broke seeking into gaps and gaps before the start.

Issue #1149
Issue #1150
Reopens #1061

Change-Id: I18fb65b1529acdacd0becd77078780625e0a955b
2017-11-22 23:01:36 +00:00
Joey Parrish 6e626cc84a Increase HLS partial segment size
This increases the amount of data we fetch to get HLS segment start
times.  The presence of a large PSSH box in Widevine-encrypted content
was pushing the "tfdt" box past the 1kB mark, so we will now fetch
2kB.

Issue #1137
References FR in google/shaka-packager#294

Change-Id: I51a1407c4d992e42d07c3e6c6c501051100d1620
2017-11-21 00:41:30 +00:00
Michelle Zhuo 156dd3c624 Do not load text stream if caption is hidden
If the user chooses not to show captions, we do not download text
streams, so as to save some bandwidth cost.

Closes #1058.

Change-Id: Ifd0d306680de7bd683405ad9b30b3c3c5c51097c
2017-11-20 22:47:29 +00:00
Joey Parrish e2aef50912 Disallow unknown "this"
This change enables an additional conformance check in the compiler
which prevents us from committing code where the compiler fails to
infer what "this" means.

None of these changes constituted actual bugs, just inference failures
in the compiler.

Issue #1130

Change-Id: If9b18203768e197258042a9b4339530f371ed831
2017-11-15 11:35:56 -08:00
Joey Parrish 4d191bcee0 Update one last proxy URL
I missed this in my previous change.

Bug: 69254836
Change-Id: Ia8e1b427fb36aca1bb844390a83b10426f0d6e5c
2017-11-14 14:35:33 -08:00