werift 0.14.1-debug → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/media/rtpSender.ts +17 -40
package/package.json
CHANGED
package/src/media/rtpSender.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
GenericNack,
|
|
17
17
|
PictureLossIndication,
|
|
18
18
|
ReceiverEstimatedMaxBitrate,
|
|
19
|
-
|
|
19
|
+
RedEncoder,
|
|
20
20
|
RtcpPacket,
|
|
21
21
|
RtcpPayloadSpecificFeedback,
|
|
22
22
|
RtcpRrPacket,
|
|
@@ -71,7 +71,8 @@ export class RTCRtpSender {
|
|
|
71
71
|
private rtxPayloadType?: number;
|
|
72
72
|
private rtxSequenceNumber = random16();
|
|
73
73
|
redRedundantPayloadType?: number;
|
|
74
|
-
|
|
74
|
+
private _redDistance = 2;
|
|
75
|
+
redEncoder = new RedEncoder(this._redDistance);
|
|
75
76
|
private headerExtensions: RTCRtpHeaderExtensionParameters[] = [];
|
|
76
77
|
private disposeTrack?: () => void;
|
|
77
78
|
|
|
@@ -115,6 +116,14 @@ export class RTCRtpSender {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
get redDistance() {
|
|
120
|
+
return this._redDistance;
|
|
121
|
+
}
|
|
122
|
+
set redDistance(n: number) {
|
|
123
|
+
this._redDistance = n;
|
|
124
|
+
this.redEncoder.distance = n;
|
|
125
|
+
}
|
|
126
|
+
|
|
118
127
|
prepareSend(params: RTCRtpSendParameters) {
|
|
119
128
|
this.cname = params.rtcp?.cname;
|
|
120
129
|
this.mid = params.muxId;
|
|
@@ -327,20 +336,12 @@ export class RTCRtpSender {
|
|
|
327
336
|
let rtpPayload = rtp.payload;
|
|
328
337
|
|
|
329
338
|
if (this.redRedundantPayloadType) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
);
|
|
337
|
-
})
|
|
338
|
-
.filter((p): p is NonNullable<typeof p> => typeof p !== "undefined");
|
|
339
|
-
const red = buildRedPacket(
|
|
340
|
-
redundantPackets,
|
|
341
|
-
this.redRedundantPayloadType,
|
|
342
|
-
rtp
|
|
343
|
-
);
|
|
339
|
+
this.redEncoder.push({
|
|
340
|
+
block: rtpPayload,
|
|
341
|
+
timestamp: header.timestamp,
|
|
342
|
+
blockPT: this.redRedundantPayloadType,
|
|
343
|
+
});
|
|
344
|
+
const red = this.redEncoder.build();
|
|
344
345
|
rtpPayload = red.serialize();
|
|
345
346
|
}
|
|
346
347
|
|
|
@@ -462,27 +463,3 @@ export function wrapRtx(
|
|
|
462
463
|
);
|
|
463
464
|
return rtx;
|
|
464
465
|
}
|
|
465
|
-
|
|
466
|
-
export function buildRedPacket(
|
|
467
|
-
redundantPackets: RtpPacket[],
|
|
468
|
-
blockPT: number,
|
|
469
|
-
presentPacket: RtpPacket
|
|
470
|
-
) {
|
|
471
|
-
const red = new Red();
|
|
472
|
-
redundantPackets.forEach((redundant) => {
|
|
473
|
-
red.blocks.push({
|
|
474
|
-
block: redundant.payload,
|
|
475
|
-
blockPT,
|
|
476
|
-
timestampOffset: uint32Add(
|
|
477
|
-
presentPacket.header.timestamp,
|
|
478
|
-
-redundant.header.timestamp
|
|
479
|
-
),
|
|
480
|
-
});
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
red.blocks.push({
|
|
484
|
-
block: presentPacket.payload,
|
|
485
|
-
blockPT,
|
|
486
|
-
});
|
|
487
|
-
return red;
|
|
488
|
-
}
|