mediasoup-client 3.6.48 → 3.6.51

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 (58) hide show
  1. package/.vimrc +21 -0
  2. package/NO_GIT/Notes.txt +18 -0
  3. package/lib/Consumer.d.ts +2 -2
  4. package/lib/Consumer.d.ts.map +1 -1
  5. package/lib/Producer.d.ts +2 -2
  6. package/lib/Producer.d.ts.map +1 -1
  7. package/lib/Transport.d.ts +6 -0
  8. package/lib/Transport.d.ts.map +1 -1
  9. package/lib/Transport.js +64 -4
  10. package/lib/handlers/Chrome55.d.ts +2 -2
  11. package/lib/handlers/Chrome55.d.ts.map +1 -1
  12. package/lib/handlers/Chrome55.js +2 -2
  13. package/lib/handlers/Chrome67.d.ts +2 -2
  14. package/lib/handlers/Chrome67.d.ts.map +1 -1
  15. package/lib/handlers/Chrome67.js +2 -2
  16. package/lib/handlers/Chrome70.d.ts +2 -2
  17. package/lib/handlers/Chrome70.d.ts.map +1 -1
  18. package/lib/handlers/Chrome70.js +8 -6
  19. package/lib/handlers/Chrome74.d.ts +2 -2
  20. package/lib/handlers/Chrome74.d.ts.map +1 -1
  21. package/lib/handlers/Chrome74.js +22 -16
  22. package/lib/handlers/Edge11.d.ts +2 -2
  23. package/lib/handlers/Edge11.d.ts.map +1 -1
  24. package/lib/handlers/Edge11.js +2 -2
  25. package/lib/handlers/FakeHandler.d.ts +2 -2
  26. package/lib/handlers/FakeHandler.d.ts.map +1 -1
  27. package/lib/handlers/FakeHandler.js +2 -2
  28. package/lib/handlers/Firefox60.d.ts +2 -2
  29. package/lib/handlers/Firefox60.d.ts.map +1 -1
  30. package/lib/handlers/Firefox60.js +22 -16
  31. package/lib/handlers/HandlerInterface.d.ts +2 -2
  32. package/lib/handlers/HandlerInterface.d.ts.map +1 -1
  33. package/lib/handlers/ReactNative.d.ts +2 -2
  34. package/lib/handlers/ReactNative.d.ts.map +1 -1
  35. package/lib/handlers/ReactNative.js +5 -3
  36. package/lib/handlers/Safari11.d.ts +2 -2
  37. package/lib/handlers/Safari11.d.ts.map +1 -1
  38. package/lib/handlers/Safari11.js +2 -2
  39. package/lib/handlers/Safari12.d.ts +2 -2
  40. package/lib/handlers/Safari12.d.ts.map +1 -1
  41. package/lib/handlers/Safari12.js +22 -16
  42. package/lib/index.d.ts +1 -1
  43. package/lib/index.js +1 -1
  44. package/package.json +1 -1
  45. package/src/Consumer.ts +3 -3
  46. package/src/Producer.ts +1 -1
  47. package/src/Transport.ts +98 -8
  48. package/src/handlers/Chrome55.ts +3 -3
  49. package/src/handlers/Chrome67.ts +2 -2
  50. package/src/handlers/Chrome70.ts +9 -6
  51. package/src/handlers/Chrome74.ts +27 -18
  52. package/src/handlers/Edge11.ts +2 -2
  53. package/src/handlers/FakeHandler.ts +2 -2
  54. package/src/handlers/Firefox60.ts +27 -18
  55. package/src/handlers/HandlerInterface.ts +2 -2
  56. package/src/handlers/ReactNative.ts +6 -3
  57. package/src/handlers/Safari11.ts +2 -2
  58. package/src/handlers/Safari12.ts +27 -18
@@ -655,6 +655,7 @@ export class Chrome74 extends HandlerInterface
655
655
  this._assertRecvDirection();
656
656
 
657
657
  const results: HandlerReceiveResult[] = [];
658
+ const mapLocalId: Map<string, string> = new Map();
658
659
 
659
660
  for (const options of optionsList)
660
661
  {
@@ -664,6 +665,8 @@ export class Chrome74 extends HandlerInterface
664
665
 
665
666
  const localId = rtpParameters.mid || String(this._mapMidTransceiver.size);
666
667
 
668
+ mapLocalId.set(trackId, localId);
669
+
667
670
  this._remoteSdp!.receive(
668
671
  {
669
672
  mid : localId,
@@ -687,8 +690,8 @@ export class Chrome74 extends HandlerInterface
687
690
 
688
691
  for (const options of optionsList)
689
692
  {
690
- const { rtpParameters } = options;
691
- const localId = rtpParameters.mid || String(this._mapMidTransceiver.size);
693
+ const { trackId, rtpParameters } = options;
694
+ const localId = mapLocalId.get(trackId);
692
695
  const answerMediaObject = localSdpObject.media
693
696
  .find((m: any) => String(m.mid) === localId);
694
697
 
@@ -720,8 +723,8 @@ export class Chrome74 extends HandlerInterface
720
723
 
721
724
  for (const options of optionsList)
722
725
  {
723
- const { rtpParameters } = options;
724
- const localId = rtpParameters.mid || String(this._mapMidTransceiver.size);
726
+ const { trackId } = options;
727
+ const localId = mapLocalId.get(trackId)!;
725
728
  const transceiver = this._pc.getTransceivers()
726
729
  .find((t: RTCRtpTransceiver) => t.mid === localId);
727
730
 
@@ -777,19 +780,22 @@ export class Chrome74 extends HandlerInterface
777
780
  this._mapMidTransceiver.delete(localId);
778
781
  }
779
782
 
780
- async pauseReceiving(localId: string): Promise<void>
783
+ async pauseReceiving(localIds: string[]): Promise<void>
781
784
  {
782
785
  this._assertRecvDirection();
783
786
 
784
- logger.debug('pauseReceiving() [localId:%s]', localId);
787
+ for (const localId of localIds)
788
+ {
789
+ logger.debug('pauseReceiving() [localId:%s]', localId);
785
790
 
786
- const transceiver = this._mapMidTransceiver.get(localId);
791
+ const transceiver = this._mapMidTransceiver.get(localId);
787
792
 
788
- if (!transceiver)
789
- throw new Error('associated RTCRtpTransceiver not found');
793
+ if (!transceiver)
794
+ throw new Error('associated RTCRtpTransceiver not found');
795
+
796
+ transceiver.direction = 'inactive';
797
+ }
790
798
 
791
- transceiver.direction = 'inactive';
792
-
793
799
  const offer = { type: 'offer', sdp: this._remoteSdp!.getSdp() };
794
800
 
795
801
  logger.debug(
@@ -807,19 +813,22 @@ export class Chrome74 extends HandlerInterface
807
813
  await this._pc.setLocalDescription(answer);
808
814
  }
809
815
 
810
- async resumeReceiving(localId: string): Promise<void>
816
+ async resumeReceiving(localIds: string[]): Promise<void>
811
817
  {
812
818
  this._assertRecvDirection();
813
819
 
814
- logger.debug('resumeReceiving() [localId:%s]', localId);
820
+ for (const localId of localIds)
821
+ {
822
+ logger.debug('resumeReceiving() [localId:%s]', localId);
815
823
 
816
- const transceiver = this._mapMidTransceiver.get(localId);
824
+ const transceiver = this._mapMidTransceiver.get(localId);
817
825
 
818
- if (!transceiver)
819
- throw new Error('associated RTCRtpTransceiver not found');
826
+ if (!transceiver)
827
+ throw new Error('associated RTCRtpTransceiver not found');
828
+
829
+ transceiver.direction = 'recvonly';
830
+ }
820
831
 
821
- transceiver.direction = 'recvonly';
822
-
823
832
  const offer = { type: 'offer', sdp: this._remoteSdp!.getSdp() };
824
833
 
825
834
  logger.debug(
@@ -440,14 +440,14 @@ export class Edge11 extends HandlerInterface
440
440
 
441
441
  async pauseReceiving(
442
442
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
443
- localId: string): Promise<void>
443
+ localIds: string[]): Promise<void>
444
444
  {
445
445
  // Unimplemented.
446
446
  }
447
447
 
448
448
  async resumeReceiving(
449
449
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
450
- localId: string): Promise<void>
450
+ localIds: string[]): Promise<void>
451
451
  {
452
452
  // Unimplemented.
453
453
  }
@@ -358,14 +358,14 @@ export class FakeHandler extends HandlerInterface
358
358
 
359
359
  async pauseReceiving(
360
360
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
361
- localId: string): Promise<void>
361
+ localIds: string[]): Promise<void>
362
362
  {
363
363
  // Unimplemented.
364
364
  }
365
365
 
366
366
  async resumeReceiving(
367
367
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
368
- localId: string): Promise<void>
368
+ localIds: string[]): Promise<void>
369
369
  {
370
370
  // Unimplemented.
371
371
  }
@@ -650,6 +650,7 @@ export class Firefox60 extends HandlerInterface
650
650
  this._assertRecvDirection();
651
651
 
652
652
  const results: HandlerReceiveResult[] = [];
653
+ const mapLocalId: Map<string, string> = new Map();
653
654
 
654
655
  for (const options of optionsList)
655
656
  {
@@ -659,6 +660,8 @@ export class Firefox60 extends HandlerInterface
659
660
 
660
661
  const localId = rtpParameters.mid || String(this._mapMidTransceiver.size);
661
662
 
663
+ mapLocalId.set(trackId, localId);
664
+
662
665
  this._remoteSdp!.receive(
663
666
  {
664
667
  mid : localId,
@@ -682,8 +685,8 @@ export class Firefox60 extends HandlerInterface
682
685
 
683
686
  for (const options of optionsList)
684
687
  {
685
- const { rtpParameters } = options;
686
- const localId = rtpParameters.mid || String(this._mapMidTransceiver.size);
688
+ const { trackId, rtpParameters } = options;
689
+ const localId = mapLocalId.get(trackId);
687
690
  const answerMediaObject = localSdpObject.media
688
691
  .find((m: any) => String(m.mid) === localId);
689
692
 
@@ -709,8 +712,8 @@ export class Firefox60 extends HandlerInterface
709
712
 
710
713
  for (const options of optionsList)
711
714
  {
712
- const { rtpParameters } = options;
713
- const localId = rtpParameters.mid || String(this._mapMidTransceiver.size);
715
+ const { trackId } = options;
716
+ const localId = mapLocalId.get(trackId)!;
714
717
  const transceiver = this._pc.getTransceivers()
715
718
  .find((t: RTCRtpTransceiver) => t.mid === localId);
716
719
 
@@ -762,19 +765,22 @@ export class Firefox60 extends HandlerInterface
762
765
  this._mapMidTransceiver.delete(localId);
763
766
  }
764
767
 
765
- async pauseReceiving(localId: string): Promise<void>
768
+ async pauseReceiving(localIds: string[]): Promise<void>
766
769
  {
767
770
  this._assertRecvDirection();
768
771
 
769
- logger.debug('pauseReceiving() [localId:%s]', localId);
772
+ for (const localId of localIds)
773
+ {
774
+ logger.debug('pauseReceiving() [localId:%s]', localId);
770
775
 
771
- const transceiver = this._mapMidTransceiver.get(localId);
776
+ const transceiver = this._mapMidTransceiver.get(localId);
772
777
 
773
- if (!transceiver)
774
- throw new Error('associated RTCRtpTransceiver not found');
778
+ if (!transceiver)
779
+ throw new Error('associated RTCRtpTransceiver not found');
780
+
781
+ transceiver.direction = 'inactive';
782
+ }
775
783
 
776
- transceiver.direction = 'inactive';
777
-
778
784
  const offer = { type: 'offer', sdp: this._remoteSdp!.getSdp() };
779
785
 
780
786
  logger.debug(
@@ -792,19 +798,22 @@ export class Firefox60 extends HandlerInterface
792
798
  await this._pc.setLocalDescription(answer);
793
799
  }
794
800
 
795
- async resumeReceiving(localId: string): Promise<void>
801
+ async resumeReceiving(localIds: string[]): Promise<void>
796
802
  {
797
803
  this._assertRecvDirection();
798
804
 
799
- logger.debug('resumeReceiving() [localId:%s]', localId);
805
+ for (const localId of localIds)
806
+ {
807
+ logger.debug('resumeReceiving() [localId:%s]', localId);
800
808
 
801
- const transceiver = this._mapMidTransceiver.get(localId);
809
+ const transceiver = this._mapMidTransceiver.get(localId);
802
810
 
803
- if (!transceiver)
804
- throw new Error('associated RTCRtpTransceiver not found');
811
+ if (!transceiver)
812
+ throw new Error('associated RTCRtpTransceiver not found');
813
+
814
+ transceiver.direction = 'recvonly';
815
+ }
805
816
 
806
- transceiver.direction = 'recvonly';
807
-
808
817
  const offer = { type: 'offer', sdp: this._remoteSdp!.getSdp() };
809
818
 
810
819
  logger.debug(
@@ -141,9 +141,9 @@ export abstract class HandlerInterface extends EnhancedEventEmitter
141
141
 
142
142
  abstract stopReceiving(localId: string): Promise<void>;
143
143
 
144
- abstract pauseReceiving(localId: string): Promise<void>;
144
+ abstract pauseReceiving(localIds: string[]): Promise<void>;
145
145
 
146
- abstract resumeReceiving(localId: string): Promise<void>;
146
+ abstract resumeReceiving(localIds: string[]): Promise<void>;
147
147
 
148
148
  abstract getReceiverStats(localId: string): Promise<RTCStatsReport>;
149
149
 
@@ -594,6 +594,7 @@ export class ReactNative extends HandlerInterface
594
594
  this._assertRecvDirection();
595
595
 
596
596
  const results: HandlerReceiveResult[] = [];
597
+ const mapStreamId: Map<string, string> = new Map();
597
598
 
598
599
  for (const options of optionsList)
599
600
  {
@@ -613,6 +614,8 @@ export class ReactNative extends HandlerInterface
613
614
 
614
615
  streamId += `-hack-${utils.generateRandomNumber()}`;
615
616
 
617
+ mapStreamId.set(trackId, streamId);
618
+
616
619
  this._remoteSdp!.receive(
617
620
  {
618
621
  mid,
@@ -672,7 +675,7 @@ export class ReactNative extends HandlerInterface
672
675
  const { kind, trackId, rtpParameters } = options;
673
676
  const localId = trackId;
674
677
  const mid = kind;
675
- const streamId = rtpParameters.rtcp!.cname!;
678
+ const streamId = mapStreamId.get(trackId);
676
679
  const stream = this._pc.getRemoteStreams()
677
680
  .find((s: MediaStream) => s.id === streamId);
678
681
  const track = stream.getTrackById(localId);
@@ -722,14 +725,14 @@ export class ReactNative extends HandlerInterface
722
725
 
723
726
  async pauseReceiving(
724
727
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
725
- localId: string): Promise<void>
728
+ localIds: string[]): Promise<void>
726
729
  {
727
730
  // Unimplemented.
728
731
  }
729
732
 
730
733
  async resumeReceiving(
731
734
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
732
- localId: string): Promise<void>
735
+ localIds: string[]): Promise<void>
733
736
  {
734
737
  // Unimplemented.
735
738
  }
@@ -790,14 +790,14 @@ export class Safari11 extends HandlerInterface
790
790
 
791
791
  async pauseReceiving(
792
792
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
793
- localId: string): Promise<void>
793
+ localIds: string[]): Promise<void>
794
794
  {
795
795
  // Unimplemented.
796
796
  }
797
797
 
798
798
  async resumeReceiving(
799
799
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
800
- localId: string): Promise<void>
800
+ localIds: string[]): Promise<void>
801
801
  {
802
802
  // Unimplemented.
803
803
  }
@@ -609,6 +609,7 @@ export class Safari12 extends HandlerInterface
609
609
  this._assertRecvDirection();
610
610
 
611
611
  const results: HandlerReceiveResult[] = [];
612
+ const mapLocalId: Map<string, string> = new Map();
612
613
 
613
614
  for (const options of optionsList)
614
615
  {
@@ -618,6 +619,8 @@ export class Safari12 extends HandlerInterface
618
619
 
619
620
  const localId = rtpParameters.mid || String(this._mapMidTransceiver.size);
620
621
 
622
+ mapLocalId.set(trackId, localId);
623
+
621
624
  this._remoteSdp!.receive(
622
625
  {
623
626
  mid : localId,
@@ -641,8 +644,8 @@ export class Safari12 extends HandlerInterface
641
644
 
642
645
  for (const options of optionsList)
643
646
  {
644
- const { rtpParameters } = options;
645
- const localId = rtpParameters.mid || String(this._mapMidTransceiver.size);
647
+ const { trackId, rtpParameters } = options;
648
+ const localId = mapLocalId.get(trackId);
646
649
  const answerMediaObject = localSdpObject.media
647
650
  .find((m: any) => String(m.mid) === localId);
648
651
 
@@ -674,8 +677,8 @@ export class Safari12 extends HandlerInterface
674
677
 
675
678
  for (const options of optionsList)
676
679
  {
677
- const { rtpParameters } = options;
678
- const localId = rtpParameters.mid || String(this._mapMidTransceiver.size);
680
+ const { trackId } = options;
681
+ const localId = mapLocalId.get(trackId)!;
679
682
  const transceiver = this._pc.getTransceivers()
680
683
  .find((t: RTCRtpTransceiver) => t.mid === localId);
681
684
 
@@ -727,19 +730,22 @@ export class Safari12 extends HandlerInterface
727
730
  this._mapMidTransceiver.delete(localId);
728
731
  }
729
732
 
730
- async pauseReceiving(localId: string): Promise<void>
733
+ async pauseReceiving(localIds: string[]): Promise<void>
731
734
  {
732
735
  this._assertRecvDirection();
733
736
 
734
- logger.debug('pauseReceiving() [localId:%s]', localId);
737
+ for (const localId of localIds)
738
+ {
739
+ logger.debug('pauseReceiving() [localId:%s]', localId);
735
740
 
736
- const transceiver = this._mapMidTransceiver.get(localId);
741
+ const transceiver = this._mapMidTransceiver.get(localId);
737
742
 
738
- if (!transceiver)
739
- throw new Error('associated RTCRtpTransceiver not found');
743
+ if (!transceiver)
744
+ throw new Error('associated RTCRtpTransceiver not found');
745
+
746
+ transceiver.direction = 'inactive';
747
+ }
740
748
 
741
- transceiver.direction = 'inactive';
742
-
743
749
  const offer = { type: 'offer', sdp: this._remoteSdp!.getSdp() };
744
750
 
745
751
  logger.debug(
@@ -757,19 +763,22 @@ export class Safari12 extends HandlerInterface
757
763
  await this._pc.setLocalDescription(answer);
758
764
  }
759
765
 
760
- async resumeReceiving(localId: string): Promise<void>
766
+ async resumeReceiving(localIds: string[]): Promise<void>
761
767
  {
762
768
  this._assertRecvDirection();
763
769
 
764
- logger.debug('resumeReceiving() [localId:%s]', localId);
770
+ for (const localId of localIds)
771
+ {
772
+ logger.debug('resumeReceiving() [localId:%s]', localId);
765
773
 
766
- const transceiver = this._mapMidTransceiver.get(localId);
774
+ const transceiver = this._mapMidTransceiver.get(localId);
767
775
 
768
- if (!transceiver)
769
- throw new Error('associated RTCRtpTransceiver not found');
776
+ if (!transceiver)
777
+ throw new Error('associated RTCRtpTransceiver not found');
778
+
779
+ transceiver.direction = 'recvonly';
780
+ }
770
781
 
771
- transceiver.direction = 'recvonly';
772
-
773
782
  const offer = { type: 'offer', sdp: this._remoteSdp!.getSdp() };
774
783
 
775
784
  logger.debug(