shaka-player 4.8.2 → 4.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,6 +22,7 @@ goog.require('shaka.util.Id3Utils');
22
22
  goog.require('shaka.util.ManifestParserUtils');
23
23
  goog.require('shaka.util.MimeUtils');
24
24
  goog.require('shaka.util.Mp4Generator');
25
+ goog.require('shaka.util.StreamUtils');
25
26
  goog.require('shaka.util.TsParser');
26
27
  goog.require('shaka.util.Uint8ArrayUtils');
27
28
 
@@ -149,7 +150,7 @@ shaka.transmuxer.TsTransmuxer = class {
149
150
  // MediaSource.isTypeSupported('audio/mp4; codecs="mp3"') -> true
150
151
  const codecs = shaka.util.MimeUtils.getCodecs(mimeType)
151
152
  .replace('mp4a.40.34', 'mp3').split(',')
152
- .map(this.getCorrectVideoCodecs_).join(',');
153
+ .map(shaka.util.StreamUtils.getCorrectVideoCodecs).join(',');
153
154
  if (contentType == ContentType.AUDIO) {
154
155
  return `audio/mp4; codecs="${codecs}"`;
155
156
  }
@@ -159,29 +160,6 @@ shaka.transmuxer.TsTransmuxer = class {
159
160
  }
160
161
 
161
162
 
162
- /**
163
- * @param {string} codec
164
- * @return {string}
165
- * @private
166
- */
167
- getCorrectVideoCodecs_(codec) {
168
- if (codec.includes('avc1')) {
169
- // Convert avc1 codec string from RFC-4281 to RFC-6381 for
170
- // MediaSource.isTypeSupported
171
- // Example, convert avc1.66.30 to avc1.42001e (0x42 == 66 and 0x1e == 30)
172
- const avcdata = codec.split('.');
173
- if (avcdata.length == 3) {
174
- let result = avcdata.shift() + '.';
175
- result += parseInt(avcdata.shift(), 10).toString(16);
176
- result +=
177
- ('000' + parseInt(avcdata.shift(), 10).toString(16)).slice(-4);
178
- return result;
179
- }
180
- }
181
- return codec;
182
- }
183
-
184
-
185
163
  /**
186
164
  * @override
187
165
  * @export
@@ -197,6 +197,17 @@ shaka.util.Platform = class {
197
197
  return Platform.isChromecast() && Platform.isAndroid();
198
198
  }
199
199
 
200
+ /**
201
+ * Check if the current platform is a Google Chromecast with Android
202
+ * (i.e. Chromecast with GoogleTV).
203
+ *
204
+ * @return {boolean}
205
+ */
206
+ static isFuchsiaCastDevice() {
207
+ const Platform = shaka.util.Platform;
208
+ return Platform.isChromecast() && Platform.isFuchsia();
209
+ }
210
+
200
211
  /**
201
212
  * Returns a major version number for Chrome, or Chromium-based browsers.
202
213
  *
@@ -459,6 +470,15 @@ shaka.util.Platform = class {
459
470
  return shaka.util.Platform.userAgentContains_('Android');
460
471
  }
461
472
 
473
+ /**
474
+ * Return true if the platform is a Fuchsia, regardless of the browser.
475
+ *
476
+ * @return {boolean}
477
+ */
478
+ static isFuchsia() {
479
+ return shaka.util.Platform.userAgentContains_('Fuchsia');
480
+ }
481
+
462
482
  /**
463
483
  * Return true if the platform is controlled by a remote control.
464
484
  *
@@ -611,19 +631,32 @@ shaka.util.Platform = class {
611
631
 
612
632
  if (Platform.isChromecast()) {
613
633
  // In our tests, the original Chromecast seems to have trouble decoding
614
- // above 1080p. It would be a waste to select a higher res anyway, given
634
+ // above 1080p. It would be a waste to select a higher res anyway, given
615
635
  // that the device only outputs 1080p to begin with.
616
636
  // Chromecast has an extension to query the device/display's resolution.
617
- if (window.cast && cast.__platform__ &&
618
- cast.__platform__.canDisplayType && cast.__platform__.canDisplayType(
619
- 'video/mp4; codecs="avc1.640028"; width=3840; height=2160')) {
620
- // The device and display can both do 4k. Assume a 4k limit.
621
- maxResolution.width = 3840;
622
- maxResolution.height = 2160;
623
- } else {
624
- // Chromecast has always been able to do 1080p. Assume a 1080p limit.
625
- maxResolution.width = 1920;
626
- maxResolution.height = 1080;
637
+ const hasCanDisplayType = window.cast && cast.__platform__ &&
638
+ cast.__platform__.canDisplayType;
639
+
640
+ // Some hub devices can only do 720p. Default to that.
641
+ maxResolution.width = 1280;
642
+ maxResolution.height = 720;
643
+
644
+ try {
645
+ if (hasCanDisplayType && await cast.__platform__.canDisplayType(
646
+ 'video/mp4; codecs="avc1.640028"; width=3840; height=2160')) {
647
+ // The device and display can both do 4k. Assume a 4k limit.
648
+ maxResolution.width = 3840;
649
+ maxResolution.height = 2160;
650
+ } else if (hasCanDisplayType && await cast.__platform__.canDisplayType(
651
+ 'video/mp4; codecs="avc1.640028"; width=1920; height=1080')) {
652
+ // Most Chromecasts can do 1080p.
653
+ maxResolution.width = 1920;
654
+ maxResolution.height = 1080;
655
+ }
656
+ } catch (error) {
657
+ // This shouldn't generally happen. Log the error.
658
+ shaka.log.alwaysError('Failed to check canDisplayType:', error);
659
+ // Now ignore the error and let the 720p default stand.
627
660
  }
628
661
  } else if (Platform.isTizen()) {
629
662
  maxResolution.width = 1920;
@@ -684,8 +717,8 @@ shaka.util.Platform = class {
684
717
  /** @type {{screenWidth: number, screenHeight: number}} */(
685
718
  JSON.parse(window.PalmSystem.deviceInfo));
686
719
  // WebOS has always been able to do 1080p. Assume a 1080p limit.
687
- maxResolution.width = Math.max(1920, deviceInfo.screenWidth);
688
- maxResolution.height = Math.max(1080, deviceInfo.screenHeight);
720
+ maxResolution.width = Math.max(1920, deviceInfo['screenWidth']);
721
+ maxResolution.height = Math.max(1080, deviceInfo['screenHeight']);
689
722
  } catch (e) {
690
723
  shaka.log.alwaysWarn('WebOS: Error detecting screen size, default ' +
691
724
  'screen size 1920x1080.');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shaka-player",
3
3
  "description": "DASH/EME video player library",
4
- "version": "4.8.2",
4
+ "version": "4.8.4",
5
5
  "homepage": "https://github.com/shaka-project/shaka-player",
6
6
  "author": "Google",
7
7
  "maintainers": [
@@ -63,6 +63,11 @@
63
63
  "tippy.js": "^4.3.5",
64
64
  "which": "^2.0.2"
65
65
  },
66
+ "overrides": {
67
+ "karma": {
68
+ "ua-parser-js": "github:joeyparrish/ua-parser-js#preview"
69
+ }
70
+ },
66
71
  "shakaCustom": {
67
72
  "purposeOfDemoDeps": "These are the files from node_modules that need to be deployed with the demo app.",
68
73
  "demoDeps": [