shaka-player 4.0.1 → 4.0.2

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.
@@ -219,8 +219,9 @@ shaka.abr.SimpleAbrManager = class {
219
219
  * @export
220
220
  */
221
221
  getBandwidthEstimate() {
222
+ const defaultBandwidthEstimate = this.getDefaultBandwidth_();
222
223
  return this.bandwidthEstimator_.getBandwidthEstimate(
223
- this.config_.defaultBandwidthEstimate);
224
+ defaultBandwidthEstimate);
224
225
  }
225
226
 
226
227
 
@@ -1892,9 +1892,20 @@ shaka.hls.HlsParser = class {
1892
1892
  const pPreviousReference = i == 0 ?
1893
1893
  previousReference : partialSegmentRefs[partialSegmentRefs.length - 1];
1894
1894
  const pStartTime = (i == 0) ? startTime : pPreviousReference.endTime;
1895
- const pDuration = Number(item.getAttributeValue('DURATION'));
1896
- // A preload hinted partial segment doesn't have duration information,
1897
- // so its startTime and endTime are the same.
1895
+
1896
+ // If DURATION is missing from this partial segment, use the target
1897
+ // partial duration from the top of the playlist, which is a required
1898
+ // attribute for content with partial segments.
1899
+ const pDuration = Number(item.getAttributeValue('DURATION')) ||
1900
+ this.partialTargetDuration_;
1901
+
1902
+ // If for some reason we have neither an explicit duration, nor a target
1903
+ // partial duration, we should SKIP this partial segment to avoid
1904
+ // duplicating content in the presentation timeline.
1905
+ if (!pDuration) {
1906
+ continue;
1907
+ }
1908
+
1898
1909
  const pEndTime = pStartTime + pDuration;
1899
1910
 
1900
1911
  let pStartByte = 0;
@@ -1424,6 +1424,9 @@ shaka.media.DrmEngine = class {
1424
1424
  }
1425
1425
  return;
1426
1426
  }
1427
+ if (this.destroyer_.destroyed()) {
1428
+ return;
1429
+ }
1427
1430
 
1428
1431
  const updateEvent = new shaka.util.FakeEvent('drmsessionupdate');
1429
1432
  this.playerInterface_.onEvent(updateEvent);
package/lib/player.js CHANGED
@@ -6450,7 +6450,7 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
6450
6450
  * @define {string} A version number taken from git at compile time.
6451
6451
  * @export
6452
6452
  */
6453
- shaka.Player.version = 'v4.0.1-uncompiled';
6453
+ shaka.Player.version = 'v4.0.2-uncompiled';
6454
6454
 
6455
6455
  // Initialize the deprecation system using the version string we just set
6456
6456
  // on the player.
@@ -8,6 +8,7 @@ goog.provide('shaka.util.MimeUtils');
8
8
 
9
9
  goog.require('shaka.dependencies');
10
10
  goog.require('shaka.media.Transmuxer');
11
+ goog.require('shaka.util.ManifestParserUtils');
11
12
 
12
13
  /**
13
14
  * @summary A set of utility functions for dealing with MIME types.
@@ -34,6 +35,8 @@ shaka.util.MimeUtils = class {
34
35
  /**
35
36
  * Takes a MIME type and a codecs string and produces the full MIME
36
37
  * type. If it's a transport stream, convert its codecs to MP4 codecs.
38
+ * Otherwise for multiplexed content, convert the video MIME types to
39
+ * their audio equivalents if the content type is audio.
37
40
  *
38
41
  * @param {string} mimeType
39
42
  * @param {string} codecs
@@ -42,13 +45,19 @@ shaka.util.MimeUtils = class {
42
45
  */
43
46
  static getFullOrConvertedType(mimeType, codecs, contentType) {
44
47
  const fullMimeType = shaka.util.MimeUtils.getFullType(mimeType, codecs);
48
+ const ContentType = shaka.util.ManifestParserUtils.ContentType;
45
49
 
46
- if (!shaka.dependencies.muxjs() ||
47
- !shaka.media.Transmuxer.isTsContainer(fullMimeType)) {
48
- return fullMimeType;
50
+ if (shaka.media.Transmuxer.isTsContainer(fullMimeType)) {
51
+ if (shaka.dependencies.muxjs()) {
52
+ return shaka.media.Transmuxer.convertTsCodecs(
53
+ contentType, fullMimeType);
54
+ }
55
+ } else if (contentType == ContentType.AUDIO) {
56
+ // video/mp2t is the correct mime type for TS audio, so only replace the
57
+ // word "video" with "audio" for non-TS audio content.
58
+ return fullMimeType.replace('video', 'audio');
49
59
  }
50
-
51
- return shaka.media.Transmuxer.convertTsCodecs(contentType, fullMimeType);
60
+ return fullMimeType;
52
61
  }
53
62
 
54
63
 
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.0.1",
4
+ "version": "4.0.2",
5
5
  "homepage": "https://github.com/shaka-project/shaka-player",
6
6
  "author": "Google",
7
7
  "maintainers": [
@@ -50,7 +50,7 @@
50
50
  "less": "https://gitpkg.now.sh/joeyparrish/less.js/packages/less?28c63a43",
51
51
  "less-plugin-clean-css": "github:austingardner/less-plugin-clean-css#4e9e77bf",
52
52
  "material-design-lite": "^1.3.0",
53
- "mux.js": "^5.14.1",
53
+ "mux.js": "^6.1.0",
54
54
  "open-sans-fonts": "^1.6.2",
55
55
  "postcss-less": "^6.0.0",
56
56
  "pwacompat": "^2.0.17",
@@ -539,11 +539,13 @@ describe('HlsParser live', () => {
539
539
  ManifestParser.verifySegmentIndex(video, [ref1, ref2]);
540
540
  });
541
541
 
542
+ // Test for https://github.com/shaka-project/shaka-player/issues/4223
542
543
  it('parses streams with partial and preload hinted segments', async () => {
543
544
  playerInterface.isLowLatencyMode = () => true;
544
545
  const mediaWithPartialSegments = [
545
546
  '#EXTM3U\n',
546
547
  '#EXT-X-TARGETDURATION:5\n',
548
+ '#EXT-X-PART-INF:PART-TARGET=1.5\n',
547
549
  '#EXT-X-MAP:URI="init.mp4",BYTERANGE="616@0"\n',
548
550
  '#EXT-X-MEDIA-SEQUENCE:0\n',
549
551
  // ref includes partialRef, partialRef2
@@ -576,26 +578,73 @@ describe('HlsParser live', () => {
576
578
  'test:/partial2.mp4', 2, 4, /* syncTime= */ null,
577
579
  /* baseUri= */ '', /* startByte= */ 200, /* endByte= */ 429);
578
580
 
581
+ const ref = makeReference(
582
+ 'test:/main.mp4', 0, 4, /* syncTime= */ null,
583
+ /* baseUri= */ '', /* startByte= */ 0, /* endByte= */ 429,
584
+ /* timestampOffset= */ 0, [partialRef, partialRef2]);
585
+
579
586
  const partialRef3 = makeReference(
580
587
  'test:/partial.mp4', 4, 6, /* syncTime= */ null,
581
588
  /* baseUri= */ '', /* startByte= */ 0, /* endByte= */ 209);
582
589
 
583
- // A preload hinted partial segment doesn't have duration information,
584
- // so its startTime and endTime are the same.
585
590
  const preloadRef = makeReference(
586
- 'test:/partial.mp4', 6, 6, /* syncTime= */ null,
591
+ 'test:/partial.mp4', 6, 7.5, /* syncTime= */ null,
587
592
  /* baseUri= */ '', /* startByte= */ 210, /* endByte= */ null);
588
593
 
594
+ // ref2 is not fully published yet, so it doesn't have a segment uri.
595
+ const ref2 = makeReference(
596
+ '', 4, 7.5, /* syncTime= */ null,
597
+ /* baseUri= */ '', /* startByte= */ 0, /* endByte= */ null,
598
+ /* timestampOffset= */ 0, [partialRef3, preloadRef]);
599
+
600
+ const manifest = await parser.start('test:/master', playerInterface);
601
+ const video = manifest.variants[0].video;
602
+ await video.createSegmentIndex();
603
+ ManifestParser.verifySegmentIndex(video, [ref, ref2]);
604
+ });
605
+
606
+ // Test for https://github.com/shaka-project/shaka-player/issues/4223
607
+ it('ignores preload hinted segments without target duration', async () => {
608
+ playerInterface.isLowLatencyMode = () => true;
609
+
610
+ // Missing PART-TARGET, so preload hints are skipped.
611
+ const mediaWithPartialSegments = [
612
+ '#EXTM3U\n',
613
+ '#EXT-X-TARGETDURATION:5\n',
614
+ '#EXT-X-MAP:URI="init.mp4",BYTERANGE="616@0"\n',
615
+ '#EXT-X-MEDIA-SEQUENCE:0\n',
616
+ '#EXTINF:4,\n',
617
+ // ref1
618
+ 'main.mp4\n',
619
+ // ref2 includes partialRef, but not preloadRef
620
+ // partialRef
621
+ '#EXT-X-PART:DURATION=2,URI="partial.mp4",BYTERANGE=210@0\n',
622
+ // preloadRef
623
+ '#EXT-X-PRELOAD-HINT:TYPE=PART,URI="partial.mp4",BYTERANGE-START=210\n',
624
+ ].join('');
625
+
626
+ fakeNetEngine
627
+ .setResponseText('test:/master', master)
628
+ .setResponseText('test:/video', mediaWithPartialSegments)
629
+ .setResponseValue('test:/init.mp4', initSegmentData)
630
+ .setResponseValue('test:/main.mp4', segmentData)
631
+ .setResponseValue('test:/partial.mp4', segmentData)
632
+ .setResponseValue('test:/partial2.mp4', segmentData);
633
+
589
634
  const ref = makeReference(
590
635
  'test:/main.mp4', 0, 4, /* syncTime= */ null,
591
- /* baseUri= */ '', /* startByte= */ 0, /* endByte= */ 429,
592
- /* timestampOffset= */ 0, [partialRef, partialRef2]);
636
+ /* baseUri= */ '', /* startByte= */ 0, /* endByte= */ null,
637
+ /* timestampOffset= */ 0, []);
638
+
639
+ const partialRef = makeReference(
640
+ 'test:/partial.mp4', 4, 6, /* syncTime= */ null,
641
+ /* baseUri= */ '', /* startByte= */ 0, /* endByte= */ 209);
593
642
 
594
643
  // ref2 is not fully published yet, so it doesn't have a segment uri.
595
644
  const ref2 = makeReference(
596
645
  '', 4, 6, /* syncTime= */ null,
597
- /* baseUri= */ '', /* startByte= */ 0, /* endByte= */ null,
598
- /* timestampOffset= */ 0, [partialRef3, preloadRef]);
646
+ /* baseUri= */ '', /* startByte= */ 0, /* endByte= */ 209,
647
+ /* timestampOffset= */ 0, [partialRef]);
599
648
 
600
649
  const manifest = await parser.start('test:/master', playerInterface);
601
650
  const video = manifest.variants[0].video;
@@ -611,6 +660,7 @@ describe('HlsParser live', () => {
611
660
  const mediaWithPartialSegments = [
612
661
  '#EXTM3U\n',
613
662
  '#EXT-X-TARGETDURATION:5\n',
663
+ '#EXT-X-PART-INF:PART-TARGET=1.5\n',
614
664
  '#EXTINF:4,\n',
615
665
  'main.mp4\n',
616
666
  '#EXT-X-PART:DURATION=2,URI="partial.mp4",BYTERANGE=210@0\n',
@@ -161,7 +161,7 @@
161
161
  /* Consistent margins (external) and padding (internal) between controls. */
162
162
  .bottom-panels-elements-margin();
163
163
 
164
- padding: 0;
164
+ padding: 0 5px;
165
165
 
166
166
  /* Transparent backgrounds, no borders, and a pointer when you mouse over
167
167
  * them. */
@@ -37,7 +37,7 @@
37
37
  }
38
38
 
39
39
  .bottom-panels-elements-margin() {
40
- margin: 1px 6px;
40
+ margin: 1px;
41
41
  }
42
42
 
43
43
  /* For containers which host elements overlaying other things. */
@@ -140,6 +140,7 @@
140
140
 
141
141
  .shaka-volume-bar-container {
142
142
  width: 100px;
143
+ padding: 0;
143
144
  }
144
145
 
145
146
  .shaka-range-element {
@@ -1,10 +0,0 @@
1
- <!--
2
- Please remember to:
3
-
4
- 1. Use Conventional Commits syntax (fix: ..., feat: ..., etc.) in commits and
5
- PR title (https://www.conventionalcommits.org/)
6
- 2. Tag any related or fixed issues ("Issue #123", "Closes #420")
7
- 3. Sign the Google CLA if you haven't (https://cla.developers.google.com)
8
-
9
- You may delete this comment from the PR description.
10
- -->