Commit Graph

1926 Commits

Author SHA1 Message Date
Jacob Trimble ac4fdfd0cd Make the reader types more permissive of inputs.
Now the EbmlParser and DataViewReader types can accept BufferSource
objects to avoid the caller having to convert it at each callsite.

Change-Id: I527fbc638485214bfe976d7da89b79b6098033a8
2019-08-20 22:08:27 +00:00
Jacob Trimble a2bcf7278d Move some utilities to BufferUtils.
Change-Id: Ifb3c4348cc912640b99ff53f7cac59a63480c68e
2019-08-20 22:07:35 +00:00
Jacob Trimble 596c80a949 Refactor handling of ArrayBuffer.
This changes the network API to use BufferSource instead of ArrayBuffer,
which allows plugins to return a "view" on a buffer instead of the
whole buffer.  This also adds some utilities for changing between
views and buffers.

Lastly this forbids the use of the "buffer" property of TypedArrays
since it doesn't work with partial "views".  This audits and fixes the
usages of the "buffer" property to ensure correct usage.

It should be noted that both MSE and EME accept a BufferSource as input,
so we don't need to convert a "view" into an ArrayBuffer before passing
to it.

Change-Id: Iaa417773f8ce5304424e43c7372ce10ebf540d2a
2019-08-20 20:17:33 +00:00
Jacob Trimble 32e7665fc1 Updated workaround in MediaSourceEngine.
Chrome has fixed their behavior involving endOfStream(), but both Tizen
and IE11 have the same broken behavior.  Unfortunately these platforms
will likely never be fixed, so we need to keep this forever.

Fixes #1357

Change-Id: Id540170f8c8cb6e0ddf3a30bde5035016fa61df1
2019-08-16 18:35:38 +00:00
Joey Parrish f4536acb7e Fix missing tracks, race on time during startup
During startup, there was a race between the video element's ready
state and seeking to the requested start position.  If the video
became ready before the seek to the start position, there could
briefly be 0 tracks.  Reproducing this required a first period start
> 0 and a start position > 0, such that a lookup of the "current"
period during this brief window would return null.

The problem was more likely to be seen on Chromecast, where the time
between load() and the completion of a seek was much larger than on
desktops.

The bug was caused by Playhead, which both seeks to the start position
and manages the concept of "current time", returning the start
position during startup and the video element's position thereafter.

This fixes the race, making sure that startup is not considered
complete by Playhead until the initial seek is over.  This adds an
appropriate regression test and simulated content that can reproduce
the conditions in the original bug report.

Fixes b/138941217
Fixes #2045

Change-Id: Ie8a57283468d88697619349a29e37a804586e5ef
2019-08-14 18:01:56 +00:00
Jacob Trimble 0f92d8221f Fix use of private tags.
Issue #1553

Change-Id: I8c0412eda3d68f2ad475bf8282afcaeffd80852a
2019-08-13 19:08:48 +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
Jacob Trimble d7fc19ab31 Allow filtering out failed HLS text tracks.
This adds a separate configuration value for this because (a) the HLS
parser can't access the streaming configuration and (b) this behavior
is different in that the streams are removed instead of just not playing
them.

Closes #2065

Change-Id: Ic9b1e0d40b161cd4ba0eb6d7c922882112034626
2019-08-12 18:16:28 +00:00
Jacob Trimble e660667725 Make exported docs better for Player.
- Use <code> blocks.
- Use <p> to separate blocks (since newlines in comments are ignored).
- Use <ul> for lists.
- Give messages for deprecated tags.

Change-Id: I06d5e0e75eb3e498063cf0c291e6031af5d93b2d
2019-08-09 21:50:15 +00:00
michellezhuo 1d417ff5ed HLS Refactor: Flatten createPeriod_() logic
Our previous approach:
For every variant tag, find the associated media tags(with the same
group id), create stream info for each media tag, and then create stream
info for variant tag based on that, and create variants.
This approach has duplicate calls for the media tags with the same group
id to create stream infos.

New approach:
1. Get codecs from variant tags
2. Create stream info from each media tag (with the codecs from variant
tags)
3. Create stream info for each variant tag, and then create variants.
This creates stream info for each media tag once, and avoids duplicate
calls to guess the codecs.

Issue #1558
Closes #2066

Change-Id: Icdf3133b1b15d1baf60624ff449e0a61fdb78d8a
2019-08-07 19:28:32 +00:00
Jacob Trimble c5b9d6804f Allow custom content ID in FairPlay.
Now there is a generic callback to transform the init data before
passing it to the browser.  This can be used by apps to use a custom
content ID in FairPlay content.  This also adds some utilities to help
in writing these functions and moves the default behavior to DrmEngine.

Closes #1951

Change-Id: I78ce660c126b53a69d5f55b16775ffcdbbe4d748
2019-08-07 18:38:40 +00:00
Jacob Trimble 438d599804 Parse Accessibility tag into text "kind".
Closes #2060

Change-Id: I916bbaf3357e9cdfbcfbfbafbd6dfc99890d7ebd
2019-08-05 10:27:59 -07:00
Jacob Trimble e990da0179 Remove FairPlay formatting.
Now any formatting must be done by the app the same as other key
systems.

Issue #1951

Change-Id: Ifeaa0abdfda462cd457d19f6dce93c5af3a5fdad
2019-08-05 16:52:39 +00:00
Jacob Trimble b12075093e Add sessionId field to network request.
This allows a request/response filter to determine which EME session
made the request.  This also changes the session ID of FairPlay sessions
so they are available too.

Issue #1951

Change-Id: I1a07abae6faf4a87fad7b5d4290a00b25e83da8e
2019-08-05 16:52:11 +00:00
Joey Parrish 625938e2f9 Revert offline PSSH support for manifest that are missing inline init data
This reverts commit 6e5a0797de, #2042.

The PR as it landed broke some test cases and functionality for storing persistent licenses, and it doesn't seem to work even for its intended use case.
2019-08-02 16:56:24 -07:00
Joey Parrish 7fe97b841b Move fields to SegmentReference
To prepare for flattening out the manifest structure to remove
periods, this change moves initSegmentReference and
presentationTimeOffset fields into the SegmentReference object.  This
way, the segments on either side of a period transition or HLS
discontinuity can have different offsets or init segments, eventually
allowing us to create a single array of SegmentReferences for
multi-period content.

Issue #1339

Change-Id: Ic7eff0483789644881247ecf8044c5fb6a48f0e6
2019-08-01 11:04:36 -07:00
Shaka Player BuildBot 2ad32aa5b8 Merge remote-tracking branch 'github/master' 2019-07-29 15:57:34 -07:00
Jacob Trimble 5c580e243e Throw an error when FairPlay cert not set.
Fixes #1940

Change-Id: If911986eb70838b1aa81fc85f088c8367f7e1b48
2019-07-29 21:02:21 +00:00
Ante Wall 6e5a0797de feature: Offline PSSH support for manifest that are missing inline init data (#2042)
* fix: Reference issue with SegmentReference createUris

* test: Added Segment GetUris Test for timeline

* feat: Get PSSH from segements if not initdata exists

* feat: Get PSSH from segements if not initdata exists

* fix: JSDoc comments and moved drmEngine update to storage

* fix: Remove comments

* fix: Remove unused import

* fix: Lint erros and dedup initData code

* fix: remove no init data test and add check for use persistent license
2019-07-26 11:01:05 -07:00
Theodore Abshire 3a67802ce2 Fix parseFirstCue test on some platforms.
It turns out that, on some browsers, incomplete XML does not properly
parse. This means the parseFirstCue tests did not work on those platforms.
This modifies those tests on platforms that do not support partial XML;
when no support is detected, it instead tries to get the first cue
from a non-partial segment.
This also modifies the HLS parser to only load partial text segments if
the text parser supports it; otherwise, the hls parser will load full
captions in order to extract start times.

b/137945635
Issue #2037

Change-Id: I58112864a818baf155b365a65fba1c8a56eb9520
2019-07-24 11:23:03 -07:00
Sandra Lokshina 639005b124 Don't call mediaSource.endOfStream() more than once.
MediaSource throws if endOfStream() is called when
its readyState is equal to 'ended.' This happens if
endOfStream() has already been called.
This change ensures that we don't try to call endOfStream
on the MediaSource that has already marked as 'ended.'

Closes #2050.

Change-Id: I2672b297f0ebb7fd67afcf72ee52df6d5bacf761
2019-07-23 13:01:54 -07:00
michellezhuo 292af90b7c Remove duration from StreamInfo
Change-Id: I72548e0ddb567afa3f0fc88883f8cad035398c59
2019-07-22 17:08:28 +00:00
Jacob Trimble e909a0a67f Update changelog and bump versions for v2.5.4
Change-Id: I2fae964dbe3cdde850f8349bd992827ae44a6e5f
2019-07-19 17:07:55 +00:00
michellezhuo fd326951c5 Small refactor of Hls Parser
1. Make createPeriod_() and createVariantsForTag_() clearer to read.
2. Simplify and remove duplicate code.

Change-Id: Idda7cb40f33905afd9512d427d7e78cb6c96ede9
2019-07-18 22:11:28 +00:00
michellezhuo 7c404c0cca Remove SegmentIndex from StreamInfo
Since streamInfo has stream and stream already contains segmentIndex, streamInfo doesn't need it.

Change-Id: Idb8ef793abf06e1ee3538481bf9bde42e714815c
2019-07-18 21:03:04 +00:00
Ante Wall 3e752f98b5 Fix reference issue with SegmentReference createUris (#2040)
In a recent refactor that made some internals of DASH parsing async for the first time, we broke the creation of SegmentReferences by having createUris close around values that changed later.  This fixes the bug and adds a regression test.
2019-07-18 13:26:47 -07:00
Theodore Abshire 1e12873fb7 Only parse first cue when getting text start time.
Previously, when the text engine tried to load the start time of
a segment, it would parse every cue in that segment, then check the
time of the first cue. This was judged to not be a significant
performance issue, as parsing cues is a fast operation. However, it
did have an unintended side-effect: in some situations, this method
was being passed partial segments; notably, the HLS parser would load
the first 2048kb of the stream's texts to extract timing data.
If the caption parsers tried to actually parse an incomplete caption,
they would error.
This gives the text parsers "parseFirstCue" methods, and uses those
methods when it only needs the first cue anyway.

Fixes #2037

Change-Id: I2a1fb2f1a96d98967f0c6e6a5c277914a28b42ad
2019-07-17 21:27:32 +00:00
Joey Parrish 0e20f69e8d Fix Chromecast MSE polyfill
The Chromecast MediaSource polyfill was broken in "Avoid integer for
loops", Change-Id: I3ba3cb6a439264e823022b2a64e7cdbd265494c7.

This particular loop used to start at index 1, and the previous change
made it start at 0.  Because of a test infrastructure failure that
prevented testing on Chromecast, we missed this mistake.

This bug did not affect any release versions.

This fixes the bug by using shift() to remove the first item before
the loop, instead of [0] to access it in-place.

Change-Id: I3aa53436e23a1b389375df2b06b3bbbab18ecf0b
2019-07-17 20:26:05 +00:00
Sandra Lokshina 5aefcc7fc1 Clear up the fix for enabling Chromecast.
Change-Id: Ib39f1d7a73890e5174724f05cb0d2ba465a470e6
2019-07-17 19:58:20 +00:00
Vincent Valot a88e3be128 fix ttml background image support (#2034) 2019-07-16 11:02:37 -07:00
Vincent Valot c670b55d72 enhance ttml rendering (#1962) 2019-07-12 16:25:59 -07:00
Adrián Gómez Llorente d93fb394e3 Trim base64 subtitles (#2030)
This trims the textContent containing the base64 code of the subtitles, to avoid trying to decode newlines and other whitespace as part of the base64-encoded data.

Fixes #2028
2019-07-12 14:00:10 -07:00
Jacob Trimble 2dbeb0e0c8 Fix field type in Cue.
This field is typed to be a non-nullable string, but the compiler was
ignoring this type since it was defined on the interface.  A new
version of the compiler caught this error.  Originally cr/257309718.

Change-Id: I9e7589c3b059ca39324078c867dbc27f3742a095
2019-07-11 10:21:12 -07:00
Jacob Trimble fd0dc8a5cc Add utility for looping from 0 to n.
Closes #1518

Change-Id: I865f7a0311516d04ae84532dab873e1aaa31eb24
2019-07-10 21:23:22 +00:00
Joey Parrish 85ba5e49bb Ignore case in MIME type checks
Closes #1991

Change-Id: Ib76f7539ff5173fca1ddb409e33240e7e9d3fd11
2019-07-09 20:24:50 +00:00
Jacob Trimble 5c35108cb8 Avoid integer for loops.
Issue #1518

Change-Id: I3ba3cb6a439264e823022b2a64e7cdbd265494c7
2019-07-09 17:11:49 +00:00
Jacob Trimble 19b42441ae Modify Date.now instead of using jasmine.clock.
This allows us to avoid using mock timers and makes the timing more
clear.

Issue #1379

Change-Id: I0dc4bd57c3efc0c1495e32092e4b6c3a963aeda2
2019-07-09 16:42:29 +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
Joey Parrish ce8e25dfe7 Fix broken SegmentBase content
This was broken in "Replace find/get callbacks with SegmentIndex"
because automated tests for SegmentBase did not cover multiple
Representations with different index/init ranges.  Once the parsing
became async in the previous change, the index information was being
pulled from the last Representation parsed, rather than any specific
one.

This fixes the issue by making a shallow copy of the parsing context,
as was already done for SegmentTemplate.

SegmentList is synchronous, so it was not affected.

Issue #1339

Change-Id: I09c606c464b49c99d35d1031734b64872cfa6599
2019-07-09 16:36:25 +00:00
michellezhuo 39f75fca40 Small refactor of Hls Parser
Putting the lines of getting and parsing some attribute values into
separate functions.

Change-Id: I428cd769dba36515644eab8670546bf967f39b5c
2019-07-08 22:37:29 +00:00
Joey Parrish 08cec995c9 Replace find/get callbacks with SegmentIndex
This replaces find/get callbacks in Stream with a SegmentIndex.  With
the exception of DASH's SegmentTemplate+duration, all manifests were
already backed by SegmentIndex.  Now, all manifests are backed by
SegmentIndex.  This will simplify Period-flattening, in which all
tracks will be represented by a list of segments, some of which come
from different Periods.

The SegmentIndex in Stream will not be created until
createSegmentIndex is called.  Prior to this change, the find/get
callbacks could be invoked without createSegmentIndex() in some cases
(excluding DASH's SegmentBase), which some lazy tests took advantage
of.  Now that find/get are methods on SegmentIndex, createSegmentIndex
must be called in all cases.  The tests have been updated accordingly.

Making SegmentIndex generation async in all cases exposed some issues
with the parser context being modified in-place between one
Representation and the next.  So the parser now makes a shallow copy
of the context before it is bound into an async callback.

To facilitate updating the SegmentIndex for SegmentTemplate+duration
content, SegmentIndex now has a method to update its list on a timer.
Once per segment duration, the index will be updated to add and remove
SegmentReferences.

The initial expansion of SegmentTemplate+duration will be limited to a
relatively small number of segments, to avoid excessive CPU or memory
consumption.  This defaults to 1000 segments, but is configurable.

Issue #1339

Change-Id: I99c007b1096c3b396d04a729750cd7b743cb899d
2019-07-08 22:22:13 +00:00
Jacob Trimble 001c3c7b8c Add check for common misspellings.
Change-Id: Iaf546678ed787724513ed21b19a78cc895f069e8
2019-07-08 12:08:45 -07:00
michellezhuo 77d8c04415 Small refactor for HLS Parser
1. Moving getRequiredAttributeValue_() from Hls Parser to Hls Classes.
2. Removing redundant filters in getMediaTags_().

Change-Id: Ic8eca43f51386636e307ae4255d88d78e729be8f
2019-07-04 00:11:14 +00:00
Jacob Trimble fda12e770d Update changelog and bump versions for v2.5.3
Change-Id: I49b3ac8ae1ded909f3324a9089416357cdc46c63
2019-07-03 08:40:27 -07:00
Theodore Abshire fe7f42105f Fix presentationDelay being set to NaN.
In the DASH parser, if there was no suggestedPresentationDelay and
ignoreMinBufferTime was set to true, the parser would set the
presentationDelay to NaN. This was because Math.max() will return NaN
if undefined is passed into it.
This changes minBufferTime to default to 0, if ignoreMinBufferTime is
true.

Fixes #2015

Change-Id: I8fc61706a04d14fd729e2185ce993a8bc87e48e5
2019-07-01 11:53:30 -07:00
Jacob Trimble 28cc9f6f9d Favor includes over indexOf.
Change-Id: I78a8334c025fe11d485cb2f9cb7cb4cb7dcb6c2c
2019-06-27 11:54:11 -07:00
Jacob Trimble a27f50dd43 Avoid changing variant when switching text lang.
This fixes a TODO and fixes setting the "active" track when switching
languages when not displaying text.

Fixes #2010

Change-Id: Ic4cf4126ffb9b93a09af998e20f9da0e7af852fb
2019-06-27 18:40:28 +00:00
Jacob Trimble 47533d1173 Add an enumerable() method for loops.
This is a helper to aid in iterating over items.  This returns a list
of objects that contain:
- "item": The current value.
- "prev": The previous value in the list.
- "next": The next value in the list.
- "i": The zero-based index in the list.

Issue #1518

Change-Id: Id18ab977e3ae45dfbfd2b4137a1bffb6e53c6bce
2019-06-27 16:31:42 +00:00
Jacob Trimble 60d2f1cc82 Work around MediaSource duration bug.
Fixes #1967

Change-Id: Ie2a41cb17427316ce65cf180507c1fb1f2c6f11a
2019-06-26 20:57:30 +00:00
Michelle Zhuo 2e28a6c976 Small refactor for Hls Parser
Extracting small functions from createVariantsForTag_() to make it more
readable.

Change-Id: Id8bdb08e985d31396ef34441057de9854b8704b0
2019-06-26 16:41:16 +00:00