@wazo/sdk 0.38.3 → 0.38.6

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 (93) hide show
  1. package/README.md +10 -10
  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 +66 -2
  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 +16 -2
  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 +16 -2
  12. package/esm/checker/checks/webrtc-transport.js +16 -2
  13. package/esm/checker/checks/webrtc.js +16 -2
  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 +24 -11
  26. package/esm/lib/WazoSessionDescriptionHandler.js +8 -0
  27. package/esm/service/CallApi.js +6 -0
  28. package/esm/service/getApiClient.js +6 -0
  29. package/esm/simple/Auth.js +24 -11
  30. package/esm/simple/Configuration.js +24 -11
  31. package/esm/simple/Directory.js +6 -0
  32. package/esm/simple/Phone.js +24 -11
  33. package/esm/simple/Softphone.js +5 -6
  34. package/esm/simple/index.js +24 -11
  35. package/esm/simple/room/LocalParticipant.js +24 -11
  36. package/esm/simple/room/Participant.js +24 -11
  37. package/esm/simple/room/RemoteParticipant.js +24 -11
  38. package/esm/simple/room/Room.js +24 -11
  39. package/esm/simple/room/SipRoom.js +24 -11
  40. package/esm/simple/room/Stream.js +24 -11
  41. package/esm/simple/room/__tests__/RemoteParticipant.test.js +24 -11
  42. package/esm/simple/utils.js +24 -11
  43. package/esm/web-rtc-client.js +16 -2
  44. package/lib/__tests__/api-client.test.js +6 -0
  45. package/lib/__tests__/web-rtc-client.test.js +66 -2
  46. package/lib/api/calld.js +6 -0
  47. package/lib/api/ctid-ng.js +6 -0
  48. package/lib/api-client.js +6 -0
  49. package/lib/checker/Checker.js +16 -2
  50. package/lib/checker/checks/aor.js +6 -0
  51. package/lib/checker/checks/api.js +6 -0
  52. package/lib/checker/checks/index.js +16 -2
  53. package/lib/checker/checks/webrtc-transport.js +16 -2
  54. package/lib/checker/checks/webrtc.js +16 -2
  55. package/lib/domain/AdHocAPIConference.js +6 -0
  56. package/lib/domain/Call.js +6 -0
  57. package/lib/domain/CallSession.js +1 -1
  58. package/lib/domain/Features.js +6 -0
  59. package/lib/domain/Phone/CTIPhone.js +7 -1
  60. package/lib/domain/Phone/WebRTCPhone.js +3 -3
  61. package/lib/domain/__tests__/Call.test.js +6 -0
  62. package/lib/domain/__tests__/CallSession.test.js +1 -1
  63. package/lib/domain/__tests__/IndirectTransfer.test.js +1 -1
  64. package/lib/domain/__tests__/Line.test.js +5 -5
  65. package/lib/domain/__tests__/Room.test.js +1 -1
  66. package/lib/index.js +24 -11
  67. package/lib/lib/WazoSessionDescriptionHandler.js +8 -0
  68. package/lib/service/CallApi.js +6 -0
  69. package/lib/service/getApiClient.js +6 -0
  70. package/lib/simple/Auth.js +24 -11
  71. package/lib/simple/Configuration.js +24 -11
  72. package/lib/simple/Directory.js +6 -0
  73. package/lib/simple/Phone.js +24 -11
  74. package/lib/simple/Softphone.js +5 -6
  75. package/lib/simple/index.js +24 -11
  76. package/lib/simple/room/LocalParticipant.js +24 -11
  77. package/lib/simple/room/Participant.js +24 -11
  78. package/lib/simple/room/RemoteParticipant.js +24 -11
  79. package/lib/simple/room/Room.js +24 -11
  80. package/lib/simple/room/SipRoom.js +24 -11
  81. package/lib/simple/room/Stream.js +24 -11
  82. package/lib/simple/room/__tests__/RemoteParticipant.test.js +24 -11
  83. package/lib/simple/utils.js +24 -11
  84. package/lib/web-rtc-client.js +16 -2
  85. package/package.json +1 -1
  86. package/src/__tests__/web-rtc-client.test.js +50 -0
  87. package/src/domain/Call.js +6 -0
  88. package/src/domain/CallSession.js +1 -1
  89. package/src/domain/Phone/WebRTCPhone.js +2 -2
  90. package/src/domain/__tests__/Line.test.js +5 -5
  91. package/src/lib/WazoSessionDescriptionHandler.js +8 -0
  92. package/src/simple/Softphone.js +5 -6
  93. package/src/web-rtc-client.js +2 -2
@@ -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?
@@ -6296,6 +6302,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6302
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6303
  if (event.candidate) {
6298
6304
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6305
+
6306
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6307
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6308
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6309
+ ice: event.candidate.candidate,
6310
+ });
6311
+ this.iceGatheringComplete();
6312
+ }
6299
6313
  }
6300
6314
  };
6301
6315
 
@@ -7779,11 +7793,11 @@ class WebRTCClient extends Emitter {
7779
7793
  });
7780
7794
  }
7781
7795
 
7782
- changeAudioInputDevice(id , session ) {
7796
+ changeAudioInputDevice(id , session , force ) {
7783
7797
  const currentId = this.getAudioDeviceId();
7784
7798
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7785
7799
 
7786
- if (id === currentId) {
7800
+ if (!force && id === currentId) {
7787
7801
  return null;
7788
7802
  }
7789
7803
 
@@ -9579,10 +9593,10 @@ class WebRTCPhone extends Emitter {
9579
9593
  this.audioRingVolume = volume;
9580
9594
  }
9581
9595
 
9582
- changeAudioInputDevice(id ) {
9596
+ changeAudioInputDevice(id , force ) {
9583
9597
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9584
9598
 
9585
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9599
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9586
9600
  }
9587
9601
 
9588
9602
  changeVideoInputDevice(id ) {
@@ -12856,7 +12870,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
12856
12870
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
12857
12871
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
12858
12872
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
12859
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
12873
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
12860
12874
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
12861
12875
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
12862
12876
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -12900,7 +12914,7 @@ class Softphone {
12900
12914
  onIFrameLoaded() {}
12901
12915
 
12902
12916
  onCallLocallyAnswered(call ) {}
12903
- onCallRemotelyAnswered(call ) {}
12917
+ onCallEstablished(call ) {}
12904
12918
  onOutgoingCallMade(call ) {}
12905
12919
  onCallIncoming(call ) {}
12906
12920
  onCallRejected(call ) {}
@@ -12960,8 +12974,7 @@ class Softphone {
12960
12974
  window.addEventListener('message', this._onMessage.bind(this), false);
12961
12975
 
12962
12976
  if (!server) {
12963
- // eslint-disable-next-line no-param-reassign
12964
- server = 'stack.dev.wazo.io';
12977
+ throw new Error('`server` is not set');
12965
12978
  }
12966
12979
 
12967
12980
  const config = { server };
@@ -13206,8 +13219,8 @@ class Softphone {
13206
13219
  case BRIDGE_ON_CALL_REJECTED:
13207
13220
  this.onCallRejected(event.data.call);
13208
13221
  break;
13209
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
13210
- this.onCallRemotelyAnswered(event.data.call);
13222
+ case BRIDGE_ON_CALL_ESTABLISHED:
13223
+ this.onCallEstablished(event.data.call);
13211
13224
  break;
13212
13225
  default:
13213
13226
  this.onUnHandledEvent(event);
@@ -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?
@@ -6296,6 +6302,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6302
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6303
  if (event.candidate) {
6298
6304
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6305
+
6306
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6307
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6308
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6309
+ ice: event.candidate.candidate,
6310
+ });
6311
+ this.iceGatheringComplete();
6312
+ }
6299
6313
  }
6300
6314
  };
6301
6315
 
@@ -7779,11 +7793,11 @@ class WebRTCClient extends Emitter {
7779
7793
  });
7780
7794
  }
7781
7795
 
7782
- changeAudioInputDevice(id , session ) {
7796
+ changeAudioInputDevice(id , session , force ) {
7783
7797
  const currentId = this.getAudioDeviceId();
7784
7798
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7785
7799
 
7786
- if (id === currentId) {
7800
+ if (!force && id === currentId) {
7787
7801
  return null;
7788
7802
  }
7789
7803
 
@@ -9579,10 +9593,10 @@ class WebRTCPhone extends Emitter {
9579
9593
  this.audioRingVolume = volume;
9580
9594
  }
9581
9595
 
9582
- changeAudioInputDevice(id ) {
9596
+ changeAudioInputDevice(id , force ) {
9583
9597
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9584
9598
 
9585
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9599
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9586
9600
  }
9587
9601
 
9588
9602
  changeVideoInputDevice(id ) {
@@ -12861,7 +12875,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
12861
12875
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
12862
12876
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
12863
12877
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
12864
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
12878
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
12865
12879
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
12866
12880
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
12867
12881
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -12905,7 +12919,7 @@ class Softphone {
12905
12919
  onIFrameLoaded() {}
12906
12920
 
12907
12921
  onCallLocallyAnswered(call ) {}
12908
- onCallRemotelyAnswered(call ) {}
12922
+ onCallEstablished(call ) {}
12909
12923
  onOutgoingCallMade(call ) {}
12910
12924
  onCallIncoming(call ) {}
12911
12925
  onCallRejected(call ) {}
@@ -12965,8 +12979,7 @@ class Softphone {
12965
12979
  window.addEventListener('message', this._onMessage.bind(this), false);
12966
12980
 
12967
12981
  if (!server) {
12968
- // eslint-disable-next-line no-param-reassign
12969
- server = 'stack.dev.wazo.io';
12982
+ throw new Error('`server` is not set');
12970
12983
  }
12971
12984
 
12972
12985
  const config = { server };
@@ -13211,8 +13224,8 @@ class Softphone {
13211
13224
  case BRIDGE_ON_CALL_REJECTED:
13212
13225
  this.onCallRejected(event.data.call);
13213
13226
  break;
13214
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
13215
- this.onCallRemotelyAnswered(event.data.call);
13227
+ case BRIDGE_ON_CALL_ESTABLISHED:
13228
+ this.onCallEstablished(event.data.call);
13216
13229
  break;
13217
13230
  default:
13218
13231
  this.onUnHandledEvent(event);
@@ -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?
@@ -6296,6 +6302,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6302
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6303
  if (event.candidate) {
6298
6304
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6305
+
6306
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6307
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6308
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6309
+ ice: event.candidate.candidate,
6310
+ });
6311
+ this.iceGatheringComplete();
6312
+ }
6299
6313
  }
6300
6314
  };
6301
6315
 
@@ -7779,11 +7793,11 @@ class WebRTCClient extends Emitter {
7779
7793
  });
7780
7794
  }
7781
7795
 
7782
- changeAudioInputDevice(id , session ) {
7796
+ changeAudioInputDevice(id , session , force ) {
7783
7797
  const currentId = this.getAudioDeviceId();
7784
7798
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7785
7799
 
7786
- if (id === currentId) {
7800
+ if (!force && id === currentId) {
7787
7801
  return null;
7788
7802
  }
7789
7803
 
@@ -9579,10 +9593,10 @@ class WebRTCPhone extends Emitter {
9579
9593
  this.audioRingVolume = volume;
9580
9594
  }
9581
9595
 
9582
- changeAudioInputDevice(id ) {
9596
+ changeAudioInputDevice(id , force ) {
9583
9597
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9584
9598
 
9585
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9599
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9586
9600
  }
9587
9601
 
9588
9602
  changeVideoInputDevice(id ) {
@@ -13140,7 +13154,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13140
13154
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13141
13155
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13142
13156
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13143
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13157
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13144
13158
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13145
13159
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13146
13160
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13184,7 +13198,7 @@ class Softphone {
13184
13198
  onIFrameLoaded() {}
13185
13199
 
13186
13200
  onCallLocallyAnswered(call ) {}
13187
- onCallRemotelyAnswered(call ) {}
13201
+ onCallEstablished(call ) {}
13188
13202
  onOutgoingCallMade(call ) {}
13189
13203
  onCallIncoming(call ) {}
13190
13204
  onCallRejected(call ) {}
@@ -13244,8 +13258,7 @@ class Softphone {
13244
13258
  window.addEventListener('message', this._onMessage.bind(this), false);
13245
13259
 
13246
13260
  if (!server) {
13247
- // eslint-disable-next-line no-param-reassign
13248
- server = 'stack.dev.wazo.io';
13261
+ throw new Error('`server` is not set');
13249
13262
  }
13250
13263
 
13251
13264
  const config = { server };
@@ -13490,8 +13503,8 @@ class Softphone {
13490
13503
  case BRIDGE_ON_CALL_REJECTED:
13491
13504
  this.onCallRejected(event.data.call);
13492
13505
  break;
13493
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
13494
- this.onCallRemotelyAnswered(event.data.call);
13506
+ case BRIDGE_ON_CALL_ESTABLISHED:
13507
+ this.onCallEstablished(event.data.call);
13495
13508
  break;
13496
13509
  default:
13497
13510
  this.onUnHandledEvent(event);
@@ -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?
@@ -6296,6 +6302,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6302
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6303
  if (event.candidate) {
6298
6304
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6305
+
6306
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6307
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6308
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6309
+ ice: event.candidate.candidate,
6310
+ });
6311
+ this.iceGatheringComplete();
6312
+ }
6299
6313
  }
6300
6314
  };
6301
6315
 
@@ -7779,11 +7793,11 @@ class WebRTCClient extends Emitter {
7779
7793
  });
7780
7794
  }
7781
7795
 
7782
- changeAudioInputDevice(id , session ) {
7796
+ changeAudioInputDevice(id , session , force ) {
7783
7797
  const currentId = this.getAudioDeviceId();
7784
7798
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7785
7799
 
7786
- if (id === currentId) {
7800
+ if (!force && id === currentId) {
7787
7801
  return null;
7788
7802
  }
7789
7803
 
@@ -9579,10 +9593,10 @@ class WebRTCPhone extends Emitter {
9579
9593
  this.audioRingVolume = volume;
9580
9594
  }
9581
9595
 
9582
- changeAudioInputDevice(id ) {
9596
+ changeAudioInputDevice(id , force ) {
9583
9597
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9584
9598
 
9585
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9599
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9586
9600
  }
9587
9601
 
9588
9602
  changeVideoInputDevice(id ) {
@@ -13151,7 +13165,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13151
13165
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13152
13166
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13153
13167
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13154
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13168
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13155
13169
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13156
13170
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13157
13171
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13195,7 +13209,7 @@ class Softphone {
13195
13209
  onIFrameLoaded() {}
13196
13210
 
13197
13211
  onCallLocallyAnswered(call ) {}
13198
- onCallRemotelyAnswered(call ) {}
13212
+ onCallEstablished(call ) {}
13199
13213
  onOutgoingCallMade(call ) {}
13200
13214
  onCallIncoming(call ) {}
13201
13215
  onCallRejected(call ) {}
@@ -13255,8 +13269,7 @@ class Softphone {
13255
13269
  window.addEventListener('message', this._onMessage.bind(this), false);
13256
13270
 
13257
13271
  if (!server) {
13258
- // eslint-disable-next-line no-param-reassign
13259
- server = 'stack.dev.wazo.io';
13272
+ throw new Error('`server` is not set');
13260
13273
  }
13261
13274
 
13262
13275
  const config = { server };
@@ -13501,8 +13514,8 @@ class Softphone {
13501
13514
  case BRIDGE_ON_CALL_REJECTED:
13502
13515
  this.onCallRejected(event.data.call);
13503
13516
  break;
13504
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
13505
- this.onCallRemotelyAnswered(event.data.call);
13517
+ case BRIDGE_ON_CALL_ESTABLISHED:
13518
+ this.onCallEstablished(event.data.call);
13506
13519
  break;
13507
13520
  default:
13508
13521
  this.onUnHandledEvent(event);
@@ -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?
@@ -6296,6 +6302,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6302
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6303
  if (event.candidate) {
6298
6304
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6305
+
6306
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6307
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6308
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6309
+ ice: event.candidate.candidate,
6310
+ });
6311
+ this.iceGatheringComplete();
6312
+ }
6299
6313
  }
6300
6314
  };
6301
6315
 
@@ -7779,11 +7793,11 @@ class WebRTCClient extends Emitter {
7779
7793
  });
7780
7794
  }
7781
7795
 
7782
- changeAudioInputDevice(id , session ) {
7796
+ changeAudioInputDevice(id , session , force ) {
7783
7797
  const currentId = this.getAudioDeviceId();
7784
7798
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7785
7799
 
7786
- if (id === currentId) {
7800
+ if (!force && id === currentId) {
7787
7801
  return null;
7788
7802
  }
7789
7803
 
@@ -9579,10 +9593,10 @@ class WebRTCPhone extends Emitter {
9579
9593
  this.audioRingVolume = volume;
9580
9594
  }
9581
9595
 
9582
- changeAudioInputDevice(id ) {
9596
+ changeAudioInputDevice(id , force ) {
9583
9597
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9584
9598
 
9585
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9599
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9586
9600
  }
9587
9601
 
9588
9602
  changeVideoInputDevice(id ) {
@@ -13848,7 +13862,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13848
13862
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13849
13863
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13850
13864
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13851
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13865
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13852
13866
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13853
13867
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13854
13868
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13892,7 +13906,7 @@ class Softphone {
13892
13906
  onIFrameLoaded() {}
13893
13907
 
13894
13908
  onCallLocallyAnswered(call ) {}
13895
- onCallRemotelyAnswered(call ) {}
13909
+ onCallEstablished(call ) {}
13896
13910
  onOutgoingCallMade(call ) {}
13897
13911
  onCallIncoming(call ) {}
13898
13912
  onCallRejected(call ) {}
@@ -13952,8 +13966,7 @@ class Softphone {
13952
13966
  window.addEventListener('message', this._onMessage.bind(this), false);
13953
13967
 
13954
13968
  if (!server) {
13955
- // eslint-disable-next-line no-param-reassign
13956
- server = 'stack.dev.wazo.io';
13969
+ throw new Error('`server` is not set');
13957
13970
  }
13958
13971
 
13959
13972
  const config = { server };
@@ -14198,8 +14211,8 @@ class Softphone {
14198
14211
  case BRIDGE_ON_CALL_REJECTED:
14199
14212
  this.onCallRejected(event.data.call);
14200
14213
  break;
14201
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
14202
- this.onCallRemotelyAnswered(event.data.call);
14214
+ case BRIDGE_ON_CALL_ESTABLISHED:
14215
+ this.onCallEstablished(event.data.call);
14203
14216
  break;
14204
14217
  default:
14205
14218
  this.onUnHandledEvent(event);