Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 4 additions & 12 deletions src/demux/transmuxer-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,10 @@ export default class TransmuxerInterface {
snDiff === 0 &&
chunkMeta.id > 1 &&
chunkMeta.id === lastFrag?.stats.chunkCount;
const nextInSequence =
snDiff === 1 ||
(snDiff === 0 && (partDiff === 1 || (progressive && partDiff <= 0)));
const contiguous = !trackSwitch && nextInSequence;
const consecutive =
nextInSequence ||
(trackSwitch &&
lastFrag !== null &&
Math.abs(timeOffset - (this.part ? this.part.end : lastFrag.end)) <=
this.hls.config.maxFragLookUpTolerance);
const contiguous =
!trackSwitch &&
(snDiff === 1 ||
(snDiff === 0 && (partDiff === 1 || (progressive && partDiff <= 0))));
const now = self.performance.now();

if (trackSwitch || snDiff || frag.stats.parsing.start === 0) {
Expand All @@ -238,7 +232,6 @@ export default class TransmuxerInterface {
trackSwitch,
timeOffset,
initSegmentChange,
consecutive,
);
if (!contiguous || discontinuity || initSegmentChange) {
this.hls.logger
Expand All @@ -248,7 +241,6 @@ export default class TransmuxerInterface {
discontinuity: ${discontinuity}
trackSwitch: ${trackSwitch}
contiguous: ${contiguous}
consecutive: ${consecutive}
accurateTimeOffset: ${accurateTimeOffset}
timeOffset: ${timeOffset}
initSegmentChange: ${initSegmentChange}`);
Expand Down
14 changes: 3 additions & 11 deletions src/demux/transmuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export default class Transmuxer {

const {
contiguous,
consecutive,
discontinuity,
trackSwitch,
accurateTimeOffset,
Expand Down Expand Up @@ -182,7 +181,7 @@ export default class Transmuxer {
}

if (discontinuity || initSegmentChange || resetMuxers) {
this.resetInitialTimestamp(defaultInitPts, consecutive);
this.resetInitialTimestamp(defaultInitPts);
}

if (!contiguous) {
Expand All @@ -201,7 +200,6 @@ export default class Transmuxer {
const currentState = this.currentTransmuxState;

currentState.contiguous = true;
currentState.consecutive = true;
currentState.discontinuity = false;
currentState.trackSwitch = false;

Expand Down Expand Up @@ -306,16 +304,13 @@ export default class Transmuxer {
chunkMeta.transmuxing.executeEnd = now();
}

resetInitialTimestamp(
defaultInitPts: TimestampOffset | null,
consecutive: boolean = false,
) {
resetInitialTimestamp(defaultInitPts: TimestampOffset | null) {
const { demuxer, remuxer } = this;
if (!demuxer || !remuxer) {
return;
}
demuxer.resetTimeStamp(defaultInitPts);
remuxer.resetTimeStamp(defaultInitPts, consecutive);
remuxer.resetTimeStamp(defaultInitPts);
}

resetContiguity() {
Expand Down Expand Up @@ -575,7 +570,6 @@ export class TransmuxState {
public trackSwitch: boolean;
public timeOffset: number;
public initSegmentChange: boolean;
public consecutive: boolean;

constructor(
discontinuity: boolean,
Expand All @@ -584,14 +578,12 @@ export class TransmuxState {
trackSwitch: boolean,
timeOffset: number,
initSegmentChange: boolean,
consecutive: boolean = contiguous,
) {
this.discontinuity = discontinuity;
this.contiguous = contiguous;
this.accurateTimeOffset = accurateTimeOffset;
this.trackSwitch = trackSwitch;
this.timeOffset = timeOffset;
this.initSegmentChange = initSegmentChange;
this.consecutive = consecutive;
}
}
11 changes: 3 additions & 8 deletions src/remux/mp4-remuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export default class MP4Remuxer extends Logger implements Remuxer {
private _initDTS: TimestampOffset | null = null;
private nextVideoTs: number | null = null;
private nextAudioTs: number | null = null;
private isConsecutive: boolean = false;
private videoSampleDuration: number | null = null;
private isAudioContiguous: boolean = false;
private isVideoContiguous: boolean = false;
Expand Down Expand Up @@ -105,10 +104,7 @@ export default class MP4Remuxer extends Logger implements Remuxer {
this.config = this.videoTrackConfig = this._initPTS = this._initDTS = null;
}

resetTimeStamp(
defaultTimeStamp: TimestampOffset | null,
consecutive: boolean = false,
) {
resetTimeStamp(defaultTimeStamp: TimestampOffset | null) {
const initPTS = this._initPTS;
if (
!initPTS ||
Expand All @@ -119,11 +115,10 @@ export default class MP4Remuxer extends Logger implements Remuxer {
defaultTimeStamp.timescale !== initPTS.timescale
) {
this.log(
`Reset initPTS: ${initPTS ? timestampToString(initPTS) : initPTS} > ${defaultTimeStamp ? timestampToString(defaultTimeStamp) : defaultTimeStamp} consecutive: ${consecutive}`,
`Reset initPTS: ${initPTS ? timestampToString(initPTS) : initPTS} > ${defaultTimeStamp ? timestampToString(defaultTimeStamp) : defaultTimeStamp}`,
);
}

this.isConsecutive = consecutive;
this._initPTS = this._initDTS = defaultTimeStamp;
}

Expand Down Expand Up @@ -492,7 +487,7 @@ export default class MP4Remuxer extends Logger implements Remuxer {
initDTS = Math.min(initDTS as number, videoInitDTS);
// Bind initPTS to the lowest DTS across tracks to prevent negative timestamps
const videoInit =
!_initPTS && this.isConsecutive ? videoInitPTS : videoInitDTS;
!_initPTS && this.isVideoContiguous ? videoInitPTS : videoInitDTS;
initPTS = Math.min(initPTS as number, videoInit);
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/types/remuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ export interface Remuxer {
videoCodec: string | undefined,
decryptdata: DecryptData | null,
): void;
resetTimeStamp(
defaultInitPTS: TimestampOffset | null,
consecutive?: boolean,
): void;
resetTimeStamp(defaultInitPTS: TimestampOffset | null): void;
resetNextTimestamp(): void;
destroy(): void;
}
Expand Down
Loading
Loading