@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
@@ -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';
@@ -59,6 +59,7 @@ const RECORD_STATE_ACTIVE = 'active';
59
59
 
60
60
 
61
61
 
62
+
62
63
 
63
64
 
64
65
 
@@ -69,6 +70,7 @@ const RECORD_STATE_ACTIVE = 'active';
69
70
 
70
71
 
71
72
 
73
+
72
74
 
73
75
 
74
76
 
@@ -97,6 +99,7 @@ class Call {
97
99
 
98
100
 
99
101
 
102
+
100
103
 
101
104
 
102
105
 
@@ -121,6 +124,7 @@ class Call {
121
124
  calleeNumber: plain.peer_caller_id_number,
122
125
  dialedExtension: plain.dialed_extension,
123
126
  isCaller: plain.is_caller,
127
+ isVideo: plain.is_video,
124
128
  muted: plain.muted,
125
129
  onHold: plain.on_hold,
126
130
  status: plain.status,
@@ -144,6 +148,7 @@ class Call {
144
148
  calleeNumber,
145
149
  dialedExtension,
146
150
  isCaller,
151
+ isVideo,
147
152
  lineId,
148
153
  muted,
149
154
  onHold,
@@ -167,6 +172,7 @@ class Call {
167
172
  this.startingTime = startingTime;
168
173
  this.talkingToIds = talkingToIds || [];
169
174
  this.recording = recording;
175
+ this.isVideo = !!isVideo;
170
176
 
171
177
  // Useful to compare instead of instanceof with minified code
172
178
  this.type = 'Call';
@@ -640,7 +646,7 @@ class CallSession {
640
646
  ringing: call.isRinging(),
641
647
  answered: call.isUp(),
642
648
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
643
- cameraEnabled: false,
649
+ cameraEnabled: call.isVideo,
644
650
  dialedExtension: call.dialedExtension,
645
651
  call,
646
652
  conference: false, // @FIXME?
@@ -6005,6 +6011,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6005
6011
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6006
6012
  if (event.candidate) {
6007
6013
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6014
+
6015
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6016
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6017
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6018
+ ice: event.candidate.candidate,
6019
+ });
6020
+ this.iceGatheringComplete();
6021
+ }
6008
6022
  }
6009
6023
  };
6010
6024
 
@@ -7488,11 +7502,11 @@ class WebRTCClient extends Emitter {
7488
7502
  });
7489
7503
  }
7490
7504
 
7491
- changeAudioInputDevice(id , session ) {
7505
+ changeAudioInputDevice(id , session , force ) {
7492
7506
  const currentId = this.getAudioDeviceId();
7493
7507
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7494
7508
 
7495
- if (id === currentId) {
7509
+ if (!force && id === currentId) {
7496
7510
  return null;
7497
7511
  }
7498
7512
 
@@ -9288,10 +9302,10 @@ class WebRTCPhone extends Emitter {
9288
9302
  this.audioRingVolume = volume;
9289
9303
  }
9290
9304
 
9291
- changeAudioInputDevice(id ) {
9305
+ changeAudioInputDevice(id , force ) {
9292
9306
  logger$8.info('WebRTC phone - changeAudio input device', { deviceId: id });
9293
9307
 
9294
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9308
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9295
9309
  }
9296
9310
 
9297
9311
  changeVideoInputDevice(id ) {
@@ -13587,7 +13601,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13587
13601
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13588
13602
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13589
13603
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13590
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13604
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13591
13605
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13592
13606
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13593
13607
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13631,7 +13645,7 @@ class Softphone {
13631
13645
  onIFrameLoaded() {}
13632
13646
 
13633
13647
  onCallLocallyAnswered(call ) {}
13634
- onCallRemotelyAnswered(call ) {}
13648
+ onCallEstablished(call ) {}
13635
13649
  onOutgoingCallMade(call ) {}
13636
13650
  onCallIncoming(call ) {}
13637
13651
  onCallRejected(call ) {}
@@ -13691,8 +13705,7 @@ class Softphone {
13691
13705
  window.addEventListener('message', this._onMessage.bind(this), false);
13692
13706
 
13693
13707
  if (!server) {
13694
- // eslint-disable-next-line no-param-reassign
13695
- server = 'stack.dev.wazo.io';
13708
+ throw new Error('`server` is not set');
13696
13709
  }
13697
13710
 
13698
13711
  const config = { server };
@@ -13937,8 +13950,8 @@ class Softphone {
13937
13950
  case BRIDGE_ON_CALL_REJECTED:
13938
13951
  this.onCallRejected(event.data.call);
13939
13952
  break;
13940
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
13941
- this.onCallRemotelyAnswered(event.data.call);
13953
+ case BRIDGE_ON_CALL_ESTABLISHED:
13954
+ this.onCallEstablished(event.data.call);
13942
13955
  break;
13943
13956
  default:
13944
13957
  this.onUnHandledEvent(event);
@@ -18,7 +18,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
18
18
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
19
19
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
20
20
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
21
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
21
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
22
22
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
23
23
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
24
24
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -62,7 +62,7 @@ class Softphone {
62
62
  onIFrameLoaded() {}
63
63
 
64
64
  onCallLocallyAnswered(call ) {}
65
- onCallRemotelyAnswered(call ) {}
65
+ onCallEstablished(call ) {}
66
66
  onOutgoingCallMade(call ) {}
67
67
  onCallIncoming(call ) {}
68
68
  onCallRejected(call ) {}
@@ -122,8 +122,7 @@ class Softphone {
122
122
  window.addEventListener('message', this._onMessage.bind(this), false);
123
123
 
124
124
  if (!server) {
125
- // eslint-disable-next-line no-param-reassign
126
- server = 'stack.dev.wazo.io';
125
+ throw new Error('`server` is not set');
127
126
  }
128
127
 
129
128
  const config = { server };
@@ -368,8 +367,8 @@ class Softphone {
368
367
  case BRIDGE_ON_CALL_REJECTED:
369
368
  this.onCallRejected(event.data.call);
370
369
  break;
371
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
372
- this.onCallRemotelyAnswered(event.data.call);
370
+ case BRIDGE_ON_CALL_ESTABLISHED:
371
+ this.onCallEstablished(event.data.call);
373
372
  break;
374
373
  default:
375
374
  this.onUnHandledEvent(event);
@@ -3081,6 +3081,7 @@ const RECORD_STATE_ACTIVE = 'active';
3081
3081
 
3082
3082
 
3083
3083
 
3084
+
3084
3085
 
3085
3086
 
3086
3087
 
@@ -3091,6 +3092,7 @@ const RECORD_STATE_ACTIVE = 'active';
3091
3092
 
3092
3093
 
3093
3094
 
3095
+
3094
3096
 
3095
3097
 
3096
3098
 
@@ -3119,6 +3121,7 @@ class Call {
3119
3121
 
3120
3122
 
3121
3123
 
3124
+
3122
3125
 
3123
3126
 
3124
3127
 
@@ -3143,6 +3146,7 @@ class Call {
3143
3146
  calleeNumber: plain.peer_caller_id_number,
3144
3147
  dialedExtension: plain.dialed_extension,
3145
3148
  isCaller: plain.is_caller,
3149
+ isVideo: plain.is_video,
3146
3150
  muted: plain.muted,
3147
3151
  onHold: plain.on_hold,
3148
3152
  status: plain.status,
@@ -3166,6 +3170,7 @@ class Call {
3166
3170
  calleeNumber,
3167
3171
  dialedExtension,
3168
3172
  isCaller,
3173
+ isVideo,
3169
3174
  lineId,
3170
3175
  muted,
3171
3176
  onHold,
@@ -3189,6 +3194,7 @@ class Call {
3189
3194
  this.startingTime = startingTime;
3190
3195
  this.talkingToIds = talkingToIds || [];
3191
3196
  this.recording = recording;
3197
+ this.isVideo = !!isVideo;
3192
3198
 
3193
3199
  // Useful to compare instead of instanceof with minified code
3194
3200
  this.type = 'Call';
@@ -3662,7 +3668,7 @@ class CallSession {
3662
3668
  ringing: call.isRinging(),
3663
3669
  answered: call.isUp(),
3664
3670
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3665
- cameraEnabled: false,
3671
+ cameraEnabled: call.isVideo,
3666
3672
  dialedExtension: call.dialedExtension,
3667
3673
  call,
3668
3674
  conference: false, // @FIXME?
@@ -6306,6 +6312,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6306
6312
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6307
6313
  if (event.candidate) {
6308
6314
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6315
+
6316
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6317
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6318
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6319
+ ice: event.candidate.candidate,
6320
+ });
6321
+ this.iceGatheringComplete();
6322
+ }
6309
6323
  }
6310
6324
  };
6311
6325
 
@@ -7789,11 +7803,11 @@ class WebRTCClient extends Emitter {
7789
7803
  });
7790
7804
  }
7791
7805
 
7792
- changeAudioInputDevice(id , session ) {
7806
+ changeAudioInputDevice(id , session , force ) {
7793
7807
  const currentId = this.getAudioDeviceId();
7794
7808
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7795
7809
 
7796
- if (id === currentId) {
7810
+ if (!force && id === currentId) {
7797
7811
  return null;
7798
7812
  }
7799
7813
 
@@ -9589,10 +9603,10 @@ class WebRTCPhone extends Emitter {
9589
9603
  this.audioRingVolume = volume;
9590
9604
  }
9591
9605
 
9592
- changeAudioInputDevice(id ) {
9606
+ changeAudioInputDevice(id , force ) {
9593
9607
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9594
9608
 
9595
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9609
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9596
9610
  }
9597
9611
 
9598
9612
  changeVideoInputDevice(id ) {
@@ -13997,7 +14011,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13997
14011
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13998
14012
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13999
14013
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
14000
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
14014
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
14001
14015
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
14002
14016
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
14003
14017
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -14041,7 +14055,7 @@ class Softphone {
14041
14055
  onIFrameLoaded() {}
14042
14056
 
14043
14057
  onCallLocallyAnswered(call ) {}
14044
- onCallRemotelyAnswered(call ) {}
14058
+ onCallEstablished(call ) {}
14045
14059
  onOutgoingCallMade(call ) {}
14046
14060
  onCallIncoming(call ) {}
14047
14061
  onCallRejected(call ) {}
@@ -14101,8 +14115,7 @@ class Softphone {
14101
14115
  window.addEventListener('message', this._onMessage.bind(this), false);
14102
14116
 
14103
14117
  if (!server) {
14104
- // eslint-disable-next-line no-param-reassign
14105
- server = 'stack.dev.wazo.io';
14118
+ throw new Error('`server` is not set');
14106
14119
  }
14107
14120
 
14108
14121
  const config = { server };
@@ -14347,8 +14360,8 @@ class Softphone {
14347
14360
  case BRIDGE_ON_CALL_REJECTED:
14348
14361
  this.onCallRejected(event.data.call);
14349
14362
  break;
14350
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
14351
- this.onCallRemotelyAnswered(event.data.call);
14363
+ case BRIDGE_ON_CALL_ESTABLISHED:
14364
+ this.onCallEstablished(event.data.call);
14352
14365
  break;
14353
14366
  default:
14354
14367
  this.onUnHandledEvent(event);
@@ -3107,6 +3107,7 @@ const RECORD_STATE_ACTIVE = 'active';
3107
3107
 
3108
3108
 
3109
3109
 
3110
+
3110
3111
 
3111
3112
 
3112
3113
 
@@ -3117,6 +3118,7 @@ const RECORD_STATE_ACTIVE = 'active';
3117
3118
 
3118
3119
 
3119
3120
 
3121
+
3120
3122
 
3121
3123
 
3122
3124
 
@@ -3145,6 +3147,7 @@ class Call {
3145
3147
 
3146
3148
 
3147
3149
 
3150
+
3148
3151
 
3149
3152
 
3150
3153
 
@@ -3169,6 +3172,7 @@ class Call {
3169
3172
  calleeNumber: plain.peer_caller_id_number,
3170
3173
  dialedExtension: plain.dialed_extension,
3171
3174
  isCaller: plain.is_caller,
3175
+ isVideo: plain.is_video,
3172
3176
  muted: plain.muted,
3173
3177
  onHold: plain.on_hold,
3174
3178
  status: plain.status,
@@ -3192,6 +3196,7 @@ class Call {
3192
3196
  calleeNumber,
3193
3197
  dialedExtension,
3194
3198
  isCaller,
3199
+ isVideo,
3195
3200
  lineId,
3196
3201
  muted,
3197
3202
  onHold,
@@ -3215,6 +3220,7 @@ class Call {
3215
3220
  this.startingTime = startingTime;
3216
3221
  this.talkingToIds = talkingToIds || [];
3217
3222
  this.recording = recording;
3223
+ this.isVideo = !!isVideo;
3218
3224
 
3219
3225
  // Useful to compare instead of instanceof with minified code
3220
3226
  this.type = 'Call';
@@ -3688,7 +3694,7 @@ class CallSession {
3688
3694
  ringing: call.isRinging(),
3689
3695
  answered: call.isUp(),
3690
3696
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3691
- cameraEnabled: false,
3697
+ cameraEnabled: call.isVideo,
3692
3698
  dialedExtension: call.dialedExtension,
3693
3699
  call,
3694
3700
  conference: false, // @FIXME?
@@ -6306,6 +6312,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6306
6312
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6307
6313
  if (event.candidate) {
6308
6314
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6315
+
6316
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6317
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6318
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6319
+ ice: event.candidate.candidate,
6320
+ });
6321
+ this.iceGatheringComplete();
6322
+ }
6309
6323
  }
6310
6324
  };
6311
6325
 
@@ -7789,11 +7803,11 @@ class WebRTCClient extends Emitter {
7789
7803
  });
7790
7804
  }
7791
7805
 
7792
- changeAudioInputDevice(id , session ) {
7806
+ changeAudioInputDevice(id , session , force ) {
7793
7807
  const currentId = this.getAudioDeviceId();
7794
7808
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7795
7809
 
7796
- if (id === currentId) {
7810
+ if (!force && id === currentId) {
7797
7811
  return null;
7798
7812
  }
7799
7813
 
@@ -9589,10 +9603,10 @@ class WebRTCPhone extends Emitter {
9589
9603
  this.audioRingVolume = volume;
9590
9604
  }
9591
9605
 
9592
- changeAudioInputDevice(id ) {
9606
+ changeAudioInputDevice(id , force ) {
9593
9607
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9594
9608
 
9595
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9609
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9596
9610
  }
9597
9611
 
9598
9612
  changeVideoInputDevice(id ) {
@@ -12866,7 +12880,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
12866
12880
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
12867
12881
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
12868
12882
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
12869
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
12883
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
12870
12884
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
12871
12885
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
12872
12886
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -12910,7 +12924,7 @@ class Softphone {
12910
12924
  onIFrameLoaded() {}
12911
12925
 
12912
12926
  onCallLocallyAnswered(call ) {}
12913
- onCallRemotelyAnswered(call ) {}
12927
+ onCallEstablished(call ) {}
12914
12928
  onOutgoingCallMade(call ) {}
12915
12929
  onCallIncoming(call ) {}
12916
12930
  onCallRejected(call ) {}
@@ -12970,8 +12984,7 @@ class Softphone {
12970
12984
  window.addEventListener('message', this._onMessage.bind(this), false);
12971
12985
 
12972
12986
  if (!server) {
12973
- // eslint-disable-next-line no-param-reassign
12974
- server = 'stack.dev.wazo.io';
12987
+ throw new Error('`server` is not set');
12975
12988
  }
12976
12989
 
12977
12990
  const config = { server };
@@ -13216,8 +13229,8 @@ class Softphone {
13216
13229
  case BRIDGE_ON_CALL_REJECTED:
13217
13230
  this.onCallRejected(event.data.call);
13218
13231
  break;
13219
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
13220
- this.onCallRemotelyAnswered(event.data.call);
13232
+ case BRIDGE_ON_CALL_ESTABLISHED:
13233
+ this.onCallEstablished(event.data.call);
13221
13234
  break;
13222
13235
  default:
13223
13236
  this.onUnHandledEvent(event);
@@ -3107,6 +3107,7 @@ const RECORD_STATE_ACTIVE = 'active';
3107
3107
 
3108
3108
 
3109
3109
 
3110
+
3110
3111
 
3111
3112
 
3112
3113
 
@@ -3117,6 +3118,7 @@ const RECORD_STATE_ACTIVE = 'active';
3117
3118
 
3118
3119
 
3119
3120
 
3121
+
3120
3122
 
3121
3123
 
3122
3124
 
@@ -3145,6 +3147,7 @@ class Call {
3145
3147
 
3146
3148
 
3147
3149
 
3150
+
3148
3151
 
3149
3152
 
3150
3153
 
@@ -3169,6 +3172,7 @@ class Call {
3169
3172
  calleeNumber: plain.peer_caller_id_number,
3170
3173
  dialedExtension: plain.dialed_extension,
3171
3174
  isCaller: plain.is_caller,
3175
+ isVideo: plain.is_video,
3172
3176
  muted: plain.muted,
3173
3177
  onHold: plain.on_hold,
3174
3178
  status: plain.status,
@@ -3192,6 +3196,7 @@ class Call {
3192
3196
  calleeNumber,
3193
3197
  dialedExtension,
3194
3198
  isCaller,
3199
+ isVideo,
3195
3200
  lineId,
3196
3201
  muted,
3197
3202
  onHold,
@@ -3215,6 +3220,7 @@ class Call {
3215
3220
  this.startingTime = startingTime;
3216
3221
  this.talkingToIds = talkingToIds || [];
3217
3222
  this.recording = recording;
3223
+ this.isVideo = !!isVideo;
3218
3224
 
3219
3225
  // Useful to compare instead of instanceof with minified code
3220
3226
  this.type = 'Call';
@@ -3688,7 +3694,7 @@ class CallSession {
3688
3694
  ringing: call.isRinging(),
3689
3695
  answered: call.isUp(),
3690
3696
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3691
- cameraEnabled: false,
3697
+ cameraEnabled: call.isVideo,
3692
3698
  dialedExtension: call.dialedExtension,
3693
3699
  call,
3694
3700
  conference: false, // @FIXME?
@@ -6306,6 +6312,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6306
6312
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6307
6313
  if (event.candidate) {
6308
6314
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6315
+
6316
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6317
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6318
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6319
+ ice: event.candidate.candidate,
6320
+ });
6321
+ this.iceGatheringComplete();
6322
+ }
6309
6323
  }
6310
6324
  };
6311
6325
 
@@ -7789,11 +7803,11 @@ class WebRTCClient extends Emitter {
7789
7803
  });
7790
7804
  }
7791
7805
 
7792
- changeAudioInputDevice(id , session ) {
7806
+ changeAudioInputDevice(id , session , force ) {
7793
7807
  const currentId = this.getAudioDeviceId();
7794
7808
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7795
7809
 
7796
- if (id === currentId) {
7810
+ if (!force && id === currentId) {
7797
7811
  return null;
7798
7812
  }
7799
7813
 
@@ -9589,10 +9603,10 @@ class WebRTCPhone extends Emitter {
9589
9603
  this.audioRingVolume = volume;
9590
9604
  }
9591
9605
 
9592
- changeAudioInputDevice(id ) {
9606
+ changeAudioInputDevice(id , force ) {
9593
9607
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9594
9608
 
9595
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9609
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9596
9610
  }
9597
9611
 
9598
9612
  changeVideoInputDevice(id ) {
@@ -12871,7 +12885,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
12871
12885
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
12872
12886
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
12873
12887
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
12874
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
12888
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
12875
12889
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
12876
12890
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
12877
12891
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -12915,7 +12929,7 @@ class Softphone {
12915
12929
  onIFrameLoaded() {}
12916
12930
 
12917
12931
  onCallLocallyAnswered(call ) {}
12918
- onCallRemotelyAnswered(call ) {}
12932
+ onCallEstablished(call ) {}
12919
12933
  onOutgoingCallMade(call ) {}
12920
12934
  onCallIncoming(call ) {}
12921
12935
  onCallRejected(call ) {}
@@ -12975,8 +12989,7 @@ class Softphone {
12975
12989
  window.addEventListener('message', this._onMessage.bind(this), false);
12976
12990
 
12977
12991
  if (!server) {
12978
- // eslint-disable-next-line no-param-reassign
12979
- server = 'stack.dev.wazo.io';
12992
+ throw new Error('`server` is not set');
12980
12993
  }
12981
12994
 
12982
12995
  const config = { server };
@@ -13221,8 +13234,8 @@ class Softphone {
13221
13234
  case BRIDGE_ON_CALL_REJECTED:
13222
13235
  this.onCallRejected(event.data.call);
13223
13236
  break;
13224
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
13225
- this.onCallRemotelyAnswered(event.data.call);
13237
+ case BRIDGE_ON_CALL_ESTABLISHED:
13238
+ this.onCallEstablished(event.data.call);
13226
13239
  break;
13227
13240
  default:
13228
13241
  this.onUnHandledEvent(event);