shaka-player 4.10.11 → 4.10.13

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.
@@ -890,26 +890,33 @@ shaka.util.PeriodCombiner = class {
890
890
  // Create a fresh output stream for trick-mode playback.
891
891
  output.trickModeVideo = shaka.util.PeriodCombiner.cloneStream_(
892
892
  input.trickModeVideo);
893
- // TODO: fix the createSegmentIndex function for trickModeVideo.
894
- // The trick-mode tracks in multi-period content should have trick-mode
895
- // segment indexes whenever available, rather than only regular-mode
896
- // segment indexes.
893
+ output.trickModeVideo.matchedStreams = [];
897
894
  output.trickModeVideo.createSegmentIndex = () => {
898
- // Satisfy the compiler about the type.
899
- goog.asserts.assert(
900
- output.segmentIndex instanceof shaka.media.MetaSegmentIndex,
901
- 'The stream should have a MetaSegmentIndex.');
902
- output.trickModeVideo.segmentIndex = output.segmentIndex.clone();
895
+ if (output.trickModeVideo.segmentIndex) {
896
+ return Promise.resolve();
897
+ }
898
+ const segmentIndex = new shaka.media.MetaSegmentIndex();
899
+ goog.asserts.assert(output.trickModeVideo.matchedStreams,
900
+ 'trickmode matched streams should exist');
901
+ for (const stream of output.trickModeVideo.matchedStreams) {
902
+ goog.asserts.assert(stream.segmentIndex,
903
+ 'trickmode segment index should exist');
904
+ segmentIndex.appendSegmentIndex(stream.segmentIndex);
905
+ }
906
+ output.trickModeVideo.segmentIndex = segmentIndex;
907
+
903
908
  return Promise.resolve();
904
909
  };
905
910
  }
906
911
 
907
912
  // Concatenate the trick mode input onto the trick mode output.
913
+ output.trickModeVideo.matchedStreams.push(input.trickModeVideo);
908
914
  shaka.util.PeriodCombiner.concatenateStreams_(
909
915
  output.trickModeVideo, input.trickModeVideo);
910
916
  } else if (output.trickModeVideo) {
911
917
  // We have a trick mode output, but no input from this Period. Fill it in
912
918
  // from the standard input Stream.
919
+ output.trickModeVideo.matchedStreams.push(input);
913
920
  shaka.util.PeriodCombiner.concatenateStreams_(
914
921
  output.trickModeVideo, input);
915
922
  }
@@ -418,6 +418,8 @@ shaka.util.StreamUtils = class {
418
418
  'dva1': 'avc1',
419
419
  'dvhe': 'hev1',
420
420
  'dvh1': 'hvc1',
421
+ 'dvc1': 'vvc1',
422
+ 'dvi1': 'vvi1',
421
423
  };
422
424
  /** @type {!Set<!shaka.extern.Stream>} */
423
425
  const streams = new Set();
package/lib/util/tXml.js CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  goog.provide('shaka.util.TXml');
8
8
 
9
+ goog.require('shaka.util.ObjectUtils');
9
10
  goog.require('shaka.util.StringUtils');
10
11
  goog.require('shaka.log');
11
12
 
@@ -71,24 +72,37 @@ shaka.util.TXml = class {
71
72
  }
72
73
 
73
74
  /**
74
- * Parse some data
75
+ * Get namespace based on schema
75
76
  * @param {string} schema
76
77
  * @return {string}
77
78
  */
78
79
  static getKnownNameSpace(schema) {
79
- if (shaka.util.TXml.knownNameSpaces_.has(schema)) {
80
- return shaka.util.TXml.knownNameSpaces_.get(schema);
80
+ if (shaka.util.TXml.uriToNameSpace_.has(schema)) {
81
+ return shaka.util.TXml.uriToNameSpace_.get(schema);
81
82
  }
82
83
  return '';
83
84
  }
84
85
 
85
86
  /**
86
- * Parse some data
87
+ * Get schema based on namespace
88
+ * @param {string} NS
89
+ * @return {string}
90
+ */
91
+ static getKnownSchema(NS) {
92
+ if (shaka.util.TXml.nameSpaceToUri_.has(NS)) {
93
+ return shaka.util.TXml.nameSpaceToUri_.get(NS);
94
+ }
95
+ return '';
96
+ }
97
+
98
+ /**
99
+ * Sets NS <-> schema bidirectional mapping
87
100
  * @param {string} schema
88
101
  * @param {string} NS
89
102
  */
90
103
  static setKnownNameSpace(schema, NS) {
91
- shaka.util.TXml.knownNameSpaces_.set(schema, NS);
104
+ shaka.util.TXml.uriToNameSpace_.set(schema, NS);
105
+ shaka.util.TXml.nameSpaceToUri_.set(NS, schema);
92
106
  }
93
107
 
94
108
  /**
@@ -869,43 +883,69 @@ shaka.util.TXml = class {
869
883
  /**
870
884
  * Converts a tXml node to DOM element.
871
885
  * @param {shaka.extern.xml.Node} node
872
- * @param {boolean=} doParents
873
- * @param {boolean=} doChildren
874
886
  * @return {!Element}
875
887
  */
876
- static txmlNodeToDomElement(node, doParents = true, doChildren = true) {
888
+ static txmlNodeToDomElement(node) {
877
889
  const TXml = shaka.util.TXml;
878
- const element = document.createElement(node.tagName);
890
+ let namespace = '';
891
+ const parts = node.tagName.split(':');
892
+ if (parts.length > 0) {
893
+ namespace = TXml.getKnownSchema(parts[0]);
894
+ }
895
+ const element = document.createElementNS(namespace, node.tagName);
879
896
 
880
897
  for (const k in node.attributes) {
881
898
  const v = node.attributes[k];
882
899
  element.setAttribute(k, v);
883
900
  }
884
901
 
885
- if (doParents && node.parent && node.parent.tagName != '?xml') {
886
- const parentElement = TXml.txmlNodeToDomElement(
887
- node.parent, /* doParents= */ true, /* doChildren= */ false);
888
- parentElement.appendChild(element);
889
- }
890
-
891
- if (doChildren) {
892
- for (const child of node.children) {
893
- let childElement;
894
- if (typeof child == 'string') {
895
- childElement = new Text(child);
896
- } else {
897
- childElement = TXml.txmlNodeToDomElement(
898
- child, /* doParents= */ false, /* doChildren= */ true);
899
- }
900
- element.appendChild(childElement);
902
+ for (const child of node.children) {
903
+ let childElement;
904
+ if (typeof child == 'string') {
905
+ childElement = new Text(child);
906
+ } else {
907
+ childElement = TXml.txmlNodeToDomElement(child);
901
908
  }
909
+ element.appendChild(childElement);
902
910
  }
903
911
 
904
912
  return element;
905
913
  }
914
+
915
+ /**
916
+ * Clones node and its children recursively. Skips parent.
917
+ * @param {?shaka.extern.xml.Node} node
918
+ * @return {?shaka.extern.xml.Node}
919
+ */
920
+ static cloneNode(node) {
921
+ if (!node) {
922
+ return null;
923
+ }
924
+ /** @type {!shaka.extern.xml.Node} */
925
+ const clone = {
926
+ tagName: node.tagName,
927
+ attributes: shaka.util.ObjectUtils.shallowCloneObject(node.attributes),
928
+ children: [],
929
+ parent: null,
930
+ };
931
+ for (const child of node.children) {
932
+ if (typeof child === 'string') {
933
+ clone.children.push(child);
934
+ } else {
935
+ const clonedChild = shaka.util.TXml.cloneNode(child);
936
+ clonedChild.parent = clone;
937
+ clone.children.push(clonedChild);
938
+ }
939
+ }
940
+ return clone;
941
+ }
906
942
  };
907
943
 
908
- shaka.util.TXml.knownNameSpaces_ = new Map([]);
944
+ /** @private {!Map<string, string>} */
945
+ shaka.util.TXml.uriToNameSpace_ = new Map();
946
+
947
+ /** @private {!Map<string, string>} */
948
+ shaka.util.TXml.nameSpaceToUri_ = new Map();
909
949
 
910
950
 
911
951
  /**
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.10.11",
4
+ "version": "4.10.13",
5
5
  "homepage": "https://github.com/shaka-project/shaka-player",
6
6
  "author": "Google",
7
7
  "maintainers": [