@exotel-npm-dev/webrtc-client-sdk 2.0.3 → 2.0.4

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.
package/Makefile CHANGED
@@ -12,7 +12,7 @@ build-local:
12
12
 
13
13
  dep:
14
14
  npm uninstall @exotel-npm-dev/webrtc-core-sdk
15
- npm install @exotel-npm-dev/webrtc-core-sdk@1.0.22
15
+ npm install @exotel-npm-dev/webrtc-core-sdk@1.0.23
16
16
 
17
17
  publish: build
18
18
  npm publish --tag legacy
package/dist/exotelsdk.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * WebRTC CLient SIP version 2.0.3
3
+ * WebRTC CLient SIP version 2.0.4
4
4
  *
5
5
  */
6
6
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -22165,16 +22165,7 @@ const SIPJSPhone = {
22165
22165
  changeAudioInputDevice(deviceId, onSuccess, onError, forceDeviceChange) {
22166
22166
  logger.log(`SIPJSPhone: changeAudioInputDevice called with deviceId=${deviceId}, forceDeviceChange=${forceDeviceChange}, enableAutoAudioDeviceChangeHandling=${enableAutoAudioDeviceChangeHandling}`);
22167
22167
  _audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.changeAudioInputDevice(deviceId, function (stream) {
22168
- const trackChanged = SIPJSPhone.replaceSenderTrack(stream, deviceId);
22169
- if (trackChanged) {
22170
- _audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId = deviceId;
22171
- logger.log(`sipjsphone: changeAudioInputDevice: Input device changed to: ${deviceId}`);
22172
-
22173
- onSuccess();
22174
- } else {
22175
- logger.error("sipjsphone: changeAudioInputDevice: failed");
22176
- onError("replaceSenderTrack failed for webrtc");
22177
- }
22168
+ SIPJSPhone.replaceSenderTrack(stream, deviceId, onSuccess, onError);
22178
22169
  }, onError, forceDeviceChange);
22179
22170
  },
22180
22171
  changeAudioOutputDeviceForAdditionalAudioElement(deviceId) {
@@ -22214,36 +22205,41 @@ const SIPJSPhone = {
22214
22205
  logger.error("sipjsphone:stopStreamTracks failed to stop tracks");
22215
22206
  }
22216
22207
  },
22217
- replaceSenderTrack(stream, deviceId) {
22208
+ replaceSenderTrack(stream, deviceId, onSuccessCallback, onErrorCallback) {
22218
22209
  logger.log(`sipjsphone:replaceSenderTrack: entry, deviceId=${deviceId}`);
22210
+ let trackChanged = false;
22211
+ let errorMessage = "";
22219
22212
  try {
22220
22213
  if (ctxSip.callActiveID) {
22221
22214
  ctxSip.Stream = stream;
22222
22215
  const s = ctxSip.Sessions[ctxSip.callActiveID];
22223
22216
  const pc = s.sessionDescriptionHandler.peerConnection;
22224
22217
  if (pc.getSenders) {
22225
- try {
22226
22218
  const [audioTrack] = stream.getAudioTracks();
22227
22219
  const sender = pc.getSenders().find((s) => s.track.kind === audioTrack.kind);
22228
22220
  sender.track.stop();
22229
22221
  sender.replaceTrack(audioTrack);
22230
- } catch (e) {
22231
- logger.error(`sipjsphone:replaceSenderTrack: unable to replace track for stream for device id ${deviceId} `, e);
22232
- SIPJSPhone.stopStreamTracks(stream);
22233
- }
22222
+ trackChanged = true;
22234
22223
  } else {
22235
22224
  logger.error("sipjsphone:replaceSenderTrack: no sender found");
22236
- SIPJSPhone.stopStreamTracks(stream);
22225
+ errorMessage = "no sender found";
22237
22226
  }
22238
22227
  } else {
22239
22228
  logger.log("sipjsphone:replaceSenderTrack: no call active, stopping stream tracks");
22240
- SIPJSPhone.stopStreamTracks(stream);
22229
+ errorMessage = "no call active";
22241
22230
  }
22242
- return true;
22243
22231
  } catch (e) {
22244
- SIPJSPhone.stopStreamTracks(stream);
22245
22232
  logger.error("sipjsphone:replaceSenderTrack: failed to replace track", e);
22246
- return false;
22233
+ errorMessage = "failed to replace track";
22234
+ }
22235
+
22236
+ if(trackChanged) {
22237
+ _audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId = deviceId;
22238
+ logger.info("sipjsphone:replaceSenderTrack: track replaced");
22239
+ onSuccessCallback();
22240
+ } else {
22241
+ SIPJSPhone.stopStreamTracks(stream);
22242
+ onErrorCallback(errorMessage);
22247
22243
  }
22248
22244
 
22249
22245
  },
@@ -22274,13 +22270,15 @@ const SIPJSPhone = {
22274
22270
  _audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.onAudioDeviceChange(
22275
22271
  audioRemote,
22276
22272
  (stream, deviceId) => {
22277
- const trackChanged = SIPJSPhone.replaceSenderTrack(stream, deviceId);
22278
- if (trackChanged) {
22279
- _audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId = deviceId;
22273
+ SIPJSPhone.replaceSenderTrack(stream, deviceId, function (){
22280
22274
  if (SIPJSPhone.audioInputDeviceChangeCallback) {
22281
22275
  SIPJSPhone.audioInputDeviceChangeCallback(deviceId);
22282
- }
22283
- }
22276
+ }
22277
+ }, function(errorMessage) {
22278
+ logger.error("sipjsphone:ondevicechange: failed to replace track", errorMessage);
22279
+ });
22280
+
22281
+
22284
22282
  },
22285
22283
  (deviceId) => {
22286
22284
  SIPJSPhone.changeAudioOutputDeviceForAdditionalAudioElement(deviceId);