Commit Graph

2706 Commits

Author SHA1 Message Date
Álvaro Velad Galván 19e12b5e28 feat(hls): make a head request if hls subtitles have no extension (#4140)
Closes https://github.com/shaka-project/shaka-player/issues/4135 
Closes https://github.com/shaka-project/shaka-player/issues/1959
2022-04-20 14:23:54 -07:00
Álvaro Velad Galván 42eecc84f9 feat(hls): parse EXT-X-GAP (#4134)
Parse EXT-X-GAP HLS tag and add a status enum to shaka.media.SegmentReference.

shaka.media.SegmentReference.Status.AVAILABLE --> Normal behaviour
shaka.media.SegmentReference.Status. UNAVAILABLE --> Related to https://github.com/shaka-project/shaka-player/issues/2541
shaka.media.SegmentReference.Status. MISSING --> EXT-X-GAP in HLS

Note: only the parsing is added, but the functionality is not yet implemented.

Issue https://github.com/shaka-project/shaka-player/issues/1308
2022-04-18 10:22:30 -07:00
Á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 ead344fe1f chore: Drop MS EME polyfill (#4123)
The MS EME polyfill has been unused since v3.1 and removal of IE support, and isn't needed for Edge or Xbox One support.

Closes #4113
2022-04-12 21:15:14 -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 169943f668 chore: remove mathround polyfill (used in IE) (#4114) 2022-04-11 13:15:04 -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
theodab 8a3bed710c feat(HLS): Re-add TS support to Safari (#4097)
It appears that the problems we previously had with TS content
on Safari have been fixed. We no longer need the workaround where
we transmuxed TS on that platform.
2022-04-01 20:32:12 -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 7ecbe05381 chore(HLS): Refactor unused bandwidth parameter (#4090) 2022-03-30 19:47:29 -07:00
Joey Parrish ca08230fbe fix: Fix exceptions when quickly shutting down src= on Safari (#4088)
Some events and timers were used to process track changes with src=
playback on Safari, but they did not properly clean up when the player
was unloaded or destroyed.  In the case that this happened quickly
after starting playback, exceptions would be thrown or tracks could
manipulated after new content began.

This fixes the cleanup of these timers and events to be aware of
Player unloads or destruction.

Closes #4087
2022-03-30 19:26:41 -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 400575498f fix(cmcd): Fix Symbol usage in CMCD on Xbox One (#4073)
Close #4072

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2022-03-29 16:04:26 -07:00
Joey Parrish 5c81f3bddb fix: Fix playRangeEnd for certain content (#4068)
For content where the manifest parser uses the notifySegments API
(DASH SegmentBase/SegmentList/SegmentTimeline, or HLS, but not DASH
SegmentTemplate+duration), the Player seekRangeEnd configuration was
not being honored correctly.

This fixes the issue in PresentationTimeline and adds a regression
test to our playRangeStart/playRangeEnds tests.

Fixed #4026
2022-03-29 10:57:37 -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 bdc5ea767e feat(DRM): add initData and initDataType to license requests (#4039)
Adds initData and initDataType field to all LICENSE-type requests.

Based on comments here: https://github.com/shaka-project/shaka-player/issues/4001#issuecomment-1050655197
2022-03-21 09:49:49 -07:00
Álvaro Velad Galván abe846e1a3 feat(DRM): add drmInfo to license requests (#4030)
Adds drmInfo field to all LICENSE-type requests.

Based on comments here: https://github.com/shaka-project/shaka-player/issues/4001#issuecomment-1050655197
2022-03-16 11:10:33 -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
Álvaro Velad Galván f2f24d528f fix(ttml): Center subtitles by default (#4023)
Closes: https://github.com/shaka-project/shaka-player/issues/4015
2022-03-10 13:11:50 -08:00
Joey Parrish 1507b1e844 chore: Update URLs after moving projects (#4008) 2022-03-03 14:34:40 -08:00
Álvaro Velad Galván 2687b95d58 fix(cea): make a more robust CEA MP4 parser (#3965)
Fix a HLS error reported in https://github.com/google/shaka-player/issues/2337#issuecomment-1040389975

Tested with https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_adv_example_hevc/master.m3u8
2022-02-24 13:27:18 -08:00
theodab c438e857f2 fix(hls): Fixed buffering issue with live HLS (#4002)
HLS now appends segments in sequence mode. In order to handle seeks,
we set the timestampOffset property on SourceBuffer to the startTime of
the segment. This is done after every seek, or on startup.

For non-sequence-mode content (DASH), we normally set timestampOffset
based on the Period structure.  This should be suppressed in sequence
mode, though, where only the reference startTime matters.

The buffering issue was caused by two things in combination:

1. The HLS parser set meaningless timestampOffset values that would
change when a playlist was updated
2. We would use those timestampOffset values in setStreamProperties,
even though this should be skipped in sequence mode

These two things in combination would lead MediaSourceEngine to start
inserting segments near the start of the presentation, rather than at
the live edge.

This changes MediaSourceEngine so that in sequence mode, timestampOffset
is ignored in setStreamProperties.  This also cleans up the HLS parser
to set each reference's timestampOffset to 0, since they should be
ignored anyway.
2022-02-24 11:43:30 -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 c482e81ad9 build: Update Closure Compiler (#3976)
This updates the compiler and closure library to the latest releases.
This required a few small tweaks:

 - Drop custom extern for WebCrypto (now built into the compiler)
 - Remove require() in cea parser, only used in `throws` annotations
 - Hack around a typing issue in a fake version of TextTrack in tests
2022-02-17 18:55:49 -08:00
wjywbs a6d8610241 fix: Select first of identical audio streams (#3869)
If a manifest lists 2 audio streams, select the first acceptable stream instead of the last one. For example below, previously the 2nd stream was selected, and now the first stream will be selected. Other players like roku, video.js and exoplayer select the first one.

```
#EXT-X-MEDIA:TYPE=AUDIO,URI="stream_1.m3u8",GROUP-ID="default-audio-group",NAME="128k",AUTOSELECT=YES,CHANNELS="2"
#EXT-X-MEDIA:TYPE=AUDIO,URI="stream_2.m3u8",GROUP-ID="default-audio-group",NAME="64k",CHANNELS="2"
(video streams snipped)
```
2022-02-17 13:59:08 -08:00
Joey Parrish b7f04cb36b fix: Fix memory leak in DASH live streams with inband EventStream (#3957)
EventStreams in DASH generate TimelineRegionInfo objects, which are
then stored in the RegionTimeline and RegionObserver classes.  But
DashParser would add all regions to RegionTimeline, even if they would
be quickly removed again, and RegionObserver would cache some regions
from the timeline without ever removing them.

This fixes the issue from both of those directions.  DashParser will
now ignore regions that are outside the DVR window (and therefore
would soon be removed from RegionTimeline), and RegionObserver listens
to an event on RegionTimeline to clean up its own storage when regions
fall outside the DVR window during playback.

Closes #3949 (memory leak in DASH live streams with inband EventStream)
2022-02-16 14:02:54 -08:00
theodab a4e926772e fix(text): Fix webvtt offset in sequence mode (#3955)
When running in sequence mode, we ignore the normal timestamps
of video and audio segments. This lead to problems in some Apple-
encoded webvtt content, which used the X-TIMESTAMP-MAP tag to account
for the timestamp offsets in their video. Thus, those subtitles would
end up 10 seconds offset.

This changes the webvtt parser to ignore the X-TIMESTAMP-MAP when in
sequence mode.

Issue #2337
2022-02-16 11:38:20 -08:00
Joey Parrish e49c849321 refactor: Replace callbacks with events (#3953)
Three classes (RegionTimeline, RegionObserver, and QualityObserver)
were all designed with callbacks instead of events.  A single callback
is inflexible compared to events, which allow multiple listeners.  We
already have a long-standing and robust event system, so why not use
it?

Issue #3949 (memory leak in DASH live streams with inband EventStream)
2022-02-15 17:23:40 -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
Joey Parrish e2ec5ebd52 ci: Add workflow for automated release PRs (#3942)
This includes a temporary config file to bootstrap the workflow for
the master branch, whose commit and branch history is too confusing
for the tool to handle with defaults.  After v3.4.0 is released from
the master branch, these configs can be deleted.
2022-02-11 16:25:44 -08:00
wjywbs ea6c02aece fix(HLS): skip whitespace in attributes (#3884)
Example:
`#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=1000000, RESOLUTION=1920x1080`

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2022-02-11 12:58:47 -08:00
Álvaro Velad Galván 36ca820877 fix: Fix download of some HLS assets (#3934)
Fix download of https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8

The filterManifestByMediaCapabilities method is async, but the code doesn't wait for it to finish before continuing the download process. This PR fix it.

This also fixes a hidden compiler issue caused by the use of an alias for StreamUtils.
2022-02-10 08:36:50 -08:00
Patrick Cruikshank 48433abe74 fix: Fix exception in StreamingEngine for EMSG with HLS (#3887)
Add null check for emsgSchemeIdUris when EMSG boxes are parsed, as this value is null for HLS streams

Fixes #3886
2022-02-09 12:38:08 -08:00
theodab b005a7c645 demo: Probe for containerless format support (#3931)
Issue #2337
2022-02-09 12:27:15 -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
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