@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
@@ -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 ) {
@@ -13929,7 +13943,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13929
13943
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13930
13944
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13931
13945
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13932
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13946
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13933
13947
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13934
13948
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13935
13949
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13973,7 +13987,7 @@ class Softphone {
13973
13987
  onIFrameLoaded() {}
13974
13988
 
13975
13989
  onCallLocallyAnswered(call ) {}
13976
- onCallRemotelyAnswered(call ) {}
13990
+ onCallEstablished(call ) {}
13977
13991
  onOutgoingCallMade(call ) {}
13978
13992
  onCallIncoming(call ) {}
13979
13993
  onCallRejected(call ) {}
@@ -14033,8 +14047,7 @@ class Softphone {
14033
14047
  window.addEventListener('message', this._onMessage.bind(this), false);
14034
14048
 
14035
14049
  if (!server) {
14036
- // eslint-disable-next-line no-param-reassign
14037
- server = 'stack.dev.wazo.io';
14050
+ throw new Error('`server` is not set');
14038
14051
  }
14039
14052
 
14040
14053
  const config = { server };
@@ -14279,8 +14292,8 @@ class Softphone {
14279
14292
  case BRIDGE_ON_CALL_REJECTED:
14280
14293
  this.onCallRejected(event.data.call);
14281
14294
  break;
14282
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
14283
- this.onCallRemotelyAnswered(event.data.call);
14295
+ case BRIDGE_ON_CALL_ESTABLISHED:
14296
+ this.onCallEstablished(event.data.call);
14284
14297
  break;
14285
14298
  default:
14286
14299
  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 ) {
@@ -13987,7 +14001,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13987
14001
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13988
14002
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13989
14003
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13990
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
14004
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13991
14005
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13992
14006
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13993
14007
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -14031,7 +14045,7 @@ class Softphone {
14031
14045
  onIFrameLoaded() {}
14032
14046
 
14033
14047
  onCallLocallyAnswered(call ) {}
14034
- onCallRemotelyAnswered(call ) {}
14048
+ onCallEstablished(call ) {}
14035
14049
  onOutgoingCallMade(call ) {}
14036
14050
  onCallIncoming(call ) {}
14037
14051
  onCallRejected(call ) {}
@@ -14091,8 +14105,7 @@ class Softphone {
14091
14105
  window.addEventListener('message', this._onMessage.bind(this), false);
14092
14106
 
14093
14107
  if (!server) {
14094
- // eslint-disable-next-line no-param-reassign
14095
- server = 'stack.dev.wazo.io';
14108
+ throw new Error('`server` is not set');
14096
14109
  }
14097
14110
 
14098
14111
  const config = { server };
@@ -14337,8 +14350,8 @@ class Softphone {
14337
14350
  case BRIDGE_ON_CALL_REJECTED:
14338
14351
  this.onCallRejected(event.data.call);
14339
14352
  break;
14340
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
14341
- this.onCallRemotelyAnswered(event.data.call);
14353
+ case BRIDGE_ON_CALL_ESTABLISHED:
14354
+ this.onCallEstablished(event.data.call);
14342
14355
  break;
14343
14356
  default:
14344
14357
  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 ) {
@@ -13971,7 +13985,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13971
13985
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13972
13986
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13973
13987
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13974
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13988
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13975
13989
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13976
13990
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13977
13991
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -14015,7 +14029,7 @@ class Softphone {
14015
14029
  onIFrameLoaded() {}
14016
14030
 
14017
14031
  onCallLocallyAnswered(call ) {}
14018
- onCallRemotelyAnswered(call ) {}
14032
+ onCallEstablished(call ) {}
14019
14033
  onOutgoingCallMade(call ) {}
14020
14034
  onCallIncoming(call ) {}
14021
14035
  onCallRejected(call ) {}
@@ -14075,8 +14089,7 @@ class Softphone {
14075
14089
  window.addEventListener('message', this._onMessage.bind(this), false);
14076
14090
 
14077
14091
  if (!server) {
14078
- // eslint-disable-next-line no-param-reassign
14079
- server = 'stack.dev.wazo.io';
14092
+ throw new Error('`server` is not set');
14080
14093
  }
14081
14094
 
14082
14095
  const config = { server };
@@ -14321,8 +14334,8 @@ class Softphone {
14321
14334
  case BRIDGE_ON_CALL_REJECTED:
14322
14335
  this.onCallRejected(event.data.call);
14323
14336
  break;
14324
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
14325
- this.onCallRemotelyAnswered(event.data.call);
14337
+ case BRIDGE_ON_CALL_ESTABLISHED:
14338
+ this.onCallEstablished(event.data.call);
14326
14339
  break;
14327
14340
  default:
14328
14341
  this.onUnHandledEvent(event);
@@ -876,6 +876,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
876
876
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
877
877
  if (event.candidate) {
878
878
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
879
+
880
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
881
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
882
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
883
+ ice: event.candidate.candidate,
884
+ });
885
+ this.iceGatheringComplete();
886
+ }
879
887
  }
880
888
  };
881
889
 
@@ -3599,6 +3607,7 @@ const RECORD_STATE_ACTIVE = 'active';
3599
3607
 
3600
3608
 
3601
3609
 
3610
+
3602
3611
 
3603
3612
 
3604
3613
 
@@ -3609,6 +3618,7 @@ const RECORD_STATE_ACTIVE = 'active';
3609
3618
 
3610
3619
 
3611
3620
 
3621
+
3612
3622
 
3613
3623
 
3614
3624
 
@@ -3637,6 +3647,7 @@ class Call {
3637
3647
 
3638
3648
 
3639
3649
 
3650
+
3640
3651
 
3641
3652
 
3642
3653
 
@@ -3661,6 +3672,7 @@ class Call {
3661
3672
  calleeNumber: plain.peer_caller_id_number,
3662
3673
  dialedExtension: plain.dialed_extension,
3663
3674
  isCaller: plain.is_caller,
3675
+ isVideo: plain.is_video,
3664
3676
  muted: plain.muted,
3665
3677
  onHold: plain.on_hold,
3666
3678
  status: plain.status,
@@ -3684,6 +3696,7 @@ class Call {
3684
3696
  calleeNumber,
3685
3697
  dialedExtension,
3686
3698
  isCaller,
3699
+ isVideo,
3687
3700
  lineId,
3688
3701
  muted,
3689
3702
  onHold,
@@ -3707,6 +3720,7 @@ class Call {
3707
3720
  this.startingTime = startingTime;
3708
3721
  this.talkingToIds = talkingToIds || [];
3709
3722
  this.recording = recording;
3723
+ this.isVideo = !!isVideo;
3710
3724
 
3711
3725
  // Useful to compare instead of instanceof with minified code
3712
3726
  this.type = 'Call';
@@ -6409,11 +6423,11 @@ class WebRTCClient extends Emitter {
6409
6423
  });
6410
6424
  }
6411
6425
 
6412
- changeAudioInputDevice(id , session ) {
6426
+ changeAudioInputDevice(id , session , force ) {
6413
6427
  const currentId = this.getAudioDeviceId();
6414
6428
  logger.info('setting audio input device', { id, currentId, session: !!session });
6415
6429
 
6416
- if (id === currentId) {
6430
+ if (!force && id === currentId) {
6417
6431
  return null;
6418
6432
  }
6419
6433
 
@@ -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';
@@ -885,6 +885,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
885
885
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
886
886
  if (event.candidate) {
887
887
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
888
+
889
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
890
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
891
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
892
+ ice: event.candidate.candidate,
893
+ });
894
+ this.iceGatheringComplete();
895
+ }
888
896
  }
889
897
  };
890
898
 
@@ -3608,6 +3616,7 @@ const RECORD_STATE_ACTIVE = 'active';
3608
3616
 
3609
3617
 
3610
3618
 
3619
+
3611
3620
 
3612
3621
 
3613
3622
 
@@ -3618,6 +3627,7 @@ const RECORD_STATE_ACTIVE = 'active';
3618
3627
 
3619
3628
 
3620
3629
 
3630
+
3621
3631
 
3622
3632
 
3623
3633
 
@@ -3646,6 +3656,7 @@ class Call {
3646
3656
 
3647
3657
 
3648
3658
 
3659
+
3649
3660
 
3650
3661
 
3651
3662
 
@@ -3670,6 +3681,7 @@ class Call {
3670
3681
  calleeNumber: plain.peer_caller_id_number,
3671
3682
  dialedExtension: plain.dialed_extension,
3672
3683
  isCaller: plain.is_caller,
3684
+ isVideo: plain.is_video,
3673
3685
  muted: plain.muted,
3674
3686
  onHold: plain.on_hold,
3675
3687
  status: plain.status,
@@ -3693,6 +3705,7 @@ class Call {
3693
3705
  calleeNumber,
3694
3706
  dialedExtension,
3695
3707
  isCaller,
3708
+ isVideo,
3696
3709
  lineId,
3697
3710
  muted,
3698
3711
  onHold,
@@ -3716,6 +3729,7 @@ class Call {
3716
3729
  this.startingTime = startingTime;
3717
3730
  this.talkingToIds = talkingToIds || [];
3718
3731
  this.recording = recording;
3732
+ this.isVideo = !!isVideo;
3719
3733
 
3720
3734
  // Useful to compare instead of instanceof with minified code
3721
3735
  this.type = 'Call';
@@ -6415,11 +6429,11 @@ class WebRTCClient extends Emitter {
6415
6429
  });
6416
6430
  }
6417
6431
 
6418
- changeAudioInputDevice(id , session ) {
6432
+ changeAudioInputDevice(id , session , force ) {
6419
6433
  const currentId = this.getAudioDeviceId();
6420
6434
  logger.info('setting audio input device', { id, currentId, session: !!session });
6421
6435
 
6422
- if (id === currentId) {
6436
+ if (!force && id === currentId) {
6423
6437
  return null;
6424
6438
  }
6425
6439
 
@@ -7603,3 +7617,53 @@ describe('WebRTC client', () => {
7603
7617
  expect(client.isAudioMuted(oldKindUnmuted)).toBeFalsy();
7604
7618
  });
7605
7619
  });
7620
+
7621
+ describe('changeAudioInputDevice', () => {
7622
+ const defaultId = 'default';
7623
+ const deviceId = 'device1';
7624
+ const constraints = { audio: { deviceId: { exact: defaultId } }, video: null };
7625
+
7626
+ const session = {
7627
+ sessionDescriptionHandler: {
7628
+ peerConnection: {
7629
+ getSenders: () => [{ track: { kind: 'audio', enabled: true } }],
7630
+ },
7631
+ },
7632
+ };
7633
+
7634
+ const stream = {};
7635
+ const getAudioTracksMock = jest.fn(() => []);
7636
+ Object.defineProperty(stream, 'getAudioTracks', {
7637
+ value: getAudioTracksMock,
7638
+ });
7639
+
7640
+ const getUserMediaMock = jest.fn(async () => {
7641
+ return new Promise(resolve => {
7642
+ resolve(stream);
7643
+ });
7644
+ });
7645
+
7646
+ Object.defineProperty(global.navigator, 'mediaDevices', {
7647
+ value: {
7648
+ getUserMedia: getUserMediaMock,
7649
+ },
7650
+ });
7651
+
7652
+ it('should change the audio input track if the provided id is different', async () => {
7653
+ client.setMediaConstraints(constraints);
7654
+ expect(client.getAudioDeviceId()).toBe(defaultId);
7655
+ expect(client.changeAudioInputDevice(deviceId, session)).toBeTruthy();
7656
+ });
7657
+
7658
+ it('should NOT change the audio input track if the provided id is the same', async () => {
7659
+ client.setMediaConstraints(constraints);
7660
+ expect(client.getAudioDeviceId()).toBe(defaultId);
7661
+ expect(client.changeAudioInputDevice(defaultId, session)).toBeFalsy();
7662
+ });
7663
+
7664
+ it('should change the audio input track if the provided id is the same and force param is TRUE', async () => {
7665
+ client.setMediaConstraints(constraints);
7666
+ expect(client.getAudioDeviceId()).toBe(defaultId);
7667
+ expect(client.changeAudioInputDevice(defaultId, session, true)).toBeTruthy();
7668
+ });
7669
+ });
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';