werift 0.14.2-debug2a → 0.14.4-debug0
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/lib/dtls/src/transport.js +10 -1
- package/lib/dtls/src/transport.js.map +1 -1
- package/lib/ice/src/ice.js +1 -1
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/stun/protocol.js +8 -1
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/transport.js +9 -12
- package/lib/ice/src/transport.js.map +1 -1
- package/lib/rtp/src/rtp/red/encoder.js +6 -1
- package/lib/rtp/src/rtp/red/encoder.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/ctr.js +1 -5
- package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
- package/lib/sctp/src/helper.d.ts +1 -1
- package/lib/sctp/src/helper.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +6 -2
- package/lib/sctp/src/sctp.js +107 -41
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/sctp/src/transport.js +8 -1
- package/lib/sctp/src/transport.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +1 -1
- package/lib/webrtc/src/media/rtpSender.js +6 -6
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/peerConnection.js +5 -1
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +1 -1
- package/lib/webrtc/src/transport/dtls.js +7 -8
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.js +30 -17
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/package.json +18 -20
- package/src/media/rtpSender.ts +9 -6
- package/src/peerConnection.ts +5 -1
- package/src/transport/dtls.ts +7 -7
- package/src/transport/sctp.ts +31 -24
package/lib/sctp/src/sctp.js
CHANGED
|
@@ -96,7 +96,7 @@ class SCTP {
|
|
|
96
96
|
this.timer1Failures = 0;
|
|
97
97
|
this.timer2Failures = 0;
|
|
98
98
|
this.timerReconfigFailures = 0;
|
|
99
|
-
this.send = async (streamId, ppId, userData, expiry = undefined, maxRetransmits
|
|
99
|
+
this.send = async (streamId, ppId, userData, { expiry, maxRetransmits, ordered, } = { expiry: undefined, maxRetransmits: undefined, ordered: true }) => {
|
|
100
100
|
const streamSeqNum = ordered ? this.outboundStreamSeq[streamId] || 0 : 0;
|
|
101
101
|
const fragments = Math.ceil(userData.length / USERDATA_MAX_LENGTH);
|
|
102
102
|
let pos = 0;
|
|
@@ -145,7 +145,11 @@ class SCTP {
|
|
|
145
145
|
this.setState(const_1.SCTP_STATE.CLOSED);
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
148
|
-
setImmediate(() =>
|
|
148
|
+
setImmediate(() => {
|
|
149
|
+
this.sendChunk(this.timer1Chunk).catch((err) => {
|
|
150
|
+
log("send timer1 chunk failed", err.message);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
149
153
|
this.timer1Handle = setTimeout(this.timer1Expired, this.rto * 1000);
|
|
150
154
|
}
|
|
151
155
|
};
|
|
@@ -156,7 +160,11 @@ class SCTP {
|
|
|
156
160
|
this.setState(const_1.SCTP_STATE.CLOSED);
|
|
157
161
|
}
|
|
158
162
|
else {
|
|
159
|
-
setImmediate(() =>
|
|
163
|
+
setImmediate(() => {
|
|
164
|
+
this.sendChunk(this.timer2Chunk).catch((err) => {
|
|
165
|
+
log("send timer2Chunk failed", err.message);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
160
168
|
this.timer2Handle = setTimeout(this.timer2Expired, this.rto * 1000);
|
|
161
169
|
}
|
|
162
170
|
};
|
|
@@ -252,18 +260,24 @@ class SCTP {
|
|
|
252
260
|
sack.advertisedRwnd = Math.max(0, this.advertisedRwnd);
|
|
253
261
|
sack.duplicates = [...this.sackDuplicates];
|
|
254
262
|
sack.gaps = gaps;
|
|
255
|
-
await this.sendChunk(sack)
|
|
263
|
+
await this.sendChunk(sack).catch((err) => {
|
|
264
|
+
log("send sack failed", err.message);
|
|
265
|
+
});
|
|
256
266
|
this.sackDuplicates = [];
|
|
257
267
|
this.sackNeeded = false;
|
|
258
268
|
}
|
|
259
269
|
async receiveChunk(chunk) {
|
|
260
270
|
switch (chunk.type) {
|
|
261
271
|
case chunk_1.DataChunk.type:
|
|
262
|
-
|
|
272
|
+
{
|
|
273
|
+
this.receiveDataChunk(chunk);
|
|
274
|
+
}
|
|
263
275
|
break;
|
|
264
276
|
case chunk_1.InitChunk.type:
|
|
265
|
-
|
|
266
|
-
|
|
277
|
+
{
|
|
278
|
+
if (!this.isServer)
|
|
279
|
+
return;
|
|
280
|
+
const init = chunk;
|
|
267
281
|
log("receive init", init);
|
|
268
282
|
this.lastReceivedTsn = tsnMinusOne(init.initialTsn);
|
|
269
283
|
this.reconfigResponseSeq = tsnMinusOne(init.initialTsn);
|
|
@@ -287,11 +301,15 @@ class SCTP {
|
|
|
287
301
|
]);
|
|
288
302
|
ack.params.push([SCTP_STATE_COOKIE, cookie]);
|
|
289
303
|
log("send initAck", ack);
|
|
290
|
-
await this.sendChunk(ack)
|
|
304
|
+
await this.sendChunk(ack).catch((err) => {
|
|
305
|
+
log("send initAck failed", err.message);
|
|
306
|
+
});
|
|
291
307
|
}
|
|
292
308
|
break;
|
|
293
309
|
case chunk_1.InitAckChunk.type:
|
|
294
|
-
|
|
310
|
+
{
|
|
311
|
+
if (this.associationState != const_1.SCTP_STATE.COOKIE_WAIT)
|
|
312
|
+
return;
|
|
295
313
|
const initAck = chunk;
|
|
296
314
|
this.timer1Cancel();
|
|
297
315
|
this.lastReceivedTsn = tsnMinusOne(initAck.initialTsn);
|
|
@@ -308,42 +326,58 @@ class SCTP {
|
|
|
308
326
|
break;
|
|
309
327
|
}
|
|
310
328
|
}
|
|
311
|
-
await this.sendChunk(echo)
|
|
329
|
+
await this.sendChunk(echo).catch((err) => {
|
|
330
|
+
log("send echo failed", err.message);
|
|
331
|
+
});
|
|
312
332
|
this.timer1Start(echo);
|
|
313
333
|
this.setState(const_1.SCTP_STATE.COOKIE_ECHOED);
|
|
314
334
|
}
|
|
315
335
|
break;
|
|
316
336
|
case chunk_1.SackChunk.type:
|
|
317
|
-
|
|
337
|
+
{
|
|
338
|
+
await this.receiveSackChunk(chunk);
|
|
339
|
+
}
|
|
318
340
|
break;
|
|
319
341
|
case chunk_1.HeartbeatChunk.type:
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
342
|
+
{
|
|
343
|
+
const ack = new chunk_1.HeartbeatAckChunk();
|
|
344
|
+
ack.params = chunk.params;
|
|
345
|
+
await this.sendChunk(ack).catch((err) => {
|
|
346
|
+
log("send heartbeat ack failed", err.message);
|
|
347
|
+
});
|
|
348
|
+
}
|
|
323
349
|
break;
|
|
324
350
|
case chunk_1.AbortChunk.type:
|
|
325
|
-
|
|
351
|
+
{
|
|
352
|
+
this.setState(const_1.SCTP_STATE.CLOSED);
|
|
353
|
+
}
|
|
326
354
|
break;
|
|
327
355
|
case chunk_1.ShutdownChunk.type:
|
|
328
356
|
{
|
|
329
357
|
this.timer2Cancel();
|
|
330
358
|
this.setState(const_1.SCTP_STATE.SHUTDOWN_RECEIVED);
|
|
331
359
|
const ack = new chunk_1.ShutdownAckChunk();
|
|
332
|
-
await this.sendChunk(ack)
|
|
360
|
+
await this.sendChunk(ack).catch((err) => {
|
|
361
|
+
log("send shutdown ack failed", err.message);
|
|
362
|
+
});
|
|
333
363
|
this.t2Start(ack);
|
|
334
364
|
this.setState(const_1.SCTP_STATE.SHUTDOWN_SENT);
|
|
335
365
|
}
|
|
336
366
|
break;
|
|
337
367
|
case chunk_1.ErrorChunk.type:
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
368
|
+
{
|
|
369
|
+
// 3.3.10. Operation Error (ERROR) (9)
|
|
370
|
+
// An Operation Error is not considered fatal in and of itself, but may be
|
|
371
|
+
// used with an ABORT chunk to report a fatal condition. It has the
|
|
372
|
+
// following parameters:
|
|
373
|
+
log("ErrorChunk", chunk.descriptions);
|
|
374
|
+
}
|
|
343
375
|
break;
|
|
344
376
|
case chunk_1.CookieEchoChunk.type:
|
|
345
|
-
|
|
346
|
-
|
|
377
|
+
{
|
|
378
|
+
if (!this.isServer)
|
|
379
|
+
return;
|
|
380
|
+
const data = chunk;
|
|
347
381
|
const cookie = data.body;
|
|
348
382
|
const digest = (0, crypto_1.createHmac)("sha1", this.hmacKey)
|
|
349
383
|
.update(cookie.slice(0, 4))
|
|
@@ -361,29 +395,39 @@ class SCTP {
|
|
|
361
395
|
chunk_1.ErrorChunk.CODE.StaleCookieError,
|
|
362
396
|
Buffer.concat([...Array(8)].map(() => Buffer.from("\x00"))),
|
|
363
397
|
]);
|
|
364
|
-
await this.sendChunk(error)
|
|
398
|
+
await this.sendChunk(error).catch((err) => {
|
|
399
|
+
log("send errorChunk failed", err.message);
|
|
400
|
+
});
|
|
365
401
|
return;
|
|
366
402
|
}
|
|
367
403
|
const ack = new chunk_1.CookieAckChunk();
|
|
368
|
-
await this.sendChunk(ack)
|
|
404
|
+
await this.sendChunk(ack).catch((err) => {
|
|
405
|
+
log("send cookieAck failed", err.message);
|
|
406
|
+
});
|
|
369
407
|
this.setState(const_1.SCTP_STATE.ESTABLISHED);
|
|
370
408
|
}
|
|
371
409
|
break;
|
|
372
410
|
case chunk_1.CookieAckChunk.type:
|
|
373
|
-
|
|
411
|
+
{
|
|
412
|
+
if (this.associationState != const_1.SCTP_STATE.COOKIE_ECHOED)
|
|
413
|
+
return;
|
|
374
414
|
this.timer1Cancel();
|
|
375
415
|
this.setState(const_1.SCTP_STATE.ESTABLISHED);
|
|
376
416
|
}
|
|
377
417
|
break;
|
|
378
418
|
case chunk_1.ShutdownCompleteChunk.type:
|
|
379
|
-
|
|
419
|
+
{
|
|
420
|
+
if (this.associationState != const_1.SCTP_STATE.SHUTDOWN_ACK_SENT)
|
|
421
|
+
return;
|
|
380
422
|
this.timer2Cancel();
|
|
381
423
|
this.setState(const_1.SCTP_STATE.CLOSED);
|
|
382
424
|
}
|
|
383
425
|
break;
|
|
384
426
|
// extensions
|
|
385
427
|
case chunk_1.ReconfigChunk.type:
|
|
386
|
-
|
|
428
|
+
{
|
|
429
|
+
if (this.associationState != const_1.SCTP_STATE.ESTABLISHED)
|
|
430
|
+
return;
|
|
387
431
|
const reconfig = chunk;
|
|
388
432
|
for (const [type, body] of reconfig.params) {
|
|
389
433
|
const target = param_1.RECONFIG_PARAM_BY_TYPES[type];
|
|
@@ -394,7 +438,9 @@ class SCTP {
|
|
|
394
438
|
}
|
|
395
439
|
break;
|
|
396
440
|
case chunk_1.ForwardTsnChunk.type:
|
|
397
|
-
|
|
441
|
+
{
|
|
442
|
+
this.receiveForwardTsnChunk(chunk);
|
|
443
|
+
}
|
|
398
444
|
break;
|
|
399
445
|
}
|
|
400
446
|
}
|
|
@@ -654,7 +700,9 @@ class SCTP {
|
|
|
654
700
|
// """
|
|
655
701
|
// # send FORWARD TSN
|
|
656
702
|
if (this.forwardTsnChunk) {
|
|
657
|
-
await this.sendChunk(this.forwardTsnChunk)
|
|
703
|
+
await this.sendChunk(this.forwardTsnChunk).catch((err) => {
|
|
704
|
+
log("send forwardTsn failed", err.message);
|
|
705
|
+
});
|
|
658
706
|
this.forwardTsnChunk = undefined;
|
|
659
707
|
if (!this.timer3Handle) {
|
|
660
708
|
this.timer3Start();
|
|
@@ -677,7 +725,9 @@ class SCTP {
|
|
|
677
725
|
dataChunk.misses = 0;
|
|
678
726
|
dataChunk.retransmit = false;
|
|
679
727
|
dataChunk.sentCount++;
|
|
680
|
-
await this.sendChunk(dataChunk)
|
|
728
|
+
await this.sendChunk(dataChunk).catch((err) => {
|
|
729
|
+
log("send data failed", err.message);
|
|
730
|
+
});
|
|
681
731
|
if (retransmitEarliest) {
|
|
682
732
|
this.timer3Restart();
|
|
683
733
|
}
|
|
@@ -694,7 +744,9 @@ class SCTP {
|
|
|
694
744
|
// # update counters
|
|
695
745
|
chunk.sentCount++;
|
|
696
746
|
chunk.sentTime = Date.now() / 1000;
|
|
697
|
-
await this.sendChunk(chunk)
|
|
747
|
+
await this.sendChunk(chunk).catch((err) => {
|
|
748
|
+
log("send data outboundQueue failed", err.message);
|
|
749
|
+
});
|
|
698
750
|
if (!this.timer3Handle) {
|
|
699
751
|
this.timer3Start();
|
|
700
752
|
}
|
|
@@ -717,7 +769,9 @@ class SCTP {
|
|
|
717
769
|
log("sendReconfigParam", param);
|
|
718
770
|
const chunk = new chunk_1.ReconfigChunk();
|
|
719
771
|
chunk.params.push([param.type, param.bytes]);
|
|
720
|
-
await this.sendChunk(chunk)
|
|
772
|
+
await this.sendChunk(chunk).catch((err) => {
|
|
773
|
+
log("send reconfig failed", err.message);
|
|
774
|
+
});
|
|
721
775
|
}
|
|
722
776
|
// https://github.com/pion/sctp/pull/44/files
|
|
723
777
|
async sendResetRequest(streamId) {
|
|
@@ -853,10 +907,13 @@ class SCTP {
|
|
|
853
907
|
setRemotePort(port) {
|
|
854
908
|
this.remotePort = port;
|
|
855
909
|
}
|
|
856
|
-
async start() {
|
|
910
|
+
async start(remotePort) {
|
|
857
911
|
if (!this.started) {
|
|
858
912
|
this.started = true;
|
|
859
913
|
this.setConnectionState("connecting");
|
|
914
|
+
if (remotePort) {
|
|
915
|
+
this.setRemotePort(remotePort);
|
|
916
|
+
}
|
|
860
917
|
if (!this.isServer) {
|
|
861
918
|
await this.init();
|
|
862
919
|
}
|
|
@@ -871,10 +928,15 @@ class SCTP {
|
|
|
871
928
|
init.initialTsn = this.localTsn;
|
|
872
929
|
this.setExtensions(init.params);
|
|
873
930
|
log("send init", init);
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
931
|
+
try {
|
|
932
|
+
await this.sendChunk(init);
|
|
933
|
+
// # start T1 timer and enter COOKIE-WAIT state
|
|
934
|
+
this.timer1Start(init);
|
|
935
|
+
this.setState(const_1.SCTP_STATE.COOKIE_WAIT);
|
|
936
|
+
}
|
|
937
|
+
catch (error) {
|
|
938
|
+
log("send init failed", error.message);
|
|
939
|
+
}
|
|
878
940
|
}
|
|
879
941
|
setExtensions(params) {
|
|
880
942
|
const extensions = [];
|
|
@@ -886,10 +948,11 @@ class SCTP {
|
|
|
886
948
|
params.push([SCTP_SUPPORTED_CHUNK_EXT, Buffer.from(extensions)]);
|
|
887
949
|
}
|
|
888
950
|
async sendChunk(chunk) {
|
|
889
|
-
if (this.remotePort === undefined)
|
|
890
|
-
throw new Error("invalid remote port");
|
|
891
951
|
if (this.state === "closed")
|
|
892
952
|
return;
|
|
953
|
+
if (this.remotePort === undefined) {
|
|
954
|
+
throw new Error("invalid remote port");
|
|
955
|
+
}
|
|
893
956
|
const packet = (0, chunk_1.serializePacket)(this.localPort, this.remotePort, this.remoteVerificationTag, chunk);
|
|
894
957
|
await this.transport.send(packet);
|
|
895
958
|
}
|
|
@@ -910,6 +973,7 @@ class SCTP {
|
|
|
910
973
|
}
|
|
911
974
|
setConnectionState(state) {
|
|
912
975
|
this.state = state;
|
|
976
|
+
log("setConnectionState", state);
|
|
913
977
|
this.stateChanged[state].execute();
|
|
914
978
|
}
|
|
915
979
|
async stop() {
|
|
@@ -923,7 +987,9 @@ class SCTP {
|
|
|
923
987
|
}
|
|
924
988
|
async abort() {
|
|
925
989
|
const abort = new chunk_1.AbortChunk();
|
|
926
|
-
await this.sendChunk(abort)
|
|
990
|
+
await this.sendChunk(abort).catch((err) => {
|
|
991
|
+
log("send abort failed", err.message);
|
|
992
|
+
});
|
|
927
993
|
}
|
|
928
994
|
removeAllListeners() {
|
|
929
995
|
Object.values(this.stateChanged).forEach((v) => v.allUnsubscribe());
|