Commit Graph

137 Commits

Author SHA1 Message Date
Joey Parrish 1eadfd1e20 test: Improve TextDisplayer test reliability and timing (#4136)
This seems to reduce flakiness in the TextDisplayer tests.  The
theory is that Safari throttles timers when the system is very busy,
which it often is during full test runs across multiple browsers.  By
not relying on timers and triggering an explicit update in the
TextDisplayer, the tests seem to become more reliable.
2022-04-19 10:47:39 -07:00
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
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 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 4bdd3bb65a fix(text): Force caption update when removing cues
Previously, in the updateCaptions_ method in the UI text displayer,
when trying to determine if a cue should be removed from the container,
we checked to see if it was out of the time range.
This worked in most cases, but it did have the side-effect that the
displayer would not remove the old cues if they were removed manually
via the remove() method. This was most visible if the user changed the
text language; the currently-displayed cue of the old language would
linger until it reached the point it would stop displaying normally.
This changes the UI text displayer to force an update when remove() is
called, if necessary.

Change-Id: I84a4847b67c5fb7597342a943abe13a3cc9e826e
2021-12-06 18:33:54 +00:00
Jacob Trimble cdeffbb9e6 fix(ui): Fix styling of UI text cues
First, the positioning of cues was incorrect.  We need to explicitly
set all the position attributes when we position elements with the
"absolute" position.

Second, if we position a text <span> manually, the background will fill
the whole region.  So to keep the background wrapping the text, we need
to add another <span> for the text.

Third, the background and font color should not be set on every <span>
element since it won't allow parent cues to set the inherited value.
So this moves the defaults to the top-level text element and allows
parent cue elements to override this.  It also would make app CSS
easier to override.  Because background color isn't inherited through
CSS, the default is set in JavaScript instead.

Fixes #3521
Fixes #3600
Closes #3713

Change-Id: I45fc88dcac4a0a062e1474087f24c80d98eef619
2021-11-03 17:31:25 +00:00
Theodore Abshire 7da2cd59ff fix(text): Fix UI test failures
A new UI test added in a recent CL involved manually setting the
currentTime value of a videoElement in tests.
For some reason that wasn't working on Safari, so this changes that
UI test to use a fake video instead of a real one.

Closes #3689

Change-Id: I412f677f6cda49bbfc850a9102edfe3b75bca302
2021-10-08 16:19:06 -07:00
Theodore Abshire b02ff27017 fix: Fixes updating of nested cues
Previously, we added support for respecting the time constraints
of nested cues. However, the UI text displayer did not take the
time constraints of nested cues into account when determining when
and how to update the cues.
This changes the UI text displayer to also do that.

Issue #3524
Issue #3643

Change-Id: I6b643f2aa21f367a8e40a8aca2ebb62492c071c2
2021-10-06 14:50:11 -07: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 a7f4db7f18 fix: Account for server-side ad cue points in external text tracks. (#3617)
When an external subtitle track is added and you are using DAI, the external track does not take into account the ads that the video has, so this PR makes this internally take into account when generating the external track.
2021-09-13 15:39:06 -07:00
bcupac 65e9d8ff85 fix: Display captions with forward slashes (#3556)
Closes #3555 .
2021-08-15 22:30:22 -07:00
Joey Parrish 2250324a4a fix: Fix enforcement of cue alignment styles
This uses flexbox once again to get proper positioning of cues.  To
compensate for the issues that originally made us remove flexbox, this
adds a wrapper span inside the flexbox element.

Summary of screenshot changes:
 - slight change to background sizing
   - ui-basic-cue
   - ui-cue-with-controls
   - ui-duplicate-cues
   - ui-end-time-edge-case
   - ui-flat-cue-bg
   - ui-two-basic-cues
 - background fills block with literal newline in text
   - ui-cue-with-newline
 - region anchored without padding
   - ui-region-position
 - new screenshots
   - *-nested-cues-with-linebreak
   - *-region-with-display-alignment  (regression test for this issue)

Closes #3379

Change-Id: I8c678721d96662e0f8940cda12df4f5b5e5baf1e
2021-07-09 17:19:42 +00:00
Álvaro Velad Galván 9ffc111c49 feat: Add align and vertical settings to WebVttGenerator (#3413) 2021-05-17 13:30:08 -07:00
Michelle Zhuo 95ba28b5af refactor: Remove IE 11 support
Issue #2339

Change-Id: I80ffa7b04f7afd943aa0f881d2a494dd35def732
2021-04-29 17:47:07 +00:00
Joey Parrish fff9a96958 fix(UI): Fix writing-mode on Tizen 3
Old versions of Chromium, which may be found in certain versions of
Tizen and WebOS, may require the prefixed version of "writingMode":
"webkitWritingMode".

However, testing shows that Tizen 3, at least, has a "writingMode"
property, but the setter for it does nothing.

Therefore, instead of just detecting the existence of the property, we
need to additionally check if setting it had any effect.  If it is
either missing or non-functional, then we fall back to the prefixed
version of the property.  This fixes the functionality on Tizen 3.

We also need to change the conditions we check for in the tests, since
property existence is not enough to set the correct test expectation.

See also PR #3330

Change-Id: Ic906f3c5af956b5edd1788e95e1978eb4b3098ac
2021-04-22 17:09:25 +00:00
Álvaro Velad Galván 7af44ef565 fix(UI): Fix writing-mode support in old versions of Tizen and WebOS (#3330) 2021-04-19 10:44:17 -07:00
Álvaro Velad Galván 463b1b6886 Remove support for IE 11 (#3309)
Issue #2339
2021-04-16 13:59:35 -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
Álvaro Velad Galván 658790a012 feat(text): Creates style tags for underline/italics/bold in WebVttGenerator (#3266) 2021-03-30 11:02:02 -07:00
Jacob Trimble 9c2315e69d fix(text): Don't use flex layout in subtitles.
Using flex layout causes problems with the positioning of elements and
causes the borders to be wrapped over the whole parent.  This changes
to use block/inline layouts instead.

This also removes any padding around the cue lines, hugging the
background around the text.  This is a bit more consistent with other
renderers by having a gap between lines.  This also changes a bit of
the nested cues padding.

The deeply nested cue test is different because the `background-color`
CSS attribute isn't inherited, so the default in our CSS sets the
background to black.

Fixes #3013

Change-Id: I3e4b63b1b4de1f12e69fce2460d142e0a69bfcd9
2021-03-17 18:57:30 +00:00
Percy Tse d882d282f9 Support WebVTT default text color and default text background color (#3182)
Closes #3182
2021-03-11 08:52:40 -08: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
Álvaro Velad Galván 6db55e0141 feat: Add support for WebVTT style blocks (#3071) 2021-02-18 16:01:36 -08:00
david-hm-morgan 57ba772fc0 fix: Support localized whitespace preservation in TTML (#3043)
Closes #3011
2021-02-18 10:12:13 -08:00
Álvaro Velad Galván 82b2878c94 feat: Add SubViewer (SBV) support (#3063) 2021-02-12 11:12:18 -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
Joey Parrish 7544670ee5 chore: Upgrade eslint
The new eslint found many style errors which have now been corrected.

It also complains a lot about atomic update issues that do not seem to
exist, so that rule has been disabled.

This upgrade will allow us to adopt eslint's "id-denylist" instead of
the older "id-blacklist" rule, the name of which violates new Google
guidelines about respectful language.

Bug: 178203011

Change-Id: Ia65581b96e4dd1331f720fa396183dca020b9caf
2021-02-01 23:36:12 +00:00
Álvaro Velad Galván 0845843b65 feat: Add SubStation Alpha (SSA) support (#3060)
Format info: https://en.wikipedia.org/wiki/SubStation_Alpha
2021-02-01 12:50:54 -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
Álvaro Velad Galván 8b7e70a30d feat(text): Add LyRiCs (LRC) support (#3036)
Format info: https://en.wikipedia.org/wiki/LRC_(file_format)
2020-12-28 14:19:36 -08: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
Álvaro Velad Galván 96f36278c4 Be more permissive in vtt files (#2941)
Resolves #2720
2020-10-26 10:05:46 -07:00
michellezhuo 648e12e9c1 build: add goog.require for compiler upgrade (Part 4)
Change-Id: I6b4a7209c7a3a9f6069351377dac32f22222c0fb
2020-10-12 16:54:08 +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
Álvaro Velad Galván 840aae408d Add SubRip (SRT) subtitle support (#2872)
SRT can be trivially converted into WebVTT, so the SRT parser delegates to the VTT parser.
2020-10-01 09:52:43 -07:00
Muhammad Haris 54ff2d8f28 feat(cea): CEA-708 Decoder (#2807)
This pertains to #2648 (although this is a new feature, not a replacement) and #1404. A CEA-708 decoder that follows the CEA-708-E standard, decodes closed caption data from User Data Registered by Rec. ITU-T T.35 SEI messages, and returns them as cues in Shaka's internal cue format. Furthermore, this pull request fixes and cements some of the logic surrounding CEA-608 and CEA-708 tag parsing on the Dash Manifest Parser.

Format:
Similar to the CEA-608 decoder, cues are emitted in Shaka's internal format (lib/text/cue.js). This decoder makes use of nested cues. The top level cue is always a blank cue with no text, and each nested cue inside it contains text, as well as a specific style, or linebreak cues to facilitate line breaks. This also allows for inline style (color, italics, underline) changes.

Details:
- ASCII (G0), Latin-1 (G1), and CEA-708 specific charsets (G2 and G3) all supported.
- Underlines, colors, and Italics supported, set as a property on each nested cue.
- Positioning of text is supported. (Exception: In CEA-708 the default positioning is left, in this decoder it is centered.)
- Positioning of windows not supported, but relevant fields that could be used to support this are extracted and left as a TODO.
2020-09-10 13:06:07 -07:00
Joey Parrish 45e39f87d5 fix(text): Fix missing cues in UITextDisplayer
The duplicate cues check did not account for nested cues, which could
cause some inputs to be erroneously filtered out.  This uses a more
detailed check that includes all properties.

Change-Id: I517be17a8f7377f8840f102d26d515baa327530a
2020-08-25 16:29:26 -07:00
Joey Parrish 4bf22e2359 fix(VTT): Fix timing of VTT in HLS without map header
When there is no X-TIMESTAMP-MAP header, the HLS spec states that the
client should map 0 to 0, effectively.  That means we were wrong to
offset the cues by the segment time.

Since DASH IOP states that segmented text should be packaged in MP4,
this should not affect compliant DASH content.

Closes #2714

Change-Id: Iddb00f2fd1afeb4f0f2c99f92f65e5db0e3a84f1
2020-08-12 14:10:11 -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