mediasoup-client 3.6.92 → 3.6.94

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.
@@ -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":"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,EACN,eAAe,EAGf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAM3E,qBAAa,sBAAuB,SAAQ,gBAAgB;IAG3D,OAAO,CAAC,UAAU,CAAC,CAAkB;IAErC,OAAO,CAAC,UAAU,CAAC,CAAY;IAE/B,OAAO,CAAC,2BAA2B,CAAC,CAAmC;IAGvE,OAAO,CAAC,iCAAiC,C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,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,10 +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 }) {
209
- var _a, _b;
220
+ this.assertNotClosed();
210
221
  this.assertSendDirection();
211
222
  logger.debug('send() [kind:%s, track.id:%s]', track.kind, track.id);
212
223
  if (encodings && encodings.length > 1) {
@@ -233,7 +244,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
233
244
  let offerMediaObject;
234
245
  if (!this._transportReady) {
235
246
  await this.setupTransport({
236
- localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
247
+ localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
237
248
  localSdpObject
238
249
  });
239
250
  }
@@ -263,7 +274,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
263
274
  // Issue: https://github.com/react-native-webrtc/react-native-webrtc/issues/1404
264
275
  // NOTE: So let's fill MID in sendingRtpParameters later.
265
276
  // NOTE: This is fixed in react-native-webrtc 111.0.3.
266
- let localId = (_b = transceiver.mid) !== null && _b !== void 0 ? _b : undefined;
277
+ let localId = transceiver.mid ?? undefined;
267
278
  if (!localId) {
268
279
  logger.warn('send() | missing transceiver.mid (bug in react-native-webrtc, using a workaround');
269
280
  }
@@ -338,6 +349,9 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
338
349
  }
339
350
  async stopSending(localId) {
340
351
  this.assertSendDirection();
352
+ if (this._closed) {
353
+ return;
354
+ }
341
355
  logger.debug('stopSending() [localId:%s]', localId);
342
356
  const transceiver = this._mapMidTransceiver.get(localId);
343
357
  if (!transceiver) {
@@ -361,6 +375,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
361
375
  this._mapMidTransceiver.delete(localId);
362
376
  }
363
377
  async pauseSending(localId) {
378
+ this.assertNotClosed();
364
379
  this.assertSendDirection();
365
380
  logger.debug('pauseSending() [localId:%s]', localId);
366
381
  const transceiver = this._mapMidTransceiver.get(localId);
@@ -377,6 +392,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
377
392
  await this._pc.setRemoteDescription(answer);
378
393
  }
379
394
  async resumeSending(localId) {
395
+ this.assertNotClosed();
380
396
  this.assertSendDirection();
381
397
  logger.debug('resumeSending() [localId:%s]', localId);
382
398
  const transceiver = this._mapMidTransceiver.get(localId);
@@ -393,6 +409,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
393
409
  await this._pc.setRemoteDescription(answer);
394
410
  }
395
411
  async replaceTrack(localId, track) {
412
+ this.assertNotClosed();
396
413
  this.assertSendDirection();
397
414
  if (track) {
398
415
  logger.debug('replaceTrack() [localId:%s, track.id:%s]', localId, track.id);
@@ -407,6 +424,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
407
424
  await transceiver.sender.replaceTrack(track);
408
425
  }
409
426
  async setMaxSpatialLayer(localId, spatialLayer) {
427
+ this.assertNotClosed();
410
428
  this.assertSendDirection();
411
429
  logger.debug('setMaxSpatialLayer() [localId:%s, spatialLayer:%s]', localId, spatialLayer);
412
430
  const transceiver = this._mapMidTransceiver.get(localId);
@@ -432,6 +450,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
432
450
  await this._pc.setRemoteDescription(answer);
433
451
  }
434
452
  async setRtpEncodingParameters(localId, params) {
453
+ this.assertNotClosed();
435
454
  this.assertSendDirection();
436
455
  logger.debug('setRtpEncodingParameters() [localId:%s, params:%o]', localId, params);
437
456
  const transceiver = this._mapMidTransceiver.get(localId);
@@ -452,6 +471,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
452
471
  await this._pc.setRemoteDescription(answer);
453
472
  }
454
473
  async getSenderStats(localId) {
474
+ this.assertNotClosed();
455
475
  this.assertSendDirection();
456
476
  const transceiver = this._mapMidTransceiver.get(localId);
457
477
  if (!transceiver) {
@@ -460,7 +480,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
460
480
  return transceiver.sender.getStats();
461
481
  }
462
482
  async sendDataChannel({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol }) {
463
- var _a;
483
+ this.assertNotClosed();
464
484
  this.assertSendDirection();
465
485
  const options = {
466
486
  negotiated: true,
@@ -484,7 +504,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
484
504
  .find((m) => m.type === 'application');
485
505
  if (!this._transportReady) {
486
506
  await this.setupTransport({
487
- localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
507
+ localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
488
508
  localSdpObject
489
509
  });
490
510
  }
@@ -505,7 +525,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
505
525
  return { dataChannel, sctpStreamParameters };
506
526
  }
507
527
  async receive(optionsList) {
508
- var _a;
528
+ this.assertNotClosed();
509
529
  this.assertRecvDirection();
510
530
  const results = [];
511
531
  const mapLocalId = new Map();
@@ -542,7 +562,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
542
562
  answer = { type: 'answer', sdp: sdpTransform.write(localSdpObject) };
543
563
  if (!this._transportReady) {
544
564
  await this.setupTransport({
545
- localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
565
+ localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
546
566
  localSdpObject
547
567
  });
548
568
  }
@@ -570,6 +590,9 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
570
590
  }
571
591
  async stopReceiving(localIds) {
572
592
  this.assertRecvDirection();
593
+ if (this._closed) {
594
+ return;
595
+ }
573
596
  for (const localId of localIds) {
574
597
  logger.debug('stopReceiving() [localId:%s]', localId);
575
598
  const transceiver = this._mapMidTransceiver.get(localId);
@@ -589,6 +612,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
589
612
  }
590
613
  }
591
614
  async pauseReceiving(localIds) {
615
+ this.assertNotClosed();
592
616
  this.assertRecvDirection();
593
617
  for (const localId of localIds) {
594
618
  logger.debug('pauseReceiving() [localId:%s]', localId);
@@ -607,6 +631,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
607
631
  await this._pc.setLocalDescription(answer);
608
632
  }
609
633
  async resumeReceiving(localIds) {
634
+ this.assertNotClosed();
610
635
  this.assertRecvDirection();
611
636
  for (const localId of localIds) {
612
637
  logger.debug('resumeReceiving() [localId:%s]', localId);
@@ -625,6 +650,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
625
650
  await this._pc.setLocalDescription(answer);
626
651
  }
627
652
  async getReceiverStats(localId) {
653
+ this.assertNotClosed();
628
654
  this.assertRecvDirection();
629
655
  const transceiver = this._mapMidTransceiver.get(localId);
630
656
  if (!transceiver) {
@@ -633,7 +659,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
633
659
  return transceiver.receiver.getStats();
634
660
  }
635
661
  async receiveDataChannel({ sctpStreamParameters, label, protocol }) {
636
- var _a;
662
+ this.assertNotClosed();
637
663
  this.assertRecvDirection();
638
664
  const { streamId, ordered, maxPacketLifeTime, maxRetransmits } = sctpStreamParameters;
639
665
  const options = {
@@ -657,7 +683,7 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
657
683
  if (!this._transportReady) {
658
684
  const localSdpObject = sdpTransform.parse(answer.sdp);
659
685
  await this.setupTransport({
660
- localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
686
+ localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
661
687
  localSdpObject
662
688
  });
663
689
  }
@@ -683,6 +709,11 @@ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
683
709
  });
684
710
  this._transportReady = true;
685
711
  }
712
+ assertNotClosed() {
713
+ if (this._closed) {
714
+ throw new errors_1.InvalidStateError('method called in a closed handler');
715
+ }
716
+ }
686
717
  assertSendDirection() {
687
718
  if (this._direction !== 'send') {
688
719
  throw new Error('method can just be called for handlers with "send" direction');
@@ -204,7 +204,6 @@ class Safari11 extends HandlerInterface_1.HandlerInterface {
204
204
  return this._pc.getStats();
205
205
  }
206
206
  async send({ track, encodings, codecOptions, codec }) {
207
- var _a;
208
207
  this.assertSendDirection();
209
208
  logger.debug('send() [kind:%s, track.id:%s]', track.kind, track.id);
210
209
  if (codec) {
@@ -223,7 +222,7 @@ class Safari11 extends HandlerInterface_1.HandlerInterface {
223
222
  ortc.reduceCodecs(sendingRemoteRtpParameters.codecs);
224
223
  if (!this._transportReady) {
225
224
  await this.setupTransport({
226
- localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
225
+ localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
227
226
  localSdpObject
228
227
  });
229
228
  }
@@ -388,7 +387,6 @@ class Safari11 extends HandlerInterface_1.HandlerInterface {
388
387
  return rtpSender.getStats();
389
388
  }
390
389
  async sendDataChannel({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol }) {
391
- var _a;
392
390
  this.assertSendDirection();
393
391
  const options = {
394
392
  negotiated: true,
@@ -412,7 +410,7 @@ class Safari11 extends HandlerInterface_1.HandlerInterface {
412
410
  .find((m) => m.type === 'application');
413
411
  if (!this._transportReady) {
414
412
  await this.setupTransport({
415
- localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
413
+ localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
416
414
  localSdpObject
417
415
  });
418
416
  }
@@ -433,7 +431,6 @@ class Safari11 extends HandlerInterface_1.HandlerInterface {
433
431
  return { dataChannel, sctpStreamParameters };
434
432
  }
435
433
  async receive(optionsList) {
436
- var _a;
437
434
  this.assertRecvDirection();
438
435
  const results = [];
439
436
  for (const options of optionsList) {
@@ -468,7 +465,7 @@ class Safari11 extends HandlerInterface_1.HandlerInterface {
468
465
  answer = { type: 'answer', sdp: sdpTransform.write(localSdpObject) };
469
466
  if (!this._transportReady) {
470
467
  await this.setupTransport({
471
- localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
468
+ localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
472
469
  localSdpObject
473
470
  });
474
471
  }
@@ -528,7 +525,6 @@ class Safari11 extends HandlerInterface_1.HandlerInterface {
528
525
  // Unimplemented.
529
526
  }
530
527
  async receiveDataChannel({ sctpStreamParameters, label, protocol }) {
531
- var _a;
532
528
  this.assertRecvDirection();
533
529
  const { streamId, ordered, maxPacketLifeTime, maxRetransmits } = sctpStreamParameters;
534
530
  const options = {
@@ -552,7 +548,7 @@ class Safari11 extends HandlerInterface_1.HandlerInterface {
552
548
  if (!this._transportReady) {
553
549
  const localSdpObject = sdpTransform.parse(answer.sdp);
554
550
  await this.setupTransport({
555
- localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
551
+ localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
556
552
  localSdpObject
557
553
  });
558
554
  }
@@ -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":"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,QAAS,SAAQ,gBAAgB;IAG7C,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,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,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 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,10 +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 }) {
203
- var _a;
214
+ this.assertNotClosed();
204
215
  this.assertSendDirection();
205
216
  logger.debug('send() [kind:%s, track.id:%s]', track.kind, track.id);
206
217
  const sendingRtpParameters = utils.clone(this._sendingRtpParametersByKind[track.kind], {});
@@ -218,7 +229,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
218
229
  let offerMediaObject;
219
230
  if (!this._transportReady) {
220
231
  await this.setupTransport({
221
- localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
232
+ localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
222
233
  localSdpObject
223
234
  });
224
235
  }
@@ -289,6 +300,9 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
289
300
  }
290
301
  async stopSending(localId) {
291
302
  this.assertSendDirection();
303
+ if (this._closed) {
304
+ return;
305
+ }
292
306
  logger.debug('stopSending() [localId:%s]', localId);
293
307
  const transceiver = this._mapMidTransceiver.get(localId);
294
308
  if (!transceiver) {
@@ -313,6 +327,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
313
327
  }
314
328
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
315
329
  async pauseSending(localId) {
330
+ this.assertNotClosed();
316
331
  this.assertSendDirection();
317
332
  logger.debug('pauseSending() [localId:%s]', localId);
318
333
  const transceiver = this._mapMidTransceiver.get(localId);
@@ -330,6 +345,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
330
345
  }
331
346
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
332
347
  async resumeSending(localId) {
348
+ this.assertNotClosed();
333
349
  this.assertSendDirection();
334
350
  logger.debug('resumeSending() [localId:%s]', localId);
335
351
  const transceiver = this._mapMidTransceiver.get(localId);
@@ -346,6 +362,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
346
362
  await this._pc.setRemoteDescription(answer);
347
363
  }
348
364
  async replaceTrack(localId, track) {
365
+ this.assertNotClosed();
349
366
  this.assertSendDirection();
350
367
  if (track) {
351
368
  logger.debug('replaceTrack() [localId:%s, track.id:%s]', localId, track.id);
@@ -360,6 +377,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
360
377
  await transceiver.sender.replaceTrack(track);
361
378
  }
362
379
  async setMaxSpatialLayer(localId, spatialLayer) {
380
+ this.assertNotClosed();
363
381
  this.assertSendDirection();
364
382
  logger.debug('setMaxSpatialLayer() [localId:%s, spatialLayer:%s]', localId, spatialLayer);
365
383
  const transceiver = this._mapMidTransceiver.get(localId);
@@ -385,6 +403,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
385
403
  await this._pc.setRemoteDescription(answer);
386
404
  }
387
405
  async setRtpEncodingParameters(localId, params) {
406
+ this.assertNotClosed();
388
407
  this.assertSendDirection();
389
408
  logger.debug('setRtpEncodingParameters() [localId:%s, params:%o]', localId, params);
390
409
  const transceiver = this._mapMidTransceiver.get(localId);
@@ -405,6 +424,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
405
424
  await this._pc.setRemoteDescription(answer);
406
425
  }
407
426
  async getSenderStats(localId) {
427
+ this.assertNotClosed();
408
428
  this.assertSendDirection();
409
429
  const transceiver = this._mapMidTransceiver.get(localId);
410
430
  if (!transceiver) {
@@ -413,7 +433,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
413
433
  return transceiver.sender.getStats();
414
434
  }
415
435
  async sendDataChannel({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol }) {
416
- var _a;
436
+ this.assertNotClosed();
417
437
  this.assertSendDirection();
418
438
  const options = {
419
439
  negotiated: true,
@@ -437,7 +457,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
437
457
  .find((m) => m.type === 'application');
438
458
  if (!this._transportReady) {
439
459
  await this.setupTransport({
440
- localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
460
+ localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
441
461
  localSdpObject
442
462
  });
443
463
  }
@@ -458,7 +478,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
458
478
  return { dataChannel, sctpStreamParameters };
459
479
  }
460
480
  async receive(optionsList) {
461
- var _a;
481
+ this.assertNotClosed();
462
482
  this.assertRecvDirection();
463
483
  const results = [];
464
484
  const mapLocalId = new Map();
@@ -495,7 +515,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
495
515
  answer = { type: 'answer', sdp: sdpTransform.write(localSdpObject) };
496
516
  if (!this._transportReady) {
497
517
  await this.setupTransport({
498
- localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
518
+ localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
499
519
  localSdpObject
500
520
  });
501
521
  }
@@ -521,6 +541,9 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
521
541
  }
522
542
  async stopReceiving(localIds) {
523
543
  this.assertRecvDirection();
544
+ if (this._closed) {
545
+ return;
546
+ }
524
547
  for (const localId of localIds) {
525
548
  logger.debug('stopReceiving() [localId:%s]', localId);
526
549
  const transceiver = this._mapMidTransceiver.get(localId);
@@ -540,6 +563,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
540
563
  }
541
564
  }
542
565
  async pauseReceiving(localIds) {
566
+ this.assertNotClosed();
543
567
  this.assertRecvDirection();
544
568
  for (const localId of localIds) {
545
569
  logger.debug('pauseReceiving() [localId:%s]', localId);
@@ -558,6 +582,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
558
582
  await this._pc.setLocalDescription(answer);
559
583
  }
560
584
  async resumeReceiving(localIds) {
585
+ this.assertNotClosed();
561
586
  this.assertRecvDirection();
562
587
  for (const localId of localIds) {
563
588
  logger.debug('resumeReceiving() [localId:%s]', localId);
@@ -576,6 +601,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
576
601
  await this._pc.setLocalDescription(answer);
577
602
  }
578
603
  async getReceiverStats(localId) {
604
+ this.assertNotClosed();
579
605
  this.assertRecvDirection();
580
606
  const transceiver = this._mapMidTransceiver.get(localId);
581
607
  if (!transceiver) {
@@ -584,7 +610,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
584
610
  return transceiver.receiver.getStats();
585
611
  }
586
612
  async receiveDataChannel({ sctpStreamParameters, label, protocol }) {
587
- var _a;
613
+ this.assertNotClosed();
588
614
  this.assertRecvDirection();
589
615
  const { streamId, ordered, maxPacketLifeTime, maxRetransmits } = sctpStreamParameters;
590
616
  const options = {
@@ -608,7 +634,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
608
634
  if (!this._transportReady) {
609
635
  const localSdpObject = sdpTransform.parse(answer.sdp);
610
636
  await this.setupTransport({
611
- localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
637
+ localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
612
638
  localSdpObject
613
639
  });
614
640
  }
@@ -634,6 +660,11 @@ class Safari12 extends HandlerInterface_1.HandlerInterface {
634
660
  });
635
661
  this._transportReady = true;
636
662
  }
663
+ assertNotClosed() {
664
+ if (this._closed) {
665
+ throw new errors_1.InvalidStateError('method called in a closed handler');
666
+ }
667
+ }
637
668
  assertSendDirection() {
638
669
  if (this._direction !== 'send') {
639
670
  throw new Error('method can just be called for handlers with "send" direction');
@@ -5,11 +5,10 @@ exports.addNackSuppportForOpus = void 0;
5
5
  * This function adds RTCP NACK support for OPUS codec in given capabilities.
6
6
  */
7
7
  function addNackSuppportForOpus(rtpCapabilities) {
8
- var _a;
9
8
  for (const codec of (rtpCapabilities.codecs || [])) {
10
9
  if ((codec.mimeType.toLowerCase() === 'audio/opus' ||
11
10
  codec.mimeType.toLowerCase() === 'audio/multiopus') &&
12
- !((_a = codec.rtcpFeedback) === null || _a === void 0 ? void 0 : _a.some((fb) => fb.type === 'nack' && !fb.parameter))) {
11
+ !codec.rtcpFeedback?.some((fb) => fb.type === 'nack' && !fb.parameter)) {
13
12
  if (!codec.rtcpFeedback) {
14
13
  codec.rtcpFeedback = [];
15
14
  }
@@ -312,7 +312,6 @@ class AnswerMediaSection extends MediaSection {
312
312
  this._mediaObject.direction = 'recvonly';
313
313
  }
314
314
  muxSimulcastStreams(encodings) {
315
- var _a;
316
315
  if (!this._mediaObject.simulcast || !this._mediaObject.simulcast.list1) {
317
316
  return;
318
317
  }
@@ -326,7 +325,7 @@ class AnswerMediaSection extends MediaSection {
326
325
  const simulcastStreams = sdpTransform.parseSimulcastStreamList(raw);
327
326
  for (const simulcastStream of simulcastStreams) {
328
327
  for (const simulcastFormat of simulcastStream) {
329
- simulcastFormat.paused = !((_a = layers[simulcastFormat.scid]) === null || _a === void 0 ? void 0 : _a.active);
328
+ simulcastFormat.paused = !layers[simulcastFormat.scid]?.active;
330
329
  }
331
330
  }
332
331
  this._mediaObject.simulcast.list1 = simulcastStreams.map((simulcastFormats) => simulcastFormats.map((f) => `${f.paused ? '~' : ''}${f.scid}`).join(',')).join(';');
package/lib/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export { types };
8
8
  /**
9
9
  * Expose mediasoup-client version.
10
10
  */
11
- export declare const version = "3.6.92";
11
+ export declare const version = "3.6.94";
12
12
  /**
13
13
  * Expose Device class and detectDevice() helper.
14
14
  */
package/lib/index.js CHANGED
@@ -37,7 +37,7 @@ exports.types = types;
37
37
  /**
38
38
  * Expose mediasoup-client version.
39
39
  */
40
- exports.version = '3.6.92';
40
+ exports.version = '3.6.94';
41
41
  /**
42
42
  * Expose parseScalabilityMode() function.
43
43
  */