mediasoup-client 3.6.93 → 3.6.95
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/Transport.js +7 -7
- package/lib/handlers/Chrome111.d.ts +2 -0
- package/lib/handlers/Chrome111.d.ts.map +1 -1
- package/lib/handlers/Chrome111.js +35 -0
- package/lib/handlers/Chrome74.d.ts +2 -0
- package/lib/handlers/Chrome74.d.ts.map +1 -1
- package/lib/handlers/Chrome74.js +34 -0
- package/lib/handlers/FakeHandler.d.ts +2 -0
- package/lib/handlers/FakeHandler.d.ts.map +1 -1
- package/lib/handlers/FakeHandler.js +35 -2
- package/lib/handlers/Firefox60.d.ts +2 -0
- package/lib/handlers/Firefox60.d.ts.map +1 -1
- package/lib/handlers/Firefox60.js +34 -0
- package/lib/handlers/ReactNativeUnifiedPlan.d.ts +2 -0
- package/lib/handlers/ReactNativeUnifiedPlan.d.ts.map +1 -1
- package/lib/handlers/ReactNativeUnifiedPlan.js +35 -0
- package/lib/handlers/Safari12.d.ts +2 -0
- package/lib/handlers/Safari12.d.ts.map +1 -1
- package/lib/handlers/Safari12.js +35 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +1 -0
- package/npm-scripts.mjs +1 -2
- package/package.json +9 -9
|
@@ -3,6 +3,7 @@ import { IceParameters } from '../Transport';
|
|
|
3
3
|
import { RtpCapabilities } from '../RtpParameters';
|
|
4
4
|
import { SctpCapabilities } from '../SctpParameters';
|
|
5
5
|
export declare class Firefox60 extends HandlerInterface {
|
|
6
|
+
private _closed;
|
|
6
7
|
private _direction?;
|
|
7
8
|
private _remoteSdp?;
|
|
8
9
|
private _sendingRtpParametersByKind?;
|
|
@@ -42,6 +43,7 @@ export declare class Firefox60 extends HandlerInterface {
|
|
|
42
43
|
getReceiverStats(localId: string): Promise<RTCStatsReport>;
|
|
43
44
|
receiveDataChannel({ sctpStreamParameters, label, protocol }: HandlerReceiveDataChannelOptions): Promise<HandlerReceiveDataChannelResult>;
|
|
44
45
|
private setupTransport;
|
|
46
|
+
private assertNotClosed;
|
|
45
47
|
private assertSendDirection;
|
|
46
48
|
private assertRecvDirection;
|
|
47
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Firefox60.d.ts","sourceRoot":"","sources":["../../src/handlers/Firefox60.ts"],"names":[],"mappings":"AAOA,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,EAC7B,4BAA4B,EAC5B,gCAAgC,EAChC,+BAA+B,EAC/B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,aAAa,EAAY,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,eAAe,EAAiB,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAM3E,qBAAa,SAAU,SAAQ,gBAAgB;IAG9C,OAAO,CAAC,UAAU,CAAC,CAAkB;IAErC,OAAO,CAAC,UAAU,CAAC,CAAY;IAE/B,OAAO,CAAC,2BAA2B,CAAC,CAAmC;IAGvE,OAAO,CAAC,iCAAiC,CAAC,CAAmC;IAE7E,OAAO,CAAC,GAAG,CAAM;IAEjB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CACxB;IAEX,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IAEjD,OAAO,CAAC,2BAA2B,CAAS;IAE5C,OAAO,CAAC,qBAAqB,CAAK;IAElC,OAAO,CAAC,eAAe,CAAS;IAEhC;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI,cAAc;;IAUtC,IAAI,IAAI,IAAI,MAAM,CAGjB;IAED,KAAK,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"Firefox60.d.ts","sourceRoot":"","sources":["../../src/handlers/Firefox60.ts"],"names":[],"mappings":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EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqClD,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAc1D,kBAAkB,CACvB,EAAE,oBAAoB,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,gCAAgC,GACzE,OAAO,CAAC,+BAA+B,CAAC;YA6D7B,cAAc;IAyC5B,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,mBAAmB;CAQ3B"}
|
|
@@ -45,6 +45,8 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
45
45
|
}
|
|
46
46
|
constructor() {
|
|
47
47
|
super();
|
|
48
|
+
// Closed flag.
|
|
49
|
+
this._closed = false;
|
|
48
50
|
// Map of RTCTransceivers indexed by MID.
|
|
49
51
|
this._mapMidTransceiver = new Map();
|
|
50
52
|
// Local stream for sending.
|
|
@@ -61,6 +63,10 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
61
63
|
}
|
|
62
64
|
close() {
|
|
63
65
|
logger.debug('close()');
|
|
66
|
+
if (this._closed) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this._closed = true;
|
|
64
70
|
// Close RTCPeerConnection.
|
|
65
71
|
if (this._pc) {
|
|
66
72
|
try {
|
|
@@ -134,6 +140,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
134
140
|
};
|
|
135
141
|
}
|
|
136
142
|
run({ direction, iceParameters, iceCandidates, dtlsParameters, sctpParameters, iceServers, iceTransportPolicy, additionalSettings, proprietaryConstraints, extendedRtpCapabilities }) {
|
|
143
|
+
this.assertNotClosed();
|
|
137
144
|
logger.debug('run()');
|
|
138
145
|
this._direction = direction;
|
|
139
146
|
this._remoteSdp = new RemoteSdp_1.RemoteSdp({
|
|
@@ -190,10 +197,12 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
190
197
|
}
|
|
191
198
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
192
199
|
async updateIceServers(iceServers) {
|
|
200
|
+
this.assertNotClosed();
|
|
193
201
|
// NOTE: Firefox does not implement pc.setConfiguration().
|
|
194
202
|
throw new errors_1.UnsupportedError('not supported');
|
|
195
203
|
}
|
|
196
204
|
async restartIce(iceParameters) {
|
|
205
|
+
this.assertNotClosed();
|
|
197
206
|
logger.debug('restartIce()');
|
|
198
207
|
// Provide the remote SDP handler with new remote ICE parameters.
|
|
199
208
|
this._remoteSdp.updateIceParameters(iceParameters);
|
|
@@ -218,9 +227,11 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
218
227
|
}
|
|
219
228
|
}
|
|
220
229
|
async getTransportStats() {
|
|
230
|
+
this.assertNotClosed();
|
|
221
231
|
return this._pc.getStats();
|
|
222
232
|
}
|
|
223
233
|
async send({ track, encodings, codecOptions, codec }) {
|
|
234
|
+
this.assertNotClosed();
|
|
224
235
|
this.assertSendDirection();
|
|
225
236
|
logger.debug('send() [kind:%s, track.id:%s]', track.kind, track.id);
|
|
226
237
|
if (encodings) {
|
|
@@ -324,7 +335,11 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
324
335
|
};
|
|
325
336
|
}
|
|
326
337
|
async stopSending(localId) {
|
|
338
|
+
this.assertSendDirection();
|
|
327
339
|
logger.debug('stopSending() [localId:%s]', localId);
|
|
340
|
+
if (this._closed) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
328
343
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
329
344
|
if (!transceiver) {
|
|
330
345
|
throw new Error('associated transceiver not found');
|
|
@@ -353,6 +368,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
353
368
|
}
|
|
354
369
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
355
370
|
async pauseSending(localId) {
|
|
371
|
+
this.assertNotClosed();
|
|
356
372
|
this.assertSendDirection();
|
|
357
373
|
logger.debug('pauseSending() [localId:%s]', localId);
|
|
358
374
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -370,6 +386,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
370
386
|
}
|
|
371
387
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
372
388
|
async resumeSending(localId) {
|
|
389
|
+
this.assertNotClosed();
|
|
373
390
|
this.assertSendDirection();
|
|
374
391
|
logger.debug('resumeSending() [localId:%s]', localId);
|
|
375
392
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -386,6 +403,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
386
403
|
await this._pc.setRemoteDescription(answer);
|
|
387
404
|
}
|
|
388
405
|
async replaceTrack(localId, track) {
|
|
406
|
+
this.assertNotClosed();
|
|
389
407
|
this.assertSendDirection();
|
|
390
408
|
if (track) {
|
|
391
409
|
logger.debug('replaceTrack() [localId:%s, track.id:%s]', localId, track.id);
|
|
@@ -400,6 +418,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
400
418
|
await transceiver.sender.replaceTrack(track);
|
|
401
419
|
}
|
|
402
420
|
async setMaxSpatialLayer(localId, spatialLayer) {
|
|
421
|
+
this.assertNotClosed();
|
|
403
422
|
this.assertSendDirection();
|
|
404
423
|
logger.debug('setMaxSpatialLayer() [localId:%s, spatialLayer:%s]', localId, spatialLayer);
|
|
405
424
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -428,6 +447,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
428
447
|
await this._pc.setRemoteDescription(answer);
|
|
429
448
|
}
|
|
430
449
|
async setRtpEncodingParameters(localId, params) {
|
|
450
|
+
this.assertNotClosed();
|
|
431
451
|
this.assertSendDirection();
|
|
432
452
|
logger.debug('setRtpEncodingParameters() [localId:%s, params:%o]', localId, params);
|
|
433
453
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -448,6 +468,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
448
468
|
await this._pc.setRemoteDescription(answer);
|
|
449
469
|
}
|
|
450
470
|
async getSenderStats(localId) {
|
|
471
|
+
this.assertNotClosed();
|
|
451
472
|
this.assertSendDirection();
|
|
452
473
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
453
474
|
if (!transceiver) {
|
|
@@ -456,6 +477,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
456
477
|
return transceiver.sender.getStats();
|
|
457
478
|
}
|
|
458
479
|
async sendDataChannel({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol }) {
|
|
480
|
+
this.assertNotClosed();
|
|
459
481
|
this.assertSendDirection();
|
|
460
482
|
const options = {
|
|
461
483
|
negotiated: true,
|
|
@@ -499,6 +521,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
499
521
|
async receive(
|
|
500
522
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
501
523
|
optionsList) {
|
|
524
|
+
this.assertNotClosed();
|
|
502
525
|
this.assertRecvDirection();
|
|
503
526
|
const results = [];
|
|
504
527
|
const mapLocalId = new Map();
|
|
@@ -558,6 +581,9 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
558
581
|
}
|
|
559
582
|
async stopReceiving(localIds) {
|
|
560
583
|
this.assertRecvDirection();
|
|
584
|
+
if (this._closed) {
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
561
587
|
for (const localId of localIds) {
|
|
562
588
|
logger.debug('stopReceiving() [localId:%s]', localId);
|
|
563
589
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -577,6 +603,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
577
603
|
}
|
|
578
604
|
}
|
|
579
605
|
async pauseReceiving(localIds) {
|
|
606
|
+
this.assertNotClosed();
|
|
580
607
|
this.assertRecvDirection();
|
|
581
608
|
for (const localId of localIds) {
|
|
582
609
|
logger.debug('pauseReceiving() [localId:%s]', localId);
|
|
@@ -595,6 +622,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
595
622
|
await this._pc.setLocalDescription(answer);
|
|
596
623
|
}
|
|
597
624
|
async resumeReceiving(localIds) {
|
|
625
|
+
this.assertNotClosed();
|
|
598
626
|
this.assertRecvDirection();
|
|
599
627
|
for (const localId of localIds) {
|
|
600
628
|
logger.debug('resumeReceiving() [localId:%s]', localId);
|
|
@@ -621,6 +649,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
621
649
|
return transceiver.receiver.getStats();
|
|
622
650
|
}
|
|
623
651
|
async receiveDataChannel({ sctpStreamParameters, label, protocol }) {
|
|
652
|
+
this.assertNotClosed();
|
|
624
653
|
this.assertRecvDirection();
|
|
625
654
|
const { streamId, ordered, maxPacketLifeTime, maxRetransmits } = sctpStreamParameters;
|
|
626
655
|
const options = {
|
|
@@ -667,6 +696,11 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface {
|
|
|
667
696
|
});
|
|
668
697
|
this._transportReady = true;
|
|
669
698
|
}
|
|
699
|
+
assertNotClosed() {
|
|
700
|
+
if (this._closed) {
|
|
701
|
+
throw new errors_1.InvalidStateError('method called in a closed handler');
|
|
702
|
+
}
|
|
703
|
+
}
|
|
670
704
|
assertSendDirection() {
|
|
671
705
|
if (this._direction !== 'send') {
|
|
672
706
|
throw new Error('method can just be called for handlers with "send" direction');
|
|
@@ -3,6 +3,7 @@ import { IceParameters } from '../Transport';
|
|
|
3
3
|
import { RtpCapabilities } from '../RtpParameters';
|
|
4
4
|
import { SctpCapabilities } from '../SctpParameters';
|
|
5
5
|
export declare class ReactNativeUnifiedPlan extends HandlerInterface {
|
|
6
|
+
private _closed;
|
|
6
7
|
private _direction?;
|
|
7
8
|
private _remoteSdp?;
|
|
8
9
|
private _sendingRtpParametersByKind?;
|
|
@@ -43,6 +44,7 @@ export declare class ReactNativeUnifiedPlan extends HandlerInterface {
|
|
|
43
44
|
getReceiverStats(localId: string): Promise<RTCStatsReport>;
|
|
44
45
|
receiveDataChannel({ sctpStreamParameters, label, protocol }: HandlerReceiveDataChannelOptions): Promise<HandlerReceiveDataChannelResult>;
|
|
45
46
|
private setupTransport;
|
|
47
|
+
private assertNotClosed;
|
|
46
48
|
private assertSendDirection;
|
|
47
49
|
private assertRecvDirection;
|
|
48
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeUnifiedPlan.d.ts","sourceRoot":"","sources":["../../src/handlers/ReactNativeUnifiedPlan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ReactNativeUnifiedPlan.d.ts","sourceRoot":"","sources":["../../src/handlers/ReactNativeUnifiedPlan.ts"],"names":[],"mappings":"AAQA,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,EAC7B,4BAA4B,EAC5B,gCAAgC,EAChC,+BAA+B,EAC/B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,aAAa,EAAY,MAAM,cAAc,CAAC;AACvD,OAAO,EACN,eAAe,EAGf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAM3E,qBAAa,sBAAuB,SAAQ,gBAAgB;IAG3D,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,UAAU,CAAC,CAAkB;IAErC,OAAO,CAAC,UAAU,CAAC,CAAY;IAE/B,OAAO,CAAC,2BAA2B,CAAC,CAAmC;IAGvE,OAAO,CAAC,iCAAiC,CAAC,CAAmC;IAG7E,OAAO,CAAC,oBAAoB,CAAC,CAAW;IAExC,OAAO,CAAC,GAAG,CAAM;IAEjB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CACxB;IAEX,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IAEjD,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E,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CrE,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAexD,eAAe,CACpB,EACC,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,KAAK,EACL,QAAQ,EACR,EAAE,6BAA6B,GAC9B,OAAO,CAAC,4BAA4B,CAAC;IAuElC,OAAO,CACZ,WAAW,EAAE,qBAAqB,EAAE,GACjC,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAmG7B,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA6ChD,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqCjD,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqClD,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAe1D,kBAAkB,CACvB,EAAE,oBAAoB,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,gCAAgC,GACzE,OAAO,CAAC,+BAA+B,CAAC;YAiE7B,cAAc;IAyC5B,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,mBAAmB;CAQ3B"}
|
|
@@ -31,6 +31,7 @@ const ortc = __importStar(require("../ortc"));
|
|
|
31
31
|
const sdpCommonUtils = __importStar(require("./sdp/commonUtils"));
|
|
32
32
|
const sdpUnifiedPlanUtils = __importStar(require("./sdp/unifiedPlanUtils"));
|
|
33
33
|
const ortcUtils = __importStar(require("./ortc/utils"));
|
|
34
|
+
const errors_1 = require("../errors");
|
|
34
35
|
const HandlerInterface_1 = require("./HandlerInterface");
|
|
35
36
|
const RemoteSdp_1 = require("./sdp/RemoteSdp");
|
|
36
37
|
const scalabilityModes_1 = require("../scalabilityModes");
|
|
@@ -45,6 +46,8 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
45
46
|
}
|
|
46
47
|
constructor() {
|
|
47
48
|
super();
|
|
49
|
+
// Closed flag.
|
|
50
|
+
this._closed = false;
|
|
48
51
|
// Map of RTCTransceivers indexed by MID.
|
|
49
52
|
this._mapMidTransceiver = new Map();
|
|
50
53
|
// Local stream for sending.
|
|
@@ -61,6 +64,10 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
61
64
|
}
|
|
62
65
|
close() {
|
|
63
66
|
logger.debug('close()');
|
|
67
|
+
if (this._closed) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this._closed = true;
|
|
64
71
|
// Free/dispose native MediaStream but DO NOT free/dispose native
|
|
65
72
|
// MediaStreamTracks (that is parent's business).
|
|
66
73
|
// @ts-ignore (proprietary API in react-native-webrtc).
|
|
@@ -112,6 +119,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
112
119
|
};
|
|
113
120
|
}
|
|
114
121
|
run({ direction, iceParameters, iceCandidates, dtlsParameters, sctpParameters, iceServers, iceTransportPolicy, additionalSettings, proprietaryConstraints, extendedRtpCapabilities }) {
|
|
122
|
+
this.assertNotClosed();
|
|
115
123
|
logger.debug('run()');
|
|
116
124
|
this._direction = direction;
|
|
117
125
|
this._remoteSdp = new RemoteSdp_1.RemoteSdp({
|
|
@@ -173,12 +181,14 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
173
181
|
}
|
|
174
182
|
}
|
|
175
183
|
async updateIceServers(iceServers) {
|
|
184
|
+
this.assertNotClosed();
|
|
176
185
|
logger.debug('updateIceServers()');
|
|
177
186
|
const configuration = this._pc.getConfiguration();
|
|
178
187
|
configuration.iceServers = iceServers;
|
|
179
188
|
this._pc.setConfiguration(configuration);
|
|
180
189
|
}
|
|
181
190
|
async restartIce(iceParameters) {
|
|
191
|
+
this.assertNotClosed();
|
|
182
192
|
logger.debug('restartIce()');
|
|
183
193
|
// Provide the remote SDP handler with new remote ICE parameters.
|
|
184
194
|
this._remoteSdp.updateIceParameters(iceParameters);
|
|
@@ -203,9 +213,11 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
203
213
|
}
|
|
204
214
|
}
|
|
205
215
|
async getTransportStats() {
|
|
216
|
+
this.assertNotClosed();
|
|
206
217
|
return this._pc.getStats();
|
|
207
218
|
}
|
|
208
219
|
async send({ track, encodings, codecOptions, codec }) {
|
|
220
|
+
this.assertNotClosed();
|
|
209
221
|
this.assertSendDirection();
|
|
210
222
|
logger.debug('send() [kind:%s, track.id:%s]', track.kind, track.id);
|
|
211
223
|
if (encodings && encodings.length > 1) {
|
|
@@ -337,6 +349,9 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
337
349
|
}
|
|
338
350
|
async stopSending(localId) {
|
|
339
351
|
this.assertSendDirection();
|
|
352
|
+
if (this._closed) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
340
355
|
logger.debug('stopSending() [localId:%s]', localId);
|
|
341
356
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
342
357
|
if (!transceiver) {
|
|
@@ -360,6 +375,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
360
375
|
this._mapMidTransceiver.delete(localId);
|
|
361
376
|
}
|
|
362
377
|
async pauseSending(localId) {
|
|
378
|
+
this.assertNotClosed();
|
|
363
379
|
this.assertSendDirection();
|
|
364
380
|
logger.debug('pauseSending() [localId:%s]', localId);
|
|
365
381
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -376,6 +392,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
376
392
|
await this._pc.setRemoteDescription(answer);
|
|
377
393
|
}
|
|
378
394
|
async resumeSending(localId) {
|
|
395
|
+
this.assertNotClosed();
|
|
379
396
|
this.assertSendDirection();
|
|
380
397
|
logger.debug('resumeSending() [localId:%s]', localId);
|
|
381
398
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -392,6 +409,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
392
409
|
await this._pc.setRemoteDescription(answer);
|
|
393
410
|
}
|
|
394
411
|
async replaceTrack(localId, track) {
|
|
412
|
+
this.assertNotClosed();
|
|
395
413
|
this.assertSendDirection();
|
|
396
414
|
if (track) {
|
|
397
415
|
logger.debug('replaceTrack() [localId:%s, track.id:%s]', localId, track.id);
|
|
@@ -406,6 +424,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
406
424
|
await transceiver.sender.replaceTrack(track);
|
|
407
425
|
}
|
|
408
426
|
async setMaxSpatialLayer(localId, spatialLayer) {
|
|
427
|
+
this.assertNotClosed();
|
|
409
428
|
this.assertSendDirection();
|
|
410
429
|
logger.debug('setMaxSpatialLayer() [localId:%s, spatialLayer:%s]', localId, spatialLayer);
|
|
411
430
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -431,6 +450,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
431
450
|
await this._pc.setRemoteDescription(answer);
|
|
432
451
|
}
|
|
433
452
|
async setRtpEncodingParameters(localId, params) {
|
|
453
|
+
this.assertNotClosed();
|
|
434
454
|
this.assertSendDirection();
|
|
435
455
|
logger.debug('setRtpEncodingParameters() [localId:%s, params:%o]', localId, params);
|
|
436
456
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -451,6 +471,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
451
471
|
await this._pc.setRemoteDescription(answer);
|
|
452
472
|
}
|
|
453
473
|
async getSenderStats(localId) {
|
|
474
|
+
this.assertNotClosed();
|
|
454
475
|
this.assertSendDirection();
|
|
455
476
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
456
477
|
if (!transceiver) {
|
|
@@ -459,6 +480,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
459
480
|
return transceiver.sender.getStats();
|
|
460
481
|
}
|
|
461
482
|
async sendDataChannel({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol }) {
|
|
483
|
+
this.assertNotClosed();
|
|
462
484
|
this.assertSendDirection();
|
|
463
485
|
const options = {
|
|
464
486
|
negotiated: true,
|
|
@@ -503,6 +525,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
503
525
|
return { dataChannel, sctpStreamParameters };
|
|
504
526
|
}
|
|
505
527
|
async receive(optionsList) {
|
|
528
|
+
this.assertNotClosed();
|
|
506
529
|
this.assertRecvDirection();
|
|
507
530
|
const results = [];
|
|
508
531
|
const mapLocalId = new Map();
|
|
@@ -567,6 +590,9 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
567
590
|
}
|
|
568
591
|
async stopReceiving(localIds) {
|
|
569
592
|
this.assertRecvDirection();
|
|
593
|
+
if (this._closed) {
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
570
596
|
for (const localId of localIds) {
|
|
571
597
|
logger.debug('stopReceiving() [localId:%s]', localId);
|
|
572
598
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -586,6 +612,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
586
612
|
}
|
|
587
613
|
}
|
|
588
614
|
async pauseReceiving(localIds) {
|
|
615
|
+
this.assertNotClosed();
|
|
589
616
|
this.assertRecvDirection();
|
|
590
617
|
for (const localId of localIds) {
|
|
591
618
|
logger.debug('pauseReceiving() [localId:%s]', localId);
|
|
@@ -604,6 +631,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
604
631
|
await this._pc.setLocalDescription(answer);
|
|
605
632
|
}
|
|
606
633
|
async resumeReceiving(localIds) {
|
|
634
|
+
this.assertNotClosed();
|
|
607
635
|
this.assertRecvDirection();
|
|
608
636
|
for (const localId of localIds) {
|
|
609
637
|
logger.debug('resumeReceiving() [localId:%s]', localId);
|
|
@@ -622,6 +650,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
622
650
|
await this._pc.setLocalDescription(answer);
|
|
623
651
|
}
|
|
624
652
|
async getReceiverStats(localId) {
|
|
653
|
+
this.assertNotClosed();
|
|
625
654
|
this.assertRecvDirection();
|
|
626
655
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
627
656
|
if (!transceiver) {
|
|
@@ -630,6 +659,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
630
659
|
return transceiver.receiver.getStats();
|
|
631
660
|
}
|
|
632
661
|
async receiveDataChannel({ sctpStreamParameters, label, protocol }) {
|
|
662
|
+
this.assertNotClosed();
|
|
633
663
|
this.assertRecvDirection();
|
|
634
664
|
const { streamId, ordered, maxPacketLifeTime, maxRetransmits } = sctpStreamParameters;
|
|
635
665
|
const options = {
|
|
@@ -679,6 +709,11 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
|
679
709
|
});
|
|
680
710
|
this._transportReady = true;
|
|
681
711
|
}
|
|
712
|
+
assertNotClosed() {
|
|
713
|
+
if (this._closed) {
|
|
714
|
+
throw new errors_1.InvalidStateError('method called in a closed handler');
|
|
715
|
+
}
|
|
716
|
+
}
|
|
682
717
|
assertSendDirection() {
|
|
683
718
|
if (this._direction !== 'send') {
|
|
684
719
|
throw new Error('method can just be called for handlers with "send" direction');
|
|
@@ -3,6 +3,7 @@ import { IceParameters } from '../Transport';
|
|
|
3
3
|
import { RtpCapabilities } from '../RtpParameters';
|
|
4
4
|
import { SctpCapabilities } from '../SctpParameters';
|
|
5
5
|
export declare class Safari12 extends HandlerInterface {
|
|
6
|
+
private _closed;
|
|
6
7
|
private _direction?;
|
|
7
8
|
private _remoteSdp?;
|
|
8
9
|
private _sendingRtpParametersByKind?;
|
|
@@ -43,6 +44,7 @@ export declare class Safari12 extends HandlerInterface {
|
|
|
43
44
|
getReceiverStats(localId: string): Promise<RTCStatsReport>;
|
|
44
45
|
receiveDataChannel({ sctpStreamParameters, label, protocol }: HandlerReceiveDataChannelOptions): Promise<HandlerReceiveDataChannelResult>;
|
|
45
46
|
private setupTransport;
|
|
47
|
+
private assertNotClosed;
|
|
46
48
|
private assertSendDirection;
|
|
47
49
|
private assertRecvDirection;
|
|
48
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Safari12.d.ts","sourceRoot":"","sources":["../../src/handlers/Safari12.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Safari12.d.ts","sourceRoot":"","sources":["../../src/handlers/Safari12.ts"],"names":[],"mappings":"AAQA,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,EAC7B,4BAA4B,EAC5B,gCAAgC,EAChC,+BAA+B,EAC/B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,aAAa,EAAY,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,eAAe,EAAiB,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAM3E,qBAAa,QAAS,SAAQ,gBAAgB;IAG7C,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,UAAU,CAAC,CAAkB;IAErC,OAAO,CAAC,UAAU,CAAC,CAAY;IAE/B,OAAO,CAAC,2BAA2B,CAAC,CAAmC;IAGvE,OAAO,CAAC,iCAAiC,CAAC,CAAmC;IAG7E,OAAO,CAAC,oBAAoB,CAAC,CAAW;IAExC,OAAO,CAAC,GAAG,CAAM;IAEjB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CACxB;IAEX,OAAO,CAAC,QAAQ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,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CrE,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAexD,eAAe,CACpB,EACC,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,KAAK,EACL,QAAQ,EACR,EAAE,6BAA6B,GAC9B,OAAO,CAAC,4BAA4B,CAAC;IAuElC,OAAO,CACZ,WAAW,EAAE,qBAAqB,EAAE,GACjC,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAiG7B,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA6ChD,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqCjD,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqClD,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAe1D,kBAAkB,CACvB,EAAE,oBAAoB,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,gCAAgC,GACzE,OAAO,CAAC,+BAA+B,CAAC;YAiE7B,cAAc;IAyC5B,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,mBAAmB;CAQ3B"}
|
package/lib/handlers/Safari12.js
CHANGED
|
@@ -31,6 +31,7 @@ const ortc = __importStar(require("../ortc"));
|
|
|
31
31
|
const sdpCommonUtils = __importStar(require("./sdp/commonUtils"));
|
|
32
32
|
const sdpUnifiedPlanUtils = __importStar(require("./sdp/unifiedPlanUtils"));
|
|
33
33
|
const ortcUtils = __importStar(require("./ortc/utils"));
|
|
34
|
+
const errors_1 = require("../errors");
|
|
34
35
|
const HandlerInterface_1 = require("./HandlerInterface");
|
|
35
36
|
const RemoteSdp_1 = require("./sdp/RemoteSdp");
|
|
36
37
|
const scalabilityModes_1 = require("../scalabilityModes");
|
|
@@ -45,6 +46,8 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
45
46
|
}
|
|
46
47
|
constructor() {
|
|
47
48
|
super();
|
|
49
|
+
// Closed flag.
|
|
50
|
+
this._closed = false;
|
|
48
51
|
// Map of RTCTransceivers indexed by MID.
|
|
49
52
|
this._mapMidTransceiver = new Map();
|
|
50
53
|
// Local stream for sending.
|
|
@@ -61,6 +64,10 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
61
64
|
}
|
|
62
65
|
close() {
|
|
63
66
|
logger.debug('close()');
|
|
67
|
+
if (this._closed) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this._closed = true;
|
|
64
71
|
// Close RTCPeerConnection.
|
|
65
72
|
if (this._pc) {
|
|
66
73
|
try {
|
|
@@ -107,6 +114,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
107
114
|
};
|
|
108
115
|
}
|
|
109
116
|
run({ direction, iceParameters, iceCandidates, dtlsParameters, sctpParameters, iceServers, iceTransportPolicy, additionalSettings, proprietaryConstraints, extendedRtpCapabilities }) {
|
|
117
|
+
this.assertNotClosed();
|
|
110
118
|
logger.debug('run()');
|
|
111
119
|
this._direction = direction;
|
|
112
120
|
this._remoteSdp = new RemoteSdp_1.RemoteSdp({
|
|
@@ -167,12 +175,14 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
167
175
|
}
|
|
168
176
|
}
|
|
169
177
|
async updateIceServers(iceServers) {
|
|
178
|
+
this.assertNotClosed();
|
|
170
179
|
logger.debug('updateIceServers()');
|
|
171
180
|
const configuration = this._pc.getConfiguration();
|
|
172
181
|
configuration.iceServers = iceServers;
|
|
173
182
|
this._pc.setConfiguration(configuration);
|
|
174
183
|
}
|
|
175
184
|
async restartIce(iceParameters) {
|
|
185
|
+
this.assertNotClosed();
|
|
176
186
|
logger.debug('restartIce()');
|
|
177
187
|
// Provide the remote SDP handler with new remote ICE parameters.
|
|
178
188
|
this._remoteSdp.updateIceParameters(iceParameters);
|
|
@@ -197,9 +207,11 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
197
207
|
}
|
|
198
208
|
}
|
|
199
209
|
async getTransportStats() {
|
|
210
|
+
this.assertNotClosed();
|
|
200
211
|
return this._pc.getStats();
|
|
201
212
|
}
|
|
202
213
|
async send({ track, encodings, codecOptions, codec }) {
|
|
214
|
+
this.assertNotClosed();
|
|
203
215
|
this.assertSendDirection();
|
|
204
216
|
logger.debug('send() [kind:%s, track.id:%s]', track.kind, track.id);
|
|
205
217
|
const sendingRtpParameters = utils.clone(this._sendingRtpParametersByKind[track.kind], {});
|
|
@@ -288,6 +300,9 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
288
300
|
}
|
|
289
301
|
async stopSending(localId) {
|
|
290
302
|
this.assertSendDirection();
|
|
303
|
+
if (this._closed) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
291
306
|
logger.debug('stopSending() [localId:%s]', localId);
|
|
292
307
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
293
308
|
if (!transceiver) {
|
|
@@ -312,6 +327,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
312
327
|
}
|
|
313
328
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
314
329
|
async pauseSending(localId) {
|
|
330
|
+
this.assertNotClosed();
|
|
315
331
|
this.assertSendDirection();
|
|
316
332
|
logger.debug('pauseSending() [localId:%s]', localId);
|
|
317
333
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -329,6 +345,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
329
345
|
}
|
|
330
346
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
331
347
|
async resumeSending(localId) {
|
|
348
|
+
this.assertNotClosed();
|
|
332
349
|
this.assertSendDirection();
|
|
333
350
|
logger.debug('resumeSending() [localId:%s]', localId);
|
|
334
351
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -345,6 +362,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
345
362
|
await this._pc.setRemoteDescription(answer);
|
|
346
363
|
}
|
|
347
364
|
async replaceTrack(localId, track) {
|
|
365
|
+
this.assertNotClosed();
|
|
348
366
|
this.assertSendDirection();
|
|
349
367
|
if (track) {
|
|
350
368
|
logger.debug('replaceTrack() [localId:%s, track.id:%s]', localId, track.id);
|
|
@@ -359,6 +377,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
359
377
|
await transceiver.sender.replaceTrack(track);
|
|
360
378
|
}
|
|
361
379
|
async setMaxSpatialLayer(localId, spatialLayer) {
|
|
380
|
+
this.assertNotClosed();
|
|
362
381
|
this.assertSendDirection();
|
|
363
382
|
logger.debug('setMaxSpatialLayer() [localId:%s, spatialLayer:%s]', localId, spatialLayer);
|
|
364
383
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -384,6 +403,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
384
403
|
await this._pc.setRemoteDescription(answer);
|
|
385
404
|
}
|
|
386
405
|
async setRtpEncodingParameters(localId, params) {
|
|
406
|
+
this.assertNotClosed();
|
|
387
407
|
this.assertSendDirection();
|
|
388
408
|
logger.debug('setRtpEncodingParameters() [localId:%s, params:%o]', localId, params);
|
|
389
409
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -404,6 +424,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
404
424
|
await this._pc.setRemoteDescription(answer);
|
|
405
425
|
}
|
|
406
426
|
async getSenderStats(localId) {
|
|
427
|
+
this.assertNotClosed();
|
|
407
428
|
this.assertSendDirection();
|
|
408
429
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
409
430
|
if (!transceiver) {
|
|
@@ -412,6 +433,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
412
433
|
return transceiver.sender.getStats();
|
|
413
434
|
}
|
|
414
435
|
async sendDataChannel({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol }) {
|
|
436
|
+
this.assertNotClosed();
|
|
415
437
|
this.assertSendDirection();
|
|
416
438
|
const options = {
|
|
417
439
|
negotiated: true,
|
|
@@ -456,6 +478,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
456
478
|
return { dataChannel, sctpStreamParameters };
|
|
457
479
|
}
|
|
458
480
|
async receive(optionsList) {
|
|
481
|
+
this.assertNotClosed();
|
|
459
482
|
this.assertRecvDirection();
|
|
460
483
|
const results = [];
|
|
461
484
|
const mapLocalId = new Map();
|
|
@@ -518,6 +541,9 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
518
541
|
}
|
|
519
542
|
async stopReceiving(localIds) {
|
|
520
543
|
this.assertRecvDirection();
|
|
544
|
+
if (this._closed) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
521
547
|
for (const localId of localIds) {
|
|
522
548
|
logger.debug('stopReceiving() [localId:%s]', localId);
|
|
523
549
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
@@ -537,6 +563,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
537
563
|
}
|
|
538
564
|
}
|
|
539
565
|
async pauseReceiving(localIds) {
|
|
566
|
+
this.assertNotClosed();
|
|
540
567
|
this.assertRecvDirection();
|
|
541
568
|
for (const localId of localIds) {
|
|
542
569
|
logger.debug('pauseReceiving() [localId:%s]', localId);
|
|
@@ -555,6 +582,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
555
582
|
await this._pc.setLocalDescription(answer);
|
|
556
583
|
}
|
|
557
584
|
async resumeReceiving(localIds) {
|
|
585
|
+
this.assertNotClosed();
|
|
558
586
|
this.assertRecvDirection();
|
|
559
587
|
for (const localId of localIds) {
|
|
560
588
|
logger.debug('resumeReceiving() [localId:%s]', localId);
|
|
@@ -573,6 +601,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
573
601
|
await this._pc.setLocalDescription(answer);
|
|
574
602
|
}
|
|
575
603
|
async getReceiverStats(localId) {
|
|
604
|
+
this.assertNotClosed();
|
|
576
605
|
this.assertRecvDirection();
|
|
577
606
|
const transceiver = this._mapMidTransceiver.get(localId);
|
|
578
607
|
if (!transceiver) {
|
|
@@ -581,6 +610,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
581
610
|
return transceiver.receiver.getStats();
|
|
582
611
|
}
|
|
583
612
|
async receiveDataChannel({ sctpStreamParameters, label, protocol }) {
|
|
613
|
+
this.assertNotClosed();
|
|
584
614
|
this.assertRecvDirection();
|
|
585
615
|
const { streamId, ordered, maxPacketLifeTime, maxRetransmits } = sctpStreamParameters;
|
|
586
616
|
const options = {
|
|
@@ -630,6 +660,11 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
|
|
|
630
660
|
});
|
|
631
661
|
this._transportReady = true;
|
|
632
662
|
}
|
|
663
|
+
assertNotClosed() {
|
|
664
|
+
if (this._closed) {
|
|
665
|
+
throw new errors_1.InvalidStateError('method called in a closed handler');
|
|
666
|
+
}
|
|
667
|
+
}
|
|
633
668
|
assertSendDirection() {
|
|
634
669
|
if (this._direction !== 'send') {
|
|
635
670
|
throw new Error('method can just be called for handlers with "send" direction');
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,UAAU,CAAC;AACzB,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,MAAM,OAAO,GACnB;IACC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB,CAAC"}
|
package/lib/types.js
CHANGED
|
@@ -23,4 +23,5 @@ __exportStar(require("./DataConsumer"), exports);
|
|
|
23
23
|
__exportStar(require("./RtpParameters"), exports);
|
|
24
24
|
__exportStar(require("./SctpParameters"), exports);
|
|
25
25
|
__exportStar(require("./handlers/HandlerInterface"), exports);
|
|
26
|
+
// We cannot export only the type of error classes because those are useless.
|
|
26
27
|
__exportStar(require("./errors"), exports);
|