Commit Graph

152 Commits

Author SHA1 Message Date
Á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
theodab 48dd20562c fix(hls): Support playing media playlists directly (#4080)
Closes #3536
2022-03-30 17:27:50 -07:00
Joey Parrish 1507b1e844 chore: Update URLs after moving projects (#4008) 2022-03-03 14:34:40 -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
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
Jacob Trimble f16e0265d8 docs: Update PlayReady error links
This site has an easy search function for all Microsoft error codes,
which is better than the two other links.

Change-Id: I4a2d67e3412c43200e38b7abf3086b6b14de778b
2021-06-01 20:41:16 +00:00
Vincent Valot 9b4502cc5d feat: add serverCertificateUri in DRM advanced config (#3358)
Fixes #1906
2021-05-03 10:53:31 -07:00
Michelle Zhuo 95ba28b5af refactor: Remove IE 11 support
Issue #2339

Change-Id: I80ffa7b04f7afd943aa0f881d2a494dd35def732
2021-04-29 17:47:07 +00:00
Suraj kumar (sk) 77140991f1 fix(hls): Assume MP4 if MIME type can't be deduced (#3325)
Fixes #3142
2021-04-13 13:56:02 -07:00
Álvaro Velad Galván 54b8f6eaee feat: Add downloadSizeCallback before storing offline (#3049)
When downloading content for storage, it's useful to know how much storage space
will be needed before storing. This is extremely important for mobile devices
that have limited space. See google/shaka-player-embedded#167.

Use the info in the manifest and make HEAD requests to determine the
size of the content we're downloading.

Add a downloadSizeCallback that will be called with the size once we know it.
The callback determine if the content can be downloaded due to its estimated
size.

Closes #3049 .
2021-02-01 11:45:19 -08:00
Joey Parrish d0da2d49e1 fix: Fix mixed clear/encrypted content on Xbox & Tizen
Some platforms seem to ignore EME if the first init segment appended
at the MSE level does not indicate encryption.  To work around this,
we will detect such platforms, and if EME is set up, we will insert
fake encryption metadata into the init segment to convince the
platform to be ready to decrypt.

Closes #2759

Change-Id: Iccf6b8589cf9265ac9bef0d083f4a72f6f2dd628
2021-01-21 18:10:02 +00: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
Á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
Á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
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
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 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
Joey Parrish aba5e2583c Rename v2.6 to v3.0 and v2.7 to v3.1
We have decided to bump the major version number instead of the minor
number, based primarily on the fact that this release breaks
compatibility with our previous manifest structure.

Change-Id: I67e4c8267c6e103cfc7278e09daac186ae5cbbc6
2020-05-29 17:50:22 +00:00
Álvaro Velad Galván e246855c63 Add variable substitution support to HLS parser (#2509)
Resolves #1561
2020-04-24 12:37:11 -07:00
Theodore Abshire a2a988d876 Allow for multiple concurrent storage operations.
In the process, this removes the in-progress flag, which should fix
issues where the storage instance can't be re-used after an error.

Closes #1432
Closes #2432

Change-Id: I51018e170fb9ab262b5c70125a03d979c8ccfb08
2020-04-10 04:33:11 +00:00
Joey Parrish e24fec4b08 Flatten periods
This creates a new utility used by DashParser and old offline DB
formats to combine Streams across Periods.  This allows multi-Period
DASH content to be played without period-specific structures in the
manifest format, StreamingEngine, or Player.  This also makes the
Tracks stable across Periods.

Closes #1339 (flatten periods)
Closes #1698 (rapid period transitions issue)
Closes #856 (audio change causes bitrate change)

Change-Id: Icb04c8e47e36eacf7ac024a5063130d85a115e54
2020-04-09 19:22:16 +00:00
Joey Parrish 99de217c23 Remove periods from manifest structure
This removes periods from the internal manifest structure and cleans
up code and tests accordingly.  This leaves us unable to play
multi-period DASH & offline streams until the main period-flattening
algorithm is completed in shaka.util.Periods.

Three test cases have been disabled for the moment.

Multi-period playback will be restored in a smaller, more focused
follow-up commit, with disabled tests re-enabled.

Issue #1339 (flatten periods)
Issue #1698 (rapid period transitions issue)
Issue #856 (audio change causes bitrate change)
Closes #892 (refactor StreamingEngine)

Change-Id: I0cbf3b56bfdb51add15229df323b902f0b2e643a
2020-04-09 19:22:16 +00:00
Sandra Lokshina f4a2b858d7 Refactor player out of SS ad manager.
Issue #2367

This also accidently fixes showing seek bar on ad end for
SS content.

Change-Id: I52241df9861f27d50976f0ce7309c7c14092463a
2020-03-26 17:13:26 +00:00
Álvaro Velad Galván 697a6ff785 Add initial DAI support (#2382)
This PR ads initial logic to enable support for IMA DAI streams.
Ad-containing streams can now be requested from the IMA stream manager and played.

Integration with the ad UI will follow in a separate CL.
2020-02-18 14:11:51 -08:00
Jacob Trimble 59b47651ca Add some documentation/links for Error.
This adds some links to where users can find error codes for some of
the browser errors that can happen.

Change-Id: I8ce94307159afb2df9e06813b07593920dcbac1e
2020-02-13 21:59:23 +00:00
Álvaro Velad Galván 32e81c0e79 IMA: disambig between CS and DAI (#2375)
IMA has two separate SDKs for CS and SS ad insertion.
This PR makes sure people don't try to init CS ads when they only have SS SDK
included.
2020-02-06 10:40:35 -08:00
Joey Parrish 1ee32849e4 Fix skipping of raw format streams in HLS
Raw, containerless streams can't be played yet (#2337), but our logic
for skipping or rejecting them was broken.  This broken logic affected
the whole v2.5.x series of releases up to and including v2.5.8.

This fixes the logic and improves it in several ways:
 - Skip streams that can't be played, instead of rejecting the whole
   master playlist
 - Handle raw AC3 and EC3, in addition to MP3 and AAC
 - Handle and skip WebM+HLS in the same way
 - Add the playlist and segment URLs to
   HLS_COULD_NOT_PARSE_SEGMENT_START_TIME errors

This allows us to re-enable the Apple HLS+TS asset as video-only.

Change-Id: Ia00857d87b085aa7e2b810b0b949993cebabe4ba
2020-01-17 12:28:08 -08:00
Joey Parrish 64896d70b0 Use shorter license header
This reflects changes in Google's policy on JavaScript license
headers, which should be smaller to avoid increasing the size of the
binary unnecessarily.

This also updates the company name from "Google, Inc" to "Google LLC".

Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
2019-11-22 18:18:36 +00:00
Jacob Trimble c56fe7db19 Fix and cleanup offline without init data.
The PR to add support for pulling EME init data from the segments was
incorrect and had some bugs.  This stops re-initializing DrmEngine since
this isn't needed and could cause problems with the offline licenses.
This also just uses the Pssh helper once to parse and extract the
init data.  Lastly this throws the old error if we don't have any
sessions when we are done;  if we try to store WebM content, we should
still throw if there is no init data in the manifest.

Issue #1531

Change-Id: Ie524abda993a076397e233008709f11a2e68a8f8
2019-11-05 23:33:54 +00:00
Sandra Lokshina 7da5dc91b7 Add ad related errors.
Change-Id: I45ada9c983798a136f4e04caaac91e9d149f6a84
2019-10-18 13:27:14 -07:00
Shaka Player BuildBot 3f712c2652 Merge remote-tracking branch 'github/master' 2019-10-17 14:54:24 -07:00
Theodore Abshire db9a0eebec Throw if ttml parsing outputs <parsererror>.
Previously, if no XML was produced, or if it failed to have a <tt> element,
we assumed that parsing had failed. This caught some failures, but not
every possible failure; there are some partial failures that still return
valid XML. These sorts of errors are signaled by the output containing a
<parsererror> tag; this CL makes us also return an error in this case.
It also corrects the documentation for XML parsing errors, which was
incorrect; it seems that we had been confusing INVALID_XML and
DASH_INVALID_XML for documentation.

Issue #2157

Change-Id: I79716c9d2ff90ed9672eef8e54dd4019d8ca109b
2019-10-17 21:53:58 +00:00
Álvaro Velad Galván 5eaca0aebd Offline license support for manifests without inline init data (#2164)
Closes #1531
2019-10-17 14:53:34 -07:00
Jacob Trimble c5b9d6804f Allow custom content ID in FairPlay.
Now there is a generic callback to transform the init data before
passing it to the browser.  This can be used by apps to use a custom
content ID in FairPlay content.  This also adds some utilities to help
in writing these functions and moves the default behavior to DrmEngine.

Closes #1951

Change-Id: I78ce660c126b53a69d5f55b16775ffcdbbe4d748
2019-08-07 18:38:40 +00:00
Jacob Trimble 5c580e243e Throw an error when FairPlay cert not set.
Fixes #1940

Change-Id: If911986eb70838b1aa81fc85f088c8367f7e1b48
2019-07-29 21:02:21 +00:00
Sandra Lokshina 5aefcc7fc1 Clear up the fix for enabling Chromecast.
Change-Id: Ib39f1d7a73890e5174724f05cb0d2ba465a470e6
2019-07-17 19:58:20 +00:00
Jacob Trimble f6d0f15fa6 Refactor handling of destroy().
This changes several classes to use the Destroyer class to handle
destroy().  This also changes the behavior to not ignore destruction
and instead throw a new error.  This is more clear for callers and
ensures we propagate errors.

Change-Id: I756c085639558509c22e5c43d69ddf4acd28d46f
2019-06-19 20:39:20 +00:00
Sandra Lokshina 3e3e940e34 Add a temporary fix to enable casting.
Issue #1948

Change-Id: Id3953cdc32f1cdd02729c1a3f08c522b2ee376f1
2019-06-03 21:05:36 +00:00
Joey Parrish 615ce93178 Fix formatting of test failures/errors
Code in karma-jasmine's adapter will malform test failures when the
expectation message contains a stack trace, losing the failure message
and mixing up the stack trace of the failure.  To avoid this, we
modify shaka.util.Error not to create a stack trace.  This trace is
not available in production, and there is never any need for it in the
tests.

One test expectation had to be updated.  The previous version of
jasmineError would use the original error by reference.  Now that it's
capturing a few fields explicitly, the severity value doesn't update
when NetworkingEngine modifies the original.

Change-Id: If7af93a1a0357df9763dbf6a4afc45db2c8317df
2019-05-31 21:29:27 +00:00
Sandra Lokshina 0e7c366e9d Convert more utils to es6.
Issue #1157.

Change-Id: I49092237b7fe7f98a22087b0ecf41f65005dbc61
2019-05-28 22:17:48 +00:00
Jacob Trimble ded2b84313 Require consistent return values.
This enables the eslint rule that requires all functions to consistently
either return a value or not return a value.

Change-Id: I98b579f3689c3b6c74968116824231bb792bd9dd
2019-05-09 20:34:47 +00:00
Jacob Trimble c81389741f Prefer const over let.
A coming update to the Google eslint config will require using "const"
over "let".  This makes that one change to isolate the big changes.

Change-Id: I7d0974c3ae15c53cc45a6b07bf9f6586e2d34aca
2019-05-08 09:22:10 -07:00
Joey Parrish d27d8180e0 Only use configured license servers if provided
If the application developer specifies license servers, only those
should be used.  Before this, a manifest-specified license server
for a certain key system could still be used if the application didn't
provide one.

Now, if there are _any_ license servers specified by the app, _no_
license servers will be used from the manifest.  This is important
because it allows the application a clear way to indicate which DRM
systems should be used on platforms with multiple DRM systems.

The new order of preference for drmInfo:
1. Clear Key config, used for debugging, should override everything else.
   (The application can still specify a clearkey license server.)
2. Application-configured servers, if any are present, should override
   anything from the manifest.  Nuance: if key system A is in the manifest
   and key system B is in the player config, only B will be used, not A.
3. Manifest-provided license servers are only used if nothing else is
   specified.

Introduced in #1644 to solve #484
Internal issue b/131264101
Closes #1905

Change-Id: I1a36a70044dc7bcc22681e3e4246d0a43d58e413
2019-05-02 20:30:54 +00:00
Michelle Zhuo cb9decbb5f Reject AES-128 HLS content with meaningful error
Currently we check encrypt key tags after we parse the segment, so
playing an AES-128 encrypted content results in error message
'MANIFEST.HLS_COULD_NOT_PARSE_SEGMENT_START_TIME'. We should check the
encrypt key before, and give a more clear error message.
Filtering out the contents encrypted with AES-128, and if there's no
valid content left, we'll show 'CONTENT_UNSUPPORTED_BY_BROWSER'.

Closes #1838

Change-Id: I893f57a939e45f2787144dfe311b779aed26ac34
2019-04-22 18:48:18 +00:00
Jacob Trimble 76f78187b6 Add extended error code for failed license request
Issue #1689

Change-Id: I7d3b4eee487395fdb8c121a4b6acc11ec461f0e3
2018-11-28 23:27:51 +00:00
Jacob Trimble 9b885bac06 Give extra data for RESTRICTIONS_CANNOT_BE_MET.
Fixes #1368

Change-Id: I14563d309251c3ecd146fe6a467f30f637e4e6fc
2018-08-07 22:49:31 +00:00
Aaron Vaage 952c9b8341 Reject Promise In Player With Error
When reading through shaka.Player I found a promise that was being
rejected without an error. This change removes the log call and
rejects the promise with an error object.

Change-Id: I7072e2bb1ec367750ebb2dce31edff4e9c9e857b
2018-07-24 17:31:31 +00:00
Jacob Trimble 061aea1828 Add another entry for RESTRICTIONS_CANNOT_BE_MET.
Change-Id: I8bccecaa88c81581db524a6351c34a7a4750bfbe
2018-07-23 11:55:21 -07:00