@exotel-npm-dev/webrtc-client-sdk 1.0.13 → 1.0.15
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/Changelog +7 -0
- package/dist/exotelsdk.js +103 -48
- package/dist/exotelsdk.js.map +1 -1
- package/package.json +2 -2
- package/src/api/callAPI/CallDetails.js +31 -27
- package/src/listeners/ExWebClient.js +18 -3
package/Changelog
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
Change Log
|
|
2
|
+
|
|
3
|
+
## v1.0.15 25 October, 2024
|
|
4
|
+
-[VST-863] Added option provide ondevice change callback
|
|
5
|
+
|
|
6
|
+
## v1.0.14 12 September, 2024
|
|
7
|
+
-[VST-807] Added call details with callsid and sip headers
|
|
8
|
+
|
|
2
9
|
## v1.0.12 01 September, 2024
|
|
3
10
|
-[VST-807] Added real-time selection for microphone and speaker devices, and implemented callbacks to notify the application when a device change occurs. also added logger callback
|
|
4
11
|
|
package/dist/exotelsdk.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* WebRTC CLient SIP version 1.0.
|
|
3
|
+
* WebRTC CLient SIP version 1.0.15
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
@@ -53,7 +53,7 @@ const audioDeviceManager = {
|
|
|
53
53
|
resetOutputDevice: false,
|
|
54
54
|
currentAudioInputDeviceId: "default",
|
|
55
55
|
currentAudioOutputDeviceId: "default",
|
|
56
|
-
|
|
56
|
+
mediaDevices: [],
|
|
57
57
|
|
|
58
58
|
// Method to set the resetInputDevice flag
|
|
59
59
|
setResetInputDeviceFlag(value) {
|
|
@@ -69,14 +69,14 @@ const audioDeviceManager = {
|
|
|
69
69
|
logger.log(`SIPJSPhone:changeAudioInputDevice entry`);
|
|
70
70
|
try {
|
|
71
71
|
if (deviceId == audioDeviceManager.currentAudioInputDeviceId) {
|
|
72
|
-
logger.log(`SIPJSPhone:changeAudioInputDevice current input device is same as ${deviceId}`);
|
|
72
|
+
logger.log(`SIPJSPhone:changeAudioInputDevice current input device is same as ${deviceId} hence not changing`);
|
|
73
|
+
if (onError) onError("current input device is same as " + deviceId + " hence not changing");
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
75
|
-
const
|
|
76
|
-
const inputDevice = devices.find(device => device.deviceId === deviceId && device.kind === 'audioinput');
|
|
76
|
+
const inputDevice = audioDeviceManager.mediaDevices.find(device => device.deviceId === deviceId && device.kind === 'audioinput');
|
|
77
77
|
if (!inputDevice) {
|
|
78
78
|
logger.error("input device id " + deviceId + "not found");
|
|
79
|
-
onError("deviceIdNotFound");
|
|
79
|
+
if (onError) onError("deviceIdNotFound");
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
logger.log(`SIPJSPhone:changeAudioInputDevice acquiring input device ${deviceId} : ${inputDevice.label}`);
|
|
@@ -86,7 +86,7 @@ const audioDeviceManager = {
|
|
|
86
86
|
onSuccess(stream);
|
|
87
87
|
} catch (error) {
|
|
88
88
|
logger.error('SIPJSPhone:changeAudioInputDevice Error changing input device:', error);
|
|
89
|
-
onError(error);
|
|
89
|
+
if (onError) onError(error);
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
92
|
|
|
@@ -94,19 +94,26 @@ const audioDeviceManager = {
|
|
|
94
94
|
logger.log(`audioDeviceManager:changeAudioOutputDevice : entry`);
|
|
95
95
|
if (deviceId == audioDeviceManager.currentAudioOutputDeviceId) {
|
|
96
96
|
logger.log(`SIPJSPhone:changeAudioOutputDevice current output device is same as ${deviceId}`);
|
|
97
|
+
if (onError) onError("current output device is same as " + deviceId);
|
|
97
98
|
return;
|
|
98
99
|
}
|
|
99
100
|
const audioElement = audioRemote;
|
|
100
101
|
if (typeof audioElement.sinkId !== 'undefined') {
|
|
101
102
|
try {
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
|
|
104
|
+
if (!audioDeviceManager.mediaDevices || audioDeviceManager.mediaDevices.length == 0) {
|
|
105
|
+
logger.error("audioDeviceManager:changeAudioOutputDevice mediaDeviceList is empty ");
|
|
106
|
+
if (onError) logger.error(deviceId + "not found in mediaDeviceList in audioManager");
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const outputDevice = audioDeviceManager.mediaDevices.find(device => device.deviceId === deviceId && device.kind === 'audiooutput');
|
|
104
110
|
if (!outputDevice) {
|
|
105
111
|
logger.error("audioDeviceManager:changeAudioOutputDevice output device id " + deviceId + "not found");
|
|
106
|
-
onError("deviceIdNotFound");
|
|
112
|
+
if (onError) onError("deviceIdNotFound");
|
|
107
113
|
return;
|
|
108
114
|
}
|
|
109
|
-
logger.log(`
|
|
115
|
+
logger.log(`audioDeviceManager:changeAudioOutputDevice acquiring output device ${deviceId} : ${outputDevice.label}`);
|
|
116
|
+
// audioElement.load();
|
|
110
117
|
await audioElement.setSinkId(deviceId);
|
|
111
118
|
audioDeviceManager.currentAudioOutputDeviceId = deviceId;
|
|
112
119
|
logger.log(`audioDeviceManager:changeAudioOutputDevice Output device changed to: ${deviceId}`);
|
|
@@ -136,21 +143,20 @@ const audioDeviceManager = {
|
|
|
136
143
|
async _resetAudioDevice(audioRemote, onInputDeviceChangeCallback, onOutputDeviceChangecallback, resetOutputDevice, resetInputDevice) {
|
|
137
144
|
logger.log("audioDeviceManager:_resetAudioDevice entry");
|
|
138
145
|
try {
|
|
139
|
-
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
140
146
|
|
|
141
147
|
if (resetOutputDevice) {
|
|
142
|
-
const defaultOutputDevice =
|
|
143
|
-
const outputDevice =
|
|
148
|
+
const defaultOutputDevice = audioDeviceManager.mediaDevices.find(device => device.deviceId === "default" && device.kind === 'audiooutput');
|
|
149
|
+
const outputDevice = audioDeviceManager.mediaDevices.find(device => device.groupId == defaultOutputDevice.groupId && device.kind === 'audiooutput' && device.deviceId != 'default');
|
|
144
150
|
|
|
145
151
|
audioDeviceManager.changeAudioOutputDevice(audioRemote,
|
|
146
152
|
outputDevice.deviceId,
|
|
147
153
|
() => onOutputDeviceChangecallback(outputDevice.deviceId),
|
|
148
|
-
(error) => logger.
|
|
154
|
+
(error) => logger.error(`audioDeviceManager:_resetAudioDevice Failed to change output device: ${error}`)
|
|
149
155
|
);
|
|
150
156
|
}
|
|
151
157
|
if (resetInputDevice) {
|
|
152
|
-
const defaultInputDevice =
|
|
153
|
-
const inputDevice =
|
|
158
|
+
const defaultInputDevice = audioDeviceManager.mediaDevices.find(device => device.deviceId === "default" && device.kind === 'audioinput');
|
|
159
|
+
const inputDevice = audioDeviceManager.mediaDevices.find(device => device.groupId == defaultInputDevice.groupId && device.kind === 'audioinput' && device.deviceId != 'default');
|
|
154
160
|
audioDeviceManager.changeAudioInputDevice(
|
|
155
161
|
inputDevice.deviceId,
|
|
156
162
|
(stream) => onInputDeviceChangeCallback(stream, inputDevice.deviceId),
|
|
@@ -158,13 +164,23 @@ const audioDeviceManager = {
|
|
|
158
164
|
);
|
|
159
165
|
}
|
|
160
166
|
} catch (error) {
|
|
161
|
-
logger.
|
|
167
|
+
logger.error("audioDeviceManager:_resetAudioDevice reset audio device failed", error);
|
|
162
168
|
}
|
|
163
169
|
},
|
|
164
170
|
|
|
165
|
-
|
|
171
|
+
async enumerateDevices(callback) {
|
|
172
|
+
logger.log("audioDeviceManager:enumerateDevices entry")
|
|
173
|
+
try {
|
|
174
|
+
audioDeviceManager.mediaDevices = await navigator.mediaDevices.enumerateDevices();
|
|
175
|
+
} catch (e) {
|
|
176
|
+
logger.log("audioDeviceManager:enumerateDevices device enumeration failed", e);
|
|
177
|
+
}
|
|
178
|
+
if (callback) callback();
|
|
179
|
+
},
|
|
166
180
|
|
|
181
|
+
};
|
|
167
182
|
|
|
183
|
+
audioDeviceManager.enumerateDevices();
|
|
168
184
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (audioDeviceManager);
|
|
169
185
|
|
|
170
186
|
/***/ }),
|
|
@@ -22032,21 +22048,30 @@ const SIPJSPhone = {
|
|
|
22032
22048
|
onSuccess();
|
|
22033
22049
|
} else {
|
|
22034
22050
|
logger.error("SIPJSPhone:changeAudioInputDevice failed");
|
|
22035
|
-
onError("
|
|
22051
|
+
onError("replaceSenderTrack failed for webrtc");
|
|
22036
22052
|
}
|
|
22037
22053
|
}, onError);
|
|
22038
22054
|
},
|
|
22039
|
-
|
|
22040
|
-
ringtone
|
|
22041
|
-
|
|
22042
|
-
|
|
22055
|
+
changeAudioOutputDeviceForAdditionalAudioElement(deviceId) {
|
|
22056
|
+
const additionalAudioElements = [ringtone, beeptone, ringbacktone, dtmftone];
|
|
22057
|
+
let i = 0;
|
|
22058
|
+
let elem;
|
|
22059
|
+
try {
|
|
22060
|
+
for (i = 0; i < additionalAudioElements.length; i++) {
|
|
22061
|
+
elem = additionalAudioElements[i];
|
|
22062
|
+
elem.load();
|
|
22063
|
+
elem.setSinkId(deviceId);
|
|
22064
|
+
}
|
|
22065
|
+
} catch (e) {
|
|
22066
|
+
logger.error("sipjsphone:changeAudioOutputDeviceForAdditionalAudioElement failed to setSink for additonal AudioElements", e);
|
|
22067
|
+
}
|
|
22043
22068
|
},
|
|
22044
22069
|
changeAudioOutputDevice(deviceId, onSuccess, onError) {
|
|
22045
22070
|
if (!ctxSip.callActiveID) {
|
|
22046
22071
|
audioRemote = document.createElement("audio");
|
|
22047
22072
|
}
|
|
22048
22073
|
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.changeAudioOutputDevice(audioRemote, deviceId, function () {
|
|
22049
|
-
SIPJSPhone.
|
|
22074
|
+
SIPJSPhone.changeAudioOutputDeviceForAdditionalAudioElement(deviceId);
|
|
22050
22075
|
onSuccess();
|
|
22051
22076
|
}, onError);
|
|
22052
22077
|
},
|
|
@@ -22098,11 +22123,12 @@ const SIPJSPhone = {
|
|
|
22098
22123
|
},
|
|
22099
22124
|
audioInputDeviceChangeCallback: null,
|
|
22100
22125
|
audioOutputDeviceChangeCallback: null,
|
|
22101
|
-
|
|
22126
|
+
onDeviceChangeCallback: null,
|
|
22127
|
+
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback) {
|
|
22102
22128
|
logger.log(`SIPJSPhone:registerAudioDeviceChangeCallback entry`);
|
|
22103
22129
|
SIPJSPhone.audioInputDeviceChangeCallback = audioInputDeviceChangeCallback;
|
|
22104
22130
|
SIPJSPhone.audioOutputDeviceChangeCallback = audioOutputDeviceChangeCallback;
|
|
22105
|
-
|
|
22131
|
+
SIPJSPhone.onDeviceChangeCallback = onDeviceChangeCallback;
|
|
22106
22132
|
}
|
|
22107
22133
|
|
|
22108
22134
|
};
|
|
@@ -22113,22 +22139,31 @@ navigator.mediaDevices.addEventListener('devicechange', function (event) {
|
|
|
22113
22139
|
if (!ctxSip.callActiveID) {
|
|
22114
22140
|
audioRemote = document.createElement("audio");
|
|
22115
22141
|
}
|
|
22116
|
-
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.
|
|
22117
|
-
|
|
22118
|
-
|
|
22119
|
-
|
|
22120
|
-
|
|
22121
|
-
|
|
22122
|
-
|
|
22142
|
+
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.enumerateDevices(function () {
|
|
22143
|
+
|
|
22144
|
+
if (SIPJSPhone.onDeviceChangeCallback) {
|
|
22145
|
+
logger.info("SIPJSPhone:ondevicechange relaying event to callback");
|
|
22146
|
+
SIPJSPhone.onDeviceChangeCallback(event);
|
|
22147
|
+
return;
|
|
22148
|
+
}
|
|
22149
|
+
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.onAudioDeviceChange(audioRemote,
|
|
22150
|
+
function (stream, deviceId) {
|
|
22151
|
+
const trackChanged = SIPJSPhone.replaceSenderTrack(stream, deviceId);
|
|
22152
|
+
if (trackChanged) {
|
|
22153
|
+
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId = deviceId;
|
|
22154
|
+
if (SIPJSPhone.audioInputDeviceChangeCallback) {
|
|
22155
|
+
SIPJSPhone.audioInputDeviceChangeCallback(deviceId);
|
|
22156
|
+
}
|
|
22123
22157
|
}
|
|
22124
|
-
}
|
|
22125
|
-
|
|
22126
|
-
|
|
22127
|
-
|
|
22128
|
-
|
|
22129
|
-
|
|
22130
|
-
}
|
|
22131
|
-
|
|
22158
|
+
}, function (deviceId) {
|
|
22159
|
+
SIPJSPhone.changeAudioOutputDeviceForAdditionalAudioElement(deviceId);
|
|
22160
|
+
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioOutputDeviceId = deviceId;
|
|
22161
|
+
if (SIPJSPhone.audioOutputDeviceChangeCallback) {
|
|
22162
|
+
SIPJSPhone.audioOutputDeviceChangeCallback(deviceId);
|
|
22163
|
+
}
|
|
22164
|
+
});
|
|
22165
|
+
});
|
|
22166
|
+
|
|
22132
22167
|
} catch (e) {
|
|
22133
22168
|
logger.error("SIPJSPhone:ondevicechange something went wrong during device change", e);
|
|
22134
22169
|
}
|
|
@@ -22359,9 +22394,9 @@ const webrtcSIPPhone = {
|
|
|
22359
22394
|
logger.log(`webrtcSIPPhone:changeAudioOutputDevice entry`);
|
|
22360
22395
|
_sipjsphone__WEBPACK_IMPORTED_MODULE_1__["default"].changeAudioOutputDevice(deviceId, onSuccess, onError);
|
|
22361
22396
|
},
|
|
22362
|
-
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback) {
|
|
22397
|
+
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback) {
|
|
22363
22398
|
logger.log(`webrtcSIPPhone:registerAudioDeviceChangeCallback entry`);
|
|
22364
|
-
_sipjsphone__WEBPACK_IMPORTED_MODULE_1__["default"].registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback);
|
|
22399
|
+
_sipjsphone__WEBPACK_IMPORTED_MODULE_1__["default"].registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback);
|
|
22365
22400
|
},
|
|
22366
22401
|
getLogger() {
|
|
22367
22402
|
return _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__["default"];
|
|
@@ -22685,6 +22720,8 @@ var CallDetails = {
|
|
|
22685
22720
|
callAnswerTime: '',
|
|
22686
22721
|
callEndReason: '',
|
|
22687
22722
|
sessionId: '',
|
|
22723
|
+
callSid: '',
|
|
22724
|
+
sipHeaders: {},
|
|
22688
22725
|
setCallDetails: function (callId, remoteId, remoteDisplayName, callDirection, callState, callDuration, callStartedTime, callEstablishedTime, callEndedTime, callAnswerTime, callEndReason, sessionId) {
|
|
22689
22726
|
this.callId = callId;
|
|
22690
22727
|
this.remoteId = remoteId;
|
|
@@ -22739,7 +22776,9 @@ var CallDetails = {
|
|
|
22739
22776
|
callEndedTime: this.callEndedTime,
|
|
22740
22777
|
callAnswerTime: this.callAnswerTime,
|
|
22741
22778
|
callEndReason: this.callEndReason,
|
|
22742
|
-
sessionId: this.sessionId
|
|
22779
|
+
sessionId: this.sessionId,
|
|
22780
|
+
callSid: this.callSid,
|
|
22781
|
+
sipHeaders: this.sipHeaders
|
|
22743
22782
|
};
|
|
22744
22783
|
return callDetailsObj;
|
|
22745
22784
|
}
|
|
@@ -23793,6 +23832,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23793
23832
|
/* harmony import */ var _api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../api/omAPI/DiagnosticsListener */ "./src/api/omAPI/DiagnosticsListener.js");
|
|
23794
23833
|
/* harmony import */ var _listeners_Callback__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Callback */ "./src/listeners/Callback.js");
|
|
23795
23834
|
/* harmony import */ var _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @exotel-npm-dev/webrtc-core-sdk */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/index.js");
|
|
23835
|
+
/* harmony import */ var _api_callAPI_CallDetails__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../api/callAPI/CallDetails */ "./src/api/callAPI/CallDetails.js");
|
|
23836
|
+
|
|
23796
23837
|
|
|
23797
23838
|
|
|
23798
23839
|
|
|
@@ -23920,6 +23961,20 @@ function ExDelegationHandler(exClient_) {
|
|
|
23920
23961
|
this.onRecieveInvite = function (incomingSession) {
|
|
23921
23962
|
logger.log("delegationHandler: onRecieveInvite\n");
|
|
23922
23963
|
exClient.callFromNumber = incomingSession.incomingInviteRequest.message.from.displayName;
|
|
23964
|
+
_api_callAPI_CallDetails__WEBPACK_IMPORTED_MODULE_9__.CallDetails.callSid = incomingSession.incomingInviteRequest.message.headers['X-Exotel-Callsid'][0].raw;
|
|
23965
|
+
_api_callAPI_CallDetails__WEBPACK_IMPORTED_MODULE_9__.CallDetails.callId = incomingSession.incomingInviteRequest.message.headers['Call-ID'][0].raw;
|
|
23966
|
+
const result = {};
|
|
23967
|
+
const obj = incomingSession.incomingInviteRequest.message.headers;
|
|
23968
|
+
for (let key in obj) {
|
|
23969
|
+
if (obj.hasOwnProperty(key)) {
|
|
23970
|
+
if (obj[key].length == 1) {
|
|
23971
|
+
result[key] = obj[key][0].raw;
|
|
23972
|
+
} else if (obj[key].length > 1) {
|
|
23973
|
+
result[key] = obj[key].map(item => item.raw);
|
|
23974
|
+
}
|
|
23975
|
+
}
|
|
23976
|
+
}
|
|
23977
|
+
_api_callAPI_CallDetails__WEBPACK_IMPORTED_MODULE_9__.CallDetails.sipHeaders = result;
|
|
23923
23978
|
};
|
|
23924
23979
|
this.onPickCall = function () {
|
|
23925
23980
|
logger.log("delegationHandler: onPickCall\n");
|
|
@@ -23950,7 +24005,7 @@ function ExSynchronousHandler() {
|
|
|
23950
24005
|
}
|
|
23951
24006
|
class ExotelWebClient {
|
|
23952
24007
|
ctrlr = null;
|
|
23953
|
-
call
|
|
24008
|
+
call;
|
|
23954
24009
|
eventListener = null;
|
|
23955
24010
|
callListener = null;
|
|
23956
24011
|
callFromNumber = null;
|
|
@@ -24237,8 +24292,8 @@ class ExotelWebClient {
|
|
|
24237
24292
|
registerLoggerCallback(callback) {
|
|
24238
24293
|
logger.registerLoggerCallback(callback);
|
|
24239
24294
|
}
|
|
24240
|
-
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback) {
|
|
24241
|
-
_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__.webrtcSIPPhone.registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback);
|
|
24295
|
+
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback) {
|
|
24296
|
+
_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__.webrtcSIPPhone.registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback);
|
|
24242
24297
|
}
|
|
24243
24298
|
}
|
|
24244
24299
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ExotelWebClient);
|