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
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 #1164Closes#1232
Change-Id: I1f2805e0dbdc44be71e2160b3d37a73732c97a4f
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
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
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
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
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
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
We do not support CSS embedded in WebVTT at this time. Instead of
failing to parse the cues, skip the style block.
Closes#1104
Change-Id: I3d500ba11afe43e81bbdef9924e4dd9e05db2b85
This avoids having media from one period replaced by media from the
next period. Instead, media that comes before the period start will
be chopped off by MediaSource.
Closes#1098
Change-Id: Idf6dc2ffafe78214e94bc75aca63920e153f1a2c
This speeds up HLS stream startup significantly for servers that
permit this kind of request, and falls back to full segments for
servers that do not.
Closes#1106
Change-Id: I96bc7f0df0fb84b75f3a3fe43476ba0ba5fc2264
We misinterpretted the EXT-X-START tag before. Now, we ignore this
tag and parse segment times from the segments themselves. This is
more robust for both VOD and live HLS content.
We avoid segment parsing when updating normal, well-behaved live
streams. For poorly-behaved live streams, we will fall back to
segment parsing and recover.
This also addresses the issue of VOD content which does not start at
zero. Instead of using configuration to make this playable, we will
now offset VOD content back to 0 automatically.
Issue #740Closes#1011
Change-Id: Ib3a59f87e3a050244cd39854409d8e3542c50b0a
We want to be able to write logs for deprecated APIs. This ensures
that those logs appear even when we disable logging in compiled builds.
Change-Id: I1f1546049fb17967eedb1bb45a7f76d5b1809cd1
This converts from using ArrayBuffer in the text parsers to using
Uint8Array. This avoids doing extra buffer copies when using
ArrayBuffer.slice().
Closes#1022
Change-Id: I34a789ec4eb76c95169ba81f27a8433ef25f27f0
Generated externs should include member assignments from constructors.
Without them, the generated externs may not appear to implement the
full interface. The alternative is to re-declare these members on the
prototype, but that is more difficult to maintain. Instead, the
extern generator can convert them for us.
Example code:
/** @interface @exportInterface */
FooLike = function() {};
/** @exportInterface @type {number} */
FooLike.prototype.bar;
/** @constructor @export @implements {FooLike} */
Foo = function() {
/** @override @exportInterface */
this.bar = 10;
};
Example externs:
/** @interface */
FooLike = function() {};
/** @type {number} */
FooLike.prototype.bar;
/**
* @constructor @implements {FooLike}
*/
Foo = function() {}
/**
* @override
*/
Foo.prototype.bar;
Change-Id: I435ba1800d5eefbf68c27851d6454c1a572cc6f6
The tts:origin and tts:extent attributes specify the sub-region to
render cues onto. We parsed them as positioning info for the cues
themselves. This converts to using VTTRegion for this. However, this
is ignored on browsers since none expose VTTRegion as of now.
Closes#1020
Change-Id: I0f922868690461cdd8847c3eba21d944d854f537
Beforehand, if we were parsing a ttml subtitles stored in an mp4, we did
not account for the possibility that there would be multiple mdat boxes,
each with its own ttml data. In such a case, we would only use the
payload from the final mdat.
I don't know if having multiple mdat like that is really in the spec, but
at least one user has had this problem, and it's a straightforward change
to make that doesn't really slow down the text parser at all (since we
parse every mdat anyway).
Closes#1028
Change-Id: Id782695548cb92f7aa7278843695b670d8c15ff0
The fields in shaka.text.Cue were getting renamed in compiled builds,
which would cause problems with custom text parsers or text
displayers.
Change-Id: I5a1c05ad373aca722268417c55a84f195e53ee20
It appears there are different behaviours for text cues on
safari compared to other browsers. We were using "auto" for
position, but Safari does not support setting that value for
position. The spec says that the default value is "auto", so
by not setting it, we can assume that it will be "auto".
Closes#991Closes#1012
Change-Id: Ibedc5f01f72138df85b911bb5112d40f2f327ad3
When a text track's mode is set to "disabled" the cues exposed cue
list is set to null. However, if you save a reference to the list,
the reference is valid. If the track is disabled, the add and remove
calls still work.
This change caches the reference to the cue's list when the track is
first created so that we can always read it - regardless of what mode
the track is set to.
Fix#990
Change-Id: I8274ea8450e664eeaa359bf9e78d13405fd2e503
Previously, our HLS implementation only supported WebVTT, because
that seemed to be the only supported format in HLS.
Now, we add support for other formats by extending the MIME and codec
guessing system to text streams. We also add a parser registration
for HLS's new "stpp.TTML.im1t" codec string.
Closes#986
Change-Id: I0a58ca4650675ff0546e36edf4114290f7931239
Text parsers set several cue enum properties with
parsedValue.toUpper() rather than explicitely stating the enum
value. Renaming enum keys in compiled mode interferes with it.
Closes#987
Change-Id: Id3ff878eaa96bce28eaddd379a457f8743c97ea2
IE/Edge don't accept cues that are out of time order. So when we
reverse the order of cues for #848, the cues would be rejected. Now
we sort the cues and only reverse the order of cues with equal times.
Change-Id: I860e1ea9694eb95ff2e74d9545c92373eb371686
If line and position are null, the corresponding VttCue should have
default values. Before this change, we treated 0 as null, which would
have prevented setting line or position to 0.
Change-Id: I63c3ce301016eb96bf3e6c1299433262c998cdc2
Since the browser displays identical ranges from bottom up, we must
reverse the order before feeding them to the browser. This way, the
first one parsed shows up on top.
Issue #848
Change-Id: Id2e6582e610808f7061bd0f8281c0705ecf1d6dc
This adds support for WVTT samples with no sample duration by parsing
the default duration from the "tfhd" box. If neither is provided, we
now log an error to the console.
Closes#919
Change-Id: Icc5550de7bc6018253004a5d3429ccc083ff6cb6
We can now accept non-integral values in settings, such as
"position: 100.0%" instead of just "position: 100%".
The regex change is very simple, so we would also accept invalid
settings such as "position: 12.34.56%" or "position: ...%", both
of which would result in NaN in the output.
Issue #919
Change-Id: I0a437322e76e35fe1d2f369b4a3ea87269799431
We should not reinit text until we are sure we are switching.
Otherwise, the new text parser won't have seen the init segment and
won't be properly initialized.
Closes#910
Change-Id: Ieb5549afcad7aa58aa1a6e8d383f3cd783280d5c
This is part of adding a new conformance rule to add additional type
safety. This will disallow using properties of unknown types or using
unknown properties.
The first parts will be fixing errors caused by the new rule. These
are backwards compatible, so can be applied before the rule is enabled.
Once all the errors and bugs are fixed, the rule will be enabled.
Change-Id: Iefde089b2f62ddfdf43944cda5badab438577561
This change creates a lib/text directory and moves all files
with text-related logic to it. It also lays the ground for
separating text parsing and display logic. (That change will
introduce even more files with text-related logic which will
crowd lib/media directory).
Issue #796.
Change-Id: I65ac134020a0126ff02a8f2067beb73870232e65