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: allow the playback on platforms when low latency APIs are not supported #4485

Merged
merged 4 commits into from
Sep 22, 2022
Merged
Changes from 1 commit
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
31 changes: 30 additions & 1 deletion lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,13 @@ shaka.media.StreamingEngine = class {
if (this.config_.lowLatencyMode && isReadableStreamSupported && isMP4 &&
!reference.hlsAes128Key) {
let remaining = new Uint8Array(0);
let processingResult = false;
let callbackCalled = false;
const streamDataCallback = async (data) => {
if (processingResult) {
avelad marked this conversation as resolved.
Show resolved Hide resolved
return;
}
callbackCalled = true;
this.destroyer_.ensureNotDestroyed();
if (this.fatalError_) {
return;
Expand Down Expand Up @@ -1271,7 +1277,30 @@ shaka.media.StreamingEngine = class {
}
};

await this.fetch_(mediaState, reference, streamDataCallback);
const result =
await this.fetch_(mediaState, reference, streamDataCallback);
if (!callbackCalled) {
avelad marked this conversation as resolved.
Show resolved Hide resolved
processingResult = true;
this.destroyer_.ensureNotDestroyed();
if (this.fatalError_) {
return;
}

// If the text stream gets switched between fetch_() and append_(),
// the new text parser is initialized, but the new init segment is
// not fetched yet. That would cause an error in
// TextParser.parseMedia().
// See http://b/168253400
if (mediaState.waitingToClearBuffer) {
shaka.log.info(logPrefix, 'waitingToClearBuffer, skip append');
mediaState.performingUpdate = false;
this.scheduleUpdate_(mediaState, 0);
return;
}

await this.append_(
mediaState, presentationTime, stream, reference, result);
}
} else {
if (this.config_.lowLatencyMode && !isReadableStreamSupported) {
shaka.log.warning('Low latency streaming mode is enabled, but ' +
Expand Down