@exotel-npm-dev/webrtc-client-sdk 1.0.14 → 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 +3 -0
- package/dist/exotelsdk.js +82 -47
- package/dist/exotelsdk.js.map +1 -1
- package/package.json +2 -2
- package/src/listeners/ExWebClient.js +3 -3
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.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"];
|
|
@@ -23970,7 +24005,7 @@ function ExSynchronousHandler() {
|
|
|
23970
24005
|
}
|
|
23971
24006
|
class ExotelWebClient {
|
|
23972
24007
|
ctrlr = null;
|
|
23973
|
-
call
|
|
24008
|
+
call;
|
|
23974
24009
|
eventListener = null;
|
|
23975
24010
|
callListener = null;
|
|
23976
24011
|
callFromNumber = null;
|
|
@@ -24257,8 +24292,8 @@ class ExotelWebClient {
|
|
|
24257
24292
|
registerLoggerCallback(callback) {
|
|
24258
24293
|
logger.registerLoggerCallback(callback);
|
|
24259
24294
|
}
|
|
24260
|
-
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback) {
|
|
24261
|
-
_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);
|
|
24262
24297
|
}
|
|
24263
24298
|
}
|
|
24264
24299
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ExotelWebClient);
|