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

Fix transition from live to static #3748

Merged
merged 1 commit into from
Sep 2, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/dash/DashHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function DashHandler(config) {
}
}

function lastSegmentRequested(representation, bufferingTime) {
function isLastSegmentRequested(representation, bufferingTime) {
if (!representation || !lastSegment) {
return false;
}
Expand Down Expand Up @@ -314,7 +314,7 @@ function DashHandler(config) {
getSegmentRequestForTime,
getCurrentIndex,
getNextSegmentRequest,
lastSegmentRequested,
isLastSegmentRequested,
reset,
getNextSegmentRequestIdempotent
};
Expand Down
42 changes: 23 additions & 19 deletions src/streaming/StreamProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,22 +405,6 @@ function StreamProcessor(config) {

let request = null;

const representation = representationController.getCurrentRepresentation();
const lastSegmentRequested = dashHandler.lastSegmentRequested(representation, bufferingTime);

// Check if the media is finished. If so, no need to schedule another request
if (lastSegmentRequested) {
const segmentIndex = dashHandler.getCurrentIndex();
logger.debug(`Segment requesting for stream ${streamInfo.id} has finished`);
eventBus.trigger(Events.STREAM_REQUESTING_COMPLETED, { segmentIndex }, {
streamId: streamInfo.id,
mediaType: type
});
bufferController.segmentRequestingCompleted(segmentIndex);
scheduleController.clearScheduleTimer();
return;
}

// Don't schedule next fragments while pruning to avoid buffer inconsistencies
if (!bufferController.getIsPruningInProgress()) {
request = _getFragmentRequest();
Expand All @@ -442,9 +426,29 @@ function StreamProcessor(config) {
logger.warn(`Fragment request url ${request.url} for stream id ${streamInfo.id} and media type ${type} is on the ignore list and will be skipped`);
_noValidRequest();
}
} else if (rescheduleIfNoRequest) {
// Use case - Playing at the bleeding live edge and frag is not available yet. Cycle back around.
_noValidRequest();
}
else {
// Check if the media is finished. If so, no need to schedule another request
const representation = representationController.getCurrentRepresentation();
const isLastSegmentRequested = dashHandler.isLastSegmentRequested(representation, bufferingTime);

if (isLastSegmentRequested) {
const segmentIndex = dashHandler.getCurrentIndex();
logger.debug(`Segment requesting for stream ${streamInfo.id} has finished`);
eventBus.trigger(Events.STREAM_REQUESTING_COMPLETED, { segmentIndex }, {
streamId: streamInfo.id,
mediaType: type
});
bufferController.segmentRequestingCompleted(segmentIndex);
scheduleController.clearScheduleTimer();
return;
}

// Reschedule
if (rescheduleIfNoRequest) {
// Use case - Playing at the bleeding live edge and frag is not available yet. Cycle back around.
_noValidRequest();
}
}
}

Expand Down