Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSS] Update for live streams support #3011

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mss/MssFragmentMoofProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function MssFragmentMoofProcessor(config) {
updateDVR(type, range, streamProcessor.getStreamInfo().manifestInfo);
}

indexHandler.updateSegmentList(representation);
indexHandler.updateRepresentation(representation, true);
}

function updateDVR(type, range, manifestInfo) {
Expand Down
32 changes: 15 additions & 17 deletions src/mss/parser/MssParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,8 @@ function MssParser(config) {
// Duration will be set according to current segment timeline duration (see below)
}

// In case of live streams, set availabilityStartTime property according to DVRWindowLength
if (manifest.type === 'dynamic' && manifest.timeShiftBufferDepth < Infinity) {
manifest.availabilityStartTime = new Date(manifestLoadedTime.getTime() - (manifest.timeShiftBufferDepth * 1000));
manifest.refreshManifestOnSwitchTrack = true;
manifest.refreshManifestOnSwitchTrack = true; // Refresh manifest when switching tracks
manifest.doNotUpdateDVRWindowOnBufferUpdated = true; // DVRWindow is update by MssFragmentMoofPocessor based on tfrf boxes
manifest.ignorePostponeTimePeriod = true; // Never update manifest
}
Expand Down Expand Up @@ -669,22 +667,22 @@ function MssParser(config) {
adaptations[i].ContentProtection_asArray = manifest.ContentProtection_asArray;
}

// Set minBufferTime
if (adaptations[i].contentType === 'video') {
// Set minBufferTime
manifest.minBufferTime = adaptations[i].SegmentTemplate.SegmentTimeline.S_asArray[0].d / adaptations[i].SegmentTemplate.timescale * 2;
}

if (manifest.type === 'dynamic') {
// Set availabilityStartTime for infinite DVR Window from segment timeline duration
if (manifest.timeShiftBufferDepth === Infinity) {
manifest.availabilityStartTime = new Date(manifestLoadedTime.getTime() - (adaptations[i].SegmentTemplate.SegmentTimeline.duration * 1000));
}
// Match timeShiftBufferDepth to video segment timeline duration
if (manifest.timeShiftBufferDepth > 0 &&
manifest.timeShiftBufferDepth !== Infinity &&
adaptations[i].contentType === 'video' &&
manifest.timeShiftBufferDepth > adaptations[i].SegmentTemplate.SegmentTimeline.duration) {
manifest.timeShiftBufferDepth = adaptations[i].SegmentTemplate.SegmentTimeline.duration;
if (manifest.type === 'dynamic' ) {
// Set availabilityStartTime
segments = adaptations[i].SegmentTemplate.SegmentTimeline.S_asArray;
let endTime = (segments[segments.length - 1].t + segments[segments.length - 1].d) / adaptations[i].SegmentTemplate.timescale * 1000;
manifest.availabilityStartTime = new Date(manifestLoadedTime.getTime() - endTime);

// Match timeShiftBufferDepth to video segment timeline duration
if (manifest.timeShiftBufferDepth > 0 &&
manifest.timeShiftBufferDepth !== Infinity &&
manifest.timeShiftBufferDepth > adaptations[i].SegmentTemplate.SegmentTimeline.duration) {
manifest.timeShiftBufferDepth = adaptations[i].SegmentTemplate.SegmentTimeline.duration;
}
}
}
}
Expand Down Expand Up @@ -742,7 +740,7 @@ function MssParser(config) {
}

// Floor the duration to get around precision differences between segments timestamps and MSE buffer timestamps
// and the avoid 'ended' event not being raised
// and then avoid 'ended' event not being raised
manifest.mediaPresentationDuration = Math.floor(manifest.mediaPresentationDuration * 1000) / 1000;
period.duration = manifest.mediaPresentationDuration;

Expand Down