Skip to content

Commit

Permalink
fix: Exported SegmentReference.getUris.
Browse files Browse the repository at this point in the history
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 shaka-project#3096

Change-Id: I847439c444021bcf6af2b210f7138a51ba164d71
  • Loading branch information
theodab committed Mar 11, 2021
1 parent fc3afeb commit 8e1eeda
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/media/segment_index.js
Expand Up @@ -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,
Expand Down
12 changes: 11 additions & 1 deletion lib/media/segment_reference.js
Expand Up @@ -154,7 +154,7 @@ shaka.media.SegmentReference = class {
this.endTime = endTime;

/** @type {function():!Array.<string>} */
this.getUris = uris;
this.getUrisInner = uris;

/** @const {number} */
this.startByte = startByte;
Expand All @@ -178,6 +178,16 @@ shaka.media.SegmentReference = class {
this.partialReferences = partialReferences;
}

/**
* Creates and returns the URIs of the resource containing the segment.
*
* @return {!Array.<string>}
* @export
*/
getUris() {
return this.getUrisInner();
}

/**
* Returns the segment's start time in seconds.
*
Expand Down
2 changes: 1 addition & 1 deletion test/dash/dash_parser_live_unit.js
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions test/media/streaming_engine_unit.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions test/test/util/util.js
Expand Up @@ -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.
Expand Down

0 comments on commit 8e1eeda

Please sign in to comment.