@exotel-npm-dev/webrtc-client-sdk 3.0.0 → 3.0.3
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 +6 -0
- package/dist/exotelsdk.js +612 -477
- package/dist/exotelsdk.js.map +1 -1
- package/package.json +2 -2
- package/src/listeners/ExWebClient.js +64 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exotel-npm-dev/webrtc-client-sdk",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "client sdk for webrtc based on webrtc core sdk",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
"webpack-cli": "^4.10.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@exotel-npm-dev/webrtc-core-sdk": "^3.0.
|
|
32
|
+
"@exotel-npm-dev/webrtc-core-sdk": "^3.0.3"
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -65,6 +65,7 @@ function fetchPublicIP(sipAccountInfo) {
|
|
|
65
65
|
class ExDelegationHandler {
|
|
66
66
|
constructor(exClient) {
|
|
67
67
|
this.exClient = exClient;
|
|
68
|
+
this.sessionCallback = exClient.sessionCallback;
|
|
68
69
|
}
|
|
69
70
|
setTestingMode(mode) {
|
|
70
71
|
logger.log("delegationHandler: setTestingMode\n");
|
|
@@ -88,6 +89,8 @@ class ExDelegationHandler {
|
|
|
88
89
|
}
|
|
89
90
|
onStatPeerConnectionIceGatheringStateChange(iceGatheringState) {
|
|
90
91
|
logger.log("delegationHandler: onStatPeerConnectionIceGatheringStateChange\n");
|
|
92
|
+
this.sessionCallback.initializeSession(`ice_gathering_state_${iceGatheringState}`, this.exClient.callFromNumber);
|
|
93
|
+
this.sessionCallback.triggerSessionCallback();
|
|
91
94
|
}
|
|
92
95
|
onCallStatIceCandidate(ev, icestate) {
|
|
93
96
|
logger.log("delegationHandler: onCallStatIceCandidate\n");
|
|
@@ -98,8 +101,10 @@ class ExDelegationHandler {
|
|
|
98
101
|
onCallStatSignalingStateChange(cstate) {
|
|
99
102
|
logger.log("delegationHandler: onCallStatSignalingStateChange\n");
|
|
100
103
|
}
|
|
101
|
-
onStatPeerConnectionIceConnectionStateChange() {
|
|
104
|
+
onStatPeerConnectionIceConnectionStateChange(iceConnectionState) {
|
|
102
105
|
logger.log("delegationHandler: onStatPeerConnectionIceConnectionStateChange\n");
|
|
106
|
+
this.sessionCallback.initializeSession(`ice_connection_state_${iceConnectionState}`, this.exClient.callFromNumber);
|
|
107
|
+
this.sessionCallback.triggerSessionCallback();
|
|
103
108
|
}
|
|
104
109
|
onStatPeerConnectionConnectionStateChange() {
|
|
105
110
|
logger.log("delegationHandler: onStatPeerConnectionConnectionStateChange\n");
|
|
@@ -109,6 +114,8 @@ class ExDelegationHandler {
|
|
|
109
114
|
}
|
|
110
115
|
onGetUserMediaErrorCallstatCallback() {
|
|
111
116
|
logger.log("delegationHandler: onGetUserMediaErrorCallstatCallback\n");
|
|
117
|
+
this.sessionCallback.initializeSession(`media_permission_denied`, this.exClient.callFromNumber);
|
|
118
|
+
this.sessionCallback.triggerSessionCallback();
|
|
112
119
|
}
|
|
113
120
|
onCallStatAddStream() {
|
|
114
121
|
logger.log("delegationHandler: onCallStatAddStream\n");
|
|
@@ -185,9 +192,8 @@ class ExSynchronousHandler {
|
|
|
185
192
|
}
|
|
186
193
|
}
|
|
187
194
|
|
|
188
|
-
export { ExDelegationHandler, ExSynchronousHandler };
|
|
189
195
|
|
|
190
|
-
|
|
196
|
+
class ExotelWebClient {
|
|
191
197
|
/**
|
|
192
198
|
* @param {Object} sipAccntInfo
|
|
193
199
|
*/
|
|
@@ -210,6 +216,8 @@ export class ExotelWebClient {
|
|
|
210
216
|
registerCallback = null;
|
|
211
217
|
sessionCallback = null;
|
|
212
218
|
logger = getLogger();
|
|
219
|
+
static clientSDKLoggerCallback = null;
|
|
220
|
+
|
|
213
221
|
|
|
214
222
|
constructor() {
|
|
215
223
|
// Initialize properties
|
|
@@ -224,24 +232,17 @@ export class ExotelWebClient {
|
|
|
224
232
|
this.currentSIPUserName = "";
|
|
225
233
|
this.isReadyToRegister = true;
|
|
226
234
|
this.sipAccountInfo = null;
|
|
227
|
-
this.clientSDKLoggerCallback = null;
|
|
228
235
|
this.callbacks = new Callback();
|
|
229
236
|
this.registerCallback = new RegisterCallback();
|
|
230
237
|
this.sessionCallback = new SessionCallback();
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.logger.registerLoggerCallback((type, message, args) => {
|
|
235
|
-
LogManager.onLog(type, message, args);
|
|
236
|
-
if (this.clientSDKLoggerCallback) {
|
|
237
|
-
this.clientSDKLoggerCallback("log", message, args);
|
|
238
|
-
}
|
|
239
|
-
});
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
240
241
|
}
|
|
241
242
|
|
|
242
243
|
|
|
243
244
|
initWebrtc = async (sipAccountInfo_,
|
|
244
|
-
RegisterEventCallBack, CallListenerCallback, SessionCallback) => {
|
|
245
|
+
RegisterEventCallBack, CallListenerCallback, SessionCallback, enableAutoAudioDeviceChangeHandling=false) => {
|
|
245
246
|
const userName = sipAccountInfo_?.userName;
|
|
246
247
|
if (!userName) return false;
|
|
247
248
|
|
|
@@ -271,6 +272,7 @@ export class ExotelWebClient {
|
|
|
271
272
|
this.ctrlr = new CallController();
|
|
272
273
|
}
|
|
273
274
|
|
|
275
|
+
sipAccountInfo_.enableAutoAudioDeviceChangeHandling = enableAutoAudioDeviceChangeHandling;
|
|
274
276
|
logger.log("ExWebClient: initWebrtc: Exotel Client Initialised with " + JSON.stringify(sipAccountInfo_))
|
|
275
277
|
this.sipAccountInfo = sipAccountInfo_;
|
|
276
278
|
if (!this.sipAccountInfo["userName"] || !this.sipAccountInfo["sipdomain"] || !this.sipAccountInfo["port"]) {
|
|
@@ -301,7 +303,7 @@ export class ExotelWebClient {
|
|
|
301
303
|
}
|
|
302
304
|
|
|
303
305
|
// Initialize the phone with SIP engine
|
|
304
|
-
this.webrtcSIPPhone.registerPhone("sipjs", new ExDelegationHandler(this));
|
|
306
|
+
this.webrtcSIPPhone.registerPhone("sipjs", new ExDelegationHandler(this), this.sipAccountInfo.enableAutoAudioDeviceChangeHandling);
|
|
305
307
|
|
|
306
308
|
// Create call instance after phone is initialized
|
|
307
309
|
if (!this.call) {
|
|
@@ -533,7 +535,7 @@ export class ExotelWebClient {
|
|
|
533
535
|
var userName = this.userName;
|
|
534
536
|
|
|
535
537
|
|
|
536
|
-
this.webrtcSIPPhone.registerPhone("sipjs", delegationHandler);
|
|
538
|
+
this.webrtcSIPPhone.registerPhone("sipjs", delegationHandler, this.sipAccountInfo.enableAutoAudioDeviceChangeHandling);
|
|
537
539
|
this.webrtcSIPPhone.registerWebRTCClient(this.sipAccntInfo, synchronousHandler);
|
|
538
540
|
phonePool[this.userName] = this.webrtcSIPPhone;
|
|
539
541
|
|
|
@@ -585,14 +587,14 @@ export class ExotelWebClient {
|
|
|
585
587
|
});
|
|
586
588
|
};
|
|
587
589
|
|
|
588
|
-
changeAudioInputDevice(deviceId, onSuccess, onError) {
|
|
590
|
+
changeAudioInputDevice(deviceId, onSuccess, onError, forceDeviceChange = false) {
|
|
589
591
|
logger.log(`ExWebClient: changeAudioInputDevice: Entry`);
|
|
590
|
-
this.webrtcSIPPhone.changeAudioInputDevice(deviceId, onSuccess, onError);
|
|
592
|
+
this.webrtcSIPPhone.changeAudioInputDevice(deviceId, onSuccess, onError, forceDeviceChange);
|
|
591
593
|
}
|
|
592
594
|
|
|
593
|
-
changeAudioOutputDevice(deviceId, onSuccess, onError) {
|
|
595
|
+
changeAudioOutputDevice(deviceId, onSuccess, onError, forceDeviceChange = false) {
|
|
594
596
|
logger.log(`ExWebClient: changeAudioOutputDevice: Entry`);
|
|
595
|
-
this.webrtcSIPPhone.changeAudioOutputDevice(deviceId, onSuccess, onError);
|
|
597
|
+
this.webrtcSIPPhone.changeAudioOutputDevice(deviceId, onSuccess, onError, forceDeviceChange);
|
|
596
598
|
}
|
|
597
599
|
|
|
598
600
|
downloadLogs() {
|
|
@@ -609,8 +611,9 @@ export class ExotelWebClient {
|
|
|
609
611
|
this.webrtcSIPPhone.setPreferredCodec(codecName);
|
|
610
612
|
}
|
|
611
613
|
|
|
612
|
-
registerLoggerCallback(callback) {
|
|
613
|
-
|
|
614
|
+
static registerLoggerCallback(callback) {
|
|
615
|
+
logger.log("ExWebClient: registerLoggerCallback: Entry");
|
|
616
|
+
ExotelWebClient.clientSDKLoggerCallback = callback;
|
|
614
617
|
}
|
|
615
618
|
|
|
616
619
|
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback) {
|
|
@@ -621,6 +624,45 @@ export class ExotelWebClient {
|
|
|
621
624
|
}
|
|
622
625
|
this.webrtcSIPPhone.registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback);
|
|
623
626
|
}
|
|
627
|
+
|
|
628
|
+
static setEnableConsoleLogging(enable) {
|
|
629
|
+
if (enable) {
|
|
630
|
+
logger.log("ExWebClient: setEnableConsoleLogging: Entry, enable: " + enable);
|
|
631
|
+
}
|
|
632
|
+
logger.setEnableConsoleLogging(enable);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
static setAudioOutputVolume(audioElementName, value) {
|
|
636
|
+
logger.log(`ExWebClient: setAudioOutputVolume: Entry, audioElementName: ${audioElementName}, value: ${value}`);
|
|
637
|
+
WebrtcSIPPhone.setAudioOutputVolume(audioElementName, value);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
static getAudioOutputVolume(audioElementName) {
|
|
641
|
+
logger.log(`ExWebClient: getAudioOutputVolume: Entry, audioElementName: ${audioElementName}`);
|
|
642
|
+
return WebrtcSIPPhone.getAudioOutputVolume(audioElementName);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
setCallAudioOutputVolume(value) {
|
|
646
|
+
logger.log(`ExWebClient: setCallAudioOutputVolume: Entry, value: ${value}`);
|
|
647
|
+
this.webrtcSIPPhone.setCallAudioOutputVolume(value);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
getCallAudioOutputVolume() {
|
|
651
|
+
logger.log(`ExWebClient: getCallAudioOutputVolume: Entry`);
|
|
652
|
+
return this.webrtcSIPPhone.getCallAudioOutputVolume();
|
|
653
|
+
}
|
|
654
|
+
|
|
624
655
|
}
|
|
625
656
|
|
|
657
|
+
|
|
658
|
+
logger.registerLoggerCallback((type, message, args) => {
|
|
659
|
+
LogManager.onLog(type, message, args);
|
|
660
|
+
if (ExotelWebClient.clientSDKLoggerCallback) {
|
|
661
|
+
ExotelWebClient.clientSDKLoggerCallback("log", message, args);
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
export { ExDelegationHandler, ExSynchronousHandler, ExotelWebClient };
|
|
667
|
+
|
|
626
668
|
export default ExotelWebClient;
|