Commit Graph

59 Commits

Author SHA1 Message Date
Joey Parrish fbbd63d96b test: Late load tests, fix Chromecast test flake (#4115)
This change fixes tests on Chromecast by loading tests later in the process.  Test scripts are now dynamically inserted by boot.js, rather than loaded by Karma.  The bootstrapping code then awaits the completion of that before starting the Karma frameworks (Jasmine) to run the tests.

This also removes the use of goog.provide/goog.require in tests and test utils.  We don't need to load test utils or library sources dynamically in each test, and this gives us more explicit control over script loading and ordering.

Closes #4094
2022-04-11 15:47:48 -07:00
Philippe f382cc702b feat: add option for segment-relative VTT timings (#4083)
This PR fixes #3242 where for some live streams using segmented VTT, text timings are relative to segment start instead of being absolute.

The PR introduces a new setting: `manifest.segmentRelativeVttTiming: boolean` allowing such alternative timing offset calculation.

The setting is off by default, preserving the current player behaviour.

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2022-04-01 09:39:11 -07:00
Joey Parrish 1507b1e844 chore: Update URLs after moving projects (#4008) 2022-03-03 14:34:40 -08:00
Álvaro Velad Galván 0635e2c055 fix: Fix compiler error introduced in #3864 (#3906) 2022-01-26 09:53:08 -08:00
Theodore Abshire e9df8fb10c fix(text): Inherit alignment from regions.
The recent changes to TTML parsing, to not inherit regions,
inadvertently ended up breaking text alignment in situations
where a region with alignment was on the p or div above a span.
Previously, we only inherited the text and display alignment
from a region on leaf nodes... which was a problem, since we
also didn't apply any styles to text nodes.

Change-Id: I62ac155bc4310a5f7da52c10ca2dd434f8015c97
2022-01-25 21:39:21 +00: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
Theodore Abshire bf67d87387 fix(text): Fix caption overlap.
This changes the TTML parser to not allow cue regions to be inherited
to the children of the element the region was originally assigned on,
except for the purposes of styles (colors, etc).
To allow regions on elements "above" the cues in TTML, such as the
<body> or <div> elements, this also changes the TTML parser to render
the full structure of the TTML file as a tree of cues. The end result
will be a single cue representing the <body>, with children
representing the <div> elements inside it, and those <divs> will have
children that represent the actual cues. Now that our text displayer
can intelligently update child cues as they enter or leave the display
window, this approach should be possible.

Closes #3850
Closes #3741

Change-Id: Ia8d750daa06920610c04e9b26e29d2d304eaf8a9
2022-01-20 22:41:37 +00:00
Álvaro Velad Galván 3ff48cba9b fix(text): Made nested cues inherit region (#3837)
Closes #3743
2022-01-12 12:45:24 -08:00
Álvaro Velad Galván c5a81f53fe fix(text): Allow comments in the TTML parser (#3827)
Closes #3766
2022-01-04 11:34:44 -08:00
Theodore Abshire 157bd77be2 fix(ttml): Fix ttml erroneously dismissing cues.
When trying to detect if it is appropriate to ignore a non-break
element, the ttml parser would base the decision on the presence
of timing info in the cue itself, and on the presence of
textContent within the node. If neither is present, the element
might be ignored.
This works in most cases of nested cues, as the presence of text
within a child node will show up in the textContent of the parent
node. However, not all valid ttml cues have textContent; image
cues, for example, have their contents defined as a DOM attribute.

This changes the ttml parser to not ignore any cue that has child
cues. It also changes the ttml parser to cause cues with no defined
timing to base their timing on their child cues, if present.
This also changes our UI text displayer to respect the timing info
of child cues.

Closes #3643

Change-Id: I9a017f53398bbed8dbeeeebca2cff76dd3666c64
2021-09-29 21:53:41 +00:00
Theodore Abshire 911ce6d250 feat(text): Partially support tts:textOutline
Unfortunately, modern browsers do not support any CSS property that
directly maps to tts:textOutline. However, the non-standard (but still
commonly implemented) -webkit-text-stroke-width and
-webkit-text-stroke-color properties, when used together, can
replicate the functionality of tts:textOutline, with the exception of
the optional blur radius.

Closes #3612

Change-Id: I863d09fc447765646bd405c59b0b20960362a594
2021-09-14 12:05:39 -07:00
Álvaro Velad Galván 9f54c41860 fix(TTML): fix image subtitles parsing in TTML (#3294)
TTML allows "smpte:backgroundImage" on both the div level and p level. Adding parsing the background images into cues on the div level.

Closes: #3097
Closes #3248
2021-04-01 14:40:01 -07:00
Joey Parrish 43538fba43 fix: Fix TTML background image attribute case
Ever since background image support was introduced in PR #1859, and
since the feature was first released in v2.5.0, we were checking for
"imagetype" (lowercase) instead of the spec-compliant "imageType"
(camelCase).

This fixes the parser to accept both, and updates our unit tests with
spec-compliant content.

Fixes #3196

Change-Id: Ife13ca92220e4bfde150f9f0b1d9a3de3a954821
2021-03-08 15:14:40 -08:00
david-hm-morgan 57ba772fc0 fix: Support localized whitespace preservation in TTML (#3043)
Closes #3011
2021-02-18 10:12:13 -08:00
Michelle Zhuo 2371bd8591 fix: Fix build failures
1. Added hdr as a property in stream when constructing.
Fixes build failure from commit
71372869de .
PR #3116
Issue #2813

2. Fixed the test error from commit
d3640d1da1 .
PR #3044
Issue #3029

3. Fixed the new line with no other arguments from commit
0845843b65 .
PR #3060

Change-Id: I5833e49c1a95172742c4ec820960c9c5a7bf0cca
2021-02-02 14:02:12 -08:00
david-hm-morgan d3640d1da1 fix(TTML): Fix TTML extent and origin percentage calculations (#3044)
Closes #3044 .
2021-01-29 10:11:07 -08:00
Michelle Zhuo 7a53f691df fix(test): Apply smpte:backgroundImage to div element
smpte:backgroundImage attribute should apply to a div element, not a
p element.

Closes #3068

Change-Id: I6e06aab0c5be091b93d5cc1cf28b9a65cdfbc1eb
2021-01-05 19:03:28 +00:00
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
michellezhuo 65a6f265c7 feat(text): rename cue "spacer" to "lineBreak"
Change-Id: Ifca815b2f4d0c5f6e34edaa7b9fcb809d963f701
2020-11-16 07:53:16 +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
michellezhuo 341b92ad04 build: add goog.require for compiler upgrade (Part1)
This change includes files under test/cea and test/text folders.

Change-Id: I1db1ccb6daeea77058cb56f1f5fc80992596600c
2020-10-07 19:20:29 +00: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 7e6a0f38ff fix: Correct license headers in misc. files
This corrects/normalizes license headers in misc. files, such as
config files, docs, build tools, tests, and externs.  This does not
affect the compiled output, and is only done for consistency.

Issue #2638

Change-Id: I9d8da2de55243b08d7df2b743aac73c6f15e858a
2020-06-09 16:13:56 -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
michellezhuo 1f30becf13 Display nested cues in SimpleTextDisplayer
Closes #2263

Change-Id: I18af70e4ff69a1d27ef462678c0c49bacb74553c
2020-04-16 18:59:44 +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
Á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
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
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 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 bf5547b78c Refactor ArrayBuffer usage in tests.
Change-Id: I27e898a7d3c2d706e265abfc4b9bde88b67f3256
2019-08-21 20:44:36 +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
Jacob Trimble 010a60b8f1 Use objectContaining in text tests.
Instead of checking each property separately, just use
jasmine.objectContaining.  This also adds a utility for matching a
number that is close to an expected value.  This is required when
matching objects with toEqual().

Change-Id: I4de49cfaf254e0752beffc97c578a77f9ec8ee95
2019-06-26 18:54:13 +00:00
Theodore Abshire b805d15444 Convert externs to ES6.
Issue #1157

Change-Id: Ib8ddecc7106fea8c24c10cfac406c4709a3f275b
2019-06-10 17:52:08 +00:00
Jacob Trimble a69047ba0d Convert text tests to ES6.
Issue #1157

Change-Id: I839d4ab38324a2247bb3c788837a16652d401595
2019-05-21 22:56:34 +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
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
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 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
Jacob Trimble 064089152b Remove spacing around object definitions.
This is an automated fix to be inline with Google style guides, this
was created with eslint's --fix option.

Change-Id: I860eecbc8152603e730aa17a1393f16d26b3b6fc
2018-02-21 13:35:00 -08: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