Commit Graph

352 Commits

Author SHA1 Message Date
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 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 e8ac57f36c Move drmInfos array to Stream
Period-flattening will concatenate Stream objects, so this information
should be available per-Stream instead of at the Variant level.

Issue #1339

Change-Id: I96195fea48cab1e4a349b2ab0b16064a443e928a
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
michellezhuo 3b52166f56 Remove support for custom DASH ContentProtection schemas
Remove manifest.dash.customScheme callback function since it's no longer used.

Closes #2356

Change-Id: I6d08fcf97cff1bf2985e7c660d74efcd767eaed9
2020-04-09 09:11:20 -07:00
Joey Parrish 51779cf3be Fix memory leak in live streams
Live stream tests call stop() on their manifest parsers, but nobody
was calling release() on the SegmentIndex objects.  This meant they
could continue to generate SegmentReference objects indefinitely.

In production, the Player releases all SegmentIndex objects.  But if
some Variants had been removed due to filtering, they would never be
stopped.

By having DashParser release all SegmentIndexes it generated, we can
ensure that there are no timers running after the parser is stopped.

This bug was introduced in the master branch and has not appeared in
any release.

Change-Id: If885e828b4761528e40abdbc601a11cf13849a1e
2020-04-04 03:46:15 +00:00
Álvaro Velad Galván ad33625a11 Add non-standard DASH PlayReady UUID (#2474)
Resolves #2440
2020-04-01 09:54:42 -07:00
Jacob Trimble 5f81429aef Don't allow querySelector.
querySelector isn't available in Shaka Player Embedded.  Since we only
use it to find nodes with a specific tag name, we can usually use
getElementsByTagName.

Issue google/shaka-player-embedded#113

Change-Id: Ia225e5d1f7598b13bd05db868fe2ea566dca4493
2020-03-26 16:37:26 +00:00
Joey Parrish 1ab3f9c6db Remove position from SegmentReference
As part of Period-flattening, I'm trying to remove our dependence on
the "position" field of SegmentReference.  With that eliminated, we
can more easily concatenate Arrays of SegmentReferences without
modifying them.

 - Make SegmentIndex iterable
 - Add specialized seek() and current() methods to SegmentIterator
 - Remove position from SegmentReference
 - Make positions in SegmentIndex API stable without field in
   reference
 - Remove brittle hard-coded positions in tests (except SegmentIndex
   tests, where they would be hard to avoid in testing methods
   separately)
 - Use SegmentIterator in StreamingEngine to track the next segment
   between switches

Issue #892 (refactor StreamingEngine)
Issue #1339 (period flattening)

Change-Id: I666cc21249c34ee6cbc138a59109d9f1159fa127
2020-03-23 10:09:35 -07:00
michellezhuo c82ff51d1f Add a presentationDelay config for HLS live
Closes #2373

Change-Id: I627bbd226ed9cab9bc476e2c2a3257d2e2dbc0e9
2020-03-11 18:41:15 +00:00
Jacob Trimble 3f63021a2f Avoid using "new" with factories.
Instead of having the "factories" use "new" to construct them, now they
will be plain functions.

Closes #1521

Change-Id: Ia6151ad679a78a5c6db128d43094c82add0af348
2020-02-19 09:57:51 -08:00
Joey Parrish 9f448710bc Fix DASH SegmentTemplate multi-period regression
The recent DASH refactor broke the details of multi-period segment
references for SegmentTemplate+duration.

This change introduces a corrected universal model for generating
segment references for fixed-duration SegmentTemplate content.  It has
been tested with a variety of streams from third-parties, most notably
the DASH-IF's live simulator.

Issue #1339 (flatten periods)
Issue #892 (refactor StreamingEngine)
Closes #2111
Bug: 28087927

Change-Id: Ife4e9ae2bb726e24e97dfe153882dabba4c03f2d
2020-02-05 13:37:29 -08: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
Joey Parrish 17473d5370 Fix DASH SegmentTemplate IPR regression
In an in-progress DASH stream (in which the content is static, but not
fully available yet), we will need to produce additional segment
references as time progresses.  This was broken recently during
refactors for period flattening, when SegmentTemplate with a fixed
duration was changed to use a SegmentIndex instead of generating
references on-demand.

Issue #1339 (flatten periods)
Issue #892 (refactor StreamingEngine)

Change-Id: I0239335fa7c569063f06f4416982fc5ca7d5873d
2020-01-11 21:29:59 +00:00
Leon Chen c6f0a86d73 add manifest.dash.ignoreEmptyAdaptationSet config option (#2330)
Closes #2023
2020-01-08 11:33:22 -08:00
Jacob Trimble 011749e95f Standardize argument comments.
This changes the eslint rule to enforce a strict pattern for the
argument comments.  The comment must appear before the argument and
must be /* foo= */.  This still ignores line comments.

Change-Id: I3afb01c65e1088eda13facb3aeeaa7595a2f5aee
2020-01-06 19:40:52 +00:00
Álvaro Velad Galván bdca05ff4b Add pixelAspectRatio property from DASH (#2294) 2020-01-06 10:56:28 -08:00
Joey Parrish 41a8664dba Make segment references independent of periods
This is a step along the way to flattening periods, and also
simplifies a few small things in StreamingEngine and tests.

Issue #1339 (flatten periods)
Issue #892 (refactor StreamingEngine)

Change-Id: Ie17cd5e15ed6ec9290a918c3a69c05c74581e0fc
2020-01-02 19:03:18 +00:00
Joey Parrish c13830e535 Augment SegmentReference with offset and window
SegmentReference used to have presentationTimeOffset, which,
subtracted from the period start time, was then _added_ to the
timestamps in the segment by MediaSource.

Now, SegmentReference has a timestampOffset field, which is exactly
what MediaSource's timestampOffset field is set to on the SourceBuffer
before this segment is appended.  For DASH, this is periodStart minus
presentationTimeOffset.

This also adds append window start & end times to the
SegmentReference.  Now segments can be appended to SourceBuffers
without reference to the period.

Note that start & end times of the SegmentReference in each segment
index are still relative to the period.  This will change in a
follow-up.

Issue #1339 (flatten periods)
Issue #892 (refactor StreamingEngine)

Change-Id: I9d54eb2b529ec643c9475b8e9d218c3e2e826a26
2019-12-19 11:35:14 -08:00
Theodore Abshire d95ab947e9 Added check for E-AC3 JOC in DASH.
Closes #2296

Change-Id: I776acf68f43e1e48f762a1bd68376c028e777c98
2019-12-16 17:01:23 -08:00
Álvaro Velad Galván 02fa8c6876 Add audioSamplingRate property (#2290) 2019-12-10 18:00:16 -08:00
Álvaro Velad Galván fcff08b58d Filter image adaptation sets (#2276)
* Filter image adaptation sets

* Add comment about the change

* Add test

* Change Test  name
2019-12-06 12:18:33 -08:00
Álvaro Velad Galván 8cbe54575a Allow disabling the text parsing, decoding, etc in DASH/HLS with a config (#2278) 2019-12-04 13:50:56 -08:00
Álvaro Velad Galván f6da953112 Allow ignoreSuggestedPresentationDelay in DASH (#2260)
* Add ignoreSuggestedPresentationDelay configuration

* Add test

* Change test name

* Add missing locale
2019-12-03 11:22:40 -08:00
Álvaro Velad Galván 05c03fcf64 Allow disable the video parsing/decoding/.. in DASH/HLS with a config (#2259)
* Add disableVideo configuration

* Add missing locale
2019-12-03 11:11:06 -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
Álvaro Velad Galván 585c725d09 Allow disable the audio parsing/decoding/.. in DASH/HLS with a config (#2196)
Resolves #2195
2019-10-22 15:00:36 +02:00
Álvaro Velad Galván a1ce0fea61 Use label from DASH manifest AdaptationSet (#2197)
Fixes #2178
2019-10-18 11:15:34 -07:00
Joey Parrish 0fa058662a Support pre-standard DASH MIME type
This adds support for a DASH MIME type that predates standardization
on "application/dash+xml".  Some servers still use the older, now
non-standard MIME type of "video/vnd.mpeg.dash.mpd".  This is trivial
to support, and it helps some folks who needs it, so there's no good
reason not to support it.

Change-Id: I17e85fdb74491e9e32628eddf30ef9e88acf5221
2019-08-29 09:46:17 -07:00
Jacob Trimble 50938a02a4 Remove throws directives.
These are intermittently used and cannot be verified.  Most of our
methods can throw a shaka.util.Error, so having it doesn't really add
anything.  Plus, if we change a function to throw, we'd need to update
all their callers to ensure they have an accurate description of what
they throw; otherwise we can't trust the directive.

Change-Id: I520bd0fc4c33443e967bf5b103ca5aa9e3274884
2019-08-28 17:00:04 +00:00
Álvaro Velad Galván 5a5864c653 Get PlayReady PSSH from <mspr:pro> in DASH (#2106)
Creates "pssh" init data based on the <mspr:pro> element in the DASH manifest.

Closes #2058
2019-08-23 08:46:56 -07:00
Jacob Trimble 18b59c5294 Disallow using new Uint8Array with BufferSource.
Using "new Uint8Array" with a TypedArray creates a copy of the buffer;
this is unnecessarily expensive for large buffers.  This adds a rule
to disallow using it in favor of a new utility that correctly creates
a new "view" on the same buffer.

Note it is fine to pass an ArrayBuffer to "new Uint8Array" and it won't
copy; but there there are many cases where the type is BufferSource,
so it could be a TypedArray.  Unfortunately, there are many other cases
where we explicitly pass an ArrayBuffer; but the compiler rules don't
allow us to whitelist this case (since ArrayBuffer is part of
BufferSource).

Change-Id: I58696a85a9cbcc188c0b16919c9eeb63e56edca1
2019-08-21 20:40:59 +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 0f92d8221f Fix use of private tags.
Issue #1553

Change-Id: I8c0412eda3d68f2ad475bf8282afcaeffd80852a
2019-08-13 19:08:48 +00:00
Jacob Trimble 438d599804 Parse Accessibility tag into text "kind".
Closes #2060

Change-Id: I916bbaf3357e9cdfbcfbfbafbd6dfc99890d7ebd
2019-08-05 10:27:59 -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
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
Jacob Trimble fd0dc8a5cc Add utility for looping from 0 to n.
Closes #1518

Change-Id: I865f7a0311516d04ae84532dab873e1aaa31eb24
2019-07-10 21:23:22 +00:00
Jacob Trimble 5c35108cb8 Avoid integer for loops.
Issue #1518

Change-Id: I3ba3cb6a439264e823022b2a64e7cdbd265494c7
2019-07-09 17:11:49 +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
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
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 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
Michelle Zhuo 8c8552ae7c Update media files to ES6
Issue #1157

Change-Id: I82213c9a20e7aa6e506732dc0295a61d2a67b1ec
2019-05-31 17:44:36 +00:00
Jacob Trimble a6d06cc104 Convert dash files to ES6
Issue #1157

Change-Id: I9c269bb82e791efbb5df483a4ff1701b7739a96f
2019-05-21 22:27:26 +00:00
Theodore Abshire 71afe0872b Update dash parser to ES6.
Issue #1157

Change-Id: I49644cac5081e2f1dae17700a368f7697f2fb938
2019-05-16 10:28:03 -07:00
Jacob Trimble d5780d401b Fix line length issues for indent fix.
Change-Id: I87d75fd88000f8f9bff7b9f1bf5667ba28f6dd60
2019-05-13 22:31:20 +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