Skip to content

Commit

Permalink
fix: Fix implementation of AAC and MP3 transmuxers (#5296)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Jun 13, 2023
1 parent d4dca2a commit df18f10
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/transmuxer/aac_transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ shaka.transmuxer.AacTransmuxer = class {
* @export
*/
destroy() {
// Nothing
this.initSegments.clear();
}


Expand Down
16 changes: 10 additions & 6 deletions lib/transmuxer/mp3_transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ shaka.transmuxer.Mp3Transmuxer = class {
/** @private {number} */
this.frameIndex_ = 0;

/** @private {?Uint8Array} */
this.initSegment = null;
/** @private {!Map.<number, !Uint8Array>} */
this.initSegments = new Map();
}


Expand All @@ -42,7 +42,7 @@ shaka.transmuxer.Mp3Transmuxer = class {
* @export
*/
destroy() {
// Nothing
this.initSegments.clear();
}


Expand Down Expand Up @@ -179,13 +179,17 @@ shaka.transmuxer.Mp3Transmuxer = class {
stream: stream,
};
const mp4Generator = new shaka.util.Mp4Generator(streamInfo);
if (!this.initSegment) {
this.initSegment = mp4Generator.initSegment();
let initSegment;
if (!this.initSegments.has(stream.id)) {
initSegment = mp4Generator.initSegment();
this.initSegments.set(stream.id, initSegment);
} else {
initSegment = this.initSegments.get(stream.id);
}
const segmentData = mp4Generator.segmentData();

this.frameIndex_++;
const transmuxData = Uint8ArrayUtils.concat(this.initSegment, segmentData);
const transmuxData = Uint8ArrayUtils.concat(initSegment, segmentData);
return Promise.resolve(transmuxData);
}
};
Expand Down

0 comments on commit df18f10

Please sign in to comment.