shaka-player 3.3.0 → 3.3.1

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/build/conformance.textproto +183 -169
  3. package/dist/controls.css +1 -1
  4. package/dist/deps.js +1 -1
  5. package/dist/locales.js +30 -30
  6. package/dist/shaka-player.compiled.d.ts +25 -2
  7. package/dist/shaka-player.compiled.debug.d.ts +25 -2
  8. package/dist/shaka-player.compiled.debug.externs.js +22 -1
  9. package/dist/shaka-player.compiled.debug.js +226 -222
  10. package/dist/shaka-player.compiled.debug.map +3 -3
  11. package/dist/shaka-player.compiled.externs.js +22 -1
  12. package/dist/shaka-player.compiled.js +814 -812
  13. package/dist/shaka-player.compiled.map +4 -4
  14. package/dist/shaka-player.ui.d.ts +25 -2
  15. package/dist/shaka-player.ui.debug.d.ts +25 -2
  16. package/dist/shaka-player.ui.debug.externs.js +22 -1
  17. package/dist/shaka-player.ui.debug.js +244 -240
  18. package/dist/shaka-player.ui.debug.map +3 -3
  19. package/dist/shaka-player.ui.externs.js +22 -1
  20. package/dist/shaka-player.ui.js +995 -992
  21. package/dist/shaka-player.ui.map +4 -4
  22. package/externs/cmcd.js +186 -0
  23. package/externs/shaka/player.js +8 -0
  24. package/externs/shaka/text.js +10 -0
  25. package/lib/hls/hls_parser.js +30 -0
  26. package/lib/media/segment_index.js +2 -1
  27. package/lib/media/segment_reference.js +19 -1
  28. package/lib/media/streaming_engine.js +5 -2
  29. package/lib/player.js +23 -17
  30. package/lib/polyfill/media_capabilities.js +30 -15
  31. package/lib/text/cue.js +6 -0
  32. package/lib/text/ttml_text_parser.js +84 -58
  33. package/lib/text/ui_text_displayer.js +17 -11
  34. package/lib/util/cmcd_manager.js +47 -201
  35. package/lib/util/stream_utils.js +86 -10
  36. package/lib/util/xml_utils.js +19 -0
  37. package/package.json +2 -2
  38. package/test/media/drm_engine_unit.js +3 -3
  39. package/test/media/streaming_engine_integration.js +2 -1
  40. package/test/media/streaming_engine_unit.js +145 -0
  41. package/test/player_integration.js +41 -8
  42. package/test/player_src_equals_integration.js +41 -8
  43. package/test/player_unit.js +19 -9
  44. package/test/test/assets/chapters.vtt +2 -2
  45. package/test/test/assets/chapters2.vtt +10 -0
  46. package/test/test/util/ttml_utils.js +81 -0
  47. package/test/text/mp4_ttml_parser_unit.js +11 -18
  48. package/test/text/ttml_text_parser_unit.js +499 -230
  49. package/test/util/cmcd_manager_unit.js +29 -15
  50. package/test/util/stream_utils_unit.js +36 -30
  51. package/third_party/closure-uri/uri.js +21 -0
  52. package/ui/text_selection.js +1 -0
  53. package/externs/media_capabilities.js +0 -16
@@ -33,13 +33,19 @@ describe('CmcdManager', () => {
33
33
  describe('Query serialization', () => {
34
34
  it('produces correctly serialized data', () => {
35
35
  const query = CmcdManager.toQuery(data);
36
- const result = 'CMCD=br%3D52317%2Cbs%2Ccid%3D%22xyz%22%2C' +
37
- 'com.test-exists%2Ccom.test-hello%3D%22world%22%2C' +
38
- 'com.test-testing%3D1234%2Ccom.test-token%3Ds%2C' +
39
- 'd%3D6067%2Cmtp%3D10000%2C' +
40
- 'nor%3D%22..%252Ftesting%252F3.m4v%22%2C' +
41
- 'nrr%3D%220-99%22%2C' +
42
- 'sid%3D%22c936730c-031e-4a73-976f-92bc34039c60%22';
36
+ const result = 'br=52317,bs,cid="xyz",com.test-exists,' +
37
+ 'com.test-hello="world",com.test-testing=1234,' +
38
+ 'com.test-token=s,d=6067,mtp=10000,' +
39
+ 'nor="..%2Ftesting%2F3.m4v",nrr="0-99",' +
40
+ 'sid="c936730c-031e-4a73-976f-92bc34039c60"';
41
+ expect(query).toBe(result);
42
+ });
43
+
44
+ it('escapes reserve character in string values', () => {
45
+ const query = CmcdManager.toQuery({
46
+ 'com.test-escape': 'Double "Quotes"',
47
+ });
48
+ const result = 'com.test-escape="Double \\"Quotes\\""';
43
49
  expect(query).toBe(result);
44
50
  });
45
51
  });
@@ -77,12 +83,20 @@ describe('CmcdManager', () => {
77
83
  {start: 35, end: 40},
78
84
  ],
79
85
  }),
80
- getManifest: () => /** @type {shaka.extern.Manifest} */({
81
- variants: [
82
- {video: {bandwidth: 50000}},
83
- {video: {bandwidth: 5000000}},
84
- ],
85
- }),
86
+ getVariantTracks: () => /** @type {Array.<shaka.extern.Track>} */([
87
+ {
88
+ type: 'variant',
89
+ bandwidth: 50000,
90
+ videoBandwidth: 40000,
91
+ audioBandWidth: 10000,
92
+ },
93
+ {
94
+ type: 'variant',
95
+ bandwidth: 5000000,
96
+ videoBandwidth: 4000000,
97
+ audioBandWidth: 1000000,
98
+ },
99
+ ]),
86
100
  getPlaybackRate: () => 1,
87
101
  getCurrentTime: () => 10,
88
102
  };
@@ -169,7 +183,7 @@ describe('CmcdManager', () => {
169
183
  const uri = 'https://test.com/test.mpd?CMCD=bl%3D21200%2Cbr%3D5234%2Ccid%3D%22' +
170
184
  'testing%22%2Cd%3D3330%2Cmtp%3D10000%2Cot%3Dv%2Csf%3Dd%2C' +
171
185
  'sid%3D%222ed2d1cd-970b-48f2-bfb3-50a79e87cfa3%22%2Cst%3Dv%2Csu%2C' +
172
- 'tb%3D5000';
186
+ 'tb%3D4000';
173
187
  expect(r.uris[0]).toBe(uri);
174
188
  });
175
189
 
@@ -206,7 +220,7 @@ describe('CmcdManager', () => {
206
220
  cmcdManager.applySegmentData(r, segmentInfo);
207
221
  expect(r.headers).toEqual({
208
222
  'testing': '1234',
209
- 'CMCD-Object': 'br=5234,d=3330,ot=v,tb=5000',
223
+ 'CMCD-Object': 'br=5234,d=3330,ot=v,tb=4000',
210
224
  'CMCD-Request': 'bl=21200,mtp=10000,su',
211
225
  'CMCD-Session': 'cid="testing",sf=d,' +
212
226
  'sid="2ed2d1cd-970b-48f2-bfb3-50a79e87cfa3",st=v',
@@ -16,14 +16,14 @@ describe('StreamUtils', () => {
16
16
  /** @type {!jasmine.Spy} */
17
17
  let decodingInfoSpy;
18
18
 
19
- const originalDecodingInfo = window.shakaMediaCapabilities.decodingInfo;
19
+ const originalDecodingInfo = navigator.mediaCapabilities.decodingInfo;
20
20
 
21
21
  beforeEach(() => {
22
22
  decodingInfoSpy = jasmine.createSpy('decodingInfo');
23
23
  });
24
24
 
25
25
  afterEach(() => {
26
- window.shakaMediaCapabilities.decodingInfo = originalDecodingInfo;
26
+ navigator.mediaCapabilities.decodingInfo = originalDecodingInfo;
27
27
  });
28
28
 
29
29
  describe('filterStreamsByLanguageAndRole', () => {
@@ -511,7 +511,7 @@ describe('StreamUtils', () => {
511
511
  });
512
512
 
513
513
  it('handles decodingInfo exception', async () => {
514
- window.shakaMediaCapabilities.decodingInfo =
514
+ navigator.mediaCapabilities.decodingInfo =
515
515
  shaka.test.Util.spyFunc(decodingInfoSpy);
516
516
  // If decodingInfo() fails, setDecodingInfo should finish without throwing
517
517
  // an exception, and the variant should have no decodingInfo result.
@@ -539,38 +539,44 @@ describe('StreamUtils', () => {
539
539
  });
540
540
 
541
541
  it('includes transferFunction in config when hdr', async () => {
542
- window.shakaMediaCapabilities.decodingInfo =
543
- shaka.test.Util.spyFunc(decodingInfoSpy);
542
+ const originalDecodingInfo = navigator.mediaCapabilities.decodingInfo;
544
543
 
545
- manifest = shaka.test.ManifestGenerator.generate((manifest) => {
546
- manifest.addVariant(0, (variant) => {
547
- variant.addVideo(0, (stream) => {
548
- stream.mime('video/mp4', 'avc1.640028');
549
- stream.hdr = 'SDR';
544
+ try {
545
+ navigator.mediaCapabilities.decodingInfo =
546
+ shaka.test.Util.spyFunc(decodingInfoSpy);
547
+
548
+ manifest = shaka.test.ManifestGenerator.generate((manifest) => {
549
+ manifest.addVariant(0, (variant) => {
550
+ variant.addVideo(0, (stream) => {
551
+ stream.mime('video/mp4', 'avc1.640028');
552
+ stream.hdr = 'SDR';
553
+ });
550
554
  });
551
- });
552
- manifest.addVariant(1, (variant) => {
553
- variant.addVideo(1, (stream) => {
554
- stream.mime('video/mp4', 'hvc1.2.4.L150.90');
555
- stream.hdr = 'PQ';
555
+ manifest.addVariant(1, (variant) => {
556
+ variant.addVideo(1, (stream) => {
557
+ stream.mime('video/mp4', 'hvc1.2.4.L150.90');
558
+ stream.hdr = 'PQ';
559
+ });
556
560
  });
557
- });
558
- manifest.addVariant(2, (variant) => {
559
- variant.addVideo(2, (stream) => {
560
- stream.mime('video/mp4', 'hvc1.2.4.L153.B0');
561
- stream.hdr = 'HLG';
561
+ manifest.addVariant(2, (variant) => {
562
+ variant.addVideo(2, (stream) => {
563
+ stream.mime('video/mp4', 'hvc1.2.4.L153.B0');
564
+ stream.hdr = 'HLG';
565
+ });
562
566
  });
563
567
  });
564
- });
565
568
 
566
- await StreamUtils.getDecodingInfosForVariants(manifest.variants,
567
- /* usePersistentLicenses= */ false, /* srcEquals= */ false);
568
- expect(decodingInfoSpy.calls.argsFor(0)[0].video.transferFunction)
569
- .toBe('srgb');
570
- expect(decodingInfoSpy.calls.argsFor(1)[0].video.transferFunction)
571
- .toBe('pq');
572
- expect(decodingInfoSpy.calls.argsFor(2)[0].video.transferFunction)
573
- .toBe('hlg');
569
+ await StreamUtils.getDecodingInfosForVariants(manifest.variants,
570
+ /* usePersistentLicenses= */ false, /* srcEquals= */ false);
571
+ expect(decodingInfoSpy.calls.argsFor(0)[0].video.transferFunction)
572
+ .toBe('srgb');
573
+ expect(decodingInfoSpy.calls.argsFor(1)[0].video.transferFunction)
574
+ .toBe('pq');
575
+ expect(decodingInfoSpy.calls.argsFor(2)[0].video.transferFunction)
576
+ .toBe('hlg');
577
+ } finally {
578
+ navigator.mediaCapabilities.decodingInfo = originalDecodingInfo;
579
+ }
574
580
  });
575
581
  });
576
582
 
@@ -861,7 +867,7 @@ describe('StreamUtils', () => {
861
867
  });
862
868
  });
863
869
  });
864
- window.shakaMediaCapabilities.decodingInfo =
870
+ navigator.mediaCapabilities.decodingInfo =
865
871
  shaka.test.Util.spyFunc(decodingInfoSpy);
866
872
  decodingInfoSpy.and.callFake((config) => {
867
873
  const res = config.video.contentType.includes('notsmooth') ?
@@ -808,6 +808,27 @@ goog.Uri.QueryData.prototype.add = function(key, value) {
808
808
  return this;
809
809
  };
810
810
 
811
+ /**
812
+ * Sets a key value pair and removes all other keys with the same value.
813
+ *
814
+ * @param {string} key Name.
815
+ * @param {string} value Value.
816
+ * @return {!goog.Uri.QueryData} Instance of this object.
817
+ */
818
+ goog.Uri.QueryData.prototype.set = function(key, value) {
819
+ this.ensureKeyMapInitialized_();
820
+ // Invalidate the cache.
821
+ this.encodedQuery_ = null;
822
+
823
+ if (!this.keyMap_.hasOwnProperty(key)) {
824
+ this.add(key, value);
825
+ } else {
826
+ this.keyMap_[key] = [value];
827
+ }
828
+
829
+ return this;
830
+ };
831
+
811
832
 
812
833
  /**
813
834
  * @return {string} Encoded query string.
@@ -66,6 +66,7 @@ shaka.ui.TextSelection = class extends shaka.ui.SettingsMenu {
66
66
 
67
67
  this.eventManager.listen(this.player, 'texttrackvisibility', () => {
68
68
  this.onCaptionStateChange_();
69
+ this.updateTextLanguages_();
69
70
  });
70
71
 
71
72
  this.eventManager.listen(this.player, 'textchanged', () => {
@@ -1,16 +0,0 @@
1
- /*! @license
2
- * Shaka Player
3
- * Copyright 2016 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- /**
8
- * @fileoverview Externs for Shaka MediaCapabilities which were missing in the
9
- * Closure compiler.
10
- *
11
- * @externs
12
- */
13
-
14
-
15
- /** @type {MediaCapabilities} */
16
- window.shakaMediaCapabilities;