Commit Graph

78 Commits

Author SHA1 Message Date
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
Á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
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
Michelle Zhuo 40e52ca71c TextDisplayer: Apply cues styles
Issue #1708

Change-Id: I87cea002d52792ca1f414716f7b42c080530294f
2019-01-25 11:40: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 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
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
Andy Hochhaus 3bba6f37d6 Add missing require for shaka.util.XmlUtils (#1660)
Fixes #1658
2018-11-11 20:33:54 -08: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
Jacob Trimble aa64769513 Remove VTTRegion support.
Browser support is currently buggy and limited, so until they fix it,
this removes VTTRegion support.

Closes #1584

Change-Id: Ia5bb34dd3ea94737adcdd1d441201bb97b303f81
2018-09-18 21:59:10 +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
Aaron Vaage f8b707aaeb Use Sets For Uniqueness
Update all our code to use |Set| to handle storing and testing
unique values.

Change-Id: Id809d4d84e4779ae19be58eca96983750c3f3a81
2018-09-14 22:03:04 +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 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
Theodore Abshire 03e1a82b18 Simplify remove function in SimpleTextDisplayer.
Change-Id: Ida4d55356bd846177ebd577de6cdd80a392dc46d
2018-08-23 21:02:38 +00:00
Aaron Vaage 9bfcd21955 Made Convert Methods Static in SimpleTextDisplayer
Since the convert methods in SimpleTextDisplayer do not affect the
state of |this|, this changes them to be static to better represent
the in/out affect of the methods.

Change-Id: I1084fd64490f4ef9aa97972913e5e14ff6245051
2018-07-27 15:18:52 +00:00
Aaron Vaage 4d568fde22 Isolate Use of Track Cues In Simple Text Displayer
Since we only need to know about which cues a text track has when we
remove cues, there is no need to keep a local copy.

Since some platforms return null if the track is disabled, we do need
to temporarily change the mode if the track is disabled so that we can
get the cues.

However, this limits the scope of these "special" conditions to a single
function.

Change-Id: I7026e9c73629ef86633d5fe732f21a48178e8767
2018-07-10 13:46:50 -07: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
Theodore Abshire 18859597e9 Prefer a new cue list in simple_text_displayer.
On some platforms, the cue list object returned by TextTrack
might not update as cues are added and removed.
To account for that, this changes simple_text_displayer to fetch
a new cue list when one is available.

Change-Id: I9eda19197b343b0f6385a8cbb64cef8f2b31b9b9
2018-07-03 10:11:54 -07:00
Jacob Trimble 759eef9685 Change goo.gl links to bit.ly.
https://goo.gl is being turned-down, so we can't use it for new URLS.
So we have consistent short links, this converts them to be
https://bit.ly.

Change-Id: I07a86cba807b67157664893341f648023918d0de
2018-06-22 20:20:00 +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
Joey Parrish 772dc231c9 Remove non-nullable on implicit non-nullable types
This is a style cleanup to pass stricter checks from future versions
of the Closure linter.

Change-Id: Icca8f974af7c9f4834acf6bba69e4cef1f89e502
2018-04-09 14:52:59 -07:00
Theodore Abshire 8ea237c214 Fixes how the MDAT is read for VTT in mp4 content.
Previously, we would read each individual VTTC and VTTE box in the
MDAT and associate them with durations in the TRUN. This worked for a
lot of content, but if sampleSize is defined in the TRUN, a duration
might refer to multiple VTTC boxes.

This changes the VTT in mp4 reader to parse the MDAT based on the TRUN,
to account for such situations.

For the moment, this only accounts for a single MDAT, and assumes that
the MDAT contains nothing but vttc or vtte boxes, listed in order.

Issue #1266

Change-Id: I56e310d085abdda16e968761ed3b4fd0cc5e24d0
2018-03-27 17:10:48 +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
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
Jacob Trimble 0a2190246c Fix catastrophic backtracking in TTML text parser.
Issue #1312

Change-Id: I0aed14068776a800eee35f03d2f878db0dd565b6
2018-02-21 18:49:07 +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
Sandra Lokshina 118756e8e8 Add parsing of VTTRegions and TTML attributes set in pixels.
Closes #1188

Change-Id: Ib9fc1a5b35065fdadafae01df4737ce1dcfa3ada
2018-02-08 18:19:31 +00:00
Michelle Zhuo 175e0b9594 Support CEA 708 Closed Captions
Issue #276.

Change-Id: If42ab04a451dc8c4c7038213b7f7c925648c3444
2018-02-03 00:03:44 +00:00
Joey Parrish 14d91b0be8 Improve annotations and docs for TtmlTextParser
During docs review, I noticed that shaka.text.TtmlTextParser's
textAlignToLineAlign_ was defined as merely {Object}.  Improving that
to {Object.<string, string>} caused compiler issues, so I had to
further refine to {Object.<string, shaka.text.Cue.lineAlign>} and
refer to the enum values instead of directly using strings.

Issue #1259

Change-Id: Ifb012771a534f74f4458f8673fd4d12d136b2638
2018-02-01 21:55:01 +00:00
Jacob Trimble 554cffc95c Fix SegmentTemplate w/ duration.
We incorrectly added the presentationTimeOffset to the segment times as
a fix for #1164.  The correct fix is to use the include the PTO in the
time structure passed to the text parsers.  This is a partial revert
of 207505.

Issue #1164
Closes #1232

Change-Id: I1f2805e0dbdc44be71e2160b3d37a73732c97a4f
2018-02-01 00:12:45 +00:00
Joey Parrish ed54199260 Upgrade and unfork jsdoc
This updates jsdoc to the latest version from npm and forks a copy of
the default jsdoc template.

In subsequent commits, we will reapply our customizations to the
template and to a jsdoc plugin.

This also fixes several bad annotations that the new jsdoc failed to
parse.

Issue #1259

Change-Id: I00a47270ea4754e1c96c43ca900d5cf889ab72e6
2018-01-31 22:04:48 +00:00
Joey Parrish d36168a55f Protect against WebVTT MPEGTS rollover
When the MPEGTS field rolls over in HLS live WebVTT, we need to avoid
our parsed cue timestamps rolling over as well.  To achieve this, we
simply ignore the X-TIMESTAMP-MAP tag once the segment index is built.

Rollover in TS video and audio segments is handled by mux.js already.

Closes #1191

Change-Id: Ie52734509921973ff47517fab34367ec413a6ca6
2018-01-19 21:48:35 +00:00
Joey Parrish 4067c20a7c [ES6] Replace gjslint with compiler linter & eslint
The eslint configuration is derived from analyzing the style of our
sources as they are now, plus a few tweaks.

In particular, we have disabled checks for undefined variables and use
of console, both of which the compiler handle with greater precision.
The compiler already knows what is defined in the environment through
our externs, and has specific exceptions for the use of console (demo,
tests).

We have also disabled a few checks that we should use, but will
require many changes to the code: no-unused-vars, no-redeclare,
and comma-dangle.

This commit also fixes several types of eslint errors that were easy:
  - no-useless-escape (unneccessary escape characters in Regexp)
  - no-constant-condition (using true/false/0/1/etc in if/while)
  - no-fallthrough (caught an actual bug in one EME polyfill)
  - no-irregular-whitespace (we had a UTF-8 nbsp in externs)
  - no-cond-assign (using an assignment inside a conditional)

To satisfy stricter provide/require checks in the Closure Compiler
Linter, we will no longer use provide/require at all in tests.  We
will still use provide in test utilities (test/test/util/) since it
sets up the namespace for us.  But we will not use require there
because there is no deps management for test code.

Issue #1157

Change-Id: Icc44f51feeb568ea7d3980e693e92e560d897afd
2018-01-16 17:25:05 +00:00
Joey Parrish 74316c37d9 Add missing require statements
These were not caught by the compiler due to aliases used to access
them, but they were caught by some new linter tools I am trying to
integrate into the build.

Change-Id: I343d155d43285e8244376b95c95b08b5d4f2fa39
2018-01-03 22:29:45 +00:00
Joey Parrish 186e3e69c4 Consistently take Uint8Array in text plugins
Instead of taking Uint8Array for media segments and ArrayBuffer for
init segments, take Uint8Array for everything.

Clean-up after #1022, discovered while preparing the upgrade guide for
v2.3.

Change-Id: I1f284f6f51f345e663c06d96d788bd9cfb941c52
2017-12-19 22:29:43 +00:00
Joey Parrish 66bfa31538 Do not use VTTRegion yet
Our use of VTTRegion seems to be wrong.  The feature in Chrome is
behind the "experimental web platform features" flag.  If this is
turned on, we display subtitles in the wrong place.

Until we can verify and fix our usage of VTTRegion, we will not
use it.  There are other issues to deal with in our region support,
in particular that TTML uses px and VTT uses percentages.  Futher,
our VTT parser does not yet extract region information.

This fixes the main issue for v2.3, so that future releases of Chrome
do not break sites built with v2.3.  There is more work to do in v2.4.

Issue #1188

Change-Id: I0de3392bdfca381c3727580e66c1a57ec457c5c2
2017-12-18 22:39:20 +00:00