@wazo/sdk 0.37.2 → 0.37.6
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/dist/wazo-sdk.js +5 -5
- package/esm/__tests__/api-client.test.js +84 -22
- package/esm/__tests__/web-rtc-client.test.js +156 -55
- package/esm/api/call-logd.js +10 -22
- package/esm/api/calld.js +3 -0
- package/esm/api/confd.js +71 -0
- package/esm/api-client.js +84 -22
- package/esm/checker/Checker.js +160 -55
- package/esm/checker/checks/aor.js +84 -22
- package/esm/checker/checks/api.js +84 -22
- package/esm/checker/checks/index.js +160 -55
- package/esm/checker/checks/wazo-websocket.js +4 -0
- package/esm/checker/checks/webrtc-transport.js +156 -55
- package/esm/checker/checks/webrtc.js +156 -55
- package/esm/domain/AdHocAPIConference.js +84 -22
- package/esm/domain/CallLog.js +10 -22
- package/esm/domain/Features.js +84 -22
- package/esm/domain/Meeting.js +71 -0
- package/esm/domain/Phone/CTIPhone.js +84 -22
- package/esm/domain/Phone/WebRTCPhone.js +22 -8
- package/esm/domain/__tests__/CallLog.test.js +10 -22
- package/esm/index.js +726 -371
- package/esm/lib/WazoSessionDescriptionHandler.js +17 -9
- package/esm/service/CallApi.js +84 -22
- package/esm/service/getApiClient.js +84 -22
- package/esm/simple/Auth.js +717 -363
- package/esm/simple/Configuration.js +717 -363
- package/esm/simple/Directory.js +84 -22
- package/esm/simple/Phone.js +709 -355
- package/esm/simple/Websocket.js +6 -0
- package/esm/simple/index.js +719 -365
- package/esm/simple/room/LocalParticipant.js +689 -335
- package/esm/simple/room/Participant.js +689 -335
- package/esm/simple/room/RemoteParticipant.js +689 -335
- package/esm/simple/room/Room.js +689 -335
- package/esm/simple/room/SipRoom.js +13001 -0
- package/esm/simple/room/Stream.js +719 -365
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +4130 -3774
- package/esm/simple/utils.js +719 -365
- package/esm/web-rtc-client.js +156 -55
- package/esm/websocket-client.js +5 -1
- package/lib/__tests__/api-client.test.js +84 -22
- package/lib/__tests__/web-rtc-client.test.js +156 -55
- package/lib/api/call-logd.js +10 -22
- package/lib/api/calld.js +3 -0
- package/lib/api/confd.js +71 -0
- package/lib/api-client.js +84 -22
- package/lib/checker/Checker.js +160 -55
- package/lib/checker/checks/aor.js +84 -22
- package/lib/checker/checks/api.js +84 -22
- package/lib/checker/checks/index.js +160 -55
- package/lib/checker/checks/wazo-websocket.js +4 -0
- package/lib/checker/checks/webrtc-transport.js +156 -55
- package/lib/checker/checks/webrtc.js +156 -55
- package/lib/domain/AdHocAPIConference.js +84 -22
- package/lib/domain/CallLog.js +10 -22
- package/lib/domain/Features.js +84 -22
- package/lib/domain/Meeting.js +73 -0
- package/lib/domain/Phone/CTIPhone.js +84 -22
- package/lib/domain/Phone/WebRTCPhone.js +22 -8
- package/lib/domain/__tests__/CallLog.test.js +10 -22
- package/lib/index.js +726 -371
- package/lib/lib/WazoSessionDescriptionHandler.js +17 -9
- package/lib/service/CallApi.js +84 -22
- package/lib/service/getApiClient.js +84 -22
- package/lib/simple/Auth.js +717 -363
- package/lib/simple/Configuration.js +717 -363
- package/lib/simple/Directory.js +84 -22
- package/lib/simple/Phone.js +709 -355
- package/lib/simple/Websocket.js +6 -0
- package/lib/simple/index.js +719 -365
- package/lib/simple/room/LocalParticipant.js +689 -335
- package/lib/simple/room/Participant.js +689 -335
- package/lib/simple/room/RemoteParticipant.js +689 -335
- package/lib/simple/room/Room.js +689 -335
- package/lib/simple/room/SipRoom.js +13011 -0
- package/lib/simple/room/Stream.js +719 -365
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +4131 -3775
- package/lib/simple/utils.js +719 -365
- package/lib/web-rtc-client.js +156 -55
- package/lib/websocket-client.js +6 -0
- package/package.json +1 -1
- package/src/api/calld.js +3 -0
- package/src/api/confd.js +13 -0
- package/src/domain/CallLog.js +10 -22
- package/src/domain/Meeting.js +59 -0
- package/src/domain/Phone/WebRTCPhone.js +22 -8
- package/src/index.js +2 -0
- package/src/lib/WazoSessionDescriptionHandler.js +17 -9
- package/src/simple/Phone.js +13 -4
- package/src/simple/index.js +4 -0
- package/src/simple/room/Participant.js +7 -0
- package/src/simple/room/Room.js +158 -79
- package/src/simple/room/SipRoom.js +147 -0
- package/src/simple/room/Stream.js +1 -3
- package/src/simple/room/__tests__/RemoteParticipant.test.js +3 -2
- package/src/types/WebSocketMessage.js +21 -0
- package/src/web-rtc-client.js +55 -24
- package/src/websocket-client.js +4 -0
|
@@ -138,7 +138,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
138
138
|
|
|
139
139
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
140
140
|
|
|
141
|
-
const logger$
|
|
141
|
+
const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
142
142
|
|
|
143
143
|
// Use a function here to be able to mock it in tests
|
|
144
144
|
const realFetch = () => {
|
|
@@ -277,7 +277,7 @@ class ApiRequester {
|
|
|
277
277
|
};
|
|
278
278
|
|
|
279
279
|
if (this.refreshTokenPromise) {
|
|
280
|
-
logger$
|
|
280
|
+
logger$c.info('A token is already refreshing, waiting ...', { url });
|
|
281
281
|
await this.refreshTokenPromise;
|
|
282
282
|
}
|
|
283
283
|
|
|
@@ -297,7 +297,7 @@ class ApiRequester {
|
|
|
297
297
|
return promise.then(async (err ) => {
|
|
298
298
|
// Check if the token is still valid
|
|
299
299
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
300
|
-
logger$
|
|
300
|
+
logger$c.warn('token expired', { error: err.reason });
|
|
301
301
|
// Replay the call after refreshing the token
|
|
302
302
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
303
303
|
}
|
|
@@ -307,7 +307,7 @@ class ApiRequester {
|
|
|
307
307
|
: exceptionClass.fromResponse(err, response.status);
|
|
308
308
|
|
|
309
309
|
if (this.shouldLogErrors) {
|
|
310
|
-
logger$
|
|
310
|
+
logger$c.error('API error', error);
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
throw error;
|
|
@@ -317,7 +317,7 @@ class ApiRequester {
|
|
|
317
317
|
return newParse(response, isJson);
|
|
318
318
|
}).catch(error => {
|
|
319
319
|
if (this.shouldLogErrors) {
|
|
320
|
-
logger$
|
|
320
|
+
logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
throw error;
|
|
@@ -345,13 +345,13 @@ class ApiRequester {
|
|
|
345
345
|
) {
|
|
346
346
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
347
347
|
let newPath = path;
|
|
348
|
-
logger$
|
|
348
|
+
logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
349
349
|
|
|
350
350
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
351
351
|
|
|
352
352
|
return this.refreshTokenPromise.then(() => {
|
|
353
353
|
this.refreshTokenPromise = null;
|
|
354
|
-
logger$
|
|
354
|
+
logger$c.info('token refreshed', { isTokenNotFound });
|
|
355
355
|
if (isTokenNotFound) {
|
|
356
356
|
const pathParts = path.split('/');
|
|
357
357
|
pathParts.pop();
|
|
@@ -2548,6 +2548,65 @@ class ExternalApp {
|
|
|
2548
2548
|
}
|
|
2549
2549
|
}
|
|
2550
2550
|
|
|
2551
|
+
//
|
|
2552
|
+
|
|
2553
|
+
|
|
2554
|
+
|
|
2555
|
+
|
|
2556
|
+
|
|
2557
|
+
|
|
2558
|
+
|
|
2559
|
+
|
|
2560
|
+
|
|
2561
|
+
|
|
2562
|
+
|
|
2563
|
+
class Meeting {
|
|
2564
|
+
|
|
2565
|
+
|
|
2566
|
+
|
|
2567
|
+
|
|
2568
|
+
|
|
2569
|
+
|
|
2570
|
+
|
|
2571
|
+
|
|
2572
|
+
|
|
2573
|
+
|
|
2574
|
+
static parse(plain ) {
|
|
2575
|
+
return new Meeting({
|
|
2576
|
+
guestSipAuthorization: plain.guest_sip_authorization,
|
|
2577
|
+
hostname: plain.hostname,
|
|
2578
|
+
name: plain.name,
|
|
2579
|
+
ownerUuids: plain.owner_uuids,
|
|
2580
|
+
port: plain.port,
|
|
2581
|
+
uuid: plain.uuid,
|
|
2582
|
+
number: plain.number,
|
|
2583
|
+
});
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
static newFrom(meeting ) {
|
|
2587
|
+
return newFrom(meeting, Meeting);
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, hostname, number } = {}) {
|
|
2591
|
+
this.guestSipAuthorization = guestSipAuthorization;
|
|
2592
|
+
this.hostname = hostname;
|
|
2593
|
+
this.name = name;
|
|
2594
|
+
this.ownerUuids = ownerUuids;
|
|
2595
|
+
this.port = port;
|
|
2596
|
+
this.uuid = uuid;
|
|
2597
|
+
this.number = number;
|
|
2598
|
+
|
|
2599
|
+
// Useful to compare instead of instanceof with minified code
|
|
2600
|
+
this.type = 'Meeting';
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
getGuestSipCredentials() {
|
|
2604
|
+
// eslint-disable-next-line no-undef
|
|
2605
|
+
const [username, secret] = atob(this.guestSipAuthorization).split(':');
|
|
2606
|
+
return { username, secret };
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2551
2610
|
/* */
|
|
2552
2611
|
|
|
2553
2612
|
var confdMethods = (client , baseUrl ) => ({
|
|
@@ -2612,6 +2671,18 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2612
2671
|
return null;
|
|
2613
2672
|
}
|
|
2614
2673
|
},
|
|
2674
|
+
|
|
2675
|
+
createMyMeeting: (name ) =>
|
|
2676
|
+
client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
|
|
2677
|
+
|
|
2678
|
+
deleteMyMeeting: (meetingUuid ) =>
|
|
2679
|
+
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
2680
|
+
|
|
2681
|
+
getMeeting: (meetingUuid ) =>
|
|
2682
|
+
client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
2683
|
+
|
|
2684
|
+
guestGetMeeting: (meetingUuid ) =>
|
|
2685
|
+
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
2615
2686
|
});
|
|
2616
2687
|
|
|
2617
2688
|
//
|
|
@@ -3528,7 +3599,11 @@ class CallLog {
|
|
|
3528
3599
|
answered: plain.answered,
|
|
3529
3600
|
callDirection: plain.call_direction,
|
|
3530
3601
|
destination: {
|
|
3531
|
-
|
|
3602
|
+
// @TEMP: Temporarily assuming empty numbers are meetings
|
|
3603
|
+
// which is admittedly a very dangerous assumption. Did i mention it was temporary?
|
|
3604
|
+
extension: plain.requested_extension
|
|
3605
|
+
|| plain.destination_extension
|
|
3606
|
+
|| `meeting-${plain.requested_name || plain.destination_name || ''}`,
|
|
3532
3607
|
name: plain.requested_name || plain.destination_name || '',
|
|
3533
3608
|
},
|
|
3534
3609
|
source: {
|
|
@@ -3544,27 +3619,11 @@ class CallLog {
|
|
|
3544
3619
|
}
|
|
3545
3620
|
|
|
3546
3621
|
static parseNew(plain , session ) {
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
extension: plain.requested_extension || plain.destination_extension,
|
|
3553
|
-
name: plain.requested_name || plain.destination_name || '',
|
|
3554
|
-
},
|
|
3555
|
-
source: {
|
|
3556
|
-
extension: plain.source_extension,
|
|
3557
|
-
name: plain.source_name,
|
|
3558
|
-
},
|
|
3559
|
-
id: plain.id,
|
|
3560
|
-
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
3561
|
-
start: moment__default['default'](plain.start).toDate(),
|
|
3562
|
-
end: plain.end ? moment__default['default'](plain.end).toDate() : null,
|
|
3563
|
-
recordings: Recording.parseMany(plain.recordings),
|
|
3564
|
-
// @TODO: FIXME add verification declined vs missed call
|
|
3565
|
-
newMissedCall: session
|
|
3566
|
-
&& session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
|
|
3567
|
-
});
|
|
3622
|
+
const callLog = CallLog.parse(plain);
|
|
3623
|
+
// @TODO: FIXME add verification declined vs missed call
|
|
3624
|
+
callLog.newMissedCall = session
|
|
3625
|
+
&& session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
|
|
3626
|
+
return callLog;
|
|
3568
3627
|
}
|
|
3569
3628
|
|
|
3570
3629
|
static newFrom(profile ) {
|
|
@@ -3829,7 +3888,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3829
3888
|
|
|
3830
3889
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3831
3890
|
|
|
3832
|
-
const logger$
|
|
3891
|
+
const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3833
3892
|
|
|
3834
3893
|
class CTIPhone extends Emitter {
|
|
3835
3894
|
|
|
@@ -3842,7 +3901,7 @@ class CTIPhone extends Emitter {
|
|
|
3842
3901
|
|
|
3843
3902
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
3844
3903
|
super();
|
|
3845
|
-
logger$
|
|
3904
|
+
logger$b.info('CTI Phone created');
|
|
3846
3905
|
this.session = session;
|
|
3847
3906
|
this.isMobile = isMobile;
|
|
3848
3907
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -3903,7 +3962,7 @@ class CTIPhone extends Emitter {
|
|
|
3903
3962
|
}
|
|
3904
3963
|
|
|
3905
3964
|
async makeCall(number , line ) {
|
|
3906
|
-
logger$
|
|
3965
|
+
logger$b.info('make CTI call', { number });
|
|
3907
3966
|
|
|
3908
3967
|
if (!number) {
|
|
3909
3968
|
return null;
|
|
@@ -3926,7 +3985,7 @@ class CTIPhone extends Emitter {
|
|
|
3926
3985
|
if (!callSession) {
|
|
3927
3986
|
return Promise.resolve(null);
|
|
3928
3987
|
}
|
|
3929
|
-
logger$
|
|
3988
|
+
logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3930
3989
|
|
|
3931
3990
|
if (!this.currentCall) {
|
|
3932
3991
|
this.currentCall = callSession.call;
|
|
@@ -3939,7 +3998,7 @@ class CTIPhone extends Emitter {
|
|
|
3939
3998
|
if (!callSession) {
|
|
3940
3999
|
return;
|
|
3941
4000
|
}
|
|
3942
|
-
logger$
|
|
4001
|
+
logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3943
4002
|
|
|
3944
4003
|
this.currentCall = undefined;
|
|
3945
4004
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -3949,7 +4008,7 @@ class CTIPhone extends Emitter {
|
|
|
3949
4008
|
if (!callSession) {
|
|
3950
4009
|
return Promise.resolve(false);
|
|
3951
4010
|
}
|
|
3952
|
-
logger$
|
|
4011
|
+
logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3953
4012
|
|
|
3954
4013
|
try {
|
|
3955
4014
|
await CallApi.cancelCall(callSession);
|
|
@@ -3960,7 +4019,7 @@ class CTIPhone extends Emitter {
|
|
|
3960
4019
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
3961
4020
|
return true;
|
|
3962
4021
|
} catch (e) {
|
|
3963
|
-
logger$
|
|
4022
|
+
logger$b.error('hangup CTI call, error', e);
|
|
3964
4023
|
|
|
3965
4024
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
3966
4025
|
return false;
|
|
@@ -3973,7 +4032,7 @@ class CTIPhone extends Emitter {
|
|
|
3973
4032
|
if (!callSession) {
|
|
3974
4033
|
return;
|
|
3975
4034
|
}
|
|
3976
|
-
logger$
|
|
4035
|
+
logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3977
4036
|
|
|
3978
4037
|
await CallApi.cancelCall(callSession);
|
|
3979
4038
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -3983,7 +4042,7 @@ class CTIPhone extends Emitter {
|
|
|
3983
4042
|
if (!callSession) {
|
|
3984
4043
|
return;
|
|
3985
4044
|
}
|
|
3986
|
-
logger$
|
|
4045
|
+
logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
3987
4046
|
|
|
3988
4047
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
3989
4048
|
}
|
|
@@ -3994,19 +4053,19 @@ class CTIPhone extends Emitter {
|
|
|
3994
4053
|
if (!callSession) {
|
|
3995
4054
|
return;
|
|
3996
4055
|
}
|
|
3997
|
-
logger$
|
|
4056
|
+
logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
3998
4057
|
|
|
3999
4058
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4000
4059
|
}
|
|
4001
4060
|
|
|
4002
4061
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4003
|
-
logger$
|
|
4062
|
+
logger$b.info('cancel CTI transfer', { transferId });
|
|
4004
4063
|
|
|
4005
4064
|
return CallApi.cancelCallTransfer(transferId);
|
|
4006
4065
|
}
|
|
4007
4066
|
|
|
4008
4067
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4009
|
-
logger$
|
|
4068
|
+
logger$b.info('confirm CTI transfer', { transferId });
|
|
4010
4069
|
|
|
4011
4070
|
return CallApi.confirmCallTransfer(transferId);
|
|
4012
4071
|
}
|
|
@@ -4015,19 +4074,19 @@ class CTIPhone extends Emitter {
|
|
|
4015
4074
|
if (!callSession) {
|
|
4016
4075
|
return;
|
|
4017
4076
|
}
|
|
4018
|
-
logger$
|
|
4077
|
+
logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4019
4078
|
|
|
4020
4079
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4021
4080
|
}
|
|
4022
4081
|
|
|
4023
4082
|
onConnectionMade() {
|
|
4024
|
-
logger$
|
|
4083
|
+
logger$b.info('on CTI connection made');
|
|
4025
4084
|
|
|
4026
4085
|
this.eventEmitter.emit('onCallAccepted');
|
|
4027
4086
|
}
|
|
4028
4087
|
|
|
4029
4088
|
async close() {
|
|
4030
|
-
logger$
|
|
4089
|
+
logger$b.info('CTI close');
|
|
4031
4090
|
|
|
4032
4091
|
return Promise.resolve();
|
|
4033
4092
|
}
|
|
@@ -4036,7 +4095,7 @@ class CTIPhone extends Emitter {
|
|
|
4036
4095
|
if (!callSession) {
|
|
4037
4096
|
return;
|
|
4038
4097
|
}
|
|
4039
|
-
logger$
|
|
4098
|
+
logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4040
4099
|
|
|
4041
4100
|
return CallApi.hold(callSession.callId);
|
|
4042
4101
|
}
|
|
@@ -4045,7 +4104,7 @@ class CTIPhone extends Emitter {
|
|
|
4045
4104
|
if (!callSession) {
|
|
4046
4105
|
return;
|
|
4047
4106
|
}
|
|
4048
|
-
logger$
|
|
4107
|
+
logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4049
4108
|
|
|
4050
4109
|
return CallApi.resume(callSession.callId);
|
|
4051
4110
|
}
|
|
@@ -4054,7 +4113,7 @@ class CTIPhone extends Emitter {
|
|
|
4054
4113
|
if (!callSession) {
|
|
4055
4114
|
return;
|
|
4056
4115
|
}
|
|
4057
|
-
logger$
|
|
4116
|
+
logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4058
4117
|
|
|
4059
4118
|
return CallApi.mute(callSession.callId);
|
|
4060
4119
|
}
|
|
@@ -4063,7 +4122,7 @@ class CTIPhone extends Emitter {
|
|
|
4063
4122
|
if (!callSession) {
|
|
4064
4123
|
return;
|
|
4065
4124
|
}
|
|
4066
|
-
logger$
|
|
4125
|
+
logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4067
4126
|
|
|
4068
4127
|
return CallApi.unmute(callSession.callId);
|
|
4069
4128
|
}
|
|
@@ -4709,6 +4768,9 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
4709
4768
|
getConferenceParticipantsAsUser: async (conferenceId ) =>
|
|
4710
4769
|
client.get(`${baseUrl}/users/me/conferences/${conferenceId}/participants`),
|
|
4711
4770
|
|
|
4771
|
+
getMeetingParticipantsAsUser: async (meetingUuid ) =>
|
|
4772
|
+
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
|
|
4773
|
+
|
|
4712
4774
|
listTrunks: () => client.get(`${baseUrl}/trunks`),
|
|
4713
4775
|
|
|
4714
4776
|
mute: (callId ) =>
|
|
@@ -5062,7 +5124,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5062
5124
|
const WEBHOOKD_VERSION = '1.0';
|
|
5063
5125
|
const AMID_VERSION = '1.0';
|
|
5064
5126
|
|
|
5065
|
-
const logger$
|
|
5127
|
+
const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5066
5128
|
|
|
5067
5129
|
class ApiClient {
|
|
5068
5130
|
|
|
@@ -5114,12 +5176,12 @@ class ApiClient {
|
|
|
5114
5176
|
}
|
|
5115
5177
|
|
|
5116
5178
|
async forceRefreshToken() {
|
|
5117
|
-
logger$
|
|
5179
|
+
logger$a.info('forcing refresh token, calling callback');
|
|
5118
5180
|
return this.refreshTokenCallback();
|
|
5119
5181
|
}
|
|
5120
5182
|
|
|
5121
5183
|
async refreshTokenCallback() {
|
|
5122
|
-
logger$
|
|
5184
|
+
logger$a.info('refresh token callback called', {
|
|
5123
5185
|
refreshToken: this.refreshToken,
|
|
5124
5186
|
refreshBackend: this.refreshBackend,
|
|
5125
5187
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5137,7 +5199,7 @@ class ApiClient {
|
|
|
5137
5199
|
this.isMobile,
|
|
5138
5200
|
);
|
|
5139
5201
|
|
|
5140
|
-
logger$
|
|
5202
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5141
5203
|
|
|
5142
5204
|
if (this.onRefreshToken) {
|
|
5143
5205
|
this.onRefreshToken(session.token, session);
|
|
@@ -5278,7 +5340,7 @@ var getApiClient = (forServer ) => {
|
|
|
5278
5340
|
class InvalidSubscription extends Error {}
|
|
5279
5341
|
class InvalidAuthorization extends Error {}
|
|
5280
5342
|
|
|
5281
|
-
const logger$
|
|
5343
|
+
const logger$9 = IssueReporter$1.loggerFor('simple-auth');
|
|
5282
5344
|
|
|
5283
5345
|
class Auth {
|
|
5284
5346
|
|
|
@@ -5313,7 +5375,7 @@ class Auth {
|
|
|
5313
5375
|
setApiClientId(this.clientId);
|
|
5314
5376
|
setRefreshExpiration(this.expiration);
|
|
5315
5377
|
setOnRefreshToken((token , session ) => {
|
|
5316
|
-
logger$
|
|
5378
|
+
logger$9.info('on refresh token done', { token });
|
|
5317
5379
|
setApiToken(token);
|
|
5318
5380
|
Wazo.Websocket.updateToken(token);
|
|
5319
5381
|
|
|
@@ -5872,7 +5934,9 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5872
5934
|
.then(() => {
|
|
5873
5935
|
if (isConference && (options.constraints && !options.constraints.video) && !('hold' in options) && !audioOnly) {
|
|
5874
5936
|
// Add a video an empty bundle to be able to replaceTrack when joining a conference without video
|
|
5875
|
-
this.peerConnection.addTransceiver
|
|
5937
|
+
if (this.peerConnection.addTransceiver) {
|
|
5938
|
+
this.peerConnection.addTransceiver('video', { streams: [this._localMediaStream], direction: 'sendrecv' });
|
|
5939
|
+
}
|
|
5876
5940
|
}
|
|
5877
5941
|
})
|
|
5878
5942
|
.then(() => this.createLocalOfferOrAnswer(options))
|
|
@@ -5899,12 +5963,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5899
5963
|
};
|
|
5900
5964
|
})
|
|
5901
5965
|
.then((sessionDescription) => this.applyModifiers(sessionDescription, modifiers))
|
|
5902
|
-
.then((sessionDescription) => {
|
|
5903
|
-
// Set new constraints to avoid the constraints check issue in `sdh.getLocalMediaStream` later.
|
|
5904
|
-
this.localMediaStreamConstraints = options.constraints;
|
|
5905
|
-
|
|
5906
|
-
return sessionDescription;
|
|
5907
|
-
})
|
|
5908
5966
|
.then((sessionDescription) => ({ body: sessionDescription.sdp, contentType: 'application/sdp' }))
|
|
5909
5967
|
.catch((error) => {
|
|
5910
5968
|
wazoLogger.error('error when creating media', error);
|
|
@@ -6099,6 +6157,9 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6099
6157
|
|
|
6100
6158
|
// set the transceiver direction to the answer direction
|
|
6101
6159
|
this._peerConnection.getTransceivers().forEach((transceiver) => {
|
|
6160
|
+
if (transceiver.stopped) {
|
|
6161
|
+
return;
|
|
6162
|
+
}
|
|
6102
6163
|
if (transceiver.direction /* guarding, but should always be true */) {
|
|
6103
6164
|
const { receiver } = transceiver;
|
|
6104
6165
|
if (isConference && audioOnly && receiver.track && receiver.track.kind === 'video') {
|
|
@@ -6143,10 +6204,15 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6143
6204
|
if (kind !== 'audio' && kind !== 'video') {
|
|
6144
6205
|
throw new Error(`Unknown new track kind ${kind}.`);
|
|
6145
6206
|
}
|
|
6146
|
-
const sender = pc.getSenders().find((otherSender) =>
|
|
6207
|
+
const sender = pc.getSenders && pc.getSenders().find((otherSender) =>
|
|
6208
|
+
otherSender.track && otherSender.track.kind === kind);
|
|
6147
6209
|
|
|
6148
6210
|
// Do not reuse sender video tracks in SFU
|
|
6149
6211
|
if (sender && (!sfu || newTrack.kind === 'audio')) {
|
|
6212
|
+
if (sender.track) {
|
|
6213
|
+
// eslint-disable-next-line no-param-reassign
|
|
6214
|
+
newTrack.enabled = sender.track.enabled;
|
|
6215
|
+
}
|
|
6150
6216
|
trackUpdates.push(
|
|
6151
6217
|
new Promise((resolve) => {
|
|
6152
6218
|
this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - replacing sender ${kind} track`);
|
|
@@ -6180,7 +6246,11 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6180
6246
|
// Review: could make streamless tracks a configurable option?
|
|
6181
6247
|
// https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addTrack#Usage_notes
|
|
6182
6248
|
try {
|
|
6183
|
-
pc.addTrack
|
|
6249
|
+
if (pc.addTrack) {
|
|
6250
|
+
pc.addTrack(newTrack, localStream);
|
|
6251
|
+
} else {
|
|
6252
|
+
pc.addStream(localStream);
|
|
6253
|
+
}
|
|
6184
6254
|
} catch (error) {
|
|
6185
6255
|
this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to add sender ${kind} track`);
|
|
6186
6256
|
throw error;
|
|
@@ -6316,7 +6386,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6316
6386
|
const SEND_STATS_DELAY = 5000;
|
|
6317
6387
|
|
|
6318
6388
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6319
|
-
const logger$
|
|
6389
|
+
const logger$8 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6320
6390
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6321
6391
|
|
|
6322
6392
|
// events
|
|
@@ -6362,6 +6432,7 @@ const MAX_REGISTER_TRIES = 10;
|
|
|
6362
6432
|
|
|
6363
6433
|
|
|
6364
6434
|
|
|
6435
|
+
|
|
6365
6436
|
|
|
6366
6437
|
|
|
6367
6438
|
|
|
@@ -6388,6 +6459,7 @@ class WebRTCClient extends Emitter {
|
|
|
6388
6459
|
|
|
6389
6460
|
|
|
6390
6461
|
|
|
6462
|
+
|
|
6391
6463
|
|
|
6392
6464
|
// sugar
|
|
6393
6465
|
|
|
@@ -6426,6 +6498,8 @@ class WebRTCClient extends Emitter {
|
|
|
6426
6498
|
super();
|
|
6427
6499
|
this.uaConfigOverrides = uaConfigOverrides;
|
|
6428
6500
|
this.config = config;
|
|
6501
|
+
this.skipRegister = config.skipRegister;
|
|
6502
|
+
|
|
6429
6503
|
this._buildConfig(config, session).then((newConfig ) => {
|
|
6430
6504
|
this.config = newConfig;
|
|
6431
6505
|
this.userAgent = this.createUserAgent(uaConfigOverrides);
|
|
@@ -6481,13 +6555,13 @@ class WebRTCClient extends Emitter {
|
|
|
6481
6555
|
|
|
6482
6556
|
createUserAgent(configOverrides ) {
|
|
6483
6557
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6484
|
-
logger$
|
|
6558
|
+
logger$8.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6485
6559
|
|
|
6486
6560
|
webRTCConfiguration.delegate = {
|
|
6487
6561
|
onConnect: this.onConnect.bind(this),
|
|
6488
6562
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6489
6563
|
onInvite: (invitation ) => {
|
|
6490
|
-
logger$
|
|
6564
|
+
logger$8.info('sdk webrtc on invite', {
|
|
6491
6565
|
method: 'delegate.onInvite',
|
|
6492
6566
|
id: invitation.id,
|
|
6493
6567
|
remoteURI: invitation.remoteURI,
|
|
@@ -6530,7 +6604,7 @@ class WebRTCClient extends Emitter {
|
|
|
6530
6604
|
}
|
|
6531
6605
|
|
|
6532
6606
|
onConnect() {
|
|
6533
|
-
logger$
|
|
6607
|
+
logger$8.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6534
6608
|
this.eventEmitter.emit(CONNECTED);
|
|
6535
6609
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6536
6610
|
this.registerer.waitingToggle(false);
|
|
@@ -6539,7 +6613,7 @@ class WebRTCClient extends Emitter {
|
|
|
6539
6613
|
}
|
|
6540
6614
|
|
|
6541
6615
|
async onDisconnect(error ) {
|
|
6542
|
-
logger$
|
|
6616
|
+
logger$8.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6543
6617
|
this.connectionPromise = null;
|
|
6544
6618
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6545
6619
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6553,40 +6627,48 @@ class WebRTCClient extends Emitter {
|
|
|
6553
6627
|
}
|
|
6554
6628
|
|
|
6555
6629
|
register(tries = 0) {
|
|
6556
|
-
|
|
6630
|
+
const logInfo = {
|
|
6557
6631
|
userAgent: !!this.userAgent,
|
|
6558
6632
|
registered: this.isRegistered(),
|
|
6559
6633
|
connectionPromise: !!this.connectionPromise,
|
|
6560
6634
|
registerer: !!this.registerer,
|
|
6561
6635
|
waiting: this.registerer && this.registerer.waiting,
|
|
6562
6636
|
tries,
|
|
6563
|
-
|
|
6637
|
+
skipRegister: this.skipRegister,
|
|
6638
|
+
};
|
|
6639
|
+
|
|
6640
|
+
if (this.skipRegister) {
|
|
6641
|
+
logger$8.info('sdk webrtc skip register...', logInfo);
|
|
6642
|
+
return Promise.resolve();
|
|
6643
|
+
}
|
|
6644
|
+
|
|
6645
|
+
logger$8.info('sdk webrtc registering...', logInfo);
|
|
6564
6646
|
|
|
6565
6647
|
if (!this.userAgent) {
|
|
6566
|
-
logger$
|
|
6648
|
+
logger$8.info('sdk webrtc recreating User Agent');
|
|
6567
6649
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6568
6650
|
}
|
|
6569
6651
|
if (!this.userAgent || this.isRegistered()) {
|
|
6570
|
-
logger$
|
|
6652
|
+
logger$8.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6571
6653
|
return Promise.resolve();
|
|
6572
6654
|
}
|
|
6573
6655
|
|
|
6574
6656
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6575
|
-
logger$
|
|
6657
|
+
logger$8.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6576
6658
|
return Promise.resolve();
|
|
6577
6659
|
}
|
|
6578
6660
|
|
|
6579
6661
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6580
6662
|
|
|
6581
6663
|
const onRegisterFailed = () => {
|
|
6582
|
-
logger$
|
|
6664
|
+
logger$8.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6583
6665
|
this.connectionPromise = null;
|
|
6584
6666
|
if (this.registerer && this.registerer.waiting) {
|
|
6585
6667
|
this.registerer.waitingToggle(false);
|
|
6586
6668
|
}
|
|
6587
6669
|
|
|
6588
6670
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6589
|
-
logger$
|
|
6671
|
+
logger$8.info('sdk webrtc registering, retrying...', { tries });
|
|
6590
6672
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6591
6673
|
}
|
|
6592
6674
|
};
|
|
@@ -6595,18 +6677,18 @@ class WebRTCClient extends Emitter {
|
|
|
6595
6677
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6596
6678
|
// during the resolution of the primise.
|
|
6597
6679
|
if (!this.userAgent) {
|
|
6598
|
-
logger$
|
|
6680
|
+
logger$8.info('sdk webrtc recreating User Agent after connection');
|
|
6599
6681
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6600
6682
|
}
|
|
6601
6683
|
|
|
6602
|
-
logger$
|
|
6684
|
+
logger$8.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6603
6685
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
6604
6686
|
this.connectionPromise = null;
|
|
6605
6687
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6606
6688
|
|
|
6607
6689
|
// Bind registerer events
|
|
6608
6690
|
this.registerer.stateChange.addListener(newState => {
|
|
6609
|
-
logger$
|
|
6691
|
+
logger$8.info('sdk webrtc registering, state changed', { newState });
|
|
6610
6692
|
|
|
6611
6693
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
6612
6694
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -6619,7 +6701,7 @@ class WebRTCClient extends Emitter {
|
|
|
6619
6701
|
const options = {
|
|
6620
6702
|
requestDelegate: {
|
|
6621
6703
|
onReject: response => {
|
|
6622
|
-
logger$
|
|
6704
|
+
logger$8.error('sdk webrtc registering, rejected', { response });
|
|
6623
6705
|
|
|
6624
6706
|
onRegisterFailed();
|
|
6625
6707
|
},
|
|
@@ -6627,13 +6709,13 @@ class WebRTCClient extends Emitter {
|
|
|
6627
6709
|
};
|
|
6628
6710
|
|
|
6629
6711
|
return this.registerer.register(options).catch((e) => {
|
|
6630
|
-
logger$
|
|
6712
|
+
logger$8.error('sdk webrtc registering, error', e);
|
|
6631
6713
|
|
|
6632
6714
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6633
6715
|
return e;
|
|
6634
6716
|
});
|
|
6635
6717
|
}).catch(error => {
|
|
6636
|
-
logger$
|
|
6718
|
+
logger$8.error('sdk webrtc registering, transport error', error);
|
|
6637
6719
|
onRegisterFailed();
|
|
6638
6720
|
});
|
|
6639
6721
|
}
|
|
@@ -6662,21 +6744,21 @@ class WebRTCClient extends Emitter {
|
|
|
6662
6744
|
}
|
|
6663
6745
|
|
|
6664
6746
|
unregister() {
|
|
6665
|
-
logger$
|
|
6747
|
+
logger$8.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6666
6748
|
if (!this.registerer) {
|
|
6667
6749
|
return Promise.resolve();
|
|
6668
6750
|
}
|
|
6669
6751
|
|
|
6670
6752
|
try {
|
|
6671
6753
|
return this.registerer.unregister().then(() => {
|
|
6672
|
-
logger$
|
|
6754
|
+
logger$8.info('sdk webrtc unregistered');
|
|
6673
6755
|
this._cleanupRegister();
|
|
6674
6756
|
}).catch(e => {
|
|
6675
|
-
logger$
|
|
6757
|
+
logger$8.error('sdk webrtc unregistering, promise error', e);
|
|
6676
6758
|
this._cleanupRegister();
|
|
6677
6759
|
});
|
|
6678
6760
|
} catch (e) {
|
|
6679
|
-
logger$
|
|
6761
|
+
logger$8.error('sdk webrtc unregistering, error', e);
|
|
6680
6762
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6681
6763
|
// error when the registerer is in a bad state
|
|
6682
6764
|
this._cleanupRegister();
|
|
@@ -6684,7 +6766,7 @@ class WebRTCClient extends Emitter {
|
|
|
6684
6766
|
}
|
|
6685
6767
|
|
|
6686
6768
|
stop() {
|
|
6687
|
-
logger$
|
|
6769
|
+
logger$8.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6688
6770
|
if (!this.userAgent) {
|
|
6689
6771
|
return Promise.resolve();
|
|
6690
6772
|
}
|
|
@@ -6692,12 +6774,12 @@ class WebRTCClient extends Emitter {
|
|
|
6692
6774
|
return this.userAgent.stop().then(() => {
|
|
6693
6775
|
return this._cleanupRegister();
|
|
6694
6776
|
}).catch(e => {
|
|
6695
|
-
logger$
|
|
6777
|
+
logger$8.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6696
6778
|
});
|
|
6697
6779
|
}
|
|
6698
6780
|
|
|
6699
6781
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6700
|
-
logger$
|
|
6782
|
+
logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6701
6783
|
const inviterOptions = {
|
|
6702
6784
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6703
6785
|
conference,
|
|
@@ -6726,7 +6808,7 @@ class WebRTCClient extends Emitter {
|
|
|
6726
6808
|
this._onAccepted(session, response.session, true);
|
|
6727
6809
|
},
|
|
6728
6810
|
onReject: (response ) => {
|
|
6729
|
-
logger$
|
|
6811
|
+
logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6730
6812
|
this._stopSendingStats(session);
|
|
6731
6813
|
|
|
6732
6814
|
this.eventEmitter.emit(REJECTED, session, response);
|
|
@@ -6748,11 +6830,11 @@ class WebRTCClient extends Emitter {
|
|
|
6748
6830
|
}
|
|
6749
6831
|
|
|
6750
6832
|
answer(session , enableVideo ) {
|
|
6751
|
-
logger$
|
|
6833
|
+
logger$8.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6752
6834
|
|
|
6753
6835
|
if (!session || !session.accept) {
|
|
6754
6836
|
const error = 'No session to answer, or not an invitation';
|
|
6755
|
-
logger$
|
|
6837
|
+
logger$8.warn(error);
|
|
6756
6838
|
return Promise.reject(new Error(error));
|
|
6757
6839
|
}
|
|
6758
6840
|
const options = {
|
|
@@ -6762,15 +6844,15 @@ class WebRTCClient extends Emitter {
|
|
|
6762
6844
|
return session.accept(options).then(() => {
|
|
6763
6845
|
if (session.isCanceled) {
|
|
6764
6846
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
6765
|
-
logger$
|
|
6847
|
+
logger$8.error(message, { id: session.id });
|
|
6766
6848
|
this.onCallEnded(session);
|
|
6767
6849
|
|
|
6768
6850
|
throw new CanceledCallError(message);
|
|
6769
6851
|
}
|
|
6770
|
-
logger$
|
|
6852
|
+
logger$8.info('sdk webrtc answer, accepted.');
|
|
6771
6853
|
this._onAccepted(session);
|
|
6772
6854
|
}).catch(e => {
|
|
6773
|
-
logger$
|
|
6855
|
+
logger$8.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6774
6856
|
|
|
6775
6857
|
throw e;
|
|
6776
6858
|
});
|
|
@@ -6778,7 +6860,7 @@ class WebRTCClient extends Emitter {
|
|
|
6778
6860
|
|
|
6779
6861
|
hangup(session ) {
|
|
6780
6862
|
const { state, id } = session;
|
|
6781
|
-
logger$
|
|
6863
|
+
logger$8.info('sdk webrtc hangup call', { id, state });
|
|
6782
6864
|
|
|
6783
6865
|
try {
|
|
6784
6866
|
this._stopSendingStats(session);
|
|
@@ -6807,24 +6889,24 @@ class WebRTCClient extends Emitter {
|
|
|
6807
6889
|
|
|
6808
6890
|
return bye();
|
|
6809
6891
|
} catch (error) {
|
|
6810
|
-
logger$
|
|
6892
|
+
logger$8.warn('sdk webrtc hangup, error', error);
|
|
6811
6893
|
}
|
|
6812
6894
|
|
|
6813
6895
|
return null;
|
|
6814
6896
|
}
|
|
6815
6897
|
|
|
6816
6898
|
reject(session ) {
|
|
6817
|
-
logger$
|
|
6899
|
+
logger$8.info('sdk webrtc reject call', { id: session.id });
|
|
6818
6900
|
|
|
6819
6901
|
try {
|
|
6820
6902
|
return session.reject ? session.reject() : session.cancel();
|
|
6821
6903
|
} catch (e) {
|
|
6822
|
-
logger$
|
|
6904
|
+
logger$8.warn('Error when rejecting call', e.message, e.stack);
|
|
6823
6905
|
}
|
|
6824
6906
|
}
|
|
6825
6907
|
|
|
6826
6908
|
async close() {
|
|
6827
|
-
logger$
|
|
6909
|
+
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6828
6910
|
this._cleanupMedia();
|
|
6829
6911
|
this.connectionPromise = null;
|
|
6830
6912
|
|
|
@@ -6855,7 +6937,7 @@ class WebRTCClient extends Emitter {
|
|
|
6855
6937
|
// eg: "INVITE not rejectable in state Completed"
|
|
6856
6938
|
}
|
|
6857
6939
|
this.userAgent = null;
|
|
6858
|
-
logger$
|
|
6940
|
+
logger$8.info('sdk webrtc client closed');
|
|
6859
6941
|
}
|
|
6860
6942
|
|
|
6861
6943
|
getNumber(session ) {
|
|
@@ -6868,13 +6950,13 @@ class WebRTCClient extends Emitter {
|
|
|
6868
6950
|
}
|
|
6869
6951
|
|
|
6870
6952
|
mute(session ) {
|
|
6871
|
-
logger$
|
|
6953
|
+
logger$8.info('sdk webrtc mute', { id: session.id });
|
|
6872
6954
|
|
|
6873
6955
|
this._toggleAudio(session, true);
|
|
6874
6956
|
}
|
|
6875
6957
|
|
|
6876
6958
|
unmute(session ) {
|
|
6877
|
-
logger$
|
|
6959
|
+
logger$8.info('sdk webrtc unmute', { id: session.id });
|
|
6878
6960
|
|
|
6879
6961
|
this._toggleAudio(session, false);
|
|
6880
6962
|
}
|
|
@@ -6891,12 +6973,18 @@ class WebRTCClient extends Emitter {
|
|
|
6891
6973
|
}
|
|
6892
6974
|
|
|
6893
6975
|
if (pc.getSenders) {
|
|
6976
|
+
if (!pc.getSenders().length) {
|
|
6977
|
+
return false;
|
|
6978
|
+
}
|
|
6894
6979
|
pc.getSenders().forEach(sender => {
|
|
6895
6980
|
if (sender && sender.track && sender.track.kind === 'audio') {
|
|
6896
6981
|
muted = muted && !sender.track.enabled;
|
|
6897
6982
|
}
|
|
6898
6983
|
});
|
|
6899
6984
|
} else {
|
|
6985
|
+
if (!pc.getLocalStreams().length) {
|
|
6986
|
+
return false;
|
|
6987
|
+
}
|
|
6900
6988
|
pc.getLocalStreams().forEach(stream => {
|
|
6901
6989
|
stream.getAudioTracks().forEach(track => {
|
|
6902
6990
|
muted = muted && !track.enabled;
|
|
@@ -6908,20 +6996,20 @@ class WebRTCClient extends Emitter {
|
|
|
6908
6996
|
}
|
|
6909
6997
|
|
|
6910
6998
|
toggleCameraOn(session ) {
|
|
6911
|
-
logger$
|
|
6999
|
+
logger$8.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6912
7000
|
|
|
6913
7001
|
this._toggleVideo(session, false);
|
|
6914
7002
|
}
|
|
6915
7003
|
|
|
6916
7004
|
toggleCameraOff(session ) {
|
|
6917
|
-
logger$
|
|
7005
|
+
logger$8.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6918
7006
|
|
|
6919
7007
|
this._toggleVideo(session, true);
|
|
6920
7008
|
}
|
|
6921
7009
|
|
|
6922
7010
|
hold(session , isConference = false) {
|
|
6923
7011
|
const sessionId = this.getSipSessionId(session);
|
|
6924
|
-
logger$
|
|
7012
|
+
logger$8.info('sdk webrtc hold', {
|
|
6925
7013
|
sessionId,
|
|
6926
7014
|
keys: Object.keys(this.heldSessions),
|
|
6927
7015
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6955,6 +7043,8 @@ class WebRTCClient extends Emitter {
|
|
|
6955
7043
|
}
|
|
6956
7044
|
options.sessionDescriptionHandlerOptions = {
|
|
6957
7045
|
constraints: options.constraints,
|
|
7046
|
+
hold: true,
|
|
7047
|
+
conference: isConference,
|
|
6958
7048
|
};
|
|
6959
7049
|
|
|
6960
7050
|
// Send re-INVITE
|
|
@@ -6964,7 +7054,7 @@ class WebRTCClient extends Emitter {
|
|
|
6964
7054
|
unhold(session , isConference = false) {
|
|
6965
7055
|
const sessionId = this.getSipSessionId(session);
|
|
6966
7056
|
|
|
6967
|
-
logger$
|
|
7057
|
+
logger$8.info('sdk webrtc unhold', {
|
|
6968
7058
|
sessionId,
|
|
6969
7059
|
keys: Object.keys(this.heldSessions),
|
|
6970
7060
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6997,6 +7087,8 @@ class WebRTCClient extends Emitter {
|
|
|
6997
7087
|
}
|
|
6998
7088
|
options.sessionDescriptionHandlerOptions = {
|
|
6999
7089
|
constraints: options.constraints,
|
|
7090
|
+
hold: false,
|
|
7091
|
+
conference: isConference,
|
|
7000
7092
|
};
|
|
7001
7093
|
|
|
7002
7094
|
// Send re-INVITE
|
|
@@ -7055,7 +7147,7 @@ class WebRTCClient extends Emitter {
|
|
|
7055
7147
|
return;
|
|
7056
7148
|
}
|
|
7057
7149
|
|
|
7058
|
-
logger$
|
|
7150
|
+
logger$8.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7059
7151
|
|
|
7060
7152
|
try {
|
|
7061
7153
|
sipSession.message({
|
|
@@ -7180,7 +7272,8 @@ class WebRTCClient extends Emitter {
|
|
|
7180
7272
|
}
|
|
7181
7273
|
const sdh = session.sessionDescriptionHandler;
|
|
7182
7274
|
const pc = sdh.peerConnection;
|
|
7183
|
-
const
|
|
7275
|
+
const sessionId = this.getSipSessionId(session);
|
|
7276
|
+
const localStream = this.getLocalStream(sessionId);
|
|
7184
7277
|
|
|
7185
7278
|
// Release old video stream
|
|
7186
7279
|
if (localStream) {
|
|
@@ -7206,11 +7299,8 @@ class WebRTCClient extends Emitter {
|
|
|
7206
7299
|
|
|
7207
7300
|
// let's update the local stream
|
|
7208
7301
|
this.eventEmitter.emit('onVideoInputChange', stream);
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
} catch (_) {
|
|
7212
|
-
// Nothing to do
|
|
7213
|
-
}
|
|
7302
|
+
this.setLocalMediaStream(sessionId, stream);
|
|
7303
|
+
|
|
7214
7304
|
return stream;
|
|
7215
7305
|
});
|
|
7216
7306
|
}
|
|
@@ -7422,7 +7512,7 @@ class WebRTCClient extends Emitter {
|
|
|
7422
7512
|
}
|
|
7423
7513
|
|
|
7424
7514
|
startHeartbeat() {
|
|
7425
|
-
logger$
|
|
7515
|
+
logger$8.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7426
7516
|
if (!this.userAgent) {
|
|
7427
7517
|
this.heartbeat.stop();
|
|
7428
7518
|
return;
|
|
@@ -7435,7 +7525,7 @@ class WebRTCClient extends Emitter {
|
|
|
7435
7525
|
}
|
|
7436
7526
|
|
|
7437
7527
|
stopHeartbeat() {
|
|
7438
|
-
logger$
|
|
7528
|
+
logger$8.info('sdk webrtc stop heartbeat');
|
|
7439
7529
|
this.heartbeat.stop();
|
|
7440
7530
|
}
|
|
7441
7531
|
|
|
@@ -7455,7 +7545,7 @@ class WebRTCClient extends Emitter {
|
|
|
7455
7545
|
}
|
|
7456
7546
|
|
|
7457
7547
|
attemptReconnection() {
|
|
7458
|
-
logger$
|
|
7548
|
+
logger$8.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7459
7549
|
if (!this.userAgent) {
|
|
7460
7550
|
return;
|
|
7461
7551
|
}
|
|
@@ -7512,9 +7602,11 @@ class WebRTCClient extends Emitter {
|
|
|
7512
7602
|
remoteStream.removeTrack(track);
|
|
7513
7603
|
});
|
|
7514
7604
|
|
|
7515
|
-
pc.getReceivers
|
|
7516
|
-
|
|
7517
|
-
|
|
7605
|
+
if (pc.getReceivers) {
|
|
7606
|
+
pc.getReceivers().forEach(receiver => {
|
|
7607
|
+
remoteStream.addTrack(receiver.track);
|
|
7608
|
+
});
|
|
7609
|
+
}
|
|
7518
7610
|
}
|
|
7519
7611
|
|
|
7520
7612
|
getMediaConfiguration(enableVideo , conference = false, constraints = null) {
|
|
@@ -7549,6 +7641,25 @@ class WebRTCClient extends Emitter {
|
|
|
7549
7641
|
return sessionId in this.conferences;
|
|
7550
7642
|
}
|
|
7551
7643
|
|
|
7644
|
+
createAudioElementFor(sessionId ) {
|
|
7645
|
+
const audio = document.createElement('audio');
|
|
7646
|
+
audio.setAttribute('id', `audio-${sessionId}`);
|
|
7647
|
+
|
|
7648
|
+
if (audio.setSinkId && this.audioOutputDeviceId) {
|
|
7649
|
+
audio.setSinkId(this.audioOutputDeviceId);
|
|
7650
|
+
}
|
|
7651
|
+
|
|
7652
|
+
if (document.body) {
|
|
7653
|
+
document.body.appendChild(audio);
|
|
7654
|
+
}
|
|
7655
|
+
this.audioElements[sessionId] = audio;
|
|
7656
|
+
|
|
7657
|
+
audio.volume = this.audioOutputVolume;
|
|
7658
|
+
audio.autoplay = true;
|
|
7659
|
+
|
|
7660
|
+
return audio;
|
|
7661
|
+
}
|
|
7662
|
+
|
|
7552
7663
|
_onTransportError() {
|
|
7553
7664
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
7554
7665
|
this.attemptReconnection();
|
|
@@ -7558,7 +7669,7 @@ class WebRTCClient extends Emitter {
|
|
|
7558
7669
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
7559
7670
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
7560
7671
|
if (this.hasHeartbeat()) {
|
|
7561
|
-
logger$
|
|
7672
|
+
logger$8.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7562
7673
|
|
|
7563
7674
|
this.heartbeat.onHeartbeat();
|
|
7564
7675
|
if (this.heartbeatCb) {
|
|
@@ -7569,7 +7680,7 @@ class WebRTCClient extends Emitter {
|
|
|
7569
7680
|
}
|
|
7570
7681
|
|
|
7571
7682
|
async _onHeartbeatTimeout() {
|
|
7572
|
-
logger$
|
|
7683
|
+
logger$8.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7573
7684
|
|
|
7574
7685
|
if (this.heartbeatTimeoutCb) {
|
|
7575
7686
|
this.heartbeatTimeoutCb();
|
|
@@ -7581,7 +7692,7 @@ class WebRTCClient extends Emitter {
|
|
|
7581
7692
|
try {
|
|
7582
7693
|
await this.userAgent.transport.disconnect();
|
|
7583
7694
|
} catch (e) {
|
|
7584
|
-
logger$
|
|
7695
|
+
logger$8.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7585
7696
|
}
|
|
7586
7697
|
}
|
|
7587
7698
|
|
|
@@ -7614,31 +7725,31 @@ class WebRTCClient extends Emitter {
|
|
|
7614
7725
|
}
|
|
7615
7726
|
|
|
7616
7727
|
_connectIfNeeded() {
|
|
7617
|
-
logger$
|
|
7728
|
+
logger$8.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7618
7729
|
if (!this.userAgent) {
|
|
7619
|
-
logger$
|
|
7730
|
+
logger$8.info('need to recreate User Agent');
|
|
7620
7731
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
7621
7732
|
}
|
|
7622
7733
|
|
|
7623
7734
|
if (this.isConnected()) {
|
|
7624
|
-
logger$
|
|
7735
|
+
logger$8.info('webrtc sdk, already connected');
|
|
7625
7736
|
return Promise.resolve();
|
|
7626
7737
|
}
|
|
7627
7738
|
|
|
7628
7739
|
if (this.isConnecting()) {
|
|
7629
|
-
logger$
|
|
7740
|
+
logger$8.info('webrtc sdk, already connecting...');
|
|
7630
7741
|
|
|
7631
7742
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
7632
7743
|
return this.connectionPromise;
|
|
7633
7744
|
}
|
|
7634
7745
|
|
|
7635
7746
|
if (this.connectionPromise) {
|
|
7636
|
-
logger$
|
|
7747
|
+
logger$8.info('webrtc sdk, connection promise connecting...');
|
|
7637
7748
|
// $FlowFixMe
|
|
7638
7749
|
return this.connectionPromise;
|
|
7639
7750
|
}
|
|
7640
7751
|
|
|
7641
|
-
logger$
|
|
7752
|
+
logger$8.info('WebRTC UA needs to connect');
|
|
7642
7753
|
|
|
7643
7754
|
// Force UA to reconnect
|
|
7644
7755
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -7763,7 +7874,7 @@ class WebRTCClient extends Emitter {
|
|
|
7763
7874
|
|
|
7764
7875
|
sdh.peerConnectionDelegate = {
|
|
7765
7876
|
onicecandidateerror: (error ) => {
|
|
7766
|
-
logger$
|
|
7877
|
+
logger$8.error('on icecandidate error', {
|
|
7767
7878
|
address: error.address,
|
|
7768
7879
|
port: error.port,
|
|
7769
7880
|
errorCode: error.errorCode,
|
|
@@ -7778,7 +7889,7 @@ class WebRTCClient extends Emitter {
|
|
|
7778
7889
|
let hadRemoteVideo = false;
|
|
7779
7890
|
|
|
7780
7891
|
// Monkey patch `onInviteRequest` to be able to know if there was a remote video stream before `onInvite` is called
|
|
7781
|
-
//
|
|
7892
|
+
// Because when `onInvite` is called we already got the video track
|
|
7782
7893
|
session.onInviteRequest = (request) => {
|
|
7783
7894
|
hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
|
|
7784
7895
|
|
|
@@ -7792,7 +7903,7 @@ class WebRTCClient extends Emitter {
|
|
|
7792
7903
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
7793
7904
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
7794
7905
|
}
|
|
7795
|
-
logger$
|
|
7906
|
+
logger$8.info('re-invite received', { updatedCalleeName, updatedNumber });
|
|
7796
7907
|
|
|
7797
7908
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
7798
7909
|
|
|
@@ -7813,7 +7924,7 @@ class WebRTCClient extends Emitter {
|
|
|
7813
7924
|
}
|
|
7814
7925
|
|
|
7815
7926
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
7816
|
-
logger$
|
|
7927
|
+
logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7817
7928
|
|
|
7818
7929
|
this.storeSipSession(session);
|
|
7819
7930
|
|
|
@@ -7853,20 +7964,10 @@ class WebRTCClient extends Emitter {
|
|
|
7853
7964
|
const isConference = this.isConference(sessionId);
|
|
7854
7965
|
|
|
7855
7966
|
if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
|
|
7856
|
-
|
|
7857
|
-
audio.setAttribute('id', `audio-${sessionId}`);
|
|
7858
|
-
|
|
7859
|
-
if (audio.setSinkId && this.audioOutputDeviceId) {
|
|
7860
|
-
audio.setSinkId(this.audioOutputDeviceId);
|
|
7861
|
-
}
|
|
7862
|
-
|
|
7863
|
-
if (document.body) {
|
|
7864
|
-
document.body.appendChild(audio);
|
|
7865
|
-
}
|
|
7866
|
-
this.audioElements[sessionId] = audio;
|
|
7967
|
+
this.createAudioElementFor(sessionId);
|
|
7867
7968
|
}
|
|
7868
7969
|
|
|
7869
|
-
const audioElement = this.audioElements[
|
|
7970
|
+
const audioElement = this.audioElements[sessionId];
|
|
7870
7971
|
const stream = newStream || this.getRemoteStream(sessionId);
|
|
7871
7972
|
|
|
7872
7973
|
if (!this._isWeb() || !stream) {
|
|
@@ -8013,10 +8114,10 @@ class WebRTCClient extends Emitter {
|
|
|
8013
8114
|
|
|
8014
8115
|
_stopSendingStats(session ) {
|
|
8015
8116
|
const sessionId = this.getSipSessionId(session);
|
|
8016
|
-
logger$
|
|
8117
|
+
logger$8.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8017
8118
|
|
|
8018
8119
|
if (sessionId in this.statsIntervals) {
|
|
8019
|
-
logger$
|
|
8120
|
+
logger$8.trace('Stop sending stats for call', { sessionId });
|
|
8020
8121
|
this.statsIntervals[sessionId]();
|
|
8021
8122
|
delete this.statsIntervals[sessionId];
|
|
8022
8123
|
}
|
|
@@ -8032,7 +8133,7 @@ class WebRTCClient extends Emitter {
|
|
|
8032
8133
|
try {
|
|
8033
8134
|
await this.userAgent.transport.disconnect();
|
|
8034
8135
|
} catch (e) {
|
|
8035
|
-
logger$
|
|
8136
|
+
logger$8.error('WebRTC transport disconnect, error', e);
|
|
8036
8137
|
}
|
|
8037
8138
|
}
|
|
8038
8139
|
}
|
|
@@ -8119,7 +8220,7 @@ const events = [
|
|
|
8119
8220
|
ON_SIGNAL,
|
|
8120
8221
|
];
|
|
8121
8222
|
|
|
8122
|
-
const logger$
|
|
8223
|
+
const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
8123
8224
|
|
|
8124
8225
|
class WebRTCPhone extends Emitter {
|
|
8125
8226
|
|
|
@@ -8190,7 +8291,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8190
8291
|
}).catch(error => {
|
|
8191
8292
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
8192
8293
|
console.error('register error', error, error.message, error.stack);
|
|
8193
|
-
logger$
|
|
8294
|
+
logger$7.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
8194
8295
|
});
|
|
8195
8296
|
}
|
|
8196
8297
|
|
|
@@ -8205,7 +8306,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8205
8306
|
if (!this.client) {
|
|
8206
8307
|
return;
|
|
8207
8308
|
}
|
|
8208
|
-
logger$
|
|
8309
|
+
logger$7.info('WebRTC phone stop');
|
|
8209
8310
|
this.client.stop();
|
|
8210
8311
|
}
|
|
8211
8312
|
|
|
@@ -8220,14 +8321,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8220
8321
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
8221
8322
|
audioOnly = false) {
|
|
8222
8323
|
const sipSession = this.findSipSession(callSession);
|
|
8223
|
-
logger$
|
|
8324
|
+
logger$7.info('WebRTC phone - send reinvite', {
|
|
8224
8325
|
sessionId: sipSession ? sipSession.id : null,
|
|
8225
8326
|
constraints,
|
|
8226
8327
|
audioOnly,
|
|
8227
8328
|
});
|
|
8228
8329
|
|
|
8229
8330
|
if (!sipSession) {
|
|
8230
|
-
return
|
|
8331
|
+
return false;
|
|
8231
8332
|
}
|
|
8232
8333
|
|
|
8233
8334
|
// $FlowFixMe
|
|
@@ -8237,19 +8338,17 @@ class WebRTCPhone extends Emitter {
|
|
|
8237
8338
|
// Downgrade
|
|
8238
8339
|
if (constraints && !isUpgrade) {
|
|
8239
8340
|
// No reinvite needed
|
|
8240
|
-
|
|
8341
|
+
this._downgradeToAudio(callSession);
|
|
8342
|
+
return false;
|
|
8241
8343
|
}
|
|
8242
8344
|
|
|
8243
8345
|
if (isUpgrade) {
|
|
8244
8346
|
const shouldReinvite = await this._upgradeToVideo(callSession, constraints, conference);
|
|
8245
8347
|
if (!shouldReinvite) {
|
|
8246
|
-
return;
|
|
8348
|
+
return false;
|
|
8247
8349
|
}
|
|
8248
8350
|
}
|
|
8249
8351
|
|
|
8250
|
-
// Force reinvite in SDH
|
|
8251
|
-
sipSession.sessionDescriptionHandler.localMediaStreamConstraints = null;
|
|
8252
|
-
|
|
8253
8352
|
return this.client.reinvite(sipSession, constraints, conference, audioOnly);
|
|
8254
8353
|
}
|
|
8255
8354
|
|
|
@@ -8258,7 +8357,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8258
8357
|
}
|
|
8259
8358
|
|
|
8260
8359
|
startHeartbeat() {
|
|
8261
|
-
logger$
|
|
8360
|
+
logger$7.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
8262
8361
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
8263
8362
|
return;
|
|
8264
8363
|
}
|
|
@@ -8267,7 +8366,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8267
8366
|
}
|
|
8268
8367
|
|
|
8269
8368
|
stopHeartbeat() {
|
|
8270
|
-
logger$
|
|
8369
|
+
logger$7.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
8271
8370
|
if (!this.client) {
|
|
8272
8371
|
return;
|
|
8273
8372
|
}
|
|
@@ -8284,7 +8383,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8284
8383
|
}
|
|
8285
8384
|
|
|
8286
8385
|
reconnect() {
|
|
8287
|
-
logger$
|
|
8386
|
+
logger$7.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
8288
8387
|
if (!this.client) {
|
|
8289
8388
|
return;
|
|
8290
8389
|
}
|
|
@@ -8322,7 +8421,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8322
8421
|
_downgradeToAudio(callSession ) {
|
|
8323
8422
|
const sipSession = this.findSipSession(callSession);
|
|
8324
8423
|
if (!sipSession) {
|
|
8325
|
-
return;
|
|
8424
|
+
return false;
|
|
8326
8425
|
}
|
|
8327
8426
|
|
|
8328
8427
|
// Release local video stream when downgrading to audio
|
|
@@ -8435,7 +8534,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8435
8534
|
// Monkey patch to know when canceled with the CANCEL message
|
|
8436
8535
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
8437
8536
|
sipSession._onCancel = (message ) => {
|
|
8438
|
-
logger$
|
|
8537
|
+
logger$7.trace('on sip session canceled', { callId: message.callId });
|
|
8439
8538
|
|
|
8440
8539
|
onCancel(message);
|
|
8441
8540
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
@@ -8460,13 +8559,13 @@ class WebRTCPhone extends Emitter {
|
|
|
8460
8559
|
this.audioOutputVolume,
|
|
8461
8560
|
);
|
|
8462
8561
|
case sessionState.SessionState.Terminating:
|
|
8463
|
-
logger$
|
|
8562
|
+
logger$7.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
8464
8563
|
|
|
8465
8564
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
8466
8565
|
|
|
8467
8566
|
break;
|
|
8468
8567
|
case sessionState.SessionState.Terminated:
|
|
8469
|
-
logger$
|
|
8568
|
+
logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
8470
8569
|
|
|
8471
8570
|
this._onCallTerminated(sipSession);
|
|
8472
8571
|
|
|
@@ -8502,7 +8601,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8502
8601
|
}
|
|
8503
8602
|
|
|
8504
8603
|
async startScreenSharing(constraints , callSession ) {
|
|
8505
|
-
logger$
|
|
8604
|
+
logger$7.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
8506
8605
|
|
|
8507
8606
|
const screenShareStream = await this._getStreamFromConstraints(constraints);
|
|
8508
8607
|
if (!screenShareStream) {
|
|
@@ -8524,6 +8623,10 @@ class WebRTCPhone extends Emitter {
|
|
|
8524
8623
|
localStream.removeTrack(videoTrack);
|
|
8525
8624
|
}
|
|
8526
8625
|
|
|
8626
|
+
if (localStream) {
|
|
8627
|
+
localStream.addTrack(screenTrack);
|
|
8628
|
+
}
|
|
8629
|
+
|
|
8527
8630
|
if (sender) {
|
|
8528
8631
|
sender.replaceTrack(screenTrack);
|
|
8529
8632
|
}
|
|
@@ -8538,7 +8641,8 @@ class WebRTCPhone extends Emitter {
|
|
|
8538
8641
|
return;
|
|
8539
8642
|
}
|
|
8540
8643
|
|
|
8541
|
-
logger$
|
|
8644
|
+
logger$7.info('WebRTC phone - stop screen sharing');
|
|
8645
|
+
let reinvited = false;
|
|
8542
8646
|
|
|
8543
8647
|
try {
|
|
8544
8648
|
if (this.currentScreenShare.stream) {
|
|
@@ -8553,7 +8657,8 @@ class WebRTCPhone extends Emitter {
|
|
|
8553
8657
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
8554
8658
|
// We have to downgrade to audio.
|
|
8555
8659
|
const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
|
|
8556
|
-
|
|
8660
|
+
const constraints = { audio: false, video: screenshareStopped };
|
|
8661
|
+
reinvited = await this.sendReinvite(targetCallSession, constraints, conference);
|
|
8557
8662
|
}
|
|
8558
8663
|
} catch (e) {
|
|
8559
8664
|
console.warn(e);
|
|
@@ -8567,6 +8672,8 @@ class WebRTCPhone extends Emitter {
|
|
|
8567
8672
|
);
|
|
8568
8673
|
|
|
8569
8674
|
this.currentScreenShare = null;
|
|
8675
|
+
|
|
8676
|
+
return reinvited;
|
|
8570
8677
|
}
|
|
8571
8678
|
|
|
8572
8679
|
async _getStreamFromConstraints(constraints , conference = false) {
|
|
@@ -8604,7 +8711,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8604
8711
|
}
|
|
8605
8712
|
|
|
8606
8713
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
8607
|
-
logger$
|
|
8714
|
+
logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
8608
8715
|
|
|
8609
8716
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
8610
8717
|
this.currentSipSession = sipSession;
|
|
@@ -8622,11 +8729,15 @@ class WebRTCPhone extends Emitter {
|
|
|
8622
8729
|
}
|
|
8623
8730
|
|
|
8624
8731
|
changeAudioDevice(id ) {
|
|
8625
|
-
logger$
|
|
8732
|
+
logger$7.info('WebRTC phone - change audio device', { deviceId: id });
|
|
8626
8733
|
this.audioOutputDeviceId = id;
|
|
8627
8734
|
this.client.changeAudioOutputDevice(id);
|
|
8628
8735
|
}
|
|
8629
8736
|
|
|
8737
|
+
createAudioElementFor(sessionId ) {
|
|
8738
|
+
return this.client.createAudioElementFor(sessionId);
|
|
8739
|
+
}
|
|
8740
|
+
|
|
8630
8741
|
changeRingDevice(id ) {
|
|
8631
8742
|
this.audioRingDeviceId = id;
|
|
8632
8743
|
}
|
|
@@ -8643,25 +8754,25 @@ class WebRTCPhone extends Emitter {
|
|
|
8643
8754
|
}
|
|
8644
8755
|
|
|
8645
8756
|
changeAudioInputDevice(id ) {
|
|
8646
|
-
logger$
|
|
8757
|
+
logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
8647
8758
|
|
|
8648
8759
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
8649
8760
|
}
|
|
8650
8761
|
|
|
8651
8762
|
changeVideoInputDevice(id ) {
|
|
8652
|
-
logger$
|
|
8763
|
+
logger$7.info('WebRTC phone - change video input device', { deviceId: id });
|
|
8653
8764
|
|
|
8654
8765
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
8655
8766
|
}
|
|
8656
8767
|
|
|
8657
8768
|
changeSessionVideoInputDevice(id ) {
|
|
8658
|
-
logger$
|
|
8769
|
+
logger$7.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
8659
8770
|
|
|
8660
8771
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
8661
8772
|
}
|
|
8662
8773
|
|
|
8663
8774
|
_onCallTerminated(sipSession ) {
|
|
8664
|
-
logger$
|
|
8775
|
+
logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
8665
8776
|
|
|
8666
8777
|
const callSession = this._createCallSession(sipSession);
|
|
8667
8778
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -8695,7 +8806,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8695
8806
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
8696
8807
|
|
|
8697
8808
|
// Re-trigger incoming call event for remaining incoming calls
|
|
8698
|
-
logger$
|
|
8809
|
+
logger$7.info('WebRTC phone - check to re-trigger incoming call', {
|
|
8699
8810
|
sipId: sipSession.id,
|
|
8700
8811
|
shouldRetrigger,
|
|
8701
8812
|
hasIncomingCallSession,
|
|
@@ -8784,37 +8895,37 @@ class WebRTCPhone extends Emitter {
|
|
|
8784
8895
|
|
|
8785
8896
|
// Deprecated
|
|
8786
8897
|
getLocalStreamForCall(callSession ) {
|
|
8787
|
-
logger$
|
|
8898
|
+
logger$7.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
8788
8899
|
|
|
8789
8900
|
return this.getLocalStream(callSession);
|
|
8790
8901
|
}
|
|
8791
8902
|
|
|
8792
8903
|
// Deprecated
|
|
8793
8904
|
getRemoteStreamForCall(callSession ) {
|
|
8794
|
-
logger$
|
|
8905
|
+
logger$7.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
8795
8906
|
|
|
8796
8907
|
return this.getRemoteVideoStream(callSession);
|
|
8797
8908
|
}
|
|
8798
8909
|
|
|
8799
8910
|
getRemoteStreamsForCall(callSession ) {
|
|
8800
|
-
logger$
|
|
8911
|
+
logger$7.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
8801
8912
|
|
|
8802
8913
|
return this.getRemoteStream(callSession);
|
|
8803
8914
|
}
|
|
8804
8915
|
|
|
8805
8916
|
accept(callSession , cameraEnabled ) {
|
|
8806
|
-
logger$
|
|
8917
|
+
logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
8807
8918
|
if (this.currentSipSession) {
|
|
8808
8919
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
8809
8920
|
}
|
|
8810
8921
|
|
|
8811
8922
|
if (!callSession) {
|
|
8812
|
-
logger$
|
|
8923
|
+
logger$7.warn('no CallSession to accept.');
|
|
8813
8924
|
return Promise.resolve(null);
|
|
8814
8925
|
}
|
|
8815
8926
|
|
|
8816
8927
|
if (callSession.getId() in this.acceptedSessions) {
|
|
8817
|
-
logger$
|
|
8928
|
+
logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
8818
8929
|
return Promise.resolve(callSession.sipCallId);
|
|
8819
8930
|
}
|
|
8820
8931
|
|
|
@@ -8826,24 +8937,24 @@ class WebRTCPhone extends Emitter {
|
|
|
8826
8937
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
8827
8938
|
if (sipSession) {
|
|
8828
8939
|
if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
|
|
8829
|
-
logger$
|
|
8940
|
+
logger$7.warn('Trying to answer a terminated sipSession.');
|
|
8830
8941
|
|
|
8831
8942
|
return Promise.resolve(null);
|
|
8832
8943
|
}
|
|
8833
8944
|
|
|
8834
|
-
logger$
|
|
8945
|
+
logger$7.info('accept call, session found', { sipId: sipSession.id });
|
|
8835
8946
|
|
|
8836
8947
|
// $FlowFixMe
|
|
8837
8948
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
8838
8949
|
return callSession.sipCallId;
|
|
8839
8950
|
}).catch(e => {
|
|
8840
|
-
logger$
|
|
8951
|
+
logger$7.error(e);
|
|
8841
8952
|
this.endCurrentCall(callSession);
|
|
8842
8953
|
throw e;
|
|
8843
8954
|
});
|
|
8844
8955
|
}
|
|
8845
8956
|
|
|
8846
|
-
logger$
|
|
8957
|
+
logger$7.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
8847
8958
|
|
|
8848
8959
|
return Promise.resolve(null);
|
|
8849
8960
|
}
|
|
@@ -8853,7 +8964,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8853
8964
|
}
|
|
8854
8965
|
|
|
8855
8966
|
async reject(callSession ) {
|
|
8856
|
-
logger$
|
|
8967
|
+
logger$7.info('reject WebRTC called', { id: callSession.getId() });
|
|
8857
8968
|
|
|
8858
8969
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
8859
8970
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -8865,14 +8976,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8865
8976
|
|
|
8866
8977
|
const sipSession = this.findSipSession(callSession);
|
|
8867
8978
|
if (sipSession) {
|
|
8868
|
-
logger$
|
|
8979
|
+
logger$7.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
8869
8980
|
|
|
8870
8981
|
this.client.hangup(sipSession);
|
|
8871
8982
|
}
|
|
8872
8983
|
}
|
|
8873
8984
|
|
|
8874
8985
|
async ignore(callSession ) {
|
|
8875
|
-
logger$
|
|
8986
|
+
logger$7.info('WebRTC ignore', { id: callSession.getId() });
|
|
8876
8987
|
|
|
8877
8988
|
// kill the ring
|
|
8878
8989
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -8881,7 +8992,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8881
8992
|
}
|
|
8882
8993
|
|
|
8883
8994
|
hold(callSession , withEvent = true, isConference = false) {
|
|
8884
|
-
logger$
|
|
8995
|
+
logger$7.info('WebRTC hold', { id: callSession.getId() });
|
|
8885
8996
|
|
|
8886
8997
|
const sipSession = this.findSipSession(callSession);
|
|
8887
8998
|
|
|
@@ -8892,7 +9003,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8892
9003
|
|
|
8893
9004
|
// @Deprecated
|
|
8894
9005
|
unhold(callSession , withEvent = true, isConference = false) {
|
|
8895
|
-
logger$
|
|
9006
|
+
logger$7.info('WebRTC unhold', { id: callSession ? callSession.getId() : null });
|
|
8896
9007
|
|
|
8897
9008
|
console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
|
|
8898
9009
|
|
|
@@ -8907,7 +9018,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8907
9018
|
const sipSession = this.findSipSession(callSession);
|
|
8908
9019
|
|
|
8909
9020
|
if (sipSession) {
|
|
8910
|
-
logger$
|
|
9021
|
+
logger$7.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
8911
9022
|
|
|
8912
9023
|
return this.client.atxfer(sipSession);
|
|
8913
9024
|
}
|
|
@@ -8922,7 +9033,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8922
9033
|
if (!sipSession) {
|
|
8923
9034
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
8924
9035
|
}
|
|
8925
|
-
logger$
|
|
9036
|
+
logger$7.info('WebRTC hold sip session', { sipId: sipSession.id });
|
|
8926
9037
|
|
|
8927
9038
|
const promise = this.client.hold(sipSession, isConference);
|
|
8928
9039
|
if (withEvent) {
|
|
@@ -8941,7 +9052,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8941
9052
|
if (!sipSession) {
|
|
8942
9053
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
8943
9054
|
}
|
|
8944
|
-
logger$
|
|
9055
|
+
logger$7.info('WebRTC unhold', { sipId: sipSession.id });
|
|
8945
9056
|
|
|
8946
9057
|
const promise = this.client.unhold(sipSession, isConference);
|
|
8947
9058
|
if (withEvent) {
|
|
@@ -8952,18 +9063,18 @@ class WebRTCPhone extends Emitter {
|
|
|
8952
9063
|
}
|
|
8953
9064
|
|
|
8954
9065
|
resume(callSession , isConference = false) {
|
|
8955
|
-
logger$
|
|
9066
|
+
logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
8956
9067
|
|
|
8957
9068
|
const sipSession = this.findSipSession(callSession);
|
|
8958
9069
|
if (!sipSession) {
|
|
8959
9070
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
8960
9071
|
}
|
|
8961
9072
|
|
|
8962
|
-
logger$
|
|
9073
|
+
logger$7.info('WebRTC resuming', { sipId: sipSession.id });
|
|
8963
9074
|
|
|
8964
9075
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
8965
9076
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
8966
|
-
logger$
|
|
9077
|
+
logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
8967
9078
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
8968
9079
|
}
|
|
8969
9080
|
|
|
@@ -8978,14 +9089,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8978
9089
|
}
|
|
8979
9090
|
|
|
8980
9091
|
mute(callSession , withEvent = true) {
|
|
8981
|
-
logger$
|
|
9092
|
+
logger$7.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
8982
9093
|
|
|
8983
9094
|
const sipSession = this.findSipSession(callSession);
|
|
8984
9095
|
if (!sipSession) {
|
|
8985
9096
|
return;
|
|
8986
9097
|
}
|
|
8987
9098
|
|
|
8988
|
-
logger$
|
|
9099
|
+
logger$7.info('WebRTC muting', { sipId: sipSession.id });
|
|
8989
9100
|
this.client.mute(sipSession);
|
|
8990
9101
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
8991
9102
|
|
|
@@ -8999,14 +9110,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8999
9110
|
}
|
|
9000
9111
|
|
|
9001
9112
|
unmute(callSession , withEvent = true) {
|
|
9002
|
-
logger$
|
|
9113
|
+
logger$7.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
9003
9114
|
|
|
9004
9115
|
const sipSession = this.findSipSession(callSession);
|
|
9005
9116
|
if (!sipSession) {
|
|
9006
9117
|
return;
|
|
9007
9118
|
}
|
|
9008
9119
|
|
|
9009
|
-
logger$
|
|
9120
|
+
logger$7.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
9010
9121
|
this.client.unmute(sipSession);
|
|
9011
9122
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
9012
9123
|
|
|
@@ -9033,7 +9144,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9033
9144
|
if (!sipSession) {
|
|
9034
9145
|
return;
|
|
9035
9146
|
}
|
|
9036
|
-
logger$
|
|
9147
|
+
logger$7.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
9037
9148
|
|
|
9038
9149
|
this.client.toggleCameraOn(sipSession);
|
|
9039
9150
|
|
|
@@ -9045,7 +9156,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9045
9156
|
if (!sipSession) {
|
|
9046
9157
|
return;
|
|
9047
9158
|
}
|
|
9048
|
-
logger$
|
|
9159
|
+
logger$7.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
9049
9160
|
|
|
9050
9161
|
this.client.toggleCameraOff(sipSession);
|
|
9051
9162
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -9057,7 +9168,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9057
9168
|
return;
|
|
9058
9169
|
}
|
|
9059
9170
|
|
|
9060
|
-
logger$
|
|
9171
|
+
logger$7.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
9061
9172
|
this.client.sendDTMF(sipSession, tone);
|
|
9062
9173
|
}
|
|
9063
9174
|
|
|
@@ -9065,7 +9176,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9065
9176
|
// @TODO: line is not used here
|
|
9066
9177
|
async makeCall(number , line , cameraEnabled ,
|
|
9067
9178
|
audioOnly = false, conference = false) {
|
|
9068
|
-
logger$
|
|
9179
|
+
logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9069
9180
|
if (!number) {
|
|
9070
9181
|
return Promise.resolve(null);
|
|
9071
9182
|
}
|
|
@@ -9075,7 +9186,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9075
9186
|
}
|
|
9076
9187
|
if (this.currentSipSession) {
|
|
9077
9188
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
9078
|
-
logger$
|
|
9189
|
+
logger$7.warn('Unable to hold current session when making another call', e);
|
|
9079
9190
|
});
|
|
9080
9191
|
}
|
|
9081
9192
|
|
|
@@ -9085,7 +9196,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9085
9196
|
this._bindEvents(sipSession);
|
|
9086
9197
|
} catch (error) {
|
|
9087
9198
|
console.warn(error);
|
|
9088
|
-
logger$
|
|
9199
|
+
logger$7.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
9089
9200
|
return Promise.resolve(null);
|
|
9090
9201
|
}
|
|
9091
9202
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -9113,7 +9224,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9113
9224
|
return;
|
|
9114
9225
|
}
|
|
9115
9226
|
|
|
9116
|
-
logger$
|
|
9227
|
+
logger$7.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
9117
9228
|
|
|
9118
9229
|
this.client.transfer(sipSession, target);
|
|
9119
9230
|
}
|
|
@@ -9122,7 +9233,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9122
9233
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
9123
9234
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
9124
9235
|
|
|
9125
|
-
logger$
|
|
9236
|
+
logger$7.info('WebRTC indirect transfer', {
|
|
9126
9237
|
sipId: sipSession ? sipSession.id : null,
|
|
9127
9238
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
9128
9239
|
});
|
|
@@ -9150,7 +9261,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9150
9261
|
return false;
|
|
9151
9262
|
}
|
|
9152
9263
|
|
|
9153
|
-
logger$
|
|
9264
|
+
logger$7.info('WebRTC hangup', { sipId: sipSession.id });
|
|
9154
9265
|
|
|
9155
9266
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9156
9267
|
|
|
@@ -9195,7 +9306,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9195
9306
|
}
|
|
9196
9307
|
|
|
9197
9308
|
async close() {
|
|
9198
|
-
logger$
|
|
9309
|
+
logger$7.info('WebRTC close');
|
|
9199
9310
|
|
|
9200
9311
|
try {
|
|
9201
9312
|
await Promise.race([
|
|
@@ -9203,7 +9314,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9203
9314
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
9204
9315
|
]);
|
|
9205
9316
|
} catch (e) {
|
|
9206
|
-
logger$
|
|
9317
|
+
logger$7.error('WebRTC close, unregister error', e);
|
|
9207
9318
|
}
|
|
9208
9319
|
|
|
9209
9320
|
this.client.close();
|
|
@@ -9221,12 +9332,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9221
9332
|
}
|
|
9222
9333
|
|
|
9223
9334
|
enableRinging() {
|
|
9224
|
-
logger$
|
|
9335
|
+
logger$7.info('WebRTC enable ringing');
|
|
9225
9336
|
this.ringingEnabled = true;
|
|
9226
9337
|
}
|
|
9227
9338
|
|
|
9228
9339
|
disableRinging() {
|
|
9229
|
-
logger$
|
|
9340
|
+
logger$7.info('WebRTC disable ringing');
|
|
9230
9341
|
this.ringingEnabled = false;
|
|
9231
9342
|
}
|
|
9232
9343
|
|
|
@@ -9266,7 +9377,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9266
9377
|
|
|
9267
9378
|
// Deprecated
|
|
9268
9379
|
getLocalMediaStream(callSession ) {
|
|
9269
|
-
logger$
|
|
9380
|
+
logger$7.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9270
9381
|
return this.getLocalStream(callSession);
|
|
9271
9382
|
}
|
|
9272
9383
|
|
|
@@ -9274,6 +9385,10 @@ class WebRTCPhone extends Emitter {
|
|
|
9274
9385
|
return callSession ? this.client.hasLocalVideo(callSession.sipCallId) : null;
|
|
9275
9386
|
}
|
|
9276
9387
|
|
|
9388
|
+
hasALocalVideoTrack(callSession ) {
|
|
9389
|
+
return callSession ? this.client.hasALocalVideoTrack(callSession.sipCallId) : null;
|
|
9390
|
+
}
|
|
9391
|
+
|
|
9277
9392
|
getRemoteStream(callSession ) {
|
|
9278
9393
|
return callSession ? this.client.getRemoteStream(callSession.sipCallId) : null;
|
|
9279
9394
|
}
|
|
@@ -9296,7 +9411,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9296
9411
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
9297
9412
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
9298
9413
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
9299
|
-
logger$
|
|
9414
|
+
logger$7.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
9300
9415
|
|
|
9301
9416
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
9302
9417
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -9319,7 +9434,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9319
9434
|
});
|
|
9320
9435
|
|
|
9321
9436
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
9322
|
-
logger$
|
|
9437
|
+
logger$7.info('WebRTC on reinvite', {
|
|
9323
9438
|
sessionId: args[0].id,
|
|
9324
9439
|
inviteId: args[1].id,
|
|
9325
9440
|
updatedCalleeName: args[2],
|
|
@@ -9339,7 +9454,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9339
9454
|
});
|
|
9340
9455
|
|
|
9341
9456
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
9342
|
-
logger$
|
|
9457
|
+
logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
9343
9458
|
|
|
9344
9459
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
9345
9460
|
|
|
@@ -9350,17 +9465,17 @@ class WebRTCPhone extends Emitter {
|
|
|
9350
9465
|
this.client.on('ended', () => {});
|
|
9351
9466
|
|
|
9352
9467
|
this.client.on(this.client.ON_ERROR, e => {
|
|
9353
|
-
logger$
|
|
9468
|
+
logger$7.error('WebRTC error', e);
|
|
9354
9469
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
9355
9470
|
});
|
|
9356
9471
|
|
|
9357
9472
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
9358
|
-
logger$
|
|
9473
|
+
logger$7.info('WebRTC unregistered');
|
|
9359
9474
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9360
9475
|
});
|
|
9361
9476
|
|
|
9362
9477
|
this.client.on(this.client.REGISTERED, () => {
|
|
9363
|
-
logger$
|
|
9478
|
+
logger$7.info('WebRTC registered', {
|
|
9364
9479
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
9365
9480
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
9366
9481
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -9376,19 +9491,19 @@ class WebRTCPhone extends Emitter {
|
|
|
9376
9491
|
try {
|
|
9377
9492
|
this.sendReinvite(this.currentCallSession);
|
|
9378
9493
|
} catch (e) {
|
|
9379
|
-
logger$
|
|
9494
|
+
logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
9380
9495
|
}
|
|
9381
9496
|
}
|
|
9382
9497
|
});
|
|
9383
9498
|
|
|
9384
9499
|
this.client.on(this.client.CONNECTED, () => {
|
|
9385
|
-
logger$
|
|
9500
|
+
logger$7.info('WebRTC client connected');
|
|
9386
9501
|
|
|
9387
9502
|
this.stopHeartbeat();
|
|
9388
9503
|
});
|
|
9389
9504
|
|
|
9390
9505
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
9391
|
-
logger$
|
|
9506
|
+
logger$7.info('WebRTC client disconnected');
|
|
9392
9507
|
|
|
9393
9508
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9394
9509
|
|
|
@@ -9620,7 +9735,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
9620
9735
|
|
|
9621
9736
|
//
|
|
9622
9737
|
|
|
9623
|
-
const logger$
|
|
9738
|
+
const logger$6 = IssueReporter$1.loggerFor('simple-phone');
|
|
9624
9739
|
const sipLogger = IssueReporter$1.loggerFor('sip.js');
|
|
9625
9740
|
const protocolLogger = IssueReporter$1.loggerFor('sip');
|
|
9626
9741
|
|
|
@@ -9727,7 +9842,7 @@ class Phone extends Emitter {
|
|
|
9727
9842
|
async disconnect() {
|
|
9728
9843
|
if (this.phone) {
|
|
9729
9844
|
if (this.phone.hasAnActiveCall()) {
|
|
9730
|
-
logger$
|
|
9845
|
+
logger$6.info('hangup call on disconnect');
|
|
9731
9846
|
// $FlowFixMe
|
|
9732
9847
|
await this.phone.hangup();
|
|
9733
9848
|
}
|
|
@@ -9750,13 +9865,13 @@ class Phone extends Emitter {
|
|
|
9750
9865
|
}
|
|
9751
9866
|
|
|
9752
9867
|
async hangup(callSession ) {
|
|
9753
|
-
logger$
|
|
9868
|
+
logger$6.info('hangup via simple phone', { callId: callSession.getId() });
|
|
9754
9869
|
|
|
9755
9870
|
return this.phone && this.phone.hangup(callSession);
|
|
9756
9871
|
}
|
|
9757
9872
|
|
|
9758
9873
|
async accept(callSession , cameraEnabled ) {
|
|
9759
|
-
logger$
|
|
9874
|
+
logger$6.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
|
|
9760
9875
|
|
|
9761
9876
|
return this.phone && this.phone.accept(callSession, cameraEnabled);
|
|
9762
9877
|
}
|
|
@@ -9776,13 +9891,18 @@ class Phone extends Emitter {
|
|
|
9776
9891
|
return adHocConference.start();
|
|
9777
9892
|
}
|
|
9778
9893
|
|
|
9779
|
-
mute(callSession ) {
|
|
9780
|
-
|
|
9894
|
+
mute(callSession , withApi = true) {
|
|
9895
|
+
if (withApi) {
|
|
9896
|
+
this.muteViaAPI(callSession);
|
|
9897
|
+
}
|
|
9898
|
+
|
|
9781
9899
|
return this.phone && this.phone.mute(callSession);
|
|
9782
9900
|
}
|
|
9783
9901
|
|
|
9784
|
-
unmute(callSession ) {
|
|
9785
|
-
|
|
9902
|
+
unmute(callSession , withApi = true) {
|
|
9903
|
+
if (withApi) {
|
|
9904
|
+
this.unmuteViaAPI(callSession);
|
|
9905
|
+
}
|
|
9786
9906
|
|
|
9787
9907
|
return this.phone && this.phone.unmute(callSession);
|
|
9788
9908
|
}
|
|
@@ -9790,7 +9910,7 @@ class Phone extends Emitter {
|
|
|
9790
9910
|
muteViaAPI(callSession ) {
|
|
9791
9911
|
if (callSession && callSession.callId) {
|
|
9792
9912
|
Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
|
|
9793
|
-
logger$
|
|
9913
|
+
logger$6.error('Mute via API, error', e);
|
|
9794
9914
|
});
|
|
9795
9915
|
}
|
|
9796
9916
|
}
|
|
@@ -9798,7 +9918,7 @@ class Phone extends Emitter {
|
|
|
9798
9918
|
unmuteViaAPI(callSession ) {
|
|
9799
9919
|
if (callSession && callSession.callId) {
|
|
9800
9920
|
Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
|
|
9801
|
-
logger$
|
|
9921
|
+
logger$6.error('Unmute via API, error', e);
|
|
9802
9922
|
});
|
|
9803
9923
|
}
|
|
9804
9924
|
}
|
|
@@ -9888,9 +10008,13 @@ class Phone extends Emitter {
|
|
|
9888
10008
|
return this.phone && this.phone.hasLocalVideo(callSession);
|
|
9889
10009
|
}
|
|
9890
10010
|
|
|
10011
|
+
hasALocalVideoTrack(callSession ) {
|
|
10012
|
+
return this.phone && this.phone.hasALocalVideoTrack(callSession);
|
|
10013
|
+
}
|
|
10014
|
+
|
|
9891
10015
|
// @Deprecated
|
|
9892
10016
|
getLocalMediaStream(callSession ) {
|
|
9893
|
-
logger$
|
|
10017
|
+
logger$6.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
9894
10018
|
|
|
9895
10019
|
return this.phone && this.phone.getLocalStream(callSession);
|
|
9896
10020
|
}
|
|
@@ -9909,20 +10033,20 @@ class Phone extends Emitter {
|
|
|
9909
10033
|
|
|
9910
10034
|
// @Deprecated
|
|
9911
10035
|
getRemoteStreamForCall(callSession ) {
|
|
9912
|
-
logger$
|
|
10036
|
+
logger$6.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
9913
10037
|
return this.getRemoteStream(callSession);
|
|
9914
10038
|
}
|
|
9915
10039
|
|
|
9916
10040
|
// Returns remote streams directly from the peerConnection
|
|
9917
10041
|
// @Deprecated
|
|
9918
10042
|
getRemoteStreamsForCall(callSession ) {
|
|
9919
|
-
logger$
|
|
10043
|
+
logger$6.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
9920
10044
|
return this.getLocalStream(callSession);
|
|
9921
10045
|
}
|
|
9922
10046
|
|
|
9923
10047
|
// @Deprecated
|
|
9924
10048
|
getRemoteVideoStreamForCall(callSession ) {
|
|
9925
|
-
logger$
|
|
10049
|
+
logger$6.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
9926
10050
|
|
|
9927
10051
|
return this.getRemoteVideoStream(callSession);
|
|
9928
10052
|
}
|
|
@@ -10052,6 +10176,8 @@ const CONFERENCE_USER_PARTICIPANT_JOINED = 'conference_user_participant_joined';
|
|
|
10052
10176
|
const CONFERENCE_USER_PARTICIPANT_LEFT = 'conference_user_participant_left';
|
|
10053
10177
|
const CONFERENCE_USER_PARTICIPANT_TALK_STARTED = 'conference_user_participant_talk_started';
|
|
10054
10178
|
const CONFERENCE_USER_PARTICIPANT_TALK_STOPPED = 'conference_user_participant_talk_stopped';
|
|
10179
|
+
const MEETING_USER_PARTICIPANT_JOINED = 'meeting_user_participant_joined';
|
|
10180
|
+
const MEETING_USER_PARTICIPANT_LEFT = 'meeting_user_participant_left';
|
|
10055
10181
|
const SWITCHBOARD_QUEUED_CALLS_UPDATED = 'switchboard_queued_calls_updated';
|
|
10056
10182
|
const SWITCHBOARD_QUEUED_CALL_ANSWERED = 'switchboard_queued_call_answered';
|
|
10057
10183
|
const SWITCHBOARD_HELD_CALLS_UPDATED = 'switchboard_held_calls_updated';
|
|
@@ -10093,7 +10219,7 @@ const BLACKLIST_EVENTS = [
|
|
|
10093
10219
|
];
|
|
10094
10220
|
|
|
10095
10221
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
10096
|
-
const logger$
|
|
10222
|
+
const logger$5 = IssueReporter$1.loggerFor('wazo-ws');
|
|
10097
10223
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
10098
10224
|
|
|
10099
10225
|
class WebSocketClient extends Emitter {
|
|
@@ -10142,19 +10268,19 @@ class WebSocketClient extends Emitter {
|
|
|
10142
10268
|
}
|
|
10143
10269
|
|
|
10144
10270
|
connect() {
|
|
10145
|
-
logger$
|
|
10271
|
+
logger$5.info('connect method started', { host: this.host, token: this.token });
|
|
10146
10272
|
this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
|
|
10147
10273
|
if (this.options.binaryType) {
|
|
10148
10274
|
this.socket.binaryType = this.options.binaryType;
|
|
10149
10275
|
}
|
|
10150
10276
|
|
|
10151
10277
|
this.socket.onopen = () => {
|
|
10152
|
-
logger$
|
|
10278
|
+
logger$5.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
10153
10279
|
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
|
|
10154
10280
|
};
|
|
10155
10281
|
|
|
10156
10282
|
this.socket.onerror = event => {
|
|
10157
|
-
logger$
|
|
10283
|
+
logger$5.error('on Wazo WS error', event.target);
|
|
10158
10284
|
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
|
|
10159
10285
|
};
|
|
10160
10286
|
|
|
@@ -10184,7 +10310,7 @@ class WebSocketClient extends Emitter {
|
|
|
10184
10310
|
|
|
10185
10311
|
this.socket.onclose = event => {
|
|
10186
10312
|
// Can't be converted to JSON (circular structure)
|
|
10187
|
-
logger$
|
|
10313
|
+
logger$5.info('on Wazo WS close', {
|
|
10188
10314
|
reason: event.reason,
|
|
10189
10315
|
code: event.code,
|
|
10190
10316
|
readyState: event.target.readyState,
|
|
@@ -10202,12 +10328,12 @@ class WebSocketClient extends Emitter {
|
|
|
10202
10328
|
};
|
|
10203
10329
|
|
|
10204
10330
|
this.socket.onerror = event => {
|
|
10205
|
-
logger$
|
|
10331
|
+
logger$5.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
10206
10332
|
};
|
|
10207
10333
|
}
|
|
10208
10334
|
|
|
10209
10335
|
close(force = false) {
|
|
10210
|
-
logger$
|
|
10336
|
+
logger$5.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
10211
10337
|
|
|
10212
10338
|
if (!this.socket) {
|
|
10213
10339
|
return;
|
|
@@ -10225,7 +10351,7 @@ class WebSocketClient extends Emitter {
|
|
|
10225
10351
|
|
|
10226
10352
|
updateToken(token ) {
|
|
10227
10353
|
this.token = token;
|
|
10228
|
-
logger$
|
|
10354
|
+
logger$5.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
10229
10355
|
|
|
10230
10356
|
if (this.socket) {
|
|
10231
10357
|
// If still connected, send the token to the WS
|
|
@@ -10243,7 +10369,7 @@ class WebSocketClient extends Emitter {
|
|
|
10243
10369
|
}
|
|
10244
10370
|
|
|
10245
10371
|
startHeartbeat() {
|
|
10246
|
-
logger$
|
|
10372
|
+
logger$5.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
10247
10373
|
|
|
10248
10374
|
if (!this.socket) {
|
|
10249
10375
|
this.heartbeat.stop();
|
|
@@ -10257,7 +10383,7 @@ class WebSocketClient extends Emitter {
|
|
|
10257
10383
|
}
|
|
10258
10384
|
|
|
10259
10385
|
stopHeartbeat() {
|
|
10260
|
-
logger$
|
|
10386
|
+
logger$5.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
10261
10387
|
|
|
10262
10388
|
this.heartbeat.stop();
|
|
10263
10389
|
}
|
|
@@ -10287,7 +10413,7 @@ class WebSocketClient extends Emitter {
|
|
|
10287
10413
|
}
|
|
10288
10414
|
|
|
10289
10415
|
reconnect(reason ) {
|
|
10290
|
-
logger$
|
|
10416
|
+
logger$5.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
10291
10417
|
if (!this.socket) {
|
|
10292
10418
|
return;
|
|
10293
10419
|
}
|
|
@@ -10343,7 +10469,7 @@ class WebSocketClient extends Emitter {
|
|
|
10343
10469
|
this.close();
|
|
10344
10470
|
}
|
|
10345
10471
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
10346
|
-
logger$
|
|
10472
|
+
logger$5.log('Wazo WS url computed to reconnect', { url });
|
|
10347
10473
|
|
|
10348
10474
|
return url;
|
|
10349
10475
|
}
|
|
@@ -10351,12 +10477,12 @@ class WebSocketClient extends Emitter {
|
|
|
10351
10477
|
_onHeartbeat(message ) {
|
|
10352
10478
|
if (message.payload === 'pong') {
|
|
10353
10479
|
this.heartbeat.onHeartbeat();
|
|
10354
|
-
logger$
|
|
10480
|
+
logger$5.log('on heartbeat received from Wazo WS');
|
|
10355
10481
|
}
|
|
10356
10482
|
}
|
|
10357
10483
|
|
|
10358
10484
|
async _onHeartbeatTimeout() {
|
|
10359
|
-
logger$
|
|
10485
|
+
logger$5.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
10360
10486
|
|
|
10361
10487
|
this.close();
|
|
10362
10488
|
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
@@ -10398,6 +10524,8 @@ WebSocketClient.eventLists = [
|
|
|
10398
10524
|
CHATD_USER_ROOM_CREATED,
|
|
10399
10525
|
CONFERENCE_USER_PARTICIPANT_JOINED,
|
|
10400
10526
|
CONFERENCE_USER_PARTICIPANT_LEFT,
|
|
10527
|
+
MEETING_USER_PARTICIPANT_JOINED,
|
|
10528
|
+
MEETING_USER_PARTICIPANT_LEFT,
|
|
10401
10529
|
CONFERENCE_USER_PARTICIPANT_TALK_STARTED,
|
|
10402
10530
|
CONFERENCE_USER_PARTICIPANT_TALK_STOPPED,
|
|
10403
10531
|
SWITCHBOARD_QUEUED_CALLS_UPDATED,
|
|
@@ -10468,6 +10596,8 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
10468
10596
|
CONFERENCE_USER_PARTICIPANT_LEFT: CONFERENCE_USER_PARTICIPANT_LEFT,
|
|
10469
10597
|
CONFERENCE_USER_PARTICIPANT_TALK_STARTED: CONFERENCE_USER_PARTICIPANT_TALK_STARTED,
|
|
10470
10598
|
CONFERENCE_USER_PARTICIPANT_TALK_STOPPED: CONFERENCE_USER_PARTICIPANT_TALK_STOPPED,
|
|
10599
|
+
MEETING_USER_PARTICIPANT_JOINED: MEETING_USER_PARTICIPANT_JOINED,
|
|
10600
|
+
MEETING_USER_PARTICIPANT_LEFT: MEETING_USER_PARTICIPANT_LEFT,
|
|
10471
10601
|
SWITCHBOARD_QUEUED_CALLS_UPDATED: SWITCHBOARD_QUEUED_CALLS_UPDATED,
|
|
10472
10602
|
SWITCHBOARD_QUEUED_CALL_ANSWERED: SWITCHBOARD_QUEUED_CALL_ANSWERED,
|
|
10473
10603
|
SWITCHBOARD_HELD_CALLS_UPDATED: SWITCHBOARD_HELD_CALLS_UPDATED,
|
|
@@ -10509,7 +10639,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
10509
10639
|
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
10510
10640
|
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
10511
10641
|
|
|
10512
|
-
const logger$
|
|
10642
|
+
const logger$4 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
10513
10643
|
|
|
10514
10644
|
class Websocket extends Emitter {
|
|
10515
10645
|
|
|
@@ -10533,7 +10663,7 @@ class Websocket extends Emitter {
|
|
|
10533
10663
|
}
|
|
10534
10664
|
|
|
10535
10665
|
open(host , session ) {
|
|
10536
|
-
logger$
|
|
10666
|
+
logger$4.info('open simple WebSocket', { host, token: session.token });
|
|
10537
10667
|
this.ws = new WebSocketClient(
|
|
10538
10668
|
{
|
|
10539
10669
|
host,
|
|
@@ -10561,7 +10691,7 @@ class Websocket extends Emitter {
|
|
|
10561
10691
|
}
|
|
10562
10692
|
|
|
10563
10693
|
updateToken(token ) {
|
|
10564
|
-
logger$
|
|
10694
|
+
logger$4.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
10565
10695
|
|
|
10566
10696
|
if (!this.ws) {
|
|
10567
10697
|
return;
|
|
@@ -10589,6 +10719,145 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
10589
10719
|
|
|
10590
10720
|
//
|
|
10591
10721
|
|
|
10722
|
+
const logger$3 = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
10723
|
+
|
|
10724
|
+
class SipRoom extends Room {
|
|
10725
|
+
|
|
10726
|
+
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
10727
|
+
logger$3.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
10728
|
+
|
|
10729
|
+
if (!room) {
|
|
10730
|
+
await Wazo.Phone.connect();
|
|
10731
|
+
|
|
10732
|
+
const withCamera = constraints && !!constraints.video;
|
|
10733
|
+
|
|
10734
|
+
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
10735
|
+
// eslint-disable-next-line no-param-reassign
|
|
10736
|
+
room = new SipRoom(callSession, extension, null, null, extra);
|
|
10737
|
+
}
|
|
10738
|
+
|
|
10739
|
+
if (room && room.callSession && room.callSession.call) {
|
|
10740
|
+
room.setCallId(room.callSession.call.id);
|
|
10741
|
+
}
|
|
10742
|
+
|
|
10743
|
+
logger$3.info('connected to room', {
|
|
10744
|
+
extension: room.extension,
|
|
10745
|
+
});
|
|
10746
|
+
|
|
10747
|
+
return room;
|
|
10748
|
+
}
|
|
10749
|
+
|
|
10750
|
+
mute() {
|
|
10751
|
+
logger$3.info('mute sip room');
|
|
10752
|
+
|
|
10753
|
+
Wazo.Phone.mute(this.callSession, false);
|
|
10754
|
+
|
|
10755
|
+
this.sendMuteStatus();
|
|
10756
|
+
}
|
|
10757
|
+
|
|
10758
|
+
unmute() {
|
|
10759
|
+
logger$3.info('unmute sip room');
|
|
10760
|
+
|
|
10761
|
+
Wazo.Phone.unmute(this.callSession, false);
|
|
10762
|
+
|
|
10763
|
+
this.sendUnMuteStatus();
|
|
10764
|
+
}
|
|
10765
|
+
|
|
10766
|
+
getLocalGuestName() {
|
|
10767
|
+
return Wazo.Phone.phone.client.userAgent.options.displayName;
|
|
10768
|
+
}
|
|
10769
|
+
|
|
10770
|
+
// Overridden to not listen to websocket messages
|
|
10771
|
+
_transferEvents() {
|
|
10772
|
+
// Phone events
|
|
10773
|
+
Wazo.Phone.on(this.ON_MESSAGE, this._boundOnMessage);
|
|
10774
|
+
Wazo.Phone.on(this.ON_CHAT, this._boundOnChat);
|
|
10775
|
+
Wazo.Phone.on(this.ON_SIGNAL, this._boundOnSignal);
|
|
10776
|
+
Wazo.Phone.on(this.ON_VIDEO_INPUT_CHANGE, this._boundSaveLocalVideoStream);
|
|
10777
|
+
|
|
10778
|
+
[this.ON_AUDIO_STREAM, this.ON_VIDEO_STREAM, this.ON_REMOVE_STREAM].forEach(event =>
|
|
10779
|
+
Wazo.Phone.on(event, (...args) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
|
|
10780
|
+
}
|
|
10781
|
+
|
|
10782
|
+
_onMessage(message ) {
|
|
10783
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
10784
|
+
const body = super._onMessage(message);
|
|
10785
|
+
if (!body) {
|
|
10786
|
+
return;
|
|
10787
|
+
}
|
|
10788
|
+
|
|
10789
|
+
const getChannel = () => body.channels[0];
|
|
10790
|
+
|
|
10791
|
+
switch (body.type) {
|
|
10792
|
+
case 'ConfbridgeWelcome':
|
|
10793
|
+
body.channels.forEach(channel => {
|
|
10794
|
+
this._onParticipantJoined(channel);
|
|
10795
|
+
});
|
|
10796
|
+
|
|
10797
|
+
break;
|
|
10798
|
+
case 'ConfbridgeJoin': {
|
|
10799
|
+
const channel = getChannel();
|
|
10800
|
+
this._onParticipantJoined(channel);
|
|
10801
|
+
break;
|
|
10802
|
+
}
|
|
10803
|
+
case 'ConfbridgeLeave': {
|
|
10804
|
+
const channel = getChannel();
|
|
10805
|
+
this._onParticipantLeft({
|
|
10806
|
+
data: {
|
|
10807
|
+
call_id: channel.id,
|
|
10808
|
+
},
|
|
10809
|
+
});
|
|
10810
|
+
break;
|
|
10811
|
+
}
|
|
10812
|
+
}
|
|
10813
|
+
}
|
|
10814
|
+
|
|
10815
|
+
async _onParticipantJoined(channel ) {
|
|
10816
|
+
const isLocal = channel.channelvars.WAZO_SIP_CALL_ID === this._getCurrentSipCallIs();
|
|
10817
|
+
const callId = channel.id;
|
|
10818
|
+
const ParticipantClass = isLocal ? Wazo.LocalParticipant : Wazo.RemoteParticipant;
|
|
10819
|
+
const name = channel.caller ? channel.caller.name : null;
|
|
10820
|
+
const extra = isLocal ? { guestName: this.getLocalGuestName() } : {};
|
|
10821
|
+
const participant = new ParticipantClass(this, {
|
|
10822
|
+
caller_id_name: name,
|
|
10823
|
+
call_id: callId,
|
|
10824
|
+
}, extra);
|
|
10825
|
+
|
|
10826
|
+
const participantIdx = this.participants.findIndex(other => other.callId === participant.callId);
|
|
10827
|
+
if (participantIdx !== -1 && name) {
|
|
10828
|
+
this.participants[participantIdx].name = name;
|
|
10829
|
+
return;
|
|
10830
|
+
}
|
|
10831
|
+
|
|
10832
|
+
if (isLocal) {
|
|
10833
|
+
// Should be updated by the Wazo WS but we don't have it for now
|
|
10834
|
+
if (this.callSession) {
|
|
10835
|
+
this.callSession.ringing = false;
|
|
10836
|
+
}
|
|
10837
|
+
|
|
10838
|
+
this._onLocalParticipantJoined(participant);
|
|
10839
|
+
|
|
10840
|
+
// Give some time for the stream to be updated
|
|
10841
|
+
setTimeout(() => {
|
|
10842
|
+
this.eventEmitter.emit(this.ON_JOINED, participant, this.participants);
|
|
10843
|
+
}, 1000);
|
|
10844
|
+
}
|
|
10845
|
+
|
|
10846
|
+
this.participants.push(participant);
|
|
10847
|
+
|
|
10848
|
+
this._isParticipantJoining(participant);
|
|
10849
|
+
|
|
10850
|
+
return participant;
|
|
10851
|
+
}
|
|
10852
|
+
|
|
10853
|
+
_getCurrentSipCallIs() {
|
|
10854
|
+
return Wazo.Phone.getSipSessionId(Wazo.Phone.phone.currentSipSession);
|
|
10855
|
+
}
|
|
10856
|
+
|
|
10857
|
+
}
|
|
10858
|
+
|
|
10859
|
+
//
|
|
10860
|
+
|
|
10592
10861
|
class RemoteParticipant extends Participant {
|
|
10593
10862
|
constructor(room , rawParticipant = {}, extra = {}) {
|
|
10594
10863
|
super(room, rawParticipant, extra);
|
|
@@ -10648,9 +10917,7 @@ class Stream {
|
|
|
10648
10917
|
return false;
|
|
10649
10918
|
}
|
|
10650
10919
|
|
|
10651
|
-
|
|
10652
|
-
return this.htmlStream.getTracks().find(track => track.kind === 'video'
|
|
10653
|
-
&& track.readyState !== 'ended' && 'width' in track.getSettings());
|
|
10920
|
+
return this.htmlStream.getTracks().some(track => track.kind === 'video' && track.readyState !== 'ended');
|
|
10654
10921
|
}
|
|
10655
10922
|
|
|
10656
10923
|
get id() {
|
|
@@ -11551,6 +11818,7 @@ const Wazo = {
|
|
|
11551
11818
|
Phone: Phone$1,
|
|
11552
11819
|
Websocket: Websocket$1,
|
|
11553
11820
|
Room,
|
|
11821
|
+
SipRoom,
|
|
11554
11822
|
RemoteParticipant,
|
|
11555
11823
|
LocalParticipant,
|
|
11556
11824
|
Stream,
|
|
@@ -11587,6 +11855,7 @@ const Wazo = {
|
|
|
11587
11855
|
IndirectTransfer,
|
|
11588
11856
|
SwitchboardCall,
|
|
11589
11857
|
WebRTCPhone,
|
|
11858
|
+
Meeting,
|
|
11590
11859
|
},
|
|
11591
11860
|
|
|
11592
11861
|
// Api
|
|
@@ -11615,7 +11884,7 @@ if (global) {
|
|
|
11615
11884
|
global.Wazo = Wazo;
|
|
11616
11885
|
}
|
|
11617
11886
|
|
|
11618
|
-
|
|
11887
|
+
//
|
|
11619
11888
|
|
|
11620
11889
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
11621
11890
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
@@ -11627,6 +11896,7 @@ class Room extends Emitter {
|
|
|
11627
11896
|
|
|
11628
11897
|
|
|
11629
11898
|
|
|
11899
|
+
|
|
11630
11900
|
|
|
11631
11901
|
|
|
11632
11902
|
|
|
@@ -11648,6 +11918,8 @@ class Room extends Emitter {
|
|
|
11648
11918
|
|
|
11649
11919
|
|
|
11650
11920
|
|
|
11921
|
+
|
|
11922
|
+
|
|
11651
11923
|
|
|
11652
11924
|
|
|
11653
11925
|
|
|
@@ -11665,6 +11937,7 @@ class Room extends Emitter {
|
|
|
11665
11937
|
* @param extension string
|
|
11666
11938
|
* @param sourceId number
|
|
11667
11939
|
* @param callId string
|
|
11940
|
+
* @param meetingUuid string
|
|
11668
11941
|
* @param extra Object
|
|
11669
11942
|
*/
|
|
11670
11943
|
constructor(
|
|
@@ -11672,15 +11945,17 @@ class Room extends Emitter {
|
|
|
11672
11945
|
extension ,
|
|
11673
11946
|
sourceId ,
|
|
11674
11947
|
callId ,
|
|
11948
|
+
meetingUuid ,
|
|
11675
11949
|
extra = {},
|
|
11676
11950
|
) {
|
|
11677
11951
|
super();
|
|
11678
|
-
logger$1.info('room initialized', { callId, extension, sourceId });
|
|
11952
|
+
logger$1.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
11679
11953
|
|
|
11680
11954
|
// Represents the room callSession
|
|
11681
11955
|
this.callSession = callSession;
|
|
11682
11956
|
this.extension = extension;
|
|
11683
11957
|
this.sourceId = sourceId;
|
|
11958
|
+
this.meetingUuid = meetingUuid;
|
|
11684
11959
|
this.callId = callId;
|
|
11685
11960
|
this.participants = [];
|
|
11686
11961
|
this.connected = false;
|
|
@@ -11700,6 +11975,8 @@ class Room extends Emitter {
|
|
|
11700
11975
|
// Sugar syntax for `room.EVENT_NAME`
|
|
11701
11976
|
this.CONFERENCE_USER_PARTICIPANT_JOINED = Wazo.Websocket.CONFERENCE_USER_PARTICIPANT_JOINED;
|
|
11702
11977
|
this.CONFERENCE_USER_PARTICIPANT_LEFT = Wazo.Websocket.CONFERENCE_USER_PARTICIPANT_LEFT;
|
|
11978
|
+
this.MEETING_USER_PARTICIPANT_JOINED = Wazo.Websocket.MEETING_USER_PARTICIPANT_JOINED;
|
|
11979
|
+
this.MEETING_USER_PARTICIPANT_LEFT = Wazo.Websocket.MEETING_USER_PARTICIPANT_LEFT;
|
|
11703
11980
|
this.ON_SHARE_SCREEN_ENDED = Wazo.Phone.ON_SHARE_SCREEN_ENDED;
|
|
11704
11981
|
this.ON_MESSAGE = Wazo.Phone.ON_MESSAGE;
|
|
11705
11982
|
this.ON_CHAT = Wazo.Phone.ON_CHAT;
|
|
@@ -11734,9 +12011,10 @@ class Room extends Emitter {
|
|
|
11734
12011
|
* @param audioOnly boolean
|
|
11735
12012
|
* @param extra Object
|
|
11736
12013
|
* @param room ?Room
|
|
12014
|
+
* @param meeting ?Meeting
|
|
11737
12015
|
* @returns {Promise<Room>}
|
|
11738
12016
|
*/
|
|
11739
|
-
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
12017
|
+
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
11740
12018
|
logger$1.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
11741
12019
|
|
|
11742
12020
|
if (!room) {
|
|
@@ -11771,21 +12049,31 @@ class Room extends Emitter {
|
|
|
11771
12049
|
room.setCallId(room.callSession.call.id);
|
|
11772
12050
|
}
|
|
11773
12051
|
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
|
|
11779
|
-
|
|
12052
|
+
if (!meeting) {
|
|
12053
|
+
// Fetch conference source
|
|
12054
|
+
const sources = await getApiClient().dird.fetchConferenceSource('default');
|
|
12055
|
+
// Retrieve conference sources
|
|
12056
|
+
const contacts = await getApiClient().dird.fetchConferenceContacts(sources.items[0]);
|
|
12057
|
+
// Retrieve conference
|
|
12058
|
+
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
11780
12059
|
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
|
|
12060
|
+
logger$1.info('connected to room', {
|
|
12061
|
+
sourceId: conference ? conference.sourceId : null,
|
|
12062
|
+
name: conference ? conference.name : null,
|
|
12063
|
+
});
|
|
11785
12064
|
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
|
|
12065
|
+
if (conference) {
|
|
12066
|
+
room.setSourceId(conference.sourceId);
|
|
12067
|
+
room.setName(conference.name);
|
|
12068
|
+
}
|
|
12069
|
+
} else if (meeting) {
|
|
12070
|
+
logger$1.info('Already connected to meeting', {
|
|
12071
|
+
uuid: meeting.uuid,
|
|
12072
|
+
name: meeting.name,
|
|
12073
|
+
});
|
|
12074
|
+
|
|
12075
|
+
room.setMeetingUuid(meeting.uuid);
|
|
12076
|
+
room.setName(meeting.name);
|
|
11789
12077
|
}
|
|
11790
12078
|
|
|
11791
12079
|
return room;
|
|
@@ -11813,10 +12101,8 @@ class Room extends Emitter {
|
|
|
11813
12101
|
Wazo.Phone.phone.off(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
11814
12102
|
Wazo.Websocket.off(this.CONFERENCE_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
|
|
11815
12103
|
Wazo.Websocket.off(this.CONFERENCE_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
|
|
11816
|
-
|
|
11817
|
-
|
|
11818
|
-
document.body.removeChild(this.roomAudioElement);
|
|
11819
|
-
}
|
|
12104
|
+
Wazo.Websocket.off(this.MEETING_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
|
|
12105
|
+
Wazo.Websocket.off(this.MEETING_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
|
|
11820
12106
|
}
|
|
11821
12107
|
|
|
11822
12108
|
setSourceId(sourceId ) {
|
|
@@ -11825,6 +12111,12 @@ class Room extends Emitter {
|
|
|
11825
12111
|
this.sourceId = sourceId;
|
|
11826
12112
|
}
|
|
11827
12113
|
|
|
12114
|
+
setMeetingUuid(meetingUuid ) {
|
|
12115
|
+
logger$1.info('set meeting uuid', { meetingUuid });
|
|
12116
|
+
|
|
12117
|
+
this.meetingUuid = meetingUuid;
|
|
12118
|
+
}
|
|
12119
|
+
|
|
11828
12120
|
setCallId(callId ) {
|
|
11829
12121
|
logger$1.info('set room call id', { callId });
|
|
11830
12122
|
|
|
@@ -11866,14 +12158,22 @@ class Room extends Emitter {
|
|
|
11866
12158
|
return screensharingStream;
|
|
11867
12159
|
}
|
|
11868
12160
|
|
|
11869
|
-
stopScreenSharing(restoreLocalStream = true) {
|
|
12161
|
+
async stopScreenSharing(restoreLocalStream = true) {
|
|
11870
12162
|
logger$1.info('stop room screen sharing');
|
|
11871
12163
|
|
|
11872
|
-
Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
12164
|
+
const reinvited = await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
11873
12165
|
|
|
11874
12166
|
if (this.localParticipant) {
|
|
11875
12167
|
this.localParticipant.onStopScreensharing();
|
|
11876
12168
|
}
|
|
12169
|
+
|
|
12170
|
+
if (!reinvited && this.localParticipant) {
|
|
12171
|
+
// When we had video and we made a screenshare we don't reinvite when stopping the screensahre
|
|
12172
|
+
// So not REINVITE even is fired, we have to restore the video stream manually
|
|
12173
|
+
const localVideoStream = Wazo.Phone.getLocalVideoStream(this.callSession);
|
|
12174
|
+
// $FlowFixMe
|
|
12175
|
+
this._associateStreamTo(localVideoStream, this.localParticipant);
|
|
12176
|
+
}
|
|
11877
12177
|
}
|
|
11878
12178
|
|
|
11879
12179
|
turnCameraOff() {
|
|
@@ -11976,6 +12276,22 @@ class Room extends Emitter {
|
|
|
11976
12276
|
return response;
|
|
11977
12277
|
}
|
|
11978
12278
|
|
|
12279
|
+
hasALocalVideoTrack() {
|
|
12280
|
+
return Wazo.Phone.hasALocalVideoTrack(this.callSession);
|
|
12281
|
+
}
|
|
12282
|
+
|
|
12283
|
+
getLocalStream() {
|
|
12284
|
+
return Wazo.Phone.getLocalStream(this.callSession);
|
|
12285
|
+
}
|
|
12286
|
+
|
|
12287
|
+
getRemoteStream() {
|
|
12288
|
+
return Wazo.Phone.getRemoteStream(this.callSession);
|
|
12289
|
+
}
|
|
12290
|
+
|
|
12291
|
+
getRemoteVideoStream() {
|
|
12292
|
+
return Wazo.Phone.getRemoteVideoStream(this.callSession);
|
|
12293
|
+
}
|
|
12294
|
+
|
|
11979
12295
|
_bindEvents() {
|
|
11980
12296
|
if (!Wazo.Phone.phone || !Wazo.Phone.phone.currentSipSession) {
|
|
11981
12297
|
return;
|
|
@@ -11997,27 +12313,10 @@ class Room extends Emitter {
|
|
|
11997
12313
|
logger$1.info('on room audio stream');
|
|
11998
12314
|
|
|
11999
12315
|
this.audioStream = stream;
|
|
12000
|
-
if (
|
|
12001
|
-
|
|
12002
|
-
|
|
12003
|
-
if (!this.roomAudioElement) {
|
|
12004
|
-
roomAudioElement = document.createElement('audio');
|
|
12005
|
-
// $FlowFixMe
|
|
12006
|
-
document.body.appendChild(roomAudioElement);
|
|
12007
|
-
}
|
|
12008
|
-
if (!roomAudioElement) {
|
|
12009
|
-
return;
|
|
12010
|
-
}
|
|
12011
|
-
this.roomAudioElement = roomAudioElement;
|
|
12316
|
+
if (!this.roomAudioElement) {
|
|
12317
|
+
const sessionId = Wazo.Phone.phone.getSipSessionId(Wazo.Phone.phone.currentSipSession);
|
|
12318
|
+
this.roomAudioElement = Wazo.Phone.phone.createAudioElementFor(sessionId);
|
|
12012
12319
|
this.roomAudioElement.srcObject = stream;
|
|
12013
|
-
this.roomAudioElement.autoplay = true;
|
|
12014
|
-
this.roomAudioElement.id = 'audio-room';
|
|
12015
|
-
|
|
12016
|
-
// $FlowFixMe
|
|
12017
|
-
if (this.roomAudioElement.setSinkId) {
|
|
12018
|
-
// $FlowFixMe
|
|
12019
|
-
this.roomAudioElement.setSinkId(Wazo.Phone.getOutputDevice());
|
|
12020
|
-
}
|
|
12021
12320
|
}
|
|
12022
12321
|
});
|
|
12023
12322
|
|
|
@@ -12092,6 +12391,9 @@ class Room extends Emitter {
|
|
|
12092
12391
|
Wazo.Websocket.on(this.CONFERENCE_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
|
|
12093
12392
|
Wazo.Websocket.on(this.CONFERENCE_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
|
|
12094
12393
|
|
|
12394
|
+
Wazo.Websocket.on(this.MEETING_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
|
|
12395
|
+
Wazo.Websocket.on(this.MEETING_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
|
|
12396
|
+
|
|
12095
12397
|
// Phone events
|
|
12096
12398
|
Wazo.Phone.on(this.ON_MESSAGE, this._boundOnMessage);
|
|
12097
12399
|
Wazo.Phone.on(this.ON_CHAT, this._boundOnChat);
|
|
@@ -12102,15 +12404,15 @@ class Room extends Emitter {
|
|
|
12102
12404
|
Wazo.Phone.on(event, (...args) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
|
|
12103
12405
|
}
|
|
12104
12406
|
|
|
12105
|
-
_onMessage(message )
|
|
12407
|
+
_onMessage(message ) {
|
|
12106
12408
|
if (message.method !== 'MESSAGE') {
|
|
12107
|
-
return;
|
|
12409
|
+
return null;
|
|
12108
12410
|
}
|
|
12109
12411
|
let body;
|
|
12110
12412
|
try {
|
|
12111
12413
|
body = JSON.parse(message.body);
|
|
12112
12414
|
} catch (e) {
|
|
12113
|
-
return;
|
|
12415
|
+
return null;
|
|
12114
12416
|
}
|
|
12115
12417
|
|
|
12116
12418
|
switch (body.type) {
|
|
@@ -12129,6 +12431,8 @@ class Room extends Emitter {
|
|
|
12129
12431
|
}
|
|
12130
12432
|
|
|
12131
12433
|
this.eventEmitter.emit(this.ON_MESSAGE, body);
|
|
12434
|
+
|
|
12435
|
+
return body;
|
|
12132
12436
|
}
|
|
12133
12437
|
|
|
12134
12438
|
_onChat(content ) {
|
|
@@ -12193,23 +12497,24 @@ class Room extends Emitter {
|
|
|
12193
12497
|
const session = Wazo.Auth.getSession();
|
|
12194
12498
|
let participants = [];
|
|
12195
12499
|
|
|
12196
|
-
// @TODO: we could use a better function name here
|
|
12197
|
-
const isJoining = part => {
|
|
12198
|
-
this.__associateStreams(part);
|
|
12199
|
-
// @VALIDATE: no need to publicize ourselves, no?
|
|
12200
|
-
if (part instanceof RemoteParticipant) {
|
|
12201
|
-
this.eventEmitter.emit(this.CONFERENCE_USER_PARTICIPANT_JOINED, part);
|
|
12202
|
-
}
|
|
12203
|
-
};
|
|
12204
|
-
|
|
12205
12500
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
12206
12501
|
if (participant.user_uuid === session.uuid) {
|
|
12207
12502
|
logger$1.info('room current user joined');
|
|
12208
12503
|
|
|
12209
12504
|
// Retrieve participants via an API calls
|
|
12210
12505
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
12211
|
-
|
|
12212
|
-
|
|
12506
|
+
let response;
|
|
12507
|
+
try {
|
|
12508
|
+
if (this.meetingUuid) {
|
|
12509
|
+
logger$1.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
12510
|
+
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
12511
|
+
} else {
|
|
12512
|
+
logger$1.info('fetching conference participants', { conferenceId });
|
|
12513
|
+
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
12514
|
+
}
|
|
12515
|
+
} catch (e) {
|
|
12516
|
+
logger$1.error('room participants fetching, error', e);
|
|
12517
|
+
}
|
|
12213
12518
|
if (response) {
|
|
12214
12519
|
logger$1.info('conference participants fetched', { nb: response.items.length });
|
|
12215
12520
|
participants = response.items.map(item => {
|
|
@@ -12224,25 +12529,10 @@ class Room extends Emitter {
|
|
|
12224
12529
|
|
|
12225
12530
|
const localParticipant = participants.find(someParticipant => someParticipant instanceof Wazo.LocalParticipant);
|
|
12226
12531
|
if (!this.localParticipant && localParticipant) {
|
|
12227
|
-
this.localParticipant
|
|
12228
|
-
|
|
12229
|
-
const localVideoStream = this._getLocalVideoStream();
|
|
12230
|
-
if (localVideoStream) {
|
|
12231
|
-
this._saveLocalVideoStream(localVideoStream);
|
|
12232
|
-
}
|
|
12233
|
-
|
|
12234
|
-
this.connected = true;
|
|
12235
|
-
|
|
12236
|
-
// we're in the room, now let's request everyone's status
|
|
12237
|
-
if (this.localParticipant) {
|
|
12238
|
-
this.sendSignal({
|
|
12239
|
-
type: SIGNAL_TYPE_PARTICIPANT_REQUEST,
|
|
12240
|
-
origin: this.localParticipant.getStatus(),
|
|
12241
|
-
});
|
|
12242
|
-
}
|
|
12532
|
+
this._onLocalParticipantJoined(localParticipant);
|
|
12243
12533
|
}
|
|
12244
12534
|
|
|
12245
|
-
participants.forEach(someParticipant =>
|
|
12535
|
+
participants.forEach(someParticipant => this._isParticipantJoining(someParticipant));
|
|
12246
12536
|
this.eventEmitter.emit(this.ON_JOINED, localParticipant, participants);
|
|
12247
12537
|
}
|
|
12248
12538
|
|
|
@@ -12257,12 +12547,41 @@ class Room extends Emitter {
|
|
|
12257
12547
|
|
|
12258
12548
|
if (remoteParticipant) {
|
|
12259
12549
|
this.participants.push(remoteParticipant);
|
|
12260
|
-
|
|
12550
|
+
this._isParticipantJoining(remoteParticipant);
|
|
12261
12551
|
}
|
|
12262
12552
|
|
|
12263
12553
|
return remoteParticipant;
|
|
12264
12554
|
}
|
|
12265
12555
|
|
|
12556
|
+
_onLocalParticipantJoined(localParticipant ) {
|
|
12557
|
+
this.localParticipant = localParticipant;
|
|
12558
|
+
|
|
12559
|
+
const localVideoStream = this._getLocalVideoStream();
|
|
12560
|
+
if (localVideoStream) {
|
|
12561
|
+
this._saveLocalVideoStream(localVideoStream);
|
|
12562
|
+
}
|
|
12563
|
+
|
|
12564
|
+
this.connected = true;
|
|
12565
|
+
|
|
12566
|
+
localParticipant.broadcastStatus();
|
|
12567
|
+
|
|
12568
|
+
// we're in the room, now let's request everyone's status
|
|
12569
|
+
if (this.localParticipant) {
|
|
12570
|
+
this.sendSignal({
|
|
12571
|
+
type: SIGNAL_TYPE_PARTICIPANT_REQUEST,
|
|
12572
|
+
origin: this.localParticipant.getStatus(),
|
|
12573
|
+
});
|
|
12574
|
+
}
|
|
12575
|
+
}
|
|
12576
|
+
|
|
12577
|
+
_isParticipantJoining(participant ) {
|
|
12578
|
+
this.__associateStreams(participant);
|
|
12579
|
+
// @VALIDATE: no need to publicize ourselves, no?
|
|
12580
|
+
if (participant instanceof RemoteParticipant) {
|
|
12581
|
+
this.eventEmitter.emit(this.CONFERENCE_USER_PARTICIPANT_JOINED, participant);
|
|
12582
|
+
}
|
|
12583
|
+
}
|
|
12584
|
+
|
|
12266
12585
|
_saveLocalVideoStream(stream ) {
|
|
12267
12586
|
const { localParticipant } = this;
|
|
12268
12587
|
|
|
@@ -12308,9 +12627,11 @@ class Room extends Emitter {
|
|
|
12308
12627
|
_onParticipantTrackUpdate(oldParticipant , update ) {
|
|
12309
12628
|
const newParticipant = oldParticipant;
|
|
12310
12629
|
|
|
12311
|
-
const { trackId } = this._callIdStreamIdMap[newParticipant.callId] || {};
|
|
12630
|
+
const { trackId, streamId } = this._callIdStreamIdMap[newParticipant.callId] || {};
|
|
12312
12631
|
const pc = Wazo.Phone.phone.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
12313
|
-
|
|
12632
|
+
// Can't use `getReceivers` here because on FF we make the mapping based on the streamId
|
|
12633
|
+
const stream = pc.getRemoteStreams().find(someStream =>
|
|
12634
|
+
someStream.id === streamId || someStream.getTracks().some(track => track.id === trackId));
|
|
12314
12635
|
|
|
12315
12636
|
if (update === 'downgrade') {
|
|
12316
12637
|
newParticipant.streams = [];
|
|
@@ -12340,15 +12661,42 @@ class Room extends Emitter {
|
|
|
12340
12661
|
return;
|
|
12341
12662
|
}
|
|
12342
12663
|
|
|
12343
|
-
|
|
12664
|
+
const streamId = this._getStreamIdFrTrackId(trackId);
|
|
12665
|
+
const key = this._getUnassociatedMapIdFromTrackIdOrStreamId(trackId, streamId);
|
|
12666
|
+
const stream = this._unassociatedVideoStreams[key];
|
|
12667
|
+
|
|
12668
|
+
if (stream) {
|
|
12344
12669
|
// Try to associate stream
|
|
12345
|
-
this._associateStreamTo(
|
|
12670
|
+
this._associateStreamTo(stream, participant);
|
|
12346
12671
|
|
|
12347
|
-
delete this._unassociatedVideoStreams[
|
|
12672
|
+
delete this._unassociatedVideoStreams[key];
|
|
12348
12673
|
delete this._unassociatedParticipants[participant.callId];
|
|
12349
12674
|
}
|
|
12350
12675
|
}
|
|
12351
12676
|
|
|
12677
|
+
_getUnassociatedMapIdFromTrackIdOrStreamId(trackId , streamId ) {
|
|
12678
|
+
// Find by trackId
|
|
12679
|
+
if (trackId in this._unassociatedVideoStreams) {
|
|
12680
|
+
return trackId;
|
|
12681
|
+
}
|
|
12682
|
+
|
|
12683
|
+
// Find by streamId
|
|
12684
|
+
if (streamId && streamId in this._unassociatedVideoStreams) {
|
|
12685
|
+
return streamId;
|
|
12686
|
+
}
|
|
12687
|
+
|
|
12688
|
+
// Find in all the streams by streamId (used on FF where we can't map by trackId)
|
|
12689
|
+
const idx = Object.values(this._unassociatedVideoStreams).findIndex((stream ) =>
|
|
12690
|
+
stream && stream.id === streamId);
|
|
12691
|
+
return idx === -1 ? null : Object.keys(this._unassociatedVideoStreams)[idx];
|
|
12692
|
+
}
|
|
12693
|
+
|
|
12694
|
+
_getStreamIdFrTrackId(trackId ) {
|
|
12695
|
+
const mapping = Object.values(this._callIdStreamIdMap).find((map ) => map.trackId === trackId);
|
|
12696
|
+
|
|
12697
|
+
return mapping ? mapping.streamId : null;
|
|
12698
|
+
}
|
|
12699
|
+
|
|
12352
12700
|
_associateStreamTo(rawStream , participant ) {
|
|
12353
12701
|
const stream = new Wazo.Stream(rawStream, participant);
|
|
12354
12702
|
participant.streams.push(stream);
|
|
@@ -12406,6 +12754,7 @@ class Participant extends Emitter {
|
|
|
12406
12754
|
|
|
12407
12755
|
|
|
12408
12756
|
/**
|
|
12757
|
+
* @param room Room The room where the participant is
|
|
12409
12758
|
* @param rawParticipant string Participant sent via the Wazo WS
|
|
12410
12759
|
* @param extra Object extra status of the participant
|
|
12411
12760
|
*/
|
|
@@ -12633,6 +12982,11 @@ class Participant extends Emitter {
|
|
|
12633
12982
|
// Poor man's object comparison
|
|
12634
12983
|
if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
|
|
12635
12984
|
this.extra = { ...this.extra, ...status.extra };
|
|
12985
|
+
|
|
12986
|
+
if (this.extra.contact && !(this.extra.contact instanceof Contact)) {
|
|
12987
|
+
this.extra.contact = new Contact(this.extra.contact);
|
|
12988
|
+
}
|
|
12989
|
+
|
|
12636
12990
|
this.triggerUpdate(this.ON_EXTRA_CHANGE, broadcast);
|
|
12637
12991
|
}
|
|
12638
12992
|
}
|