Commit Graph

60 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
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 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
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
Álvaro Velad Galván 82b2878c94 feat: Add SubViewer (SBV) support (#3063) 2021-02-12 11:12:18 -08:00
michellezhuo c17f427194 build: Add require and requireType
Add missing require and requireType for compiler upgrade.

Change-Id: Ie21418d93eb70c2213815638d6fd2d784cf6ef2e
2020-09-24 22:20:14 +00: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
Muhammad Haris 1c00b4c1fb feat(text): CEA-608 Decoder (#2731)
This replaces mux.js for CEA608 decoding.  Applications will no longer need to include mux.js for CEA support, and mux.js will only be necessary for TS transmuxing.

Closes #2648
2020-08-07 09:07:26 -07:00
Sergei Gridasov d477326e3d feat: add dependencies module (#2683)
Closes #2562
2020-08-05 11:11:32 -07:00
Joey Parrish 06fd3ce322 fix: Fix strict compiler errors
In our Google-internal build systems, with the strictest compiler
settings, we were seeing errors related to these two issues:

1. A missing require
2. Incomplete type info

This fixes the errors in that environment.

Change-Id: I9c4c482ed6ef8f669e113263a70958b53138c4ee
2020-06-11 10:17:48 -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 a65ef9983b Remove partial exports, broken in new compiler
The old compiler would let us export a static method on a class
without exporting the whole class and its constructor.  The new
compiler silently ignores `@export` for any methods of a non-exported
class.

This means that for the latest Closure Compiler, we must export any
class with exported static methods.  In some cases, these are
non-utility classes with constructors we'd rather not export, but the
constructor is implicitly exported by exporting the class itself.

This was initially caught by the integration tests.  The error wasn't
especially helpful, so I added a try/catch to loadShaka that makes the
error more apparent:
  TypeError: Cannot read property 'registerParserByMime' of undefined

To make sure we do not make this mistake again, I've added a check to
the extern generator, which was already able to detect these types of
classes.  I don't know a compiler-based way to do it, since the
compiler silently ignores the export annotations in these cases.

Issue #2528

Change-Id: I797c75a8098b0bb3cf837588569f878253dec2cf
2020-04-30 17:30:36 +00: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
Joey Parrish 639137b4e6 Drop dead code and extra export in TextEngine
The appendCues method in TextEngine was completely unused.  Another
method was exported that should not have been.

Change-Id: Icee35d8ccbc5a903cb13409211a8c5770f1c6a87
2020-01-23 12:32:21 -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
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 c014d445a4 Fix Period transitions with embedded captions.
We would incorrectly initialize the embedded captions multiple times
during a Period transition, which caused duplicate cues to be given to
the displayer.  We also wouldn't handle the case when switching between
embedded captions and external text during a Period transition.  This
fixes both cases and adds tests for them.

This also avoids passing an empty cue list to the displayer.

Fixes #2076

Change-Id: I89add3eb86ad8d93644bba14eabd11f98d57bc5e
2019-09-23 22:54:00 +00: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 18b59c5294 Disallow using new Uint8Array with BufferSource.
Using "new Uint8Array" with a TypedArray creates a copy of the buffer;
this is unnecessarily expensive for large buffers.  This adds a rule
to disallow using it in favor of a new utility that correctly creates
a new "view" on the same buffer.

Note it is fine to pass an ArrayBuffer to "new Uint8Array" and it won't
copy; but there there are many cases where the type is BufferSource,
so it could be a TypedArray.  Unfortunately, there are many other cases
where we explicitly pass an ArrayBuffer; but the compiler rules don't
allow us to whitelist this case (since ArrayBuffer is part of
BufferSource).

Change-Id: I58696a85a9cbcc188c0b16919c9eeb63e56edca1
2019-08-21 20:40:59 +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 5ddb92a4ee Convert text files to ES6.
Issue #1157

Change-Id: I33df747b0fad0e6d8f5e3d7dc8f5c93bd07800b1
2019-05-21 22:31:19 +00:00
Theodore Abshire dc04edfa51 Use correct TextDisplayer in demo.
This sets a TextDisplayer to the native text displayer if native
controls were desired, or a custom UI text displayer otherwise.
This required adding methods to the player to switch out the current
text displayer if a new factory is provided, and a method to streaming
engine to reload the current text stream.

Change-Id: I85595e9ac9db0b60464ee7f20fa35855efb26424
2019-05-14 12:53:16 -07:00
Jacob Trimble d5780d401b Fix line length issues for indent fix.
Change-Id: I87d75fd88000f8f9bff7b9f1bf5667ba28f6dd60
2019-05-13 22:31:20 +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 73c2ac72d3 Fix CEA timestamps with presentationTimeOffset
When CEA captions are extracted from video segments, the
presentationTimeOffset of the video segment should be applied to the
extracted captions, as well.

Fixes b/70902665

Change-Id: I446333a14b8b6374786ab594a579b6e18bc73ac1
2019-02-13 10:45:34 -08:00
Aaron Vaage 0f0a3515b6 Refactor media source engine to take text displayer in constructor
Before, media source engine could be created with no text displayer.
However, player would always create media source engine with a
text displayer.

Just like with closed captions, this appeared to be a good time
to change it to be passed in the constructor and have media source
engine own it.

This now means that media source engine is responsible for destroying
it - lessening player's responsibilities.

Change-Id: I71cd1c28a3c22d3c765a3892fe74ae3f9abd1914
2019-01-24 01:12:37 +00:00
Michelle Zhuo 4cd5666d84 Clear closed captions map when text engine is destroyed
Change-Id: I610334e6ad187a09e8831cde285d9a0e38876aad
2019-01-02 16:28:53 -08:00
Aaron Vaage eb6eea1f46 Address channel ids as |channelId|
In the methods use for testing, when getting the number of
close caption cues, we were only addressing the channel by "id".
This updates the name to be "channelId" so that it is clear
what the id will map to.

Change-Id: I773d5a63c376b832d492b41cf2505d8a27ea0f32
2018-12-05 16:42:09 +00:00
Aaron Vaage c9411d1c22 Refine comments on closed caption test methods
This change refines and emphasizes the message of the test only
methods for closed captions in text engine.

Change-Id: I0f13f0fa48f3b464c8dc4166ddbd12f09f53874c
2018-12-05 08:41:03 -08:00
Aaron Vaage e3b1cb41aa Remove Redundant Null Check in TextEngine
The close caption map cannot be null in text engine, but we were
still checking if it was falsy. Since it can't be null, we can remove
the falsy check.

With the falsy check removed, the expression was able to be reduce
even further.

Change-Id: I839bc2337cfa1415cc6b00b75602e608f75b0e13
2018-12-04 16:12:34 -08:00
Michelle Zhuo a51bc995f7 Add integration tests for closed captions
Issue #1404

Change-Id: Id8c16c073f3f85fd093d33e3f40e809fa574f5ee
2018-12-05 00:07:59 +00:00
Michelle Zhuo 1afceadc9c Refactor Closed Captions Support for HLS
Refactor the closed captions support for HLS, using the same approach as
the closed captions support for Dash.
If closed captions are signaled in the manifest, player will create a
text stream for to represent the closed captions, and text engine will
store and append them. We don't need to set 'useEmbeddedText' value for
closed captions any longer.

Issue #1404

Change-Id: I9a5bf4df7e29d6e6982f29fd5e2df07bc78071d7
2018-11-27 20:59:52 +00:00
Michelle Zhuo dbdd39886b Small refactor for CEA closed captions for Dash
Removing a few hacks from player and streaming engine, so that now
closed captions streams are treated almost the same way as usual text streams.
Fixed the issue where toggling the closed captions doesn't work.
Fixed the delay of showing closed captions when we seek to a buffered
stream.

Issue #1404

Change-Id: I28a739f3033f30b53b3adf8fa1a181e3d4592f6f
2018-11-09 00:36:56 +00:00
Michelle Zhuo b9a806d071 Add test cases for CEA closed captions
Issue #1404

Change-Id: I35e679ef985ac5cef1f8d8673192845cae29b114
2018-11-08 15:13:51 -08:00
Michelle Zhuo 19a38ed6b5 CEA closed captions for Dash
Adding support for CEA closed captions embedded in video streams for
Dash.
1. Dash parser reads and parses closed captions' channel and language
information.
2. Player creates text streams for the closed captions.
3. Media Source Engine calls mux.js Caption Parser API to get the closed
captions embedded in the video streams.
4. Text Engine stores the closed captions, and text displayer shows the
captions.

TODO:
1. Add test cases, will send out another CL.
2. Change closed captions support for hls to the similar way we handle
dash closed captions, will send out another CL.
3. Handle dash content that's missing language indication from the manifest.

Issue: #1404
Change-Id: Ibae8f69623c13561415ec860107d7f5bc86e19e9
2018-11-06 09:53:18 -08:00
Joey Parrish 9cce246325 Fix TextEngine buffered range calculations
This reverts commit c38d4dd8d3, which
actually broke text range calculations in v2.3.10, and v2.4.2-v2.4.4.
The original commit was meant to account for the period start, but
resulted in a double-accounting of presentationTimeOffset.

The start and ends times passed into TextEngine's appendBuffer were
period-relative, so timestampOffset had already been applied.  To
avoid further confusion and to fix the original issue the reverted
commit tried to address, these have been changed to
presentation-relative timestamps.  Now the period start and all
offsets have been accounted for before the metadata reaches
MediaSourceEngine and TextEngine.

The tests added in the bad commit have been modified to test for the
opposite: that we do not erroneously account for timestamp offset when
calculating the buffered ranges for text.

Closes #1562

Change-Id: I9fa7a3f59906c4f3e623f411e48551f86f5c2ff7
2018-08-28 17:21:39 +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
Jacob Trimble c38d4dd8d3 Fix TextEngine buffered range calculations.
For multi-Period content, we need to account for the timestamp offset
in the buffered range calculation since the start/end times are
given as Period-relative.

Change-Id: I6d32de2abc316918333b1c58ba73c71d028284c4
2018-06-18 14:54:15 -07:00
Aaron Vaage bf0d107630 Add Missing "."
Add missing "." after "Array", "Object", and "Promise".

Change-Id: I86f6bd6ea38ce6531b71d22923622ccda07fc6aa
2018-04-11 21:36:44 +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 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
Michelle Zhuo 175e0b9594 Support CEA 708 Closed Captions
Issue #276.

Change-Id: If42ab04a451dc8c4c7038213b7f7c925648c3444
2018-02-03 00:03:44 +00:00