Commit Graph

2406 Commits

Author SHA1 Message Date
Álvaro Velad Galván 42d9ec052d Prefer unprefixed EME for Safari (#3021)
Closes: #2999
2021-01-19 15:06:10 -08:00
lyjimmy 83ff40892f fix(ads): Use the correct AdsLoader AD_ERROR event (#3105)
Listen to the `google.ima.AdErrorEvent.Type.AD_ERROR` event from the
IMA SDK AdsLoader instead of the `google.ima.AdEvent.Type.AD_ERROR` in
order to properly catch some ad errors that are currently being missed.

Closes #3095
2021-01-15 17:19:00 -08:00
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
Theodore Abshire cc035766c1 Feat(ads): Exposed getMinSuggestedDuration.
Change-Id: I73091d8bef9bee6f028a553b53a24b03ff36cbf3
2021-01-12 02:00:18 +00:00
Benjamin Wallberg 9ec5cb19d6 fix: Fix trick mode tracks in DASH (work around compiler bug) (#3087)
Closes #3085
2021-01-11 13:13:55 -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
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
Michelle Zhuo e40cdd0f9d fix(StreamingEngine): clear lastInitSegmentReference when clearing buffer
When toggling between two text streams quickly(for example en -> fr ->
en), the mediaState's lastInitSegmentReference may not get updated to
'fr' before switching back to 'en'. That way, in initSourceBuffer_(),
the initSegmentReference is considered as fetched and appended, but the
buffer was in fact cleared.

Setting lastInitSegmentReference to null every time we clear the
buffer, and fetch and append the initSegmentReference with the new
update.

b/168253400

Change-Id: Id6378bdadd34f93a2a2f54ac84d82cf39b89716e
2021-01-05 19:03:14 +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
Á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 b89312d3fa fix(MediaSourceEngine): Revoke the MediaSource object URL
We should call URL.revokeObjectURL after calling
URL.createObjectURL() to prevent memory leak.

createObjectURL creates a strong reference to the MediaSource object
inside the browser.  Setting the src of the video then creates another
reference within the video element.  revokeObjectURL will remove the
strong reference to the MediaSource object, and allow it to be
garbage-collected later.

Fixes #2953

Change-Id: If9dc18a69468dfb8a6ebe7f4992bd61c716c2104
2020-12-23 20:50:53 +00:00
Álvaro Velad Galván 607deb71c9 feat(dash): Add support for mpegB:cicp:ChannelConfiguration (#3057)
Closes: #2873
2020-12-23 10:27:15 -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
Michelle Zhuo 3ad70b4e02 fix(text): Skip append if switching to a new stream
StreamingEngine takes the following steps to fetch and append a
segment:
1. Fetch and append the init segment, and initializes the source
buffer;
2. Fetch the segment;
3. Append the segment.

When StreamingEngine switches to a new text stream, it:
1. initializes a new text parser
2. If there's a fetchAndAppend_() call in the process, waits until
   that is finished
3. Otherwise, clears the buffer, and schedules an update to call
   fetchAndAppend_().

If switching the text stream gets called in the middle of a
fetchAndAppend_() process, the stream of the mediaState
can be changed between fetch_() and append_().
The new text parser is intialized, but the new init segment is not
fetched yet, however StreamingEngine tries to append the old segment.
That would cause an error in TextParser.parseMedia().

After a segment is fetched, we can check if the current stream is
switched. If so, the mediaState is waiting to clear buffer. We can
skip append, and schedule a new update for the new stream.

b/168253400

Change-Id: If8eebeb9a8e459baf0ff34748d77020098a9468e
2020-12-21 21:28:54 +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 40a0b366f6 feat: Change default network request timeout (#3024)
The old default was 0 (effectively infinite, no timeout).  The new default is 30s.

Closes: #1578
2020-12-17 11:02:15 -08:00
Álvaro Velad Galván 207c235b1c feat: Optionally force HTTPS content URIs (#3025)
Closes: #1389
2020-12-17 10:59:15 -08:00
Theodore Abshire 655493f441 Fix(ads): Fix bug w/ configuring UI during CS ads
Previously, the client-side ad container was put inside the controls
container, which was cleared when the UI was configured. This meant
that re-configuring the UI made client-side ads go away, basically.
This moves client-side ads to go into their own container, which
is never re-made or uprooted, even when the DOM is recreated, in
order to not break the IMA SDK.
This has the side-effect of fixing a bug where client-side ads were
not always cleared upon loading a new asset, and could show up
unexpectedly in future playbacks.

Fixes #2869
Fixes #2943

Change-Id: I3cf67b0b278764c10c6ff2f678316dc9cc85929e
2020-12-16 14:26:09 -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 281edf35f3 fix: Avoid the risk condition of unloading text stream and scheduling updates
With slow network, fetchAndAppend_() may take some time, and the
text stream can get unloaded during the fetching and appending.
Before we schedule a new update of the text stream, we should check
if the mediaState of the text is still valid.

Fixes #2764

Change-Id: I311b0c18fd3f6ce8e167547bc91d4514a3790924
2020-12-16 18:15:42 +00:00
Álvaro Velad Galván 6494a5b1db feat: Add parameter to probeSupport to skip DRM tests (#3047)
Closes: #3037
2020-12-15 10:24:34 -08: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
Álvaro Velad Galván b7209f00f8 fix(media): SourceBuffer remove error on some platforms (#3042)
Fixes #2982
2020-12-14 15:39:41 -08:00
Dany L'Hébreux ed953bf76c fix(DASH): fix memory leak with SegmentTimeline (#3039)
We found the issue within our app with the latest Chromecast CAF receiver update (November 22, 2020) that use Shaka 3.0.x. With our live stream containing 90 minutes of buffer, we notice high level of buffering issue with our customer.

It seems that the createUris callback was holding onto a parsing context in each reference.

Closes #3038
2020-12-10 15:53:47 -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
Theodore Abshire ea90fbdf66 Fix(ads): Fix stopping ad manager after adblock.
Previously, if the ad manager was shut down before the client side
ad manager finished setting up (most commonly due to adblock preventing
the ads metadata from being loaded), it would result in an error. The
client side ad manager assumed that the IMA ad manager would have been
loaded before unloading, and didn't check to see if the object was
null.
This prevents that error, by checking if the object is set before
stopping it.

Change-Id: Ic9e9b206bcd62641c0c2c6257b3eaacb6246e9df
2020-12-08 13:56:39 -08:00
Álvaro Velad Galván 65143a6d32 fix(DASH): Fix trick-mode tracks associated with multiple regular tracks (#2992)
In DASH, a trick mode track can be associated with multiple regular tracks.

This fixes the parser to respect the whitespace-separated list of IDs instead of assuming just one ID.

Resolves #2978
2020-11-23 14:23:46 -08:00
Jacob Trimble ec210cbe1d fix(media): Create segment iterator when needed.
This refactors the user of SegmentIterator to be more of a strict
iterator and avoids the extra work of seek().  This has been moved to
SegmentIndex as a getIteratorForTime() function.  This makes iterators
simpler and easier to understand.

This also refactors StreamingEngine to only create the iterator when
needed and to clear it when seeking.  This also makes it easier to
understand since you need to get a new position if we switch streams
or seek.

Fixes #2956
Closes #2970

Change-Id: If35a5d8aaba01598c526c2d70b9d9d0e305851c3
2020-11-19 15:41:03 -08:00
Jacob Trimble 7944616657 cleanup(test): Use real SegmentIndex in tests.
This is important for integration tests that use the compiled library
since we need to use objects defined in the compiled bundle.  The
compiled library may call the renamed versions of methods, so our fakes
won't have the correct methods.

This also adds an immutable mode to SegmentIndex.  The TestScheme uses
the same manifest objects for multiple calls to load().  However, when
unloading, the Player will call destroy/release, which will clear the
SegmentIndex.  By having an immutable mode, we can reuse the same
manifest objects.

Change-Id: Id95c1df26c3c08b91cbfec7d1f61a551b897417d
2020-11-19 15:23:13 -08:00
Joey Parrish cb385731de fix(drm): Fix TS DRM failures
Before asking the CDM about its support for a MIME type, convert TS
types as the Transmuxer will.  That way, we're asking the CDM about
what it will eventually consume, not what we're streaming.

Fixes #2981

Change-Id: I6539e9a7e4c8afca348367c788e6438fb6e07b08
2020-11-17 02:53:32 +00:00
michellezhuo 65a6f265c7 feat(text): rename cue "spacer" to "lineBreak"
Change-Id: Ifca815b2f4d0c5f6e34edaa7b9fcb809d963f701
2020-11-16 07:53:16 +00:00
Joey Parrish ba4763ad49 fix(Tizen): Work around misreported AC-3 support on Tizen
Some Tizen devices seem to misreport AC-3 support.  This works around
the issue by falling back to EC-3, which seems to be supported on the
same devices and be correctly reported in all cases we have observed.

Closes #2989

Change-Id: I80f20ba796df29858728b19f8a9f6c1712c9556d
2020-11-14 00:14:29 +00:00
Álvaro Velad Galván 57d11d13c6 fix(media): Ignore incompatible TrickMode streams (#2984)
Resolves: #2846
2020-11-13 13:28:00 -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
Álvaro Velad Galván 0283283c09 fix(player): Fix metadata track in src= (#2971) 2020-11-11 10:31:55 -08:00
Joey Parrish 99d8d37e88 fix: Fix handling of role-less audio tracks
These two issues turned out to be related:

1. No way to select a track without a particular role (#2906)
2. Player should default to role-less audio tracks (#2909)

Before this fix, the Player would default to the first audio track
with a language match, which may have been an audio description track
or commentary track.  If the user doesn't have a preference of track
roles, we should default to a role-less track when possible.

There was also no way to explicitly select a role-less track in
selectAudioLanguage.  Before this fix, a call without a role would
effect a language-only match, ignoring roles and potentially selecting
a description or commentary track.

Now, not specifying a role (either in initial preferences or in
selectAudioLanguage) will result in a preference for role-less tracks
when possible.

Fixes #2906
Fixes #2909

Change-Id: Ie6957eaecd1dcf9b7b65d62afa8ba9d9a5bdefe9
2020-11-11 17:40:07 +00:00
Joey Parrish 9692dc080d fix(drm): Fix support for multi-period encrypted live
To support encrypted, multi-period live streams, you must initialize
the CDM whenever there is a license server config, without regard for
whether or not there is encryption signalled in a manifest.

If you join the stream during a clear ad, and there isn't enough
rewind allowed to see any encrypted periods at the time you join, the
manifest may not indicate encryption.  If we start playback without
setting up decryption, we would fail later when an encrypted period
appeared.

This issue affected releases v3.0.0 - v3.0.5.

Fixes #2979
Fixes #2645

Change-Id: Ic7ddcf46843178e6a3ce0b1d663da40dc9f4be8f
2020-11-11 17:39:59 +00:00
Álvaro Velad Galván 3484ac8c7c fix(media): Fix initSegment requests on manifest updates (#2942)
Fixes #2856
2020-11-10 10:38:35 -08:00
Jacob Trimble 20923cca5d fix(ttml): Fix another hard-coded namespace.
This also changes the tests to fail if we use any hard-coded namespace
prefixes.

Fixes #2756

Change-Id: I06cb7c2043cd7e1278f89a355e40d9d5d375d87d
2020-11-10 00:24:35 +00:00
Álvaro Velad Galván 383f3fc873 Filter chapters tracks in src= (#2960) 2020-11-05 12:48:58 -08:00
Michelle Zhuo a9a1695d22 fix: support TTML background image's region positioning
In bitmap-based cues, the tts:origin of the region should specify
the position of the background image. Add support for that case.

Closes #2703

Change-Id: I83ebeac939550138f8eef5d0b4547ab54fd6cf6c
2020-11-03 16:55:52 -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
DDeis 40d44517b9 feat(ads): allow adsResponse for making ad request (#2946)
Fixes #2892
2020-10-29 11:36:40 -07:00
Álvaro Velad Galván 01998f3b99 Parse forced subtitles from manifest (#2938)
Issue #2122
Issue #2916
2020-10-27 14:00:48 -07:00