From 8e1eeda96516b43b91cf240eb20ca486958b6fe3 Mon Sep 17 00:00:00 2001 From: Theodore Abshire Date: Wed, 10 Mar 2021 22:36:41 -0800 Subject: [PATCH] fix: Exported SegmentReference.getUris. Previously, SegmentReference.getUris was listed as public field, but not actually exported. For an object that does not have externs, there is no way to ensure that a member variable is not renamed. So, instead, this CL makes an exported public getUris method, that wraps the getUrisInner member variable. This allows for the method to be exported, without having to make an extern for the class. Closes #3096 Change-Id: I847439c444021bcf6af2b210f7138a51ba164d71 --- lib/media/segment_index.js | 2 +- lib/media/segment_reference.js | 12 +++++++++++- test/dash/dash_parser_live_unit.js | 2 +- test/media/streaming_engine_unit.js | 4 ++-- test/test/util/util.js | 2 ++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/media/segment_index.js b/lib/media/segment_index.js index ccf65ccadc..8e2deb83e2 100644 --- a/lib/media/segment_index.js +++ b/lib/media/segment_index.js @@ -291,7 +291,7 @@ shaka.media.SegmentIndex = class { new shaka.media.SegmentReference( lastReference.startTime, /* endTime= */ windowEnd, - lastReference.getUris, + lastReference.getUrisInner, lastReference.startByte, lastReference.endByte, lastReference.initSegmentReference, diff --git a/lib/media/segment_reference.js b/lib/media/segment_reference.js index 9b2823fb14..662a22f298 100644 --- a/lib/media/segment_reference.js +++ b/lib/media/segment_reference.js @@ -154,7 +154,7 @@ shaka.media.SegmentReference = class { this.endTime = endTime; /** @type {function():!Array.} */ - this.getUris = uris; + this.getUrisInner = uris; /** @const {number} */ this.startByte = startByte; @@ -178,6 +178,16 @@ shaka.media.SegmentReference = class { this.partialReferences = partialReferences; } + /** + * Creates and returns the URIs of the resource containing the segment. + * + * @return {!Array.} + * @export + */ + getUris() { + return this.getUrisInner(); + } + /** * Returns the segment's start time in seconds. * diff --git a/test/dash/dash_parser_live_unit.js b/test/dash/dash_parser_live_unit.js index 9b36c70638..e28c9a5bbf 100644 --- a/test/dash/dash_parser_live_unit.js +++ b/test/dash/dash_parser_live_unit.js @@ -123,7 +123,7 @@ describe('DashParser Live', () => { return new shaka.media.SegmentReference( ref.startTime, ref.endTime, - ref.getUris, + ref.getUrisInner, ref.startByte, ref.endByte, ref.initSegmentReference, diff --git a/test/media/streaming_engine_unit.js b/test/media/streaming_engine_unit.js index 10fe20d71f..2d76aec306 100644 --- a/test/media/streaming_engine_unit.js +++ b/test/media/streaming_engine_unit.js @@ -2940,7 +2940,7 @@ describe('StreamingEngine', () => { if (seg) { // With endByte being null, we won't know the segment size. return new shaka.media.SegmentReference( - seg.startTime, seg.endTime, seg.getUris, + seg.startTime, seg.endTime, seg.getUrisInner, /* startByte= */ 0, /* endByte= */ null, /* initSegmentReference= */ null, /* timestampOffset= */ 0, /* appendWindowStart= */ 0, /* appendWindowEnd= */ Infinity); @@ -3047,7 +3047,7 @@ describe('StreamingEngine', () => { // With endByte being null, we won't know the segment size. // Segment size has to be calculated with times and bandwidth. return new shaka.media.SegmentReference( - seg.startTime, seg.endTime, seg.getUris, + seg.startTime, seg.endTime, seg.getUrisInner, /* startByte= */ 0, /* endByte= */ null, /* initSegmentReference= */ null, /* timestampOffset= */ 0, /* appendWindowStart= */ 0, /* appendWindowEnd= */ Infinity); diff --git a/test/test/util/util.js b/test/test/util/util.js index 330de0c28d..6b321855a4 100644 --- a/test/test/util/util.js +++ b/test/test/util/util.js @@ -245,8 +245,10 @@ shaka.test.Util = class { // Make shallow copies of each, without their getUris fields. const trimmedFirst = Object.assign({}, /** @type {Object} */(firstRef)); delete trimmedFirst['getUris']; + delete trimmedFirst['getUrisInner']; const trimmedSecond = Object.assign({}, /** @type {Object} */(secondRef)); delete trimmedSecond['getUris']; + delete trimmedSecond['getUrisInner']; // Compare those using Jasmine's utility, which will compare the fields of // an object and the items of an array.