Commit Graph

42 Commits

Author SHA1 Message Date
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 8796415d87 Quote exported enum keys
All other enum keys are quoted, and these should be, too.

Change-Id: If1776d9611b1102d65bab6584b19aced82b4ba81
2020-04-22 11:54:30 -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 ea84dfe494 Avoid creating buffers in PSSH.
Now shaka.util.Pssh will only create a view on the buffer instead of
re-creating the PSSH boxes for each element.  This also removes the
boundaries field since the data fields are the useful ones.

This also fixes a possible bug in BufferUtils, updates comments, and
adds some more tests for negative offsets.

Change-Id: Ibe1b7d61d5f5c7e52dfd7aa954db98f0592da4a5
2019-11-05 23:32:37 +00: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
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 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
Sandra Lokshina afa82e2692 Convert array, config and dataViewReader utils to es6.
Issue #1157

Change-Id: I3f57077939f1e8b044dc8af3c826b98e2e1003e1
2019-05-24 20:58:07 +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
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 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
Theodore Abshire 566fe8417c Don't error on reading 0 bytes
This allows us to parse EMSG boxes that contain no message
text, among other things.

Issue #1535

Change-Id: I2dfe928ead0a53d8910749c61451b90cfdb9cf49
2018-08-14 20:07:56 +00: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
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 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 c52884afed Fix 'var' scoping problems.
A follow-up fix changes all 'var' definitions to 'let'.  This fixes
issues caused by it.  One major change is adding brackets to case
statements.  Each case statement is considered in the same scope, so
defining variables in them actually are the same variable.  By adding
brackes to the cases, each case gets its own scope.

Change-Id: I99b1298223786f4df415594a2e64eb31d72b2053
2018-02-13 21:32:57 +00:00
Joey Parrish a35c2d621d Get timestamps from HLS TS segments
This adds a TS packet parser to find PTS values from the segments
themselves.

Issue #740

Change-Id: I267a9dbe5e4fc050ae63b5738c143a91cfa4f12b
2017-11-01 16:59:11 +00:00
Jacob Trimble d125a54656 Use Uint8Arrays in text parsers.
This converts from using ArrayBuffer in the text parsers to using
Uint8Array.  This avoids doing extra buffer copies when using
ArrayBuffer.slice().

Closes #1022

Change-Id: I34a789ec4eb76c95169ba81f27a8433ef25f27f0
2017-10-03 10:36:48 -07:00
Jacob Trimble 6069e76c4e Disallow ArrayBuffer.slice.
ArrayBuffer.slice isn't supported with two arguments on Tizen 2016.
This is a temporary fix that can be cherry-picked to v2.2.  A better
fix will be handled in a follow-up change.

Issue #1022

Change-Id: Iae6a0b2ef0cf17843f42f22f0ea0962a56e8be68
2017-09-25 17:28:19 +00:00
Joey Parrish eb92f14ab5 Add more missing exports
See also commit 7a770783.

This fixes exports and externs that were broken in v2.1.0 and v2.1.1.

Generated externs are now verified and working with an external
Closure project.

Change-Id: I73a6b92474c87fd6119592c6d632ce91045fc073
2017-05-12 14:54:41 -07:00
Joey Parrish 7a770783a8 Fix export of DataViewReader
DataViewReader is referenced in the exported class Mp4Parser, so it
must be exported as well.  This fixes broken exports and externs in
v2.1.0 and v2.1.1.

Change-Id: If94e623d36694dd528495f654bbb8f27d0b113ba
2017-05-12 14:24:50 -07:00
Jacob Trimble 575f2ad109 Add an indicator for critical errors.
This adds a severity field to Error objects.  This can be used to
detect whether an error is recoverable.  All the same errors are still
reported so the field can be ignored.

There are two possible values:
* RECOVERABLE means that the Player will try to recover from the error
* CRITICAL means the Player will be unable to continue and must call
  load() again

Closes #564

Change-Id: Ie2c5468340c13e7a288b99690ab65b7ecc0a6b29
2017-04-04 23:57:59 +00:00
Aaron Vaage 924e396a18 Added readInt32 to DataViewReader
Change-Id: Ib54b4997df19902c35ada8aaadbacba7292e2198
2017-03-20 12:50:55 -07:00
Jacob Trimble ded62a8205 Add more tests and remove dead code.
This brings 9 classes over 80% branch coverage.

Change-Id: Id9edf22022c3f99d21fa6cad6df6994ee751079d
2017-01-11 01:20:19 +00:00
Joey Parrish e4e200388c Fix encoding issues with Chinese subs
In many places we tried to guess the encoding of a piece of text.
This guess fails for Chinese UTF-8 text, and probably text in many
other languages.

However, DASH manifests, TTML files, WebVTT files, and VTTC box
payloads are all specified to be in UTF-8.  Rather than guess and
possibly fail, treat all text in these contexts as UTF-8.

Change-Id: I00c652a9f1dd20855e94abfac84275e41dd9e266
2016-08-25 22:29:37 +00:00
Sandra Lokshina f1a4e25151 Add support for EMSG box.
Look for EMSG boxes in segments if the manifest signals their presence.
Update the manifest when a DASH EMSG box is encountered.
Dispatch an event with the content of the box for all other EMSG boxes.

Closes #259

Change-Id: I874121207c2419e756980ac858fba0d56e68e07e
2016-08-01 14:32:23 -07:00
Sandra Lokshina 259777fe9f Implement parser for segmented TTML in MP4
Closes issue #278

Change-Id: I2f454a2c2f63d8ce6682cd4593c1d843b2967978
2016-07-13 21:49:43 +00:00
Jacob Trimble 19973d63f4 Changed copyright headers from 2015 to 2016.
Change-Id: I429ff27e4794c03b7ea392e38415075077f9bfb1
2016-03-15 16:32:13 -07: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 3bb8f06b7d Require assertion messages
This will enforce messages on assertions, which should make console
logs more useful.

Change-Id: I2cff9e20f630d1d4d46192e2ee317b1942cc7188
2016-01-08 13:29:56 -08:00
Joey Parrish a4b947c9a4 Add @struct to @constructors
Change-Id: I0c4f0468cc0f7632c71ec15e458c9a1d84a2c2af
2015-12-07 18:04:55 +00:00
Joey Parrish c934f426d8 Add new error type
This error type will be used for all internal errors, and will rely
on numeric error codes which can be easily checked by the application.

This also changes PSSH parsing to throw on errors instead of retaining
partial data.

Issue #201
b/25306826

Change-Id: I19d23d99d4ee72cb31fe5f233bac57a3a9cfc283
2015-12-04 10:26:08 -08:00
Joey Parrish 4cc4e96dbd Overhaul license comments and file annotations
* Updates all Copyright years to 2015.
* Adds licenses annotations to all JS.
* Makes all licenses identical to avoid repeated appearance in the
  compiled output.
* Drops fileoverview annotations, which do not affect docs output.
* The linter still requires fileoverview on externs.

This patch required a newer closure compiler, since the previous
version we used had a bug regarding license annotations that caused
the license comment block to appear in the output once per file
regardless of uniqueness.

Change-Id: I2e9272db680cba7ecc4613d97f1d3a94ac2244cc
2015-09-08 12:02:34 -07:00
Joey Parrish 4d9177240a Revert "Adding license annotation to js files."
This reverts commit 8cb24652cb, due to
the fact that the new annotations caused our binary size to jump
by 52%.

The compiler preserves all 'unique' licenses, which causes trouble
since the comment blocks with the license annotations are not unique
and contain file overview comments as well.

We can re-examine this once we have restructured the license headers.

Change-Id: I418e407a0e0253630633697f30cf496a7fc2ddfc
2015-09-04 18:36:39 -07:00
Yohann Connell 8cb24652cb Adding license annotation to js files.
Change-Id: Id10592ccaf35608ac4f01844cae2fec4a2030d65
2015-09-04 00:05:17 +00:00
Joey Parrish b9d2f6e8cd Fix failed assertion while parsing data-less PSSH.
When there is no data section in the PSSH, we need to skip 0 bytes,
which should not be an issue.

Change-Id: I53ab5d666f6895175a300bcc080a12e0375c3a25
2015-02-23 18:15:23 -08:00
Joey Parrish 08bdb3079b Make PSSH parser more robust.
Includes unit tests and covers zero-sized PSSHs, truncated PSSHs, and
various orderings of both v0 and v1 PSSHs.

Change-Id: I79ecc9475d483be610c003b57e831954a1c9800b
2015-02-06 10:57:47 -08:00
Joey Parrish b3d035be9f Shaka Player release v1.0 2014-12-19 14:26:19 -08:00