@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
package/esm/simple/Auth.js
CHANGED
|
@@ -1838,7 +1838,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
1838
1838
|
|
|
1839
1839
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
1840
1840
|
|
|
1841
|
-
const logger$
|
|
1841
|
+
const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
1842
1842
|
|
|
1843
1843
|
// Use a function here to be able to mock it in tests
|
|
1844
1844
|
const realFetch = () => {
|
|
@@ -1977,7 +1977,7 @@ class ApiRequester {
|
|
|
1977
1977
|
};
|
|
1978
1978
|
|
|
1979
1979
|
if (this.refreshTokenPromise) {
|
|
1980
|
-
logger$
|
|
1980
|
+
logger$c.info('A token is already refreshing, waiting ...', { url });
|
|
1981
1981
|
await this.refreshTokenPromise;
|
|
1982
1982
|
}
|
|
1983
1983
|
|
|
@@ -1997,7 +1997,7 @@ class ApiRequester {
|
|
|
1997
1997
|
return promise.then(async (err ) => {
|
|
1998
1998
|
// Check if the token is still valid
|
|
1999
1999
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
2000
|
-
logger$
|
|
2000
|
+
logger$c.warn('token expired', { error: err.reason });
|
|
2001
2001
|
// Replay the call after refreshing the token
|
|
2002
2002
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
2003
2003
|
}
|
|
@@ -2007,7 +2007,7 @@ class ApiRequester {
|
|
|
2007
2007
|
: exceptionClass.fromResponse(err, response.status);
|
|
2008
2008
|
|
|
2009
2009
|
if (this.shouldLogErrors) {
|
|
2010
|
-
logger$
|
|
2010
|
+
logger$c.error('API error', error);
|
|
2011
2011
|
}
|
|
2012
2012
|
|
|
2013
2013
|
throw error;
|
|
@@ -2017,7 +2017,7 @@ class ApiRequester {
|
|
|
2017
2017
|
return newParse(response, isJson);
|
|
2018
2018
|
}).catch(error => {
|
|
2019
2019
|
if (this.shouldLogErrors) {
|
|
2020
|
-
logger$
|
|
2020
|
+
logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
2021
2021
|
}
|
|
2022
2022
|
|
|
2023
2023
|
throw error;
|
|
@@ -2045,13 +2045,13 @@ class ApiRequester {
|
|
|
2045
2045
|
) {
|
|
2046
2046
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
2047
2047
|
let newPath = path;
|
|
2048
|
-
logger$
|
|
2048
|
+
logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
2049
2049
|
|
|
2050
2050
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
2051
2051
|
|
|
2052
2052
|
return this.refreshTokenPromise.then(() => {
|
|
2053
2053
|
this.refreshTokenPromise = null;
|
|
2054
|
-
logger$
|
|
2054
|
+
logger$c.info('token refreshed', { isTokenNotFound });
|
|
2055
2055
|
if (isTokenNotFound) {
|
|
2056
2056
|
const pathParts = path.split('/');
|
|
2057
2057
|
pathParts.pop();
|
|
@@ -2512,6 +2512,65 @@ class ExternalApp {
|
|
|
2512
2512
|
}
|
|
2513
2513
|
}
|
|
2514
2514
|
|
|
2515
|
+
//
|
|
2516
|
+
|
|
2517
|
+
|
|
2518
|
+
|
|
2519
|
+
|
|
2520
|
+
|
|
2521
|
+
|
|
2522
|
+
|
|
2523
|
+
|
|
2524
|
+
|
|
2525
|
+
|
|
2526
|
+
|
|
2527
|
+
class Meeting {
|
|
2528
|
+
|
|
2529
|
+
|
|
2530
|
+
|
|
2531
|
+
|
|
2532
|
+
|
|
2533
|
+
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
static parse(plain ) {
|
|
2539
|
+
return new Meeting({
|
|
2540
|
+
guestSipAuthorization: plain.guest_sip_authorization,
|
|
2541
|
+
hostname: plain.hostname,
|
|
2542
|
+
name: plain.name,
|
|
2543
|
+
ownerUuids: plain.owner_uuids,
|
|
2544
|
+
port: plain.port,
|
|
2545
|
+
uuid: plain.uuid,
|
|
2546
|
+
number: plain.number,
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
static newFrom(meeting ) {
|
|
2551
|
+
return newFrom(meeting, Meeting);
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, hostname, number } = {}) {
|
|
2555
|
+
this.guestSipAuthorization = guestSipAuthorization;
|
|
2556
|
+
this.hostname = hostname;
|
|
2557
|
+
this.name = name;
|
|
2558
|
+
this.ownerUuids = ownerUuids;
|
|
2559
|
+
this.port = port;
|
|
2560
|
+
this.uuid = uuid;
|
|
2561
|
+
this.number = number;
|
|
2562
|
+
|
|
2563
|
+
// Useful to compare instead of instanceof with minified code
|
|
2564
|
+
this.type = 'Meeting';
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
getGuestSipCredentials() {
|
|
2568
|
+
// eslint-disable-next-line no-undef
|
|
2569
|
+
const [username, secret] = atob(this.guestSipAuthorization).split(':');
|
|
2570
|
+
return { username, secret };
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2515
2574
|
/* */
|
|
2516
2575
|
|
|
2517
2576
|
var confdMethods = (client , baseUrl ) => ({
|
|
@@ -2576,6 +2635,18 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2576
2635
|
return null;
|
|
2577
2636
|
}
|
|
2578
2637
|
},
|
|
2638
|
+
|
|
2639
|
+
createMyMeeting: (name ) =>
|
|
2640
|
+
client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
|
|
2641
|
+
|
|
2642
|
+
deleteMyMeeting: (meetingUuid ) =>
|
|
2643
|
+
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
2644
|
+
|
|
2645
|
+
getMeeting: (meetingUuid ) =>
|
|
2646
|
+
client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
2647
|
+
|
|
2648
|
+
guestGetMeeting: (meetingUuid ) =>
|
|
2649
|
+
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
2579
2650
|
});
|
|
2580
2651
|
|
|
2581
2652
|
//
|
|
@@ -3518,7 +3589,11 @@ class CallLog {
|
|
|
3518
3589
|
answered: plain.answered,
|
|
3519
3590
|
callDirection: plain.call_direction,
|
|
3520
3591
|
destination: {
|
|
3521
|
-
|
|
3592
|
+
// @TEMP: Temporarily assuming empty numbers are meetings
|
|
3593
|
+
// which is admittedly a very dangerous assumption. Did i mention it was temporary?
|
|
3594
|
+
extension: plain.requested_extension
|
|
3595
|
+
|| plain.destination_extension
|
|
3596
|
+
|| `meeting-${plain.requested_name || plain.destination_name || ''}`,
|
|
3522
3597
|
name: plain.requested_name || plain.destination_name || '',
|
|
3523
3598
|
},
|
|
3524
3599
|
source: {
|
|
@@ -3534,27 +3609,11 @@ class CallLog {
|
|
|
3534
3609
|
}
|
|
3535
3610
|
|
|
3536
3611
|
static parseNew(plain , session ) {
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
extension: plain.requested_extension || plain.destination_extension,
|
|
3543
|
-
name: plain.requested_name || plain.destination_name || '',
|
|
3544
|
-
},
|
|
3545
|
-
source: {
|
|
3546
|
-
extension: plain.source_extension,
|
|
3547
|
-
name: plain.source_name,
|
|
3548
|
-
},
|
|
3549
|
-
id: plain.id,
|
|
3550
|
-
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
3551
|
-
start: moment(plain.start).toDate(),
|
|
3552
|
-
end: plain.end ? moment(plain.end).toDate() : null,
|
|
3553
|
-
recordings: Recording.parseMany(plain.recordings),
|
|
3554
|
-
// @TODO: FIXME add verification declined vs missed call
|
|
3555
|
-
newMissedCall: session
|
|
3556
|
-
&& session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
|
|
3557
|
-
});
|
|
3612
|
+
const callLog = CallLog.parse(plain);
|
|
3613
|
+
// @TODO: FIXME add verification declined vs missed call
|
|
3614
|
+
callLog.newMissedCall = session
|
|
3615
|
+
&& session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
|
|
3616
|
+
return callLog;
|
|
3558
3617
|
}
|
|
3559
3618
|
|
|
3560
3619
|
static newFrom(profile ) {
|
|
@@ -3819,7 +3878,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3819
3878
|
|
|
3820
3879
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3821
3880
|
|
|
3822
|
-
const logger$
|
|
3881
|
+
const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3823
3882
|
|
|
3824
3883
|
class CTIPhone extends Emitter {
|
|
3825
3884
|
|
|
@@ -3832,7 +3891,7 @@ class CTIPhone extends Emitter {
|
|
|
3832
3891
|
|
|
3833
3892
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
3834
3893
|
super();
|
|
3835
|
-
logger$
|
|
3894
|
+
logger$b.info('CTI Phone created');
|
|
3836
3895
|
this.session = session;
|
|
3837
3896
|
this.isMobile = isMobile;
|
|
3838
3897
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -3893,7 +3952,7 @@ class CTIPhone extends Emitter {
|
|
|
3893
3952
|
}
|
|
3894
3953
|
|
|
3895
3954
|
async makeCall(number , line ) {
|
|
3896
|
-
logger$
|
|
3955
|
+
logger$b.info('make CTI call', { number });
|
|
3897
3956
|
|
|
3898
3957
|
if (!number) {
|
|
3899
3958
|
return null;
|
|
@@ -3916,7 +3975,7 @@ class CTIPhone extends Emitter {
|
|
|
3916
3975
|
if (!callSession) {
|
|
3917
3976
|
return Promise.resolve(null);
|
|
3918
3977
|
}
|
|
3919
|
-
logger$
|
|
3978
|
+
logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3920
3979
|
|
|
3921
3980
|
if (!this.currentCall) {
|
|
3922
3981
|
this.currentCall = callSession.call;
|
|
@@ -3929,7 +3988,7 @@ class CTIPhone extends Emitter {
|
|
|
3929
3988
|
if (!callSession) {
|
|
3930
3989
|
return;
|
|
3931
3990
|
}
|
|
3932
|
-
logger$
|
|
3991
|
+
logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3933
3992
|
|
|
3934
3993
|
this.currentCall = undefined;
|
|
3935
3994
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -3939,7 +3998,7 @@ class CTIPhone extends Emitter {
|
|
|
3939
3998
|
if (!callSession) {
|
|
3940
3999
|
return Promise.resolve(false);
|
|
3941
4000
|
}
|
|
3942
|
-
logger$
|
|
4001
|
+
logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3943
4002
|
|
|
3944
4003
|
try {
|
|
3945
4004
|
await CallApi.cancelCall(callSession);
|
|
@@ -3950,7 +4009,7 @@ class CTIPhone extends Emitter {
|
|
|
3950
4009
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
3951
4010
|
return true;
|
|
3952
4011
|
} catch (e) {
|
|
3953
|
-
logger$
|
|
4012
|
+
logger$b.error('hangup CTI call, error', e);
|
|
3954
4013
|
|
|
3955
4014
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
3956
4015
|
return false;
|
|
@@ -3963,7 +4022,7 @@ class CTIPhone extends Emitter {
|
|
|
3963
4022
|
if (!callSession) {
|
|
3964
4023
|
return;
|
|
3965
4024
|
}
|
|
3966
|
-
logger$
|
|
4025
|
+
logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3967
4026
|
|
|
3968
4027
|
await CallApi.cancelCall(callSession);
|
|
3969
4028
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -3973,7 +4032,7 @@ class CTIPhone extends Emitter {
|
|
|
3973
4032
|
if (!callSession) {
|
|
3974
4033
|
return;
|
|
3975
4034
|
}
|
|
3976
|
-
logger$
|
|
4035
|
+
logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
3977
4036
|
|
|
3978
4037
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
3979
4038
|
}
|
|
@@ -3984,19 +4043,19 @@ class CTIPhone extends Emitter {
|
|
|
3984
4043
|
if (!callSession) {
|
|
3985
4044
|
return;
|
|
3986
4045
|
}
|
|
3987
|
-
logger$
|
|
4046
|
+
logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
3988
4047
|
|
|
3989
4048
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
3990
4049
|
}
|
|
3991
4050
|
|
|
3992
4051
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
3993
|
-
logger$
|
|
4052
|
+
logger$b.info('cancel CTI transfer', { transferId });
|
|
3994
4053
|
|
|
3995
4054
|
return CallApi.cancelCallTransfer(transferId);
|
|
3996
4055
|
}
|
|
3997
4056
|
|
|
3998
4057
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
3999
|
-
logger$
|
|
4058
|
+
logger$b.info('confirm CTI transfer', { transferId });
|
|
4000
4059
|
|
|
4001
4060
|
return CallApi.confirmCallTransfer(transferId);
|
|
4002
4061
|
}
|
|
@@ -4005,19 +4064,19 @@ class CTIPhone extends Emitter {
|
|
|
4005
4064
|
if (!callSession) {
|
|
4006
4065
|
return;
|
|
4007
4066
|
}
|
|
4008
|
-
logger$
|
|
4067
|
+
logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4009
4068
|
|
|
4010
4069
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4011
4070
|
}
|
|
4012
4071
|
|
|
4013
4072
|
onConnectionMade() {
|
|
4014
|
-
logger$
|
|
4073
|
+
logger$b.info('on CTI connection made');
|
|
4015
4074
|
|
|
4016
4075
|
this.eventEmitter.emit('onCallAccepted');
|
|
4017
4076
|
}
|
|
4018
4077
|
|
|
4019
4078
|
async close() {
|
|
4020
|
-
logger$
|
|
4079
|
+
logger$b.info('CTI close');
|
|
4021
4080
|
|
|
4022
4081
|
return Promise.resolve();
|
|
4023
4082
|
}
|
|
@@ -4026,7 +4085,7 @@ class CTIPhone extends Emitter {
|
|
|
4026
4085
|
if (!callSession) {
|
|
4027
4086
|
return;
|
|
4028
4087
|
}
|
|
4029
|
-
logger$
|
|
4088
|
+
logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4030
4089
|
|
|
4031
4090
|
return CallApi.hold(callSession.callId);
|
|
4032
4091
|
}
|
|
@@ -4035,7 +4094,7 @@ class CTIPhone extends Emitter {
|
|
|
4035
4094
|
if (!callSession) {
|
|
4036
4095
|
return;
|
|
4037
4096
|
}
|
|
4038
|
-
logger$
|
|
4097
|
+
logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4039
4098
|
|
|
4040
4099
|
return CallApi.resume(callSession.callId);
|
|
4041
4100
|
}
|
|
@@ -4044,7 +4103,7 @@ class CTIPhone extends Emitter {
|
|
|
4044
4103
|
if (!callSession) {
|
|
4045
4104
|
return;
|
|
4046
4105
|
}
|
|
4047
|
-
logger$
|
|
4106
|
+
logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4048
4107
|
|
|
4049
4108
|
return CallApi.mute(callSession.callId);
|
|
4050
4109
|
}
|
|
@@ -4053,7 +4112,7 @@ class CTIPhone extends Emitter {
|
|
|
4053
4112
|
if (!callSession) {
|
|
4054
4113
|
return;
|
|
4055
4114
|
}
|
|
4056
|
-
logger$
|
|
4115
|
+
logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4057
4116
|
|
|
4058
4117
|
return CallApi.unmute(callSession.callId);
|
|
4059
4118
|
}
|
|
@@ -4699,6 +4758,9 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
4699
4758
|
getConferenceParticipantsAsUser: async (conferenceId ) =>
|
|
4700
4759
|
client.get(`${baseUrl}/users/me/conferences/${conferenceId}/participants`),
|
|
4701
4760
|
|
|
4761
|
+
getMeetingParticipantsAsUser: async (meetingUuid ) =>
|
|
4762
|
+
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
|
|
4763
|
+
|
|
4702
4764
|
listTrunks: () => client.get(`${baseUrl}/trunks`),
|
|
4703
4765
|
|
|
4704
4766
|
mute: (callId ) =>
|
|
@@ -5052,7 +5114,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5052
5114
|
const WEBHOOKD_VERSION = '1.0';
|
|
5053
5115
|
const AMID_VERSION = '1.0';
|
|
5054
5116
|
|
|
5055
|
-
const logger$
|
|
5117
|
+
const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5056
5118
|
|
|
5057
5119
|
class ApiClient {
|
|
5058
5120
|
|
|
@@ -5104,12 +5166,12 @@ class ApiClient {
|
|
|
5104
5166
|
}
|
|
5105
5167
|
|
|
5106
5168
|
async forceRefreshToken() {
|
|
5107
|
-
logger$
|
|
5169
|
+
logger$a.info('forcing refresh token, calling callback');
|
|
5108
5170
|
return this.refreshTokenCallback();
|
|
5109
5171
|
}
|
|
5110
5172
|
|
|
5111
5173
|
async refreshTokenCallback() {
|
|
5112
|
-
logger$
|
|
5174
|
+
logger$a.info('refresh token callback called', {
|
|
5113
5175
|
refreshToken: this.refreshToken,
|
|
5114
5176
|
refreshBackend: this.refreshBackend,
|
|
5115
5177
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5127,7 +5189,7 @@ class ApiClient {
|
|
|
5127
5189
|
this.isMobile,
|
|
5128
5190
|
);
|
|
5129
5191
|
|
|
5130
|
-
logger$
|
|
5192
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5131
5193
|
|
|
5132
5194
|
if (this.onRefreshToken) {
|
|
5133
5195
|
this.onRefreshToken(session.token, session);
|
|
@@ -5600,7 +5662,9 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5600
5662
|
.then(() => {
|
|
5601
5663
|
if (isConference && (options.constraints && !options.constraints.video) && !('hold' in options) && !audioOnly) {
|
|
5602
5664
|
// Add a video an empty bundle to be able to replaceTrack when joining a conference without video
|
|
5603
|
-
this.peerConnection.addTransceiver
|
|
5665
|
+
if (this.peerConnection.addTransceiver) {
|
|
5666
|
+
this.peerConnection.addTransceiver('video', { streams: [this._localMediaStream], direction: 'sendrecv' });
|
|
5667
|
+
}
|
|
5604
5668
|
}
|
|
5605
5669
|
})
|
|
5606
5670
|
.then(() => this.createLocalOfferOrAnswer(options))
|
|
@@ -5627,12 +5691,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5627
5691
|
};
|
|
5628
5692
|
})
|
|
5629
5693
|
.then((sessionDescription) => this.applyModifiers(sessionDescription, modifiers))
|
|
5630
|
-
.then((sessionDescription) => {
|
|
5631
|
-
// Set new constraints to avoid the constraints check issue in `sdh.getLocalMediaStream` later.
|
|
5632
|
-
this.localMediaStreamConstraints = options.constraints;
|
|
5633
|
-
|
|
5634
|
-
return sessionDescription;
|
|
5635
|
-
})
|
|
5636
5694
|
.then((sessionDescription) => ({ body: sessionDescription.sdp, contentType: 'application/sdp' }))
|
|
5637
5695
|
.catch((error) => {
|
|
5638
5696
|
wazoLogger.error('error when creating media', error);
|
|
@@ -5827,6 +5885,9 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5827
5885
|
|
|
5828
5886
|
// set the transceiver direction to the answer direction
|
|
5829
5887
|
this._peerConnection.getTransceivers().forEach((transceiver) => {
|
|
5888
|
+
if (transceiver.stopped) {
|
|
5889
|
+
return;
|
|
5890
|
+
}
|
|
5830
5891
|
if (transceiver.direction /* guarding, but should always be true */) {
|
|
5831
5892
|
const { receiver } = transceiver;
|
|
5832
5893
|
if (isConference && audioOnly && receiver.track && receiver.track.kind === 'video') {
|
|
@@ -5871,10 +5932,15 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5871
5932
|
if (kind !== 'audio' && kind !== 'video') {
|
|
5872
5933
|
throw new Error(`Unknown new track kind ${kind}.`);
|
|
5873
5934
|
}
|
|
5874
|
-
const sender = pc.getSenders().find((otherSender) =>
|
|
5935
|
+
const sender = pc.getSenders && pc.getSenders().find((otherSender) =>
|
|
5936
|
+
otherSender.track && otherSender.track.kind === kind);
|
|
5875
5937
|
|
|
5876
5938
|
// Do not reuse sender video tracks in SFU
|
|
5877
5939
|
if (sender && (!sfu || newTrack.kind === 'audio')) {
|
|
5940
|
+
if (sender.track) {
|
|
5941
|
+
// eslint-disable-next-line no-param-reassign
|
|
5942
|
+
newTrack.enabled = sender.track.enabled;
|
|
5943
|
+
}
|
|
5878
5944
|
trackUpdates.push(
|
|
5879
5945
|
new Promise((resolve) => {
|
|
5880
5946
|
this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - replacing sender ${kind} track`);
|
|
@@ -5908,7 +5974,11 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5908
5974
|
// Review: could make streamless tracks a configurable option?
|
|
5909
5975
|
// https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addTrack#Usage_notes
|
|
5910
5976
|
try {
|
|
5911
|
-
pc.addTrack
|
|
5977
|
+
if (pc.addTrack) {
|
|
5978
|
+
pc.addTrack(newTrack, localStream);
|
|
5979
|
+
} else {
|
|
5980
|
+
pc.addStream(localStream);
|
|
5981
|
+
}
|
|
5912
5982
|
} catch (error) {
|
|
5913
5983
|
this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to add sender ${kind} track`);
|
|
5914
5984
|
throw error;
|
|
@@ -6044,7 +6114,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6044
6114
|
const SEND_STATS_DELAY = 5000;
|
|
6045
6115
|
|
|
6046
6116
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6047
|
-
const logger$
|
|
6117
|
+
const logger$9 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6048
6118
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6049
6119
|
|
|
6050
6120
|
// events
|
|
@@ -6090,6 +6160,7 @@ const MAX_REGISTER_TRIES = 10;
|
|
|
6090
6160
|
|
|
6091
6161
|
|
|
6092
6162
|
|
|
6163
|
+
|
|
6093
6164
|
|
|
6094
6165
|
|
|
6095
6166
|
|
|
@@ -6116,6 +6187,7 @@ class WebRTCClient extends Emitter {
|
|
|
6116
6187
|
|
|
6117
6188
|
|
|
6118
6189
|
|
|
6190
|
+
|
|
6119
6191
|
|
|
6120
6192
|
// sugar
|
|
6121
6193
|
|
|
@@ -6154,6 +6226,8 @@ class WebRTCClient extends Emitter {
|
|
|
6154
6226
|
super();
|
|
6155
6227
|
this.uaConfigOverrides = uaConfigOverrides;
|
|
6156
6228
|
this.config = config;
|
|
6229
|
+
this.skipRegister = config.skipRegister;
|
|
6230
|
+
|
|
6157
6231
|
this._buildConfig(config, session).then((newConfig ) => {
|
|
6158
6232
|
this.config = newConfig;
|
|
6159
6233
|
this.userAgent = this.createUserAgent(uaConfigOverrides);
|
|
@@ -6209,13 +6283,13 @@ class WebRTCClient extends Emitter {
|
|
|
6209
6283
|
|
|
6210
6284
|
createUserAgent(configOverrides ) {
|
|
6211
6285
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6212
|
-
logger$
|
|
6286
|
+
logger$9.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6213
6287
|
|
|
6214
6288
|
webRTCConfiguration.delegate = {
|
|
6215
6289
|
onConnect: this.onConnect.bind(this),
|
|
6216
6290
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6217
6291
|
onInvite: (invitation ) => {
|
|
6218
|
-
logger$
|
|
6292
|
+
logger$9.info('sdk webrtc on invite', {
|
|
6219
6293
|
method: 'delegate.onInvite',
|
|
6220
6294
|
id: invitation.id,
|
|
6221
6295
|
remoteURI: invitation.remoteURI,
|
|
@@ -6258,7 +6332,7 @@ class WebRTCClient extends Emitter {
|
|
|
6258
6332
|
}
|
|
6259
6333
|
|
|
6260
6334
|
onConnect() {
|
|
6261
|
-
logger$
|
|
6335
|
+
logger$9.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6262
6336
|
this.eventEmitter.emit(CONNECTED);
|
|
6263
6337
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6264
6338
|
this.registerer.waitingToggle(false);
|
|
@@ -6267,7 +6341,7 @@ class WebRTCClient extends Emitter {
|
|
|
6267
6341
|
}
|
|
6268
6342
|
|
|
6269
6343
|
async onDisconnect(error ) {
|
|
6270
|
-
logger$
|
|
6344
|
+
logger$9.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6271
6345
|
this.connectionPromise = null;
|
|
6272
6346
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6273
6347
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6281,40 +6355,48 @@ class WebRTCClient extends Emitter {
|
|
|
6281
6355
|
}
|
|
6282
6356
|
|
|
6283
6357
|
register(tries = 0) {
|
|
6284
|
-
|
|
6358
|
+
const logInfo = {
|
|
6285
6359
|
userAgent: !!this.userAgent,
|
|
6286
6360
|
registered: this.isRegistered(),
|
|
6287
6361
|
connectionPromise: !!this.connectionPromise,
|
|
6288
6362
|
registerer: !!this.registerer,
|
|
6289
6363
|
waiting: this.registerer && this.registerer.waiting,
|
|
6290
6364
|
tries,
|
|
6291
|
-
|
|
6365
|
+
skipRegister: this.skipRegister,
|
|
6366
|
+
};
|
|
6367
|
+
|
|
6368
|
+
if (this.skipRegister) {
|
|
6369
|
+
logger$9.info('sdk webrtc skip register...', logInfo);
|
|
6370
|
+
return Promise.resolve();
|
|
6371
|
+
}
|
|
6372
|
+
|
|
6373
|
+
logger$9.info('sdk webrtc registering...', logInfo);
|
|
6292
6374
|
|
|
6293
6375
|
if (!this.userAgent) {
|
|
6294
|
-
logger$
|
|
6376
|
+
logger$9.info('sdk webrtc recreating User Agent');
|
|
6295
6377
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6296
6378
|
}
|
|
6297
6379
|
if (!this.userAgent || this.isRegistered()) {
|
|
6298
|
-
logger$
|
|
6380
|
+
logger$9.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6299
6381
|
return Promise.resolve();
|
|
6300
6382
|
}
|
|
6301
6383
|
|
|
6302
6384
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6303
|
-
logger$
|
|
6385
|
+
logger$9.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6304
6386
|
return Promise.resolve();
|
|
6305
6387
|
}
|
|
6306
6388
|
|
|
6307
6389
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6308
6390
|
|
|
6309
6391
|
const onRegisterFailed = () => {
|
|
6310
|
-
logger$
|
|
6392
|
+
logger$9.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6311
6393
|
this.connectionPromise = null;
|
|
6312
6394
|
if (this.registerer && this.registerer.waiting) {
|
|
6313
6395
|
this.registerer.waitingToggle(false);
|
|
6314
6396
|
}
|
|
6315
6397
|
|
|
6316
6398
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6317
|
-
logger$
|
|
6399
|
+
logger$9.info('sdk webrtc registering, retrying...', { tries });
|
|
6318
6400
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6319
6401
|
}
|
|
6320
6402
|
};
|
|
@@ -6323,18 +6405,18 @@ class WebRTCClient extends Emitter {
|
|
|
6323
6405
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6324
6406
|
// during the resolution of the primise.
|
|
6325
6407
|
if (!this.userAgent) {
|
|
6326
|
-
logger$
|
|
6408
|
+
logger$9.info('sdk webrtc recreating User Agent after connection');
|
|
6327
6409
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6328
6410
|
}
|
|
6329
6411
|
|
|
6330
|
-
logger$
|
|
6412
|
+
logger$9.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6331
6413
|
this.registerer = new Registerer(this.userAgent, registerOptions);
|
|
6332
6414
|
this.connectionPromise = null;
|
|
6333
6415
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6334
6416
|
|
|
6335
6417
|
// Bind registerer events
|
|
6336
6418
|
this.registerer.stateChange.addListener(newState => {
|
|
6337
|
-
logger$
|
|
6419
|
+
logger$9.info('sdk webrtc registering, state changed', { newState });
|
|
6338
6420
|
|
|
6339
6421
|
if (newState === RegistererState.Registered && this.registerer
|
|
6340
6422
|
&& this.registerer.state === RegistererState.Registered) {
|
|
@@ -6347,7 +6429,7 @@ class WebRTCClient extends Emitter {
|
|
|
6347
6429
|
const options = {
|
|
6348
6430
|
requestDelegate: {
|
|
6349
6431
|
onReject: response => {
|
|
6350
|
-
logger$
|
|
6432
|
+
logger$9.error('sdk webrtc registering, rejected', { response });
|
|
6351
6433
|
|
|
6352
6434
|
onRegisterFailed();
|
|
6353
6435
|
},
|
|
@@ -6355,13 +6437,13 @@ class WebRTCClient extends Emitter {
|
|
|
6355
6437
|
};
|
|
6356
6438
|
|
|
6357
6439
|
return this.registerer.register(options).catch((e) => {
|
|
6358
|
-
logger$
|
|
6440
|
+
logger$9.error('sdk webrtc registering, error', e);
|
|
6359
6441
|
|
|
6360
6442
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6361
6443
|
return e;
|
|
6362
6444
|
});
|
|
6363
6445
|
}).catch(error => {
|
|
6364
|
-
logger$
|
|
6446
|
+
logger$9.error('sdk webrtc registering, transport error', error);
|
|
6365
6447
|
onRegisterFailed();
|
|
6366
6448
|
});
|
|
6367
6449
|
}
|
|
@@ -6390,21 +6472,21 @@ class WebRTCClient extends Emitter {
|
|
|
6390
6472
|
}
|
|
6391
6473
|
|
|
6392
6474
|
unregister() {
|
|
6393
|
-
logger$
|
|
6475
|
+
logger$9.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6394
6476
|
if (!this.registerer) {
|
|
6395
6477
|
return Promise.resolve();
|
|
6396
6478
|
}
|
|
6397
6479
|
|
|
6398
6480
|
try {
|
|
6399
6481
|
return this.registerer.unregister().then(() => {
|
|
6400
|
-
logger$
|
|
6482
|
+
logger$9.info('sdk webrtc unregistered');
|
|
6401
6483
|
this._cleanupRegister();
|
|
6402
6484
|
}).catch(e => {
|
|
6403
|
-
logger$
|
|
6485
|
+
logger$9.error('sdk webrtc unregistering, promise error', e);
|
|
6404
6486
|
this._cleanupRegister();
|
|
6405
6487
|
});
|
|
6406
6488
|
} catch (e) {
|
|
6407
|
-
logger$
|
|
6489
|
+
logger$9.error('sdk webrtc unregistering, error', e);
|
|
6408
6490
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6409
6491
|
// error when the registerer is in a bad state
|
|
6410
6492
|
this._cleanupRegister();
|
|
@@ -6412,7 +6494,7 @@ class WebRTCClient extends Emitter {
|
|
|
6412
6494
|
}
|
|
6413
6495
|
|
|
6414
6496
|
stop() {
|
|
6415
|
-
logger$
|
|
6497
|
+
logger$9.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6416
6498
|
if (!this.userAgent) {
|
|
6417
6499
|
return Promise.resolve();
|
|
6418
6500
|
}
|
|
@@ -6420,12 +6502,12 @@ class WebRTCClient extends Emitter {
|
|
|
6420
6502
|
return this.userAgent.stop().then(() => {
|
|
6421
6503
|
return this._cleanupRegister();
|
|
6422
6504
|
}).catch(e => {
|
|
6423
|
-
logger$
|
|
6505
|
+
logger$9.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6424
6506
|
});
|
|
6425
6507
|
}
|
|
6426
6508
|
|
|
6427
6509
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6428
|
-
logger$
|
|
6510
|
+
logger$9.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6429
6511
|
const inviterOptions = {
|
|
6430
6512
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6431
6513
|
conference,
|
|
@@ -6454,7 +6536,7 @@ class WebRTCClient extends Emitter {
|
|
|
6454
6536
|
this._onAccepted(session, response.session, true);
|
|
6455
6537
|
},
|
|
6456
6538
|
onReject: (response ) => {
|
|
6457
|
-
logger$
|
|
6539
|
+
logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6458
6540
|
this._stopSendingStats(session);
|
|
6459
6541
|
|
|
6460
6542
|
this.eventEmitter.emit(REJECTED, session, response);
|
|
@@ -6476,11 +6558,11 @@ class WebRTCClient extends Emitter {
|
|
|
6476
6558
|
}
|
|
6477
6559
|
|
|
6478
6560
|
answer(session , enableVideo ) {
|
|
6479
|
-
logger$
|
|
6561
|
+
logger$9.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6480
6562
|
|
|
6481
6563
|
if (!session || !session.accept) {
|
|
6482
6564
|
const error = 'No session to answer, or not an invitation';
|
|
6483
|
-
logger$
|
|
6565
|
+
logger$9.warn(error);
|
|
6484
6566
|
return Promise.reject(new Error(error));
|
|
6485
6567
|
}
|
|
6486
6568
|
const options = {
|
|
@@ -6490,15 +6572,15 @@ class WebRTCClient extends Emitter {
|
|
|
6490
6572
|
return session.accept(options).then(() => {
|
|
6491
6573
|
if (session.isCanceled) {
|
|
6492
6574
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
6493
|
-
logger$
|
|
6575
|
+
logger$9.error(message, { id: session.id });
|
|
6494
6576
|
this.onCallEnded(session);
|
|
6495
6577
|
|
|
6496
6578
|
throw new CanceledCallError(message);
|
|
6497
6579
|
}
|
|
6498
|
-
logger$
|
|
6580
|
+
logger$9.info('sdk webrtc answer, accepted.');
|
|
6499
6581
|
this._onAccepted(session);
|
|
6500
6582
|
}).catch(e => {
|
|
6501
|
-
logger$
|
|
6583
|
+
logger$9.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6502
6584
|
|
|
6503
6585
|
throw e;
|
|
6504
6586
|
});
|
|
@@ -6506,7 +6588,7 @@ class WebRTCClient extends Emitter {
|
|
|
6506
6588
|
|
|
6507
6589
|
hangup(session ) {
|
|
6508
6590
|
const { state, id } = session;
|
|
6509
|
-
logger$
|
|
6591
|
+
logger$9.info('sdk webrtc hangup call', { id, state });
|
|
6510
6592
|
|
|
6511
6593
|
try {
|
|
6512
6594
|
this._stopSendingStats(session);
|
|
@@ -6535,24 +6617,24 @@ class WebRTCClient extends Emitter {
|
|
|
6535
6617
|
|
|
6536
6618
|
return bye();
|
|
6537
6619
|
} catch (error) {
|
|
6538
|
-
logger$
|
|
6620
|
+
logger$9.warn('sdk webrtc hangup, error', error);
|
|
6539
6621
|
}
|
|
6540
6622
|
|
|
6541
6623
|
return null;
|
|
6542
6624
|
}
|
|
6543
6625
|
|
|
6544
6626
|
reject(session ) {
|
|
6545
|
-
logger$
|
|
6627
|
+
logger$9.info('sdk webrtc reject call', { id: session.id });
|
|
6546
6628
|
|
|
6547
6629
|
try {
|
|
6548
6630
|
return session.reject ? session.reject() : session.cancel();
|
|
6549
6631
|
} catch (e) {
|
|
6550
|
-
logger$
|
|
6632
|
+
logger$9.warn('Error when rejecting call', e.message, e.stack);
|
|
6551
6633
|
}
|
|
6552
6634
|
}
|
|
6553
6635
|
|
|
6554
6636
|
async close() {
|
|
6555
|
-
logger$
|
|
6637
|
+
logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6556
6638
|
this._cleanupMedia();
|
|
6557
6639
|
this.connectionPromise = null;
|
|
6558
6640
|
|
|
@@ -6583,7 +6665,7 @@ class WebRTCClient extends Emitter {
|
|
|
6583
6665
|
// eg: "INVITE not rejectable in state Completed"
|
|
6584
6666
|
}
|
|
6585
6667
|
this.userAgent = null;
|
|
6586
|
-
logger$
|
|
6668
|
+
logger$9.info('sdk webrtc client closed');
|
|
6587
6669
|
}
|
|
6588
6670
|
|
|
6589
6671
|
getNumber(session ) {
|
|
@@ -6596,13 +6678,13 @@ class WebRTCClient extends Emitter {
|
|
|
6596
6678
|
}
|
|
6597
6679
|
|
|
6598
6680
|
mute(session ) {
|
|
6599
|
-
logger$
|
|
6681
|
+
logger$9.info('sdk webrtc mute', { id: session.id });
|
|
6600
6682
|
|
|
6601
6683
|
this._toggleAudio(session, true);
|
|
6602
6684
|
}
|
|
6603
6685
|
|
|
6604
6686
|
unmute(session ) {
|
|
6605
|
-
logger$
|
|
6687
|
+
logger$9.info('sdk webrtc unmute', { id: session.id });
|
|
6606
6688
|
|
|
6607
6689
|
this._toggleAudio(session, false);
|
|
6608
6690
|
}
|
|
@@ -6619,12 +6701,18 @@ class WebRTCClient extends Emitter {
|
|
|
6619
6701
|
}
|
|
6620
6702
|
|
|
6621
6703
|
if (pc.getSenders) {
|
|
6704
|
+
if (!pc.getSenders().length) {
|
|
6705
|
+
return false;
|
|
6706
|
+
}
|
|
6622
6707
|
pc.getSenders().forEach(sender => {
|
|
6623
6708
|
if (sender && sender.track && sender.track.kind === 'audio') {
|
|
6624
6709
|
muted = muted && !sender.track.enabled;
|
|
6625
6710
|
}
|
|
6626
6711
|
});
|
|
6627
6712
|
} else {
|
|
6713
|
+
if (!pc.getLocalStreams().length) {
|
|
6714
|
+
return false;
|
|
6715
|
+
}
|
|
6628
6716
|
pc.getLocalStreams().forEach(stream => {
|
|
6629
6717
|
stream.getAudioTracks().forEach(track => {
|
|
6630
6718
|
muted = muted && !track.enabled;
|
|
@@ -6636,20 +6724,20 @@ class WebRTCClient extends Emitter {
|
|
|
6636
6724
|
}
|
|
6637
6725
|
|
|
6638
6726
|
toggleCameraOn(session ) {
|
|
6639
|
-
logger$
|
|
6727
|
+
logger$9.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6640
6728
|
|
|
6641
6729
|
this._toggleVideo(session, false);
|
|
6642
6730
|
}
|
|
6643
6731
|
|
|
6644
6732
|
toggleCameraOff(session ) {
|
|
6645
|
-
logger$
|
|
6733
|
+
logger$9.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6646
6734
|
|
|
6647
6735
|
this._toggleVideo(session, true);
|
|
6648
6736
|
}
|
|
6649
6737
|
|
|
6650
6738
|
hold(session , isConference = false) {
|
|
6651
6739
|
const sessionId = this.getSipSessionId(session);
|
|
6652
|
-
logger$
|
|
6740
|
+
logger$9.info('sdk webrtc hold', {
|
|
6653
6741
|
sessionId,
|
|
6654
6742
|
keys: Object.keys(this.heldSessions),
|
|
6655
6743
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6683,6 +6771,8 @@ class WebRTCClient extends Emitter {
|
|
|
6683
6771
|
}
|
|
6684
6772
|
options.sessionDescriptionHandlerOptions = {
|
|
6685
6773
|
constraints: options.constraints,
|
|
6774
|
+
hold: true,
|
|
6775
|
+
conference: isConference,
|
|
6686
6776
|
};
|
|
6687
6777
|
|
|
6688
6778
|
// Send re-INVITE
|
|
@@ -6692,7 +6782,7 @@ class WebRTCClient extends Emitter {
|
|
|
6692
6782
|
unhold(session , isConference = false) {
|
|
6693
6783
|
const sessionId = this.getSipSessionId(session);
|
|
6694
6784
|
|
|
6695
|
-
logger$
|
|
6785
|
+
logger$9.info('sdk webrtc unhold', {
|
|
6696
6786
|
sessionId,
|
|
6697
6787
|
keys: Object.keys(this.heldSessions),
|
|
6698
6788
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6725,6 +6815,8 @@ class WebRTCClient extends Emitter {
|
|
|
6725
6815
|
}
|
|
6726
6816
|
options.sessionDescriptionHandlerOptions = {
|
|
6727
6817
|
constraints: options.constraints,
|
|
6818
|
+
hold: false,
|
|
6819
|
+
conference: isConference,
|
|
6728
6820
|
};
|
|
6729
6821
|
|
|
6730
6822
|
// Send re-INVITE
|
|
@@ -6783,7 +6875,7 @@ class WebRTCClient extends Emitter {
|
|
|
6783
6875
|
return;
|
|
6784
6876
|
}
|
|
6785
6877
|
|
|
6786
|
-
logger$
|
|
6878
|
+
logger$9.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6787
6879
|
|
|
6788
6880
|
try {
|
|
6789
6881
|
sipSession.message({
|
|
@@ -6908,7 +7000,8 @@ class WebRTCClient extends Emitter {
|
|
|
6908
7000
|
}
|
|
6909
7001
|
const sdh = session.sessionDescriptionHandler;
|
|
6910
7002
|
const pc = sdh.peerConnection;
|
|
6911
|
-
const
|
|
7003
|
+
const sessionId = this.getSipSessionId(session);
|
|
7004
|
+
const localStream = this.getLocalStream(sessionId);
|
|
6912
7005
|
|
|
6913
7006
|
// Release old video stream
|
|
6914
7007
|
if (localStream) {
|
|
@@ -6934,11 +7027,8 @@ class WebRTCClient extends Emitter {
|
|
|
6934
7027
|
|
|
6935
7028
|
// let's update the local stream
|
|
6936
7029
|
this.eventEmitter.emit('onVideoInputChange', stream);
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
} catch (_) {
|
|
6940
|
-
// Nothing to do
|
|
6941
|
-
}
|
|
7030
|
+
this.setLocalMediaStream(sessionId, stream);
|
|
7031
|
+
|
|
6942
7032
|
return stream;
|
|
6943
7033
|
});
|
|
6944
7034
|
}
|
|
@@ -7150,7 +7240,7 @@ class WebRTCClient extends Emitter {
|
|
|
7150
7240
|
}
|
|
7151
7241
|
|
|
7152
7242
|
startHeartbeat() {
|
|
7153
|
-
logger$
|
|
7243
|
+
logger$9.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7154
7244
|
if (!this.userAgent) {
|
|
7155
7245
|
this.heartbeat.stop();
|
|
7156
7246
|
return;
|
|
@@ -7163,7 +7253,7 @@ class WebRTCClient extends Emitter {
|
|
|
7163
7253
|
}
|
|
7164
7254
|
|
|
7165
7255
|
stopHeartbeat() {
|
|
7166
|
-
logger$
|
|
7256
|
+
logger$9.info('sdk webrtc stop heartbeat');
|
|
7167
7257
|
this.heartbeat.stop();
|
|
7168
7258
|
}
|
|
7169
7259
|
|
|
@@ -7183,7 +7273,7 @@ class WebRTCClient extends Emitter {
|
|
|
7183
7273
|
}
|
|
7184
7274
|
|
|
7185
7275
|
attemptReconnection() {
|
|
7186
|
-
logger$
|
|
7276
|
+
logger$9.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7187
7277
|
if (!this.userAgent) {
|
|
7188
7278
|
return;
|
|
7189
7279
|
}
|
|
@@ -7240,9 +7330,11 @@ class WebRTCClient extends Emitter {
|
|
|
7240
7330
|
remoteStream.removeTrack(track);
|
|
7241
7331
|
});
|
|
7242
7332
|
|
|
7243
|
-
pc.getReceivers
|
|
7244
|
-
|
|
7245
|
-
|
|
7333
|
+
if (pc.getReceivers) {
|
|
7334
|
+
pc.getReceivers().forEach(receiver => {
|
|
7335
|
+
remoteStream.addTrack(receiver.track);
|
|
7336
|
+
});
|
|
7337
|
+
}
|
|
7246
7338
|
}
|
|
7247
7339
|
|
|
7248
7340
|
getMediaConfiguration(enableVideo , conference = false, constraints = null) {
|
|
@@ -7277,6 +7369,25 @@ class WebRTCClient extends Emitter {
|
|
|
7277
7369
|
return sessionId in this.conferences;
|
|
7278
7370
|
}
|
|
7279
7371
|
|
|
7372
|
+
createAudioElementFor(sessionId ) {
|
|
7373
|
+
const audio = document.createElement('audio');
|
|
7374
|
+
audio.setAttribute('id', `audio-${sessionId}`);
|
|
7375
|
+
|
|
7376
|
+
if (audio.setSinkId && this.audioOutputDeviceId) {
|
|
7377
|
+
audio.setSinkId(this.audioOutputDeviceId);
|
|
7378
|
+
}
|
|
7379
|
+
|
|
7380
|
+
if (document.body) {
|
|
7381
|
+
document.body.appendChild(audio);
|
|
7382
|
+
}
|
|
7383
|
+
this.audioElements[sessionId] = audio;
|
|
7384
|
+
|
|
7385
|
+
audio.volume = this.audioOutputVolume;
|
|
7386
|
+
audio.autoplay = true;
|
|
7387
|
+
|
|
7388
|
+
return audio;
|
|
7389
|
+
}
|
|
7390
|
+
|
|
7280
7391
|
_onTransportError() {
|
|
7281
7392
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
7282
7393
|
this.attemptReconnection();
|
|
@@ -7286,7 +7397,7 @@ class WebRTCClient extends Emitter {
|
|
|
7286
7397
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
7287
7398
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
7288
7399
|
if (this.hasHeartbeat()) {
|
|
7289
|
-
logger$
|
|
7400
|
+
logger$9.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7290
7401
|
|
|
7291
7402
|
this.heartbeat.onHeartbeat();
|
|
7292
7403
|
if (this.heartbeatCb) {
|
|
@@ -7297,7 +7408,7 @@ class WebRTCClient extends Emitter {
|
|
|
7297
7408
|
}
|
|
7298
7409
|
|
|
7299
7410
|
async _onHeartbeatTimeout() {
|
|
7300
|
-
logger$
|
|
7411
|
+
logger$9.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7301
7412
|
|
|
7302
7413
|
if (this.heartbeatTimeoutCb) {
|
|
7303
7414
|
this.heartbeatTimeoutCb();
|
|
@@ -7309,7 +7420,7 @@ class WebRTCClient extends Emitter {
|
|
|
7309
7420
|
try {
|
|
7310
7421
|
await this.userAgent.transport.disconnect();
|
|
7311
7422
|
} catch (e) {
|
|
7312
|
-
logger$
|
|
7423
|
+
logger$9.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7313
7424
|
}
|
|
7314
7425
|
}
|
|
7315
7426
|
|
|
@@ -7342,31 +7453,31 @@ class WebRTCClient extends Emitter {
|
|
|
7342
7453
|
}
|
|
7343
7454
|
|
|
7344
7455
|
_connectIfNeeded() {
|
|
7345
|
-
logger$
|
|
7456
|
+
logger$9.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7346
7457
|
if (!this.userAgent) {
|
|
7347
|
-
logger$
|
|
7458
|
+
logger$9.info('need to recreate User Agent');
|
|
7348
7459
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
7349
7460
|
}
|
|
7350
7461
|
|
|
7351
7462
|
if (this.isConnected()) {
|
|
7352
|
-
logger$
|
|
7463
|
+
logger$9.info('webrtc sdk, already connected');
|
|
7353
7464
|
return Promise.resolve();
|
|
7354
7465
|
}
|
|
7355
7466
|
|
|
7356
7467
|
if (this.isConnecting()) {
|
|
7357
|
-
logger$
|
|
7468
|
+
logger$9.info('webrtc sdk, already connecting...');
|
|
7358
7469
|
|
|
7359
7470
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
7360
7471
|
return this.connectionPromise;
|
|
7361
7472
|
}
|
|
7362
7473
|
|
|
7363
7474
|
if (this.connectionPromise) {
|
|
7364
|
-
logger$
|
|
7475
|
+
logger$9.info('webrtc sdk, connection promise connecting...');
|
|
7365
7476
|
// $FlowFixMe
|
|
7366
7477
|
return this.connectionPromise;
|
|
7367
7478
|
}
|
|
7368
7479
|
|
|
7369
|
-
logger$
|
|
7480
|
+
logger$9.info('WebRTC UA needs to connect');
|
|
7370
7481
|
|
|
7371
7482
|
// Force UA to reconnect
|
|
7372
7483
|
if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
|
|
@@ -7491,7 +7602,7 @@ class WebRTCClient extends Emitter {
|
|
|
7491
7602
|
|
|
7492
7603
|
sdh.peerConnectionDelegate = {
|
|
7493
7604
|
onicecandidateerror: (error ) => {
|
|
7494
|
-
logger$
|
|
7605
|
+
logger$9.error('on icecandidate error', {
|
|
7495
7606
|
address: error.address,
|
|
7496
7607
|
port: error.port,
|
|
7497
7608
|
errorCode: error.errorCode,
|
|
@@ -7506,7 +7617,7 @@ class WebRTCClient extends Emitter {
|
|
|
7506
7617
|
let hadRemoteVideo = false;
|
|
7507
7618
|
|
|
7508
7619
|
// Monkey patch `onInviteRequest` to be able to know if there was a remote video stream before `onInvite` is called
|
|
7509
|
-
//
|
|
7620
|
+
// Because when `onInvite` is called we already got the video track
|
|
7510
7621
|
session.onInviteRequest = (request) => {
|
|
7511
7622
|
hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
|
|
7512
7623
|
|
|
@@ -7520,7 +7631,7 @@ class WebRTCClient extends Emitter {
|
|
|
7520
7631
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
7521
7632
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
7522
7633
|
}
|
|
7523
|
-
logger$
|
|
7634
|
+
logger$9.info('re-invite received', { updatedCalleeName, updatedNumber });
|
|
7524
7635
|
|
|
7525
7636
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
7526
7637
|
|
|
@@ -7541,7 +7652,7 @@ class WebRTCClient extends Emitter {
|
|
|
7541
7652
|
}
|
|
7542
7653
|
|
|
7543
7654
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
7544
|
-
logger$
|
|
7655
|
+
logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7545
7656
|
|
|
7546
7657
|
this.storeSipSession(session);
|
|
7547
7658
|
|
|
@@ -7581,20 +7692,10 @@ class WebRTCClient extends Emitter {
|
|
|
7581
7692
|
const isConference = this.isConference(sessionId);
|
|
7582
7693
|
|
|
7583
7694
|
if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
|
|
7584
|
-
|
|
7585
|
-
audio.setAttribute('id', `audio-${sessionId}`);
|
|
7586
|
-
|
|
7587
|
-
if (audio.setSinkId && this.audioOutputDeviceId) {
|
|
7588
|
-
audio.setSinkId(this.audioOutputDeviceId);
|
|
7589
|
-
}
|
|
7590
|
-
|
|
7591
|
-
if (document.body) {
|
|
7592
|
-
document.body.appendChild(audio);
|
|
7593
|
-
}
|
|
7594
|
-
this.audioElements[sessionId] = audio;
|
|
7695
|
+
this.createAudioElementFor(sessionId);
|
|
7595
7696
|
}
|
|
7596
7697
|
|
|
7597
|
-
const audioElement = this.audioElements[
|
|
7698
|
+
const audioElement = this.audioElements[sessionId];
|
|
7598
7699
|
const stream = newStream || this.getRemoteStream(sessionId);
|
|
7599
7700
|
|
|
7600
7701
|
if (!this._isWeb() || !stream) {
|
|
@@ -7741,10 +7842,10 @@ class WebRTCClient extends Emitter {
|
|
|
7741
7842
|
|
|
7742
7843
|
_stopSendingStats(session ) {
|
|
7743
7844
|
const sessionId = this.getSipSessionId(session);
|
|
7744
|
-
logger$
|
|
7845
|
+
logger$9.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7745
7846
|
|
|
7746
7847
|
if (sessionId in this.statsIntervals) {
|
|
7747
|
-
logger$
|
|
7848
|
+
logger$9.trace('Stop sending stats for call', { sessionId });
|
|
7748
7849
|
this.statsIntervals[sessionId]();
|
|
7749
7850
|
delete this.statsIntervals[sessionId];
|
|
7750
7851
|
}
|
|
@@ -7760,7 +7861,7 @@ class WebRTCClient extends Emitter {
|
|
|
7760
7861
|
try {
|
|
7761
7862
|
await this.userAgent.transport.disconnect();
|
|
7762
7863
|
} catch (e) {
|
|
7763
|
-
logger$
|
|
7864
|
+
logger$9.error('WebRTC transport disconnect, error', e);
|
|
7764
7865
|
}
|
|
7765
7866
|
}
|
|
7766
7867
|
}
|
|
@@ -7847,7 +7948,7 @@ const events = [
|
|
|
7847
7948
|
ON_SIGNAL,
|
|
7848
7949
|
];
|
|
7849
7950
|
|
|
7850
|
-
const logger$
|
|
7951
|
+
const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
7851
7952
|
|
|
7852
7953
|
class WebRTCPhone extends Emitter {
|
|
7853
7954
|
|
|
@@ -7918,7 +8019,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7918
8019
|
}).catch(error => {
|
|
7919
8020
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
7920
8021
|
console.error('register error', error, error.message, error.stack);
|
|
7921
|
-
logger$
|
|
8022
|
+
logger$8.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
7922
8023
|
});
|
|
7923
8024
|
}
|
|
7924
8025
|
|
|
@@ -7933,7 +8034,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7933
8034
|
if (!this.client) {
|
|
7934
8035
|
return;
|
|
7935
8036
|
}
|
|
7936
|
-
logger$
|
|
8037
|
+
logger$8.info('WebRTC phone stop');
|
|
7937
8038
|
this.client.stop();
|
|
7938
8039
|
}
|
|
7939
8040
|
|
|
@@ -7948,14 +8049,14 @@ class WebRTCPhone extends Emitter {
|
|
|
7948
8049
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
7949
8050
|
audioOnly = false) {
|
|
7950
8051
|
const sipSession = this.findSipSession(callSession);
|
|
7951
|
-
logger$
|
|
8052
|
+
logger$8.info('WebRTC phone - send reinvite', {
|
|
7952
8053
|
sessionId: sipSession ? sipSession.id : null,
|
|
7953
8054
|
constraints,
|
|
7954
8055
|
audioOnly,
|
|
7955
8056
|
});
|
|
7956
8057
|
|
|
7957
8058
|
if (!sipSession) {
|
|
7958
|
-
return
|
|
8059
|
+
return false;
|
|
7959
8060
|
}
|
|
7960
8061
|
|
|
7961
8062
|
// $FlowFixMe
|
|
@@ -7965,19 +8066,17 @@ class WebRTCPhone extends Emitter {
|
|
|
7965
8066
|
// Downgrade
|
|
7966
8067
|
if (constraints && !isUpgrade) {
|
|
7967
8068
|
// No reinvite needed
|
|
7968
|
-
|
|
8069
|
+
this._downgradeToAudio(callSession);
|
|
8070
|
+
return false;
|
|
7969
8071
|
}
|
|
7970
8072
|
|
|
7971
8073
|
if (isUpgrade) {
|
|
7972
8074
|
const shouldReinvite = await this._upgradeToVideo(callSession, constraints, conference);
|
|
7973
8075
|
if (!shouldReinvite) {
|
|
7974
|
-
return;
|
|
8076
|
+
return false;
|
|
7975
8077
|
}
|
|
7976
8078
|
}
|
|
7977
8079
|
|
|
7978
|
-
// Force reinvite in SDH
|
|
7979
|
-
sipSession.sessionDescriptionHandler.localMediaStreamConstraints = null;
|
|
7980
|
-
|
|
7981
8080
|
return this.client.reinvite(sipSession, constraints, conference, audioOnly);
|
|
7982
8081
|
}
|
|
7983
8082
|
|
|
@@ -7986,7 +8085,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7986
8085
|
}
|
|
7987
8086
|
|
|
7988
8087
|
startHeartbeat() {
|
|
7989
|
-
logger$
|
|
8088
|
+
logger$8.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
7990
8089
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
7991
8090
|
return;
|
|
7992
8091
|
}
|
|
@@ -7995,7 +8094,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7995
8094
|
}
|
|
7996
8095
|
|
|
7997
8096
|
stopHeartbeat() {
|
|
7998
|
-
logger$
|
|
8097
|
+
logger$8.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
7999
8098
|
if (!this.client) {
|
|
8000
8099
|
return;
|
|
8001
8100
|
}
|
|
@@ -8012,7 +8111,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8012
8111
|
}
|
|
8013
8112
|
|
|
8014
8113
|
reconnect() {
|
|
8015
|
-
logger$
|
|
8114
|
+
logger$8.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
8016
8115
|
if (!this.client) {
|
|
8017
8116
|
return;
|
|
8018
8117
|
}
|
|
@@ -8050,7 +8149,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8050
8149
|
_downgradeToAudio(callSession ) {
|
|
8051
8150
|
const sipSession = this.findSipSession(callSession);
|
|
8052
8151
|
if (!sipSession) {
|
|
8053
|
-
return;
|
|
8152
|
+
return false;
|
|
8054
8153
|
}
|
|
8055
8154
|
|
|
8056
8155
|
// Release local video stream when downgrading to audio
|
|
@@ -8163,7 +8262,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8163
8262
|
// Monkey patch to know when canceled with the CANCEL message
|
|
8164
8263
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
8165
8264
|
sipSession._onCancel = (message ) => {
|
|
8166
|
-
logger$
|
|
8265
|
+
logger$8.trace('on sip session canceled', { callId: message.callId });
|
|
8167
8266
|
|
|
8168
8267
|
onCancel(message);
|
|
8169
8268
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
@@ -8188,13 +8287,13 @@ class WebRTCPhone extends Emitter {
|
|
|
8188
8287
|
this.audioOutputVolume,
|
|
8189
8288
|
);
|
|
8190
8289
|
case SessionState.Terminating:
|
|
8191
|
-
logger$
|
|
8290
|
+
logger$8.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
8192
8291
|
|
|
8193
8292
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
8194
8293
|
|
|
8195
8294
|
break;
|
|
8196
8295
|
case SessionState.Terminated:
|
|
8197
|
-
logger$
|
|
8296
|
+
logger$8.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
8198
8297
|
|
|
8199
8298
|
this._onCallTerminated(sipSession);
|
|
8200
8299
|
|
|
@@ -8230,7 +8329,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8230
8329
|
}
|
|
8231
8330
|
|
|
8232
8331
|
async startScreenSharing(constraints , callSession ) {
|
|
8233
|
-
logger$
|
|
8332
|
+
logger$8.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
8234
8333
|
|
|
8235
8334
|
const screenShareStream = await this._getStreamFromConstraints(constraints);
|
|
8236
8335
|
if (!screenShareStream) {
|
|
@@ -8252,6 +8351,10 @@ class WebRTCPhone extends Emitter {
|
|
|
8252
8351
|
localStream.removeTrack(videoTrack);
|
|
8253
8352
|
}
|
|
8254
8353
|
|
|
8354
|
+
if (localStream) {
|
|
8355
|
+
localStream.addTrack(screenTrack);
|
|
8356
|
+
}
|
|
8357
|
+
|
|
8255
8358
|
if (sender) {
|
|
8256
8359
|
sender.replaceTrack(screenTrack);
|
|
8257
8360
|
}
|
|
@@ -8266,7 +8369,8 @@ class WebRTCPhone extends Emitter {
|
|
|
8266
8369
|
return;
|
|
8267
8370
|
}
|
|
8268
8371
|
|
|
8269
|
-
logger$
|
|
8372
|
+
logger$8.info('WebRTC phone - stop screen sharing');
|
|
8373
|
+
let reinvited = false;
|
|
8270
8374
|
|
|
8271
8375
|
try {
|
|
8272
8376
|
if (this.currentScreenShare.stream) {
|
|
@@ -8281,7 +8385,8 @@ class WebRTCPhone extends Emitter {
|
|
|
8281
8385
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
8282
8386
|
// We have to downgrade to audio.
|
|
8283
8387
|
const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
|
|
8284
|
-
|
|
8388
|
+
const constraints = { audio: false, video: screenshareStopped };
|
|
8389
|
+
reinvited = await this.sendReinvite(targetCallSession, constraints, conference);
|
|
8285
8390
|
}
|
|
8286
8391
|
} catch (e) {
|
|
8287
8392
|
console.warn(e);
|
|
@@ -8295,6 +8400,8 @@ class WebRTCPhone extends Emitter {
|
|
|
8295
8400
|
);
|
|
8296
8401
|
|
|
8297
8402
|
this.currentScreenShare = null;
|
|
8403
|
+
|
|
8404
|
+
return reinvited;
|
|
8298
8405
|
}
|
|
8299
8406
|
|
|
8300
8407
|
async _getStreamFromConstraints(constraints , conference = false) {
|
|
@@ -8332,7 +8439,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8332
8439
|
}
|
|
8333
8440
|
|
|
8334
8441
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
8335
|
-
logger$
|
|
8442
|
+
logger$8.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
8336
8443
|
|
|
8337
8444
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
8338
8445
|
this.currentSipSession = sipSession;
|
|
@@ -8350,11 +8457,15 @@ class WebRTCPhone extends Emitter {
|
|
|
8350
8457
|
}
|
|
8351
8458
|
|
|
8352
8459
|
changeAudioDevice(id ) {
|
|
8353
|
-
logger$
|
|
8460
|
+
logger$8.info('WebRTC phone - change audio device', { deviceId: id });
|
|
8354
8461
|
this.audioOutputDeviceId = id;
|
|
8355
8462
|
this.client.changeAudioOutputDevice(id);
|
|
8356
8463
|
}
|
|
8357
8464
|
|
|
8465
|
+
createAudioElementFor(sessionId ) {
|
|
8466
|
+
return this.client.createAudioElementFor(sessionId);
|
|
8467
|
+
}
|
|
8468
|
+
|
|
8358
8469
|
changeRingDevice(id ) {
|
|
8359
8470
|
this.audioRingDeviceId = id;
|
|
8360
8471
|
}
|
|
@@ -8371,25 +8482,25 @@ class WebRTCPhone extends Emitter {
|
|
|
8371
8482
|
}
|
|
8372
8483
|
|
|
8373
8484
|
changeAudioInputDevice(id ) {
|
|
8374
|
-
logger$
|
|
8485
|
+
logger$8.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
8375
8486
|
|
|
8376
8487
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
8377
8488
|
}
|
|
8378
8489
|
|
|
8379
8490
|
changeVideoInputDevice(id ) {
|
|
8380
|
-
logger$
|
|
8491
|
+
logger$8.info('WebRTC phone - change video input device', { deviceId: id });
|
|
8381
8492
|
|
|
8382
8493
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
8383
8494
|
}
|
|
8384
8495
|
|
|
8385
8496
|
changeSessionVideoInputDevice(id ) {
|
|
8386
|
-
logger$
|
|
8497
|
+
logger$8.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
8387
8498
|
|
|
8388
8499
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
8389
8500
|
}
|
|
8390
8501
|
|
|
8391
8502
|
_onCallTerminated(sipSession ) {
|
|
8392
|
-
logger$
|
|
8503
|
+
logger$8.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
8393
8504
|
|
|
8394
8505
|
const callSession = this._createCallSession(sipSession);
|
|
8395
8506
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -8423,7 +8534,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8423
8534
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
8424
8535
|
|
|
8425
8536
|
// Re-trigger incoming call event for remaining incoming calls
|
|
8426
|
-
logger$
|
|
8537
|
+
logger$8.info('WebRTC phone - check to re-trigger incoming call', {
|
|
8427
8538
|
sipId: sipSession.id,
|
|
8428
8539
|
shouldRetrigger,
|
|
8429
8540
|
hasIncomingCallSession,
|
|
@@ -8512,37 +8623,37 @@ class WebRTCPhone extends Emitter {
|
|
|
8512
8623
|
|
|
8513
8624
|
// Deprecated
|
|
8514
8625
|
getLocalStreamForCall(callSession ) {
|
|
8515
|
-
logger$
|
|
8626
|
+
logger$8.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
8516
8627
|
|
|
8517
8628
|
return this.getLocalStream(callSession);
|
|
8518
8629
|
}
|
|
8519
8630
|
|
|
8520
8631
|
// Deprecated
|
|
8521
8632
|
getRemoteStreamForCall(callSession ) {
|
|
8522
|
-
logger$
|
|
8633
|
+
logger$8.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
8523
8634
|
|
|
8524
8635
|
return this.getRemoteVideoStream(callSession);
|
|
8525
8636
|
}
|
|
8526
8637
|
|
|
8527
8638
|
getRemoteStreamsForCall(callSession ) {
|
|
8528
|
-
logger$
|
|
8639
|
+
logger$8.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
8529
8640
|
|
|
8530
8641
|
return this.getRemoteStream(callSession);
|
|
8531
8642
|
}
|
|
8532
8643
|
|
|
8533
8644
|
accept(callSession , cameraEnabled ) {
|
|
8534
|
-
logger$
|
|
8645
|
+
logger$8.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
8535
8646
|
if (this.currentSipSession) {
|
|
8536
8647
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
8537
8648
|
}
|
|
8538
8649
|
|
|
8539
8650
|
if (!callSession) {
|
|
8540
|
-
logger$
|
|
8651
|
+
logger$8.warn('no CallSession to accept.');
|
|
8541
8652
|
return Promise.resolve(null);
|
|
8542
8653
|
}
|
|
8543
8654
|
|
|
8544
8655
|
if (callSession.getId() in this.acceptedSessions) {
|
|
8545
|
-
logger$
|
|
8656
|
+
logger$8.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
8546
8657
|
return Promise.resolve(callSession.sipCallId);
|
|
8547
8658
|
}
|
|
8548
8659
|
|
|
@@ -8554,24 +8665,24 @@ class WebRTCPhone extends Emitter {
|
|
|
8554
8665
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
8555
8666
|
if (sipSession) {
|
|
8556
8667
|
if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
|
|
8557
|
-
logger$
|
|
8668
|
+
logger$8.warn('Trying to answer a terminated sipSession.');
|
|
8558
8669
|
|
|
8559
8670
|
return Promise.resolve(null);
|
|
8560
8671
|
}
|
|
8561
8672
|
|
|
8562
|
-
logger$
|
|
8673
|
+
logger$8.info('accept call, session found', { sipId: sipSession.id });
|
|
8563
8674
|
|
|
8564
8675
|
// $FlowFixMe
|
|
8565
8676
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
8566
8677
|
return callSession.sipCallId;
|
|
8567
8678
|
}).catch(e => {
|
|
8568
|
-
logger$
|
|
8679
|
+
logger$8.error(e);
|
|
8569
8680
|
this.endCurrentCall(callSession);
|
|
8570
8681
|
throw e;
|
|
8571
8682
|
});
|
|
8572
8683
|
}
|
|
8573
8684
|
|
|
8574
|
-
logger$
|
|
8685
|
+
logger$8.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
8575
8686
|
|
|
8576
8687
|
return Promise.resolve(null);
|
|
8577
8688
|
}
|
|
@@ -8581,7 +8692,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8581
8692
|
}
|
|
8582
8693
|
|
|
8583
8694
|
async reject(callSession ) {
|
|
8584
|
-
logger$
|
|
8695
|
+
logger$8.info('reject WebRTC called', { id: callSession.getId() });
|
|
8585
8696
|
|
|
8586
8697
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
8587
8698
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -8593,14 +8704,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8593
8704
|
|
|
8594
8705
|
const sipSession = this.findSipSession(callSession);
|
|
8595
8706
|
if (sipSession) {
|
|
8596
|
-
logger$
|
|
8707
|
+
logger$8.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
8597
8708
|
|
|
8598
8709
|
this.client.hangup(sipSession);
|
|
8599
8710
|
}
|
|
8600
8711
|
}
|
|
8601
8712
|
|
|
8602
8713
|
async ignore(callSession ) {
|
|
8603
|
-
logger$
|
|
8714
|
+
logger$8.info('WebRTC ignore', { id: callSession.getId() });
|
|
8604
8715
|
|
|
8605
8716
|
// kill the ring
|
|
8606
8717
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -8609,7 +8720,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8609
8720
|
}
|
|
8610
8721
|
|
|
8611
8722
|
hold(callSession , withEvent = true, isConference = false) {
|
|
8612
|
-
logger$
|
|
8723
|
+
logger$8.info('WebRTC hold', { id: callSession.getId() });
|
|
8613
8724
|
|
|
8614
8725
|
const sipSession = this.findSipSession(callSession);
|
|
8615
8726
|
|
|
@@ -8620,7 +8731,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8620
8731
|
|
|
8621
8732
|
// @Deprecated
|
|
8622
8733
|
unhold(callSession , withEvent = true, isConference = false) {
|
|
8623
|
-
logger$
|
|
8734
|
+
logger$8.info('WebRTC unhold', { id: callSession ? callSession.getId() : null });
|
|
8624
8735
|
|
|
8625
8736
|
console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
|
|
8626
8737
|
|
|
@@ -8635,7 +8746,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8635
8746
|
const sipSession = this.findSipSession(callSession);
|
|
8636
8747
|
|
|
8637
8748
|
if (sipSession) {
|
|
8638
|
-
logger$
|
|
8749
|
+
logger$8.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
8639
8750
|
|
|
8640
8751
|
return this.client.atxfer(sipSession);
|
|
8641
8752
|
}
|
|
@@ -8650,7 +8761,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8650
8761
|
if (!sipSession) {
|
|
8651
8762
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
8652
8763
|
}
|
|
8653
|
-
logger$
|
|
8764
|
+
logger$8.info('WebRTC hold sip session', { sipId: sipSession.id });
|
|
8654
8765
|
|
|
8655
8766
|
const promise = this.client.hold(sipSession, isConference);
|
|
8656
8767
|
if (withEvent) {
|
|
@@ -8669,7 +8780,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8669
8780
|
if (!sipSession) {
|
|
8670
8781
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
8671
8782
|
}
|
|
8672
|
-
logger$
|
|
8783
|
+
logger$8.info('WebRTC unhold', { sipId: sipSession.id });
|
|
8673
8784
|
|
|
8674
8785
|
const promise = this.client.unhold(sipSession, isConference);
|
|
8675
8786
|
if (withEvent) {
|
|
@@ -8680,18 +8791,18 @@ class WebRTCPhone extends Emitter {
|
|
|
8680
8791
|
}
|
|
8681
8792
|
|
|
8682
8793
|
resume(callSession , isConference = false) {
|
|
8683
|
-
logger$
|
|
8794
|
+
logger$8.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
8684
8795
|
|
|
8685
8796
|
const sipSession = this.findSipSession(callSession);
|
|
8686
8797
|
if (!sipSession) {
|
|
8687
8798
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
8688
8799
|
}
|
|
8689
8800
|
|
|
8690
|
-
logger$
|
|
8801
|
+
logger$8.info('WebRTC resuming', { sipId: sipSession.id });
|
|
8691
8802
|
|
|
8692
8803
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
8693
8804
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
8694
|
-
logger$
|
|
8805
|
+
logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
8695
8806
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
8696
8807
|
}
|
|
8697
8808
|
|
|
@@ -8706,14 +8817,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8706
8817
|
}
|
|
8707
8818
|
|
|
8708
8819
|
mute(callSession , withEvent = true) {
|
|
8709
|
-
logger$
|
|
8820
|
+
logger$8.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
8710
8821
|
|
|
8711
8822
|
const sipSession = this.findSipSession(callSession);
|
|
8712
8823
|
if (!sipSession) {
|
|
8713
8824
|
return;
|
|
8714
8825
|
}
|
|
8715
8826
|
|
|
8716
|
-
logger$
|
|
8827
|
+
logger$8.info('WebRTC muting', { sipId: sipSession.id });
|
|
8717
8828
|
this.client.mute(sipSession);
|
|
8718
8829
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
8719
8830
|
|
|
@@ -8727,14 +8838,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8727
8838
|
}
|
|
8728
8839
|
|
|
8729
8840
|
unmute(callSession , withEvent = true) {
|
|
8730
|
-
logger$
|
|
8841
|
+
logger$8.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
8731
8842
|
|
|
8732
8843
|
const sipSession = this.findSipSession(callSession);
|
|
8733
8844
|
if (!sipSession) {
|
|
8734
8845
|
return;
|
|
8735
8846
|
}
|
|
8736
8847
|
|
|
8737
|
-
logger$
|
|
8848
|
+
logger$8.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
8738
8849
|
this.client.unmute(sipSession);
|
|
8739
8850
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
8740
8851
|
|
|
@@ -8761,7 +8872,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8761
8872
|
if (!sipSession) {
|
|
8762
8873
|
return;
|
|
8763
8874
|
}
|
|
8764
|
-
logger$
|
|
8875
|
+
logger$8.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
8765
8876
|
|
|
8766
8877
|
this.client.toggleCameraOn(sipSession);
|
|
8767
8878
|
|
|
@@ -8773,7 +8884,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8773
8884
|
if (!sipSession) {
|
|
8774
8885
|
return;
|
|
8775
8886
|
}
|
|
8776
|
-
logger$
|
|
8887
|
+
logger$8.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
8777
8888
|
|
|
8778
8889
|
this.client.toggleCameraOff(sipSession);
|
|
8779
8890
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -8785,7 +8896,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8785
8896
|
return;
|
|
8786
8897
|
}
|
|
8787
8898
|
|
|
8788
|
-
logger$
|
|
8899
|
+
logger$8.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
8789
8900
|
this.client.sendDTMF(sipSession, tone);
|
|
8790
8901
|
}
|
|
8791
8902
|
|
|
@@ -8793,7 +8904,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8793
8904
|
// @TODO: line is not used here
|
|
8794
8905
|
async makeCall(number , line , cameraEnabled ,
|
|
8795
8906
|
audioOnly = false, conference = false) {
|
|
8796
|
-
logger$
|
|
8907
|
+
logger$8.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
8797
8908
|
if (!number) {
|
|
8798
8909
|
return Promise.resolve(null);
|
|
8799
8910
|
}
|
|
@@ -8803,7 +8914,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8803
8914
|
}
|
|
8804
8915
|
if (this.currentSipSession) {
|
|
8805
8916
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
8806
|
-
logger$
|
|
8917
|
+
logger$8.warn('Unable to hold current session when making another call', e);
|
|
8807
8918
|
});
|
|
8808
8919
|
}
|
|
8809
8920
|
|
|
@@ -8813,7 +8924,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8813
8924
|
this._bindEvents(sipSession);
|
|
8814
8925
|
} catch (error) {
|
|
8815
8926
|
console.warn(error);
|
|
8816
|
-
logger$
|
|
8927
|
+
logger$8.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
8817
8928
|
return Promise.resolve(null);
|
|
8818
8929
|
}
|
|
8819
8930
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -8841,7 +8952,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8841
8952
|
return;
|
|
8842
8953
|
}
|
|
8843
8954
|
|
|
8844
|
-
logger$
|
|
8955
|
+
logger$8.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
8845
8956
|
|
|
8846
8957
|
this.client.transfer(sipSession, target);
|
|
8847
8958
|
}
|
|
@@ -8850,7 +8961,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8850
8961
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
8851
8962
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
8852
8963
|
|
|
8853
|
-
logger$
|
|
8964
|
+
logger$8.info('WebRTC indirect transfer', {
|
|
8854
8965
|
sipId: sipSession ? sipSession.id : null,
|
|
8855
8966
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
8856
8967
|
});
|
|
@@ -8878,7 +8989,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8878
8989
|
return false;
|
|
8879
8990
|
}
|
|
8880
8991
|
|
|
8881
|
-
logger$
|
|
8992
|
+
logger$8.info('WebRTC hangup', { sipId: sipSession.id });
|
|
8882
8993
|
|
|
8883
8994
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
8884
8995
|
|
|
@@ -8923,7 +9034,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8923
9034
|
}
|
|
8924
9035
|
|
|
8925
9036
|
async close() {
|
|
8926
|
-
logger$
|
|
9037
|
+
logger$8.info('WebRTC close');
|
|
8927
9038
|
|
|
8928
9039
|
try {
|
|
8929
9040
|
await Promise.race([
|
|
@@ -8931,7 +9042,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8931
9042
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
8932
9043
|
]);
|
|
8933
9044
|
} catch (e) {
|
|
8934
|
-
logger$
|
|
9045
|
+
logger$8.error('WebRTC close, unregister error', e);
|
|
8935
9046
|
}
|
|
8936
9047
|
|
|
8937
9048
|
this.client.close();
|
|
@@ -8949,12 +9060,12 @@ class WebRTCPhone extends Emitter {
|
|
|
8949
9060
|
}
|
|
8950
9061
|
|
|
8951
9062
|
enableRinging() {
|
|
8952
|
-
logger$
|
|
9063
|
+
logger$8.info('WebRTC enable ringing');
|
|
8953
9064
|
this.ringingEnabled = true;
|
|
8954
9065
|
}
|
|
8955
9066
|
|
|
8956
9067
|
disableRinging() {
|
|
8957
|
-
logger$
|
|
9068
|
+
logger$8.info('WebRTC disable ringing');
|
|
8958
9069
|
this.ringingEnabled = false;
|
|
8959
9070
|
}
|
|
8960
9071
|
|
|
@@ -8994,7 +9105,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8994
9105
|
|
|
8995
9106
|
// Deprecated
|
|
8996
9107
|
getLocalMediaStream(callSession ) {
|
|
8997
|
-
logger$
|
|
9108
|
+
logger$8.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
8998
9109
|
return this.getLocalStream(callSession);
|
|
8999
9110
|
}
|
|
9000
9111
|
|
|
@@ -9002,6 +9113,10 @@ class WebRTCPhone extends Emitter {
|
|
|
9002
9113
|
return callSession ? this.client.hasLocalVideo(callSession.sipCallId) : null;
|
|
9003
9114
|
}
|
|
9004
9115
|
|
|
9116
|
+
hasALocalVideoTrack(callSession ) {
|
|
9117
|
+
return callSession ? this.client.hasALocalVideoTrack(callSession.sipCallId) : null;
|
|
9118
|
+
}
|
|
9119
|
+
|
|
9005
9120
|
getRemoteStream(callSession ) {
|
|
9006
9121
|
return callSession ? this.client.getRemoteStream(callSession.sipCallId) : null;
|
|
9007
9122
|
}
|
|
@@ -9024,7 +9139,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9024
9139
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
9025
9140
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
9026
9141
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
9027
|
-
logger$
|
|
9142
|
+
logger$8.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
9028
9143
|
|
|
9029
9144
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
9030
9145
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -9047,7 +9162,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9047
9162
|
});
|
|
9048
9163
|
|
|
9049
9164
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
9050
|
-
logger$
|
|
9165
|
+
logger$8.info('WebRTC on reinvite', {
|
|
9051
9166
|
sessionId: args[0].id,
|
|
9052
9167
|
inviteId: args[1].id,
|
|
9053
9168
|
updatedCalleeName: args[2],
|
|
@@ -9067,7 +9182,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9067
9182
|
});
|
|
9068
9183
|
|
|
9069
9184
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
9070
|
-
logger$
|
|
9185
|
+
logger$8.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
9071
9186
|
|
|
9072
9187
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
9073
9188
|
|
|
@@ -9078,17 +9193,17 @@ class WebRTCPhone extends Emitter {
|
|
|
9078
9193
|
this.client.on('ended', () => {});
|
|
9079
9194
|
|
|
9080
9195
|
this.client.on(this.client.ON_ERROR, e => {
|
|
9081
|
-
logger$
|
|
9196
|
+
logger$8.error('WebRTC error', e);
|
|
9082
9197
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
9083
9198
|
});
|
|
9084
9199
|
|
|
9085
9200
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
9086
|
-
logger$
|
|
9201
|
+
logger$8.info('WebRTC unregistered');
|
|
9087
9202
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9088
9203
|
});
|
|
9089
9204
|
|
|
9090
9205
|
this.client.on(this.client.REGISTERED, () => {
|
|
9091
|
-
logger$
|
|
9206
|
+
logger$8.info('WebRTC registered', {
|
|
9092
9207
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
9093
9208
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
9094
9209
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -9104,19 +9219,19 @@ class WebRTCPhone extends Emitter {
|
|
|
9104
9219
|
try {
|
|
9105
9220
|
this.sendReinvite(this.currentCallSession);
|
|
9106
9221
|
} catch (e) {
|
|
9107
|
-
logger$
|
|
9222
|
+
logger$8.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
9108
9223
|
}
|
|
9109
9224
|
}
|
|
9110
9225
|
});
|
|
9111
9226
|
|
|
9112
9227
|
this.client.on(this.client.CONNECTED, () => {
|
|
9113
|
-
logger$
|
|
9228
|
+
logger$8.info('WebRTC client connected');
|
|
9114
9229
|
|
|
9115
9230
|
this.stopHeartbeat();
|
|
9116
9231
|
});
|
|
9117
9232
|
|
|
9118
9233
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
9119
|
-
logger$
|
|
9234
|
+
logger$8.info('WebRTC client disconnected');
|
|
9120
9235
|
|
|
9121
9236
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9122
9237
|
|
|
@@ -9348,7 +9463,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
9348
9463
|
|
|
9349
9464
|
//
|
|
9350
9465
|
|
|
9351
|
-
const logger$
|
|
9466
|
+
const logger$7 = IssueReporter$1.loggerFor('simple-phone');
|
|
9352
9467
|
const sipLogger = IssueReporter$1.loggerFor('sip.js');
|
|
9353
9468
|
const protocolLogger = IssueReporter$1.loggerFor('sip');
|
|
9354
9469
|
|
|
@@ -9455,7 +9570,7 @@ class Phone extends Emitter {
|
|
|
9455
9570
|
async disconnect() {
|
|
9456
9571
|
if (this.phone) {
|
|
9457
9572
|
if (this.phone.hasAnActiveCall()) {
|
|
9458
|
-
logger$
|
|
9573
|
+
logger$7.info('hangup call on disconnect');
|
|
9459
9574
|
// $FlowFixMe
|
|
9460
9575
|
await this.phone.hangup();
|
|
9461
9576
|
}
|
|
@@ -9478,13 +9593,13 @@ class Phone extends Emitter {
|
|
|
9478
9593
|
}
|
|
9479
9594
|
|
|
9480
9595
|
async hangup(callSession ) {
|
|
9481
|
-
logger$
|
|
9596
|
+
logger$7.info('hangup via simple phone', { callId: callSession.getId() });
|
|
9482
9597
|
|
|
9483
9598
|
return this.phone && this.phone.hangup(callSession);
|
|
9484
9599
|
}
|
|
9485
9600
|
|
|
9486
9601
|
async accept(callSession , cameraEnabled ) {
|
|
9487
|
-
logger$
|
|
9602
|
+
logger$7.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
|
|
9488
9603
|
|
|
9489
9604
|
return this.phone && this.phone.accept(callSession, cameraEnabled);
|
|
9490
9605
|
}
|
|
@@ -9504,13 +9619,18 @@ class Phone extends Emitter {
|
|
|
9504
9619
|
return adHocConference.start();
|
|
9505
9620
|
}
|
|
9506
9621
|
|
|
9507
|
-
mute(callSession ) {
|
|
9508
|
-
|
|
9622
|
+
mute(callSession , withApi = true) {
|
|
9623
|
+
if (withApi) {
|
|
9624
|
+
this.muteViaAPI(callSession);
|
|
9625
|
+
}
|
|
9626
|
+
|
|
9509
9627
|
return this.phone && this.phone.mute(callSession);
|
|
9510
9628
|
}
|
|
9511
9629
|
|
|
9512
|
-
unmute(callSession ) {
|
|
9513
|
-
|
|
9630
|
+
unmute(callSession , withApi = true) {
|
|
9631
|
+
if (withApi) {
|
|
9632
|
+
this.unmuteViaAPI(callSession);
|
|
9633
|
+
}
|
|
9514
9634
|
|
|
9515
9635
|
return this.phone && this.phone.unmute(callSession);
|
|
9516
9636
|
}
|
|
@@ -9518,7 +9638,7 @@ class Phone extends Emitter {
|
|
|
9518
9638
|
muteViaAPI(callSession ) {
|
|
9519
9639
|
if (callSession && callSession.callId) {
|
|
9520
9640
|
Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
|
|
9521
|
-
logger$
|
|
9641
|
+
logger$7.error('Mute via API, error', e);
|
|
9522
9642
|
});
|
|
9523
9643
|
}
|
|
9524
9644
|
}
|
|
@@ -9526,7 +9646,7 @@ class Phone extends Emitter {
|
|
|
9526
9646
|
unmuteViaAPI(callSession ) {
|
|
9527
9647
|
if (callSession && callSession.callId) {
|
|
9528
9648
|
Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
|
|
9529
|
-
logger$
|
|
9649
|
+
logger$7.error('Unmute via API, error', e);
|
|
9530
9650
|
});
|
|
9531
9651
|
}
|
|
9532
9652
|
}
|
|
@@ -9616,9 +9736,13 @@ class Phone extends Emitter {
|
|
|
9616
9736
|
return this.phone && this.phone.hasLocalVideo(callSession);
|
|
9617
9737
|
}
|
|
9618
9738
|
|
|
9739
|
+
hasALocalVideoTrack(callSession ) {
|
|
9740
|
+
return this.phone && this.phone.hasALocalVideoTrack(callSession);
|
|
9741
|
+
}
|
|
9742
|
+
|
|
9619
9743
|
// @Deprecated
|
|
9620
9744
|
getLocalMediaStream(callSession ) {
|
|
9621
|
-
logger$
|
|
9745
|
+
logger$7.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
9622
9746
|
|
|
9623
9747
|
return this.phone && this.phone.getLocalStream(callSession);
|
|
9624
9748
|
}
|
|
@@ -9637,20 +9761,20 @@ class Phone extends Emitter {
|
|
|
9637
9761
|
|
|
9638
9762
|
// @Deprecated
|
|
9639
9763
|
getRemoteStreamForCall(callSession ) {
|
|
9640
|
-
logger$
|
|
9764
|
+
logger$7.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
9641
9765
|
return this.getRemoteStream(callSession);
|
|
9642
9766
|
}
|
|
9643
9767
|
|
|
9644
9768
|
// Returns remote streams directly from the peerConnection
|
|
9645
9769
|
// @Deprecated
|
|
9646
9770
|
getRemoteStreamsForCall(callSession ) {
|
|
9647
|
-
logger$
|
|
9771
|
+
logger$7.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
9648
9772
|
return this.getLocalStream(callSession);
|
|
9649
9773
|
}
|
|
9650
9774
|
|
|
9651
9775
|
// @Deprecated
|
|
9652
9776
|
getRemoteVideoStreamForCall(callSession ) {
|
|
9653
|
-
logger$
|
|
9777
|
+
logger$7.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
9654
9778
|
|
|
9655
9779
|
return this.getRemoteVideoStream(callSession);
|
|
9656
9780
|
}
|
|
@@ -9780,6 +9904,8 @@ const CONFERENCE_USER_PARTICIPANT_JOINED = 'conference_user_participant_joined';
|
|
|
9780
9904
|
const CONFERENCE_USER_PARTICIPANT_LEFT = 'conference_user_participant_left';
|
|
9781
9905
|
const CONFERENCE_USER_PARTICIPANT_TALK_STARTED = 'conference_user_participant_talk_started';
|
|
9782
9906
|
const CONFERENCE_USER_PARTICIPANT_TALK_STOPPED = 'conference_user_participant_talk_stopped';
|
|
9907
|
+
const MEETING_USER_PARTICIPANT_JOINED = 'meeting_user_participant_joined';
|
|
9908
|
+
const MEETING_USER_PARTICIPANT_LEFT = 'meeting_user_participant_left';
|
|
9783
9909
|
const SWITCHBOARD_QUEUED_CALLS_UPDATED = 'switchboard_queued_calls_updated';
|
|
9784
9910
|
const SWITCHBOARD_QUEUED_CALL_ANSWERED = 'switchboard_queued_call_answered';
|
|
9785
9911
|
const SWITCHBOARD_HELD_CALLS_UPDATED = 'switchboard_held_calls_updated';
|
|
@@ -9821,7 +9947,7 @@ const BLACKLIST_EVENTS = [
|
|
|
9821
9947
|
];
|
|
9822
9948
|
|
|
9823
9949
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
9824
|
-
const logger$
|
|
9950
|
+
const logger$6 = IssueReporter$1.loggerFor('wazo-ws');
|
|
9825
9951
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
9826
9952
|
|
|
9827
9953
|
class WebSocketClient extends Emitter {
|
|
@@ -9870,19 +9996,19 @@ class WebSocketClient extends Emitter {
|
|
|
9870
9996
|
}
|
|
9871
9997
|
|
|
9872
9998
|
connect() {
|
|
9873
|
-
logger$
|
|
9999
|
+
logger$6.info('connect method started', { host: this.host, token: this.token });
|
|
9874
10000
|
this.socket = new ReconnectingWebSocket(this._getUrl.bind(this), [], this.options);
|
|
9875
10001
|
if (this.options.binaryType) {
|
|
9876
10002
|
this.socket.binaryType = this.options.binaryType;
|
|
9877
10003
|
}
|
|
9878
10004
|
|
|
9879
10005
|
this.socket.onopen = () => {
|
|
9880
|
-
logger$
|
|
10006
|
+
logger$6.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
9881
10007
|
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
|
|
9882
10008
|
};
|
|
9883
10009
|
|
|
9884
10010
|
this.socket.onerror = event => {
|
|
9885
|
-
logger$
|
|
10011
|
+
logger$6.error('on Wazo WS error', event.target);
|
|
9886
10012
|
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
|
|
9887
10013
|
};
|
|
9888
10014
|
|
|
@@ -9912,7 +10038,7 @@ class WebSocketClient extends Emitter {
|
|
|
9912
10038
|
|
|
9913
10039
|
this.socket.onclose = event => {
|
|
9914
10040
|
// Can't be converted to JSON (circular structure)
|
|
9915
|
-
logger$
|
|
10041
|
+
logger$6.info('on Wazo WS close', {
|
|
9916
10042
|
reason: event.reason,
|
|
9917
10043
|
code: event.code,
|
|
9918
10044
|
readyState: event.target.readyState,
|
|
@@ -9930,12 +10056,12 @@ class WebSocketClient extends Emitter {
|
|
|
9930
10056
|
};
|
|
9931
10057
|
|
|
9932
10058
|
this.socket.onerror = event => {
|
|
9933
|
-
logger$
|
|
10059
|
+
logger$6.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
9934
10060
|
};
|
|
9935
10061
|
}
|
|
9936
10062
|
|
|
9937
10063
|
close(force = false) {
|
|
9938
|
-
logger$
|
|
10064
|
+
logger$6.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
9939
10065
|
|
|
9940
10066
|
if (!this.socket) {
|
|
9941
10067
|
return;
|
|
@@ -9953,7 +10079,7 @@ class WebSocketClient extends Emitter {
|
|
|
9953
10079
|
|
|
9954
10080
|
updateToken(token ) {
|
|
9955
10081
|
this.token = token;
|
|
9956
|
-
logger$
|
|
10082
|
+
logger$6.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
9957
10083
|
|
|
9958
10084
|
if (this.socket) {
|
|
9959
10085
|
// If still connected, send the token to the WS
|
|
@@ -9971,7 +10097,7 @@ class WebSocketClient extends Emitter {
|
|
|
9971
10097
|
}
|
|
9972
10098
|
|
|
9973
10099
|
startHeartbeat() {
|
|
9974
|
-
logger$
|
|
10100
|
+
logger$6.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
9975
10101
|
|
|
9976
10102
|
if (!this.socket) {
|
|
9977
10103
|
this.heartbeat.stop();
|
|
@@ -9985,7 +10111,7 @@ class WebSocketClient extends Emitter {
|
|
|
9985
10111
|
}
|
|
9986
10112
|
|
|
9987
10113
|
stopHeartbeat() {
|
|
9988
|
-
logger$
|
|
10114
|
+
logger$6.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
9989
10115
|
|
|
9990
10116
|
this.heartbeat.stop();
|
|
9991
10117
|
}
|
|
@@ -10015,7 +10141,7 @@ class WebSocketClient extends Emitter {
|
|
|
10015
10141
|
}
|
|
10016
10142
|
|
|
10017
10143
|
reconnect(reason ) {
|
|
10018
|
-
logger$
|
|
10144
|
+
logger$6.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
10019
10145
|
if (!this.socket) {
|
|
10020
10146
|
return;
|
|
10021
10147
|
}
|
|
@@ -10071,7 +10197,7 @@ class WebSocketClient extends Emitter {
|
|
|
10071
10197
|
this.close();
|
|
10072
10198
|
}
|
|
10073
10199
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
10074
|
-
logger$
|
|
10200
|
+
logger$6.log('Wazo WS url computed to reconnect', { url });
|
|
10075
10201
|
|
|
10076
10202
|
return url;
|
|
10077
10203
|
}
|
|
@@ -10079,12 +10205,12 @@ class WebSocketClient extends Emitter {
|
|
|
10079
10205
|
_onHeartbeat(message ) {
|
|
10080
10206
|
if (message.payload === 'pong') {
|
|
10081
10207
|
this.heartbeat.onHeartbeat();
|
|
10082
|
-
logger$
|
|
10208
|
+
logger$6.log('on heartbeat received from Wazo WS');
|
|
10083
10209
|
}
|
|
10084
10210
|
}
|
|
10085
10211
|
|
|
10086
10212
|
async _onHeartbeatTimeout() {
|
|
10087
|
-
logger$
|
|
10213
|
+
logger$6.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
10088
10214
|
|
|
10089
10215
|
this.close();
|
|
10090
10216
|
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
@@ -10126,6 +10252,8 @@ WebSocketClient.eventLists = [
|
|
|
10126
10252
|
CHATD_USER_ROOM_CREATED,
|
|
10127
10253
|
CONFERENCE_USER_PARTICIPANT_JOINED,
|
|
10128
10254
|
CONFERENCE_USER_PARTICIPANT_LEFT,
|
|
10255
|
+
MEETING_USER_PARTICIPANT_JOINED,
|
|
10256
|
+
MEETING_USER_PARTICIPANT_LEFT,
|
|
10129
10257
|
CONFERENCE_USER_PARTICIPANT_TALK_STARTED,
|
|
10130
10258
|
CONFERENCE_USER_PARTICIPANT_TALK_STOPPED,
|
|
10131
10259
|
SWITCHBOARD_QUEUED_CALLS_UPDATED,
|
|
@@ -10196,6 +10324,8 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
10196
10324
|
CONFERENCE_USER_PARTICIPANT_LEFT: CONFERENCE_USER_PARTICIPANT_LEFT,
|
|
10197
10325
|
CONFERENCE_USER_PARTICIPANT_TALK_STARTED: CONFERENCE_USER_PARTICIPANT_TALK_STARTED,
|
|
10198
10326
|
CONFERENCE_USER_PARTICIPANT_TALK_STOPPED: CONFERENCE_USER_PARTICIPANT_TALK_STOPPED,
|
|
10327
|
+
MEETING_USER_PARTICIPANT_JOINED: MEETING_USER_PARTICIPANT_JOINED,
|
|
10328
|
+
MEETING_USER_PARTICIPANT_LEFT: MEETING_USER_PARTICIPANT_LEFT,
|
|
10199
10329
|
SWITCHBOARD_QUEUED_CALLS_UPDATED: SWITCHBOARD_QUEUED_CALLS_UPDATED,
|
|
10200
10330
|
SWITCHBOARD_QUEUED_CALL_ANSWERED: SWITCHBOARD_QUEUED_CALL_ANSWERED,
|
|
10201
10331
|
SWITCHBOARD_HELD_CALLS_UPDATED: SWITCHBOARD_HELD_CALLS_UPDATED,
|
|
@@ -10237,7 +10367,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
10237
10367
|
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
10238
10368
|
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
10239
10369
|
|
|
10240
|
-
const logger$
|
|
10370
|
+
const logger$5 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
10241
10371
|
|
|
10242
10372
|
class Websocket extends Emitter {
|
|
10243
10373
|
|
|
@@ -10261,7 +10391,7 @@ class Websocket extends Emitter {
|
|
|
10261
10391
|
}
|
|
10262
10392
|
|
|
10263
10393
|
open(host , session ) {
|
|
10264
|
-
logger$
|
|
10394
|
+
logger$5.info('open simple WebSocket', { host, token: session.token });
|
|
10265
10395
|
this.ws = new WebSocketClient(
|
|
10266
10396
|
{
|
|
10267
10397
|
host,
|
|
@@ -10289,7 +10419,7 @@ class Websocket extends Emitter {
|
|
|
10289
10419
|
}
|
|
10290
10420
|
|
|
10291
10421
|
updateToken(token ) {
|
|
10292
|
-
logger$
|
|
10422
|
+
logger$5.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
10293
10423
|
|
|
10294
10424
|
if (!this.ws) {
|
|
10295
10425
|
return;
|
|
@@ -10317,7 +10447,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
10317
10447
|
|
|
10318
10448
|
//
|
|
10319
10449
|
|
|
10320
|
-
const logger$
|
|
10450
|
+
const logger$4 = IssueReporter$1.loggerFor('room');
|
|
10321
10451
|
|
|
10322
10452
|
class Participant extends Emitter {
|
|
10323
10453
|
|
|
@@ -10351,6 +10481,7 @@ class Participant extends Emitter {
|
|
|
10351
10481
|
|
|
10352
10482
|
|
|
10353
10483
|
/**
|
|
10484
|
+
* @param room Room The room where the participant is
|
|
10354
10485
|
* @param rawParticipant string Participant sent via the Wazo WS
|
|
10355
10486
|
* @param extra Object extra status of the participant
|
|
10356
10487
|
*/
|
|
@@ -10438,7 +10569,7 @@ class Participant extends Emitter {
|
|
|
10438
10569
|
}
|
|
10439
10570
|
|
|
10440
10571
|
onTalking(isTalking ) {
|
|
10441
|
-
logger$
|
|
10572
|
+
logger$4.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
10442
10573
|
this.isTalking = isTalking;
|
|
10443
10574
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
10444
10575
|
// directly from asterisk, there's no need to do so
|
|
@@ -10541,7 +10672,7 @@ class Participant extends Emitter {
|
|
|
10541
10672
|
}
|
|
10542
10673
|
|
|
10543
10674
|
updateStatus(status , broadcast = true) {
|
|
10544
|
-
logger$
|
|
10675
|
+
logger$4.info('updating participant status', { name: this.name, status });
|
|
10545
10676
|
|
|
10546
10677
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
10547
10678
|
if (status.audioMuted) {
|
|
@@ -10578,13 +10709,18 @@ class Participant extends Emitter {
|
|
|
10578
10709
|
// Poor man's object comparison
|
|
10579
10710
|
if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
|
|
10580
10711
|
this.extra = { ...this.extra, ...status.extra };
|
|
10712
|
+
|
|
10713
|
+
if (this.extra.contact && !(this.extra.contact instanceof Contact)) {
|
|
10714
|
+
this.extra.contact = new Contact(this.extra.contact);
|
|
10715
|
+
}
|
|
10716
|
+
|
|
10581
10717
|
this.triggerUpdate(this.ON_EXTRA_CHANGE, broadcast);
|
|
10582
10718
|
}
|
|
10583
10719
|
}
|
|
10584
10720
|
|
|
10585
10721
|
broadcastStatus(inboundStatus = null) {
|
|
10586
10722
|
const status = inboundStatus || this.getStatus();
|
|
10587
|
-
logger$
|
|
10723
|
+
logger$4.info('broadcasting participant status', { callId: this.callId, status });
|
|
10588
10724
|
|
|
10589
10725
|
this.room.sendSignal({
|
|
10590
10726
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -10605,18 +10741,24 @@ class RemoteParticipant extends Participant {
|
|
|
10605
10741
|
}
|
|
10606
10742
|
}
|
|
10607
10743
|
|
|
10608
|
-
|
|
10744
|
+
//
|
|
10745
|
+
|
|
10746
|
+
class LocalParticipant extends Participant {
|
|
10747
|
+
}
|
|
10748
|
+
|
|
10749
|
+
//
|
|
10609
10750
|
|
|
10610
10751
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
10611
10752
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
10612
10753
|
|
|
10613
|
-
const logger$
|
|
10754
|
+
const logger$3 = IssueReporter$1.loggerFor('sdk-room');
|
|
10614
10755
|
|
|
10615
10756
|
class Room$1 extends Emitter {
|
|
10616
10757
|
|
|
10617
10758
|
|
|
10618
10759
|
|
|
10619
10760
|
|
|
10761
|
+
|
|
10620
10762
|
|
|
10621
10763
|
|
|
10622
10764
|
|
|
@@ -10638,6 +10780,8 @@ class Room$1 extends Emitter {
|
|
|
10638
10780
|
|
|
10639
10781
|
|
|
10640
10782
|
|
|
10783
|
+
|
|
10784
|
+
|
|
10641
10785
|
|
|
10642
10786
|
|
|
10643
10787
|
|
|
@@ -10655,6 +10799,7 @@ class Room$1 extends Emitter {
|
|
|
10655
10799
|
* @param extension string
|
|
10656
10800
|
* @param sourceId number
|
|
10657
10801
|
* @param callId string
|
|
10802
|
+
* @param meetingUuid string
|
|
10658
10803
|
* @param extra Object
|
|
10659
10804
|
*/
|
|
10660
10805
|
constructor(
|
|
@@ -10662,15 +10807,17 @@ class Room$1 extends Emitter {
|
|
|
10662
10807
|
extension ,
|
|
10663
10808
|
sourceId ,
|
|
10664
10809
|
callId ,
|
|
10810
|
+
meetingUuid ,
|
|
10665
10811
|
extra = {},
|
|
10666
10812
|
) {
|
|
10667
10813
|
super();
|
|
10668
|
-
logger$
|
|
10814
|
+
logger$3.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
10669
10815
|
|
|
10670
10816
|
// Represents the room callSession
|
|
10671
10817
|
this.callSession = callSession;
|
|
10672
10818
|
this.extension = extension;
|
|
10673
10819
|
this.sourceId = sourceId;
|
|
10820
|
+
this.meetingUuid = meetingUuid;
|
|
10674
10821
|
this.callId = callId;
|
|
10675
10822
|
this.participants = [];
|
|
10676
10823
|
this.connected = false;
|
|
@@ -10690,6 +10837,8 @@ class Room$1 extends Emitter {
|
|
|
10690
10837
|
// Sugar syntax for `room.EVENT_NAME`
|
|
10691
10838
|
this.CONFERENCE_USER_PARTICIPANT_JOINED = Wazo.Websocket.CONFERENCE_USER_PARTICIPANT_JOINED;
|
|
10692
10839
|
this.CONFERENCE_USER_PARTICIPANT_LEFT = Wazo.Websocket.CONFERENCE_USER_PARTICIPANT_LEFT;
|
|
10840
|
+
this.MEETING_USER_PARTICIPANT_JOINED = Wazo.Websocket.MEETING_USER_PARTICIPANT_JOINED;
|
|
10841
|
+
this.MEETING_USER_PARTICIPANT_LEFT = Wazo.Websocket.MEETING_USER_PARTICIPANT_LEFT;
|
|
10693
10842
|
this.ON_SHARE_SCREEN_ENDED = Wazo.Phone.ON_SHARE_SCREEN_ENDED;
|
|
10694
10843
|
this.ON_MESSAGE = Wazo.Phone.ON_MESSAGE;
|
|
10695
10844
|
this.ON_CHAT = Wazo.Phone.ON_CHAT;
|
|
@@ -10724,10 +10873,11 @@ class Room$1 extends Emitter {
|
|
|
10724
10873
|
* @param audioOnly boolean
|
|
10725
10874
|
* @param extra Object
|
|
10726
10875
|
* @param room ?Room
|
|
10876
|
+
* @param meeting ?Meeting
|
|
10727
10877
|
* @returns {Promise<Room>}
|
|
10728
10878
|
*/
|
|
10729
|
-
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
10730
|
-
logger$
|
|
10879
|
+
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
10880
|
+
logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
10731
10881
|
|
|
10732
10882
|
if (!room) {
|
|
10733
10883
|
await Wazo.Phone.connect();
|
|
@@ -10740,7 +10890,7 @@ class Room$1 extends Emitter {
|
|
|
10740
10890
|
|
|
10741
10891
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
10742
10892
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
10743
|
-
logger$
|
|
10893
|
+
logger$3.info('room call received via WS', { callId: data.call_id });
|
|
10744
10894
|
if (room) {
|
|
10745
10895
|
room.setCallId(data.call_id);
|
|
10746
10896
|
}
|
|
@@ -10761,34 +10911,44 @@ class Room$1 extends Emitter {
|
|
|
10761
10911
|
room.setCallId(room.callSession.call.id);
|
|
10762
10912
|
}
|
|
10763
10913
|
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10914
|
+
if (!meeting) {
|
|
10915
|
+
// Fetch conference source
|
|
10916
|
+
const sources = await getApiClient().dird.fetchConferenceSource('default');
|
|
10917
|
+
// Retrieve conference sources
|
|
10918
|
+
const contacts = await getApiClient().dird.fetchConferenceContacts(sources.items[0]);
|
|
10919
|
+
// Retrieve conference
|
|
10920
|
+
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
10770
10921
|
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
|
|
10774
|
-
|
|
10922
|
+
logger$3.info('connected to room', {
|
|
10923
|
+
sourceId: conference ? conference.sourceId : null,
|
|
10924
|
+
name: conference ? conference.name : null,
|
|
10925
|
+
});
|
|
10775
10926
|
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10927
|
+
if (conference) {
|
|
10928
|
+
room.setSourceId(conference.sourceId);
|
|
10929
|
+
room.setName(conference.name);
|
|
10930
|
+
}
|
|
10931
|
+
} else if (meeting) {
|
|
10932
|
+
logger$3.info('Already connected to meeting', {
|
|
10933
|
+
uuid: meeting.uuid,
|
|
10934
|
+
name: meeting.name,
|
|
10935
|
+
});
|
|
10936
|
+
|
|
10937
|
+
room.setMeetingUuid(meeting.uuid);
|
|
10938
|
+
room.setName(meeting.name);
|
|
10779
10939
|
}
|
|
10780
10940
|
|
|
10781
10941
|
return room;
|
|
10782
10942
|
}
|
|
10783
10943
|
|
|
10784
10944
|
static disconnect() {
|
|
10785
|
-
logger$
|
|
10945
|
+
logger$3.info('static disconnection to room');
|
|
10786
10946
|
|
|
10787
10947
|
Wazo.Phone.disconnect();
|
|
10788
10948
|
}
|
|
10789
10949
|
|
|
10790
10950
|
async disconnect() {
|
|
10791
|
-
logger$
|
|
10951
|
+
logger$3.info('disconnection to room called');
|
|
10792
10952
|
|
|
10793
10953
|
await Wazo.Phone.hangup(this.callSession);
|
|
10794
10954
|
this.callSession = null;
|
|
@@ -10803,20 +10963,24 @@ class Room$1 extends Emitter {
|
|
|
10803
10963
|
Wazo.Phone.phone.off(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
10804
10964
|
Wazo.Websocket.off(this.CONFERENCE_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
|
|
10805
10965
|
Wazo.Websocket.off(this.CONFERENCE_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
document.body.removeChild(this.roomAudioElement);
|
|
10809
|
-
}
|
|
10966
|
+
Wazo.Websocket.off(this.MEETING_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
|
|
10967
|
+
Wazo.Websocket.off(this.MEETING_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
|
|
10810
10968
|
}
|
|
10811
10969
|
|
|
10812
10970
|
setSourceId(sourceId ) {
|
|
10813
|
-
logger$
|
|
10971
|
+
logger$3.info('set room source id', { sourceId });
|
|
10814
10972
|
|
|
10815
10973
|
this.sourceId = sourceId;
|
|
10816
10974
|
}
|
|
10817
10975
|
|
|
10976
|
+
setMeetingUuid(meetingUuid ) {
|
|
10977
|
+
logger$3.info('set meeting uuid', { meetingUuid });
|
|
10978
|
+
|
|
10979
|
+
this.meetingUuid = meetingUuid;
|
|
10980
|
+
}
|
|
10981
|
+
|
|
10818
10982
|
setCallId(callId ) {
|
|
10819
|
-
logger$
|
|
10983
|
+
logger$3.info('set room call id', { callId });
|
|
10820
10984
|
|
|
10821
10985
|
if (callId) {
|
|
10822
10986
|
this.callId = callId;
|
|
@@ -10824,7 +10988,7 @@ class Room$1 extends Emitter {
|
|
|
10824
10988
|
}
|
|
10825
10989
|
|
|
10826
10990
|
setName(name ) {
|
|
10827
|
-
logger$
|
|
10991
|
+
logger$3.info('set room name', { name });
|
|
10828
10992
|
|
|
10829
10993
|
this.name = name;
|
|
10830
10994
|
}
|
|
@@ -10843,7 +11007,7 @@ class Room$1 extends Emitter {
|
|
|
10843
11007
|
}
|
|
10844
11008
|
|
|
10845
11009
|
async startScreenSharing(constraints ) {
|
|
10846
|
-
logger$
|
|
11010
|
+
logger$3.info('start room screen sharing', { constraints });
|
|
10847
11011
|
|
|
10848
11012
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
10849
11013
|
if (!screensharingStream) {
|
|
@@ -10856,18 +11020,26 @@ class Room$1 extends Emitter {
|
|
|
10856
11020
|
return screensharingStream;
|
|
10857
11021
|
}
|
|
10858
11022
|
|
|
10859
|
-
stopScreenSharing(restoreLocalStream = true) {
|
|
10860
|
-
logger$
|
|
11023
|
+
async stopScreenSharing(restoreLocalStream = true) {
|
|
11024
|
+
logger$3.info('stop room screen sharing');
|
|
10861
11025
|
|
|
10862
|
-
Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
11026
|
+
const reinvited = await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
10863
11027
|
|
|
10864
11028
|
if (this.localParticipant) {
|
|
10865
11029
|
this.localParticipant.onStopScreensharing();
|
|
10866
11030
|
}
|
|
11031
|
+
|
|
11032
|
+
if (!reinvited && this.localParticipant) {
|
|
11033
|
+
// When we had video and we made a screenshare we don't reinvite when stopping the screensahre
|
|
11034
|
+
// So not REINVITE even is fired, we have to restore the video stream manually
|
|
11035
|
+
const localVideoStream = Wazo.Phone.getLocalVideoStream(this.callSession);
|
|
11036
|
+
// $FlowFixMe
|
|
11037
|
+
this._associateStreamTo(localVideoStream, this.localParticipant);
|
|
11038
|
+
}
|
|
10867
11039
|
}
|
|
10868
11040
|
|
|
10869
11041
|
turnCameraOff() {
|
|
10870
|
-
logger$
|
|
11042
|
+
logger$3.info('turn room camera off');
|
|
10871
11043
|
|
|
10872
11044
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
10873
11045
|
|
|
@@ -10877,7 +11049,7 @@ class Room$1 extends Emitter {
|
|
|
10877
11049
|
}
|
|
10878
11050
|
|
|
10879
11051
|
turnCameraOn() {
|
|
10880
|
-
logger$
|
|
11052
|
+
logger$3.info('turn room camera on');
|
|
10881
11053
|
|
|
10882
11054
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
10883
11055
|
|
|
@@ -10887,7 +11059,7 @@ class Room$1 extends Emitter {
|
|
|
10887
11059
|
}
|
|
10888
11060
|
|
|
10889
11061
|
mute() {
|
|
10890
|
-
logger$
|
|
11062
|
+
logger$3.info('mute room');
|
|
10891
11063
|
|
|
10892
11064
|
Wazo.Phone.mute(this.callSession);
|
|
10893
11065
|
|
|
@@ -10895,7 +11067,7 @@ class Room$1 extends Emitter {
|
|
|
10895
11067
|
}
|
|
10896
11068
|
|
|
10897
11069
|
unmute() {
|
|
10898
|
-
logger$
|
|
11070
|
+
logger$3.info('unmute room');
|
|
10899
11071
|
|
|
10900
11072
|
Wazo.Phone.unmute(this.callSession);
|
|
10901
11073
|
|
|
@@ -10915,7 +11087,7 @@ class Room$1 extends Emitter {
|
|
|
10915
11087
|
}
|
|
10916
11088
|
|
|
10917
11089
|
hold() {
|
|
10918
|
-
logger$
|
|
11090
|
+
logger$3.info('hold room');
|
|
10919
11091
|
|
|
10920
11092
|
Wazo.Phone.hold(this.callSession, true);
|
|
10921
11093
|
|
|
@@ -10925,7 +11097,7 @@ class Room$1 extends Emitter {
|
|
|
10925
11097
|
}
|
|
10926
11098
|
|
|
10927
11099
|
resume() {
|
|
10928
|
-
logger$
|
|
11100
|
+
logger$3.info('resume room');
|
|
10929
11101
|
|
|
10930
11102
|
Wazo.Phone.resume(this.callSession, true);
|
|
10931
11103
|
|
|
@@ -10935,13 +11107,13 @@ class Room$1 extends Emitter {
|
|
|
10935
11107
|
}
|
|
10936
11108
|
|
|
10937
11109
|
sendDTMF(tone ) {
|
|
10938
|
-
logger$
|
|
11110
|
+
logger$3.info('send room DTMF', { tone });
|
|
10939
11111
|
|
|
10940
11112
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
10941
11113
|
}
|
|
10942
11114
|
|
|
10943
11115
|
async sendReinvite(newConstraints = null) {
|
|
10944
|
-
logger$
|
|
11116
|
+
logger$3.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
10945
11117
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
10946
11118
|
|
|
10947
11119
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -10966,6 +11138,22 @@ class Room$1 extends Emitter {
|
|
|
10966
11138
|
return response;
|
|
10967
11139
|
}
|
|
10968
11140
|
|
|
11141
|
+
hasALocalVideoTrack() {
|
|
11142
|
+
return Wazo.Phone.hasALocalVideoTrack(this.callSession);
|
|
11143
|
+
}
|
|
11144
|
+
|
|
11145
|
+
getLocalStream() {
|
|
11146
|
+
return Wazo.Phone.getLocalStream(this.callSession);
|
|
11147
|
+
}
|
|
11148
|
+
|
|
11149
|
+
getRemoteStream() {
|
|
11150
|
+
return Wazo.Phone.getRemoteStream(this.callSession);
|
|
11151
|
+
}
|
|
11152
|
+
|
|
11153
|
+
getRemoteVideoStream() {
|
|
11154
|
+
return Wazo.Phone.getRemoteVideoStream(this.callSession);
|
|
11155
|
+
}
|
|
11156
|
+
|
|
10969
11157
|
_bindEvents() {
|
|
10970
11158
|
if (!Wazo.Phone.phone || !Wazo.Phone.phone.currentSipSession) {
|
|
10971
11159
|
return;
|
|
@@ -10984,35 +11172,18 @@ class Room$1 extends Emitter {
|
|
|
10984
11172
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
10985
11173
|
|
|
10986
11174
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
10987
|
-
logger$
|
|
11175
|
+
logger$3.info('on room audio stream');
|
|
10988
11176
|
|
|
10989
11177
|
this.audioStream = stream;
|
|
10990
|
-
if (
|
|
10991
|
-
|
|
10992
|
-
|
|
10993
|
-
if (!this.roomAudioElement) {
|
|
10994
|
-
roomAudioElement = document.createElement('audio');
|
|
10995
|
-
// $FlowFixMe
|
|
10996
|
-
document.body.appendChild(roomAudioElement);
|
|
10997
|
-
}
|
|
10998
|
-
if (!roomAudioElement) {
|
|
10999
|
-
return;
|
|
11000
|
-
}
|
|
11001
|
-
this.roomAudioElement = roomAudioElement;
|
|
11178
|
+
if (!this.roomAudioElement) {
|
|
11179
|
+
const sessionId = Wazo.Phone.phone.getSipSessionId(Wazo.Phone.phone.currentSipSession);
|
|
11180
|
+
this.roomAudioElement = Wazo.Phone.phone.createAudioElementFor(sessionId);
|
|
11002
11181
|
this.roomAudioElement.srcObject = stream;
|
|
11003
|
-
this.roomAudioElement.autoplay = true;
|
|
11004
|
-
this.roomAudioElement.id = 'audio-room';
|
|
11005
|
-
|
|
11006
|
-
// $FlowFixMe
|
|
11007
|
-
if (this.roomAudioElement.setSinkId) {
|
|
11008
|
-
// $FlowFixMe
|
|
11009
|
-
this.roomAudioElement.setSinkId(Wazo.Phone.getOutputDevice());
|
|
11010
|
-
}
|
|
11011
11182
|
}
|
|
11012
11183
|
});
|
|
11013
11184
|
|
|
11014
11185
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
11015
|
-
logger$
|
|
11186
|
+
logger$3.info('on room video stream', { streamId });
|
|
11016
11187
|
|
|
11017
11188
|
this._mapMsid(sipSession.body.body);
|
|
11018
11189
|
|
|
@@ -11027,7 +11198,7 @@ class Room$1 extends Emitter {
|
|
|
11027
11198
|
});
|
|
11028
11199
|
|
|
11029
11200
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
11030
|
-
logger$
|
|
11201
|
+
logger$3.info('on room remove stream');
|
|
11031
11202
|
|
|
11032
11203
|
const participant = this.participants.find(someParticipant =>
|
|
11033
11204
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -11082,6 +11253,9 @@ class Room$1 extends Emitter {
|
|
|
11082
11253
|
Wazo.Websocket.on(this.CONFERENCE_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
|
|
11083
11254
|
Wazo.Websocket.on(this.CONFERENCE_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
|
|
11084
11255
|
|
|
11256
|
+
Wazo.Websocket.on(this.MEETING_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
|
|
11257
|
+
Wazo.Websocket.on(this.MEETING_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
|
|
11258
|
+
|
|
11085
11259
|
// Phone events
|
|
11086
11260
|
Wazo.Phone.on(this.ON_MESSAGE, this._boundOnMessage);
|
|
11087
11261
|
Wazo.Phone.on(this.ON_CHAT, this._boundOnChat);
|
|
@@ -11092,15 +11266,15 @@ class Room$1 extends Emitter {
|
|
|
11092
11266
|
Wazo.Phone.on(event, (...args) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
|
|
11093
11267
|
}
|
|
11094
11268
|
|
|
11095
|
-
_onMessage(message )
|
|
11269
|
+
_onMessage(message ) {
|
|
11096
11270
|
if (message.method !== 'MESSAGE') {
|
|
11097
|
-
return;
|
|
11271
|
+
return null;
|
|
11098
11272
|
}
|
|
11099
11273
|
let body;
|
|
11100
11274
|
try {
|
|
11101
11275
|
body = JSON.parse(message.body);
|
|
11102
11276
|
} catch (e) {
|
|
11103
|
-
return;
|
|
11277
|
+
return null;
|
|
11104
11278
|
}
|
|
11105
11279
|
|
|
11106
11280
|
switch (body.type) {
|
|
@@ -11119,6 +11293,8 @@ class Room$1 extends Emitter {
|
|
|
11119
11293
|
}
|
|
11120
11294
|
|
|
11121
11295
|
this.eventEmitter.emit(this.ON_MESSAGE, body);
|
|
11296
|
+
|
|
11297
|
+
return body;
|
|
11122
11298
|
}
|
|
11123
11299
|
|
|
11124
11300
|
_onChat(content ) {
|
|
@@ -11154,7 +11330,7 @@ class Room$1 extends Emitter {
|
|
|
11154
11330
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
11155
11331
|
if (requester) {
|
|
11156
11332
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
11157
|
-
logger$
|
|
11333
|
+
logger$3.info('trigger room requester status', { origin });
|
|
11158
11334
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
11159
11335
|
}
|
|
11160
11336
|
break;
|
|
@@ -11183,25 +11359,26 @@ class Room$1 extends Emitter {
|
|
|
11183
11359
|
const session = Wazo.Auth.getSession();
|
|
11184
11360
|
let participants = [];
|
|
11185
11361
|
|
|
11186
|
-
// @TODO: we could use a better function name here
|
|
11187
|
-
const isJoining = part => {
|
|
11188
|
-
this.__associateStreams(part);
|
|
11189
|
-
// @VALIDATE: no need to publicize ourselves, no?
|
|
11190
|
-
if (part instanceof RemoteParticipant) {
|
|
11191
|
-
this.eventEmitter.emit(this.CONFERENCE_USER_PARTICIPANT_JOINED, part);
|
|
11192
|
-
}
|
|
11193
|
-
};
|
|
11194
|
-
|
|
11195
11362
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
11196
11363
|
if (participant.user_uuid === session.uuid) {
|
|
11197
|
-
logger$
|
|
11364
|
+
logger$3.info('room current user joined');
|
|
11198
11365
|
|
|
11199
11366
|
// Retrieve participants via an API calls
|
|
11200
11367
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
11201
|
-
|
|
11202
|
-
|
|
11368
|
+
let response;
|
|
11369
|
+
try {
|
|
11370
|
+
if (this.meetingUuid) {
|
|
11371
|
+
logger$3.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
11372
|
+
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
11373
|
+
} else {
|
|
11374
|
+
logger$3.info('fetching conference participants', { conferenceId });
|
|
11375
|
+
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
11376
|
+
}
|
|
11377
|
+
} catch (e) {
|
|
11378
|
+
logger$3.error('room participants fetching, error', e);
|
|
11379
|
+
}
|
|
11203
11380
|
if (response) {
|
|
11204
|
-
logger$
|
|
11381
|
+
logger$3.info('conference participants fetched', { nb: response.items.length });
|
|
11205
11382
|
participants = response.items.map(item => {
|
|
11206
11383
|
const isMe = item.call_id === this.callId;
|
|
11207
11384
|
|
|
@@ -11214,25 +11391,10 @@ class Room$1 extends Emitter {
|
|
|
11214
11391
|
|
|
11215
11392
|
const localParticipant = participants.find(someParticipant => someParticipant instanceof Wazo.LocalParticipant);
|
|
11216
11393
|
if (!this.localParticipant && localParticipant) {
|
|
11217
|
-
this.localParticipant
|
|
11218
|
-
|
|
11219
|
-
const localVideoStream = this._getLocalVideoStream();
|
|
11220
|
-
if (localVideoStream) {
|
|
11221
|
-
this._saveLocalVideoStream(localVideoStream);
|
|
11222
|
-
}
|
|
11223
|
-
|
|
11224
|
-
this.connected = true;
|
|
11225
|
-
|
|
11226
|
-
// we're in the room, now let's request everyone's status
|
|
11227
|
-
if (this.localParticipant) {
|
|
11228
|
-
this.sendSignal({
|
|
11229
|
-
type: SIGNAL_TYPE_PARTICIPANT_REQUEST,
|
|
11230
|
-
origin: this.localParticipant.getStatus(),
|
|
11231
|
-
});
|
|
11232
|
-
}
|
|
11394
|
+
this._onLocalParticipantJoined(localParticipant);
|
|
11233
11395
|
}
|
|
11234
11396
|
|
|
11235
|
-
participants.forEach(someParticipant =>
|
|
11397
|
+
participants.forEach(someParticipant => this._isParticipantJoining(someParticipant));
|
|
11236
11398
|
this.eventEmitter.emit(this.ON_JOINED, localParticipant, participants);
|
|
11237
11399
|
}
|
|
11238
11400
|
|
|
@@ -11243,16 +11405,45 @@ class Room$1 extends Emitter {
|
|
|
11243
11405
|
? new Wazo.RemoteParticipant(this, participant)
|
|
11244
11406
|
: null;
|
|
11245
11407
|
|
|
11246
|
-
logger$
|
|
11408
|
+
logger$3.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
11247
11409
|
|
|
11248
11410
|
if (remoteParticipant) {
|
|
11249
11411
|
this.participants.push(remoteParticipant);
|
|
11250
|
-
|
|
11412
|
+
this._isParticipantJoining(remoteParticipant);
|
|
11251
11413
|
}
|
|
11252
11414
|
|
|
11253
11415
|
return remoteParticipant;
|
|
11254
11416
|
}
|
|
11255
11417
|
|
|
11418
|
+
_onLocalParticipantJoined(localParticipant ) {
|
|
11419
|
+
this.localParticipant = localParticipant;
|
|
11420
|
+
|
|
11421
|
+
const localVideoStream = this._getLocalVideoStream();
|
|
11422
|
+
if (localVideoStream) {
|
|
11423
|
+
this._saveLocalVideoStream(localVideoStream);
|
|
11424
|
+
}
|
|
11425
|
+
|
|
11426
|
+
this.connected = true;
|
|
11427
|
+
|
|
11428
|
+
localParticipant.broadcastStatus();
|
|
11429
|
+
|
|
11430
|
+
// we're in the room, now let's request everyone's status
|
|
11431
|
+
if (this.localParticipant) {
|
|
11432
|
+
this.sendSignal({
|
|
11433
|
+
type: SIGNAL_TYPE_PARTICIPANT_REQUEST,
|
|
11434
|
+
origin: this.localParticipant.getStatus(),
|
|
11435
|
+
});
|
|
11436
|
+
}
|
|
11437
|
+
}
|
|
11438
|
+
|
|
11439
|
+
_isParticipantJoining(participant ) {
|
|
11440
|
+
this.__associateStreams(participant);
|
|
11441
|
+
// @VALIDATE: no need to publicize ourselves, no?
|
|
11442
|
+
if (participant instanceof RemoteParticipant) {
|
|
11443
|
+
this.eventEmitter.emit(this.CONFERENCE_USER_PARTICIPANT_JOINED, participant);
|
|
11444
|
+
}
|
|
11445
|
+
}
|
|
11446
|
+
|
|
11256
11447
|
_saveLocalVideoStream(stream ) {
|
|
11257
11448
|
const { localParticipant } = this;
|
|
11258
11449
|
|
|
@@ -11298,9 +11489,11 @@ class Room$1 extends Emitter {
|
|
|
11298
11489
|
_onParticipantTrackUpdate(oldParticipant , update ) {
|
|
11299
11490
|
const newParticipant = oldParticipant;
|
|
11300
11491
|
|
|
11301
|
-
const { trackId } = this._callIdStreamIdMap[newParticipant.callId] || {};
|
|
11492
|
+
const { trackId, streamId } = this._callIdStreamIdMap[newParticipant.callId] || {};
|
|
11302
11493
|
const pc = Wazo.Phone.phone.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
11303
|
-
|
|
11494
|
+
// Can't use `getReceivers` here because on FF we make the mapping based on the streamId
|
|
11495
|
+
const stream = pc.getRemoteStreams().find(someStream =>
|
|
11496
|
+
someStream.id === streamId || someStream.getTracks().some(track => track.id === trackId));
|
|
11304
11497
|
|
|
11305
11498
|
if (update === 'downgrade') {
|
|
11306
11499
|
newParticipant.streams = [];
|
|
@@ -11330,15 +11523,42 @@ class Room$1 extends Emitter {
|
|
|
11330
11523
|
return;
|
|
11331
11524
|
}
|
|
11332
11525
|
|
|
11333
|
-
|
|
11526
|
+
const streamId = this._getStreamIdFrTrackId(trackId);
|
|
11527
|
+
const key = this._getUnassociatedMapIdFromTrackIdOrStreamId(trackId, streamId);
|
|
11528
|
+
const stream = this._unassociatedVideoStreams[key];
|
|
11529
|
+
|
|
11530
|
+
if (stream) {
|
|
11334
11531
|
// Try to associate stream
|
|
11335
|
-
this._associateStreamTo(
|
|
11532
|
+
this._associateStreamTo(stream, participant);
|
|
11336
11533
|
|
|
11337
|
-
delete this._unassociatedVideoStreams[
|
|
11534
|
+
delete this._unassociatedVideoStreams[key];
|
|
11338
11535
|
delete this._unassociatedParticipants[participant.callId];
|
|
11339
11536
|
}
|
|
11340
11537
|
}
|
|
11341
11538
|
|
|
11539
|
+
_getUnassociatedMapIdFromTrackIdOrStreamId(trackId , streamId ) {
|
|
11540
|
+
// Find by trackId
|
|
11541
|
+
if (trackId in this._unassociatedVideoStreams) {
|
|
11542
|
+
return trackId;
|
|
11543
|
+
}
|
|
11544
|
+
|
|
11545
|
+
// Find by streamId
|
|
11546
|
+
if (streamId && streamId in this._unassociatedVideoStreams) {
|
|
11547
|
+
return streamId;
|
|
11548
|
+
}
|
|
11549
|
+
|
|
11550
|
+
// Find in all the streams by streamId (used on FF where we can't map by trackId)
|
|
11551
|
+
const idx = Object.values(this._unassociatedVideoStreams).findIndex((stream ) =>
|
|
11552
|
+
stream && stream.id === streamId);
|
|
11553
|
+
return idx === -1 ? null : Object.keys(this._unassociatedVideoStreams)[idx];
|
|
11554
|
+
}
|
|
11555
|
+
|
|
11556
|
+
_getStreamIdFrTrackId(trackId ) {
|
|
11557
|
+
const mapping = Object.values(this._callIdStreamIdMap).find((map ) => map.trackId === trackId);
|
|
11558
|
+
|
|
11559
|
+
return mapping ? mapping.streamId : null;
|
|
11560
|
+
}
|
|
11561
|
+
|
|
11342
11562
|
_associateStreamTo(rawStream , participant ) {
|
|
11343
11563
|
const stream = new Wazo.Stream(rawStream, participant);
|
|
11344
11564
|
participant.streams.push(stream);
|
|
@@ -11362,7 +11582,141 @@ class Room$1 extends Emitter {
|
|
|
11362
11582
|
|
|
11363
11583
|
//
|
|
11364
11584
|
|
|
11365
|
-
|
|
11585
|
+
const logger$2 = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
11586
|
+
|
|
11587
|
+
class SipRoom extends Room$1 {
|
|
11588
|
+
|
|
11589
|
+
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
11590
|
+
logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
11591
|
+
|
|
11592
|
+
if (!room) {
|
|
11593
|
+
await Wazo.Phone.connect();
|
|
11594
|
+
|
|
11595
|
+
const withCamera = constraints && !!constraints.video;
|
|
11596
|
+
|
|
11597
|
+
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
11598
|
+
// eslint-disable-next-line no-param-reassign
|
|
11599
|
+
room = new SipRoom(callSession, extension, null, null, extra);
|
|
11600
|
+
}
|
|
11601
|
+
|
|
11602
|
+
if (room && room.callSession && room.callSession.call) {
|
|
11603
|
+
room.setCallId(room.callSession.call.id);
|
|
11604
|
+
}
|
|
11605
|
+
|
|
11606
|
+
logger$2.info('connected to room', {
|
|
11607
|
+
extension: room.extension,
|
|
11608
|
+
});
|
|
11609
|
+
|
|
11610
|
+
return room;
|
|
11611
|
+
}
|
|
11612
|
+
|
|
11613
|
+
mute() {
|
|
11614
|
+
logger$2.info('mute sip room');
|
|
11615
|
+
|
|
11616
|
+
Wazo.Phone.mute(this.callSession, false);
|
|
11617
|
+
|
|
11618
|
+
this.sendMuteStatus();
|
|
11619
|
+
}
|
|
11620
|
+
|
|
11621
|
+
unmute() {
|
|
11622
|
+
logger$2.info('unmute sip room');
|
|
11623
|
+
|
|
11624
|
+
Wazo.Phone.unmute(this.callSession, false);
|
|
11625
|
+
|
|
11626
|
+
this.sendUnMuteStatus();
|
|
11627
|
+
}
|
|
11628
|
+
|
|
11629
|
+
getLocalGuestName() {
|
|
11630
|
+
return Wazo.Phone.phone.client.userAgent.options.displayName;
|
|
11631
|
+
}
|
|
11632
|
+
|
|
11633
|
+
// Overridden to not listen to websocket messages
|
|
11634
|
+
_transferEvents() {
|
|
11635
|
+
// Phone events
|
|
11636
|
+
Wazo.Phone.on(this.ON_MESSAGE, this._boundOnMessage);
|
|
11637
|
+
Wazo.Phone.on(this.ON_CHAT, this._boundOnChat);
|
|
11638
|
+
Wazo.Phone.on(this.ON_SIGNAL, this._boundOnSignal);
|
|
11639
|
+
Wazo.Phone.on(this.ON_VIDEO_INPUT_CHANGE, this._boundSaveLocalVideoStream);
|
|
11640
|
+
|
|
11641
|
+
[this.ON_AUDIO_STREAM, this.ON_VIDEO_STREAM, this.ON_REMOVE_STREAM].forEach(event =>
|
|
11642
|
+
Wazo.Phone.on(event, (...args) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
|
|
11643
|
+
}
|
|
11644
|
+
|
|
11645
|
+
_onMessage(message ) {
|
|
11646
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
11647
|
+
const body = super._onMessage(message);
|
|
11648
|
+
if (!body) {
|
|
11649
|
+
return;
|
|
11650
|
+
}
|
|
11651
|
+
|
|
11652
|
+
const getChannel = () => body.channels[0];
|
|
11653
|
+
|
|
11654
|
+
switch (body.type) {
|
|
11655
|
+
case 'ConfbridgeWelcome':
|
|
11656
|
+
body.channels.forEach(channel => {
|
|
11657
|
+
this._onParticipantJoined(channel);
|
|
11658
|
+
});
|
|
11659
|
+
|
|
11660
|
+
break;
|
|
11661
|
+
case 'ConfbridgeJoin': {
|
|
11662
|
+
const channel = getChannel();
|
|
11663
|
+
this._onParticipantJoined(channel);
|
|
11664
|
+
break;
|
|
11665
|
+
}
|
|
11666
|
+
case 'ConfbridgeLeave': {
|
|
11667
|
+
const channel = getChannel();
|
|
11668
|
+
this._onParticipantLeft({
|
|
11669
|
+
data: {
|
|
11670
|
+
call_id: channel.id,
|
|
11671
|
+
},
|
|
11672
|
+
});
|
|
11673
|
+
break;
|
|
11674
|
+
}
|
|
11675
|
+
}
|
|
11676
|
+
}
|
|
11677
|
+
|
|
11678
|
+
async _onParticipantJoined(channel ) {
|
|
11679
|
+
const isLocal = channel.channelvars.WAZO_SIP_CALL_ID === this._getCurrentSipCallIs();
|
|
11680
|
+
const callId = channel.id;
|
|
11681
|
+
const ParticipantClass = isLocal ? Wazo.LocalParticipant : Wazo.RemoteParticipant;
|
|
11682
|
+
const name = channel.caller ? channel.caller.name : null;
|
|
11683
|
+
const extra = isLocal ? { guestName: this.getLocalGuestName() } : {};
|
|
11684
|
+
const participant = new ParticipantClass(this, {
|
|
11685
|
+
caller_id_name: name,
|
|
11686
|
+
call_id: callId,
|
|
11687
|
+
}, extra);
|
|
11688
|
+
|
|
11689
|
+
const participantIdx = this.participants.findIndex(other => other.callId === participant.callId);
|
|
11690
|
+
if (participantIdx !== -1 && name) {
|
|
11691
|
+
this.participants[participantIdx].name = name;
|
|
11692
|
+
return;
|
|
11693
|
+
}
|
|
11694
|
+
|
|
11695
|
+
if (isLocal) {
|
|
11696
|
+
// Should be updated by the Wazo WS but we don't have it for now
|
|
11697
|
+
if (this.callSession) {
|
|
11698
|
+
this.callSession.ringing = false;
|
|
11699
|
+
}
|
|
11700
|
+
|
|
11701
|
+
this._onLocalParticipantJoined(participant);
|
|
11702
|
+
|
|
11703
|
+
// Give some time for the stream to be updated
|
|
11704
|
+
setTimeout(() => {
|
|
11705
|
+
this.eventEmitter.emit(this.ON_JOINED, participant, this.participants);
|
|
11706
|
+
}, 1000);
|
|
11707
|
+
}
|
|
11708
|
+
|
|
11709
|
+
this.participants.push(participant);
|
|
11710
|
+
|
|
11711
|
+
this._isParticipantJoining(participant);
|
|
11712
|
+
|
|
11713
|
+
return participant;
|
|
11714
|
+
}
|
|
11715
|
+
|
|
11716
|
+
_getCurrentSipCallIs() {
|
|
11717
|
+
return Wazo.Phone.getSipSessionId(Wazo.Phone.phone.currentSipSession);
|
|
11718
|
+
}
|
|
11719
|
+
|
|
11366
11720
|
}
|
|
11367
11721
|
|
|
11368
11722
|
/* global document */
|
|
@@ -11415,9 +11769,7 @@ class Stream {
|
|
|
11415
11769
|
return false;
|
|
11416
11770
|
}
|
|
11417
11771
|
|
|
11418
|
-
|
|
11419
|
-
return this.htmlStream.getTracks().find(track => track.kind === 'video'
|
|
11420
|
-
&& track.readyState !== 'ended' && 'width' in track.getSettings());
|
|
11772
|
+
return this.htmlStream.getTracks().some(track => track.kind === 'video' && track.readyState !== 'ended');
|
|
11421
11773
|
}
|
|
11422
11774
|
|
|
11423
11775
|
get id() {
|
|
@@ -12318,6 +12670,7 @@ const Wazo = {
|
|
|
12318
12670
|
Phone: Phone$1,
|
|
12319
12671
|
Websocket: Websocket$1,
|
|
12320
12672
|
Room: Room$1,
|
|
12673
|
+
SipRoom,
|
|
12321
12674
|
RemoteParticipant,
|
|
12322
12675
|
LocalParticipant,
|
|
12323
12676
|
Stream,
|
|
@@ -12354,6 +12707,7 @@ const Wazo = {
|
|
|
12354
12707
|
IndirectTransfer,
|
|
12355
12708
|
SwitchboardCall,
|
|
12356
12709
|
WebRTCPhone,
|
|
12710
|
+
Meeting,
|
|
12357
12711
|
},
|
|
12358
12712
|
|
|
12359
12713
|
// Api
|