Skip to content

Commit

Permalink
fix(Transmuxer): Fix init segment between discontinuities (#7042)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Jul 16, 2024
1 parent d1435c7 commit 6850f68
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
9 changes: 5 additions & 4 deletions lib/transmuxer/aac_transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ shaka.transmuxer.AacTransmuxer = class {
/** @private {number} */
this.frameIndex_ = 0;

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

Expand Down Expand Up @@ -208,11 +208,12 @@ shaka.transmuxer.AacTransmuxer = class {
};
const mp4Generator = new shaka.util.Mp4Generator([streamInfo]);
let initSegment;
if (!this.initSegments.has(stream.id)) {
const initSegmentKey = stream.id + '_' + reference.discontinuitySequence;
if (!this.initSegments.has(initSegmentKey)) {
initSegment = mp4Generator.initSegment();
this.initSegments.set(stream.id, initSegment);
this.initSegments.set(initSegmentKey, initSegment);
} else {
initSegment = this.initSegments.get(stream.id);
initSegment = this.initSegments.get(initSegmentKey);
}
const segmentData = mp4Generator.segmentData();

Expand Down
9 changes: 5 additions & 4 deletions lib/transmuxer/ac3_transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ shaka.transmuxer.Ac3Transmuxer = class {
/** @private {number} */
this.frameIndex_ = 0;

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

Expand Down Expand Up @@ -196,11 +196,12 @@ shaka.transmuxer.Ac3Transmuxer = class {
};
const mp4Generator = new shaka.util.Mp4Generator([streamInfo]);
let initSegment;
if (!this.initSegments.has(stream.id)) {
const initSegmentKey = stream.id + '_' + reference.discontinuitySequence;
if (!this.initSegments.has(initSegmentKey)) {
initSegment = mp4Generator.initSegment();
this.initSegments.set(stream.id, initSegment);
this.initSegments.set(initSegmentKey, initSegment);
} else {
initSegment = this.initSegments.get(stream.id);
initSegment = this.initSegments.get(initSegmentKey);
}
const segmentData = mp4Generator.segmentData();

Expand Down
9 changes: 5 additions & 4 deletions lib/transmuxer/ec3_transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ shaka.transmuxer.Ec3Transmuxer = class {
/** @private {number} */
this.frameIndex_ = 0;

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

Expand Down Expand Up @@ -196,11 +196,12 @@ shaka.transmuxer.Ec3Transmuxer = class {
};
const mp4Generator = new shaka.util.Mp4Generator([streamInfo]);
let initSegment;
if (!this.initSegments.has(stream.id)) {
const initSegmentKey = stream.id + '_' + reference.discontinuitySequence;
if (!this.initSegments.has(initSegmentKey)) {
initSegment = mp4Generator.initSegment();
this.initSegments.set(stream.id, initSegment);
this.initSegments.set(initSegmentKey, initSegment);
} else {
initSegment = this.initSegments.get(stream.id);
initSegment = this.initSegments.get(initSegmentKey);
}
const segmentData = mp4Generator.segmentData();

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

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

Expand Down Expand Up @@ -189,11 +189,12 @@ shaka.transmuxer.Mp3Transmuxer = class {
};
const mp4Generator = new shaka.util.Mp4Generator([streamInfo]);
let initSegment;
if (!this.initSegments.has(stream.id)) {
const initSegmentKey = stream.id + '_' + reference.discontinuitySequence;
if (!this.initSegments.has(initSegmentKey)) {
initSegment = mp4Generator.initSegment();
this.initSegments.set(stream.id, initSegment);
this.initSegments.set(initSegmentKey, initSegment);
} else {
initSegment = this.initSegments.get(stream.id);
initSegment = this.initSegments.get(initSegmentKey);
}
const segmentData = mp4Generator.segmentData();

Expand Down
9 changes: 5 additions & 4 deletions lib/transmuxer/ts_transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ shaka.transmuxer.TsTransmuxer = class {
/** @private {number} */
this.frameIndex_ = 0;

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

/** @private {?shaka.util.TsParser} */
Expand Down Expand Up @@ -286,11 +286,12 @@ shaka.transmuxer.TsTransmuxer = class {

const mp4Generator = new shaka.util.Mp4Generator(streamInfos);
let initSegment;
if (!this.initSegments.has(stream.id)) {
const initSegmentKey = stream.id + '_' + reference.discontinuitySequence;
if (!this.initSegments.has(initSegmentKey)) {
initSegment = mp4Generator.initSegment();
this.initSegments.set(stream.id, initSegment);
this.initSegments.set(initSegmentKey, initSegment);
} else {
initSegment = this.initSegments.get(stream.id);
initSegment = this.initSegments.get(initSegmentKey);
}
const segmentData = mp4Generator.segmentData();

Expand Down

0 comments on commit 6850f68

Please sign in to comment.