Commit Graph

2665 Commits

Author SHA1 Message Date
Vincent Valot 6d76a135e5 feat: add modern EME support for FairPlay (#3776)
Add support for HLS com.apple.streamingkeydelivery through MSE/EME implementation.

Close #3346

## Tests
Tested on:
- Mac 11.6 Safari 15.2
- iOS 15.2 Safari 15.2
- Mac 11.6 Chrome 96 (for potential regressions on Widevine keySystem)

| Mode | DRM API | TS | CMAF (mono-key and multi-keys)
|---|---|---|---|
| file | EME |   |   |
| file | Legacy-prefixed |    |    |
| media-source | EME | **mux-js**: `encrypted` never fired<br />**real MSE**: `encrypted` event received, but with incorrect `sinf` initData (*1)  |   |
| media-source | Legacy-prefixed | **mux-js**: `webkitneedkey` never fired<br/>**real MSE**: TBD  | 🔴 fails to append media segment to SourceBuffer (init segment ok) `(video:4) – "failed fetch and append: code=3015"` |

## Support table 
| Mode | DRM API | TS | CMAF (mono-key and multi-keys)
|---|---|---|---|
| file | EME |   |   |
| file | Legacy-prefixed |    |    |
| media-source | EME | 🚫 `4040: HLS_MSE_ENCRYPTED_MP2T_NOT_SUPPORTED`  |   |
| media-source | Legacy-prefixed | 🚫 `4041: HLS_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED`  |🚫 `4041: HLS_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED` |

⚠️ Use EME APIs with multi-keys CMAF makes the video stalling with the audio continuing alone after a short time (~3 minutes in the stream, could be shorter, could be longer). Didn't find an explanation to that yet. I've observed the same behaviour with hls.js code so I don't think this is a player issue.
2022-02-07 11:17:22 -08:00
Casey Occhialini f27401cc15 fix: Fix duplicate CMCD parameters in HLS live content (#3875)
Use goog.Uri to append CMCD query data to avoid duplicate query params

Fixes #3862

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>
2022-01-25 14:42:20 -08:00
Theodore Abshire e9df8fb10c fix(text): Inherit alignment from regions.
The recent changes to TTML parsing, to not inherit regions,
inadvertently ended up breaking text alignment in situations
where a region with alignment was on the p or div above a span.
Previously, we only inherited the text and display alignment
from a region on leaf nodes... which was a problem, since we
also didn't apply any styles to text nodes.

Change-Id: I62ac155bc4310a5f7da52c10ca2dd434f8015c97
2022-01-25 21:39:21 +00:00
Álvaro Velad Galván 771619ff0e fix: Fix support for TTAF1 namespace (old version of TTML) (#3864)
Fixes #3009
2022-01-25 10:40:13 -08:00
Álvaro Velad Galván dfb369935b fix: Fix misdetection of HEVC support on MS Edge (#3897)
The proposed solution checks that all variants, apart from being checked in mediaCapabilities.decodingInfo, are also checked with MediaSource.isTypeSupported

There are some browser implementations that return a true mediaCapabilities.decodingInfo for unknown mimetypes and codecs and that can cause an application-level problem. For example, EDGE on Windows 10 returns true to HEVC even if you don't have the extension installed to support HEVC, instead MediaSource.isTypeSupported does take this into account

Fixes: #3860
2022-01-25 10:20:42 -08:00
Álvaro Velad Galván 74c491d2e0 feat: Add separate audio and video MIME types to Track API (#3892)
Fixes: #3888
2022-01-24 15:28:17 -08:00
Theodore Abshire bf67d87387 fix(text): Fix caption overlap.
This changes the TTML parser to not allow cue regions to be inherited
to the children of the element the region was originally assigned on,
except for the purposes of styles (colors, etc).
To allow regions on elements "above" the cues in TTML, such as the
<body> or <div> elements, this also changes the TTML parser to render
the full structure of the TTML file as a tree of cues. The end result
will be a single cue representing the <body>, with children
representing the <div> elements inside it, and those <divs> will have
children that represent the actual cues. Now that our text displayer
can intelligently update child cues as they enter or leave the display
window, this approach should be possible.

Closes #3850
Closes #3741

Change-Id: Ia8d750daa06920610c04e9b26e29d2d304eaf8a9
2022-01-20 22:41:37 +00:00
Casey Occhialini df55944e8f fix: Fix missing throughput in CMCD for HLS live (#3874)
* Use dynamic reference to abrManager

Fixes #3873

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>
2022-01-18 15:08:42 -08:00
Álvaro Velad Galván 8c626aec23 fix: Support multiple chapter tracks with same language (#3868)
Issue #3597
2022-01-18 10:02:12 -08:00
Patrick Cruikshank 9705639f45 fix: Clear buffer on seek if mediaState is updating (#3795)
Previously, we only cleared the buffer if the media state had
something buffered. This ensured that we did not pointlessly clear the
buffer when nothing was there.
However, this lead to problems if a seek was performed early during the
loading process, before the source buffer is initialized. During that
time, nothing is buffered, so we would not clear the buffer on a seek.
This lead to us accidentally fetching content from the beginning of the
presentation, rather than starting from the new clock time.
This changes the streaming engine to also clear the buffer if
mediaState.performingUpdate is true, to avoid that situation.

Closes #3299
2022-01-14 01:53:42 -08:00
Álvaro Velad Galván 087a9b489b fix(image): Fix thumbnails issues (#3858) 2022-01-13 14:37:28 -08:00
Álvaro Velad Galván 9f3fb46d37 feat: Allow WebP and AVIF image streams (#3856)
Fixes: #3845
2022-01-13 14:07:35 -08:00
Álvaro Velad Galván 8d1b5e6b07 feat(UI): Add video fullscreen support for iOS (#3853)
Closes #3832
2022-01-12 12:46:28 -08:00
Álvaro Velad Galván 3ff48cba9b fix(text): Made nested cues inherit region (#3837)
Closes #3743
2022-01-12 12:45:24 -08:00
Casey Occhialini 922778a5eb fix: Fix CMCD top bitrate reporting (#3852)
The tb (top bitrate) property should honor bitrate/size ABR constraints and only report the top playable bitrate.

The tb property should only report the bandwidth for that segments type (audio, video, muxed).

Fix incorrect top bitrate CMCD reporting by:

Honoring the player's current bitrate/size ABR constraints.
Only reporting the bandwidth for that segments type (audio, video, muxed).

Fixes #3851

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>
2022-01-11 21:40:04 -08:00
Joey Parrish 0201f2b760 fix: Fix MediaCapabilities polyfill on Safari
Fixes #3696
Fixes #3530

Change-Id: I2f2e248c9001e10013eb4b03af6b9ef49f28dc6c
2022-01-11 04:02:38 +00:00
Joey Parrish dfc44cbca6 fix: Fix usage of Shaka without polyfills
Revert "fix: Work around override of MediaCapabilities polyfill in Apple browsers (#3668)"

This reverts commit 31c0cd4b8c.

Fixes #3843 (usage of Shaka without polyfills)
Re-opens #3530 (MediaCapabilities polyfill not working on Safari)

Change-Id: Ib5aff1b38759e1a39200332f3f07d3d6bd3bd2e1
2022-01-11 04:02:38 +00:00
Joey Parrish 1cc99c1241 fix: Fix playback failure due to rounding errors
If a rounding error in the DASH parser created an extra "phantom"
segment that extended just beyond the presentation duration, this was
causing a playback failure.  Now StreamingEngine will tolerate these
small offsets and end playback at the correct time.

Fixes #3717

Change-Id: I00780a664aff4148b6b1046d8322a68da745de40
2022-01-11 04:02:34 +00:00
Theodore Abshire 264c842496 fix(image): Fix HLS image track issues
This makes the HLS parser honor more attributes for image tracks.
It also makes some changes to player.getImageTracks, so that the
returned track shows the size of a single thumbnail rather than the
entire sheet.

Closes #3840

Change-Id: I2ae096f455864201e08a85e29f0f02a3e06eb07f
2022-01-11 03:41:12 +00:00
Casey Occhialini fa5932ca8f fix: Fix CMCD property mangling (#3842)
Move CMCD type definition to externs to avoid minifying property names

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>

Fixes #3839
2022-01-10 15:42:16 -08:00
Álvaro Velad Galván 0117441bb0 fix(text): Remove caption wrapper bgColor (#3838)
Closes #3745
2022-01-10 11:49:36 -08:00
Joey Parrish 4731c7677f fix: Avoid WebCrypto randomUUID when CMCD disabled
If CMCD is disabled, there is no reason to use randomUUID.  And if
tests or applications are running in plain HTTP URLs (what the web
platform calls an "insecure context"), then WebCrypto APIs like
randomUUID don't exist.

If a site or test is running in plain HTTP, and CMCD is disabled
(which is the default), there shouldn't be any need to install the
randomUUID polyfill (which should be optional).

This changes the CMCD utility to skip generating a session ID if CMCD
is disabled.

Change-Id: Iaf9c3fe94bc03c0f5ce46a082d18513ad05fb341
2022-01-09 11:55:16 -08:00
Joey Parrish 824d8b5fa1 chore: Update master branch version number to prepare for v3.3 release
Change-Id: Ie7565815c52bd94f571c9029d0a521b6d8e9a923
2022-01-07 12:01:22 -08:00
Álvaro Velad Galván f767260dcc fix(DASH): Support "forced-subtitle" role (#3807)
Previously, Shaka Player only supported "forced_subtitle",
which was the working name before the role was finalized.

Closes #3767
2022-01-06 21:50:34 -08:00
Álvaro Velad Galván c5a81f53fe fix(text): Allow comments in the TTML parser (#3827)
Closes #3766
2022-01-04 11:34:44 -08:00
theRealRobG 73b430248b Dash hdr signalling via essential or supplemental property (#3727)
Now we parse value of descriptor for urn:mpeg:mpegB:cicp:TransferCharacteristics in AdaptationSet to indicate hdr property on shaka.extern.Stream which seems equivalent to HLS definition given in VIDEO-RANGE attribute within EXT-X-STREAM-INF.

This is done by reading the supplemental / essential property in the parsing of AdaptationSet, then mutating the hdr property on shaka.extern.Stream if no hdr exists after parseRepresentation_.

The alternative considered was to parse all essential / supplemental properties on any shaka.dash.DashParser.InheritanceFrame and then carrying that through to the parseRepresentaiton_ function; this can be seen here. The problem with the alternative approach was that the essential property in the adaptation set would have had to have been "let through" on the assumption that we would parse it within the parseRepresentation_ method... But this to me seemed somewhat risky to change, and also looks messy with the empty else if condition, plus was a much larger change (with more calls to XmlUtils, though not familiar with how that is implemented, so not sure if there was any penalty because of that).

* Test expectation for HDR signalling via property

The test sets the expectation that we should be able to extract the
information of the TransferCharacteristics from the DASH
AdaptationSet. This should then get converted to the nomenclature
used in HLS for the VIDEO-RANGE attribute on EXT-X-STREAM-INF.

* Implement signalling of HDR capability through property descriptor

According to DASH-IF IOP v4.3 6.2.5.1. the transfer characteristics
can be declared at the AdaptationSet level via a supplemental or
essential property. In HLS the transfer characteristics are used to
determine the value of the VIDEO-RANGE attribute on the
EXT-X-STREAM-INF attribute, which is already used to indicate the
hdr property on the shaka.extern.Stream object. Therefore for
consistency we also add the same identification to the DASH parser.

* Added entry in AUTHORS and CONTRIBUTORS

Fixes #3726
2021-12-16 13:19:26 -08:00
Casey Occhialini 1d54965bdc Update media capability polyfill to account for Playstation 5 (#3808)
Add Playstation 5 detection to the Media Capabilities Polyfill install method.

Fixes #3582

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>
2021-12-16 12:54:02 -08:00
Álvaro Velad Galván 3a9139e212 fix: Add DASH MIME type mapping for src= playback (#3805) 2021-12-14 11:32:17 -08:00
Aidan Ridley 6e0737ec25 Fix #3783 captions not working after a period transition on live DASH streams (#3801)
Embedded CEA-608 captions don't work on multi period live DASH DAI streams after new periods appear in the manifest because commas are appended the streams originalId string, which disrupts some stream matching code in text_engine.js

The problem has been resolved by preventing makeTextStreamsForClosedCaptions() from altering the PeriodCombiner.textStreams_ array.

Fixes #3783
2021-12-13 14:22:47 -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
Theodore Abshire 4bdd3bb65a fix(text): Force caption update when removing cues
Previously, in the updateCaptions_ method in the UI text displayer,
when trying to determine if a cue should be removed from the container,
we checked to see if it was out of the time range.
This worked in most cases, but it did have the side-effect that the
displayer would not remove the old cues if they were removed manually
via the remove() method. This was most visible if the user changed the
text language; the currently-displayed cue of the old language would
linger until it reached the point it would stop displaying normally.
This changes the UI text displayer to force an update when remove() is
called, if necessary.

Change-Id: I84a4847b67c5fb7597342a943abe13a3cc9e826e
2021-12-06 18:33:54 +00:00
Patrick Cruikshank 3e7a5b5f87 fix(hls): Fixes parsing of HLS 'DEFAULT' attribute (#3771)
Closes #3769
2021-12-06 00:36:06 -08:00
Vincent Valot 9e5b9ac139 fix(text): support stpp.ttml codec in Mp4TtmlParser (#3754) 2021-11-15 12:32:03 -08:00
Aidan Ridley bd7b384c66 feat: Add media quality change events (#3700)
Closes ##3431
2021-11-12 15:07:18 -08:00
Theodore Abshire c993fca579 Merge branch 'master' of sso://widevine-internal/shaka/js
Change-Id: Ib0905524a737510a69379bbcda0282442a03be89
2021-11-05 15:40:57 -07:00
Theodore Abshire db47395ad2 Merge branch 'geo-failover-robustness' of https://github.com/harmonicinc-com/shaka-player
Change-Id: I200cd2a53e28e2d3d8d99e4d8d242e7c90fb5a94
2021-11-04 13:35:43 -07:00
Theodore Abshire 1e598bab65 fix(hls): Made HLS notify segments after fit
Previously, the HLS parser would notify the presentation timeline
of the segments in the manifest before fitting the segments.
The HLS parser will also sometimes remove segments from the end of
a VOD asset if they do not fit within the playlist duration.
This could sometimes cause the presentation timeline and MediaSource
to have different opinions on how long the VOD asset was, which could
lead to the seek bar looking like the presentation stopped before the
end.

Closes #3733

Change-Id: I67fdc28a3f6eee158c9906359491fe6bb418e730
2021-11-03 23:19:30 +00:00
Theodore Abshire 9220c1f87d fix(hls): Made HLS notify segments after fit
Previously, the HLS parser would notify the presentation timeline
of the segments in the manifest before fitting the segments.
The HLS parser will also sometimes remove segments from the end of
a VOD asset if they do not fit within the playlist duration.
This could sometimes cause the presentation timeline and MediaSource
to have different opinions on how long the VOD asset was, which could
lead to the seek bar looking like the presentation stopped before the
end.

Closes #3733

Change-Id: I67fdc28a3f6eee158c9906359491fe6bb418e730
2021-11-03 16:16:35 -07:00
theRealRobG 1e7f2f3dc8 Pass HDR information when getting decoding info from media capabilities (#3730)
Fixes #3729

If the video variant stream contains information about `hdr`, then we now use that to provide a value for `transferFunction`, when constructing the [`VideoConfiguration`](https://w3c.github.io/media-capabilities/#videoconfiguration) object used to get decoding info from media capabilities API.

The following applies:
```js
switch (video.hdr) {
  case 'SDR':
    mediaDecodingConfig.video.transferFunction = 'srgb';
    break;
  case 'PQ':
    mediaDecodingConfig.video.transferFunction = 'pq';
    break;
  case 'HLG':
    mediaDecodingConfig.video.transferFunction = 'hlg';
    break;
}
```
2021-11-03 14:40:41 -07:00
Jacob Trimble cdeffbb9e6 fix(ui): Fix styling of UI text cues
First, the positioning of cues was incorrect.  We need to explicitly
set all the position attributes when we position elements with the
"absolute" position.

Second, if we position a text <span> manually, the background will fill
the whole region.  So to keep the background wrapping the text, we need
to add another <span> for the text.

Third, the background and font color should not be set on every <span>
element since it won't allow parent cues to set the inherited value.
So this moves the defaults to the top-level text element and allows
parent cue elements to override this.  It also would make app CSS
easier to override.  Because background color isn't inherited through
CSS, the default is set in JavaScript instead.

Fixes #3521
Fixes #3600
Closes #3713

Change-Id: I45fc88dcac4a0a062e1474087f24c80d98eef619
2021-11-03 17:31:25 +00:00
Theodore Abshire b8b72a900d fix(dash): Notify segments on all updates.
Before, when using SegmentTemplate or SegmentList, we would tell
the presentation timeline about new segments only when we saw a
new period or representation. This meant that, in live streams,
if new content was being added to the SegmentTemplate or SegmentList,
the presentation timeline was not being kept abreast of the changes.
Thus, if that stream were to then transition to VOD, the presentation
timeline would suddenly start to report that the current time was
beyond the end of the seek range, which caused playback to stop.

Closes #3675

Change-Id: I77ef00c5a86de9ebcb86f18f792084ed70f94e8d
2021-10-28 00:44:18 -07:00
Álvaro Velad Galván 173ae42cdd fix(offline): Do not apply CMCD query args to offline URIs (#3716)
Closes #3712
2021-10-26 00:38:22 -07:00
Theodore Abshire dd3748d599 fix: Enforce string-format of event data keys.
Previously, many events were being defined with a data dictionary
that used variable-type keys (e.g. {key: value}). This worked fine
in uncompiled mode, but in compiled mode it lead to those properties
being obfuscated.
This changes the FakeEvent constructor to take a map rather than an
object, so the compiler will force the keys to be strings.

Closes #3710

Change-Id: I67b1a391540a5ee21f0aaf940ae054d26f4c10a4
2021-10-25 12:40:32 -07:00
Casey Occhialini 221637a66c feat: Add Common Media Client Data (CMCD) logging support (#3662)
Add support for including Common Media Client Data (CMCD) in outgoing requests.

Fixes #3619

NOTE: The following fields have not been implemented: rtp, nrr, nor, dl

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>
2021-10-20 12:22:41 -07:00
Álvaro Velad Galván d667e50aa3 feat: Adds advanced ABR config options (#3706)
Closes #3422
2021-10-19 13:01:38 -07:00
david-hm-morgan 13aafcfd7e fix: Fix vp09 playback on webOS (#3566)
Skip the vp09 polyfill for isTypeSupported on this platform.
2021-10-18 13:51:54 -07:00
Álvaro Velad Galván 9c3bed3d60 feat(ads): Integrate with non-linear IMA CS ads (#3639)
Closes: #2596
2021-10-18 11:42:54 -07:00
Enson Choy eba7f133ea Fix variable naming as per request 2021-10-18 10:02:58 +08:00
Nick Michael a09d8c9869 fix: Dedupe DRM init data (#3695)
Linear streams accumulate init data over time because the init data is pushed to
an array regardless of whether or not it already exists as part of the logic to
combine periods. This PR dedupes the init data based on keyId to help reduce
memory usage over extended playouts.
2021-10-15 11:50:26 -07:00
Álvaro Velad Galván ea3568d726 feat: Add a config to dispatch all emsg boxes. (#3653)
Closes #3348
2021-10-12 14:22:11 -07:00