Skip to content

Commit

Permalink
fix: oggopus demuxer breaks when ogg file contains more than one stream
Browse files Browse the repository at this point in the history
  • Loading branch information
amishshah committed Apr 12, 2018
1 parent e357561 commit 4328866
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/demuxers/OggOpus.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class OggOpusDemuxer extends Transform {
super(Object.assign({ readableObjectMode: true }, options));
this._remainder = null;
this._head = null;
this._bitstream = null;
}

_transform(chunk, encoding, done) {
Expand Down Expand Up @@ -60,6 +61,7 @@ class OggOpusDemuxer extends Transform {
const pageSegments = chunk.readUInt8(26);
if (chunk.length < 27 + pageSegments) return false;
const table = chunk.slice(27, 27 + pageSegments);
const bitstream = chunk.readUInt32BE(14);

let sizes = [], totalSize = 0;

Expand All @@ -83,10 +85,11 @@ class OggOpusDemuxer extends Transform {
const header = segment.slice(0, 8);
if (this._head) {
if (header.equals(OPUS_TAGS)) this.emit('tags', segment);
else this.push(segment);
else if (this._bitstream === bitstream) this.push(segment);
} else if (header.equals(OPUS_HEAD)) {
this.emit('head', segment);
this._head = segment;
this._bitstream = bitstream;
} else {
this.emit('unknownSegment', segment);
}
Expand Down

0 comments on commit 4328866

Please sign in to comment.