Commit Graph

624 Commits

Author SHA1 Message Date
Joey Parrish edce1899f9 fix: Fix header sizes for MP4 boxes with 64-bit size fields
The MP4 box header depends on both whether the box is a "full" box
(with version and flags) and whether the box has an extra 64-bit size
field.  The MP4 parser was only considering the version and flags, but
not whether the extra size field was present.  We already correctly
parsed the 64-bit size field, but computed offsets for other fields
without considering this.

Groundwork for a fix for #2759

Change-Id: I48f16ef073a036954b6f7d25641ccf29828b02c8
2021-01-14 12:57:41 -08:00
Joey Parrish 698d4e5694 fix: Fix load-time exception in nodejs
It is sometimes useful to load Shaka Player in nodejs, particularly a
debug build, to access some internal part of Shaka Player in a nodejs
script.  For example, I am currently working on an MP4 box
transformation for Shaka, but I am doing the R&D in node on the
command line rather than in a browser.

For this setup to work, Shaka should not refer to browser-specific
classes and APIs at load-time.  Thankfully, shaka.util.Lazy gives us
an easy way to lazy-load those things so that they are not needed at
load-time at all.

This change uses shaka.util.Lazy to defer a reference to
HTMLMediaElement in shaka.util.MediaReadyState.

Tangentially related to #2759

Change-Id: I376d2a81cb45e7cbc94be0a88deab3abb08001bf
2021-01-14 17:05:54 +00: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
Joey Parrish 6c012aa467 feat(hls): Add config to prefer native HLS playback
Closes #3077

Change-Id: Ib49270c17656e50cd68806836d7b71ee8e0bc148
2021-01-09 02:00:16 +00:00
Joey Parrish 68902b9a86 fix(drm): Remove legacy Edge workarounds on new Edge
We only just gained the ability to test on new Chromium-based Edge
(google/generic-webdriver-server@475ec746), so we did not previously
know which workarounds were specific to legacy Edge.  Now all but one
of those workarounds has been limited to legacy Edge only, and will
not be applied to new Chromium-based Edge.

Change-Id: I70b7480ccb61064b796c3d9b41bbe95cabfdf850
2021-01-05 18:36:52 +00:00
Michelle Zhuo c9ac5d0fc2 fix(period flattening): Check stream codecs when filtering duplicate streams
Compare the codecs of two audio/video streams to decide whether they
are duplicate streams.

b/174040424

Change-Id: Ifde2068ddf9088f653280c013a1f3247cb7d45ba
2020-12-21 16:15:56 +00:00
Álvaro Velad Galván e5bf0277be feat: Config to prefer forced subtitles (#3022)
Closes: #2947
2020-12-17 11:21:33 -08:00
Álvaro Velad Galván 207c235b1c feat: Optionally force HTTPS content URIs (#3025)
Closes: #1389
2020-12-17 10:59:15 -08:00
Michelle Zhuo 73449197ec fix(period flattening): Combine text streams with no roles
If two text streams in two periods have no roles while other text
streams have, combine those with no roles.

Issue #2785
b/172605645

Change-Id: Ie3b98e7941d38f5be90f4eb65d1a3de1c3e394a3
2020-12-16 18:16:02 +00:00
Michelle Zhuo 4238ae07b9 fix(period flattening): Check stream labels when filtering duplicate streams
Compare the labels of two audio streams to decide whether they are
duplicate streams.

Fixes #2884

Change-Id: I08b32586d26368593b0ebcf9459787461cd05c37
2020-12-15 17:46:21 +00:00
Michelle Zhuo cf6aa88ce9 fix(period flattening): Combine the streams with no roles
If two audio streams in two periods have no roles while other audio
streams have, combine those with no roles.

Fixes #2785
b/172605645

Change-Id: I8aa4189c3ddc50257e0dbd72cae4840ae1d446f1
2020-12-14 22:22:35 -08:00
Michiel W. Beijen 26fac1290f fix: Add missing * in jsdoc comment in periods (#3041)
The compareClosestPreferMinimalAbsDiff_ was missing a * in the
jsdoc comment. Fixing to avoid closure compiler was complaint.
2020-12-10 13:50:18 -08:00
Álvaro Velad Galván 28f35c251c feat(lowLatency): Add autoLowLatencyMode config (#2861)
With "lowLatencyMode" enabled, "rebufferingGoal" is set to 0.001, and inaccurateManifestTolerance is set to 0 by default. However, in some cases longer rebufferingGoal helps to avoid new rebuffering.
Besides  "lowLatencyMode", this code change adds the  "autoLowLatencyMode" config. When "lowLatencyMode" config is disabled and "autoLowLatencyMode" config is enabled, and the manifest provides low latency features, we automatically activate the lowLatencyMode.
If "lowLatencyMode" is enabled, "autoLowLatencyMode" has no effect.

Issue #1525
2020-11-12 11:07:19 -08: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
Joey Parrish 9ece285b92 fix: Fix compatibility for plugin factories
In v3.0, we changed our plugin interfaces so that all are factories
that return objects.  We no longer call those with "new" as we did in
v2.5.

We provided backward compatibility and a deprecation warning to alert
applications to update their usage of those interfaces.  However, this
compatibility shim was broken for ES6 classes, which behaved
differently than ES5 constructor functions.

This fixes the shim and adds regression tests.  The tests were tricky
because we use Babel to transpile our tests, but we needed raw,
untranspiled code to define a class to test these features.  So we use
eval and some associated trickery to get exactly the different kinds
of plugin registrations we intend to support.  These tests are skipped
on non-ES6 browsers.

Fixes #2958

Change-Id: Ife8b63c0d89f4ea0aff085d3a4c156c4eb657604
2020-11-03 21:58:44 +00:00
Álvaro Velad Galván 01998f3b99 Parse forced subtitles from manifest (#2938)
Issue #2122
Issue #2916
2020-10-27 14:00:48 -07:00
Álvaro Velad Galván faa1e52902 feat(text): Add addTextTrackAsync (#2932)
This new method can make a HEAD request to the server to determine the MIME type.  The old method (addTextTrack) is now deprecated and will be removed in v4.
2020-10-22 09:32:06 -07:00
Álvaro Velad Galván 919e3efe94 fix(text): Add error codes to addTextTrack errors (#2930)
Add new error codes for addTextTrack:
 - CONTENT_NOT_LOADED
 - TEXT_ONLY_WEBVTT_SRC_EQUALS
 - CANNOT_ADD_EXTERNAL_TEXT_TO_SRC_EQUALS
2020-10-21 10:34:40 -07:00
Joey Parrish 3eca74721d fix(ui): Export FakeEvent for use by UI plugins
UI plugins can already dispatch events on the controls, but it is much
less convenient to do so without this export.

Issue #2923

Change-Id: I46edbe01a67e70e052dbbded333af18d086d36ab
2020-10-20 03:35:58 +00:00
Theodore Abshire 98df64c1af Feat(player): Add label to LanguageRole externs
Closes #2904

Change-Id: I96dffaf377f856db9a14d9784d3bbbbb08c297b8
2020-10-14 20:30:10 +00:00
Jacob Trimble f7aacf151c fix(periods): Ignore streams with period-specific codecs
Fixes #2883

Change-Id: Ib9ccc4e7c144e69c264f6dc24fc0cd3397950e07
2020-10-06 22:24:44 +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
Vincent Valot 54d48e1a46 feat: deduplicate text streams in period flattening (#2885)
Similar to what was already done for audio streams.
2020-10-01 08:51:05 -07: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
Michelle Zhuo 1e8f8bbf1f feat(LL-HLS): Set default streaming config for low latency
To enable low latency streaming, the configuration of
inaccurateManifestTolerance should be set to 0, and rebufferingGoal
should be set to less than 1 partial segment duration.
Instead of requiring developers to set three configurations, we
default inaccurateManifestTolerance to 0 and rebufferingGoal to 0.01
with low latency mode, unless speicfied.

Issue #1525

Change-Id: I538fa6d84ced26225fe9ebdf5213b370debfa22d
2020-09-17 18:56:58 +00:00
Vincent Valot a344f1017d fix: correctly detect Edge Chromium as Edge (#2855)
Without this, #2801 is broken on the latest versions of Edge
2020-09-17 09:21:38 -07:00
Michelle Zhuo 40d0359732 feat(LL-Dash): Parse and append ReadableStream by MP4 boxes
To enable low latency streaming, we need to append chunked data of
ReadableStream by complete MP4 boxes.
Everytime we get chunked data of the ReadableStream, we find the
last complete Mdat box. Append the completed boxes of data, and save
the data of the incomplete box until next time we get the chunked
data.

Issue #1525

Change-Id: I722ff992f397ee2f62bca45db33a0834ef57a270
2020-09-16 13:18:03 -07:00
Michelle Zhuo f67367a81b feat(LL-Dash): Fetch and append ReadableStream
With the low latency streaming mode, we fetch a segment, and get the
response data through a ReadableStream.
For each segment request, we may get multiple chunked data. We handle
and append the chunked data of the ReadableStream via a callback
function in the StreamingEngine.
Once the whole segment gets handled and appended, we move on to the
next segment.

Issue #1525

Change-Id: I7949c87f4e491c928919c2e9dc4dafbebac22c9b
2020-09-16 20:17:02 +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
Theodore Abshire a72a1e9102 feat(text): Switch to using TextDecoder for UTF8
Previously, to decode UTF8 content, we used the browser's
decodeUriComponent method.  This worked in most situations, but it
would stop and error the moment it found an invalid UTF8 character.
This meant that a single poorly-encoded character inside a text stream
would cause the entire closed captions to fail to display.
In this CL, we switch to using the newer TextDecoder API, which
will instead replace invalid characters with an "unknown character"
code point, and continue parsing. This should make our text parsers
more robust when faced with bad encoding.

Closes #2816

Change-Id: Ibf2887e143d24d15a127bbcf2961539669580eea
2020-09-09 13:49:28 -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
Michelle Zhuo a22df6d18c feat(lowLatency): Move lowLatencyMode config to streaming configuration
1. Move the config field from ManifestConfiguration to StreamingConfiguration, since StreamingEngine will need it.
2. In manifest parsers, we get the value of lowLatencyMode config from the StreamingConfiguration.

Issue #1525

Change-Id: Iaa961b4e6799ecc1fcf3147b2fb992e86d4b043d
2020-08-20 03:33:46 +00:00
Álvaro Velad Galván 1c4067122a fix: PlayReady only has little-endian key IDs on Edge & IE (#2801)
Rather than list all the platforms that have big-endian PlayReady key IDs, we should list the ones that seem to have little-endian key IDs.
2020-08-19 18:28:47 -07:00
Theodore Abshire 79f8331d5e feat(stats): Added completionPercent to stats.
Change-Id: I441bc7fafb6115aa5a2a41a71b318d36f8446929
2020-08-18 20:03:57 +00:00
Álvaro Velad Galván f42ccd2867 feat(VTT): Adds VTT tag rendering for <b>, <i> and <u> (#2776)
Closes #2348
2020-08-11 11:58:21 -07:00
ismena 11ee823b0c fix(period flattening): Ensure the number of variants stays stable when new periods are added.
Our period flattening logic used to keep creating new streams and variants
when encountering a certain type of content (same main content and slightly differing
sequence of ads). In time, this led to a performance drain, where more and more time
was spent processing the variants, leading to all kinds of delays.
This is the last change in the series, addressing the way we set stream properties
when concatinating streams.

Fixes #2716.
Fixes #2736.

Change-Id: I98ae692797d19344601d7a0c51d1e343dfe55e01
2020-08-10 22:43:02 +00:00
ismena 4781129571 fix(period flattening): fix attribute comparison in the period flattening logic.
Issue #2716.

Change-Id: I8931dc31d0208ad9cfa25c9d87fcf3cbf550f423
2020-08-07 14:50:33 -07:00
ismena 49dd504f7f fix: Filter out duplicate streams on period flattening.
Issue #2716

Change-Id: Ib48cab9e84c5ccbca9b7e54531bc11d0b8b9af13
2020-08-05 18:00:23 +00:00
Joey Parrish 5a0383585f fix: Fix data URI parsing when charset present
Data URIs can have additional parameters other than just the MIME type
and encoding.  While working on TTML fixes, I was debugging by
inserting data URIs as TTML text tracks.  But the data URI encoder I
used was inserting a "charset" parameter into the URI, which was
rejected by Shaka Player.

This fixes the data URI parser to understand these extra parameters.

While researching this fix, I also found that only the base64 encoding
is specified for data URIs.  So now only that specific parameter is
supported as an encoding, and the UNKNOWN_DATA_URI_ENCODING error code
has been retired.

Change-Id: I7022529b0931e80a77a1120fc86c25b42e1fb3d9
2020-08-04 21:48:12 +00:00
Joey Parrish 04f3009346 fix(Tizen): Fix stalling playback on Tizen 3
Playback stalls on Tizen can be corrected by pausing and playing
again.  For Tizen and similar platforms, this is superior to the old
way of seeking to unstall playback, because seeking is expensive on
those platforms.

To facilitate pausing and playing again instead of seeking, a
stallSkip value of 0 will trigger the pause/play workaround instead of
the seeking workaround.  Further, we will make this the default on
Tizen, WebOS, and Chromecast.

An internal detail which is changing is that GapJumpingController will
now call StallDetector first and inhibit gap jumping when the stall
detector has something to do, rather than the other way around.  This
allows the StallDetector to be in charge of deciding what is buffered,
rather than having to pass GapJumpingController's interpretation of
buffered ranges first.

Fixes #2620

Change-Id: I5ad7aad42aa185b2837c830970e54218b4e55a21
2020-07-23 22:09:36 +00:00
michellezhuo a534dca883 feat(LL-HLS): Add configuration comments for low latency mode
1. In low latency mode, the playback start time from live edge is about
3 times partial segment duration, 3s for example. The rebufferingGoal of
2s would result in infinite buffering.

2. In low latency mode, do not allow drift for seeking. Only seek with
the presentation time.

Change-Id: Iee92727bf17dab8b52fae070522a5a2ec1621ffc
2020-07-22 17:00:15 +00:00
Jacob Trimble dc8b007d56 cleanup: Add missing requires.
This is a port of the internal changes: cr/321495405, cr/321592702,
and cr/321594488.

Change-Id: If6a4c4266ed10a70b01442974dbd19329bb5122e
2020-07-16 10:59:49 -07:00
Álvaro Velad Galván 943bdb2b35 Use Network Information API to react to network changes (#2663)
Resolves #1067
2020-07-09 09:46:24 -07:00
Muhammad Haris 480d4a801a Parse CEA-708 Packets from Fragmented MP4 streams. (#2660)
This is an MP4 Parser which extracts CEA-708 packets from Fragmented MP4 streams.

The Closed Caption Parser (shaka.media.ClosedCaptionParser) will own this MP4 Parser, and will initialize it and call it as shown. As data comes in, the parser will parse this data, and the caption packets data then be returned in a callback (on708Data), as shown. Here, a theoretical decoder (future pull request, mentioned as a Todo comment) will decode and extract the parsed captions from these packets.

Issue #2648
2020-07-05 16:29:17 -07:00
Joey Parrish 810f09ff1e fix(DASH): fix failure with identical text streams
The period-flattening algorithm is run even on single-period content
if the manifest is dynamic, because we don't know if another period
will be added later.

As a failsafe, we should create one output per input for single-period
content, and we can ensure that no streams are unused by marking an
input stream as the "best match" for an output if they share the same
ID.  That way, even if all other characteristics for two inputs are
the same, the input-to-output mapping for single-period content will
always be sane.

That ID-based logic was missing for text streams.  This change
corrects that.

Closes #2646

Change-Id: I28c6c63d92bcf710ae0072783911f9e66ed78228
2020-06-17 16:12:00 +00:00
Muhammad Haris e8f24ece6f Created MP4 Box parsers to parse data for common box types (#2649)
Issue #2648
2020-06-15 17:35:38 -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
Jacob Trimble 705fae7908 refactor: Clean AbortableOperation and add tests
Change-Id: I2e0aee32c20bd009cb56ab58070b960f6b19b4b2
2020-06-09 22:20:45 +00:00
michellezhuo 6d373eb631 Add config for low latency mode
Issue #1525

Change-Id: I561ac50b4681036b7675efdceae70937c4b9244d
2020-06-09 17:29:54 +00:00
Álvaro Velad Galván a201be414a fix: export shaka.util.FairPlayUtils and shaka.util.BufferUtils (#2628)
@exportInterface is used by the extern generator, but ignored by the
compiler. @export should be used for shaka.util.FairPlayUtils and
shaka.util.BufferUtils.

Closes #2626 and #2627
2020-06-09 07:32:59 -07:00