Commit Graph

36 Commits

Author SHA1 Message Date
Álvaro Velad Galván 298b60481d fix(dash): Fix performance regression (#4064)
See: https://github.com/shaka-project/shaka-player/issues/4062#issuecomment-1077826210
2022-03-25 13:56:38 -07:00
theodab 89409cee3e feat(hls): Read EXT-X-PROGRAM-DATE-TIME (#4034)
This makes the HLS parser read the EXT-X-PROGRAM-DATE-TIME value
on manifests, and use it to make sure that segments are inserted at
the correct place in the timeline, when in sequence mode.

Issue #2337
2022-03-24 15:58:53 -07:00
Álvaro Velad Galván 771619ff0e fix: Fix support for TTAF1 namespace (old version of TTML) (#3864)
Fixes #3009
2022-01-25 10:40:13 -08:00
Joey Parrish 6aac1d7479 cleanup: Add error logs to all XML parser failure cases
While working on the issues tagged below, I needed to explicitly debug
the many possible error cases in the XML parser.  Now, each one is a
unique return with its own error log.

The order of checks has also been changed so that, for example, a
parser error at the root of the document isn't misunderstood to be a
mismatch of the root element's tag name.

Issue #3636
Issue #3627

Change-Id: I75ded6eaab2137892b93b5530023e0b39156f1ae
2021-09-15 22:50:46 +00:00
michellezhuo 7e4280fab4 fix: TTML clean up
1. Add support for multiple layers of nested cues.
2. Add support for anonymous span.

Closes #2623
Closes #2761

Change-Id: I10a253b1a965606fc2db49c3168e92bcf4a95fa1
2020-11-04 00:37:04 +00:00
Álvaro Velad Galván f42ccd2867 feat(VTT): Adds VTT tag rendering for <b>, <i> and <u> (#2776)
Closes #2348
2020-08-11 11:58:21 -07:00
Joey Parrish f539147d48 fix: Correct license headers in compiled output
This fixes all the license headers in the main library, which corrects
the appearance of the main license in the compiled output.

It seems that the `!` in the header forces the compiler to keep it in
the output.  I believe older compiler releases did this purely based
on `@license`.

Issue #2638

Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
2020-06-09 16:05:09 -07: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
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 43e798870f Misc ES6 conversions.
Issue #1157

Change-Id: Ia25a6cae84575f003980e9694b2769f2976e1342
2019-06-03 15:31:57 +00:00
Michelle Zhuo ebdf9d7817 Update Util files to ES6
Issue #1157

Change-Id: Ib81d198e46bc57745f60af328d1160064e253ba3
2019-05-30 16:40:49 +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 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
Joey Parrish cbfe4f82a4 Fix warnings found by a newer compiler version
This is only some of the warnings produced.  These were not errors,
but we should fix them anyway so that we can adopt stricter settings
in future.

Change-Id: Ifd12f0e7c69f8f4b3d0d78b11794da2569a06d77
2019-05-06 22:25:12 +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
Jacob Trimble bc4de8c26e Allow CDATA in text nodes.
Fixes #1508

Change-Id: I04817c8077b298b56ea11cb8cb8d1a6e832ce4ee
2018-07-30 21:32:17 +00: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
Michelle Zhuo 535de4db84 Refactor: Remove underscore from parameter names
Change-Id: Ie9e6fb59763f454f245175f23c6444f919ba8135
2018-05-08 19:21:51 +00:00
Theodore Abshire 7c5186332b Typo fixes and rewording in comments, part 7
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.

This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.

Change-Id: I225f5c7e54adf4cca8512cddae082ba50ed82e4e
2018-03-21 19:45:15 +00: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 f70436540c Convert 'var' to 'let'/'const' (3 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: I10f5c38a8b06b5797c6eec7492829084114514c9
2018-02-14 00:47:03 +00:00
Jacob Trimble 4dec8786bd Fix errors in XmlUtils tests.
Not setting the alias immediately confused the compiler, which lead to
it not type-checking the arguments.  This fixes the issues that were
found, namely problems with nullable values and that Document isn't an
Element (although our code works with it anyway).

Change-Id: I9ef95673dc52dae9a811baee74b353132eb0fae3
2018-02-13 13:38:28 -08:00
Joey Parrish 4067c20a7c [ES6] Replace gjslint with compiler linter & eslint
The eslint configuration is derived from analyzing the style of our
sources as they are now, plus a few tweaks.

In particular, we have disabled checks for undefined variables and use
of console, both of which the compiler handle with greater precision.
The compiler already knows what is defined in the environment through
our externs, and has specific exceptions for the use of console (demo,
tests).

We have also disabled a few checks that we should use, but will
require many changes to the code: no-unused-vars, no-redeclare,
and comma-dangle.

This commit also fixes several types of eslint errors that were easy:
  - no-useless-escape (unneccessary escape characters in Regexp)
  - no-constant-condition (using true/false/0/1/etc in if/while)
  - no-fallthrough (caught an actual bug in one EME polyfill)
  - no-irregular-whitespace (we had a UTF-8 nbsp in externs)
  - no-cond-assign (using an assignment inside a conditional)

To satisfy stricter provide/require checks in the Closure Compiler
Linter, we will no longer use provide/require at all in tests.  We
will still use provide in test utilities (test/test/util/) since it
sets up the namespace for us.  But we will not use require there
because there is no deps management for test code.

Issue #1157

Change-Id: Icc44f51feeb568ea7d3980e693e92e560d897afd
2018-01-16 17:25:05 +00:00
Jacob Trimble 7a5991a01d Fix date parsing when timezone is missing.
In DASH, when parsing a date, it should default to UTC.  When we pass
the date string to Date.parse(), it will use the local timezone.  So
if we don't see a timezone, we need to manually add the UTC timezone
so Date.parse() will parse the correct timezone.

Closes #901

Change-Id: Ica0433042e9bfd42b0cbf62653bdbd2b97b56297
2017-06-20 12:43:23 -07:00
Joey Parrish 6cfd337680 Remove unnecessary triple-equals usage
Change-Id: Ibfd76f8b36926e41e9bf2fd26b5bea16d3bd8f2a
2017-02-06 22:20:09 +00:00
Ross-cz 3b7328b530 Fix playback when IE11 modifies the XML DOM (#611)
When there is a hypen contained inside manifest Location/BaseUri element and the application uses MutationObserver, IE11 can change the XML DOM of the manifest and break playback.

This changes the way the document is parsed so that it is resilient to these unintended changes.

Related IE bug: https://connect.microsoft.com/IE/feedback/details/1398926/ie11-does-not-parse-cdata-containing-hyphens-correctly

Closes #608
2016-11-29 13:39:15 -08: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 eafe954d0c Replace Number.POSITIVE_INFINITY with Infinity
This is supported on all browsers, is more compact, and is easier to
read.

Change-Id: I96576dc341e093b7be9ef94fe36595c945b063c1
2016-08-29 18:56:54 +00:00
Joey Parrish 32e351d060 Add @namespace annotations to static classes
Without @namespace annotations, static classes do not show up in the
generated API docs.  Although I stumbled over one instance while
writing tutorials, the rest were discovered programmatically by:

for x in $(find lib/ -name '*.js'); do
  grep -Eq '@(constructor|interface|namespace)' $x || echo $x
done

Change-Id: I97dd2bb4bf3faad5ac8d952a28837fa1f594deb9
2016-04-01 11:37:41 -07:00
Jacob Trimble 8b85e58f73 Add several utility functions.
Change-Id: Ifbd2582747d2cb54d4abda789b0989b7a6b77aa6
2016-03-29 20:17:44 +00:00
Jacob Trimble 8daf53e329 Renamed shaka.asserts to goog.asserts.
Using goog.asserts will work with the compiler.  So rather than
simply casting a nullable value when passing to a method, we can use
an assert which will correct the type and print a log if it somehow
is null.

This is not the same goog.asserts found in closure library, this
simply calls console.assert, but it is not required to do anything
for the compiler help.

Change-Id: I2548e39e772f0aa7ec41437cf9f5a2be383e0fbd
2016-03-11 15:29:20 -08:00
Jacob Trimble 846e7beb48 Unified comment spacing.
Before there were two style to indent comments after an annotation,
using 2 and 4 spaces.  Now this only uses 2 spaces.

Change-Id: Id06415d7193cc154a2768fb3932aff7a06b7ed32
2016-03-10 16:27:45 -08:00
Joey Parrish 78e996d090 Fix issues found by the newest Closure compiler
Fixes the following issues:
=====

lib/player.js:106: ERROR - Property id never defined on TextTrack

lib/util/xml_utils.js:42: ERROR - inconsistent return type
found   : (Node|null)
required: (Element|null)

lib/dash/content_protection.js:256: ERROR - Parameter must have JSDoc.
      function(element) {

lib/dash/content_protection.js:284: ERROR - Parameter must have JSDoc.
      function(elem) {

lib/media/drm_engine.js:47: ERROR - Private property configuration_ is never read

lib/polyfill/patchedmediakeys_20140218.js:269: ERROR - Private property keySystem_ is never read

lib/polyfill/patchedmediakeys_20140218.js:389: ERROR - Private property type_ is never read

lib/util/language_utils.js:84: ERROR - The value 0.0 is duplicated in this enum.
  MIN: 0, MAX: 2

lib/util/language_utils.js:84: ERROR - The value 2.0 is duplicated in this enum.
  MIN: 0, MAX: 2

demo/assets.js:171: ERROR - Value assigned to local variable headers is never read

lib/dash/content_protection.js:188: ERROR - Value assigned to local variable repUnknown is never read

lib/dash/dash_parser.js:400: ERROR - Value assigned to local variable suggestedDelay is never read

lib/dash/segment_base.js:41: ERROR - Value assigned to local variable SegmentBase is never read

lib/dash/segment_template.js:291: ERROR - Value assigned to local variable periodStart is never read

lib/media/drm_engine.js:172: ERROR - Value assigned to local variable onEncrypted is never read

test/dash_parser_live_unit.js:358: ERROR - Value assigned to local variable manifest is never read

test/drm_engine_unit.js:383: ERROR - Value assigned to local variable cert1 is never read

test/drm_engine_unit.js:384: ERROR - Value assigned to local variable cert2 is never read

test/media_source_engine_unit.js:24: ERROR - Value assigned to local variable dummyData is never read

test/media_source_engine_unit.js:504: ERROR - Value assigned to local variable p2 is never read

test/media_source_engine_unit.js:505: ERROR - Value assigned to local variable p3 is never read

test/media_source_engine_unit.js:506: ERROR - Value assigned to local variable p4 is never read

test/media_source_engine_unit.js:535: ERROR - Value assigned to local variable p2 is never read

test/media_source_engine_unit.js:601: ERROR - Value assigned to local variable p2 is never read

test/media_source_engine_unit.js:602: ERROR - Value assigned to local variable p3 is never read

test/media_source_engine_unit.js:603: ERROR - Value assigned to local variable p4 is never read

test/media_source_engine_unit.js:632: ERROR - Value assigned to local variable p2 is never read

test/mpd_utils_unit.js:20: ERROR - Value assigned to local variable HUGE_NUMBER_STRING is never read

test/streaming_engine_integration.js:55: ERROR - Value assigned to local variable onSeek is never read

test/streaming_engine_unit.js:1263: ERROR - Value assigned to local variable reportedContentType is never read

test/streaming_engine_unit.js:1264: ERROR - Value assigned to local variable reportedPeriodIndex is never read

test/streaming_engine_unit.js:1540: ERROR - Value assigned to local variable size is never read

test/util/dash_parser_util.js:77: ERROR - Value assigned to local variable retry is never read

test/util/dash_parser_util.js💯 ERROR - Value assigned to local variable retry is never read

test/vtt_text_parser_unit.js:272: ERROR - Value assigned to local variable result is never read

Change-Id: I707700250541e04ccbfe81d7298b3f0c5a82dcdc
2016-03-03 16:04:58 -08:00
Jacob Trimble bfa42a8d1e Fix argument bug in Dash parser.
This also changes from using Node types to using Element types.  This
is more correct since the code only deals with XML elements and not
with other Node types (e.g. text content nodes).

Change-Id: I0e8c7bf2adc1800a494e575b16661e8c69a7deb0
2016-02-11 15:14:52 -08:00
Natalie Harris 388466dd6f Move XML parsing functions to XML util class.
Change-Id: Iea7256eff9f2f7a60607743cd6cf95e6762bd961
2016-01-08 23:02:25 +00:00