@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
@@ -49,6 +49,7 @@ const RECORD_STATE_ACTIVE = 'active';
49
49
 
50
50
 
51
51
 
52
+
52
53
 
53
54
 
54
55
 
@@ -59,6 +60,7 @@ const RECORD_STATE_ACTIVE = 'active';
59
60
 
60
61
 
61
62
 
63
+
62
64
 
63
65
 
64
66
 
@@ -87,6 +89,7 @@ class Call {
87
89
 
88
90
 
89
91
 
92
+
90
93
 
91
94
 
92
95
 
@@ -111,6 +114,7 @@ class Call {
111
114
  calleeNumber: plain.peer_caller_id_number,
112
115
  dialedExtension: plain.dialed_extension,
113
116
  isCaller: plain.is_caller,
117
+ isVideo: plain.is_video,
114
118
  muted: plain.muted,
115
119
  onHold: plain.on_hold,
116
120
  status: plain.status,
@@ -134,6 +138,7 @@ class Call {
134
138
  calleeNumber,
135
139
  dialedExtension,
136
140
  isCaller,
141
+ isVideo,
137
142
  lineId,
138
143
  muted,
139
144
  onHold,
@@ -157,6 +162,7 @@ class Call {
157
162
  this.startingTime = startingTime;
158
163
  this.talkingToIds = talkingToIds || [];
159
164
  this.recording = recording;
165
+ this.isVideo = !!isVideo;
160
166
 
161
167
  // Useful to compare instead of instanceof with minified code
162
168
  this.type = 'Call';
@@ -630,7 +636,7 @@ class CallSession {
630
636
  ringing: call.isRinging(),
631
637
  answered: call.isUp(),
632
638
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
633
- cameraEnabled: false,
639
+ cameraEnabled: call.isVideo,
634
640
  dialedExtension: call.dialedExtension,
635
641
  call,
636
642
  conference: false, // @FIXME?
@@ -5897,6 +5903,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
5897
5903
  return fixed;
5898
5904
  };
5899
5905
 
5906
+ const addIcesInAllBundles = (sdp ) => {
5907
+ const parsedSdp = sdpParser.parse(sdp);
5908
+
5909
+ const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
5910
+ if (!mediaWithCandidate) {
5911
+ return sdp;
5912
+ }
5913
+
5914
+ const { candidates } = mediaWithCandidate;
5915
+
5916
+ parsedSdp.media = parsedSdp.media.map(media => ({
5917
+ ...media,
5918
+ candidates: media.candidates || candidates,
5919
+ }));
5920
+
5921
+ return sdpParser.write(parsedSdp);
5922
+ };
5923
+
5900
5924
  /* global RTCSessionDescriptionInit, navigator */
5901
5925
 
5902
5926
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
@@ -5995,6 +6019,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5995
6019
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5996
6020
  if (event.candidate) {
5997
6021
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6022
+
6023
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6024
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6025
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6026
+ ice: event.candidate.candidate,
6027
+ });
6028
+ this.iceGatheringComplete();
6029
+ }
5998
6030
  }
5999
6031
  };
6000
6032
 
@@ -6018,7 +6050,10 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6018
6050
 
6019
6051
  // Check if we got ICEs
6020
6052
  if (sdp.indexOf('a=candidate') !== -1) {
6021
- return description;
6053
+ return {
6054
+ type: description.type,
6055
+ sdp: addIcesInAllBundles(sdp),
6056
+ };
6022
6057
  }
6023
6058
 
6024
6059
  wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
@@ -7478,11 +7513,11 @@ class WebRTCClient extends Emitter {
7478
7513
  });
7479
7514
  }
7480
7515
 
7481
- changeAudioInputDevice(id , session ) {
7516
+ changeAudioInputDevice(id , session , force ) {
7482
7517
  const currentId = this.getAudioDeviceId();
7483
7518
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7484
7519
 
7485
- if (id === currentId) {
7520
+ if (!force && id === currentId) {
7486
7521
  return null;
7487
7522
  }
7488
7523
 
@@ -9278,10 +9313,10 @@ class WebRTCPhone extends Emitter {
9278
9313
  this.audioRingVolume = volume;
9279
9314
  }
9280
9315
 
9281
- changeAudioInputDevice(id ) {
9316
+ changeAudioInputDevice(id , force ) {
9282
9317
  logger$8.info('WebRTC phone - changeAudio input device', { deviceId: id });
9283
9318
 
9284
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9319
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9285
9320
  }
9286
9321
 
9287
9322
  changeVideoInputDevice(id ) {
@@ -13681,8 +13716,7 @@ class Softphone {
13681
13716
  window.addEventListener('message', this._onMessage.bind(this), false);
13682
13717
 
13683
13718
  if (!server) {
13684
- // eslint-disable-next-line no-param-reassign
13685
- server = 'stack.dev.wazo.io';
13719
+ throw new Error('`server` is not set');
13686
13720
  }
13687
13721
 
13688
13722
  const config = { server };
@@ -120,8 +120,7 @@ class Softphone {
120
120
  window.addEventListener('message', this._onMessage.bind(this), false);
121
121
 
122
122
  if (!server) {
123
- // eslint-disable-next-line no-param-reassign
124
- server = 'stack.dev.wazo.io';
123
+ throw new Error('`server` is not set');
125
124
  }
126
125
 
127
126
  const config = { server };
@@ -3071,6 +3071,7 @@ const RECORD_STATE_ACTIVE = 'active';
3071
3071
 
3072
3072
 
3073
3073
 
3074
+
3074
3075
 
3075
3076
 
3076
3077
 
@@ -3081,6 +3082,7 @@ const RECORD_STATE_ACTIVE = 'active';
3081
3082
 
3082
3083
 
3083
3084
 
3085
+
3084
3086
 
3085
3087
 
3086
3088
 
@@ -3109,6 +3111,7 @@ class Call {
3109
3111
 
3110
3112
 
3111
3113
 
3114
+
3112
3115
 
3113
3116
 
3114
3117
 
@@ -3133,6 +3136,7 @@ class Call {
3133
3136
  calleeNumber: plain.peer_caller_id_number,
3134
3137
  dialedExtension: plain.dialed_extension,
3135
3138
  isCaller: plain.is_caller,
3139
+ isVideo: plain.is_video,
3136
3140
  muted: plain.muted,
3137
3141
  onHold: plain.on_hold,
3138
3142
  status: plain.status,
@@ -3156,6 +3160,7 @@ class Call {
3156
3160
  calleeNumber,
3157
3161
  dialedExtension,
3158
3162
  isCaller,
3163
+ isVideo,
3159
3164
  lineId,
3160
3165
  muted,
3161
3166
  onHold,
@@ -3179,6 +3184,7 @@ class Call {
3179
3184
  this.startingTime = startingTime;
3180
3185
  this.talkingToIds = talkingToIds || [];
3181
3186
  this.recording = recording;
3187
+ this.isVideo = !!isVideo;
3182
3188
 
3183
3189
  // Useful to compare instead of instanceof with minified code
3184
3190
  this.type = 'Call';
@@ -3652,7 +3658,7 @@ class CallSession {
3652
3658
  ringing: call.isRinging(),
3653
3659
  answered: call.isUp(),
3654
3660
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3655
- cameraEnabled: false,
3661
+ cameraEnabled: call.isVideo,
3656
3662
  dialedExtension: call.dialedExtension,
3657
3663
  call,
3658
3664
  conference: false, // @FIXME?
@@ -6198,6 +6204,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
6198
6204
  return fixed;
6199
6205
  };
6200
6206
 
6207
+ const addIcesInAllBundles = (sdp ) => {
6208
+ const parsedSdp = sdpParser.parse(sdp);
6209
+
6210
+ const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
6211
+ if (!mediaWithCandidate) {
6212
+ return sdp;
6213
+ }
6214
+
6215
+ const { candidates } = mediaWithCandidate;
6216
+
6217
+ parsedSdp.media = parsedSdp.media.map(media => ({
6218
+ ...media,
6219
+ candidates: media.candidates || candidates,
6220
+ }));
6221
+
6222
+ return sdpParser.write(parsedSdp);
6223
+ };
6224
+
6201
6225
  /* global RTCSessionDescriptionInit, navigator */
6202
6226
 
6203
6227
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
@@ -6296,6 +6320,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6320
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6321
  if (event.candidate) {
6298
6322
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6323
+
6324
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6325
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6326
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6327
+ ice: event.candidate.candidate,
6328
+ });
6329
+ this.iceGatheringComplete();
6330
+ }
6299
6331
  }
6300
6332
  };
6301
6333
 
@@ -6319,7 +6351,10 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6319
6351
 
6320
6352
  // Check if we got ICEs
6321
6353
  if (sdp.indexOf('a=candidate') !== -1) {
6322
- return description;
6354
+ return {
6355
+ type: description.type,
6356
+ sdp: addIcesInAllBundles(sdp),
6357
+ };
6323
6358
  }
6324
6359
 
6325
6360
  wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
@@ -7779,11 +7814,11 @@ class WebRTCClient extends Emitter {
7779
7814
  });
7780
7815
  }
7781
7816
 
7782
- changeAudioInputDevice(id , session ) {
7817
+ changeAudioInputDevice(id , session , force ) {
7783
7818
  const currentId = this.getAudioDeviceId();
7784
7819
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7785
7820
 
7786
- if (id === currentId) {
7821
+ if (!force && id === currentId) {
7787
7822
  return null;
7788
7823
  }
7789
7824
 
@@ -9579,10 +9614,10 @@ class WebRTCPhone extends Emitter {
9579
9614
  this.audioRingVolume = volume;
9580
9615
  }
9581
9616
 
9582
- changeAudioInputDevice(id ) {
9617
+ changeAudioInputDevice(id , force ) {
9583
9618
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9584
9619
 
9585
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9620
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9586
9621
  }
9587
9622
 
9588
9623
  changeVideoInputDevice(id ) {
@@ -14091,8 +14126,7 @@ class Softphone {
14091
14126
  window.addEventListener('message', this._onMessage.bind(this), false);
14092
14127
 
14093
14128
  if (!server) {
14094
- // eslint-disable-next-line no-param-reassign
14095
- server = 'stack.dev.wazo.io';
14129
+ throw new Error('`server` is not set');
14096
14130
  }
14097
14131
 
14098
14132
  const config = { server };
@@ -3097,6 +3097,7 @@ const RECORD_STATE_ACTIVE = 'active';
3097
3097
 
3098
3098
 
3099
3099
 
3100
+
3100
3101
 
3101
3102
 
3102
3103
 
@@ -3107,6 +3108,7 @@ const RECORD_STATE_ACTIVE = 'active';
3107
3108
 
3108
3109
 
3109
3110
 
3111
+
3110
3112
 
3111
3113
 
3112
3114
 
@@ -3135,6 +3137,7 @@ class Call {
3135
3137
 
3136
3138
 
3137
3139
 
3140
+
3138
3141
 
3139
3142
 
3140
3143
 
@@ -3159,6 +3162,7 @@ class Call {
3159
3162
  calleeNumber: plain.peer_caller_id_number,
3160
3163
  dialedExtension: plain.dialed_extension,
3161
3164
  isCaller: plain.is_caller,
3165
+ isVideo: plain.is_video,
3162
3166
  muted: plain.muted,
3163
3167
  onHold: plain.on_hold,
3164
3168
  status: plain.status,
@@ -3182,6 +3186,7 @@ class Call {
3182
3186
  calleeNumber,
3183
3187
  dialedExtension,
3184
3188
  isCaller,
3189
+ isVideo,
3185
3190
  lineId,
3186
3191
  muted,
3187
3192
  onHold,
@@ -3205,6 +3210,7 @@ class Call {
3205
3210
  this.startingTime = startingTime;
3206
3211
  this.talkingToIds = talkingToIds || [];
3207
3212
  this.recording = recording;
3213
+ this.isVideo = !!isVideo;
3208
3214
 
3209
3215
  // Useful to compare instead of instanceof with minified code
3210
3216
  this.type = 'Call';
@@ -3678,7 +3684,7 @@ class CallSession {
3678
3684
  ringing: call.isRinging(),
3679
3685
  answered: call.isUp(),
3680
3686
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3681
- cameraEnabled: false,
3687
+ cameraEnabled: call.isVideo,
3682
3688
  dialedExtension: call.dialedExtension,
3683
3689
  call,
3684
3690
  conference: false, // @FIXME?
@@ -6198,6 +6204,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
6198
6204
  return fixed;
6199
6205
  };
6200
6206
 
6207
+ const addIcesInAllBundles = (sdp ) => {
6208
+ const parsedSdp = sdpParser.parse(sdp);
6209
+
6210
+ const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
6211
+ if (!mediaWithCandidate) {
6212
+ return sdp;
6213
+ }
6214
+
6215
+ const { candidates } = mediaWithCandidate;
6216
+
6217
+ parsedSdp.media = parsedSdp.media.map(media => ({
6218
+ ...media,
6219
+ candidates: media.candidates || candidates,
6220
+ }));
6221
+
6222
+ return sdpParser.write(parsedSdp);
6223
+ };
6224
+
6201
6225
  /* global RTCSessionDescriptionInit, navigator */
6202
6226
 
6203
6227
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
@@ -6296,6 +6320,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6320
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6321
  if (event.candidate) {
6298
6322
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6323
+
6324
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6325
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6326
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6327
+ ice: event.candidate.candidate,
6328
+ });
6329
+ this.iceGatheringComplete();
6330
+ }
6299
6331
  }
6300
6332
  };
6301
6333
 
@@ -6319,7 +6351,10 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6319
6351
 
6320
6352
  // Check if we got ICEs
6321
6353
  if (sdp.indexOf('a=candidate') !== -1) {
6322
- return description;
6354
+ return {
6355
+ type: description.type,
6356
+ sdp: addIcesInAllBundles(sdp),
6357
+ };
6323
6358
  }
6324
6359
 
6325
6360
  wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
@@ -7779,11 +7814,11 @@ class WebRTCClient extends Emitter {
7779
7814
  });
7780
7815
  }
7781
7816
 
7782
- changeAudioInputDevice(id , session ) {
7817
+ changeAudioInputDevice(id , session , force ) {
7783
7818
  const currentId = this.getAudioDeviceId();
7784
7819
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7785
7820
 
7786
- if (id === currentId) {
7821
+ if (!force && id === currentId) {
7787
7822
  return null;
7788
7823
  }
7789
7824
 
@@ -9579,10 +9614,10 @@ class WebRTCPhone extends Emitter {
9579
9614
  this.audioRingVolume = volume;
9580
9615
  }
9581
9616
 
9582
- changeAudioInputDevice(id ) {
9617
+ changeAudioInputDevice(id , force ) {
9583
9618
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9584
9619
 
9585
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9620
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9586
9621
  }
9587
9622
 
9588
9623
  changeVideoInputDevice(id ) {
@@ -12960,8 +12995,7 @@ class Softphone {
12960
12995
  window.addEventListener('message', this._onMessage.bind(this), false);
12961
12996
 
12962
12997
  if (!server) {
12963
- // eslint-disable-next-line no-param-reassign
12964
- server = 'stack.dev.wazo.io';
12998
+ throw new Error('`server` is not set');
12965
12999
  }
12966
13000
 
12967
13001
  const config = { server };
@@ -3097,6 +3097,7 @@ const RECORD_STATE_ACTIVE = 'active';
3097
3097
 
3098
3098
 
3099
3099
 
3100
+
3100
3101
 
3101
3102
 
3102
3103
 
@@ -3107,6 +3108,7 @@ const RECORD_STATE_ACTIVE = 'active';
3107
3108
 
3108
3109
 
3109
3110
 
3111
+
3110
3112
 
3111
3113
 
3112
3114
 
@@ -3135,6 +3137,7 @@ class Call {
3135
3137
 
3136
3138
 
3137
3139
 
3140
+
3138
3141
 
3139
3142
 
3140
3143
 
@@ -3159,6 +3162,7 @@ class Call {
3159
3162
  calleeNumber: plain.peer_caller_id_number,
3160
3163
  dialedExtension: plain.dialed_extension,
3161
3164
  isCaller: plain.is_caller,
3165
+ isVideo: plain.is_video,
3162
3166
  muted: plain.muted,
3163
3167
  onHold: plain.on_hold,
3164
3168
  status: plain.status,
@@ -3182,6 +3186,7 @@ class Call {
3182
3186
  calleeNumber,
3183
3187
  dialedExtension,
3184
3188
  isCaller,
3189
+ isVideo,
3185
3190
  lineId,
3186
3191
  muted,
3187
3192
  onHold,
@@ -3205,6 +3210,7 @@ class Call {
3205
3210
  this.startingTime = startingTime;
3206
3211
  this.talkingToIds = talkingToIds || [];
3207
3212
  this.recording = recording;
3213
+ this.isVideo = !!isVideo;
3208
3214
 
3209
3215
  // Useful to compare instead of instanceof with minified code
3210
3216
  this.type = 'Call';
@@ -3678,7 +3684,7 @@ class CallSession {
3678
3684
  ringing: call.isRinging(),
3679
3685
  answered: call.isUp(),
3680
3686
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3681
- cameraEnabled: false,
3687
+ cameraEnabled: call.isVideo,
3682
3688
  dialedExtension: call.dialedExtension,
3683
3689
  call,
3684
3690
  conference: false, // @FIXME?
@@ -6198,6 +6204,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
6198
6204
  return fixed;
6199
6205
  };
6200
6206
 
6207
+ const addIcesInAllBundles = (sdp ) => {
6208
+ const parsedSdp = sdpParser.parse(sdp);
6209
+
6210
+ const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
6211
+ if (!mediaWithCandidate) {
6212
+ return sdp;
6213
+ }
6214
+
6215
+ const { candidates } = mediaWithCandidate;
6216
+
6217
+ parsedSdp.media = parsedSdp.media.map(media => ({
6218
+ ...media,
6219
+ candidates: media.candidates || candidates,
6220
+ }));
6221
+
6222
+ return sdpParser.write(parsedSdp);
6223
+ };
6224
+
6201
6225
  /* global RTCSessionDescriptionInit, navigator */
6202
6226
 
6203
6227
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
@@ -6296,6 +6320,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6320
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6321
  if (event.candidate) {
6298
6322
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6323
+
6324
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6325
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6326
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6327
+ ice: event.candidate.candidate,
6328
+ });
6329
+ this.iceGatheringComplete();
6330
+ }
6299
6331
  }
6300
6332
  };
6301
6333
 
@@ -6319,7 +6351,10 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6319
6351
 
6320
6352
  // Check if we got ICEs
6321
6353
  if (sdp.indexOf('a=candidate') !== -1) {
6322
- return description;
6354
+ return {
6355
+ type: description.type,
6356
+ sdp: addIcesInAllBundles(sdp),
6357
+ };
6323
6358
  }
6324
6359
 
6325
6360
  wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
@@ -7779,11 +7814,11 @@ class WebRTCClient extends Emitter {
7779
7814
  });
7780
7815
  }
7781
7816
 
7782
- changeAudioInputDevice(id , session ) {
7817
+ changeAudioInputDevice(id , session , force ) {
7783
7818
  const currentId = this.getAudioDeviceId();
7784
7819
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7785
7820
 
7786
- if (id === currentId) {
7821
+ if (!force && id === currentId) {
7787
7822
  return null;
7788
7823
  }
7789
7824
 
@@ -9579,10 +9614,10 @@ class WebRTCPhone extends Emitter {
9579
9614
  this.audioRingVolume = volume;
9580
9615
  }
9581
9616
 
9582
- changeAudioInputDevice(id ) {
9617
+ changeAudioInputDevice(id , force ) {
9583
9618
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9584
9619
 
9585
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9620
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9586
9621
  }
9587
9622
 
9588
9623
  changeVideoInputDevice(id ) {
@@ -12965,8 +13000,7 @@ class Softphone {
12965
13000
  window.addEventListener('message', this._onMessage.bind(this), false);
12966
13001
 
12967
13002
  if (!server) {
12968
- // eslint-disable-next-line no-param-reassign
12969
- server = 'stack.dev.wazo.io';
13003
+ throw new Error('`server` is not set');
12970
13004
  }
12971
13005
 
12972
13006
  const config = { server };