Commit Graph

212 Commits

Author SHA1 Message Date
Joey Parrish ac5acc80cb feat!: Remove deprecated features, update upgrade guides (#4089)
Below are the changelog entries for each deprecated feature removed by this commit.

-----

feat(config)!: `manifest.dash.defaultPresentationDelay` has been replaced by `manifest.defaultPresentationDelay` (deprecated in v3.0.0)

feat(config)!: Configuration of factories should be plain factory functions, not constructors; these will not be invoked with `new` (deprecated in v3.1.0)

feat(player)!: `shaka.Player.prototype.addTextTrack()` has been replaced by `addTextTrackAsync()`, which returns a `Promise` (deprecated in v3.1.0)

feat(ui)!: `shaka.ui.TrackLabelFormat` has been renamed to `shaka.ui.Overlay.TrackLabelFormat` (deprecated in v3.1.0)

feat(ui)!: `shaka.ui.FailReasonCode` has been renamed to `shaka.ui.Overlay.FailReasonCode` (deprecated in v3.1.0)

feat(offline)!: `shaka.offline.Storage.prototype.store()` returns `AbortableOperation` instead of `Promise` (deprecated in v3.0.0)

feat(offline)!: `shaka.offline.Storage.prototype.getStoreInProgress()` has been removed; concurrent operations are supported, so callers don't need to check this (deprecated in v3.0.0)

feat!: `shaka.util.Uint8ArrayUtils.equal` has been replaced by `shaka.util.BufferUtils.equal`, which can handle multiple types of buffers (deprecated in v3.0.0)

feat(manifest)!: `shaka.media.SegmentIndex.prototype.destroy()` has been replaced by `release()`, which is synchronous (deprecated in v3.0.0)

feat(manifest)!: `shaka.media.SegmentIterator.prototype.seek()`, which mutates the iterator, has been replaced by `shaka.media.SegmentIndex.getIteratorForTime()` (deprecated in v3.1.0)

feat(manifest)!: `shaka.media.SegmentIndex.prototype.merge()` has become private; use `mergeAndEvict()` instead (deprecated in v3.2.0)

feat(plugin)!: `AbrManager` plugins must implement the `playbackRateChanged()` method (deprecated in v3.0.0)

feat(plugin)!: `shaka.extern.Cue.prototype.spacer` has been replaced by the more clearly-named `lineBreak` (deprecated in v3.1.0)

feat(plugin)!: `IUIElement` plugins must have a `release()` method (not `destroy()`) (deprecated in v3.0.0)
2022-04-11 17:11:40 -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
Álvaro Velad Galván f2f24d528f fix(ttml): Center subtitles by default (#4023)
Closes: https://github.com/shaka-project/shaka-player/issues/4015
2022-03-10 13:11:50 -08:00
Joey Parrish 1507b1e844 chore: Update URLs after moving projects (#4008) 2022-03-03 14:34:40 -08:00
Joey Parrish d99ab7959d build: Update eslint (#3977)
Also fixes linter errors found by the new versions
2022-02-18 08:26:43 -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
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 0117441bb0 fix(text): Remove caption wrapper bgColor (#3838)
Closes #3745
2022-01-10 11:49:36 -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 b6d7138466 fix(text): Fix timestamp offset of CEA-608 cues
When we attach closed-caption cues to the text engine, we apply the
video timestamp offset to the cues, so that they can align with the
start of the stream. However, we previously forgot to apply that
offset to any nested cues.
This did not matter beforehand, since we previously ignored the start
and end times of nested cues. However, recent changes to the UI text
displayer changed that.
So this fixes nested cues to apply video timestamp offset.

Closes #3782

Change-Id: I4c9140fcfa9bf94579f8d847e546ee4e2ec5eff4
2021-12-06 19:06:01 +00: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
Vincent Valot 9e5b9ac139 fix(text): support stpp.ttml codec in Mp4TtmlParser (#3754) 2021-11-15 12:32:03 -08: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 a4e348da7b fix(text): Fixes minor bug with cue updating
There was a small bug in the cue updater that was causing our
workaround for #2076 to trigger repeatably. It turns out that
the code that detected if the cue was being successfully
removed mistakenly thought that, if a cue was removed, its
nested cues weren't removed.
This refactors the cue updating code so that it will remove
nested cues, even if they go away at the same time as the parent
cue. With this change, the actual performance of the code is no
different, but we can make the workaround for #2076 become an
assert, as we had wanted earlier.

Change-Id: Ia81068b60a42e3f25cb978cd3105d667a42a7da5
2021-10-07 19:43:34 +00: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
Chuong 3670996269 style: Fix misspelling default (#3602) 2021-08-27 09:27:03 -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
Joey Parrish 38ce45dce5 cleanup: Fix nullability declarations
Cleanup imported from an internal Google migration process, courtesy
of Laura Harker.

Change-Id: I11de518eafe6008938589e5250bdcaf8151267e9
2021-06-22 21:03:20 +00:00
Joey Parrish 4c7767f6be cleanup: Delete unnecessary nested goog.provides
Cleanup imported from an internal Google migration process, courtesy
of Laura Harker.

Change-Id: Ied2c24eeacfe4ff92f1b974c8e960949de5e4fb5
2021-06-22 21:03:20 +00:00
Chuong a0d3e528de fix: Don't force update captions by default (#3425) 2021-05-26 11:35:21 -07:00
Álvaro Velad Galván a09fa31188 fix: Force update captions when element resizes (#3426) 2021-05-26 11:31:36 -07:00
Álvaro Velad Galván b426fe87f8 fix: Force update captions with fullscreen (#3414)
There are measurements that use absolute values in pixels after a conversion. By making this change, we force to update the subtitles that are being shown to have the correct dimensions.
2021-05-17 14:24:55 -07: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
Adrián Gómez Llorente d97b09fe21 fix: Fix subtitle display in timing edge case (#3152)
We've seen some SmartTVs show one subtitle without removing the previous one.

I think this is happening because two different subtitles may meet the condition of "greater or equal than" and "lower or equal than" at the same time. After changing the greater than or equal with a greater than subtitles were fixed.

@joeyparrish will add a regression test after this fix.

Closes #3151
2021-02-10 12:02:58 -08: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
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 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
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
Michelle Zhuo 927c020ee1 fix(text): Only compare cues when necessary
When a VTT cue spans a segment boundary, the cue will be duplicated
across two segments.
To avoid displaying duplicate cues, we compare the cues to be
appended with the cues already in the list.

1. We can assume the cues to be appended at once have no duplicates.
Make a copy of the current cues list, and compare the new cues only
with the cues in the current cues list.
If we append m new cues to a list of n cues, we can reduce the times to
compare the cues from m*m*n/2 times to m*n times.

2. We compare the cues deeply by comparing their nested cues and
all the elements. We can compare their start time, end time and payload
first, and only compare their nested cues and all other elements when
their start time, end time and payload are the same.
If cue1 and cue2 both have m nested cues, we may not need
to compare the nested cues instead of comparing m times.

Fixes #3018

Change-Id: I9992f0e1834fd16e8aedaf1895b036bc7ca29190
2020-12-21 22:15:10 +00:00