@exotel-npm-dev/webrtc-client-sdk 1.0.14 → 1.0.16
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 +3 -0
- package/dist/exotelsdk.js +128 -56
- package/dist/exotelsdk.js.map +1 -1
- package/package.json +2 -2
- package/src/api/registerAPI/RegisterListener.js +9 -6
- package/src/listeners/ExWebClient.js +39 -5
package/Changelog
CHANGED
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.16
|
|
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"];
|
|
@@ -23426,15 +23461,17 @@ function DoRegister(sipAccountInfo, exWebClient) {
|
|
|
23426
23461
|
* CHANGE IS REQUIRED - in the initialize function provision is to be given to pass Callback functions as arguments
|
|
23427
23462
|
*/
|
|
23428
23463
|
try {
|
|
23429
|
-
|
|
23430
|
-
|
|
23431
|
-
|
|
23432
|
-
|
|
23433
|
-
|
|
23434
|
-
|
|
23435
|
-
|
|
23436
|
-
|
|
23437
|
-
|
|
23464
|
+
setTimeout(function () {
|
|
23465
|
+
exWebClient.initialize(userContext, sipAccountInfo.domain,
|
|
23466
|
+
//hostname
|
|
23467
|
+
sipAccountInfo.userName,
|
|
23468
|
+
//subscriberName
|
|
23469
|
+
sipAccountInfo.displayname,
|
|
23470
|
+
//displayName
|
|
23471
|
+
sipAccountInfo.accountSid,
|
|
23472
|
+
//accountSid
|
|
23473
|
+
'', sipAccountInfo); // subscriberToken
|
|
23474
|
+
}, 500);
|
|
23438
23475
|
} catch (e) {
|
|
23439
23476
|
logger.log("Register failed ", e);
|
|
23440
23477
|
}
|
|
@@ -23970,10 +24007,14 @@ function ExSynchronousHandler() {
|
|
|
23970
24007
|
}
|
|
23971
24008
|
class ExotelWebClient {
|
|
23972
24009
|
ctrlr = null;
|
|
23973
|
-
call
|
|
24010
|
+
call;
|
|
23974
24011
|
eventListener = null;
|
|
23975
24012
|
callListener = null;
|
|
23976
24013
|
callFromNumber = null;
|
|
24014
|
+
shouldAutoRetry = false;
|
|
24015
|
+
unregisterInitiated = false;
|
|
24016
|
+
registrationInProgress = false;
|
|
24017
|
+
isReadyToRegister = true;
|
|
23977
24018
|
/* OLD-Way to be revisited for multile phone support */
|
|
23978
24019
|
//this.webRTCPhones = {};
|
|
23979
24020
|
|
|
@@ -24005,9 +24046,16 @@ class ExotelWebClient {
|
|
|
24005
24046
|
return true;
|
|
24006
24047
|
};
|
|
24007
24048
|
DoRegister = () => {
|
|
24049
|
+
logger.log("ExWebClient:DoRegister Entry");
|
|
24050
|
+
if (!this.isReadyToRegister) {
|
|
24051
|
+
logger.warn("ExWebClient:DoRegister SDK is not ready to register");
|
|
24052
|
+
return false;
|
|
24053
|
+
}
|
|
24008
24054
|
(0,_api_registerAPI_RegisterListener__WEBPACK_IMPORTED_MODULE_1__.DoRegister)(this.sipAccountInfo, this);
|
|
24055
|
+
return true;
|
|
24009
24056
|
};
|
|
24010
24057
|
UnRegister = () => {
|
|
24058
|
+
logger.log("ExWebClient:UnRegister Entry");
|
|
24011
24059
|
(0,_api_registerAPI_RegisterListener__WEBPACK_IMPORTED_MODULE_1__.UnRegister)(this.sipAccountInfo, this);
|
|
24012
24060
|
};
|
|
24013
24061
|
initDiagnostics = (saveDiagnosticsCallback, keyValueSetCallback) => {
|
|
@@ -24074,11 +24122,26 @@ class ExotelWebClient {
|
|
|
24074
24122
|
* When registration is successful then send the phone number of the same to UI
|
|
24075
24123
|
*/
|
|
24076
24124
|
this.eventListener.onInitializationSuccess(phone);
|
|
24125
|
+
this.registrationInProgress = false;
|
|
24126
|
+
if (this.unregisterInitiated) {
|
|
24127
|
+
logger.log("ExWebClient:registerEventCallback unregistering due to unregisterInitiated");
|
|
24128
|
+
this.unregisterInitiated = false;
|
|
24129
|
+
this.unregister();
|
|
24130
|
+
}
|
|
24077
24131
|
} else if (event === "failed_to_start" || event === "transport_error") {
|
|
24078
24132
|
/**
|
|
24079
24133
|
* If registration fails
|
|
24080
24134
|
*/
|
|
24081
24135
|
this.eventListener.onInitializationFailure(phone);
|
|
24136
|
+
if (this.unregisterInitiated) {
|
|
24137
|
+
this.shouldAutoRetry = false;
|
|
24138
|
+
this.unregisterInitiated = false;
|
|
24139
|
+
this.isReadyToRegister = true;
|
|
24140
|
+
}
|
|
24141
|
+
if (this.shouldAutoRetry) {
|
|
24142
|
+
logger.log("ExWebClient:registerEventCallback Autoretrying");
|
|
24143
|
+
(0,_api_registerAPI_RegisterListener__WEBPACK_IMPORTED_MODULE_1__.DoRegister)(this.sipAccountInfo, this);
|
|
24144
|
+
}
|
|
24082
24145
|
} else if (event === "sent_request") {
|
|
24083
24146
|
/**
|
|
24084
24147
|
* If registration request waiting...
|
|
@@ -24118,8 +24181,14 @@ class ExotelWebClient {
|
|
|
24118
24181
|
* @param {*} sipAccountInfo
|
|
24119
24182
|
*/
|
|
24120
24183
|
unregister = sipAccountInfo => {
|
|
24121
|
-
|
|
24122
|
-
|
|
24184
|
+
logger.log("ExWebClient:unregister Entry");
|
|
24185
|
+
this.shouldAutoRetry = false;
|
|
24186
|
+
this.unregisterInitiated = true;
|
|
24187
|
+
if (!this.registrationInProgress) {
|
|
24188
|
+
setTimeout(function () {
|
|
24189
|
+
_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__.webrtcSIPPhone.sipUnRegisterWebRTC();
|
|
24190
|
+
}, 500);
|
|
24191
|
+
}
|
|
24123
24192
|
};
|
|
24124
24193
|
webRTCStatusCallbackHandler = (msg1, arg1) => {
|
|
24125
24194
|
logger.log("webRTCStatusCallbackHandler: " + msg1 + " " + arg1);
|
|
@@ -24131,6 +24200,9 @@ class ExotelWebClient {
|
|
|
24131
24200
|
initialize = (uiContext, hostName, subscriberName, displayName, accountSid, subscriberToken, sipAccountInfo) => {
|
|
24132
24201
|
let wssPort = sipAccountInfo.port;
|
|
24133
24202
|
let wsPort = 4442;
|
|
24203
|
+
this.isReadyToRegister = false;
|
|
24204
|
+
this.registrationInProgress = true;
|
|
24205
|
+
this.shouldAutoRetry = true;
|
|
24134
24206
|
this.sipAccntInfo = {
|
|
24135
24207
|
'userName': '',
|
|
24136
24208
|
'authUser': '',
|