Commit Graph

44 Commits

Author SHA1 Message Date
Wojciech Tyczyński 6e55a3b21b build: Forbid using dot in generic types (#7904)
Fixes #2643

Happy reviewing!
2025-01-20 09:39:51 +01:00
Wojciech Tyczyński eeadace2be feat: Add public method for parsing cue payload (#6992)
Close #4439 
Needed for #6985
2024-07-05 16:21:15 +02:00
Álvaro Velad Galván bd636d4edf fix(HLS): Show WebVTT subtitles with X-TIMESTAMP-MAP in segments mode (#5643) 2023-09-12 14:27:18 +02:00
Álvaro Velad Galván 62156bae02 feat: Use shaka.text.Cue everywhere instead of shaka.extern.Cue (#5529)
Closes https://github.com/shaka-project/shaka-player/issues/2818
2023-08-25 10:51:28 +02:00
Álvaro Velad Galván c6e8449468 feat: Parses a TFDT Box, with a loss of precision beyond 53 bits (#5501)
Related to https://github.com/shaka-project/shaka-player/issues/3784
2023-08-19 05:29:49 +02:00
Sacha Elkaim 6fd44c4910 fix: Handle empty media segments for Mp4VttParser (#5131)
Fixes #4429
2023-04-04 02:12:21 -07:00
theodab a4e926772e fix(text): Fix webvtt offset in sequence mode (#3955)
When running in sequence mode, we ignore the normal timestamps
of video and audio segments. This lead to problems in some Apple-
encoded webvtt content, which used the X-TIMESTAMP-MAP tag to account
for the timestamp offsets in their video. Thus, those subtitles would
end up 10 seconds offset.

This changes the webvtt parser to ignore the X-TIMESTAMP-MAP when in
sequence mode.

Issue #2337
2022-02-16 11:38:20 -08:00
Álvaro Velad Galván 6db55e0141 feat: Add support for WebVTT style blocks (#3071) 2021-02-18 16:01:36 -08:00
Joey Parrish 562a2d567b chore: Strictly require jsdoc
This enables the eslint rule requiring jsdocs on all class
declarations, function declarations, and methods.

Unfortunately, there are two problems with this:

1. We don't use class _declarations_, we use class _expressions_,
which are not covered by this rule.  So it does not enforce jsdoc at
the class level.
2. We tend to document a class at the class-level, rather than at the
constructor.  But a constructor counts as a method for eslint, so it
requires docs on the constructor.  There is no way to configure it to
make an exception for trivial constructors.

So for all trivial (no-argument) constructors, we add empty jsdocs:
  /** */
  constructor() {

This was quicker and easier than setting up some alternative plugin in
eslint to make an exception for us.

The good news is that this rule caught several undocumented parameters
and places where the jsdoc comment was malformed.  So fixing those
also improves the compiler's ability to enforce types.

Change-Id: Icbc46ed690c94e53d354648a883119524f8fca45
2021-01-09 02:00:31 +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
Muhammad Haris e8f24ece6f Created MP4 Box parsers to parse data for common box types (#2649)
Issue #2648
2020-06-15 17:35:38 -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 92ecacb663 Export default text parser plugins
This makes it easier for apps to app-specific build subclasses of
these plugins.

Closes #2428

Change-Id: I4fde7de76c139bfeddc1afecccf9374a49ecee19
2020-02-26 10:22:27 -08: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
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
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
michellezhuo 9d66e3bb09 [Hls] Avoid duplicate calls to get segment start time for VOD
For VOD, the first segment of every Media Playlist in every Variant
Stream must start at the same media timestamp. Thus, we can get the
start time once and store the value, and all the streams can use the
value directly. For live, we assume for the same.
This change reduces calling getStartTime_() from 15 times to once for
Angel One, and also fixes the text segment timestamp issue.
Also removed associated methods that no longer needed.

Closes #1558
Closes #1563

Change-Id: I0e95ab93ea2b13758128f11019b262bc53dbcd38
2019-09-30 15:43:57 -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
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
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
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
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 5ddb92a4ee Convert text files to ES6.
Issue #1157

Change-Id: I33df747b0fad0e6d8f5e3d7dc8f5c93bd07800b1
2019-05-21 22:31:19 +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
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
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
Sandra Lokshina 8065bd54a8 Change namespace from shakaExterns to shaka.externs
Change-Id: I16432351e2a266aa8fd175669aa27c44bfdffeae
2018-04-11 17:26:26 +00:00
Theodore Abshire 8ea237c214 Fixes how the MDAT is read for VTT in mp4 content.
Previously, we would read each individual VTTC and VTTE box in the
MDAT and associate them with durations in the TRUN. This worked for a
lot of content, but if sampleSize is defined in the TRUN, a duration
might refer to multiple VTTC boxes.

This changes the VTT in mp4 reader to parse the MDAT based on the TRUN,
to account for such situations.

For the moment, this only accounts for a single MDAT, and assumes that
the MDAT contains nothing but vttc or vtte boxes, listed in order.

Issue #1266

Change-Id: I56e310d085abdda16e968761ed3b4fd0cc5e24d0
2018-03-27 17:10:48 +00:00
Theodore Abshire d46e8fdf92 Typo fixes and rewording in comments, part 6
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: I2bfa4d531a8fcdcf9578e9c181c4534ad7443b7a
2018-03-21 17:59:42 +00:00
Jacob Trimble b512db87dd Convert 'var' to 'let'/'const' (8 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: I6a329d28e13a81c9f7136737518c6bb8fa18402e
2018-02-20 11:29:30 -08:00
Sandra Lokshina 118756e8e8 Add parsing of VTTRegions and TTML attributes set in pixels.
Closes #1188

Change-Id: Ib9fc1a5b35065fdadafae01df4737ce1dcfa3ada
2018-02-08 18:19:31 +00:00
Joey Parrish a18dc01874 Remove broken HLS time offset code
We misinterpretted the EXT-X-START tag before.  Now, we ignore this
tag and parse segment times from the segments themselves.  This is
more robust for both VOD and live HLS content.

We avoid segment parsing when updating normal, well-behaved live
streams.  For poorly-behaved live streams, we will fall back to
segment parsing and recover.

This also addresses the issue of VOD content which does not start at
zero.  Instead of using configuration to make this playable, we will
now offset VOD content back to 0 automatically.

Issue #740
Closes #1011

Change-Id: Ib3a59f87e3a050244cd39854409d8e3542c50b0a
2017-10-30 18:51:29 +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 2c30ac70b1 Fix shaka.text.Cue in compiled builds.
The fields in shaka.text.Cue were getting renamed in compiled builds,
which would cause problems with custom text parsers or text
displayers.

Change-Id: I5a1c05ad373aca722268417c55a84f195e53ee20
2017-09-15 20:55:14 +00:00
Joey Parrish 7d36a2091f Parse default duration in WVTT MP4s
This adds support for WVTT samples with no sample duration by parsing
the default duration from the "tfhd" box.  If neither is provided, we
now log an error to the console.

Closes #919

Change-Id: Icc5550de7bc6018253004a5d3429ccc083ff6cb6
2017-08-07 19:45:18 +00:00
Sandra Lokshina c70367dc97 Separate text parsing and display logic.
Closes #796.
Closes #923.

Change-Id: Ifc2017b40a0fb570103f0fed7bc130aa24819e9f
2017-07-17 21:39:59 +00:00
Jacob Trimble 845c9af2f6 Fix text track reinitialization.
We should not reinit text until we are sure we are switching.
Otherwise, the new text parser won't have seen the init segment and
won't be properly initialized.

Closes #910

Change-Id: Ieb5549afcad7aa58aa1a6e8d383f3cd783280d5c
2017-06-28 13:07:07 -07:00
Jacob Trimble adb8da4764 Disallow unknown properties (1/5).
This is part of adding a new conformance rule to add additional type
safety.  This will disallow using properties of unknown types or using
unknown properties.

The first parts will be fixing errors caused by the new rule.  These
are backwards compatible, so can be applied before the rule is enabled.
Once all the errors and bugs are fixed, the rule will be enabled.

Change-Id: Iefde089b2f62ddfdf43944cda5badab438577561
2017-06-27 19:43:00 +00:00
Sandra Lokshina c6c6d05810 Move text-related files into their own directory.
This change creates a lib/text directory and moves all files
with text-related logic to it. It also lays the ground for
separating text parsing and display logic. (That change will
introduce even more files with text-related logic which will
crowd lib/media directory).

Issue #796.

Change-Id: I65ac134020a0126ff02a8f2067beb73870232e65
2017-06-06 18:21:09 +00:00