Skip to content
Open
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
20 changes: 19 additions & 1 deletion www/video-rtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,10 @@ export class VideoRTC extends HTMLElement {
sb.appendBuffer(data);
bufLen = 0;
} catch (e) {
// console.debug(e);
// A failed appendBuffer starts no update cycle, so updateend
// never fires again and this drain is never re-entered. Clear
// the backlog instead of wedging it forever.
bufLen = 0;
}
}

Expand All @@ -487,6 +490,21 @@ export class VideoRTC extends HTMLElement {
this.ondata = data => {
if (sb.updating || bufLen > 0) {
const b = new Uint8Array(data);
if (bufLen + b.byteLength > buf.byteLength) {
// Staging buffer full because the SourceBuffer stopped draining.
// Drop the backlog and try to restart the update cycle, instead
// of throwing RangeError on every frame that follows.
bufLen = 0;
if (b.byteLength > buf.byteLength) return;
if (!sb.updating) {
try {
sb.appendBuffer(b);
} catch (e) {
// console.debug(e);
}
return;
}
}
buf.set(b, bufLen);
bufLen += b.byteLength;
// console.debug('VideoRTC.buffer', b.byteLength, bufLen);
Expand Down