Commit Graph

310 Commits

Author SHA1 Message Date
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
Michelle Zhuo c3cf3f1b87 Use async/await in Dash parser
Closes #1402

Change-Id: I4e11dd7976bb5ad9be528b251ef41f2a07aa4afc
2019-05-09 22:40:23 +00:00
Jacob Trimble ded2b84313 Require consistent return values.
This enables the eslint rule that requires all functions to consistently
either return a value or not return a value.

Change-Id: I98b579f3689c3b6c74968116824231bb792bd9dd
2019-05-09 20:34:47 +00:00
Jacob Trimble 47daf49f31 Use arrow functions for callbacks.
This is an automated change to convert use of "function" functions
to arrow functions.  This doesn't change all uses of bind() that
could be converted.  This also doesn't remove all "function" functions.

Change-Id: I40ac7d086bcef947a1be083359c8fd1d4499a9c3
2019-05-09 16:40:46 +00:00
Jacob Trimble cea3161ce9 Misc fixes for arrow functions.
A follow-up commit will convert "function" functions to arrow functions.
This caused some errors with the compiler, which this change fixes
beforehand.

Change-Id: Iff85b1e1f56b63a38b09f8db9947ed5daf02ddf4
2019-05-08 20:43:20 +00:00
Jacob Trimble c81389741f Prefer const over let.
A coming update to the Google eslint config will require using "const"
over "let".  This makes that one change to isolate the big changes.

Change-Id: I7d0974c3ae15c53cc45a6b07bf9f6586e2d34aca
2019-05-08 09:22:10 -07:00
Jacob Trimble a453095412 Misc fixes for const.
This prepares some changes for the conversion from "let" to "const".
This ensures the follow-up is just an automated change with minimal
intervention.

Change-Id: I19b24dc67f20038dffd36b8903547f6ee4f00c25
2019-05-08 16:17:58 +00:00
Joey Parrish 685e9d57cf Eliminate free calls of static methods
It is type-safe to alias a class, but not one of its static methods.
Aliasing the method without the class makes it a "free call" to invoke
the aliased method.

A "free call" is when you call a method without the context of its
instance of class.  There were several cases of this with static
methods.

This will be enforced by a future release of the compiler, which I
believe will lead into compiler support for "this" in static ES6
methods.  In ES6, you can use "this" in static methods to refer to the
class and call other static methods.  Closure compiler doesn't support
static "this" yet, but we will start using it as soon as it is
supported.

Change-Id: I4249db8b6dda9231ebba60ee0d4ad734a692c2fe
2019-05-03 18:43:35 +00:00
Joey Parrish c0c203cf2d Fix compiler errors found by a newer compiler
Change-Id: I83d81bcdc955331dc7afcc25c45802e77b7b7c02
2019-05-03 18:43:35 +00:00
Álvaro Velad Galván 65e9957647 Make manifest redirections sticky for updates (#1880)
Closes #1367
2019-04-15 12:15:44 -07:00
Aaron Vaage 25710b6c33 Refactor Segment Request Creation To Be Shared
In four different places in our code base, we did the same
work to create a segment request. The bulk of the work was
based on setting-up the range header.

This CL creates a common utility that will create the request
for us while keeping networking engine as ignorant to segments
as it was before.

Issue #1788

Change-Id: Ie3dc2a99a34b3925fecbfdaae7b1e178a0b7a3b6
2019-03-12 21:18:27 +00:00
Aaron Vaage 71fb7a03ec Use Timer/DelayedTick instead of setTimeout
This CL limits the use of |setTimeout| by wrapping it in our own timer
class. The timer class makes it easier to track and cancel time-based
events.

To ensure that|setTimeout| is not used outside of our timer classes, the
conformance rules have been updated to only allow |setTimeout| to be
used by our timer classes.

Since |setTimeout| is very similar to |setInterval|, the conformance
rules for |setInternal| rules were updates to reflect more of the logic
behind why we don't want to use |setTimeout| and |setInterval| directly.

Change-Id: Iff5da32a61b515dd2016837fa74a34c04b6c5fd2
2019-03-12 18:52:32 +00:00
Joey Parrish 9167ce4eb9 Fix several typos
These were found by an automated tool internal to Google.

Change-Id: I6def5463c0e5af315b168ff4c0bb91eb2ee34de1
2019-02-20 21:58:40 +00:00
Jacob Trimble 2d99929400 Add option to disable drift fixing.
The drift fixing allows us to play content that has drift by starting
to play at the last segment in the manifest.  But some live content
specifies content in the future, so we can't just start playing at the
last segment in the manifest.

Fixes #1729

Change-Id: I3095a2d28b34ed93346933f561d77335361f1fae
2019-02-15 22:50:16 +00:00
Joey Parrish 02350fbe66 Fix config-based clock sync for IPR content
The configured clock sync URI was only being used for true live
streams, but there are cases where it is needed for in-progress
recordings, as well.  This came up while working with a partner on
issues with CEA caption support.

Related to b/70902665

Change-Id: Ie7199dec3177a7ed014d9d0d9aaeb9f1bb1dbeac
2019-02-13 02:45:16 +00:00
Tyler Daines 3c8241f3c7 Add license url parsing (#1644)
This adds parsing license URLs to the DASH parser so the URL can be embedded in the manifest.

Fixes #484
2018-12-13 10:58:27 -08:00
Michelle Zhuo fd91f6ab73 Fix relative location urls
Fixes #1668

Change-Id: Ib9e1a19254f1829795bd69cc930d21f33e136980
2018-12-07 20:01:10 +00:00
Michelle Zhuo f2b9e3fdf1 Add support for CEA with no channel and language info for Dash
When the dash content has CEA closed captions signal but no detail
information about channel number and language, we show the default
caption information.

Issue #1404

Change-Id: Ie6ca77739a043d24832efc5a28d4ba708dc4b17f
2018-11-08 22:19:01 +00:00
Sandra Lokshina 34408b9c26 Notify min segment start time when creating stream.
Fixes #1601

Change-Id: I132f05a23129fca944e955cbf8a347e735724b37
2018-11-07 15:11:33 -08:00
Michelle Zhuo 19a38ed6b5 CEA closed captions for Dash
Adding support for CEA closed captions embedded in video streams for
Dash.
1. Dash parser reads and parses closed captions' channel and language
information.
2. Player creates text streams for the closed captions.
3. Media Source Engine calls mux.js Caption Parser API to get the closed
captions embedded in the video streams.
4. Text Engine stores the closed captions, and text displayer shows the
captions.

TODO:
1. Add test cases, will send out another CL.
2. Change closed captions support for hls to the similar way we handle
dash closed captions, will send out another CL.
3. Handle dash content that's missing language indication from the manifest.

Issue: #1404
Change-Id: Ibae8f69623c13561415ec860107d7f5bc86e19e9
2018-11-06 09:53:18 -08:00
Jacob Trimble 140105b0a2 Optimize processXlinks.
- Only traverse children once.
- Avoid traversing into SegmentTimeline, which is usually large and
  won't contain xlinks.

Issue #1640

Change-Id: I8a7a05d580740f9a9953b0a8aec89a06cc7e33f2
2018-10-24 11:38:36 -07:00
fadomire 99ebc693f2 Add config field to ignore manifest minBufferTime #1547 (#1581)
Add the config field manifest.dash.ignoreMinBufferTime, which will default to false. If true, the DASH parser will ignore minBufferTime in the manifest, such that streaming.rebufferingGoal is the only factor in play.

Closes #1547
2018-09-21 12:51:33 -07:00
Aaron Vaage 2ad4a582a2 Stop Using MapUtils and Functional in ContentProtection
Updated shaka.data.ContentProtection to not use |MapUtils| or
|Functional|.

Change-Id: I73577766d3a9189acae41946c461b7af8e27116f
2018-09-17 16:40:01 +00:00
Aaron Vaage f8b707aaeb Use Sets For Uniqueness
Update all our code to use |Set| to handle storing and testing
unique values.

Change-Id: Id809d4d84e4779ae19be58eca96983750c3f3a81
2018-09-14 22:03:04 +00:00
Joey Parrish 7091275cbf Replace indexOf with includes, startsWith
This replaces almost every instance of indexOf on both String and
Array.  There are very few places where we really wanted an index.
Mostly, indexOf was used to check for inclusion.

Change-Id: I08e299768b6ffdb4bfc30b39b5d82a058c6d1b56
2018-09-14 19:10:56 +00:00
Michelle Zhuo 5de57c0725 Revert "Change closed captions to an array"
This reverts commit 59920fa80b.
Issue #1404

Change-Id: I90cf8a274949c15779f0193783076ab687fcb9fb
2018-09-12 13:15:49 -07:00
Michelle Zhuo 59920fa80b Change closed captions to an array
Changed the ClosedCaptions field in Stream from an object to an
array of ClosedCaption objects, so that it can be iterated through
and accessed easier.

Issue: #1404.
Change-Id: I67980cf4d5b5746785ba29f95718970fe89056f4
2018-08-31 17:10:36 -07:00
Damien Levin 6117125f2b Emsg not referenced in MPD should be ignored.
Fixes #1548

Change-Id: Ib65957fa43b97e7c8ad61c08923a30de86febb6c
2018-08-22 16:48:02 +00:00
Joey Parrish ca3119dfba Correct segment timestamps in PresentationTimeline
Before, segment timestamps were used in PresentationTimeline without
regard for the period start.  This means they were not truly relative
to the presentation, but to the period.

The "isFirstPeriod" argument was also broken.  It was meant to be true
for segments from the first period *ever*, but was passed true for the
first period *in the latest manifest update*.  So data calculated from
that was bogus for live streams.

Now, notifySegments() is supplied with a period start time, so that
segment references can be combined with the period start to give
presentation timestamps.  This fixes a major issue with the original
fix for #999.

Closes #999

Change-Id: Id0fe450f3ce4f90a2387d7103c75eb88f0c69c72
2018-08-20 19:10:02 +00:00
Michelle Zhuo 5ef31d4bab Add closedCaptions field to stream
Dash and Hls manifests have tags and values to indicate that the content
may have CEA608/708 closed captions embedded in the video content.
Adding a closedCaptions field in Stream to represent that, and adding
parsing closed captions tag for DASH parser.

Reference:
HLS: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.4.2
DASH: https://dashif.org/wp-content/uploads/2018/04/DASH-IF-IOP-v4.2-clean.pdf

Issue: #1404.

Change-Id: I3c58b6043f7fe294dd642bdada8d2451caec9b55
2018-08-17 21:20:09 +00:00
Joey Parrish 96237671d7 Avoid assertions about $Time$ when it is not used
In some environments, goog.asserts.assert can cause an exception to be
thrown.  Therefore, we must avoid spurious assertion failures.

In this case, the assertion about $Time$ could fire even if $Time$ was
not being used in the URI template.

Change-Id: Idba351989cd439f5202373d1ecb71804b372705e
2018-08-13 09:59:28 -07:00
Joey Parrish 2aacdd25c9 Expose DASH Representation IDs in new field
The DASH parser will now expose Representation IDs via new fields in
the Stream and Track objects.  The "id" field will continue to be a
unique, auto-generated numerical ID, and will be supplemented by a
nullable string containing whatever was originally in the manifest.

The HLS parser will now expose the NAME attribute in the originalId
field as well.

Bug: 112087288

Change-Id: I6b8107d27780fb97ab18de767f7abdc6c7110fe7
2018-08-09 17:08:42 +00:00
Aaron Vaage 83d8d07635 Resolve Closure Warning
Closure was giving the warning "incomplete alias created for namespace
shaka.util.ManifestParserUtils". This change removes the alias which
resolves the warning.

Change-Id: Ie0ad79b217ba0b4f82eb6b45325075d1f1f4faa0
2018-08-08 10:28:25 -07:00
Joey Parrish 7a1c662b8a Tolerate drift in DASH live streams
This calculates the DASH live edge from explicit segment descriptions
when we have them.  The net effect is that availabilityStartTime will
only be used with SegmentTemplate+duration, in which we have no
explicit segment times.

With this, a DASH live stream experiencing encoder drift can still be
played so long as we know the segment times.  This makes playback of
DASH live streams work more like HLS live streams.

Please note that DASH live streams using SegmentTemplate+duration may
still suffer from encoder drift.

This change also:
  - Avoids DASH clock sync when availabilityStartTime is not used,
    which should reduce startup latency
  - Removes the simulation of a presentation start time for HLS live
  - Renames some variables and improves comments for clarity
  - Fixes some brittle tests that made bad assumptions or instrumented
    the wrong methods
  - Adds new tests that show the new behavior in PresentationTimeline

Closes #999

Change-Id: I21d7f3ccc81c9d9e218857a9b41882a7609ca36a
2018-08-07 18:34:16 +00:00
Joey Parrish ecd27fbf45 Move availabilityWindowOverride to manifest parsers
This reverts the implementation to an earlier draft state.  During
review of the first version, I recommended moving the implementation
to Player so that it would be independent of the manifest parsers.
That was bad advice on my part, because this overlooked updates made
by the parsers when live manifests are updated later.

Closes #1177
Closes #1307

Change-Id: I4611e00824dead83c6467da04a2a11afa892ace7
2018-07-20 12:43:49 -07:00
Patrick Cruikshank e312c3a40b Add new request type TIMING for clock sync requests (#1489)
Fixes #1488
2018-07-16 09:38:52 -07:00
Joey Parrish fd0449d8f7 Re-enable some disabled style rules
This re-enables the following style rules:
  - "block-spacing"
  - "brace-style"
  - "comma-dangle"
  - "comma-spacing"
  - "new-cap"
  - "no-multi-spaces"
  - "no-multiple-empty-lines"
  - "one-var"
  - "padded-blocks"
  - "prefer-rest-params"

Change-Id: I15d616e8d5b88b273ded6128b4f9ad86bdb26bd1
2018-07-09 19:44:56 +00:00
Joey Parrish 64d72fe08c Skip text AdaptationSets with no segment info
See also google/shaka-packager#422

Closes #1484

Change-Id: I293468a39918a4a8487d15ec70b365eec3dd1ebc
2018-07-03 18:27:14 +00:00
Jacob Trimble 759eef9685 Change goo.gl links to bit.ly.
https://goo.gl is being turned-down, so we can't use it for new URLS.
So we have consistent short links, this converts them to be
https://bit.ly.

Change-Id: I07a86cba807b67157664893341f648023918d0de
2018-06-22 20:20:00 +00:00
Joey Parrish 95a55c7240 Avoid clearkey w/ DASH mp4protection scheme
When a DASH manifest has a ContentProtection element with the generic
"mp4protection" scheme, no particular key systems are specified.  When
this happens, we assume that any of the well-known key systems could
work.

Since a recent change (Ib74b0b7477cb47f80fda2e1184c86ab37771c105) to
the demo app, we are now providing the library a license server config
for clearkey, which enables DrmEngine to select the clearkey CDM for
any generic mp4protection content.  This causes playback failures when
the license server URI points to Widevine, PlayReady, or any other
real key system.

With this change, the demo can still be used to test explicit clearkey
DASH content which uses "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", the
UUID for clearkey.  But we will no longer inappropriately select
clearkey for the generic "mp4protection" scheme.

Fixes: 110281315

Change-Id: Ie6ee4e08e749dd38852f0096df35d35f3d3b2cee
2018-06-21 23:31:07 +00:00
Theodore Abshire b212ef9b4f Fix bug with merging a period into itself
When we try to merge two SegmentIndex objects, we check to make sure
that they are sequential.  Then, after merging the various SegmentIndexes,
they are fit.
This causes problems when trying to merge two identical periods together,
an operation that could potentially happen in a live stream.
SegmentIndex.merge was comparing the post-fit version of one SegmentIndex
with the pre-fit version of another, causing it to believe that the two
SegmentIndex had different end times when really they were identical.

This change causes SegmentTemplate.createStream to perform an extra fit
operation before merging, to avoid that problem.

Closes #1448

Change-Id: If2e9a9a91de344b7ab8cd9004da0553b324cb599
2018-05-30 16:48:51 +00:00
Joey Parrish 321896db3f Fix private annotations and names
These errors were discovered by a more up-to-date compiler.

Change-Id: Ic678e259406ac6fa43c4cb355ad72118cd563f57
2018-05-23 14:29:12 -07:00
Jacob Trimble 866b0e18ef Fix non-default namespace names in DASH.
XML allows namespace names to be any string.  So instead of looking
for the literal name 'cenc:pssh', we should be looking for the 'pssh'
name in the correct namespace.

Closes #1438

Change-Id: I724db3b7f0e60b4233b0fc40b1ed57698c6ce9ce
2018-05-21 20:02:18 +00:00