mediasoup-client 3.6.53 → 3.6.56

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.
Files changed (60) hide show
  1. package/lib/Consumer.d.ts.map +1 -1
  2. package/lib/Consumer.js +8 -0
  3. package/lib/EnhancedEventEmitter.d.ts +1 -1
  4. package/lib/EnhancedEventEmitter.d.ts.map +1 -1
  5. package/lib/Producer.d.ts +8 -0
  6. package/lib/Producer.d.ts.map +1 -1
  7. package/lib/Producer.js +2 -2
  8. package/lib/Transport.d.ts +3 -0
  9. package/lib/Transport.d.ts.map +1 -1
  10. package/lib/Transport.js +72 -11
  11. package/lib/handlers/Chrome55.d.ts +3 -1
  12. package/lib/handlers/Chrome55.d.ts.map +1 -1
  13. package/lib/handlers/Chrome55.js +17 -6
  14. package/lib/handlers/Chrome67.d.ts +3 -1
  15. package/lib/handlers/Chrome67.d.ts.map +1 -1
  16. package/lib/handlers/Chrome67.js +17 -6
  17. package/lib/handlers/Chrome70.d.ts +3 -1
  18. package/lib/handlers/Chrome70.d.ts.map +1 -1
  19. package/lib/handlers/Chrome70.js +20 -7
  20. package/lib/handlers/Chrome74.d.ts +3 -1
  21. package/lib/handlers/Chrome74.d.ts.map +1 -1
  22. package/lib/handlers/Chrome74.js +40 -7
  23. package/lib/handlers/Edge11.d.ts +3 -1
  24. package/lib/handlers/Edge11.d.ts.map +1 -1
  25. package/lib/handlers/Edge11.js +23 -12
  26. package/lib/handlers/FakeHandler.d.ts +3 -1
  27. package/lib/handlers/FakeHandler.d.ts.map +1 -1
  28. package/lib/handlers/FakeHandler.js +14 -3
  29. package/lib/handlers/Firefox60.d.ts +3 -1
  30. package/lib/handlers/Firefox60.d.ts.map +1 -1
  31. package/lib/handlers/Firefox60.js +42 -7
  32. package/lib/handlers/HandlerInterface.d.ts +4 -1
  33. package/lib/handlers/HandlerInterface.d.ts.map +1 -1
  34. package/lib/handlers/ReactNative.d.ts +3 -1
  35. package/lib/handlers/ReactNative.d.ts.map +1 -1
  36. package/lib/handlers/ReactNative.js +17 -6
  37. package/lib/handlers/Safari11.d.ts +3 -1
  38. package/lib/handlers/Safari11.d.ts.map +1 -1
  39. package/lib/handlers/Safari11.js +17 -6
  40. package/lib/handlers/Safari12.d.ts +3 -1
  41. package/lib/handlers/Safari12.d.ts.map +1 -1
  42. package/lib/handlers/Safari12.js +42 -7
  43. package/lib/index.d.ts +1 -1
  44. package/lib/index.js +1 -1
  45. package/package.json +6 -6
  46. package/src/Consumer.ts +14 -0
  47. package/src/EnhancedEventEmitter.ts +1 -1
  48. package/src/Producer.ts +10 -4
  49. package/src/Transport.ts +112 -19
  50. package/src/handlers/Chrome55.ts +24 -7
  51. package/src/handlers/Chrome67.ts +24 -7
  52. package/src/handlers/Chrome70.ts +27 -7
  53. package/src/handlers/Chrome74.ts +75 -7
  54. package/src/handlers/Edge11.ts +31 -14
  55. package/src/handlers/FakeHandler.ts +19 -3
  56. package/src/handlers/Firefox60.ts +77 -7
  57. package/src/handlers/HandlerInterface.ts +6 -1
  58. package/src/handlers/ReactNative.ts +24 -7
  59. package/src/handlers/Safari11.ts +24 -7
  60. package/src/handlers/Safari12.ts +77 -7
@@ -87,6 +87,8 @@ export class Chrome74 extends HandlerInterface
87
87
  try { this._pc.close(); }
88
88
  catch (error) {}
89
89
  }
90
+
91
+ this.emit('@close');
90
92
  }
91
93
 
92
94
  async getNativeRtpCapabilities(): Promise<RtpCapabilities>
@@ -485,6 +487,66 @@ export class Chrome74 extends HandlerInterface
485
487
  this._mapMidTransceiver.delete(localId);
486
488
  }
487
489
 
490
+ async pauseSending(localId: string): Promise<void>
491
+ {
492
+ this._assertSendDirection();
493
+
494
+ logger.debug('pauseSending() [localId:%s]', localId);
495
+
496
+ const transceiver = this._mapMidTransceiver.get(localId);
497
+
498
+ if (!transceiver)
499
+ throw new Error('associated RTCRtpTransceiver not found');
500
+
501
+ transceiver.direction = 'inactive';
502
+
503
+ const offer = await this._pc.createOffer();
504
+
505
+ logger.debug(
506
+ 'pauseSending() | calling pc.setLocalDescription() [offer:%o]',
507
+ offer);
508
+
509
+ await this._pc.setLocalDescription(offer);
510
+
511
+ const answer = { type: 'answer', sdp: this._remoteSdp!.getSdp() };
512
+
513
+ logger.debug(
514
+ 'pauseSending() | calling pc.setRemoteDescription() [answer:%o]',
515
+ answer);
516
+
517
+ await this._pc.setRemoteDescription(answer);
518
+ }
519
+
520
+ async resumeSending(localId: string): Promise<void>
521
+ {
522
+ this._assertSendDirection();
523
+
524
+ logger.debug('resumeSending() [localId:%s]', localId);
525
+
526
+ const transceiver = this._mapMidTransceiver.get(localId);
527
+
528
+ if (!transceiver)
529
+ throw new Error('associated RTCRtpTransceiver not found');
530
+
531
+ transceiver.direction = 'sendonly';
532
+
533
+ const offer = await this._pc.createOffer();
534
+
535
+ logger.debug(
536
+ 'resumeSending() | calling pc.setLocalDescription() [offer:%o]',
537
+ offer);
538
+
539
+ await this._pc.setLocalDescription(offer);
540
+
541
+ const answer = { type: 'answer', sdp: this._remoteSdp!.getSdp() };
542
+
543
+ logger.debug(
544
+ 'resumeSending() | calling pc.setRemoteDescription() [answer:%o]',
545
+ answer);
546
+
547
+ await this._pc.setRemoteDescription(answer);
548
+ }
549
+
488
550
  async replaceTrack(
489
551
  localId: string, track: MediaStreamTrack | null
490
552
  ): Promise<void>
@@ -748,18 +810,21 @@ export class Chrome74 extends HandlerInterface
748
810
  return results;
749
811
  }
750
812
 
751
- async stopReceiving(localId: string): Promise<void>
813
+ async stopReceiving(localIds: string[]): Promise<void>
752
814
  {
753
815
  this._assertRecvDirection();
754
816
 
755
- logger.debug('stopReceiving() [localId:%s]', localId);
817
+ for (const localId of localIds)
818
+ {
819
+ logger.debug('stopReceiving() [localId:%s]', localId);
756
820
 
757
- const transceiver = this._mapMidTransceiver.get(localId);
821
+ const transceiver = this._mapMidTransceiver.get(localId);
758
822
 
759
- if (!transceiver)
760
- throw new Error('associated RTCRtpTransceiver not found');
823
+ if (!transceiver)
824
+ throw new Error('associated RTCRtpTransceiver not found');
761
825
 
762
- this._remoteSdp!.closeMediaSection(transceiver.mid!);
826
+ this._remoteSdp!.closeMediaSection(transceiver.mid!);
827
+ }
763
828
 
764
829
  const offer = { type: 'offer', sdp: this._remoteSdp!.getSdp() };
765
830
 
@@ -777,7 +842,10 @@ export class Chrome74 extends HandlerInterface
777
842
 
778
843
  await this._pc.setLocalDescription(answer);
779
844
 
780
- this._mapMidTransceiver.delete(localId);
845
+ for (const localId of localIds)
846
+ {
847
+ this._mapMidTransceiver.delete(localId);
848
+ }
781
849
  }
782
850
 
783
851
  async pauseReceiving(localIds: string[]): Promise<void>
@@ -102,6 +102,8 @@ export class Edge11 extends HandlerInterface
102
102
  try { (rtpReceiver as any).stop(); }
103
103
  catch (error) {}
104
104
  }
105
+
106
+ this.emit('@close');
105
107
  }
106
108
 
107
109
  async getNativeRtpCapabilities(): Promise<RtpCapabilities>
@@ -274,6 +276,18 @@ export class Edge11 extends HandlerInterface
274
276
  }
275
277
  }
276
278
 
279
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
280
+ async pauseSending(localId: string): Promise<void>
281
+ {
282
+ // Unimplemented.
283
+ }
284
+
285
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
286
+ async resumeSending(localId: string): Promise<void>
287
+ {
288
+ // Unimplemented.
289
+ }
290
+
277
291
  async replaceTrack(
278
292
  localId: string, track: MediaStreamTrack | null
279
293
  ): Promise<void>
@@ -415,26 +429,29 @@ export class Edge11 extends HandlerInterface
415
429
  return results;
416
430
  }
417
431
 
418
- async stopReceiving(localId: string): Promise<void>
432
+ async stopReceiving(localIds: string[]): Promise<void>
419
433
  {
420
- logger.debug('stopReceiving() [localId:%s]', localId);
434
+ for (const localId of localIds)
435
+ {
436
+ logger.debug('stopReceiving() [localId:%s]', localId);
421
437
 
422
- const rtpReceiver = this._rtpReceivers.get(localId);
438
+ const rtpReceiver = this._rtpReceivers.get(localId);
423
439
 
424
- if (!rtpReceiver)
425
- throw new Error('RTCRtpReceiver not found');
440
+ if (!rtpReceiver)
441
+ throw new Error('RTCRtpReceiver not found');
426
442
 
427
- this._rtpReceivers.delete(localId);
443
+ this._rtpReceivers.delete(localId);
428
444
 
429
- try
430
- {
431
- logger.debug('stopReceiving() | calling rtpReceiver.stop()');
445
+ try
446
+ {
447
+ logger.debug('stopReceiving() | calling rtpReceiver.stop()');
432
448
 
433
- (rtpReceiver as any).stop();
434
- }
435
- catch (error)
436
- {
437
- logger.warn('stopReceiving() | rtpReceiver.stop() failed:%o', error);
449
+ (rtpReceiver as any).stop();
450
+ }
451
+ catch (error)
452
+ {
453
+ logger.warn('stopReceiving() | rtpReceiver.stop() failed:%o', error);
454
+ }
438
455
  }
439
456
  }
440
457
 
@@ -65,6 +65,7 @@ class FakeDataChannel extends EnhancedEventEmitter
65
65
  close(): void
66
66
  {
67
67
  this.safeEmit('close');
68
+ this.emit('@close');
68
69
  }
69
70
 
70
71
  send(data: any): void
@@ -249,6 +250,18 @@ export class FakeHandler extends HandlerInterface
249
250
  this._tracks.delete(Number(localId));
250
251
  }
251
252
 
253
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
254
+ async pauseSending(localId: string): Promise<void>
255
+ {
256
+ // Unimplemented.
257
+ }
258
+
259
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
260
+ async resumeSending(localId: string): Promise<void>
261
+ {
262
+ // Unimplemented.
263
+ }
264
+
252
265
  async replaceTrack(
253
266
  localId: string, track: MediaStreamTrack | null
254
267
  ): Promise<void>
@@ -350,11 +363,14 @@ export class FakeHandler extends HandlerInterface
350
363
  return results;
351
364
  }
352
365
 
353
- async stopReceiving(localId: string): Promise<void>
366
+ async stopReceiving(localIds: string[]): Promise<void>
354
367
  {
355
- logger.debug('stopReceiving() [localId:%s]', localId);
368
+ for (const localId of localIds)
369
+ {
370
+ logger.debug('stopReceiving() [localId:%s]', localId);
356
371
 
357
- this._tracks.delete(Number(localId));
372
+ this._tracks.delete(Number(localId));
373
+ }
358
374
  }
359
375
 
360
376
  async pauseReceiving(
@@ -80,6 +80,8 @@ export class Firefox60 extends HandlerInterface
80
80
  try { this._pc.close(); }
81
81
  catch (error) {}
82
82
  }
83
+
84
+ this.emit('@close');
83
85
  }
84
86
 
85
87
  async getNativeRtpCapabilities(): Promise<RtpCapabilities>
@@ -481,6 +483,68 @@ export class Firefox60 extends HandlerInterface
481
483
  this._mapMidTransceiver.delete(localId);
482
484
  }
483
485
 
486
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
487
+ async pauseSending(localId: string): Promise<void>
488
+ {
489
+ this._assertSendDirection();
490
+
491
+ logger.debug('pauseSending() [localId:%s]', localId);
492
+
493
+ const transceiver = this._mapMidTransceiver.get(localId);
494
+
495
+ if (!transceiver)
496
+ throw new Error('associated RTCRtpTransceiver not found');
497
+
498
+ transceiver.direction = 'inactive';
499
+
500
+ const offer = await this._pc.createOffer();
501
+
502
+ logger.debug(
503
+ 'pauseSending() | calling pc.setLocalDescription() [offer:%o]',
504
+ offer);
505
+
506
+ await this._pc.setLocalDescription(offer);
507
+
508
+ const answer = { type: 'answer', sdp: this._remoteSdp!.getSdp() };
509
+
510
+ logger.debug(
511
+ 'pauseSending() | calling pc.setRemoteDescription() [answer:%o]',
512
+ answer);
513
+
514
+ await this._pc.setRemoteDescription(answer);
515
+ }
516
+
517
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
518
+ async resumeSending(localId: string): Promise<void>
519
+ {
520
+ this._assertSendDirection();
521
+
522
+ logger.debug('resumeSending() [localId:%s]', localId);
523
+
524
+ const transceiver = this._mapMidTransceiver.get(localId);
525
+
526
+ if (!transceiver)
527
+ throw new Error('associated RTCRtpTransceiver not found');
528
+
529
+ transceiver.direction = 'sendonly';
530
+
531
+ const offer = await this._pc.createOffer();
532
+
533
+ logger.debug(
534
+ 'resumeSending() | calling pc.setLocalDescription() [offer:%o]',
535
+ offer);
536
+
537
+ await this._pc.setLocalDescription(offer);
538
+
539
+ const answer = { type: 'answer', sdp: this._remoteSdp!.getSdp() };
540
+
541
+ logger.debug(
542
+ 'resumeSending() | calling pc.setRemoteDescription() [answer:%o]',
543
+ answer);
544
+
545
+ await this._pc.setRemoteDescription(answer);
546
+ }
547
+
484
548
  async replaceTrack(
485
549
  localId: string, track: MediaStreamTrack | null
486
550
  ): Promise<void>
@@ -733,18 +797,21 @@ export class Firefox60 extends HandlerInterface
733
797
  return results;
734
798
  }
735
799
 
736
- async stopReceiving(localId: string): Promise<void>
800
+ async stopReceiving(localIds: string[]): Promise<void>
737
801
  {
738
802
  this._assertRecvDirection();
739
803
 
740
- logger.debug('stopReceiving() [localId:%s]', localId);
804
+ for (const localId of localIds)
805
+ {
806
+ logger.debug('stopReceiving() [localId:%s]', localId);
741
807
 
742
- const transceiver = this._mapMidTransceiver.get(localId);
808
+ const transceiver = this._mapMidTransceiver.get(localId);
743
809
 
744
- if (!transceiver)
745
- throw new Error('associated RTCRtpTransceiver not found');
810
+ if (!transceiver)
811
+ throw new Error('associated RTCRtpTransceiver not found');
746
812
 
747
- this._remoteSdp!.closeMediaSection(transceiver.mid!);
813
+ this._remoteSdp!.closeMediaSection(transceiver.mid!);
814
+ }
748
815
 
749
816
  const offer = { type: 'offer', sdp: this._remoteSdp!.getSdp() };
750
817
 
@@ -762,7 +829,10 @@ export class Firefox60 extends HandlerInterface
762
829
 
763
830
  await this._pc.setLocalDescription(answer);
764
831
 
765
- this._mapMidTransceiver.delete(localId);
832
+ for (const localId of localIds)
833
+ {
834
+ this._mapMidTransceiver.delete(localId);
835
+ }
766
836
  }
767
837
 
768
838
  async pauseReceiving(localIds: string[]): Promise<void>
@@ -85,6 +85,7 @@ export type HandlerReceiveDataChannelResult =
85
85
 
86
86
  export type HandlerEvents =
87
87
  {
88
+ '@close': [];
88
89
  '@connect':
89
90
  [
90
91
  { dtlsParameters: DtlsParameters },
@@ -121,6 +122,10 @@ export abstract class HandlerInterface extends EnhancedEventEmitter<HandlerEvent
121
122
 
122
123
  abstract stopSending(localId: string): Promise<void>;
123
124
 
125
+ abstract pauseSending(localId: string): Promise<void>;
126
+
127
+ abstract resumeSending(localId: string): Promise<void>;
128
+
124
129
  abstract replaceTrack(
125
130
  localId: string, track: MediaStreamTrack | null
126
131
  ): Promise<void>;
@@ -143,7 +148,7 @@ export abstract class HandlerInterface extends EnhancedEventEmitter<HandlerEvent
143
148
  optionsList: HandlerReceiveOptions[]
144
149
  ) : Promise<HandlerReceiveResult[]>
145
150
 
146
- abstract stopReceiving(localId: string): Promise<void>;
151
+ abstract stopReceiving(localIds: string[]): Promise<void>;
147
152
 
148
153
  abstract pauseReceiving(localIds: string[]): Promise<void>;
149
154
 
@@ -99,6 +99,8 @@ export class ReactNative extends HandlerInterface
99
99
  try { this._pc.close(); }
100
100
  catch (error) {}
101
101
  }
102
+
103
+ this.emit('@close');
102
104
  }
103
105
 
104
106
  async getNativeRtpCapabilities(): Promise<RtpCapabilities>
@@ -482,6 +484,18 @@ export class ReactNative extends HandlerInterface
482
484
  await this._pc.setRemoteDescription(answer);
483
485
  }
484
486
 
487
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
488
+ async pauseSending(localId: string): Promise<void>
489
+ {
490
+ // Unimplemented.
491
+ }
492
+
493
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
494
+ async resumeSending(localId: string): Promise<void>
495
+ {
496
+ // Unimplemented.
497
+ }
498
+
485
499
  async replaceTrack(
486
500
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
487
501
  localId: string, track: MediaStreamTrack | null
@@ -692,19 +706,22 @@ export class ReactNative extends HandlerInterface
692
706
  return results;
693
707
  }
694
708
 
695
- async stopReceiving(localId: string): Promise<void>
709
+ async stopReceiving(localIds: string[]): Promise<void>
696
710
  {
697
711
  this._assertRecvDirection();
698
712
 
699
- logger.debug('stopReceiving() [localId:%s]', localId);
713
+ for (const localId of localIds)
714
+ {
715
+ logger.debug('stopReceiving() [localId:%s]', localId);
700
716
 
701
- const { mid, rtpParameters } = this._mapRecvLocalIdInfo.get(localId) || {};
717
+ const { mid, rtpParameters } = this._mapRecvLocalIdInfo.get(localId) || {};
702
718
 
703
- // Remove from the map.
704
- this._mapRecvLocalIdInfo.delete(localId);
719
+ // Remove from the map.
720
+ this._mapRecvLocalIdInfo.delete(localId);
705
721
 
706
- this._remoteSdp!.planBStopReceiving(
707
- { mid: mid!, offerRtpParameters: rtpParameters! });
722
+ this._remoteSdp!.planBStopReceiving(
723
+ { mid: mid!, offerRtpParameters: rtpParameters! });
724
+ }
708
725
 
709
726
  const offer = { type: 'offer', sdp: this._remoteSdp!.getSdp() };
710
727
 
@@ -95,6 +95,8 @@ export class Safari11 extends HandlerInterface
95
95
  try { this._pc.close(); }
96
96
  catch (error) {}
97
97
  }
98
+
99
+ this.emit('@close');
98
100
  }
99
101
 
100
102
  async getNativeRtpCapabilities(): Promise<RtpCapabilities>
@@ -477,6 +479,18 @@ export class Safari11 extends HandlerInterface
477
479
  await this._pc.setRemoteDescription(answer);
478
480
  }
479
481
 
482
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
483
+ async pauseSending(localId: string): Promise<void>
484
+ {
485
+ // Unimplemented.
486
+ }
487
+
488
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
489
+ async resumeSending(localId: string): Promise<void>
490
+ {
491
+ // Unimplemented.
492
+ }
493
+
480
494
  async replaceTrack(
481
495
  localId: string, track: MediaStreamTrack | null
482
496
  ): Promise<void>
@@ -745,19 +759,22 @@ export class Safari11 extends HandlerInterface
745
759
  return results;
746
760
  }
747
761
 
748
- async stopReceiving(localId: string): Promise<void>
762
+ async stopReceiving(localIds: string[]): Promise<void>
749
763
  {
750
764
  this._assertRecvDirection();
751
765
 
752
- logger.debug('stopReceiving() [localId:%s]', localId);
766
+ for (const localId of localIds)
767
+ {
768
+ logger.debug('stopReceiving() [localId:%s]', localId);
753
769
 
754
- const { mid, rtpParameters } = this._mapRecvLocalIdInfo.get(localId) || {};
770
+ const { mid, rtpParameters } = this._mapRecvLocalIdInfo.get(localId) || {};
755
771
 
756
- // Remove from the map.
757
- this._mapRecvLocalIdInfo.delete(localId);
772
+ // Remove from the map.
773
+ this._mapRecvLocalIdInfo.delete(localId);
758
774
 
759
- this._remoteSdp!.planBStopReceiving(
760
- { mid: mid!, offerRtpParameters: rtpParameters! });
775
+ this._remoteSdp!.planBStopReceiving(
776
+ { mid: mid!, offerRtpParameters: rtpParameters! });
777
+ }
761
778
 
762
779
  const offer = { type: 'offer', sdp: this._remoteSdp!.getSdp() };
763
780
 
@@ -82,6 +82,8 @@ export class Safari12 extends HandlerInterface
82
82
  try { this._pc.close(); }
83
83
  catch (error) {}
84
84
  }
85
+
86
+ this.emit('@close');
85
87
  }
86
88
 
87
89
  async getNativeRtpCapabilities(): Promise<RtpCapabilities>
@@ -439,6 +441,68 @@ export class Safari12 extends HandlerInterface
439
441
  this._mapMidTransceiver.delete(localId);
440
442
  }
441
443
 
444
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
445
+ async pauseSending(localId: string): Promise<void>
446
+ {
447
+ this._assertSendDirection();
448
+
449
+ logger.debug('pauseSending() [localId:%s]', localId);
450
+
451
+ const transceiver = this._mapMidTransceiver.get(localId);
452
+
453
+ if (!transceiver)
454
+ throw new Error('associated RTCRtpTransceiver not found');
455
+
456
+ transceiver.direction = 'inactive';
457
+
458
+ const offer = await this._pc.createOffer();
459
+
460
+ logger.debug(
461
+ 'pauseSending() | calling pc.setLocalDescription() [offer:%o]',
462
+ offer);
463
+
464
+ await this._pc.setLocalDescription(offer);
465
+
466
+ const answer = { type: 'answer', sdp: this._remoteSdp!.getSdp() };
467
+
468
+ logger.debug(
469
+ 'pauseSending() | calling pc.setRemoteDescription() [answer:%o]',
470
+ answer);
471
+
472
+ await this._pc.setRemoteDescription(answer);
473
+ }
474
+
475
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
476
+ async resumeSending(localId: string): Promise<void>
477
+ {
478
+ this._assertSendDirection();
479
+
480
+ logger.debug('resumeSending() [localId:%s]', localId);
481
+
482
+ const transceiver = this._mapMidTransceiver.get(localId);
483
+
484
+ if (!transceiver)
485
+ throw new Error('associated RTCRtpTransceiver not found');
486
+
487
+ transceiver.direction = 'sendonly';
488
+
489
+ const offer = await this._pc.createOffer();
490
+
491
+ logger.debug(
492
+ 'resumeSending() | calling pc.setLocalDescription() [offer:%o]',
493
+ offer);
494
+
495
+ await this._pc.setLocalDescription(offer);
496
+
497
+ const answer = { type: 'answer', sdp: this._remoteSdp!.getSdp() };
498
+
499
+ logger.debug(
500
+ 'resumeSending() | calling pc.setRemoteDescription() [answer:%o]',
501
+ answer);
502
+
503
+ await this._pc.setRemoteDescription(answer);
504
+ }
505
+
442
506
  async replaceTrack(
443
507
  localId: string, track: MediaStreamTrack | null
444
508
  ): Promise<void>
@@ -698,18 +762,21 @@ export class Safari12 extends HandlerInterface
698
762
  return results;
699
763
  }
700
764
 
701
- async stopReceiving(localId: string): Promise<void>
765
+ async stopReceiving(localIds: string[]): Promise<void>
702
766
  {
703
767
  this._assertRecvDirection();
704
768
 
705
- logger.debug('stopReceiving() [localId:%s]', localId);
769
+ for (const localId of localIds)
770
+ {
771
+ logger.debug('stopReceiving() [localId:%s]', localId);
706
772
 
707
- const transceiver = this._mapMidTransceiver.get(localId);
773
+ const transceiver = this._mapMidTransceiver.get(localId);
708
774
 
709
- if (!transceiver)
710
- throw new Error('associated RTCRtpTransceiver not found');
775
+ if (!transceiver)
776
+ throw new Error('associated RTCRtpTransceiver not found');
711
777
 
712
- this._remoteSdp!.closeMediaSection(transceiver.mid!);
778
+ this._remoteSdp!.closeMediaSection(transceiver.mid!);
779
+ }
713
780
 
714
781
  const offer = { type: 'offer', sdp: this._remoteSdp!.getSdp() };
715
782
 
@@ -727,7 +794,10 @@ export class Safari12 extends HandlerInterface
727
794
 
728
795
  await this._pc.setLocalDescription(answer);
729
796
 
730
- this._mapMidTransceiver.delete(localId);
797
+ for (const localId of localIds)
798
+ {
799
+ this._mapMidTransceiver.delete(localId);
800
+ }
731
801
  }
732
802
 
733
803
  async pauseReceiving(localIds: string[]): Promise<void>