Skip to content

Commit

Permalink
fix header extensions in RTCRtpSender
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyoshiaki committed Dec 13, 2023
1 parent 02cf711 commit 2717adc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/webrtc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "werift",
"version": "0.18.15",
"version": "0.18.16",
"description": "WebRTC Implementation for TypeScript (Node.js)",
"keywords": [
"WebRTC",
Expand Down
10 changes: 10 additions & 0 deletions packages/webrtc/src/media/rtpSender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ export class RTCRtpSender {

const ntpTimestamp = ntpTime();

const originalHeaderExtensions = [...header.extensions];
header.extensions = this.headerExtensions
.map((extension) => {
const payload = (() => {
Expand Down Expand Up @@ -364,6 +365,15 @@ export class RTCRtpSender {
if (payload) return { id: extension.id, payload };
})
.filter((v) => v) as Extension[];
for (const ext of originalHeaderExtensions) {
const exist = header.extensions.find((v) => v.id === ext.id);
if (exist) {
exist.payload = ext.payload;
} else {
header.extensions.push(ext);
}
}
header.extensions = header.extensions.sort((a, b) => a.id - b.id);

this.ntpTimestamp = ntpTimestamp;
this.rtpTimestamp = header.timestamp;
Expand Down

0 comments on commit 2717adc

Please sign in to comment.