shaka-player 4.11.1 → 4.11.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.
@@ -2978,6 +2978,8 @@ shaka.dash.DashParser = class {
2978
2978
  const schemeIdUri = elem.attributes['schemeIdUri'] || '';
2979
2979
  const value = elem.attributes['value'] || '';
2980
2980
  const timescale = TXml.parseAttr(elem, 'timescale', parseNumber) || 1;
2981
+ const presentationTimeOffset =
2982
+ TXml.parseAttr(elem, 'presentationTimeOffset', parseNumber) || 0;
2981
2983
 
2982
2984
  for (const eventNode of TXml.findChildren(elem, 'Event')) {
2983
2985
  const presentationTime =
@@ -2985,7 +2987,10 @@ shaka.dash.DashParser = class {
2985
2987
  const duration =
2986
2988
  TXml.parseAttr(eventNode, 'duration', parseNumber) || 0;
2987
2989
 
2988
- let startTime = presentationTime / timescale + periodStart;
2990
+ // Ensure start time won't be lower than period start.
2991
+ let startTime = Math.max(
2992
+ (presentationTime - presentationTimeOffset) / timescale + periodStart,
2993
+ periodStart);
2989
2994
  let endTime = startTime + (duration / timescale);
2990
2995
  if (periodDuration != null) {
2991
2996
  // An event should not go past the Period, even if the manifest says so.
@@ -3007,7 +3012,7 @@ shaka.dash.DashParser = class {
3007
3012
  endTime: endTime,
3008
3013
  id: eventNode.attributes['id'] || '',
3009
3014
  eventElement: TXml.txmlNodeToDomElement(eventNode),
3010
- eventNode: eventNode,
3015
+ eventNode: TXml.cloneNode(eventNode),
3011
3016
  };
3012
3017
 
3013
3018
  this.playerInterface_.onTimelineRegionAdded(region);
@@ -700,6 +700,17 @@ shaka.media.MetaSegmentIndex = class extends shaka.media.SegmentIndex {
700
700
  this.indexes_ = [];
701
701
  }
702
702
 
703
+ /** Evicts all old SegmentIndexes in this MetaSegmentIndex that are empty. */
704
+ evictEmpty() {
705
+ while (this.indexes_.length > 1 && this.indexes_[0].isEmpty()) {
706
+ const index = this.indexes_.shift();
707
+ // In the case of this class, this.numEvicted_ represents the evicted
708
+ // segments that were in indexes that were entirely evicted.
709
+ this.numEvicted_ += index.getNumEvicted();
710
+ index.release();
711
+ }
712
+ }
713
+
703
714
  /**
704
715
  * Append a SegmentIndex to this MetaSegmentIndex. This effectively stitches
705
716
  * the underlying Stream onto the end of the multi-Period Stream represented
@@ -724,6 +735,7 @@ shaka.media.MetaSegmentIndex = class extends shaka.media.SegmentIndex {
724
735
  // Be careful to clone the Array. We don't want to share the reference with
725
736
  // our clone and affect each other accidentally.
726
737
  clone.indexes_ = this.indexes_.slice();
738
+ clone.numEvicted_ = this.numEvicted_;
727
739
  return clone;
728
740
  }
729
741
 
@@ -754,7 +766,7 @@ shaka.media.MetaSegmentIndex = class extends shaka.media.SegmentIndex {
754
766
  * @export
755
767
  */
756
768
  find(time) {
757
- let numPassedInEarlierIndexes = 0;
769
+ let numPassedInEarlierIndexes = this.numEvicted_;
758
770
 
759
771
  for (const index of this.indexes_) {
760
772
  const position = index.find(time);
@@ -775,7 +787,7 @@ shaka.media.MetaSegmentIndex = class extends shaka.media.SegmentIndex {
775
787
  * @export
776
788
  */
777
789
  get(position) {
778
- let numPassedInEarlierIndexes = 0;
790
+ let numPassedInEarlierIndexes = this.numEvicted_;
779
791
  let sawSegments = false;
780
792
 
781
793
  for (const index of this.indexes_) {
@@ -15,6 +15,7 @@ goog.require('shaka.log');
15
15
  goog.require('shaka.media.InitSegmentReference');
16
16
  goog.require('shaka.media.ManifestParser');
17
17
  goog.require('shaka.media.MediaSourceEngine');
18
+ goog.require('shaka.media.MetaSegmentIndex');
18
19
  goog.require('shaka.media.SegmentIterator');
19
20
  goog.require('shaka.media.SegmentReference');
20
21
  goog.require('shaka.media.SegmentPrefetch');
@@ -2502,6 +2503,11 @@ shaka.media.StreamingEngine = class {
2502
2503
  * @private
2503
2504
  */
2504
2505
  async evict_(mediaState, presentationTime) {
2506
+ const segmentIndex = mediaState.stream.segmentIndex;
2507
+ if (segmentIndex instanceof shaka.media.MetaSegmentIndex) {
2508
+ segmentIndex.evictEmpty();
2509
+ }
2510
+
2505
2511
  const logPrefix = shaka.media.StreamingEngine.logPrefix_(mediaState);
2506
2512
  shaka.log.v2(logPrefix, 'checking buffer length');
2507
2513
 
package/lib/player.js CHANGED
@@ -8063,7 +8063,7 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
8063
8063
  * @export
8064
8064
  */
8065
8065
  // eslint-disable-next-line no-useless-concat
8066
- shaka.Player.version = 'v4.11.1' + '-uncompiled'; // x-release-please-version
8066
+ shaka.Player.version = 'v4.11.2' + '-uncompiled'; // x-release-please-version
8067
8067
 
8068
8068
  // Initialize the deprecation system using the version string we just set
8069
8069
  // on the player.
@@ -519,6 +519,24 @@ shaka.text.TtmlTextParser = class {
519
519
  return region;
520
520
  }
521
521
 
522
+ /**
523
+ * Ensures any TTML RGBA's alpha range of 0-255 is converted to 0-1.
524
+ * @param {string} color
525
+ * @return {string}
526
+ * @private
527
+ */
528
+ static convertTTMLrgbaToHTMLrgba_(color) {
529
+ const rgba = color.match(/rgba\(([^)]+)\)/);
530
+ if (rgba) {
531
+ const values = rgba[1].split(',');
532
+ if (values.length == 4) {
533
+ values[3] = String(Number(values[3]) / 255);
534
+ return 'rgba(' + values.join(',') + ')';
535
+ }
536
+ }
537
+ return color;
538
+ }
539
+
522
540
  /**
523
541
  * Adds applicable style properties to a cue.
524
542
  *
@@ -597,7 +615,7 @@ shaka.text.TtmlTextParser = class {
597
615
  const color = TtmlTextParser.getStyleAttribute_(
598
616
  cueElement, region, styles, 'color', shouldInheritRegionStyles);
599
617
  if (color) {
600
- cue.color = color;
618
+ cue.color = TtmlTextParser.convertTTMLrgbaToHTMLrgba_(color);
601
619
  }
602
620
 
603
621
  // Background color should not be set on a container. If this is a nested
@@ -611,7 +629,8 @@ shaka.text.TtmlTextParser = class {
611
629
  cueElement, region, styles, 'backgroundColor',
612
630
  shouldInheritRegionStyles);
613
631
  if (backgroundColor) {
614
- cue.backgroundColor = backgroundColor;
632
+ cue.backgroundColor =
633
+ TtmlTextParser.convertTTMLrgbaToHTMLrgba_(backgroundColor);
615
634
  }
616
635
 
617
636
  const border = TtmlTextParser.getStyleAttribute_(
@@ -720,7 +739,8 @@ shaka.text.TtmlTextParser = class {
720
739
  // There is no defined color, so default to the text color.
721
740
  cue.textStrokeColor = cue.color;
722
741
  } else {
723
- cue.textStrokeColor = split[0];
742
+ cue.textStrokeColor =
743
+ TtmlTextParser.convertTTMLrgbaToHTMLrgba_(split[0]);
724
744
  split.shift();
725
745
  }
726
746
  if (split[0] && split[0].match(TtmlTextParser.unitValues_)) {
@@ -852,7 +852,10 @@ shaka.util.PeriodCombiner = class {
852
852
  if (output.originalId == null) {
853
853
  output.originalId = input.originalId;
854
854
  } else {
855
- output.originalId += ',' + (input.originalId || '');
855
+ const newOriginalId = (input.originalId || '');
856
+ if (newOriginalId && !output.originalId.endsWith(newOriginalId)) {
857
+ output.originalId += ',' + newOriginalId;
858
+ }
856
859
  }
857
860
 
858
861
  const commonDrmInfos = shaka.util.DrmUtils.getCommonDrmInfos(
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.11.1",
4
+ "version": "4.11.2",
5
5
  "homepage": "https://github.com/shaka-project/shaka-player",
6
6
  "author": "Google",
7
7
  "maintainers": [