Commit Graph

726 Commits

Author SHA1 Message Date
Álvaro Velad Galván 0fd19997dd feat!: Remove small/large gap config, always jump gaps (#4125)
We get rid of the "small/large" gap concept, to always jump gaps by default

Related to issue https://github.com/shaka-project/shaka-player/issues/3188#issuecomment-788173036
2022-04-13 11:00:47 -07:00
sr90 b83b4120f4 feat(dash): Construct ClearKey PSSH based on MPD ContentProtection (#4104)
This PR parses default_KID from ContentProtection in the manifest and constructs a PSSH box from it to feed to the ClearKey CDM only if clear key content is detected.

Example: 

```
<ContentProtection
    schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc"
    cenc:default_KID="9eb4050d-e44b-4802-932e-27d75083e266" />
<ContentProtection
    value="ClearKey1.0" schemeIdUri="urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e">
         <clearkey:Laurl Lic_type="EME-1.0">https://drm-clearkey-testvectors.axtest.net/AcquireLicense</clearkey:Laurl>
 </ContentProtection>
```

PSSH is based on https://www.w3.org/TR/eme-initdata-cenc/

Tested content: 
https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p_ClearKey.mpd
2022-04-13 08:34:39 -07:00
Joey Parrish ac5acc80cb feat!: Remove deprecated features, update upgrade guides (#4089)
Below are the changelog entries for each deprecated feature removed by this commit.

-----

feat(config)!: `manifest.dash.defaultPresentationDelay` has been replaced by `manifest.defaultPresentationDelay` (deprecated in v3.0.0)

feat(config)!: Configuration of factories should be plain factory functions, not constructors; these will not be invoked with `new` (deprecated in v3.1.0)

feat(player)!: `shaka.Player.prototype.addTextTrack()` has been replaced by `addTextTrackAsync()`, which returns a `Promise` (deprecated in v3.1.0)

feat(ui)!: `shaka.ui.TrackLabelFormat` has been renamed to `shaka.ui.Overlay.TrackLabelFormat` (deprecated in v3.1.0)

feat(ui)!: `shaka.ui.FailReasonCode` has been renamed to `shaka.ui.Overlay.FailReasonCode` (deprecated in v3.1.0)

feat(offline)!: `shaka.offline.Storage.prototype.store()` returns `AbortableOperation` instead of `Promise` (deprecated in v3.0.0)

feat(offline)!: `shaka.offline.Storage.prototype.getStoreInProgress()` has been removed; concurrent operations are supported, so callers don't need to check this (deprecated in v3.0.0)

feat!: `shaka.util.Uint8ArrayUtils.equal` has been replaced by `shaka.util.BufferUtils.equal`, which can handle multiple types of buffers (deprecated in v3.0.0)

feat(manifest)!: `shaka.media.SegmentIndex.prototype.destroy()` has been replaced by `release()`, which is synchronous (deprecated in v3.0.0)

feat(manifest)!: `shaka.media.SegmentIterator.prototype.seek()`, which mutates the iterator, has been replaced by `shaka.media.SegmentIndex.getIteratorForTime()` (deprecated in v3.1.0)

feat(manifest)!: `shaka.media.SegmentIndex.prototype.merge()` has become private; use `mergeAndEvict()` instead (deprecated in v3.2.0)

feat(plugin)!: `AbrManager` plugins must implement the `playbackRateChanged()` method (deprecated in v3.0.0)

feat(plugin)!: `shaka.extern.Cue.prototype.spacer` has been replaced by the more clearly-named `lineBreak` (deprecated in v3.1.0)

feat(plugin)!: `IUIElement` plugins must have a `release()` method (not `destroy()`) (deprecated in v3.0.0)
2022-04-11 17:11:40 -07:00
Álvaro Velad Galván 8bb70449d3 feat!: Remove support for Safari 12 and iOS 12 (#4112)
1. Remove support for Safari 12
2. Support modern EME in Safari 13
3. Remove EME Apple polyfill
4. Update documentation
2022-04-11 16:17:51 -07:00
Álvaro Velad Galván 57c73241a0 fix(performance): Eliminate use of ES6 generators (#4092)
See: https://github.com/shaka-project/shaka-player/issues/4062#issuecomment-1077826210

Co-authored-by: @joeyparrish

Issue #4062
2022-04-04 10:58:16 -07:00
Philippe f382cc702b feat: add option for segment-relative VTT timings (#4083)
This PR fixes #3242 where for some live streams using segmented VTT, text timings are relative to segment start instead of being absolute.

The PR introduces a new setting: `manifest.segmentRelativeVttTiming: boolean` allowing such alternative timing offset calculation.

The setting is off by default, preserving the current player behaviour.

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2022-04-01 09:39:11 -07:00
theodab 48dd20562c fix(hls): Support playing media playlists directly (#4080)
Closes #3536
2022-03-30 17:27:50 -07:00
sr90 19e24b1d74 feat(dash): Parse ClearKey license URL in MPD (#4066)
Example content protection tags parsed: 

```xml
<ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="<default key id>" />
<ContentProtection value="ClearKey1.0" schemeIdUri="urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e">
    <clearkey:Laurl Lic_type="EME-1.0">License Url</clearkey:Laurl>
```

The player parses the default key id and license url, 
and sends a POST request to license url as per https://w3c.github.io/encrypted-media/#clear-key-request-format to retrieve the decryption key/s.
2022-03-30 09:10:14 -07:00
Álvaro Velad Galván 298b60481d fix(dash): Fix performance regression (#4064)
See: https://github.com/shaka-project/shaka-player/issues/4062#issuecomment-1077826210
2022-03-25 13:56:38 -07:00
theodab 89409cee3e feat(hls): Read EXT-X-PROGRAM-DATE-TIME (#4034)
This makes the HLS parser read the EXT-X-PROGRAM-DATE-TIME value
on manifests, and use it to make sure that segments are inserted at
the correct place in the timeline, when in sequence mode.

Issue #2337
2022-03-24 15:58:53 -07:00
Giorgio Gamberoni 0b04aecdd7 fix(dash): Account for bandwidth before filtering text stream (#3765)
We filter out text streams that are duplicates, before persenting
them to the end user. A duplicate is detected by checking if
various values on the streams are the same.
However, we were not checking for bandwidth. This could lead to a
text stream being marked as a duplicate if it had the same language,
label, etc as another, even if they did not contain the same text.
This changes the utility to also check bandwidth.

Closes #3724
2022-03-22 11:29:34 -07:00
Álvaro Velad Galván f1eeac1efb feat: add new methods to FairPlayUtils (#4029)
This adds 3 new methods to FairPlayUtils:

- isFairPlaySupported --> Closes PR #3562
- spcFairPlayRequest --> This method adds basic spc FairPlay request filter
- commonFairPlayResponse --> This method adds a basic FairPlay response filter that supports a lot of DRM providers.
2022-03-16 11:05:29 -07:00
Joey Parrish 1507b1e844 chore: Update URLs after moving projects (#4008) 2022-03-03 14:34:40 -08:00
Joey Parrish d99ab7959d build: Update eslint (#3977)
Also fixes linter errors found by the new versions
2022-02-18 08:26:43 -08:00
Álvaro Velad Galván 0daa00fc7f feat!(hls): HLS disabled in old browsers/platforms due to incompatibilities (#3964)
In Tizen 2/3 and WebOS 3.x there is no support for SourceBuffer.mode=sequence so as a result of change #2337, it necessary disable support for the HLS parser so that the user can at least use the native one with src= .
2022-02-17 19:52:36 -08:00
Joey Parrish f1c1585afb fix: Add explicit release() for FakeEventTarget (#3950)
Before, we would count on all event listeners for FakeEventTargets to
be cleaned up by the object that listens.  Now, FakeEventTarget
implements IReleasable, so that all listeners are removed when owners
call release().

For objects extending FakeEventTarget and also implementing
IDestroyable, the destroy() methods will call out to super.release()
to clean up listeners then.  The owner should use destroy() in those
cases.

Issue #3949 (memory leak in DASH live streams with inband EventStream)
2022-02-15 12:06:26 -08:00
Michelle Zhuo 36d0b5484f feat(HLS): Containerless format support
This adds code to allow Shaka Player to play media in sequence
mode, an alternate playback mode that makes the browser ignore
media timestamps, when playing HLS media.
This is important for containerless media formats, as they do not
contain such timestamps.
Changing HLS to not require timestamps also means that we no
longer need to fetch media segments in order to get the start
time, which should lower bandwidth usage and startup delay.
In initial tests, on a simulated 3G network, load latency went down
from an average 3.16s to 2.61s on the HLS version of "Big Buck Bunny:
the Dark Truths of a Video Dev Cartoon"; an improvement of about 17%.

Issue #2337

Change-Id: I507898d74ae30ddfb1bddf8dce643780949fbd9b
2022-02-08 09:34:03 -08:00
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
Á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
Á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
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 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
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
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
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
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
Aidan Ridley bd7b384c66 feat: Add media quality change events (#3700)
Closes ##3431
2021-11-12 15:07:18 -08: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
Á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
Á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
Álvaro Velad Galván 31c0cd4b8c fix: Work around override of MediaCapabilities polyfill in Apple browsers (#3668)
See also #3696

Closes #3530
2021-10-12 10:59:06 -07:00
Theodore Abshire 57836942c6 feat: Export LanguageUtils
Closes #3692

Change-Id: I4a60a4aaac0621fcef1c6753e2018687672e7ad2
2021-10-11 10:38:15 -07:00
Álvaro Velad Galván 52d68a29c8 feat(hls): Make default HLS audio/video codecs configurable (#3651) 2021-09-22 00:47:35 -07:00
Joey Parrish 6aac1d7479 cleanup: Add error logs to all XML parser failure cases
While working on the issues tagged below, I needed to explicitly debug
the many possible error cases in the XML parser.  Now, each one is a
unique return with its own error log.

The order of checks has also been changed so that, for example, a
parser error at the root of the document isn't misunderstood to be a
mismatch of the root element's tag name.

Issue #3636
Issue #3627

Change-Id: I75ded6eaab2137892b93b5530023e0b39156f1ae
2021-09-15 22:50:46 +00:00
Michelle Zhuo b16d30c249 feat(dash): Create segment index only when used
Only create the segment index for a stream when the stream is chosen.
When switching to another stream, release the segment index of the
original stream, and create the segment index of the new stream during
the next update.

Change-Id: I4d8a64e0e52d3e7edb71d402a97ab1dcd7f561dd
2021-09-14 16:41:24 -07:00
enson-choy 6a775e29a4 fix: Fix CC parsing of EPB and v1 TKHD boxes (#3610)
When unboxing TKHD, the reader read int64 as trackId instead of int32. Thus unable to find matching timescale when doing TFHD unboxing. Therefore when parsing MDAT, the default timescale will be used which is 90000. All CC timestamps will then be incorrect.

This also fixes "Shaka Error MEDIA.VIDEO_ERROR (3,,PIPELINE_ERROR_DECODE: Failed to parse H.264 stream)" error when playing DASH MP4 H.264 streams with CEA-608 CC embedded.  It's likely that the VDA bundled in Chromium-based browsers have already included EPB detection & prevention. If we let the player to remove the byte, VDA will complain about stream conformance.

Closes #3502
2021-09-09 09:44:45 -07:00
Theodore Abshire aded252e40 feat(offline): Make segment storage stateless.
This refactors the storage mechanism so that the method that
attaches a segment to the manifest is be a stateless async method,
and no longer needs to be in the same session as the method that
stored the manifest.
This is the end of phase one of the work towards allowing Shaka
Player to use background fetch to store assets offline.
This change will allow a service worker to store the segments as
they are downloaded, without having to keep the Shaka Player
instance alive.

Issue #879

Change-Id: I6a3545c57bacaf7229fe8c32669e88c6cc4e4138
2021-09-07 17:05:46 +00:00
Álvaro Velad Galván 233c2bf4d8 Fix: Add support to file type in mediaCapabilities implementation (#3570)
If it's srcEquals, the 'type' element of the input object when querying mediaCapabilities should be 'file'. Otherwise it should be 'media-source' .
Issue: #3530
2021-08-15 23:41:19 -07:00
Theodore Abshire 5215f5319f feat(offline): Changed store order of operations.
This changes the order that things happen when the offline storage
mechanism stores a manifest, so that the manifest is made and the
segments are downloaded in separate steps.
This is in preparation for adding background fetch support.

Issue #879

Change-Id: I4451db839b654f6134f06a58c240a9ca98d31a4e
2021-08-10 23:23:13 -07:00
Joey Parrish ed1563f70d fix: Fix multiperiod without consistent thumbnails
When playing multiperiod content, we should not require thumbnails to
be present in every period.  This fixes this case and adds a
regression test.

Closes #3383

Change-Id: I4403a1b8670cffcc46de32470e2d830dc199c9f4
2021-07-12 20:45:06 +00:00
Joey Parrish 4f4f6b1cf3 fix: Load image streams for offline multiperiod
When loading offline content, we should load the image streams as
well.

Issue #3383

Change-Id: I8cdd3d1ade188b7b2278a0eac5510a968229c6fc
2021-07-12 20:45:06 +00:00
Joey Parrish 42674bee03 fix: Fix filtering of duplicate image streams
We filter out duplicate streams for all other types, so we should do
this for images, as well.

This also updates all PeriodCombiner test cases to include the
imageStreams property.

Issue #3383

Change-Id: I63355f85d4e12bd25c1cadce29a040d17c4e7d61
2021-07-12 20:45:06 +00:00