Commit Graph

62 Commits

Author SHA1 Message Date
david-hm-morgan df74eab0ae feat(ttml): Add support for SMPTE namespace 2013 (#3062)
We have TTML SMPTE XML Namespaces support for 2010.
Add SMPTE namespace support for 2013.

Closes #3061 .
2020-12-26 12:35:27 -08:00
aluklon 2bebfd3de6 fix(ttml): Calculate viewport anchors for cue region (#3065)
Width should be used for calculation x, and height for calculation y.
2020-12-24 09:04:54 -08:00
michellezhuo 65a6f265c7 feat(text): rename cue "spacer" to "lineBreak"
Change-Id: Ifca815b2f4d0c5f6e34edaa7b9fcb809d963f701
2020-11-16 07:53:16 +00:00
Jacob Trimble 20923cca5d fix(ttml): Fix another hard-coded namespace.
This also changes the tests to fail if we use any hard-coded namespace
prefixes.

Fixes #2756

Change-Id: I06cb7c2043cd7e1278f89a355e40d9d5d375d87d
2020-11-10 00:24:35 +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 df22ddacda cleanup(text): Remove hard-coded tts:extent namespace in TTML parser
Closes #2860
2020-09-23 02:04:19 -07:00
Joey Parrish 85476bc227 fix(ttml): Fix TTML style inheritance
Styles in TTML can refer to other styles for inheritance.  This fixes
the implementation of inheritance in the TTML parser so that it
recurses up the chain of styles that refer to other styles.  This is
done both for elements and regions.

Fixes: 159050711

Change-Id: I59a8f9df73d98710832b329f59ce64ba28c9f573
2020-08-11 14:00:41 -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
Alex Jones 64557ff82c Add support for nested TTML captions with an offset (#2602)
Closes #2601
2020-06-03 11:49:15 -07:00
Joey Parrish f15f371d20 Fix issues with nullability of strings
Various issues with the nullability of string types led to various
fixes, including:
  - adding an assertion or runtime check that something is not null
  - moving an existing null check to before a calculation
  - converting a test expectation into an assertion that the compiler
    understands (which will still fail the test if the assertion
    fails)

These issues were caught by a compiler upgrade.

Issue #2528

Change-Id: I11da091c9e7974c8bea84b3b584cbd29d1e320e2
2020-04-29 22:40:49 +00:00
Joey Parrish 8867db6773 Fix implicit string-to-number conversions
This was caught by a compiler upgrade.

Issue #2528

Change-Id: Ica262703aa30dce2e59c139c88f3c1e74d5d9e2f
2020-04-27 17:33:06 -07:00
michellezhuo 1f30becf13 Display nested cues in SimpleTextDisplayer
Closes #2263

Change-Id: I18af70e4ff69a1d27ef462678c0c49bacb74553c
2020-04-16 18:59:44 +00:00
kumarashu123 6a04bde61f Fix TTML position parsing (#2493)
The TTML parser would accept 100%, but not 100.0%.

This makes the parser more flexible, so even 100.00000% is valid.

Fixes #2477
2020-04-13 09:43:12 -07:00
Joey Parrish 0416df3d76 Minor style cleanup in TTML parser
I find this much more readable.

Change-Id: I80ab374e5cef8cb50a4fc15c6fdae006fd78823c
2020-04-01 18:29:12 +00:00
Joey Parrish f151f55da9 Fix nested TTML cues with non-ASCII characters
A regex in the TTML parser was looking for "word" characters (\w),
which is short-hand for non-whitespace ASCII characters, and excludes
Unicode characters and symbols from non-English languages.

There is a better option in Regex in some browsers, which is /\p{L}/u.
This is not supported universally yet, and defining an equivalent
regex constant using character codes is over 4kB of extra code.

It seems that the original author of that code meant "word" (\w) in
the sense of "non-whitespace" (\S), so we can just use \S instead.

This change also adds a regression test that doesn't depend on the
specifics of the regular expression used.

Closes #2478

Change-Id: I794258a797ba5d26a7bd8fc0a5244adc70c8a1ef
2020-04-01 16:08:48 +00: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
Álvaro Velad Galván 935040a3b5 Add ebutts:linePadding to ttml parser (#2443)
https://tech.ebu.ch/docs/tech/tech3380v1_0_1.pdf Section 2.1

Resolves #2407
2020-03-13 11:22:19 -07:00
Jacob Trimble 3fa7472086 Add non-nullable modifier to return types.
This is a copy of the internal CL: cr/299901617.

Change-Id: I49abbde9563f08819ec99dbc9deb99b66dd8053b
2020-03-11 15:46:06 -07:00
Tanya Gelahova d6de4e710d Add support of fontSize in percentages and cell resolution unit for TTML captions (#2442)
Closes #2403
2020-03-06 08:53:24 -08:00
Álvaro Velad Galván c632324880 Add support to tts:border, tts:letterSpacing and tts:opacity in TTML (#2408) 2020-02-26 11:08:21 -08: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
Theodore Abshire 2b1ffa3648 Add support for ttml regions.
Closes #2191

Change-Id: I2a4d5cc9bc354b8ea429ab93476a9ad53b6f8e50
2019-11-14 23:15:09 +00:00
Theodore Abshire db9a0eebec Throw if ttml parsing outputs <parsererror>.
Previously, if no XML was produced, or if it failed to have a <tt> element,
we assumed that parsing had failed. This caught some failures, but not
every possible failure; there are some partial failures that still return
valid XML. These sorts of errors are signaled by the output containing a
<parsererror> tag; this CL makes us also return an error in this case.
It also corrects the documentation for XML parsing errors, which was
incorrect; it seems that we had been confusing INVALID_XML and
DASH_INVALID_XML for documentation.

Issue #2157

Change-Id: I79716c9d2ff90ed9672eef8e54dd4019d8ca109b
2019-10-17 21:53:58 +00:00
Theodore Abshire 9f7652e7ad Modify ttml parser to handle decimal percents.
Something I noticed while working on issue #2157; their text tracks
contained percent values with decimals in them (for example "4.17%"),
which was something the percentage-parsing regex we were using did
not handle.

Change-Id: I90f4a223f0a335057a92ae606e7298eefaa0b4aa
2019-10-11 19:59:01 +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
fadomire 2c0d824a1c Fix support for empty TTML data (#1960)
When using DOMParser parseFromString with an empty string, it returns an errored XML document.  The next part of the code is then executed and throws an unnecessary error.

This adds a special case for an empty string.
2019-09-11 14:35:58 -07:00
Jacob Trimble 0f92d8221f Fix use of private tags.
Issue #1553

Change-Id: I8c0412eda3d68f2ad475bf8282afcaeffd80852a
2019-08-13 19:08:48 +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
Vincent Valot a88e3be128 fix ttml background image support (#2034) 2019-07-16 11:02:37 -07:00
Vincent Valot c670b55d72 enhance ttml rendering (#1962) 2019-07-12 16:25:59 -07:00
Adrián Gómez Llorente d93fb394e3 Trim base64 subtitles (#2030)
This trims the textContent containing the base64 code of the subtitles, to avoid trying to decode newlines and other whitespace as part of the base64-encoded data.

Fixes #2028
2019-07-12 14:00:10 -07:00
Jacob Trimble 5c35108cb8 Avoid integer for loops.
Issue #1518

Change-Id: I3ba3cb6a439264e823022b2a64e7cdbd265494c7
2019-07-09 17:11:49 +00:00
Jacob Trimble 001c3c7b8c Add check for common misspellings.
Change-Id: Iaf546678ed787724513ed21b19a78cc895f069e8
2019-07-08 12:08:45 -07: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 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
Álvaro Velad Galván 6f3241e696 Add SMPTE-TT Subtitle Images (#1859)
This change adds support for images via SMPTE-TT by adding background image support to the TTML text parser. This required changing region parsing to respect global extends.

Issue #840
2019-04-04 15:19:08 -07:00
Michelle Zhuo 1f324e27e7 Separate text direction and writingMode
CSS style 'direction' supports only horizontal directions, (left to
right, right to left), and writing-mode supports horizontal top to
bottom, vertical left to right, vertical left to right.
Separating the field 'writingDirection' to two fields 'direction'
and 'writingMode', so that they're the same as the css style names.

Issue #1708

Change-Id: Ie730bd7d13e5483d7425261854c268cd7f095400
2019-01-11 00:40:27 +00:00
Andy Hochhaus 3bba6f37d6 Add missing require for shaka.util.XmlUtils (#1660)
Fixes #1658
2018-11-11 20:33:54 -08:00
Jacob Trimble d70af736ae Add namespace-aware parsing to TTML parser.
Closes #1585

Change-Id: Ic508e8e882c5a37c0545e19b09c58e642a00ec57
2018-09-18 16:44:35 +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
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 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