Skip to content

Commit b558849

Browse files
authored
Merge pull request #267 from koush/replace-rtp-discontinuity
replace rtp option to signal the stream contains a discontunity
2 parents 6db9f9f + a9f6840 commit b558849

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/webrtc/src/media/rtpSender.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,24 @@ export class RTCRtpSender {
283283
} catch (error) {}
284284
}
285285

286-
replaceRTP({
287-
sequenceNumber,
288-
timestamp,
289-
}: Pick<RtpHeader, "sequenceNumber" | "timestamp">) {
286+
replaceRTP(
287+
{
288+
sequenceNumber,
289+
timestamp,
290+
}: Pick<RtpHeader, "sequenceNumber" | "timestamp">,
291+
discontinuity = false
292+
) {
290293
if (this.sequenceNumber != undefined) {
291294
this.seqOffset = uint16Add(this.sequenceNumber, -sequenceNumber);
295+
if (discontinuity) {
296+
this.seqOffset = uint16Add(this.seqOffset, 2);
297+
}
292298
}
293299
if (this.timestamp != undefined) {
294300
this.timestampOffset = uint32Add(this.timestamp, -timestamp);
301+
if (discontinuity) {
302+
this.timestampOffset = uint16Add(this.timestampOffset, 1);
303+
}
295304
}
296305
this.rtpCache = [];
297306
log("replaceRTP", this.sequenceNumber, sequenceNumber, this.seqOffset);

0 commit comments

Comments
 (0)