Skip to content

Commit

Permalink
fix(DASH): Fix playback after DASH period eviction (#7603)
Browse files Browse the repository at this point in the history
Fixes #7516 in a
simpler way

Reverts
5eff038
Reverts
037193c
  • Loading branch information
avelad committed Nov 15, 2024
1 parent 2a6092e commit 09dcabc
Show file tree
Hide file tree
Showing 22 changed files with 12 additions and 209 deletions.
3 changes: 0 additions & 3 deletions externs/shaka/manifest_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ shaka.extern.ManifestParser = class {
* getBandwidthEstimate: function():number,
* onMetadata: function(string, number, ?number,
* !Array.<shaka.extern.MetadataFrame>),
* closeSegmentIndex: function(shaka.extern.Stream, function()),
* disableStream: function(!shaka.extern.Stream),
* addFont: function(string, string)
* }}
Expand Down Expand Up @@ -187,8 +186,6 @@ shaka.extern.ManifestParser = class {
* @property {function(!shaka.extern.Stream)} disableStream
* Called to temporarily disable a stream i.e. disabling all variant
* containing said stream.
* @property {function(!shaka.extern.Stream, function())} closeSegmentIndex
* Called to close a segment index.
* @property {function(string, string)} addFont
* Called when a new font needs to be added.
* @exportDoc
Expand Down
16 changes: 11 additions & 5 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,6 @@ shaka.dash.DashParser = class {
this.lowLatencyMode_ = playerInterface.isLowLatencyMode();
this.manifestUris_ = [uri];
this.playerInterface_ = playerInterface;
if (this.periodCombiner_) {
this.periodCombiner_.setPlayerInterface(this.playerInterface_);
}

const updateDelay = await this.requestManifest_();

Expand Down Expand Up @@ -684,7 +681,6 @@ shaka.dash.DashParser = class {
}

this.manifestPatchContext_.type = mpdType;
this.cleanStreamMap_();
/** @type {!shaka.media.PresentationTimeline} */
let presentationTimeline;
if (this.manifest_) {
Expand Down Expand Up @@ -861,6 +857,8 @@ shaka.dash.DashParser = class {
// after period combining, while we still have a direct reference, so that
// any new streams will appear in the period combiner.
this.playerInterface_.makeTextStreamsForClosedCaptions(this.manifest_);

this.cleanStreamMap_();
}

/**
Expand Down Expand Up @@ -1504,13 +1502,21 @@ shaka.dash.DashParser = class {
return !this.lastManifestUpdatePeriodIds_.includes(pId);
});
for (const pId of diffPeriodsIDs) {
let shouldDeleteIndex = true;
for (const contextId of this.indexStreamMap_[pId]) {
const stream = this.streamMap_[contextId];
if (stream.segmentIndex && !stream.segmentIndex.isEmpty()) {
shouldDeleteIndex = false;
continue;
}
if (this.periodCombiner_) {
this.periodCombiner_.deleteStream(this.streamMap_[contextId], pId);
}
delete this.streamMap_[contextId];
}
delete this.indexStreamMap_[pId];
if (shouldDeleteIndex) {
delete this.indexStreamMap_[pId];
}
}
}

Expand Down
26 changes: 0 additions & 26 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,32 +513,6 @@ shaka.media.StreamingEngine = class {
}
}

/**
* closeSegmentIndex if the stream is not active
* @param {shaka.extern.Stream} stream
* @param {function()} closeSegmentIndex
*/
closeSegmentIndex(stream, closeSegmentIndex) {
const type = /** @type {!shaka.util.ManifestParserUtils.ContentType} */
(stream.type);
const mediaState = this.mediaStates_.get(type);
if (mediaState) {
/**
* Closes the segmentIndex only if the stream is not active.
* If the stream is active the eviction will be peformed
* by the next onUpdate_().
*/
const matchedStreams = mediaState.stream.matchedStreams;
const found = matchedStreams.find((match) => match.id === stream.id);
if (!found) {
closeSegmentIndex();
}
} else {
// type of stream not active
closeSegmentIndex();
}
}


/**
* Handles deferred releases of old SegmentIndexes for the mediaState's
Expand Down
1 change: 0 additions & 1 deletion lib/offline/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,6 @@ shaka.offline.Storage = class {
onManifestUpdated: () => {},
getBandwidthEstimate: () => config.abr.defaultBandwidthEstimate,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
7 changes: 0 additions & 7 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2169,13 +2169,6 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
});
}
},
closeSegmentIndex: (stream, closeSegmentIndex) => {
if (this.streamingEngine_) {
this.streamingEngine_.closeSegmentIndex(stream, closeSegmentIndex);
} else {
closeSegmentIndex();
}
},
disableStream: (stream) => this.disableStream(
stream, this.config_.streaming.maxDisabledTime),
addFont: (name, url) => this.addFont(name, url),
Expand Down
25 changes: 1 addition & 24 deletions lib/util/periods.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ shaka.util.PeriodCombiner = class {
/** @private {boolean} */
this.useStreamOnce_ = false;

/** @private {?shaka.extern.ManifestParser.PlayerInterface} */
this.playerInterface_ = null;

/**
* The IDs of the periods we have already used to generate streams.
* This helps us identify the periods which have been added when a live
Expand Down Expand Up @@ -83,15 +80,6 @@ shaka.util.PeriodCombiner = class {
this.usedPeriodIds_.clear();
}

/**
* @param {?shaka.extern.ManifestParser.PlayerInterface} playerInterface
*
* @export
*/
setPlayerInterface(playerInterface) {
this.playerInterface_ = playerInterface;
}

/**
* @return {!Array.<shaka.extern.Variant>}
*
Expand Down Expand Up @@ -167,19 +155,8 @@ shaka.util.PeriodCombiner = class {
}
}
if (stream.segmentIndex) {
if (this.playerInterface_) {
const closeSegmentIndex = () => {
stream.closeSegmentIndex();
};

this.playerInterface_.closeSegmentIndex(
stream,
closeSegmentIndex);
} else {
stream.closeSegmentIndex();
}
stream.closeSegmentIndex();
}

this.usedPeriodIds_.delete(periodId);
}

Expand Down
1 change: 0 additions & 1 deletion test/dash/dash_parser_content_protection_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ describe('DashParser ContentProtection', () => {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
1 change: 0 additions & 1 deletion test/dash/dash_parser_live_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('DashParser Live', () => {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
1 change: 0 additions & 1 deletion test/dash/dash_parser_manifest_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ describe('DashParser Manifest', () => {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: shaka.test.Util.spyFunc(addFontSpy),
};
Expand Down
1 change: 0 additions & 1 deletion test/dash/dash_parser_patch_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ describe('DashParser Patch', () => {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
1 change: 0 additions & 1 deletion test/dash/dash_parser_segment_base_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ describe('DashParser SegmentBase', () => {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
1 change: 0 additions & 1 deletion test/dash/dash_parser_segment_list_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ describe('DashParser SegmentList', () => {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
1 change: 0 additions & 1 deletion test/dash/dash_parser_segment_template_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe('DashParser SegmentTemplate', () => {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
1 change: 0 additions & 1 deletion test/hls/hls_live_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ describe('HlsParser live', () => {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
1 change: 0 additions & 1 deletion test/hls/hls_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ describe('HlsParser', () => {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: shaka.test.Util.spyFunc(onMetadataSpy),
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
2 changes: 0 additions & 2 deletions test/media/streaming_engine_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,6 @@ describe('StreamingEngine', () => {
onSegmentAppended: () => playhead.notifyOfBufferingChange(),
onInitSegmentAppended: () => {},
beforeAppendSegment: () => Promise.resolve(),
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream, time) => false,
};
streamingEngine = new shaka.media.StreamingEngine(
Expand Down
1 change: 0 additions & 1 deletion test/media/streaming_engine_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ describe('StreamingEngine', () => {
onSegmentAppended: Util.spyFunc(onSegmentAppended),
onInitSegmentAppended: () => {},
beforeAppendSegment: Util.spyFunc(beforeAppendSegment),
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: Util.spyFunc(disableStream),
};
streamingEngine = new shaka.media.StreamingEngine(
Expand Down
1 change: 0 additions & 1 deletion test/mss/mss_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ describe('MssParser Manifest', () => {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
2 changes: 0 additions & 2 deletions test/test/util/dash_parser_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ shaka.test.Dash = class {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down Expand Up @@ -99,7 +98,6 @@ shaka.test.Dash = class {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
2 changes: 0 additions & 2 deletions test/test/util/mss_parser_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ shaka.test.Mss = class {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down Expand Up @@ -90,7 +89,6 @@ shaka.test.Mss = class {
onManifestUpdated: () => {},
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
1 change: 0 additions & 1 deletion test/util/content_steering_manager_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('ContentSteeringManager', () => {
onManifestUpdated: fail,
getBandwidthEstimate: () => 1e6,
onMetadata: () => {},
closeSegmentIndex: (stream, closeSegmentIndex) => {},
disableStream: (stream) => {},
addFont: (name, url) => {},
};
Expand Down
Loading

0 comments on commit 09dcabc

Please sign in to comment.