Commit Graph

149 Commits

Author SHA1 Message Date
Álvaro Velad Galván 7439a264d6 fix(MCap): Remove robustness when robustness value is default (#4953)
Fixes https://github.com/shaka-project/shaka-player/issues/4659
2023-01-31 18:21:28 +01:00
YuChao Liang e351395c4a fix: Fix legacy codec support by rewriting codec metadata (#4858)
This fixes legacy codec support by rewriting the codec metadata in the
Stream objects. After capability checking, the converted codec
information will be used.

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2023-01-05 13:41:11 -08:00
theodab 806a9a81c4 fix: Manually order key for decodingInfo cache (#4795) 2022-12-07 11:39:11 -08:00
Zhenghang Chen ad6c08561d perf: Caching mediaSource support for browser engine (#4778)
Caches the results of MediaSource.isTypeSupported, which is slow on some platforms, to reduce the
number of calls needed. This is especially helpful on manifests with many similar variants (multiple languages, etc).
Data collected from 2 months of practical testing shows that this helps reduce the start lag by 40% on Chromecast, 15% on WebOS, and 12% on Tizen.
2022-12-05 19:47:13 -08:00
theodab b7781f0446 feat: Cache mediaCapabilities.decodingInfo results (#4789)
Issue #4775
2022-12-05 18:12:21 -08:00
Álvaro Velad Galván c3ff8e5e5f fix(HLS): Fix support legacy AVC1 codec used in HLS (#4716) 2022-11-18 16:33:06 -08:00
Dave Nicholas 884c4ca4f8 feat: Caching and other efficiency improvements for mcap polyfill (#4708)
This PR caches the result of `requestMediaKeySystemAccess` saving time
on subsequent calls.

It also makes the calls to `decodingInfo` synchronous. The reason for
this, is the result of testing on multiple devices that the behaviour of
`requestMediaKeySystemAccess` appears to be synchronous, making this
synchronous can save over a second on older TVs.

Closes #4574
2022-11-18 09:34:33 -08:00
Álvaro Velad Galván 8475214bc4 fix: Filter unsupported H.264 streams in Xbox (#4493) 2022-09-19 19:59:50 +02:00
Joey Parrish b6ab769762 fix: Fix VP9 codec checks on Mac Firefox (#4391)
Tests for VP9 codec checks were failing on Firefox on our M1 Mac.  This
addresses the issue by changing some default values that get used in a testing
environment, and another default value that is used in production.
2022-08-09 08:26:40 +02:00
Casey Occhialini 713f461c62 fix: Populate track's spatialAudio property (#4291)
Fixes issue #4290 where `spatialAudio` flag is not being set on variant tracks.

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>
2022-06-13 16:19:48 -07:00
Gaetan Hervouet b757a81902 fix: Fix PERIOD_FLATTENING_FAILED error when periods have different base sample types (#4206)
Closes #4202
2022-05-17 09:46:43 -07:00
Albert Daurell b57279d39c feat: Temporarily disable the active variant from NETWORK HTTP_ERROR (#4189)
When a `NETWORK HTTP_ERROR` is thrown, we'll temporarily disable the variant for `shaka.extern.Restrictions.maxDisabledTime` seconds (default will be 30 seconds).

Closes #4121
Closes #1542
2022-05-05 09:02:32 -07:00
Joey Parrish 1507b1e844 chore: Update URLs after moving projects (#4008) 2022-03-03 14:34:40 -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
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
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 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
Á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
Álvaro Velad Galván 0579ee7779 feat(CodecPreference): Improve preferredVideoCodecs & preferredAudioCodecs (#3424)
Currently a full chain comparison is done, but in video and audio codecs, you may want H.265/VP9 with no profile preference, with this change it is possible to do this.
Examples:
'hvc1' instead of 'hvc1.1.2.L123.80' and 'hvc1.1.2.L153.80'
'vp09' instead of 'vp09.00.40.08.00.02.02.02.00'
2021-05-26 10:38:26 -07:00
Michelle Zhuo 9709086e98 refactor(MediaCap): Remove MediaCapabilities config
Remove "useMediaCapabilities" configuration in the code base.

Issue #1391

Change-Id: I5fc74e31666840828e9dc04a5733db3eaed0d21a
2021-05-21 20:39:06 +00:00
Michelle Zhuo 9a706ef90e feat(CodecPreference): Add preferred codecs config
Adding the "preferredVideoCodecs" and "preferredAudioCodecs"
configuration, so that the application can set their own preferences
when choosing a codec.

Issue: #2179
Change-Id: Ib56aec10613dda9b7dce8e465c5f1d81540c34fd
2021-05-21 18:59:04 +00:00
Álvaro Velad Galván a096bc1452 fix:Filter unsupported H.264 streams in Xbox (#3411) 2021-05-17 14:01:11 -07:00
Michelle Zhuo 79d5fd8ca0 feat(MediaCap): Add preferredDecodingAttributes config
We'll allow users to configure the decoding attributes they prefer when
choosing codecs through the configuration. The attributes include
'smooth', 'powerEfficient' and 'bandwidth'.

For example, if the user configures the field as ['smooth',
'powerEfficient'], we'll filter the variants and keep the smooth ones
first, and if we have more than one available variants, we'll filter and
keep the power efficient variants.
After that, we choose the codecs with lowest bandwidth if we have
multiple codecs available.

Issue #1391

Change-Id: Ief3f6d8ff98fabff5ec99bb0365cdc6a36d2ab2d
2021-05-11 23:50:29 +00:00
Michelle Zhuo bf0644aa4a feat(MediaCap): Patch VP9 codec
MediaCapabilities supports 'vp09...' codecs, but not 'vp9'. Translate
vp9 codec strings into 'vp09...', to allow such content to play with
mediaCapabilities enabled.

Change-Id: Iff7ddae379efb8a9f0766c89a62b85a325f81e93
2021-04-29 20:27:09 +00:00
Michelle Zhuo 0f0c9409c3 feat(MediaCap): Skip filtering by DrmEngine with MediaCap enabled
When we use decodingInfo() with the drmInfo of the variants to get media
keys, the decodingInfo result can tell us whether the variant's DRM is
supported by the platform. Thus, filterManifestByDrm_() is no longer
needed with MediaCapabilities enabled.

Issue #1391
Closes #3334

Change-Id: I34fbb3e11877f02cae1d435e9dbf274ce0e691dc
2021-04-20 07:48:49 -07:00
Michelle Zhuo 2f65b97b79 feat(MediaCap): Use MediaCapabilities for offline storage
Issue #1391

Change-Id: Ifdf4477d3798ddacf77036f7d85d9cb29438becc
2021-04-07 19:50:51 +00:00
Michelle Zhuo b63a64e4ba feat(MediaCap): Use mediaKeySystemAccess from decodingInfo in DrmEngine
In DrmEngine, previously we created MediaKeySystemConfiguration for the
variants, and called navigator.requestMediaKeySystemAccess() to get the
mediaKeySystemAccess, and set up MediaKeys.

Now we can use the mediaKeySystemAccess from the decodingInfo results of
the variants directly to set up MediaKeys.

Issue #1391

Change-Id: Id93a5e2fed7f6827317ae11644967185fc0cffbd
2021-04-07 19:32:47 +00:00
Michelle Zhuo 198a6d42f6 feat(MediaCap): Guess the codecs of multiplexd stream for MediaCap
If we have a multiplexd stream with audio and video, the video
codecs are a combined string containing both audio and video codecs.
Before sending the request to decodingInfo(), we should check which
codec is audio and which one is video.

This is a follow-up of commit 966a756.

Issue #1391

Change-Id: Ic9b1c5972a99f63a715c74ae068b85f43efac447
2021-03-30 14:43:25 -07:00
Michelle Zhuo aca343bf2c feat(MediaCap): get mediaKeySystemAccess via decodingInfo
In StreamUtils, add a MediaCapabilitiesKeySystemConfiguration
for each key system for the encrypted variant passed to the
decodingInfo API, to get the mediaKeySystemAccess as a part of
the decodingInfo results.

We create a list of mediaDecodingConfigurations for each variant,
and call decodingInfo() with each mediaDecodingConfiguration to
get the mediaKeySystemAccess.

Eventually, we'll use the mediaKeySystemAccess from the
decodingInfo results to replace the call of
navigator.requestMediaKeySystemAccess() in DrmEngine. That will be
in the next CL.

Also, adding MediaCapabilties polyfill with mediaKeysSystemAccess.

Issue #1391

Change-Id: Ied4a27dd8a1ade43209bcf07f21f0c9b31c2693c
2021-03-30 20:26:46 +00:00
Michelle Zhuo 966a756578 feat(MediaCap): Support multiplex content with MediaCap
If we have a multiplexd content with audio and video, we combine
the audio and video codecs in the manifest parser.
For example, a multiplexed stream would be with:
mimeType="video/mp4", codecs="avc1.64001e,mp4a.40.2".

When sending the request to MediaCapabilities.decodingInfo(), we
need to have the config for both audio and video to get the result
as "supported".
The video config would be:
contentType='video/mp4, codecs="avc1.64001e"'.
The audio config would be:
contentType='audio/mp4, codecs="mp4a.40.2"'.

Issue #1391

Change-Id: I74a8580c07228e9600dc40c611ebd5d34f8cd7ee
2021-03-23 23:43:01 +00:00
Michelle Zhuo acfa1a800c feat(MediaCap): get decodingInfo results before queryMediaKeys
Previously, we fill in the variants' drmInfos with the drm
configurations of |clearKeys|, |servers| and |advanced| during
initializing the DrmEngine, before we query the media keys.

Now we need to call |MediaCapabilities.decodingInfo()| to get the
mediaKeySystemAccess of the variants after the DrmEngine is
created and configured, and the drm values are filled in for the
variants, and before |DrmEngine.queryMediaKey_()|.

The steps would be:
0. StreamUtils.setDecodingInfo() should not be called before
   DrmEngine is initialized and configured.
1. Create and configure DrmEngine.
2. Fill in drm values for the variants with configurations.
3. Call StreamUtils.setDecodingInfo() to get the decodingInfo of
   the variants.
4. Use the decodingInfo results to set up the Drm mediaKeys in
   DrmEngine.
5. When StreamUtils.filterManifest() is called, we can reuse the
   decodingInfo results instead of calling decodingInfo again.

Previously we call filterManifest() when parsing the manifest, to
filter out the unsupported streams.
Now decodingInfo can tell us if a variant is supported and its
MediaKeys at once. When initializing the DrmEngine, we get the
decodingInfo results of the variants, and only use the supported
streams to set up the MediaKeys. After that, we filter the manifest
right after DrmEngine is initialized.
Thus, we can skip filterManifest() in manifest parsers.

Using decodingInfo to get media keys will be in the next CL.

Issue #1391

Change-Id: Ieb401a1e4dfbcc958f7a14fa96df546237b0f446
2021-03-23 23:41:51 +00:00
Michelle Zhuo 8d4fbf691e fix(MediaCap): Default video width and height to 1
When querying MediaCapabilities.decodingInfo(), if the video width
or height is not present, set 1 as default. Linux Firefox would
claim the variant is unsupported via decodingInfo() if the values
are falsy.

Issue #1391

Change-Id: Idc27e6869a1276585a0ca35bd380e1b7ad1db242
2021-03-18 22:28:11 +00:00
Álvaro Velad Galván b84f7742c0 feat(MediaCap): Check spatialRendering against MediaCapabilities (#3224) 2021-03-15 09:08:16 -07:00
Michelle Zhuo f4c6063b82 feat(MediaCap): Add polyfill for MediaCapabilities
If navigator.mediaCapabilties is not supported by the browser, use
MediaSource.isTypeSupported to check if the stream is supported.

Issue #1391

Change-Id: Iee0c7e339add2a07028ed14a03df14e4d36a203e
2021-03-12 13:44:53 -08:00
Michelle Zhuo 57ee23812e feat(MediaCap): Use MediaCapabilities for supporting info
In StreamUtils, use MediaCapabilities.decodingInfo() instead of
MediaSource.isTypeSupported() to check if the stream is supported.

MediaCapabilities.decodingInfo() takes an
MediaDecodingConfiguration object as input, and returns a Promise
with a MediaCapabilitiesInfo object. The returned object tells us
whether decoding the media is supported, smooth, and
powerefficient.

Steps:
1. Create a MediaDecodingConfiguration object for each variant as
   the input.
2. Query the decodingInfo API with the config.
3. Get the 'supported' info from the decodingInfo result, to know
   whether the variant is supported.

Issue #1391

Change-Id: I8fc2d3ec6a9868f38269d550d35f45c298faae98
2021-03-12 21:41:53 +00:00
Álvaro Velad Galván b9b3cc8098 feat(dash): Add support for thumbnail tracks (#3145) 2021-03-02 13:36:09 -08:00
Denis Seleznev b75cd4c38d fix: Fix codec choice when resolutions differ (#3072)
Before this change, our codec choice only worked when all codecs had the same resolutions available.

When one codec had a different set of resolutions available, we might end up choosing the wrong one.  This is because our choice was based on the average bandwidth of all resolutions for that codec.  So a "better" codec with higher resolutions available would also end up having a higher average bitrate, and would be avoided.

This fixes the issue by only considering the resolutions that all codecs have in common, then taking the average bitrate among those to choose a codec.
2021-02-24 10:43:48 -08:00
Álvaro Velad Galván f067ae10ac Parse spatial audio from manifest (#3148) 2021-02-24 09:28:33 -08:00
Michelle Zhuo 6bfd5aa59c refactor(MediaCap): avoid duplicate calls to filterManifest
StreamUtils.filterManifest() filters the manifest with four steps:
1. Filter out the variants unsupported by the platform
2. Filter out the variants unsupported by DRM
3. Filter out the variants uncompatible with the current variant
4. Filter out unsupported text streams.

We re-filter the manifest after the streams are chosen, and we only
need to filter out the variants uncompatible with the current
variant. Skip step 1,2,4 in StreamUtils.filterManifest(), to
avoid duplicate calls to MediaCapabilities.decodingInfo().

Issue #1391

Change-Id: Ia792f94d4ac3d93267741ef63db0872f30189fda
2021-02-10 10:20:47 -08:00
Michelle Zhuo df05d8e8a3 refactor(MediaCap): break down StreamUtils.filterManifest
Breaking the StreamUtils.filterManifest() function into four steps.

Issue #1391

Change-Id: I3badc3662bad12375e38f563af1a78437c23a737
2021-02-09 18:34:47 +00:00
Michelle Zhuo 5bb8c1cab0 feat(MediaCap): make StreamUtils.filterManifest async
Player.filterManifest() does two things:
1. Filter the manifest with Drm, codecs and currentVariant's
   compatibility in StreamUtil.
2. Filter the manifest with PlayerConfiguration.restrictions.

In applyConfig_(), only the restrictions config affects filtering
the manifests. We don't need to call StreamUtils.filterManifest().

2. Make the filterManifest function async.

Issue #1391

Change-Id: I2fba9cabb3f3a3e89f5d990c4eeb19cc74924de9
2021-02-05 14:20:14 -08:00
Álvaro Velad Galván 71372869de feat: Extract HDR metadata from HLS manifests (#3116)
In our isTypeSupported polyfill for Cast, we use the HEVC profile ("hevc1.2") as
an indication of the HDR transfer function, which is not always accurate.
The polyfill should stop assuming that 10-bit color HEVC means HDR, and remove
the extra eotf="smpte2084" parameter. Instead, the manifest parser should
extract HDR profile information from the DASH manifest and pass that info along
through the Stream object.

Issue #3116 .
2021-01-31 23:36:57 -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
Á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 01998f3b99 Parse forced subtitles from manifest (#2938)
Issue #2122
Issue #2916
2020-10-27 14:00:48 -07:00
Theodore Abshire 98df64c1af Feat(player): Add label to LanguageRole externs
Closes #2904

Change-Id: I96dffaf377f856db9a14d9784d3bbbbb08c297b8
2020-10-14 20:30:10 +00:00