Commit Graph

137 Commits

Author SHA1 Message Date
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
Muhammad Haris 54ff2d8f28 feat(cea): CEA-708 Decoder (#2807)
This pertains to #2648 (although this is a new feature, not a replacement) and #1404. A CEA-708 decoder that follows the CEA-708-E standard, decodes closed caption data from User Data Registered by Rec. ITU-T T.35 SEI messages, and returns them as cues in Shaka's internal cue format. Furthermore, this pull request fixes and cements some of the logic surrounding CEA-608 and CEA-708 tag parsing on the Dash Manifest Parser.

Format:
Similar to the CEA-608 decoder, cues are emitted in Shaka's internal format (lib/text/cue.js). This decoder makes use of nested cues. The top level cue is always a blank cue with no text, and each nested cue inside it contains text, as well as a specific style, or linebreak cues to facilitate line breaks. This also allows for inline style (color, italics, underline) changes.

Details:
- ASCII (G0), Latin-1 (G1), and CEA-708 specific charsets (G2 and G3) all supported.
- Underlines, colors, and Italics supported, set as a property on each nested cue.
- Positioning of text is supported. (Exception: In CEA-708 the default positioning is left, in this decoder it is centered.)
- Positioning of windows not supported, but relevant fields that could be used to support this are extracted and left as a TODO.
2020-09-10 13:06:07 -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
Álvaro Velad Galván 46c8ed49bc Add roles in text and audio tracks (src mode) using the kind parameter (#2543) 2020-05-01 10:42:48 -07:00
Joey Parrish 0911a6b3d0 Fix bad reference to frameRate on Variant
This is only defined on Stream, not Variant.  This bug has was
introduced in PR #2332 and the v2.5.8 release and affects v2.5.8 -
v2.5.10.  The corresponding feature (frameRate restrictions) has
actually never worked.

This was caught by a compiler upgrade which is still in progress.

Change-Id: I0409d9be8d3f6eb0794775ca29f28b98208bab4f
2020-04-27 18:05:02 +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
Theodore Abshire ae568e0649 Fix offline picking high-bandwidth codecs.
When playing an asset, the player will first choose a codec, based
on the lowest average bandwidth.
However, the storage mechanism did not have any such filtering;
instead, all it did (if using the default track filtering plugin) was
pick the middle-bandwidth audio track. This lead to it sometimes making
different codec decisions than the player would have.
This CL breaks the codec filtering logic out into a helper function, and
calls it both for playback and storage.

It also adds headers comments to some functions in the demo page.

Closes #2390

Change-Id: I09f1a24753121afd0e7500577c0f64ccffe5a4d1
2020-04-02 22:46:10 +00:00
Joey Parrish 9427c788c6 Drop pixelAspectRatio from MIME type
This is not a supported query parameter on the Chromecast.

Change-Id: Ia370d046669b61a223c0f36518d7b3df0ebfa6ea
2020-01-15 09:54:20 -08:00
Álvaro Velad Galván 6e8ab0132f Add framerate restriction to the config (#2332)
Closes #2068
2020-01-08 11:33:58 -08:00
Álvaro Velad Galván bdca05ff4b Add pixelAspectRatio property from DASH (#2294) 2020-01-06 10:56:28 -08:00
Álvaro Velad Galván 02fa8c6876 Add audioSamplingRate property (#2290) 2019-12-10 18:00:16 -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 5c35108cb8 Avoid integer for loops.
Issue #1518

Change-Id: I3ba3cb6a439264e823022b2a64e7cdbd265494c7
2019-07-09 17:11:49 +00:00