@wazo/sdk 0.38.4 → 0.38.7

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 (99) hide show
  1. package/README.md +4 -4
  2. package/dist/wazo-sdk.js +2 -2
  3. package/esm/__tests__/api-client.test.js +6 -0
  4. package/esm/__tests__/web-rtc-client.test.js +88 -3
  5. package/esm/api/calld.js +6 -0
  6. package/esm/api/ctid-ng.js +6 -0
  7. package/esm/api-client.js +6 -0
  8. package/esm/checker/Checker.js +38 -3
  9. package/esm/checker/checks/aor.js +6 -0
  10. package/esm/checker/checks/api.js +6 -0
  11. package/esm/checker/checks/index.js +38 -3
  12. package/esm/checker/checks/webrtc-transport.js +38 -3
  13. package/esm/checker/checks/webrtc.js +38 -3
  14. package/esm/domain/AdHocAPIConference.js +6 -0
  15. package/esm/domain/Call.js +6 -0
  16. package/esm/domain/CallSession.js +1 -1
  17. package/esm/domain/Features.js +6 -0
  18. package/esm/domain/Phone/CTIPhone.js +7 -1
  19. package/esm/domain/Phone/WebRTCPhone.js +3 -3
  20. package/esm/domain/__tests__/Call.test.js +6 -0
  21. package/esm/domain/__tests__/CallSession.test.js +1 -1
  22. package/esm/domain/__tests__/IndirectTransfer.test.js +1 -1
  23. package/esm/domain/__tests__/Line.test.js +5 -5
  24. package/esm/domain/__tests__/Room.test.js +1 -1
  25. package/esm/index.js +42 -8
  26. package/esm/lib/WazoSessionDescriptionHandler.js +30 -1
  27. package/esm/service/CallApi.js +6 -0
  28. package/esm/service/getApiClient.js +6 -0
  29. package/esm/simple/Auth.js +42 -8
  30. package/esm/simple/Configuration.js +42 -8
  31. package/esm/simple/Directory.js +6 -0
  32. package/esm/simple/Phone.js +42 -8
  33. package/esm/simple/Softphone.js +1 -2
  34. package/esm/simple/index.js +42 -8
  35. package/esm/simple/room/LocalParticipant.js +42 -8
  36. package/esm/simple/room/Participant.js +42 -8
  37. package/esm/simple/room/RemoteParticipant.js +42 -8
  38. package/esm/simple/room/Room.js +42 -8
  39. package/esm/simple/room/SipRoom.js +42 -8
  40. package/esm/simple/room/Stream.js +42 -8
  41. package/esm/simple/room/__tests__/RemoteParticipant.test.js +42 -8
  42. package/esm/simple/utils.js +42 -8
  43. package/esm/utils/__tests__/sdp.test.js +50 -0
  44. package/esm/utils/sdp.js +19 -1
  45. package/esm/web-rtc-client.js +38 -3
  46. package/lib/__tests__/api-client.test.js +6 -0
  47. package/lib/__tests__/web-rtc-client.test.js +88 -3
  48. package/lib/api/calld.js +6 -0
  49. package/lib/api/ctid-ng.js +6 -0
  50. package/lib/api-client.js +6 -0
  51. package/lib/checker/Checker.js +38 -3
  52. package/lib/checker/checks/aor.js +6 -0
  53. package/lib/checker/checks/api.js +6 -0
  54. package/lib/checker/checks/index.js +38 -3
  55. package/lib/checker/checks/webrtc-transport.js +38 -3
  56. package/lib/checker/checks/webrtc.js +38 -3
  57. package/lib/domain/AdHocAPIConference.js +6 -0
  58. package/lib/domain/Call.js +6 -0
  59. package/lib/domain/CallSession.js +1 -1
  60. package/lib/domain/Features.js +6 -0
  61. package/lib/domain/Phone/CTIPhone.js +7 -1
  62. package/lib/domain/Phone/WebRTCPhone.js +3 -3
  63. package/lib/domain/__tests__/Call.test.js +6 -0
  64. package/lib/domain/__tests__/CallSession.test.js +1 -1
  65. package/lib/domain/__tests__/IndirectTransfer.test.js +1 -1
  66. package/lib/domain/__tests__/Line.test.js +5 -5
  67. package/lib/domain/__tests__/Room.test.js +1 -1
  68. package/lib/index.js +42 -8
  69. package/lib/lib/WazoSessionDescriptionHandler.js +30 -1
  70. package/lib/service/CallApi.js +6 -0
  71. package/lib/service/getApiClient.js +6 -0
  72. package/lib/simple/Auth.js +42 -8
  73. package/lib/simple/Configuration.js +42 -8
  74. package/lib/simple/Directory.js +6 -0
  75. package/lib/simple/Phone.js +42 -8
  76. package/lib/simple/Softphone.js +1 -2
  77. package/lib/simple/index.js +42 -8
  78. package/lib/simple/room/LocalParticipant.js +42 -8
  79. package/lib/simple/room/Participant.js +42 -8
  80. package/lib/simple/room/RemoteParticipant.js +42 -8
  81. package/lib/simple/room/Room.js +42 -8
  82. package/lib/simple/room/SipRoom.js +42 -8
  83. package/lib/simple/room/Stream.js +42 -8
  84. package/lib/simple/room/__tests__/RemoteParticipant.test.js +42 -8
  85. package/lib/simple/utils.js +42 -8
  86. package/lib/utils/__tests__/sdp.test.js +50 -0
  87. package/lib/utils/sdp.js +19 -0
  88. package/lib/web-rtc-client.js +38 -3
  89. package/package.json +1 -1
  90. package/src/__tests__/web-rtc-client.test.js +50 -0
  91. package/src/domain/Call.js +6 -0
  92. package/src/domain/CallSession.js +1 -1
  93. package/src/domain/Phone/WebRTCPhone.js +2 -2
  94. package/src/domain/__tests__/Line.test.js +5 -5
  95. package/src/lib/WazoSessionDescriptionHandler.js +13 -2
  96. package/src/simple/Softphone.js +1 -2
  97. package/src/utils/__tests__/sdp.test.js +33 -1
  98. package/src/utils/sdp.js +18 -0
  99. package/src/web-rtc-client.js +2 -2
package/lib/api/calld.js CHANGED
@@ -974,6 +974,7 @@ const RECORD_STATE_ACTIVE = 'active';
974
974
 
975
975
 
976
976
 
977
+
977
978
 
978
979
 
979
980
 
@@ -984,6 +985,7 @@ const RECORD_STATE_ACTIVE = 'active';
984
985
 
985
986
 
986
987
 
988
+
987
989
 
988
990
 
989
991
 
@@ -1012,6 +1014,7 @@ class Call {
1012
1014
 
1013
1015
 
1014
1016
 
1017
+
1015
1018
 
1016
1019
 
1017
1020
 
@@ -1036,6 +1039,7 @@ class Call {
1036
1039
  calleeNumber: plain.peer_caller_id_number,
1037
1040
  dialedExtension: plain.dialed_extension,
1038
1041
  isCaller: plain.is_caller,
1042
+ isVideo: plain.is_video,
1039
1043
  muted: plain.muted,
1040
1044
  onHold: plain.on_hold,
1041
1045
  status: plain.status,
@@ -1059,6 +1063,7 @@ class Call {
1059
1063
  calleeNumber,
1060
1064
  dialedExtension,
1061
1065
  isCaller,
1066
+ isVideo,
1062
1067
  lineId,
1063
1068
  muted,
1064
1069
  onHold,
@@ -1082,6 +1087,7 @@ class Call {
1082
1087
  this.startingTime = startingTime;
1083
1088
  this.talkingToIds = talkingToIds || [];
1084
1089
  this.recording = recording;
1090
+ this.isVideo = !!isVideo;
1085
1091
 
1086
1092
  // Useful to compare instead of instanceof with minified code
1087
1093
  this.type = 'Call';
@@ -977,6 +977,7 @@ const RECORD_STATE_ACTIVE = 'active';
977
977
 
978
978
 
979
979
 
980
+
980
981
 
981
982
 
982
983
 
@@ -987,6 +988,7 @@ const RECORD_STATE_ACTIVE = 'active';
987
988
 
988
989
 
989
990
 
991
+
990
992
 
991
993
 
992
994
 
@@ -1015,6 +1017,7 @@ class Call {
1015
1017
 
1016
1018
 
1017
1019
 
1020
+
1018
1021
 
1019
1022
 
1020
1023
 
@@ -1039,6 +1042,7 @@ class Call {
1039
1042
  calleeNumber: plain.peer_caller_id_number,
1040
1043
  dialedExtension: plain.dialed_extension,
1041
1044
  isCaller: plain.is_caller,
1045
+ isVideo: plain.is_video,
1042
1046
  muted: plain.muted,
1043
1047
  onHold: plain.on_hold,
1044
1048
  status: plain.status,
@@ -1062,6 +1066,7 @@ class Call {
1062
1066
  calleeNumber,
1063
1067
  dialedExtension,
1064
1068
  isCaller,
1069
+ isVideo,
1065
1070
  lineId,
1066
1071
  muted,
1067
1072
  onHold,
@@ -1085,6 +1090,7 @@ class Call {
1085
1090
  this.startingTime = startingTime;
1086
1091
  this.talkingToIds = talkingToIds || [];
1087
1092
  this.recording = recording;
1093
+ this.isVideo = !!isVideo;
1088
1094
 
1089
1095
  // Useful to compare instead of instanceof with minified code
1090
1096
  this.type = 'Call';
package/lib/api-client.js CHANGED
@@ -3057,6 +3057,7 @@ const RECORD_STATE_ACTIVE = 'active';
3057
3057
 
3058
3058
 
3059
3059
 
3060
+
3060
3061
 
3061
3062
 
3062
3063
 
@@ -3067,6 +3068,7 @@ const RECORD_STATE_ACTIVE = 'active';
3067
3068
 
3068
3069
 
3069
3070
 
3071
+
3070
3072
 
3071
3073
 
3072
3074
 
@@ -3095,6 +3097,7 @@ class Call {
3095
3097
 
3096
3098
 
3097
3099
 
3100
+
3098
3101
 
3099
3102
 
3100
3103
 
@@ -3119,6 +3122,7 @@ class Call {
3119
3122
  calleeNumber: plain.peer_caller_id_number,
3120
3123
  dialedExtension: plain.dialed_extension,
3121
3124
  isCaller: plain.is_caller,
3125
+ isVideo: plain.is_video,
3122
3126
  muted: plain.muted,
3123
3127
  onHold: plain.on_hold,
3124
3128
  status: plain.status,
@@ -3142,6 +3146,7 @@ class Call {
3142
3146
  calleeNumber,
3143
3147
  dialedExtension,
3144
3148
  isCaller,
3149
+ isVideo,
3145
3150
  lineId,
3146
3151
  muted,
3147
3152
  onHold,
@@ -3165,6 +3170,7 @@ class Call {
3165
3170
  this.startingTime = startingTime;
3166
3171
  this.talkingToIds = talkingToIds || [];
3167
3172
  this.recording = recording;
3173
+ this.isVideo = !!isVideo;
3168
3174
 
3169
3175
  // Useful to compare instead of instanceof with minified code
3170
3176
  this.type = 'Call';
@@ -3079,6 +3079,7 @@ const RECORD_STATE_ACTIVE = 'active';
3079
3079
 
3080
3080
 
3081
3081
 
3082
+
3082
3083
 
3083
3084
 
3084
3085
 
@@ -3089,6 +3090,7 @@ const RECORD_STATE_ACTIVE = 'active';
3089
3090
 
3090
3091
 
3091
3092
 
3093
+
3092
3094
 
3093
3095
 
3094
3096
 
@@ -3117,6 +3119,7 @@ class Call {
3117
3119
 
3118
3120
 
3119
3121
 
3122
+
3120
3123
 
3121
3124
 
3122
3125
 
@@ -3141,6 +3144,7 @@ class Call {
3141
3144
  calleeNumber: plain.peer_caller_id_number,
3142
3145
  dialedExtension: plain.dialed_extension,
3143
3146
  isCaller: plain.is_caller,
3147
+ isVideo: plain.is_video,
3144
3148
  muted: plain.muted,
3145
3149
  onHold: plain.on_hold,
3146
3150
  status: plain.status,
@@ -3164,6 +3168,7 @@ class Call {
3164
3168
  calleeNumber,
3165
3169
  dialedExtension,
3166
3170
  isCaller,
3171
+ isVideo,
3167
3172
  lineId,
3168
3173
  muted,
3169
3174
  onHold,
@@ -3187,6 +3192,7 @@ class Call {
3187
3192
  this.startingTime = startingTime;
3188
3193
  this.talkingToIds = talkingToIds || [];
3189
3194
  this.recording = recording;
3195
+ this.isVideo = !!isVideo;
3190
3196
 
3191
3197
  // Useful to compare instead of instanceof with minified code
3192
3198
  this.type = 'Call';
@@ -5518,6 +5524,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
5518
5524
  return fixed;
5519
5525
  };
5520
5526
 
5527
+ const addIcesInAllBundles = (sdp ) => {
5528
+ const parsedSdp = sdpParser__default['default'].parse(sdp);
5529
+
5530
+ const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
5531
+ if (!mediaWithCandidate) {
5532
+ return sdp;
5533
+ }
5534
+
5535
+ const { candidates } = mediaWithCandidate;
5536
+
5537
+ parsedSdp.media = parsedSdp.media.map(media => ({
5538
+ ...media,
5539
+ candidates: media.candidates || candidates,
5540
+ }));
5541
+
5542
+ return sdpParser__default['default'].write(parsedSdp);
5543
+ };
5544
+
5521
5545
  /* global RTCSessionDescriptionInit, navigator */
5522
5546
 
5523
5547
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
@@ -5616,6 +5640,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5616
5640
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5617
5641
  if (event.candidate) {
5618
5642
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5643
+
5644
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
5645
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
5646
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
5647
+ ice: event.candidate.candidate,
5648
+ });
5649
+ this.iceGatheringComplete();
5650
+ }
5619
5651
  }
5620
5652
  };
5621
5653
 
@@ -5639,7 +5671,10 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5639
5671
 
5640
5672
  // Check if we got ICEs
5641
5673
  if (sdp.indexOf('a=candidate') !== -1) {
5642
- return description;
5674
+ return {
5675
+ type: description.type,
5676
+ sdp: addIcesInAllBundles(sdp),
5677
+ };
5643
5678
  }
5644
5679
 
5645
5680
  wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
@@ -7001,11 +7036,11 @@ class WebRTCClient extends Emitter {
7001
7036
  });
7002
7037
  }
7003
7038
 
7004
- changeAudioInputDevice(id , session ) {
7039
+ changeAudioInputDevice(id , session , force ) {
7005
7040
  const currentId = this.getAudioDeviceId();
7006
7041
  logger$1.info('setting audio input device', { id, currentId, session: !!session });
7007
7042
 
7008
- if (id === currentId) {
7043
+ if (!force && id === currentId) {
7009
7044
  return null;
7010
7045
  }
7011
7046
 
@@ -3057,6 +3057,7 @@ const RECORD_STATE_ACTIVE = 'active';
3057
3057
 
3058
3058
 
3059
3059
 
3060
+
3060
3061
 
3061
3062
 
3062
3063
 
@@ -3067,6 +3068,7 @@ const RECORD_STATE_ACTIVE = 'active';
3067
3068
 
3068
3069
 
3069
3070
 
3071
+
3070
3072
 
3071
3073
 
3072
3074
 
@@ -3095,6 +3097,7 @@ class Call {
3095
3097
 
3096
3098
 
3097
3099
 
3100
+
3098
3101
 
3099
3102
 
3100
3103
 
@@ -3119,6 +3122,7 @@ class Call {
3119
3122
  calleeNumber: plain.peer_caller_id_number,
3120
3123
  dialedExtension: plain.dialed_extension,
3121
3124
  isCaller: plain.is_caller,
3125
+ isVideo: plain.is_video,
3122
3126
  muted: plain.muted,
3123
3127
  onHold: plain.on_hold,
3124
3128
  status: plain.status,
@@ -3142,6 +3146,7 @@ class Call {
3142
3146
  calleeNumber,
3143
3147
  dialedExtension,
3144
3148
  isCaller,
3149
+ isVideo,
3145
3150
  lineId,
3146
3151
  muted,
3147
3152
  onHold,
@@ -3165,6 +3170,7 @@ class Call {
3165
3170
  this.startingTime = startingTime;
3166
3171
  this.talkingToIds = talkingToIds || [];
3167
3172
  this.recording = recording;
3173
+ this.isVideo = !!isVideo;
3168
3174
 
3169
3175
  // Useful to compare instead of instanceof with minified code
3170
3176
  this.type = 'Call';
@@ -3057,6 +3057,7 @@ const RECORD_STATE_ACTIVE = 'active';
3057
3057
 
3058
3058
 
3059
3059
 
3060
+
3060
3061
 
3061
3062
 
3062
3063
 
@@ -3067,6 +3068,7 @@ const RECORD_STATE_ACTIVE = 'active';
3067
3068
 
3068
3069
 
3069
3070
 
3071
+
3070
3072
 
3071
3073
 
3072
3074
 
@@ -3095,6 +3097,7 @@ class Call {
3095
3097
 
3096
3098
 
3097
3099
 
3100
+
3098
3101
 
3099
3102
 
3100
3103
 
@@ -3119,6 +3122,7 @@ class Call {
3119
3122
  calleeNumber: plain.peer_caller_id_number,
3120
3123
  dialedExtension: plain.dialed_extension,
3121
3124
  isCaller: plain.is_caller,
3125
+ isVideo: plain.is_video,
3122
3126
  muted: plain.muted,
3123
3127
  onHold: plain.on_hold,
3124
3128
  status: plain.status,
@@ -3142,6 +3146,7 @@ class Call {
3142
3146
  calleeNumber,
3143
3147
  dialedExtension,
3144
3148
  isCaller,
3149
+ isVideo,
3145
3150
  lineId,
3146
3151
  muted,
3147
3152
  onHold,
@@ -3165,6 +3170,7 @@ class Call {
3165
3170
  this.startingTime = startingTime;
3166
3171
  this.talkingToIds = talkingToIds || [];
3167
3172
  this.recording = recording;
3173
+ this.isVideo = !!isVideo;
3168
3174
 
3169
3175
  // Useful to compare instead of instanceof with minified code
3170
3176
  this.type = 'Call';
@@ -3079,6 +3079,7 @@ const RECORD_STATE_ACTIVE = 'active';
3079
3079
 
3080
3080
 
3081
3081
 
3082
+
3082
3083
 
3083
3084
 
3084
3085
 
@@ -3089,6 +3090,7 @@ const RECORD_STATE_ACTIVE = 'active';
3089
3090
 
3090
3091
 
3091
3092
 
3093
+
3092
3094
 
3093
3095
 
3094
3096
 
@@ -3117,6 +3119,7 @@ class Call {
3117
3119
 
3118
3120
 
3119
3121
 
3122
+
3120
3123
 
3121
3124
 
3122
3125
 
@@ -3141,6 +3144,7 @@ class Call {
3141
3144
  calleeNumber: plain.peer_caller_id_number,
3142
3145
  dialedExtension: plain.dialed_extension,
3143
3146
  isCaller: plain.is_caller,
3147
+ isVideo: plain.is_video,
3144
3148
  muted: plain.muted,
3145
3149
  onHold: plain.on_hold,
3146
3150
  status: plain.status,
@@ -3164,6 +3168,7 @@ class Call {
3164
3168
  calleeNumber,
3165
3169
  dialedExtension,
3166
3170
  isCaller,
3171
+ isVideo,
3167
3172
  lineId,
3168
3173
  muted,
3169
3174
  onHold,
@@ -3187,6 +3192,7 @@ class Call {
3187
3192
  this.startingTime = startingTime;
3188
3193
  this.talkingToIds = talkingToIds || [];
3189
3194
  this.recording = recording;
3195
+ this.isVideo = !!isVideo;
3190
3196
 
3191
3197
  // Useful to compare instead of instanceof with minified code
3192
3198
  this.type = 'Call';
@@ -5518,6 +5524,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
5518
5524
  return fixed;
5519
5525
  };
5520
5526
 
5527
+ const addIcesInAllBundles = (sdp ) => {
5528
+ const parsedSdp = sdpParser__default['default'].parse(sdp);
5529
+
5530
+ const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
5531
+ if (!mediaWithCandidate) {
5532
+ return sdp;
5533
+ }
5534
+
5535
+ const { candidates } = mediaWithCandidate;
5536
+
5537
+ parsedSdp.media = parsedSdp.media.map(media => ({
5538
+ ...media,
5539
+ candidates: media.candidates || candidates,
5540
+ }));
5541
+
5542
+ return sdpParser__default['default'].write(parsedSdp);
5543
+ };
5544
+
5521
5545
  /* global RTCSessionDescriptionInit, navigator */
5522
5546
 
5523
5547
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
@@ -5616,6 +5640,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5616
5640
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5617
5641
  if (event.candidate) {
5618
5642
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5643
+
5644
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
5645
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
5646
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
5647
+ ice: event.candidate.candidate,
5648
+ });
5649
+ this.iceGatheringComplete();
5650
+ }
5619
5651
  }
5620
5652
  };
5621
5653
 
@@ -5639,7 +5671,10 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5639
5671
 
5640
5672
  // Check if we got ICEs
5641
5673
  if (sdp.indexOf('a=candidate') !== -1) {
5642
- return description;
5674
+ return {
5675
+ type: description.type,
5676
+ sdp: addIcesInAllBundles(sdp),
5677
+ };
5643
5678
  }
5644
5679
 
5645
5680
  wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
@@ -7001,11 +7036,11 @@ class WebRTCClient extends Emitter {
7001
7036
  });
7002
7037
  }
7003
7038
 
7004
- changeAudioInputDevice(id , session ) {
7039
+ changeAudioInputDevice(id , session , force ) {
7005
7040
  const currentId = this.getAudioDeviceId();
7006
7041
  logger.info('setting audio input device', { id, currentId, session: !!session });
7007
7042
 
7008
- if (id === currentId) {
7043
+ if (!force && id === currentId) {
7009
7044
  return null;
7010
7045
  }
7011
7046
 
@@ -787,6 +787,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
787
787
  return fixed;
788
788
  };
789
789
 
790
+ const addIcesInAllBundles = (sdp ) => {
791
+ const parsedSdp = sdpParser__default['default'].parse(sdp);
792
+
793
+ const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
794
+ if (!mediaWithCandidate) {
795
+ return sdp;
796
+ }
797
+
798
+ const { candidates } = mediaWithCandidate;
799
+
800
+ parsedSdp.media = parsedSdp.media.map(media => ({
801
+ ...media,
802
+ candidates: media.candidates || candidates,
803
+ }));
804
+
805
+ return sdpParser__default['default'].write(parsedSdp);
806
+ };
807
+
790
808
  /* global RTCSessionDescriptionInit, navigator */
791
809
 
792
810
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
@@ -885,6 +903,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
885
903
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
886
904
  if (event.candidate) {
887
905
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
906
+
907
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
908
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
909
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
910
+ ice: event.candidate.candidate,
911
+ });
912
+ this.iceGatheringComplete();
913
+ }
888
914
  }
889
915
  };
890
916
 
@@ -908,7 +934,10 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
908
934
 
909
935
  // Check if we got ICEs
910
936
  if (sdp.indexOf('a=candidate') !== -1) {
911
- return description;
937
+ return {
938
+ type: description.type,
939
+ sdp: addIcesInAllBundles(sdp),
940
+ };
912
941
  }
913
942
 
914
943
  wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
@@ -3608,6 +3637,7 @@ const RECORD_STATE_ACTIVE = 'active';
3608
3637
 
3609
3638
 
3610
3639
 
3640
+
3611
3641
 
3612
3642
 
3613
3643
 
@@ -3618,6 +3648,7 @@ const RECORD_STATE_ACTIVE = 'active';
3618
3648
 
3619
3649
 
3620
3650
 
3651
+
3621
3652
 
3622
3653
 
3623
3654
 
@@ -3646,6 +3677,7 @@ class Call {
3646
3677
 
3647
3678
 
3648
3679
 
3680
+
3649
3681
 
3650
3682
 
3651
3683
 
@@ -3670,6 +3702,7 @@ class Call {
3670
3702
  calleeNumber: plain.peer_caller_id_number,
3671
3703
  dialedExtension: plain.dialed_extension,
3672
3704
  isCaller: plain.is_caller,
3705
+ isVideo: plain.is_video,
3673
3706
  muted: plain.muted,
3674
3707
  onHold: plain.on_hold,
3675
3708
  status: plain.status,
@@ -3693,6 +3726,7 @@ class Call {
3693
3726
  calleeNumber,
3694
3727
  dialedExtension,
3695
3728
  isCaller,
3729
+ isVideo,
3696
3730
  lineId,
3697
3731
  muted,
3698
3732
  onHold,
@@ -3716,6 +3750,7 @@ class Call {
3716
3750
  this.startingTime = startingTime;
3717
3751
  this.talkingToIds = talkingToIds || [];
3718
3752
  this.recording = recording;
3753
+ this.isVideo = !!isVideo;
3719
3754
 
3720
3755
  // Useful to compare instead of instanceof with minified code
3721
3756
  this.type = 'Call';
@@ -6415,11 +6450,11 @@ class WebRTCClient extends Emitter {
6415
6450
  });
6416
6451
  }
6417
6452
 
6418
- changeAudioInputDevice(id , session ) {
6453
+ changeAudioInputDevice(id , session , force ) {
6419
6454
  const currentId = this.getAudioDeviceId();
6420
6455
  logger.info('setting audio input device', { id, currentId, session: !!session });
6421
6456
 
6422
- if (id === currentId) {
6457
+ if (!force && id === currentId) {
6423
6458
  return null;
6424
6459
  }
6425
6460
 
@@ -787,6 +787,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
787
787
  return fixed;
788
788
  };
789
789
 
790
+ const addIcesInAllBundles = (sdp ) => {
791
+ const parsedSdp = sdpParser__default['default'].parse(sdp);
792
+
793
+ const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
794
+ if (!mediaWithCandidate) {
795
+ return sdp;
796
+ }
797
+
798
+ const { candidates } = mediaWithCandidate;
799
+
800
+ parsedSdp.media = parsedSdp.media.map(media => ({
801
+ ...media,
802
+ candidates: media.candidates || candidates,
803
+ }));
804
+
805
+ return sdpParser__default['default'].write(parsedSdp);
806
+ };
807
+
790
808
  /* global RTCSessionDescriptionInit, navigator */
791
809
 
792
810
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
@@ -885,6 +903,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
885
903
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
886
904
  if (event.candidate) {
887
905
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
906
+
907
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
908
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
909
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
910
+ ice: event.candidate.candidate,
911
+ });
912
+ this.iceGatheringComplete();
913
+ }
888
914
  }
889
915
  };
890
916
 
@@ -908,7 +934,10 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
908
934
 
909
935
  // Check if we got ICEs
910
936
  if (sdp.indexOf('a=candidate') !== -1) {
911
- return description;
937
+ return {
938
+ type: description.type,
939
+ sdp: addIcesInAllBundles(sdp),
940
+ };
912
941
  }
913
942
 
914
943
  wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
@@ -3608,6 +3637,7 @@ const RECORD_STATE_ACTIVE = 'active';
3608
3637
 
3609
3638
 
3610
3639
 
3640
+
3611
3641
 
3612
3642
 
3613
3643
 
@@ -3618,6 +3648,7 @@ const RECORD_STATE_ACTIVE = 'active';
3618
3648
 
3619
3649
 
3620
3650
 
3651
+
3621
3652
 
3622
3653
 
3623
3654
 
@@ -3646,6 +3677,7 @@ class Call {
3646
3677
 
3647
3678
 
3648
3679
 
3680
+
3649
3681
 
3650
3682
 
3651
3683
 
@@ -3670,6 +3702,7 @@ class Call {
3670
3702
  calleeNumber: plain.peer_caller_id_number,
3671
3703
  dialedExtension: plain.dialed_extension,
3672
3704
  isCaller: plain.is_caller,
3705
+ isVideo: plain.is_video,
3673
3706
  muted: plain.muted,
3674
3707
  onHold: plain.on_hold,
3675
3708
  status: plain.status,
@@ -3693,6 +3726,7 @@ class Call {
3693
3726
  calleeNumber,
3694
3727
  dialedExtension,
3695
3728
  isCaller,
3729
+ isVideo,
3696
3730
  lineId,
3697
3731
  muted,
3698
3732
  onHold,
@@ -3716,6 +3750,7 @@ class Call {
3716
3750
  this.startingTime = startingTime;
3717
3751
  this.talkingToIds = talkingToIds || [];
3718
3752
  this.recording = recording;
3753
+ this.isVideo = !!isVideo;
3719
3754
 
3720
3755
  // Useful to compare instead of instanceof with minified code
3721
3756
  this.type = 'Call';
@@ -6415,11 +6450,11 @@ class WebRTCClient extends Emitter {
6415
6450
  });
6416
6451
  }
6417
6452
 
6418
- changeAudioInputDevice(id , session ) {
6453
+ changeAudioInputDevice(id , session , force ) {
6419
6454
  const currentId = this.getAudioDeviceId();
6420
6455
  logger.info('setting audio input device', { id, currentId, session: !!session });
6421
6456
 
6422
- if (id === currentId) {
6457
+ if (!force && id === currentId) {
6423
6458
  return null;
6424
6459
  }
6425
6460