@wazo/sdk 0.37.0 → 0.37.4
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 +91 -23
- package/esm/__tests__/web-rtc-client.test.js +165 -56
- package/esm/api/agentd.js +7 -1
- package/esm/api/amid.js +7 -1
- package/esm/api/application.js +7 -1
- package/esm/api/auth.js +7 -1
- package/esm/api/call-logd.js +17 -23
- package/esm/api/calld.js +10 -18
- package/esm/api/chatd.js +7 -1
- package/esm/api/confd.js +78 -1
- package/esm/api/ctid-ng.js +7 -1
- package/esm/api/dird.js +7 -1
- package/esm/api/webhookd.js +7 -1
- package/esm/api-client.js +91 -23
- package/esm/checker/Checker.js +169 -56
- package/esm/checker/checks/aor.js +91 -23
- package/esm/checker/checks/api.js +91 -23
- package/esm/checker/checks/index.js +169 -56
- package/esm/checker/checks/wazo-websocket.js +11 -1
- package/esm/checker/checks/webrtc-transport.js +165 -56
- package/esm/checker/checks/webrtc.js +165 -56
- package/esm/domain/AdHocAPIConference.js +1722 -1654
- package/esm/domain/CallLog.js +10 -22
- package/esm/domain/CallSession.js +1 -18
- package/esm/domain/Features.js +91 -23
- package/esm/domain/IndirectTransfer.js +0 -17
- package/esm/domain/Meeting.js +71 -0
- package/esm/domain/Phone/CTIPhone.js +98 -26
- package/esm/domain/Phone/Phone.js +0 -17
- package/esm/domain/Phone/WebRTCPhone.js +47 -27
- package/esm/domain/Room.js +0 -17
- package/esm/domain/SwitchboardCall.js +0 -17
- package/esm/domain/__tests__/CallLog.test.js +10 -22
- package/esm/domain/__tests__/CallSession.test.js +1 -18
- package/esm/domain/__tests__/IndirectTransfer.test.js +1 -18
- package/esm/domain/__tests__/Room.test.js +1 -18
- package/esm/index.js +3880 -3111
- package/esm/lib/WazoSessionDescriptionHandler.js +24 -10
- package/esm/service/CallApi.js +91 -23
- package/esm/service/IssueReporter.js +7 -1
- package/esm/service/__tests__/IssueReporter.test.js +9 -1
- package/esm/service/getApiClient.js +91 -23
- package/esm/simple/Auth.js +1126 -360
- package/esm/simple/Configuration.js +1126 -360
- package/esm/simple/Directory.js +91 -23
- package/esm/simple/Phone.js +3724 -2958
- package/esm/simple/Websocket.js +13 -1
- package/esm/simple/index.js +1128 -362
- package/esm/simple/room/LocalParticipant.js +1097 -331
- package/esm/simple/room/Participant.js +1097 -331
- package/esm/simple/room/RemoteParticipant.js +1097 -331
- package/esm/simple/room/Room.js +1097 -331
- package/esm/simple/room/SipRoom.js +12996 -0
- package/esm/simple/room/Stream.js +1128 -362
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +5157 -4389
- package/esm/simple/utils.js +1128 -362
- package/esm/utils/__tests__/api-requester.test.js +7 -1
- package/esm/utils/api-requester.js +7 -1
- package/esm/web-rtc-client.js +165 -56
- package/esm/websocket-client.js +12 -2
- package/lib/__tests__/api-client.test.js +91 -23
- package/lib/__tests__/web-rtc-client.test.js +165 -56
- package/lib/api/agentd.js +7 -1
- package/lib/api/amid.js +7 -1
- package/lib/api/application.js +7 -1
- package/lib/api/auth.js +7 -1
- package/lib/api/call-logd.js +17 -23
- package/lib/api/calld.js +10 -18
- package/lib/api/chatd.js +7 -1
- package/lib/api/confd.js +78 -1
- package/lib/api/ctid-ng.js +7 -1
- package/lib/api/dird.js +7 -1
- package/lib/api/webhookd.js +7 -1
- package/lib/api-client.js +91 -23
- package/lib/checker/Checker.js +169 -56
- package/lib/checker/checks/aor.js +91 -23
- package/lib/checker/checks/api.js +91 -23
- package/lib/checker/checks/index.js +169 -56
- package/lib/checker/checks/wazo-websocket.js +11 -1
- package/lib/checker/checks/webrtc-transport.js +165 -56
- package/lib/checker/checks/webrtc.js +165 -56
- package/lib/domain/AdHocAPIConference.js +1722 -1654
- package/lib/domain/CallLog.js +10 -22
- package/lib/domain/CallSession.js +1 -18
- package/lib/domain/Features.js +91 -23
- package/lib/domain/IndirectTransfer.js +0 -17
- package/lib/domain/Meeting.js +73 -0
- package/lib/domain/Phone/CTIPhone.js +98 -26
- package/lib/domain/Phone/Phone.js +0 -16
- package/lib/domain/Phone/WebRTCPhone.js +47 -27
- package/lib/domain/Room.js +0 -17
- package/lib/domain/SwitchboardCall.js +0 -17
- package/lib/domain/__tests__/CallLog.test.js +10 -22
- package/lib/domain/__tests__/CallSession.test.js +1 -18
- package/lib/domain/__tests__/IndirectTransfer.test.js +1 -18
- package/lib/domain/__tests__/Room.test.js +1 -18
- package/lib/index.js +3880 -3111
- package/lib/lib/WazoSessionDescriptionHandler.js +24 -10
- package/lib/service/CallApi.js +91 -23
- package/lib/service/IssueReporter.js +7 -1
- package/lib/service/__tests__/IssueReporter.test.js +9 -1
- package/lib/service/getApiClient.js +91 -23
- package/lib/simple/Auth.js +1126 -360
- package/lib/simple/Configuration.js +1126 -360
- package/lib/simple/Directory.js +91 -23
- package/lib/simple/Phone.js +3724 -2958
- package/lib/simple/Websocket.js +13 -1
- package/lib/simple/index.js +1128 -362
- package/lib/simple/room/LocalParticipant.js +1097 -331
- package/lib/simple/room/Participant.js +1097 -331
- package/lib/simple/room/RemoteParticipant.js +1097 -331
- package/lib/simple/room/Room.js +1097 -331
- package/lib/simple/room/SipRoom.js +13006 -0
- package/lib/simple/room/Stream.js +1128 -362
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +5157 -4389
- package/lib/simple/utils.js +1128 -362
- package/lib/utils/__tests__/api-requester.test.js +7 -1
- package/lib/utils/api-requester.js +7 -1
- package/lib/web-rtc-client.js +165 -56
- package/lib/websocket-client.js +13 -1
- 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/CallSession.js +1 -2
- package/src/domain/Meeting.js +59 -0
- package/src/domain/Phone/CTIPhone.js +6 -2
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +22 -8
- package/src/index.js +6 -0
- package/src/lib/WazoSessionDescriptionHandler.js +17 -9
- package/src/service/IssueReporter.js +7 -1
- package/src/service/__tests__/IssueReporter.test.js +2 -0
- package/src/simple/Phone.js +13 -4
- package/src/simple/index.js +8 -0
- package/src/simple/room/Participant.js +7 -0
- package/src/simple/room/Room.js +157 -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 +57 -24
- package/src/websocket-client.js +4 -0
package/lib/simple/utils.js
CHANGED
|
@@ -1821,7 +1821,13 @@ class IssueReporter {
|
|
|
1821
1821
|
}
|
|
1822
1822
|
|
|
1823
1823
|
_isLevelAbove(level1 , level2 ) {
|
|
1824
|
-
|
|
1824
|
+
const index1 = LOG_LEVELS.indexOf(level1);
|
|
1825
|
+
const index2 = LOG_LEVELS.indexOf(level2);
|
|
1826
|
+
if (index1 === -1 || index2 === -1) {
|
|
1827
|
+
return false;
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
return index1 > index2;
|
|
1825
1831
|
}
|
|
1826
1832
|
|
|
1827
1833
|
_makeCategory(category ) {
|
|
@@ -1844,7 +1850,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
1844
1850
|
|
|
1845
1851
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
1846
1852
|
|
|
1847
|
-
const logger$
|
|
1853
|
+
const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
1848
1854
|
|
|
1849
1855
|
// Use a function here to be able to mock it in tests
|
|
1850
1856
|
const realFetch = () => {
|
|
@@ -1983,7 +1989,7 @@ class ApiRequester {
|
|
|
1983
1989
|
};
|
|
1984
1990
|
|
|
1985
1991
|
if (this.refreshTokenPromise) {
|
|
1986
|
-
logger$
|
|
1992
|
+
logger$c.info('A token is already refreshing, waiting ...', { url });
|
|
1987
1993
|
await this.refreshTokenPromise;
|
|
1988
1994
|
}
|
|
1989
1995
|
|
|
@@ -2003,7 +2009,7 @@ class ApiRequester {
|
|
|
2003
2009
|
return promise.then(async (err ) => {
|
|
2004
2010
|
// Check if the token is still valid
|
|
2005
2011
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
2006
|
-
logger$
|
|
2012
|
+
logger$c.warn('token expired', { error: err.reason });
|
|
2007
2013
|
// Replay the call after refreshing the token
|
|
2008
2014
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
2009
2015
|
}
|
|
@@ -2013,7 +2019,7 @@ class ApiRequester {
|
|
|
2013
2019
|
: exceptionClass.fromResponse(err, response.status);
|
|
2014
2020
|
|
|
2015
2021
|
if (this.shouldLogErrors) {
|
|
2016
|
-
logger$
|
|
2022
|
+
logger$c.error('API error', error);
|
|
2017
2023
|
}
|
|
2018
2024
|
|
|
2019
2025
|
throw error;
|
|
@@ -2023,7 +2029,7 @@ class ApiRequester {
|
|
|
2023
2029
|
return newParse(response, isJson);
|
|
2024
2030
|
}).catch(error => {
|
|
2025
2031
|
if (this.shouldLogErrors) {
|
|
2026
|
-
logger$
|
|
2032
|
+
logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
2027
2033
|
}
|
|
2028
2034
|
|
|
2029
2035
|
throw error;
|
|
@@ -2051,13 +2057,13 @@ class ApiRequester {
|
|
|
2051
2057
|
) {
|
|
2052
2058
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
2053
2059
|
let newPath = path;
|
|
2054
|
-
logger$
|
|
2060
|
+
logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
2055
2061
|
|
|
2056
2062
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
2057
2063
|
|
|
2058
2064
|
return this.refreshTokenPromise.then(() => {
|
|
2059
2065
|
this.refreshTokenPromise = null;
|
|
2060
|
-
logger$
|
|
2066
|
+
logger$c.info('token refreshed', { isTokenNotFound });
|
|
2061
2067
|
if (isTokenNotFound) {
|
|
2062
2068
|
const pathParts = path.split('/');
|
|
2063
2069
|
pathParts.pop();
|
|
@@ -2518,6 +2524,65 @@ class ExternalApp {
|
|
|
2518
2524
|
}
|
|
2519
2525
|
}
|
|
2520
2526
|
|
|
2527
|
+
//
|
|
2528
|
+
|
|
2529
|
+
|
|
2530
|
+
|
|
2531
|
+
|
|
2532
|
+
|
|
2533
|
+
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
|
|
2539
|
+
class Meeting {
|
|
2540
|
+
|
|
2541
|
+
|
|
2542
|
+
|
|
2543
|
+
|
|
2544
|
+
|
|
2545
|
+
|
|
2546
|
+
|
|
2547
|
+
|
|
2548
|
+
|
|
2549
|
+
|
|
2550
|
+
static parse(plain ) {
|
|
2551
|
+
return new Meeting({
|
|
2552
|
+
guestSipAuthorization: plain.guest_sip_authorization,
|
|
2553
|
+
hostname: plain.hostname,
|
|
2554
|
+
name: plain.name,
|
|
2555
|
+
ownerUuids: plain.owner_uuids,
|
|
2556
|
+
port: plain.port,
|
|
2557
|
+
uuid: plain.uuid,
|
|
2558
|
+
number: plain.number,
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
static newFrom(meeting ) {
|
|
2563
|
+
return newFrom(meeting, Meeting);
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, hostname, number } = {}) {
|
|
2567
|
+
this.guestSipAuthorization = guestSipAuthorization;
|
|
2568
|
+
this.hostname = hostname;
|
|
2569
|
+
this.name = name;
|
|
2570
|
+
this.ownerUuids = ownerUuids;
|
|
2571
|
+
this.port = port;
|
|
2572
|
+
this.uuid = uuid;
|
|
2573
|
+
this.number = number;
|
|
2574
|
+
|
|
2575
|
+
// Useful to compare instead of instanceof with minified code
|
|
2576
|
+
this.type = 'Meeting';
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
getGuestSipCredentials() {
|
|
2580
|
+
// eslint-disable-next-line no-undef
|
|
2581
|
+
const [username, secret] = atob(this.guestSipAuthorization).split(':');
|
|
2582
|
+
return { username, secret };
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2521
2586
|
/* */
|
|
2522
2587
|
|
|
2523
2588
|
var confdMethods = (client , baseUrl ) => ({
|
|
@@ -2582,6 +2647,18 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2582
2647
|
return null;
|
|
2583
2648
|
}
|
|
2584
2649
|
},
|
|
2650
|
+
|
|
2651
|
+
createMyMeeting: (name ) =>
|
|
2652
|
+
client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
|
|
2653
|
+
|
|
2654
|
+
deleteMyMeeting: (meetingUuid ) =>
|
|
2655
|
+
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
2656
|
+
|
|
2657
|
+
getMeeting: (meetingUuid ) =>
|
|
2658
|
+
client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
2659
|
+
|
|
2660
|
+
guestGetMeeting: (meetingUuid ) =>
|
|
2661
|
+
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
2585
2662
|
});
|
|
2586
2663
|
|
|
2587
2664
|
//
|
|
@@ -3339,7 +3416,7 @@ class CallSession {
|
|
|
3339
3416
|
return newFrom(callSession, CallSession);
|
|
3340
3417
|
}
|
|
3341
3418
|
|
|
3342
|
-
static parseCall(
|
|
3419
|
+
static parseCall(call ) {
|
|
3343
3420
|
return new CallSession({
|
|
3344
3421
|
callId: call.id,
|
|
3345
3422
|
sipCallId: call.sipCallId,
|
|
@@ -3524,7 +3601,11 @@ class CallLog {
|
|
|
3524
3601
|
answered: plain.answered,
|
|
3525
3602
|
callDirection: plain.call_direction,
|
|
3526
3603
|
destination: {
|
|
3527
|
-
|
|
3604
|
+
// @TEMP: Temporarily assuming empty numbers are meetings
|
|
3605
|
+
// which is admittedly a very dangerous assumption. Did i mention it was temporary?
|
|
3606
|
+
extension: plain.requested_extension
|
|
3607
|
+
|| plain.destination_extension
|
|
3608
|
+
|| `meeting-${plain.requested_name || plain.destination_name || ''}`,
|
|
3528
3609
|
name: plain.requested_name || plain.destination_name || '',
|
|
3529
3610
|
},
|
|
3530
3611
|
source: {
|
|
@@ -3540,27 +3621,11 @@ class CallLog {
|
|
|
3540
3621
|
}
|
|
3541
3622
|
|
|
3542
3623
|
static parseNew(plain , session ) {
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
extension: plain.requested_extension || plain.destination_extension,
|
|
3549
|
-
name: plain.requested_name || plain.destination_name || '',
|
|
3550
|
-
},
|
|
3551
|
-
source: {
|
|
3552
|
-
extension: plain.source_extension,
|
|
3553
|
-
name: plain.source_name,
|
|
3554
|
-
},
|
|
3555
|
-
id: plain.id,
|
|
3556
|
-
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
3557
|
-
start: moment__default['default'](plain.start).toDate(),
|
|
3558
|
-
end: plain.end ? moment__default['default'](plain.end).toDate() : null,
|
|
3559
|
-
recordings: Recording.parseMany(plain.recordings),
|
|
3560
|
-
// @TODO: FIXME add verification declined vs missed call
|
|
3561
|
-
newMissedCall: session
|
|
3562
|
-
&& session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
|
|
3563
|
-
});
|
|
3624
|
+
const callLog = CallLog.parse(plain);
|
|
3625
|
+
// @TODO: FIXME add verification declined vs missed call
|
|
3626
|
+
callLog.newMissedCall = session
|
|
3627
|
+
&& session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
|
|
3628
|
+
return callLog;
|
|
3564
3629
|
}
|
|
3565
3630
|
|
|
3566
3631
|
static newFrom(profile ) {
|
|
@@ -3720,29 +3785,432 @@ class IndirectTransfer {
|
|
|
3720
3785
|
});
|
|
3721
3786
|
}
|
|
3722
3787
|
|
|
3723
|
-
destinationIs(callSession ) {
|
|
3724
|
-
return callSession.isId(this.destinationId);
|
|
3788
|
+
destinationIs(callSession ) {
|
|
3789
|
+
return callSession.isId(this.destinationId);
|
|
3790
|
+
}
|
|
3791
|
+
|
|
3792
|
+
sourceIs(callSession ) {
|
|
3793
|
+
return callSession.isId(this.sourceId);
|
|
3794
|
+
}
|
|
3795
|
+
|
|
3796
|
+
updateFrom(indirectTransfer ) {
|
|
3797
|
+
updateFrom(this, indirectTransfer);
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
static newFrom(indirectTransfer ) {
|
|
3801
|
+
return newFrom(indirectTransfer, IndirectTransfer);
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
|
|
3805
|
+
//
|
|
3806
|
+
|
|
3807
|
+
class CallApi {
|
|
3808
|
+
static async fetchCallLogs(offset , limit ) {
|
|
3809
|
+
return getApiClient().callLogd.listCallLogs(offset, limit);
|
|
3810
|
+
}
|
|
3811
|
+
|
|
3812
|
+
static async fetchDistinctCallLogs(offset , limit , distinct = 'peer_exten') {
|
|
3813
|
+
return getApiClient().callLogd.listDistinctCallLogs(offset, limit, distinct);
|
|
3814
|
+
}
|
|
3815
|
+
|
|
3816
|
+
static async fetchActiveCalls() {
|
|
3817
|
+
return getApiClient().calld.listCalls();
|
|
3818
|
+
}
|
|
3819
|
+
|
|
3820
|
+
static async fetchCallLogsFromDate(from , number ) {
|
|
3821
|
+
return getApiClient().callLogd.listCallLogsFromDate(from, number);
|
|
3822
|
+
}
|
|
3823
|
+
|
|
3824
|
+
static async search(query , limit ) {
|
|
3825
|
+
return getApiClient().callLogd.search(query, limit);
|
|
3826
|
+
}
|
|
3827
|
+
|
|
3828
|
+
static async searchBy(field , value , limit ) {
|
|
3829
|
+
return getApiClient().callLogd.searchBy(field, value, limit);
|
|
3830
|
+
}
|
|
3831
|
+
|
|
3832
|
+
static async fetchSIP(session , line ) {
|
|
3833
|
+
const lineToUse = line || session.primaryLine();
|
|
3834
|
+
return getApiClient().confd.getUserLineSip(session.uuid, lineToUse ? lineToUse.id : null);
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
static async cancelCall(callSession ) {
|
|
3838
|
+
return getApiClient().calld.cancelCall(callSession.callId);
|
|
3839
|
+
}
|
|
3840
|
+
|
|
3841
|
+
static async makeCall(callFromLine , extension , isMobile = false,
|
|
3842
|
+
callbackAllLines = false) {
|
|
3843
|
+
const lineId = callFromLine ? callFromLine.id : null;
|
|
3844
|
+
|
|
3845
|
+
const response = await getApiClient().calld.makeCall(extension, isMobile, lineId, callbackAllLines);
|
|
3846
|
+
return Call.parse(response);
|
|
3847
|
+
}
|
|
3848
|
+
|
|
3849
|
+
static async relocateCall(callId , line , contactIdentifier ) {
|
|
3850
|
+
return getApiClient().calld.relocateCall(callId, 'line', line, contactIdentifier);
|
|
3851
|
+
}
|
|
3852
|
+
|
|
3853
|
+
static async hold(callId ) {
|
|
3854
|
+
return getApiClient().calld.hold(callId);
|
|
3855
|
+
}
|
|
3856
|
+
|
|
3857
|
+
static async resume(callId ) {
|
|
3858
|
+
return getApiClient().calld.resume(callId);
|
|
3859
|
+
}
|
|
3860
|
+
|
|
3861
|
+
static async mute(callId ) {
|
|
3862
|
+
return getApiClient().calld.mute(callId);
|
|
3863
|
+
}
|
|
3864
|
+
|
|
3865
|
+
static async sendDTMF(callId , digits ) {
|
|
3866
|
+
return getApiClient().calld.sendDTMF(callId, digits);
|
|
3867
|
+
}
|
|
3868
|
+
|
|
3869
|
+
static async unmute(callId ) {
|
|
3870
|
+
return getApiClient().calld.unmute(callId);
|
|
3871
|
+
}
|
|
3872
|
+
|
|
3873
|
+
static async transferCall(callId , number , flow ) {
|
|
3874
|
+
return getApiClient().calld.transferCall(callId, number, flow);
|
|
3875
|
+
}
|
|
3876
|
+
|
|
3877
|
+
static async cancelCallTransfer(transferId ) {
|
|
3878
|
+
return getApiClient().calld.cancelCallTransfer(transferId);
|
|
3879
|
+
}
|
|
3880
|
+
|
|
3881
|
+
static async confirmCallTransfer(transferId ) {
|
|
3882
|
+
return getApiClient().calld.confirmCallTransfer(transferId);
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
|
|
3886
|
+
//
|
|
3887
|
+
|
|
3888
|
+
const TRANSFER_FLOW_ATTENDED = 'attended';
|
|
3889
|
+
const TRANSFER_FLOW_BLIND = 'blind';
|
|
3890
|
+
|
|
3891
|
+
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3892
|
+
|
|
3893
|
+
const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3894
|
+
|
|
3895
|
+
class CTIPhone extends Emitter {
|
|
3896
|
+
|
|
3897
|
+
|
|
3898
|
+
|
|
3899
|
+
|
|
3900
|
+
|
|
3901
|
+
|
|
3902
|
+
|
|
3903
|
+
|
|
3904
|
+
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
3905
|
+
super();
|
|
3906
|
+
logger$b.info('CTI Phone created');
|
|
3907
|
+
this.session = session;
|
|
3908
|
+
this.isMobile = isMobile;
|
|
3909
|
+
this.callbackAllLines = callbackAllLines;
|
|
3910
|
+
}
|
|
3911
|
+
|
|
3912
|
+
getOptions() {
|
|
3913
|
+
// @FIXME: temporarily disabling this option
|
|
3914
|
+
// const hold = this.session.hasEngineVersionGte(MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD);
|
|
3915
|
+
|
|
3916
|
+
return {
|
|
3917
|
+
accept: false,
|
|
3918
|
+
decline: true,
|
|
3919
|
+
mute: true,
|
|
3920
|
+
hold: false,
|
|
3921
|
+
transfer: true,
|
|
3922
|
+
sendKey: true,
|
|
3923
|
+
addParticipant: false,
|
|
3924
|
+
record: true,
|
|
3925
|
+
merge: false,
|
|
3926
|
+
};
|
|
3927
|
+
}
|
|
3928
|
+
|
|
3929
|
+
hasAnActiveCall() {
|
|
3930
|
+
return !!this.currentCall;
|
|
3931
|
+
}
|
|
3932
|
+
|
|
3933
|
+
callCount() {
|
|
3934
|
+
return this.currentCall ? 1 : 0;
|
|
3935
|
+
}
|
|
3936
|
+
|
|
3937
|
+
isWebRTC() {
|
|
3938
|
+
return false;
|
|
3939
|
+
}
|
|
3940
|
+
|
|
3941
|
+
getUserAgent() {
|
|
3942
|
+
return 'cti-phone';
|
|
3943
|
+
}
|
|
3944
|
+
|
|
3945
|
+
startHeartbeat() {
|
|
3946
|
+
}
|
|
3947
|
+
|
|
3948
|
+
setOnHeartbeatTimeout() {
|
|
3949
|
+
}
|
|
3950
|
+
|
|
3951
|
+
setOnHeartbeatCallback() {
|
|
3952
|
+
}
|
|
3953
|
+
|
|
3954
|
+
stopHeartbeat() {
|
|
3955
|
+
}
|
|
3956
|
+
|
|
3957
|
+
bindClientEvents() {
|
|
3958
|
+
}
|
|
3959
|
+
|
|
3960
|
+
onConnect() {
|
|
3961
|
+
}
|
|
3962
|
+
|
|
3963
|
+
onDisconnect() {
|
|
3964
|
+
}
|
|
3965
|
+
|
|
3966
|
+
async makeCall(number , line ) {
|
|
3967
|
+
logger$b.info('make CTI call', { number });
|
|
3968
|
+
|
|
3969
|
+
if (!number) {
|
|
3970
|
+
return null;
|
|
3971
|
+
}
|
|
3972
|
+
try {
|
|
3973
|
+
this.currentCall = await CallApi.makeCall(line, number, this.isMobile, this.callbackAllLines);
|
|
3974
|
+
} catch (_) {
|
|
3975
|
+
// We have to deal with error like `User has no mobile phone number` error in the UI.
|
|
3976
|
+
}
|
|
3977
|
+
if (!this.currentCall) {
|
|
3978
|
+
return null;
|
|
3979
|
+
}
|
|
3980
|
+
const callSession = CallSession.parseCall(this.currentCall);
|
|
3981
|
+
this.eventEmitter.emit('onCallOutgoing', callSession);
|
|
3982
|
+
|
|
3983
|
+
return callSession;
|
|
3984
|
+
}
|
|
3985
|
+
|
|
3986
|
+
accept(callSession ) {
|
|
3987
|
+
if (!callSession) {
|
|
3988
|
+
return Promise.resolve(null);
|
|
3989
|
+
}
|
|
3990
|
+
logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3991
|
+
|
|
3992
|
+
if (!this.currentCall) {
|
|
3993
|
+
this.currentCall = callSession.call;
|
|
3994
|
+
}
|
|
3995
|
+
|
|
3996
|
+
return Promise.resolve(callSession.getId());
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3999
|
+
endCurrentCall(callSession ) {
|
|
4000
|
+
if (!callSession) {
|
|
4001
|
+
return;
|
|
4002
|
+
}
|
|
4003
|
+
logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4004
|
+
|
|
4005
|
+
this.currentCall = undefined;
|
|
4006
|
+
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4007
|
+
}
|
|
4008
|
+
|
|
4009
|
+
async hangup(callSession ) {
|
|
4010
|
+
if (!callSession) {
|
|
4011
|
+
return Promise.resolve(false);
|
|
4012
|
+
}
|
|
4013
|
+
logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4014
|
+
|
|
4015
|
+
try {
|
|
4016
|
+
await CallApi.cancelCall(callSession);
|
|
4017
|
+
if (this.currentCall && callSession.callId === this.currentCall.id) {
|
|
4018
|
+
this.endCurrentCall(callSession);
|
|
4019
|
+
}
|
|
4020
|
+
|
|
4021
|
+
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4022
|
+
return true;
|
|
4023
|
+
} catch (e) {
|
|
4024
|
+
logger$b.error('hangup CTI call, error', e);
|
|
4025
|
+
|
|
4026
|
+
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4027
|
+
return false;
|
|
4028
|
+
}
|
|
4029
|
+
}
|
|
4030
|
+
|
|
4031
|
+
ignore() {}
|
|
4032
|
+
|
|
4033
|
+
async reject(callSession ) {
|
|
4034
|
+
if (!callSession) {
|
|
4035
|
+
return;
|
|
4036
|
+
}
|
|
4037
|
+
logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4038
|
+
|
|
4039
|
+
await CallApi.cancelCall(callSession);
|
|
4040
|
+
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4041
|
+
}
|
|
4042
|
+
|
|
4043
|
+
async transfer(callSession , number ) {
|
|
4044
|
+
if (!callSession) {
|
|
4045
|
+
return;
|
|
4046
|
+
}
|
|
4047
|
+
logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4048
|
+
|
|
4049
|
+
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4050
|
+
}
|
|
4051
|
+
|
|
4052
|
+
indirectTransfer() {}
|
|
4053
|
+
|
|
4054
|
+
async initiateCTIIndirectTransfer(callSession , number ) {
|
|
4055
|
+
if (!callSession) {
|
|
4056
|
+
return;
|
|
4057
|
+
}
|
|
4058
|
+
logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4059
|
+
|
|
4060
|
+
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4061
|
+
}
|
|
4062
|
+
|
|
4063
|
+
async cancelCTIIndirectTransfer(transferId ) {
|
|
4064
|
+
logger$b.info('cancel CTI transfer', { transferId });
|
|
4065
|
+
|
|
4066
|
+
return CallApi.cancelCallTransfer(transferId);
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
async confirmCTIIndirectTransfer(transferId ) {
|
|
4070
|
+
logger$b.info('confirm CTI transfer', { transferId });
|
|
4071
|
+
|
|
4072
|
+
return CallApi.confirmCallTransfer(transferId);
|
|
4073
|
+
}
|
|
4074
|
+
|
|
4075
|
+
sendKey(callSession , digits ) {
|
|
4076
|
+
if (!callSession) {
|
|
4077
|
+
return;
|
|
4078
|
+
}
|
|
4079
|
+
logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4080
|
+
|
|
4081
|
+
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4082
|
+
}
|
|
4083
|
+
|
|
4084
|
+
onConnectionMade() {
|
|
4085
|
+
logger$b.info('on CTI connection made');
|
|
4086
|
+
|
|
4087
|
+
this.eventEmitter.emit('onCallAccepted');
|
|
4088
|
+
}
|
|
4089
|
+
|
|
4090
|
+
async close() {
|
|
4091
|
+
logger$b.info('CTI close');
|
|
4092
|
+
|
|
4093
|
+
return Promise.resolve();
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
async hold(callSession ) {
|
|
4097
|
+
if (!callSession) {
|
|
4098
|
+
return;
|
|
4099
|
+
}
|
|
4100
|
+
logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4101
|
+
|
|
4102
|
+
return CallApi.hold(callSession.callId);
|
|
4103
|
+
}
|
|
4104
|
+
|
|
4105
|
+
async resume(callSession ) {
|
|
4106
|
+
if (!callSession) {
|
|
4107
|
+
return;
|
|
4108
|
+
}
|
|
4109
|
+
logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4110
|
+
|
|
4111
|
+
return CallApi.resume(callSession.callId);
|
|
4112
|
+
}
|
|
4113
|
+
|
|
4114
|
+
async mute(callSession ) {
|
|
4115
|
+
if (!callSession) {
|
|
4116
|
+
return;
|
|
4117
|
+
}
|
|
4118
|
+
logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4119
|
+
|
|
4120
|
+
return CallApi.mute(callSession.callId);
|
|
4121
|
+
}
|
|
4122
|
+
|
|
4123
|
+
async unmute(callSession ) {
|
|
4124
|
+
if (!callSession) {
|
|
4125
|
+
return;
|
|
4126
|
+
}
|
|
4127
|
+
logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4128
|
+
|
|
4129
|
+
return CallApi.unmute(callSession.callId);
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
putOnSpeaker() {}
|
|
4133
|
+
|
|
4134
|
+
putOffSpeaker() {}
|
|
4135
|
+
|
|
4136
|
+
turnCameraOff() {}
|
|
4137
|
+
|
|
4138
|
+
turnCameraOn() {}
|
|
4139
|
+
|
|
4140
|
+
changeAudioInputDevice() {}
|
|
4141
|
+
|
|
4142
|
+
changeVideoInputDevice() {}
|
|
4143
|
+
|
|
4144
|
+
changeAudioDevice() {}
|
|
4145
|
+
|
|
4146
|
+
changeRingDevice() {}
|
|
4147
|
+
|
|
4148
|
+
changeAudioVolume() {}
|
|
4149
|
+
|
|
4150
|
+
changeRingVolume() {}
|
|
4151
|
+
|
|
4152
|
+
hasVideo() {
|
|
4153
|
+
return false;
|
|
4154
|
+
}
|
|
4155
|
+
|
|
4156
|
+
getLocalStreamForCall() {
|
|
4157
|
+
return null;
|
|
4158
|
+
}
|
|
4159
|
+
|
|
4160
|
+
getRemoteStreamForCall() {
|
|
4161
|
+
return null;
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4164
|
+
getLocalVideoStream() {
|
|
4165
|
+
return null;
|
|
4166
|
+
}
|
|
4167
|
+
|
|
4168
|
+
setActiveSipSession() {}
|
|
4169
|
+
|
|
4170
|
+
isRegistered() {
|
|
4171
|
+
return true;
|
|
4172
|
+
}
|
|
4173
|
+
|
|
4174
|
+
hasIncomingCallSession() {
|
|
4175
|
+
return true;
|
|
4176
|
+
}
|
|
4177
|
+
|
|
4178
|
+
hasActiveRemoteVideoStream() {
|
|
4179
|
+
return false;
|
|
4180
|
+
}
|
|
4181
|
+
|
|
4182
|
+
getCurrentCallSession() {
|
|
4183
|
+
return this.currentCall ? CallSession.parseCall(this.currentCall) : null;
|
|
4184
|
+
}
|
|
4185
|
+
|
|
4186
|
+
enableRinging() {}
|
|
4187
|
+
|
|
4188
|
+
sendMessage() {}
|
|
4189
|
+
|
|
4190
|
+
disableRinging() {}
|
|
4191
|
+
|
|
4192
|
+
getLocalStream() {
|
|
4193
|
+
return null;
|
|
3725
4194
|
}
|
|
3726
4195
|
|
|
3727
|
-
|
|
3728
|
-
return
|
|
4196
|
+
getRemoteStream() {
|
|
4197
|
+
return null;
|
|
3729
4198
|
}
|
|
3730
4199
|
|
|
3731
|
-
|
|
3732
|
-
|
|
4200
|
+
getRemoteVideoStream() {
|
|
4201
|
+
return null;
|
|
3733
4202
|
}
|
|
3734
4203
|
|
|
3735
|
-
|
|
3736
|
-
return
|
|
4204
|
+
getRemoteAudioStream() {
|
|
4205
|
+
return null;
|
|
3737
4206
|
}
|
|
3738
|
-
}
|
|
3739
|
-
|
|
3740
|
-
//
|
|
3741
|
-
const TRANSFER_FLOW_BLIND = 'blind';
|
|
3742
4207
|
|
|
3743
|
-
|
|
4208
|
+
hasLocalVideo() {
|
|
4209
|
+
return false;
|
|
4210
|
+
}
|
|
3744
4211
|
|
|
3745
|
-
|
|
4212
|
+
useLocalVideoElement() {}
|
|
4213
|
+
}
|
|
3746
4214
|
|
|
3747
4215
|
/* */
|
|
3748
4216
|
|
|
@@ -4302,6 +4770,9 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
4302
4770
|
getConferenceParticipantsAsUser: async (conferenceId ) =>
|
|
4303
4771
|
client.get(`${baseUrl}/users/me/conferences/${conferenceId}/participants`),
|
|
4304
4772
|
|
|
4773
|
+
getMeetingParticipantsAsUser: async (meetingUuid ) =>
|
|
4774
|
+
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
|
|
4775
|
+
|
|
4305
4776
|
listTrunks: () => client.get(`${baseUrl}/trunks`),
|
|
4306
4777
|
|
|
4307
4778
|
mute: (callId ) =>
|
|
@@ -4655,7 +5126,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4655
5126
|
const WEBHOOKD_VERSION = '1.0';
|
|
4656
5127
|
const AMID_VERSION = '1.0';
|
|
4657
5128
|
|
|
4658
|
-
const logger$
|
|
5129
|
+
const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4659
5130
|
|
|
4660
5131
|
class ApiClient {
|
|
4661
5132
|
|
|
@@ -4707,12 +5178,12 @@ class ApiClient {
|
|
|
4707
5178
|
}
|
|
4708
5179
|
|
|
4709
5180
|
async forceRefreshToken() {
|
|
4710
|
-
logger$
|
|
5181
|
+
logger$a.info('forcing refresh token, calling callback');
|
|
4711
5182
|
return this.refreshTokenCallback();
|
|
4712
5183
|
}
|
|
4713
5184
|
|
|
4714
5185
|
async refreshTokenCallback() {
|
|
4715
|
-
logger$
|
|
5186
|
+
logger$a.info('refresh token callback called', {
|
|
4716
5187
|
refreshToken: this.refreshToken,
|
|
4717
5188
|
refreshBackend: this.refreshBackend,
|
|
4718
5189
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4730,7 +5201,7 @@ class ApiClient {
|
|
|
4730
5201
|
this.isMobile,
|
|
4731
5202
|
);
|
|
4732
5203
|
|
|
4733
|
-
logger$
|
|
5204
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
4734
5205
|
|
|
4735
5206
|
if (this.onRefreshToken) {
|
|
4736
5207
|
this.onRefreshToken(session.token, session);
|
|
@@ -4871,7 +5342,7 @@ var getApiClient = (forServer ) => {
|
|
|
4871
5342
|
class InvalidSubscription extends Error {}
|
|
4872
5343
|
class InvalidAuthorization extends Error {}
|
|
4873
5344
|
|
|
4874
|
-
const logger$
|
|
5345
|
+
const logger$9 = IssueReporter$1.loggerFor('simple-auth');
|
|
4875
5346
|
|
|
4876
5347
|
class Auth {
|
|
4877
5348
|
|
|
@@ -4906,7 +5377,7 @@ class Auth {
|
|
|
4906
5377
|
setApiClientId(this.clientId);
|
|
4907
5378
|
setRefreshExpiration(this.expiration);
|
|
4908
5379
|
setOnRefreshToken((token , session ) => {
|
|
4909
|
-
logger$
|
|
5380
|
+
logger$9.info('on refresh token done', { token });
|
|
4910
5381
|
setApiToken(token);
|
|
4911
5382
|
Wazo.Websocket.updateToken(token);
|
|
4912
5383
|
|
|
@@ -5465,7 +5936,9 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5465
5936
|
.then(() => {
|
|
5466
5937
|
if (isConference && (options.constraints && !options.constraints.video) && !('hold' in options) && !audioOnly) {
|
|
5467
5938
|
// Add a video an empty bundle to be able to replaceTrack when joining a conference without video
|
|
5468
|
-
this.peerConnection.addTransceiver
|
|
5939
|
+
if (this.peerConnection.addTransceiver) {
|
|
5940
|
+
this.peerConnection.addTransceiver('video', { streams: [this._localMediaStream], direction: 'sendrecv' });
|
|
5941
|
+
}
|
|
5469
5942
|
}
|
|
5470
5943
|
})
|
|
5471
5944
|
.then(() => this.createLocalOfferOrAnswer(options))
|
|
@@ -5492,12 +5965,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5492
5965
|
};
|
|
5493
5966
|
})
|
|
5494
5967
|
.then((sessionDescription) => this.applyModifiers(sessionDescription, modifiers))
|
|
5495
|
-
.then((sessionDescription) => {
|
|
5496
|
-
// Set new constraints to avoid the constraints check issue in `sdh.getLocalMediaStream` later.
|
|
5497
|
-
this.localMediaStreamConstraints = options.constraints;
|
|
5498
|
-
|
|
5499
|
-
return sessionDescription;
|
|
5500
|
-
})
|
|
5501
5968
|
.then((sessionDescription) => ({ body: sessionDescription.sdp, contentType: 'application/sdp' }))
|
|
5502
5969
|
.catch((error) => {
|
|
5503
5970
|
wazoLogger.error('error when creating media', error);
|
|
@@ -5692,6 +6159,9 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5692
6159
|
|
|
5693
6160
|
// set the transceiver direction to the answer direction
|
|
5694
6161
|
this._peerConnection.getTransceivers().forEach((transceiver) => {
|
|
6162
|
+
if (transceiver.stopped) {
|
|
6163
|
+
return;
|
|
6164
|
+
}
|
|
5695
6165
|
if (transceiver.direction /* guarding, but should always be true */) {
|
|
5696
6166
|
const { receiver } = transceiver;
|
|
5697
6167
|
if (isConference && audioOnly && receiver.track && receiver.track.kind === 'video') {
|
|
@@ -5736,10 +6206,15 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5736
6206
|
if (kind !== 'audio' && kind !== 'video') {
|
|
5737
6207
|
throw new Error(`Unknown new track kind ${kind}.`);
|
|
5738
6208
|
}
|
|
5739
|
-
const sender = pc.getSenders().find((otherSender) =>
|
|
6209
|
+
const sender = pc.getSenders && pc.getSenders().find((otherSender) =>
|
|
6210
|
+
otherSender.track && otherSender.track.kind === kind);
|
|
5740
6211
|
|
|
5741
6212
|
// Do not reuse sender video tracks in SFU
|
|
5742
6213
|
if (sender && (!sfu || newTrack.kind === 'audio')) {
|
|
6214
|
+
if (sender.track) {
|
|
6215
|
+
// eslint-disable-next-line no-param-reassign
|
|
6216
|
+
newTrack.enabled = sender.track.enabled;
|
|
6217
|
+
}
|
|
5743
6218
|
trackUpdates.push(
|
|
5744
6219
|
new Promise((resolve) => {
|
|
5745
6220
|
this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - replacing sender ${kind} track`);
|
|
@@ -5773,7 +6248,11 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5773
6248
|
// Review: could make streamless tracks a configurable option?
|
|
5774
6249
|
// https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addTrack#Usage_notes
|
|
5775
6250
|
try {
|
|
5776
|
-
pc.addTrack
|
|
6251
|
+
if (pc.addTrack) {
|
|
6252
|
+
pc.addTrack(newTrack, localStream);
|
|
6253
|
+
} else {
|
|
6254
|
+
pc.addStream(localStream);
|
|
6255
|
+
}
|
|
5777
6256
|
} catch (error) {
|
|
5778
6257
|
this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to add sender ${kind} track`);
|
|
5779
6258
|
throw error;
|
|
@@ -5909,7 +6388,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
5909
6388
|
const SEND_STATS_DELAY = 5000;
|
|
5910
6389
|
|
|
5911
6390
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
5912
|
-
const logger$
|
|
6391
|
+
const logger$8 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
5913
6392
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
5914
6393
|
|
|
5915
6394
|
// events
|
|
@@ -5955,6 +6434,7 @@ const MAX_REGISTER_TRIES = 10;
|
|
|
5955
6434
|
|
|
5956
6435
|
|
|
5957
6436
|
|
|
6437
|
+
|
|
5958
6438
|
|
|
5959
6439
|
|
|
5960
6440
|
|
|
@@ -5981,6 +6461,7 @@ class WebRTCClient extends Emitter {
|
|
|
5981
6461
|
|
|
5982
6462
|
|
|
5983
6463
|
|
|
6464
|
+
|
|
5984
6465
|
|
|
5985
6466
|
// sugar
|
|
5986
6467
|
|
|
@@ -6019,6 +6500,8 @@ class WebRTCClient extends Emitter {
|
|
|
6019
6500
|
super();
|
|
6020
6501
|
this.uaConfigOverrides = uaConfigOverrides;
|
|
6021
6502
|
this.config = config;
|
|
6503
|
+
this.skipRegister = config.skipRegister;
|
|
6504
|
+
|
|
6022
6505
|
this._buildConfig(config, session).then((newConfig ) => {
|
|
6023
6506
|
this.config = newConfig;
|
|
6024
6507
|
this.userAgent = this.createUserAgent(uaConfigOverrides);
|
|
@@ -6074,13 +6557,13 @@ class WebRTCClient extends Emitter {
|
|
|
6074
6557
|
|
|
6075
6558
|
createUserAgent(configOverrides ) {
|
|
6076
6559
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6077
|
-
logger$
|
|
6560
|
+
logger$8.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6078
6561
|
|
|
6079
6562
|
webRTCConfiguration.delegate = {
|
|
6080
6563
|
onConnect: this.onConnect.bind(this),
|
|
6081
6564
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6082
6565
|
onInvite: (invitation ) => {
|
|
6083
|
-
logger$
|
|
6566
|
+
logger$8.info('sdk webrtc on invite', {
|
|
6084
6567
|
method: 'delegate.onInvite',
|
|
6085
6568
|
id: invitation.id,
|
|
6086
6569
|
remoteURI: invitation.remoteURI,
|
|
@@ -6123,7 +6606,7 @@ class WebRTCClient extends Emitter {
|
|
|
6123
6606
|
}
|
|
6124
6607
|
|
|
6125
6608
|
onConnect() {
|
|
6126
|
-
logger$
|
|
6609
|
+
logger$8.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6127
6610
|
this.eventEmitter.emit(CONNECTED);
|
|
6128
6611
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6129
6612
|
this.registerer.waitingToggle(false);
|
|
@@ -6132,7 +6615,7 @@ class WebRTCClient extends Emitter {
|
|
|
6132
6615
|
}
|
|
6133
6616
|
|
|
6134
6617
|
async onDisconnect(error ) {
|
|
6135
|
-
logger$
|
|
6618
|
+
logger$8.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6136
6619
|
this.connectionPromise = null;
|
|
6137
6620
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6138
6621
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6146,40 +6629,48 @@ class WebRTCClient extends Emitter {
|
|
|
6146
6629
|
}
|
|
6147
6630
|
|
|
6148
6631
|
register(tries = 0) {
|
|
6149
|
-
|
|
6632
|
+
const logInfo = {
|
|
6150
6633
|
userAgent: !!this.userAgent,
|
|
6151
6634
|
registered: this.isRegistered(),
|
|
6152
6635
|
connectionPromise: !!this.connectionPromise,
|
|
6153
6636
|
registerer: !!this.registerer,
|
|
6154
6637
|
waiting: this.registerer && this.registerer.waiting,
|
|
6155
6638
|
tries,
|
|
6156
|
-
|
|
6639
|
+
skipRegister: this.skipRegister,
|
|
6640
|
+
};
|
|
6641
|
+
|
|
6642
|
+
if (this.skipRegister) {
|
|
6643
|
+
logger$8.info('sdk webrtc skip register...', logInfo);
|
|
6644
|
+
return Promise.resolve();
|
|
6645
|
+
}
|
|
6646
|
+
|
|
6647
|
+
logger$8.info('sdk webrtc registering...', logInfo);
|
|
6157
6648
|
|
|
6158
6649
|
if (!this.userAgent) {
|
|
6159
|
-
logger$
|
|
6650
|
+
logger$8.info('sdk webrtc recreating User Agent');
|
|
6160
6651
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6161
6652
|
}
|
|
6162
6653
|
if (!this.userAgent || this.isRegistered()) {
|
|
6163
|
-
logger$
|
|
6654
|
+
logger$8.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6164
6655
|
return Promise.resolve();
|
|
6165
6656
|
}
|
|
6166
6657
|
|
|
6167
6658
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6168
|
-
logger$
|
|
6659
|
+
logger$8.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6169
6660
|
return Promise.resolve();
|
|
6170
6661
|
}
|
|
6171
6662
|
|
|
6172
6663
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6173
6664
|
|
|
6174
6665
|
const onRegisterFailed = () => {
|
|
6175
|
-
logger$
|
|
6666
|
+
logger$8.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6176
6667
|
this.connectionPromise = null;
|
|
6177
6668
|
if (this.registerer && this.registerer.waiting) {
|
|
6178
6669
|
this.registerer.waitingToggle(false);
|
|
6179
6670
|
}
|
|
6180
6671
|
|
|
6181
6672
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6182
|
-
logger$
|
|
6673
|
+
logger$8.info('sdk webrtc registering, retrying...', { tries });
|
|
6183
6674
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6184
6675
|
}
|
|
6185
6676
|
};
|
|
@@ -6188,18 +6679,18 @@ class WebRTCClient extends Emitter {
|
|
|
6188
6679
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6189
6680
|
// during the resolution of the primise.
|
|
6190
6681
|
if (!this.userAgent) {
|
|
6191
|
-
logger$
|
|
6682
|
+
logger$8.info('sdk webrtc recreating User Agent after connection');
|
|
6192
6683
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6193
6684
|
}
|
|
6194
6685
|
|
|
6195
|
-
logger$
|
|
6686
|
+
logger$8.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6196
6687
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
6197
6688
|
this.connectionPromise = null;
|
|
6198
6689
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6199
6690
|
|
|
6200
6691
|
// Bind registerer events
|
|
6201
6692
|
this.registerer.stateChange.addListener(newState => {
|
|
6202
|
-
logger$
|
|
6693
|
+
logger$8.info('sdk webrtc registering, state changed', { newState });
|
|
6203
6694
|
|
|
6204
6695
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
6205
6696
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -6212,7 +6703,7 @@ class WebRTCClient extends Emitter {
|
|
|
6212
6703
|
const options = {
|
|
6213
6704
|
requestDelegate: {
|
|
6214
6705
|
onReject: response => {
|
|
6215
|
-
logger$
|
|
6706
|
+
logger$8.error('sdk webrtc registering, rejected', { response });
|
|
6216
6707
|
|
|
6217
6708
|
onRegisterFailed();
|
|
6218
6709
|
},
|
|
@@ -6220,13 +6711,13 @@ class WebRTCClient extends Emitter {
|
|
|
6220
6711
|
};
|
|
6221
6712
|
|
|
6222
6713
|
return this.registerer.register(options).catch((e) => {
|
|
6223
|
-
logger$
|
|
6714
|
+
logger$8.error('sdk webrtc registering, error', e);
|
|
6224
6715
|
|
|
6225
6716
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6226
6717
|
return e;
|
|
6227
6718
|
});
|
|
6228
6719
|
}).catch(error => {
|
|
6229
|
-
logger$
|
|
6720
|
+
logger$8.error('sdk webrtc registering, transport error', error);
|
|
6230
6721
|
onRegisterFailed();
|
|
6231
6722
|
});
|
|
6232
6723
|
}
|
|
@@ -6255,21 +6746,21 @@ class WebRTCClient extends Emitter {
|
|
|
6255
6746
|
}
|
|
6256
6747
|
|
|
6257
6748
|
unregister() {
|
|
6258
|
-
logger$
|
|
6749
|
+
logger$8.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6259
6750
|
if (!this.registerer) {
|
|
6260
6751
|
return Promise.resolve();
|
|
6261
6752
|
}
|
|
6262
6753
|
|
|
6263
6754
|
try {
|
|
6264
6755
|
return this.registerer.unregister().then(() => {
|
|
6265
|
-
logger$
|
|
6756
|
+
logger$8.info('sdk webrtc unregistered');
|
|
6266
6757
|
this._cleanupRegister();
|
|
6267
6758
|
}).catch(e => {
|
|
6268
|
-
logger$
|
|
6759
|
+
logger$8.error('sdk webrtc unregistering, promise error', e);
|
|
6269
6760
|
this._cleanupRegister();
|
|
6270
6761
|
});
|
|
6271
6762
|
} catch (e) {
|
|
6272
|
-
logger$
|
|
6763
|
+
logger$8.error('sdk webrtc unregistering, error', e);
|
|
6273
6764
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6274
6765
|
// error when the registerer is in a bad state
|
|
6275
6766
|
this._cleanupRegister();
|
|
@@ -6277,7 +6768,7 @@ class WebRTCClient extends Emitter {
|
|
|
6277
6768
|
}
|
|
6278
6769
|
|
|
6279
6770
|
stop() {
|
|
6280
|
-
logger$
|
|
6771
|
+
logger$8.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6281
6772
|
if (!this.userAgent) {
|
|
6282
6773
|
return Promise.resolve();
|
|
6283
6774
|
}
|
|
@@ -6285,12 +6776,12 @@ class WebRTCClient extends Emitter {
|
|
|
6285
6776
|
return this.userAgent.stop().then(() => {
|
|
6286
6777
|
return this._cleanupRegister();
|
|
6287
6778
|
}).catch(e => {
|
|
6288
|
-
logger$
|
|
6779
|
+
logger$8.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6289
6780
|
});
|
|
6290
6781
|
}
|
|
6291
6782
|
|
|
6292
6783
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6293
|
-
logger$
|
|
6784
|
+
logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6294
6785
|
const inviterOptions = {
|
|
6295
6786
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6296
6787
|
conference,
|
|
@@ -6319,7 +6810,7 @@ class WebRTCClient extends Emitter {
|
|
|
6319
6810
|
this._onAccepted(session, response.session, true);
|
|
6320
6811
|
},
|
|
6321
6812
|
onReject: (response ) => {
|
|
6322
|
-
logger$
|
|
6813
|
+
logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6323
6814
|
this._stopSendingStats(session);
|
|
6324
6815
|
|
|
6325
6816
|
this.eventEmitter.emit(REJECTED, session, response);
|
|
@@ -6341,11 +6832,11 @@ class WebRTCClient extends Emitter {
|
|
|
6341
6832
|
}
|
|
6342
6833
|
|
|
6343
6834
|
answer(session , enableVideo ) {
|
|
6344
|
-
logger$
|
|
6835
|
+
logger$8.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6345
6836
|
|
|
6346
6837
|
if (!session || !session.accept) {
|
|
6347
6838
|
const error = 'No session to answer, or not an invitation';
|
|
6348
|
-
logger$
|
|
6839
|
+
logger$8.warn(error);
|
|
6349
6840
|
return Promise.reject(new Error(error));
|
|
6350
6841
|
}
|
|
6351
6842
|
const options = {
|
|
@@ -6355,15 +6846,15 @@ class WebRTCClient extends Emitter {
|
|
|
6355
6846
|
return session.accept(options).then(() => {
|
|
6356
6847
|
if (session.isCanceled) {
|
|
6357
6848
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
6358
|
-
logger$
|
|
6849
|
+
logger$8.error(message, { id: session.id });
|
|
6359
6850
|
this.onCallEnded(session);
|
|
6360
6851
|
|
|
6361
6852
|
throw new CanceledCallError(message);
|
|
6362
6853
|
}
|
|
6363
|
-
logger$
|
|
6854
|
+
logger$8.info('sdk webrtc answer, accepted.');
|
|
6364
6855
|
this._onAccepted(session);
|
|
6365
6856
|
}).catch(e => {
|
|
6366
|
-
logger$
|
|
6857
|
+
logger$8.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6367
6858
|
|
|
6368
6859
|
throw e;
|
|
6369
6860
|
});
|
|
@@ -6371,7 +6862,7 @@ class WebRTCClient extends Emitter {
|
|
|
6371
6862
|
|
|
6372
6863
|
hangup(session ) {
|
|
6373
6864
|
const { state, id } = session;
|
|
6374
|
-
logger$
|
|
6865
|
+
logger$8.info('sdk webrtc hangup call', { id, state });
|
|
6375
6866
|
|
|
6376
6867
|
try {
|
|
6377
6868
|
this._stopSendingStats(session);
|
|
@@ -6400,24 +6891,24 @@ class WebRTCClient extends Emitter {
|
|
|
6400
6891
|
|
|
6401
6892
|
return bye();
|
|
6402
6893
|
} catch (error) {
|
|
6403
|
-
logger$
|
|
6894
|
+
logger$8.warn('sdk webrtc hangup, error', error);
|
|
6404
6895
|
}
|
|
6405
6896
|
|
|
6406
6897
|
return null;
|
|
6407
6898
|
}
|
|
6408
6899
|
|
|
6409
6900
|
reject(session ) {
|
|
6410
|
-
logger$
|
|
6901
|
+
logger$8.info('sdk webrtc reject call', { id: session.id });
|
|
6411
6902
|
|
|
6412
6903
|
try {
|
|
6413
6904
|
return session.reject ? session.reject() : session.cancel();
|
|
6414
6905
|
} catch (e) {
|
|
6415
|
-
logger$
|
|
6906
|
+
logger$8.warn('Error when rejecting call', e.message, e.stack);
|
|
6416
6907
|
}
|
|
6417
6908
|
}
|
|
6418
6909
|
|
|
6419
6910
|
async close() {
|
|
6420
|
-
logger$
|
|
6911
|
+
logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6421
6912
|
this._cleanupMedia();
|
|
6422
6913
|
this.connectionPromise = null;
|
|
6423
6914
|
|
|
@@ -6448,7 +6939,7 @@ class WebRTCClient extends Emitter {
|
|
|
6448
6939
|
// eg: "INVITE not rejectable in state Completed"
|
|
6449
6940
|
}
|
|
6450
6941
|
this.userAgent = null;
|
|
6451
|
-
logger$
|
|
6942
|
+
logger$8.info('sdk webrtc client closed');
|
|
6452
6943
|
}
|
|
6453
6944
|
|
|
6454
6945
|
getNumber(session ) {
|
|
@@ -6461,13 +6952,13 @@ class WebRTCClient extends Emitter {
|
|
|
6461
6952
|
}
|
|
6462
6953
|
|
|
6463
6954
|
mute(session ) {
|
|
6464
|
-
logger$
|
|
6955
|
+
logger$8.info('sdk webrtc mute', { id: session.id });
|
|
6465
6956
|
|
|
6466
6957
|
this._toggleAudio(session, true);
|
|
6467
6958
|
}
|
|
6468
6959
|
|
|
6469
6960
|
unmute(session ) {
|
|
6470
|
-
logger$
|
|
6961
|
+
logger$8.info('sdk webrtc unmute', { id: session.id });
|
|
6471
6962
|
|
|
6472
6963
|
this._toggleAudio(session, false);
|
|
6473
6964
|
}
|
|
@@ -6484,12 +6975,18 @@ class WebRTCClient extends Emitter {
|
|
|
6484
6975
|
}
|
|
6485
6976
|
|
|
6486
6977
|
if (pc.getSenders) {
|
|
6978
|
+
if (!pc.getSenders().length) {
|
|
6979
|
+
return false;
|
|
6980
|
+
}
|
|
6487
6981
|
pc.getSenders().forEach(sender => {
|
|
6488
6982
|
if (sender && sender.track && sender.track.kind === 'audio') {
|
|
6489
6983
|
muted = muted && !sender.track.enabled;
|
|
6490
6984
|
}
|
|
6491
6985
|
});
|
|
6492
6986
|
} else {
|
|
6987
|
+
if (!pc.getLocalStreams().length) {
|
|
6988
|
+
return false;
|
|
6989
|
+
}
|
|
6493
6990
|
pc.getLocalStreams().forEach(stream => {
|
|
6494
6991
|
stream.getAudioTracks().forEach(track => {
|
|
6495
6992
|
muted = muted && !track.enabled;
|
|
@@ -6501,20 +6998,20 @@ class WebRTCClient extends Emitter {
|
|
|
6501
6998
|
}
|
|
6502
6999
|
|
|
6503
7000
|
toggleCameraOn(session ) {
|
|
6504
|
-
logger$
|
|
7001
|
+
logger$8.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6505
7002
|
|
|
6506
7003
|
this._toggleVideo(session, false);
|
|
6507
7004
|
}
|
|
6508
7005
|
|
|
6509
7006
|
toggleCameraOff(session ) {
|
|
6510
|
-
logger$
|
|
7007
|
+
logger$8.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6511
7008
|
|
|
6512
7009
|
this._toggleVideo(session, true);
|
|
6513
7010
|
}
|
|
6514
7011
|
|
|
6515
7012
|
hold(session , isConference = false) {
|
|
6516
7013
|
const sessionId = this.getSipSessionId(session);
|
|
6517
|
-
logger$
|
|
7014
|
+
logger$8.info('sdk webrtc hold', {
|
|
6518
7015
|
sessionId,
|
|
6519
7016
|
keys: Object.keys(this.heldSessions),
|
|
6520
7017
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6546,6 +7043,9 @@ class WebRTCClient extends Emitter {
|
|
|
6546
7043
|
if (!this._isWeb()) {
|
|
6547
7044
|
options.sessionDescriptionHandlerModifiers = [modifiers.holdModifier];
|
|
6548
7045
|
}
|
|
7046
|
+
options.sessionDescriptionHandlerOptions = {
|
|
7047
|
+
constraints: options.constraints,
|
|
7048
|
+
};
|
|
6549
7049
|
|
|
6550
7050
|
// Send re-INVITE
|
|
6551
7051
|
return session.invite(options);
|
|
@@ -6554,7 +7054,7 @@ class WebRTCClient extends Emitter {
|
|
|
6554
7054
|
unhold(session , isConference = false) {
|
|
6555
7055
|
const sessionId = this.getSipSessionId(session);
|
|
6556
7056
|
|
|
6557
|
-
logger$
|
|
7057
|
+
logger$8.info('sdk webrtc unhold', {
|
|
6558
7058
|
sessionId,
|
|
6559
7059
|
keys: Object.keys(this.heldSessions),
|
|
6560
7060
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6585,6 +7085,9 @@ class WebRTCClient extends Emitter {
|
|
|
6585
7085
|
// (eg: holdModifier)
|
|
6586
7086
|
options.sessionDescriptionHandlerModifiers = [];
|
|
6587
7087
|
}
|
|
7088
|
+
options.sessionDescriptionHandlerOptions = {
|
|
7089
|
+
constraints: options.constraints,
|
|
7090
|
+
};
|
|
6588
7091
|
|
|
6589
7092
|
// Send re-INVITE
|
|
6590
7093
|
return session.invite(options);
|
|
@@ -6642,7 +7145,7 @@ class WebRTCClient extends Emitter {
|
|
|
6642
7145
|
return;
|
|
6643
7146
|
}
|
|
6644
7147
|
|
|
6645
|
-
logger$
|
|
7148
|
+
logger$8.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6646
7149
|
|
|
6647
7150
|
try {
|
|
6648
7151
|
sipSession.message({
|
|
@@ -6767,7 +7270,8 @@ class WebRTCClient extends Emitter {
|
|
|
6767
7270
|
}
|
|
6768
7271
|
const sdh = session.sessionDescriptionHandler;
|
|
6769
7272
|
const pc = sdh.peerConnection;
|
|
6770
|
-
const
|
|
7273
|
+
const sessionId = this.getSipSessionId(session);
|
|
7274
|
+
const localStream = this.getLocalStream(sessionId);
|
|
6771
7275
|
|
|
6772
7276
|
// Release old video stream
|
|
6773
7277
|
if (localStream) {
|
|
@@ -6793,11 +7297,8 @@ class WebRTCClient extends Emitter {
|
|
|
6793
7297
|
|
|
6794
7298
|
// let's update the local stream
|
|
6795
7299
|
this.eventEmitter.emit('onVideoInputChange', stream);
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
} catch (_) {
|
|
6799
|
-
// Nothing to do
|
|
6800
|
-
}
|
|
7300
|
+
this.setLocalMediaStream(sessionId, stream);
|
|
7301
|
+
|
|
6801
7302
|
return stream;
|
|
6802
7303
|
});
|
|
6803
7304
|
}
|
|
@@ -7009,7 +7510,7 @@ class WebRTCClient extends Emitter {
|
|
|
7009
7510
|
}
|
|
7010
7511
|
|
|
7011
7512
|
startHeartbeat() {
|
|
7012
|
-
logger$
|
|
7513
|
+
logger$8.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7013
7514
|
if (!this.userAgent) {
|
|
7014
7515
|
this.heartbeat.stop();
|
|
7015
7516
|
return;
|
|
@@ -7022,7 +7523,7 @@ class WebRTCClient extends Emitter {
|
|
|
7022
7523
|
}
|
|
7023
7524
|
|
|
7024
7525
|
stopHeartbeat() {
|
|
7025
|
-
logger$
|
|
7526
|
+
logger$8.info('sdk webrtc stop heartbeat');
|
|
7026
7527
|
this.heartbeat.stop();
|
|
7027
7528
|
}
|
|
7028
7529
|
|
|
@@ -7042,7 +7543,7 @@ class WebRTCClient extends Emitter {
|
|
|
7042
7543
|
}
|
|
7043
7544
|
|
|
7044
7545
|
attemptReconnection() {
|
|
7045
|
-
logger$
|
|
7546
|
+
logger$8.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7046
7547
|
if (!this.userAgent) {
|
|
7047
7548
|
return;
|
|
7048
7549
|
}
|
|
@@ -7099,9 +7600,11 @@ class WebRTCClient extends Emitter {
|
|
|
7099
7600
|
remoteStream.removeTrack(track);
|
|
7100
7601
|
});
|
|
7101
7602
|
|
|
7102
|
-
pc.getReceivers
|
|
7103
|
-
|
|
7104
|
-
|
|
7603
|
+
if (pc.getReceivers) {
|
|
7604
|
+
pc.getReceivers().forEach(receiver => {
|
|
7605
|
+
remoteStream.addTrack(receiver.track);
|
|
7606
|
+
});
|
|
7607
|
+
}
|
|
7105
7608
|
}
|
|
7106
7609
|
|
|
7107
7610
|
getMediaConfiguration(enableVideo , conference = false, constraints = null) {
|
|
@@ -7136,6 +7639,25 @@ class WebRTCClient extends Emitter {
|
|
|
7136
7639
|
return sessionId in this.conferences;
|
|
7137
7640
|
}
|
|
7138
7641
|
|
|
7642
|
+
createAudioElementFor(sessionId ) {
|
|
7643
|
+
const audio = document.createElement('audio');
|
|
7644
|
+
audio.setAttribute('id', `audio-${sessionId}`);
|
|
7645
|
+
|
|
7646
|
+
if (audio.setSinkId && this.audioOutputDeviceId) {
|
|
7647
|
+
audio.setSinkId(this.audioOutputDeviceId);
|
|
7648
|
+
}
|
|
7649
|
+
|
|
7650
|
+
if (document.body) {
|
|
7651
|
+
document.body.appendChild(audio);
|
|
7652
|
+
}
|
|
7653
|
+
this.audioElements[sessionId] = audio;
|
|
7654
|
+
|
|
7655
|
+
audio.volume = this.audioOutputVolume;
|
|
7656
|
+
audio.autoplay = true;
|
|
7657
|
+
|
|
7658
|
+
return audio;
|
|
7659
|
+
}
|
|
7660
|
+
|
|
7139
7661
|
_onTransportError() {
|
|
7140
7662
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
7141
7663
|
this.attemptReconnection();
|
|
@@ -7145,7 +7667,7 @@ class WebRTCClient extends Emitter {
|
|
|
7145
7667
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
7146
7668
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
7147
7669
|
if (this.hasHeartbeat()) {
|
|
7148
|
-
logger$
|
|
7670
|
+
logger$8.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7149
7671
|
|
|
7150
7672
|
this.heartbeat.onHeartbeat();
|
|
7151
7673
|
if (this.heartbeatCb) {
|
|
@@ -7156,7 +7678,7 @@ class WebRTCClient extends Emitter {
|
|
|
7156
7678
|
}
|
|
7157
7679
|
|
|
7158
7680
|
async _onHeartbeatTimeout() {
|
|
7159
|
-
logger$
|
|
7681
|
+
logger$8.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7160
7682
|
|
|
7161
7683
|
if (this.heartbeatTimeoutCb) {
|
|
7162
7684
|
this.heartbeatTimeoutCb();
|
|
@@ -7168,7 +7690,7 @@ class WebRTCClient extends Emitter {
|
|
|
7168
7690
|
try {
|
|
7169
7691
|
await this.userAgent.transport.disconnect();
|
|
7170
7692
|
} catch (e) {
|
|
7171
|
-
logger$
|
|
7693
|
+
logger$8.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7172
7694
|
}
|
|
7173
7695
|
}
|
|
7174
7696
|
|
|
@@ -7201,31 +7723,31 @@ class WebRTCClient extends Emitter {
|
|
|
7201
7723
|
}
|
|
7202
7724
|
|
|
7203
7725
|
_connectIfNeeded() {
|
|
7204
|
-
logger$
|
|
7726
|
+
logger$8.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7205
7727
|
if (!this.userAgent) {
|
|
7206
|
-
logger$
|
|
7728
|
+
logger$8.info('need to recreate User Agent');
|
|
7207
7729
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
7208
7730
|
}
|
|
7209
7731
|
|
|
7210
7732
|
if (this.isConnected()) {
|
|
7211
|
-
logger$
|
|
7733
|
+
logger$8.info('webrtc sdk, already connected');
|
|
7212
7734
|
return Promise.resolve();
|
|
7213
7735
|
}
|
|
7214
7736
|
|
|
7215
7737
|
if (this.isConnecting()) {
|
|
7216
|
-
logger$
|
|
7738
|
+
logger$8.info('webrtc sdk, already connecting...');
|
|
7217
7739
|
|
|
7218
7740
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
7219
7741
|
return this.connectionPromise;
|
|
7220
7742
|
}
|
|
7221
7743
|
|
|
7222
7744
|
if (this.connectionPromise) {
|
|
7223
|
-
logger$
|
|
7745
|
+
logger$8.info('webrtc sdk, connection promise connecting...');
|
|
7224
7746
|
// $FlowFixMe
|
|
7225
7747
|
return this.connectionPromise;
|
|
7226
7748
|
}
|
|
7227
7749
|
|
|
7228
|
-
logger$
|
|
7750
|
+
logger$8.info('WebRTC UA needs to connect');
|
|
7229
7751
|
|
|
7230
7752
|
// Force UA to reconnect
|
|
7231
7753
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -7350,7 +7872,7 @@ class WebRTCClient extends Emitter {
|
|
|
7350
7872
|
|
|
7351
7873
|
sdh.peerConnectionDelegate = {
|
|
7352
7874
|
onicecandidateerror: (error ) => {
|
|
7353
|
-
logger$
|
|
7875
|
+
logger$8.error('on icecandidate error', {
|
|
7354
7876
|
address: error.address,
|
|
7355
7877
|
port: error.port,
|
|
7356
7878
|
errorCode: error.errorCode,
|
|
@@ -7365,7 +7887,7 @@ class WebRTCClient extends Emitter {
|
|
|
7365
7887
|
let hadRemoteVideo = false;
|
|
7366
7888
|
|
|
7367
7889
|
// Monkey patch `onInviteRequest` to be able to know if there was a remote video stream before `onInvite` is called
|
|
7368
|
-
//
|
|
7890
|
+
// Because when `onInvite` is called we already got the video track
|
|
7369
7891
|
session.onInviteRequest = (request) => {
|
|
7370
7892
|
hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
|
|
7371
7893
|
|
|
@@ -7379,7 +7901,7 @@ class WebRTCClient extends Emitter {
|
|
|
7379
7901
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
7380
7902
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
7381
7903
|
}
|
|
7382
|
-
logger$
|
|
7904
|
+
logger$8.info('re-invite received', { updatedCalleeName, updatedNumber });
|
|
7383
7905
|
|
|
7384
7906
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
7385
7907
|
|
|
@@ -7400,7 +7922,7 @@ class WebRTCClient extends Emitter {
|
|
|
7400
7922
|
}
|
|
7401
7923
|
|
|
7402
7924
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
7403
|
-
logger$
|
|
7925
|
+
logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7404
7926
|
|
|
7405
7927
|
this.storeSipSession(session);
|
|
7406
7928
|
|
|
@@ -7440,20 +7962,10 @@ class WebRTCClient extends Emitter {
|
|
|
7440
7962
|
const isConference = this.isConference(sessionId);
|
|
7441
7963
|
|
|
7442
7964
|
if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
|
|
7443
|
-
|
|
7444
|
-
audio.setAttribute('id', `audio-${sessionId}`);
|
|
7445
|
-
|
|
7446
|
-
if (audio.setSinkId && this.audioOutputDeviceId) {
|
|
7447
|
-
audio.setSinkId(this.audioOutputDeviceId);
|
|
7448
|
-
}
|
|
7449
|
-
|
|
7450
|
-
if (document.body) {
|
|
7451
|
-
document.body.appendChild(audio);
|
|
7452
|
-
}
|
|
7453
|
-
this.audioElements[sessionId] = audio;
|
|
7965
|
+
this.createAudioElementFor(sessionId);
|
|
7454
7966
|
}
|
|
7455
7967
|
|
|
7456
|
-
const audioElement = this.audioElements[
|
|
7968
|
+
const audioElement = this.audioElements[sessionId];
|
|
7457
7969
|
const stream = newStream || this.getRemoteStream(sessionId);
|
|
7458
7970
|
|
|
7459
7971
|
if (!this._isWeb() || !stream) {
|
|
@@ -7600,10 +8112,10 @@ class WebRTCClient extends Emitter {
|
|
|
7600
8112
|
|
|
7601
8113
|
_stopSendingStats(session ) {
|
|
7602
8114
|
const sessionId = this.getSipSessionId(session);
|
|
7603
|
-
logger$
|
|
8115
|
+
logger$8.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7604
8116
|
|
|
7605
8117
|
if (sessionId in this.statsIntervals) {
|
|
7606
|
-
logger$
|
|
8118
|
+
logger$8.trace('Stop sending stats for call', { sessionId });
|
|
7607
8119
|
this.statsIntervals[sessionId]();
|
|
7608
8120
|
delete this.statsIntervals[sessionId];
|
|
7609
8121
|
}
|
|
@@ -7619,7 +8131,7 @@ class WebRTCClient extends Emitter {
|
|
|
7619
8131
|
try {
|
|
7620
8132
|
await this.userAgent.transport.disconnect();
|
|
7621
8133
|
} catch (e) {
|
|
7622
|
-
logger$
|
|
8134
|
+
logger$8.error('WebRTC transport disconnect, error', e);
|
|
7623
8135
|
}
|
|
7624
8136
|
}
|
|
7625
8137
|
}
|
|
@@ -7706,7 +8218,7 @@ const events = [
|
|
|
7706
8218
|
ON_SIGNAL,
|
|
7707
8219
|
];
|
|
7708
8220
|
|
|
7709
|
-
const logger$
|
|
8221
|
+
const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
7710
8222
|
|
|
7711
8223
|
class WebRTCPhone extends Emitter {
|
|
7712
8224
|
|
|
@@ -7777,7 +8289,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7777
8289
|
}).catch(error => {
|
|
7778
8290
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
7779
8291
|
console.error('register error', error, error.message, error.stack);
|
|
7780
|
-
logger$
|
|
8292
|
+
logger$7.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
7781
8293
|
});
|
|
7782
8294
|
}
|
|
7783
8295
|
|
|
@@ -7792,7 +8304,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7792
8304
|
if (!this.client) {
|
|
7793
8305
|
return;
|
|
7794
8306
|
}
|
|
7795
|
-
logger$
|
|
8307
|
+
logger$7.info('WebRTC phone stop');
|
|
7796
8308
|
this.client.stop();
|
|
7797
8309
|
}
|
|
7798
8310
|
|
|
@@ -7807,14 +8319,14 @@ class WebRTCPhone extends Emitter {
|
|
|
7807
8319
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
7808
8320
|
audioOnly = false) {
|
|
7809
8321
|
const sipSession = this.findSipSession(callSession);
|
|
7810
|
-
logger$
|
|
8322
|
+
logger$7.info('WebRTC phone - send reinvite', {
|
|
7811
8323
|
sessionId: sipSession ? sipSession.id : null,
|
|
7812
8324
|
constraints,
|
|
7813
8325
|
audioOnly,
|
|
7814
8326
|
});
|
|
7815
8327
|
|
|
7816
8328
|
if (!sipSession) {
|
|
7817
|
-
return
|
|
8329
|
+
return false;
|
|
7818
8330
|
}
|
|
7819
8331
|
|
|
7820
8332
|
// $FlowFixMe
|
|
@@ -7824,19 +8336,17 @@ class WebRTCPhone extends Emitter {
|
|
|
7824
8336
|
// Downgrade
|
|
7825
8337
|
if (constraints && !isUpgrade) {
|
|
7826
8338
|
// No reinvite needed
|
|
7827
|
-
|
|
8339
|
+
this._downgradeToAudio(callSession);
|
|
8340
|
+
return false;
|
|
7828
8341
|
}
|
|
7829
8342
|
|
|
7830
8343
|
if (isUpgrade) {
|
|
7831
8344
|
const shouldReinvite = await this._upgradeToVideo(callSession, constraints, conference);
|
|
7832
8345
|
if (!shouldReinvite) {
|
|
7833
|
-
return;
|
|
8346
|
+
return false;
|
|
7834
8347
|
}
|
|
7835
8348
|
}
|
|
7836
8349
|
|
|
7837
|
-
// Force reinvite in SDH
|
|
7838
|
-
sipSession.sessionDescriptionHandler.localMediaStreamConstraints = null;
|
|
7839
|
-
|
|
7840
8350
|
return this.client.reinvite(sipSession, constraints, conference, audioOnly);
|
|
7841
8351
|
}
|
|
7842
8352
|
|
|
@@ -7845,7 +8355,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7845
8355
|
}
|
|
7846
8356
|
|
|
7847
8357
|
startHeartbeat() {
|
|
7848
|
-
logger$
|
|
8358
|
+
logger$7.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
7849
8359
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
7850
8360
|
return;
|
|
7851
8361
|
}
|
|
@@ -7854,7 +8364,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7854
8364
|
}
|
|
7855
8365
|
|
|
7856
8366
|
stopHeartbeat() {
|
|
7857
|
-
logger$
|
|
8367
|
+
logger$7.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
7858
8368
|
if (!this.client) {
|
|
7859
8369
|
return;
|
|
7860
8370
|
}
|
|
@@ -7871,7 +8381,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7871
8381
|
}
|
|
7872
8382
|
|
|
7873
8383
|
reconnect() {
|
|
7874
|
-
logger$
|
|
8384
|
+
logger$7.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
7875
8385
|
if (!this.client) {
|
|
7876
8386
|
return;
|
|
7877
8387
|
}
|
|
@@ -7909,7 +8419,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7909
8419
|
_downgradeToAudio(callSession ) {
|
|
7910
8420
|
const sipSession = this.findSipSession(callSession);
|
|
7911
8421
|
if (!sipSession) {
|
|
7912
|
-
return;
|
|
8422
|
+
return false;
|
|
7913
8423
|
}
|
|
7914
8424
|
|
|
7915
8425
|
// Release local video stream when downgrading to audio
|
|
@@ -8022,7 +8532,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8022
8532
|
// Monkey patch to know when canceled with the CANCEL message
|
|
8023
8533
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
8024
8534
|
sipSession._onCancel = (message ) => {
|
|
8025
|
-
logger$
|
|
8535
|
+
logger$7.trace('on sip session canceled', { callId: message.callId });
|
|
8026
8536
|
|
|
8027
8537
|
onCancel(message);
|
|
8028
8538
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
@@ -8047,13 +8557,13 @@ class WebRTCPhone extends Emitter {
|
|
|
8047
8557
|
this.audioOutputVolume,
|
|
8048
8558
|
);
|
|
8049
8559
|
case sessionState.SessionState.Terminating:
|
|
8050
|
-
logger$
|
|
8560
|
+
logger$7.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
8051
8561
|
|
|
8052
8562
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
8053
8563
|
|
|
8054
8564
|
break;
|
|
8055
8565
|
case sessionState.SessionState.Terminated:
|
|
8056
|
-
logger$
|
|
8566
|
+
logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
8057
8567
|
|
|
8058
8568
|
this._onCallTerminated(sipSession);
|
|
8059
8569
|
|
|
@@ -8089,7 +8599,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8089
8599
|
}
|
|
8090
8600
|
|
|
8091
8601
|
async startScreenSharing(constraints , callSession ) {
|
|
8092
|
-
logger$
|
|
8602
|
+
logger$7.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
8093
8603
|
|
|
8094
8604
|
const screenShareStream = await this._getStreamFromConstraints(constraints);
|
|
8095
8605
|
if (!screenShareStream) {
|
|
@@ -8111,6 +8621,10 @@ class WebRTCPhone extends Emitter {
|
|
|
8111
8621
|
localStream.removeTrack(videoTrack);
|
|
8112
8622
|
}
|
|
8113
8623
|
|
|
8624
|
+
if (localStream) {
|
|
8625
|
+
localStream.addTrack(screenTrack);
|
|
8626
|
+
}
|
|
8627
|
+
|
|
8114
8628
|
if (sender) {
|
|
8115
8629
|
sender.replaceTrack(screenTrack);
|
|
8116
8630
|
}
|
|
@@ -8125,7 +8639,8 @@ class WebRTCPhone extends Emitter {
|
|
|
8125
8639
|
return;
|
|
8126
8640
|
}
|
|
8127
8641
|
|
|
8128
|
-
logger$
|
|
8642
|
+
logger$7.info('WebRTC phone - stop screen sharing');
|
|
8643
|
+
let reinvited = false;
|
|
8129
8644
|
|
|
8130
8645
|
try {
|
|
8131
8646
|
if (this.currentScreenShare.stream) {
|
|
@@ -8140,7 +8655,8 @@ class WebRTCPhone extends Emitter {
|
|
|
8140
8655
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
8141
8656
|
// We have to downgrade to audio.
|
|
8142
8657
|
const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
|
|
8143
|
-
|
|
8658
|
+
const constraints = { audio: false, video: screenshareStopped };
|
|
8659
|
+
reinvited = await this.sendReinvite(targetCallSession, constraints, conference);
|
|
8144
8660
|
}
|
|
8145
8661
|
} catch (e) {
|
|
8146
8662
|
console.warn(e);
|
|
@@ -8154,6 +8670,8 @@ class WebRTCPhone extends Emitter {
|
|
|
8154
8670
|
);
|
|
8155
8671
|
|
|
8156
8672
|
this.currentScreenShare = null;
|
|
8673
|
+
|
|
8674
|
+
return reinvited;
|
|
8157
8675
|
}
|
|
8158
8676
|
|
|
8159
8677
|
async _getStreamFromConstraints(constraints , conference = false) {
|
|
@@ -8191,7 +8709,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8191
8709
|
}
|
|
8192
8710
|
|
|
8193
8711
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
8194
|
-
logger$
|
|
8712
|
+
logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
8195
8713
|
|
|
8196
8714
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
8197
8715
|
this.currentSipSession = sipSession;
|
|
@@ -8209,11 +8727,15 @@ class WebRTCPhone extends Emitter {
|
|
|
8209
8727
|
}
|
|
8210
8728
|
|
|
8211
8729
|
changeAudioDevice(id ) {
|
|
8212
|
-
logger$
|
|
8730
|
+
logger$7.info('WebRTC phone - change audio device', { deviceId: id });
|
|
8213
8731
|
this.audioOutputDeviceId = id;
|
|
8214
8732
|
this.client.changeAudioOutputDevice(id);
|
|
8215
8733
|
}
|
|
8216
8734
|
|
|
8735
|
+
createAudioElementFor(sessionId ) {
|
|
8736
|
+
return this.client.createAudioElementFor(sessionId);
|
|
8737
|
+
}
|
|
8738
|
+
|
|
8217
8739
|
changeRingDevice(id ) {
|
|
8218
8740
|
this.audioRingDeviceId = id;
|
|
8219
8741
|
}
|
|
@@ -8230,25 +8752,25 @@ class WebRTCPhone extends Emitter {
|
|
|
8230
8752
|
}
|
|
8231
8753
|
|
|
8232
8754
|
changeAudioInputDevice(id ) {
|
|
8233
|
-
logger$
|
|
8755
|
+
logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
8234
8756
|
|
|
8235
8757
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
8236
8758
|
}
|
|
8237
8759
|
|
|
8238
8760
|
changeVideoInputDevice(id ) {
|
|
8239
|
-
logger$
|
|
8761
|
+
logger$7.info('WebRTC phone - change video input device', { deviceId: id });
|
|
8240
8762
|
|
|
8241
8763
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
8242
8764
|
}
|
|
8243
8765
|
|
|
8244
8766
|
changeSessionVideoInputDevice(id ) {
|
|
8245
|
-
logger$
|
|
8767
|
+
logger$7.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
8246
8768
|
|
|
8247
8769
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
8248
8770
|
}
|
|
8249
8771
|
|
|
8250
8772
|
_onCallTerminated(sipSession ) {
|
|
8251
|
-
logger$
|
|
8773
|
+
logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
8252
8774
|
|
|
8253
8775
|
const callSession = this._createCallSession(sipSession);
|
|
8254
8776
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -8282,7 +8804,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8282
8804
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
8283
8805
|
|
|
8284
8806
|
// Re-trigger incoming call event for remaining incoming calls
|
|
8285
|
-
logger$
|
|
8807
|
+
logger$7.info('WebRTC phone - check to re-trigger incoming call', {
|
|
8286
8808
|
sipId: sipSession.id,
|
|
8287
8809
|
shouldRetrigger,
|
|
8288
8810
|
hasIncomingCallSession,
|
|
@@ -8371,37 +8893,37 @@ class WebRTCPhone extends Emitter {
|
|
|
8371
8893
|
|
|
8372
8894
|
// Deprecated
|
|
8373
8895
|
getLocalStreamForCall(callSession ) {
|
|
8374
|
-
logger$
|
|
8896
|
+
logger$7.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
8375
8897
|
|
|
8376
8898
|
return this.getLocalStream(callSession);
|
|
8377
8899
|
}
|
|
8378
8900
|
|
|
8379
8901
|
// Deprecated
|
|
8380
8902
|
getRemoteStreamForCall(callSession ) {
|
|
8381
|
-
logger$
|
|
8903
|
+
logger$7.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
8382
8904
|
|
|
8383
8905
|
return this.getRemoteVideoStream(callSession);
|
|
8384
8906
|
}
|
|
8385
8907
|
|
|
8386
8908
|
getRemoteStreamsForCall(callSession ) {
|
|
8387
|
-
logger$
|
|
8909
|
+
logger$7.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
8388
8910
|
|
|
8389
8911
|
return this.getRemoteStream(callSession);
|
|
8390
8912
|
}
|
|
8391
8913
|
|
|
8392
8914
|
accept(callSession , cameraEnabled ) {
|
|
8393
|
-
logger$
|
|
8915
|
+
logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
8394
8916
|
if (this.currentSipSession) {
|
|
8395
8917
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
8396
8918
|
}
|
|
8397
8919
|
|
|
8398
8920
|
if (!callSession) {
|
|
8399
|
-
logger$
|
|
8921
|
+
logger$7.warn('no CallSession to accept.');
|
|
8400
8922
|
return Promise.resolve(null);
|
|
8401
8923
|
}
|
|
8402
8924
|
|
|
8403
8925
|
if (callSession.getId() in this.acceptedSessions) {
|
|
8404
|
-
logger$
|
|
8926
|
+
logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
8405
8927
|
return Promise.resolve(callSession.sipCallId);
|
|
8406
8928
|
}
|
|
8407
8929
|
|
|
@@ -8413,24 +8935,24 @@ class WebRTCPhone extends Emitter {
|
|
|
8413
8935
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
8414
8936
|
if (sipSession) {
|
|
8415
8937
|
if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
|
|
8416
|
-
logger$
|
|
8938
|
+
logger$7.warn('Trying to answer a terminated sipSession.');
|
|
8417
8939
|
|
|
8418
8940
|
return Promise.resolve(null);
|
|
8419
8941
|
}
|
|
8420
8942
|
|
|
8421
|
-
logger$
|
|
8943
|
+
logger$7.info('accept call, session found', { sipId: sipSession.id });
|
|
8422
8944
|
|
|
8423
8945
|
// $FlowFixMe
|
|
8424
8946
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
8425
8947
|
return callSession.sipCallId;
|
|
8426
8948
|
}).catch(e => {
|
|
8427
|
-
logger$
|
|
8949
|
+
logger$7.error(e);
|
|
8428
8950
|
this.endCurrentCall(callSession);
|
|
8429
8951
|
throw e;
|
|
8430
8952
|
});
|
|
8431
8953
|
}
|
|
8432
8954
|
|
|
8433
|
-
logger$
|
|
8955
|
+
logger$7.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
8434
8956
|
|
|
8435
8957
|
return Promise.resolve(null);
|
|
8436
8958
|
}
|
|
@@ -8440,7 +8962,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8440
8962
|
}
|
|
8441
8963
|
|
|
8442
8964
|
async reject(callSession ) {
|
|
8443
|
-
logger$
|
|
8965
|
+
logger$7.info('reject WebRTC called', { id: callSession.getId() });
|
|
8444
8966
|
|
|
8445
8967
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
8446
8968
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -8452,14 +8974,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8452
8974
|
|
|
8453
8975
|
const sipSession = this.findSipSession(callSession);
|
|
8454
8976
|
if (sipSession) {
|
|
8455
|
-
logger$
|
|
8977
|
+
logger$7.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
8456
8978
|
|
|
8457
8979
|
this.client.hangup(sipSession);
|
|
8458
8980
|
}
|
|
8459
8981
|
}
|
|
8460
8982
|
|
|
8461
8983
|
async ignore(callSession ) {
|
|
8462
|
-
logger$
|
|
8984
|
+
logger$7.info('WebRTC ignore', { id: callSession.getId() });
|
|
8463
8985
|
|
|
8464
8986
|
// kill the ring
|
|
8465
8987
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -8468,7 +8990,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8468
8990
|
}
|
|
8469
8991
|
|
|
8470
8992
|
hold(callSession , withEvent = true, isConference = false) {
|
|
8471
|
-
logger$
|
|
8993
|
+
logger$7.info('WebRTC hold', { id: callSession.getId() });
|
|
8472
8994
|
|
|
8473
8995
|
const sipSession = this.findSipSession(callSession);
|
|
8474
8996
|
|
|
@@ -8479,7 +9001,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8479
9001
|
|
|
8480
9002
|
// @Deprecated
|
|
8481
9003
|
unhold(callSession , withEvent = true, isConference = false) {
|
|
8482
|
-
logger$
|
|
9004
|
+
logger$7.info('WebRTC unhold', { id: callSession ? callSession.getId() : null });
|
|
8483
9005
|
|
|
8484
9006
|
console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
|
|
8485
9007
|
|
|
@@ -8494,7 +9016,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8494
9016
|
const sipSession = this.findSipSession(callSession);
|
|
8495
9017
|
|
|
8496
9018
|
if (sipSession) {
|
|
8497
|
-
logger$
|
|
9019
|
+
logger$7.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
8498
9020
|
|
|
8499
9021
|
return this.client.atxfer(sipSession);
|
|
8500
9022
|
}
|
|
@@ -8509,7 +9031,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8509
9031
|
if (!sipSession) {
|
|
8510
9032
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
8511
9033
|
}
|
|
8512
|
-
logger$
|
|
9034
|
+
logger$7.info('WebRTC hold sip session', { sipId: sipSession.id });
|
|
8513
9035
|
|
|
8514
9036
|
const promise = this.client.hold(sipSession, isConference);
|
|
8515
9037
|
if (withEvent) {
|
|
@@ -8528,7 +9050,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8528
9050
|
if (!sipSession) {
|
|
8529
9051
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
8530
9052
|
}
|
|
8531
|
-
logger$
|
|
9053
|
+
logger$7.info('WebRTC unhold', { sipId: sipSession.id });
|
|
8532
9054
|
|
|
8533
9055
|
const promise = this.client.unhold(sipSession, isConference);
|
|
8534
9056
|
if (withEvent) {
|
|
@@ -8539,18 +9061,18 @@ class WebRTCPhone extends Emitter {
|
|
|
8539
9061
|
}
|
|
8540
9062
|
|
|
8541
9063
|
resume(callSession , isConference = false) {
|
|
8542
|
-
logger$
|
|
9064
|
+
logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
8543
9065
|
|
|
8544
9066
|
const sipSession = this.findSipSession(callSession);
|
|
8545
9067
|
if (!sipSession) {
|
|
8546
9068
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
8547
9069
|
}
|
|
8548
9070
|
|
|
8549
|
-
logger$
|
|
9071
|
+
logger$7.info('WebRTC resuming', { sipId: sipSession.id });
|
|
8550
9072
|
|
|
8551
9073
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
8552
9074
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
8553
|
-
logger$
|
|
9075
|
+
logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
8554
9076
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
8555
9077
|
}
|
|
8556
9078
|
|
|
@@ -8565,14 +9087,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8565
9087
|
}
|
|
8566
9088
|
|
|
8567
9089
|
mute(callSession , withEvent = true) {
|
|
8568
|
-
logger$
|
|
9090
|
+
logger$7.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
8569
9091
|
|
|
8570
9092
|
const sipSession = this.findSipSession(callSession);
|
|
8571
9093
|
if (!sipSession) {
|
|
8572
9094
|
return;
|
|
8573
9095
|
}
|
|
8574
9096
|
|
|
8575
|
-
logger$
|
|
9097
|
+
logger$7.info('WebRTC muting', { sipId: sipSession.id });
|
|
8576
9098
|
this.client.mute(sipSession);
|
|
8577
9099
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
8578
9100
|
|
|
@@ -8586,14 +9108,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8586
9108
|
}
|
|
8587
9109
|
|
|
8588
9110
|
unmute(callSession , withEvent = true) {
|
|
8589
|
-
logger$
|
|
9111
|
+
logger$7.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
8590
9112
|
|
|
8591
9113
|
const sipSession = this.findSipSession(callSession);
|
|
8592
9114
|
if (!sipSession) {
|
|
8593
9115
|
return;
|
|
8594
9116
|
}
|
|
8595
9117
|
|
|
8596
|
-
logger$
|
|
9118
|
+
logger$7.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
8597
9119
|
this.client.unmute(sipSession);
|
|
8598
9120
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
8599
9121
|
|
|
@@ -8620,7 +9142,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8620
9142
|
if (!sipSession) {
|
|
8621
9143
|
return;
|
|
8622
9144
|
}
|
|
8623
|
-
logger$
|
|
9145
|
+
logger$7.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
8624
9146
|
|
|
8625
9147
|
this.client.toggleCameraOn(sipSession);
|
|
8626
9148
|
|
|
@@ -8632,7 +9154,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8632
9154
|
if (!sipSession) {
|
|
8633
9155
|
return;
|
|
8634
9156
|
}
|
|
8635
|
-
logger$
|
|
9157
|
+
logger$7.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
8636
9158
|
|
|
8637
9159
|
this.client.toggleCameraOff(sipSession);
|
|
8638
9160
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -8644,7 +9166,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8644
9166
|
return;
|
|
8645
9167
|
}
|
|
8646
9168
|
|
|
8647
|
-
logger$
|
|
9169
|
+
logger$7.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
8648
9170
|
this.client.sendDTMF(sipSession, tone);
|
|
8649
9171
|
}
|
|
8650
9172
|
|
|
@@ -8652,7 +9174,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8652
9174
|
// @TODO: line is not used here
|
|
8653
9175
|
async makeCall(number , line , cameraEnabled ,
|
|
8654
9176
|
audioOnly = false, conference = false) {
|
|
8655
|
-
logger$
|
|
9177
|
+
logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
8656
9178
|
if (!number) {
|
|
8657
9179
|
return Promise.resolve(null);
|
|
8658
9180
|
}
|
|
@@ -8662,7 +9184,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8662
9184
|
}
|
|
8663
9185
|
if (this.currentSipSession) {
|
|
8664
9186
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
8665
|
-
logger$
|
|
9187
|
+
logger$7.warn('Unable to hold current session when making another call', e);
|
|
8666
9188
|
});
|
|
8667
9189
|
}
|
|
8668
9190
|
|
|
@@ -8672,7 +9194,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8672
9194
|
this._bindEvents(sipSession);
|
|
8673
9195
|
} catch (error) {
|
|
8674
9196
|
console.warn(error);
|
|
8675
|
-
logger$
|
|
9197
|
+
logger$7.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
8676
9198
|
return Promise.resolve(null);
|
|
8677
9199
|
}
|
|
8678
9200
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -8700,7 +9222,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8700
9222
|
return;
|
|
8701
9223
|
}
|
|
8702
9224
|
|
|
8703
|
-
logger$
|
|
9225
|
+
logger$7.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
8704
9226
|
|
|
8705
9227
|
this.client.transfer(sipSession, target);
|
|
8706
9228
|
}
|
|
@@ -8709,7 +9231,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8709
9231
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
8710
9232
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
8711
9233
|
|
|
8712
|
-
logger$
|
|
9234
|
+
logger$7.info('WebRTC indirect transfer', {
|
|
8713
9235
|
sipId: sipSession ? sipSession.id : null,
|
|
8714
9236
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
8715
9237
|
});
|
|
@@ -8737,7 +9259,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8737
9259
|
return false;
|
|
8738
9260
|
}
|
|
8739
9261
|
|
|
8740
|
-
logger$
|
|
9262
|
+
logger$7.info('WebRTC hangup', { sipId: sipSession.id });
|
|
8741
9263
|
|
|
8742
9264
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
8743
9265
|
|
|
@@ -8782,7 +9304,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8782
9304
|
}
|
|
8783
9305
|
|
|
8784
9306
|
async close() {
|
|
8785
|
-
logger$
|
|
9307
|
+
logger$7.info('WebRTC close');
|
|
8786
9308
|
|
|
8787
9309
|
try {
|
|
8788
9310
|
await Promise.race([
|
|
@@ -8790,7 +9312,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8790
9312
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
8791
9313
|
]);
|
|
8792
9314
|
} catch (e) {
|
|
8793
|
-
logger$
|
|
9315
|
+
logger$7.error('WebRTC close, unregister error', e);
|
|
8794
9316
|
}
|
|
8795
9317
|
|
|
8796
9318
|
this.client.close();
|
|
@@ -8808,12 +9330,12 @@ class WebRTCPhone extends Emitter {
|
|
|
8808
9330
|
}
|
|
8809
9331
|
|
|
8810
9332
|
enableRinging() {
|
|
8811
|
-
logger$
|
|
9333
|
+
logger$7.info('WebRTC enable ringing');
|
|
8812
9334
|
this.ringingEnabled = true;
|
|
8813
9335
|
}
|
|
8814
9336
|
|
|
8815
9337
|
disableRinging() {
|
|
8816
|
-
logger$
|
|
9338
|
+
logger$7.info('WebRTC disable ringing');
|
|
8817
9339
|
this.ringingEnabled = false;
|
|
8818
9340
|
}
|
|
8819
9341
|
|
|
@@ -8853,7 +9375,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8853
9375
|
|
|
8854
9376
|
// Deprecated
|
|
8855
9377
|
getLocalMediaStream(callSession ) {
|
|
8856
|
-
logger$
|
|
9378
|
+
logger$7.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
8857
9379
|
return this.getLocalStream(callSession);
|
|
8858
9380
|
}
|
|
8859
9381
|
|
|
@@ -8861,6 +9383,10 @@ class WebRTCPhone extends Emitter {
|
|
|
8861
9383
|
return callSession ? this.client.hasLocalVideo(callSession.sipCallId) : null;
|
|
8862
9384
|
}
|
|
8863
9385
|
|
|
9386
|
+
hasALocalVideoTrack(callSession ) {
|
|
9387
|
+
return callSession ? this.client.hasALocalVideoTrack(callSession.sipCallId) : null;
|
|
9388
|
+
}
|
|
9389
|
+
|
|
8864
9390
|
getRemoteStream(callSession ) {
|
|
8865
9391
|
return callSession ? this.client.getRemoteStream(callSession.sipCallId) : null;
|
|
8866
9392
|
}
|
|
@@ -8883,7 +9409,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8883
9409
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
8884
9410
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
8885
9411
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
8886
|
-
logger$
|
|
9412
|
+
logger$7.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
8887
9413
|
|
|
8888
9414
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
8889
9415
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -8906,7 +9432,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8906
9432
|
});
|
|
8907
9433
|
|
|
8908
9434
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
8909
|
-
logger$
|
|
9435
|
+
logger$7.info('WebRTC on reinvite', {
|
|
8910
9436
|
sessionId: args[0].id,
|
|
8911
9437
|
inviteId: args[1].id,
|
|
8912
9438
|
updatedCalleeName: args[2],
|
|
@@ -8926,7 +9452,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8926
9452
|
});
|
|
8927
9453
|
|
|
8928
9454
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
8929
|
-
logger$
|
|
9455
|
+
logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
8930
9456
|
|
|
8931
9457
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
8932
9458
|
|
|
@@ -8937,17 +9463,17 @@ class WebRTCPhone extends Emitter {
|
|
|
8937
9463
|
this.client.on('ended', () => {});
|
|
8938
9464
|
|
|
8939
9465
|
this.client.on(this.client.ON_ERROR, e => {
|
|
8940
|
-
logger$
|
|
9466
|
+
logger$7.error('WebRTC error', e);
|
|
8941
9467
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
8942
9468
|
});
|
|
8943
9469
|
|
|
8944
9470
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
8945
|
-
logger$
|
|
9471
|
+
logger$7.info('WebRTC unregistered');
|
|
8946
9472
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
8947
9473
|
});
|
|
8948
9474
|
|
|
8949
9475
|
this.client.on(this.client.REGISTERED, () => {
|
|
8950
|
-
logger$
|
|
9476
|
+
logger$7.info('WebRTC registered', {
|
|
8951
9477
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
8952
9478
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
8953
9479
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -8963,19 +9489,19 @@ class WebRTCPhone extends Emitter {
|
|
|
8963
9489
|
try {
|
|
8964
9490
|
this.sendReinvite(this.currentCallSession);
|
|
8965
9491
|
} catch (e) {
|
|
8966
|
-
logger$
|
|
9492
|
+
logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
8967
9493
|
}
|
|
8968
9494
|
}
|
|
8969
9495
|
});
|
|
8970
9496
|
|
|
8971
9497
|
this.client.on(this.client.CONNECTED, () => {
|
|
8972
|
-
logger$
|
|
9498
|
+
logger$7.info('WebRTC client connected');
|
|
8973
9499
|
|
|
8974
9500
|
this.stopHeartbeat();
|
|
8975
9501
|
});
|
|
8976
9502
|
|
|
8977
9503
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
8978
|
-
logger$
|
|
9504
|
+
logger$7.info('WebRTC client disconnected');
|
|
8979
9505
|
|
|
8980
9506
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
8981
9507
|
|
|
@@ -9207,7 +9733,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
9207
9733
|
|
|
9208
9734
|
//
|
|
9209
9735
|
|
|
9210
|
-
const logger$
|
|
9736
|
+
const logger$6 = IssueReporter$1.loggerFor('simple-phone');
|
|
9211
9737
|
const sipLogger = IssueReporter$1.loggerFor('sip.js');
|
|
9212
9738
|
const protocolLogger = IssueReporter$1.loggerFor('sip');
|
|
9213
9739
|
|
|
@@ -9314,7 +9840,7 @@ class Phone extends Emitter {
|
|
|
9314
9840
|
async disconnect() {
|
|
9315
9841
|
if (this.phone) {
|
|
9316
9842
|
if (this.phone.hasAnActiveCall()) {
|
|
9317
|
-
logger$
|
|
9843
|
+
logger$6.info('hangup call on disconnect');
|
|
9318
9844
|
// $FlowFixMe
|
|
9319
9845
|
await this.phone.hangup();
|
|
9320
9846
|
}
|
|
@@ -9337,13 +9863,13 @@ class Phone extends Emitter {
|
|
|
9337
9863
|
}
|
|
9338
9864
|
|
|
9339
9865
|
async hangup(callSession ) {
|
|
9340
|
-
logger$
|
|
9866
|
+
logger$6.info('hangup via simple phone', { callId: callSession.getId() });
|
|
9341
9867
|
|
|
9342
9868
|
return this.phone && this.phone.hangup(callSession);
|
|
9343
9869
|
}
|
|
9344
9870
|
|
|
9345
9871
|
async accept(callSession , cameraEnabled ) {
|
|
9346
|
-
logger$
|
|
9872
|
+
logger$6.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
|
|
9347
9873
|
|
|
9348
9874
|
return this.phone && this.phone.accept(callSession, cameraEnabled);
|
|
9349
9875
|
}
|
|
@@ -9363,13 +9889,18 @@ class Phone extends Emitter {
|
|
|
9363
9889
|
return adHocConference.start();
|
|
9364
9890
|
}
|
|
9365
9891
|
|
|
9366
|
-
mute(callSession ) {
|
|
9367
|
-
|
|
9892
|
+
mute(callSession , withApi = true) {
|
|
9893
|
+
if (withApi) {
|
|
9894
|
+
this.muteViaAPI(callSession);
|
|
9895
|
+
}
|
|
9896
|
+
|
|
9368
9897
|
return this.phone && this.phone.mute(callSession);
|
|
9369
9898
|
}
|
|
9370
9899
|
|
|
9371
|
-
unmute(callSession ) {
|
|
9372
|
-
|
|
9900
|
+
unmute(callSession , withApi = true) {
|
|
9901
|
+
if (withApi) {
|
|
9902
|
+
this.unmuteViaAPI(callSession);
|
|
9903
|
+
}
|
|
9373
9904
|
|
|
9374
9905
|
return this.phone && this.phone.unmute(callSession);
|
|
9375
9906
|
}
|
|
@@ -9377,7 +9908,7 @@ class Phone extends Emitter {
|
|
|
9377
9908
|
muteViaAPI(callSession ) {
|
|
9378
9909
|
if (callSession && callSession.callId) {
|
|
9379
9910
|
Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
|
|
9380
|
-
logger$
|
|
9911
|
+
logger$6.error('Mute via API, error', e);
|
|
9381
9912
|
});
|
|
9382
9913
|
}
|
|
9383
9914
|
}
|
|
@@ -9385,7 +9916,7 @@ class Phone extends Emitter {
|
|
|
9385
9916
|
unmuteViaAPI(callSession ) {
|
|
9386
9917
|
if (callSession && callSession.callId) {
|
|
9387
9918
|
Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
|
|
9388
|
-
logger$
|
|
9919
|
+
logger$6.error('Unmute via API, error', e);
|
|
9389
9920
|
});
|
|
9390
9921
|
}
|
|
9391
9922
|
}
|
|
@@ -9475,9 +10006,13 @@ class Phone extends Emitter {
|
|
|
9475
10006
|
return this.phone && this.phone.hasLocalVideo(callSession);
|
|
9476
10007
|
}
|
|
9477
10008
|
|
|
10009
|
+
hasALocalVideoTrack(callSession ) {
|
|
10010
|
+
return this.phone && this.phone.hasALocalVideoTrack(callSession);
|
|
10011
|
+
}
|
|
10012
|
+
|
|
9478
10013
|
// @Deprecated
|
|
9479
10014
|
getLocalMediaStream(callSession ) {
|
|
9480
|
-
logger$
|
|
10015
|
+
logger$6.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
9481
10016
|
|
|
9482
10017
|
return this.phone && this.phone.getLocalStream(callSession);
|
|
9483
10018
|
}
|
|
@@ -9496,20 +10031,20 @@ class Phone extends Emitter {
|
|
|
9496
10031
|
|
|
9497
10032
|
// @Deprecated
|
|
9498
10033
|
getRemoteStreamForCall(callSession ) {
|
|
9499
|
-
logger$
|
|
10034
|
+
logger$6.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
9500
10035
|
return this.getRemoteStream(callSession);
|
|
9501
10036
|
}
|
|
9502
10037
|
|
|
9503
10038
|
// Returns remote streams directly from the peerConnection
|
|
9504
10039
|
// @Deprecated
|
|
9505
10040
|
getRemoteStreamsForCall(callSession ) {
|
|
9506
|
-
logger$
|
|
10041
|
+
logger$6.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
9507
10042
|
return this.getLocalStream(callSession);
|
|
9508
10043
|
}
|
|
9509
10044
|
|
|
9510
10045
|
// @Deprecated
|
|
9511
10046
|
getRemoteVideoStreamForCall(callSession ) {
|
|
9512
|
-
logger$
|
|
10047
|
+
logger$6.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
9513
10048
|
|
|
9514
10049
|
return this.getRemoteVideoStream(callSession);
|
|
9515
10050
|
}
|
|
@@ -9639,6 +10174,8 @@ const CONFERENCE_USER_PARTICIPANT_JOINED = 'conference_user_participant_joined';
|
|
|
9639
10174
|
const CONFERENCE_USER_PARTICIPANT_LEFT = 'conference_user_participant_left';
|
|
9640
10175
|
const CONFERENCE_USER_PARTICIPANT_TALK_STARTED = 'conference_user_participant_talk_started';
|
|
9641
10176
|
const CONFERENCE_USER_PARTICIPANT_TALK_STOPPED = 'conference_user_participant_talk_stopped';
|
|
10177
|
+
const MEETING_USER_PARTICIPANT_JOINED = 'meeting_user_participant_joined';
|
|
10178
|
+
const MEETING_USER_PARTICIPANT_LEFT = 'meeting_user_participant_left';
|
|
9642
10179
|
const SWITCHBOARD_QUEUED_CALLS_UPDATED = 'switchboard_queued_calls_updated';
|
|
9643
10180
|
const SWITCHBOARD_QUEUED_CALL_ANSWERED = 'switchboard_queued_call_answered';
|
|
9644
10181
|
const SWITCHBOARD_HELD_CALLS_UPDATED = 'switchboard_held_calls_updated';
|
|
@@ -9680,7 +10217,7 @@ const BLACKLIST_EVENTS = [
|
|
|
9680
10217
|
];
|
|
9681
10218
|
|
|
9682
10219
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
9683
|
-
const logger$
|
|
10220
|
+
const logger$5 = IssueReporter$1.loggerFor('wazo-ws');
|
|
9684
10221
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
9685
10222
|
|
|
9686
10223
|
class WebSocketClient extends Emitter {
|
|
@@ -9729,19 +10266,19 @@ class WebSocketClient extends Emitter {
|
|
|
9729
10266
|
}
|
|
9730
10267
|
|
|
9731
10268
|
connect() {
|
|
9732
|
-
logger$
|
|
10269
|
+
logger$5.info('connect method started', { host: this.host, token: this.token });
|
|
9733
10270
|
this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
|
|
9734
10271
|
if (this.options.binaryType) {
|
|
9735
10272
|
this.socket.binaryType = this.options.binaryType;
|
|
9736
10273
|
}
|
|
9737
10274
|
|
|
9738
10275
|
this.socket.onopen = () => {
|
|
9739
|
-
logger$
|
|
10276
|
+
logger$5.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
9740
10277
|
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
|
|
9741
10278
|
};
|
|
9742
10279
|
|
|
9743
10280
|
this.socket.onerror = event => {
|
|
9744
|
-
logger$
|
|
10281
|
+
logger$5.error('on Wazo WS error', event.target);
|
|
9745
10282
|
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
|
|
9746
10283
|
};
|
|
9747
10284
|
|
|
@@ -9771,7 +10308,7 @@ class WebSocketClient extends Emitter {
|
|
|
9771
10308
|
|
|
9772
10309
|
this.socket.onclose = event => {
|
|
9773
10310
|
// Can't be converted to JSON (circular structure)
|
|
9774
|
-
logger$
|
|
10311
|
+
logger$5.info('on Wazo WS close', {
|
|
9775
10312
|
reason: event.reason,
|
|
9776
10313
|
code: event.code,
|
|
9777
10314
|
readyState: event.target.readyState,
|
|
@@ -9789,12 +10326,12 @@ class WebSocketClient extends Emitter {
|
|
|
9789
10326
|
};
|
|
9790
10327
|
|
|
9791
10328
|
this.socket.onerror = event => {
|
|
9792
|
-
logger$
|
|
10329
|
+
logger$5.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
9793
10330
|
};
|
|
9794
10331
|
}
|
|
9795
10332
|
|
|
9796
10333
|
close(force = false) {
|
|
9797
|
-
logger$
|
|
10334
|
+
logger$5.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
9798
10335
|
|
|
9799
10336
|
if (!this.socket) {
|
|
9800
10337
|
return;
|
|
@@ -9812,7 +10349,7 @@ class WebSocketClient extends Emitter {
|
|
|
9812
10349
|
|
|
9813
10350
|
updateToken(token ) {
|
|
9814
10351
|
this.token = token;
|
|
9815
|
-
logger$
|
|
10352
|
+
logger$5.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
9816
10353
|
|
|
9817
10354
|
if (this.socket) {
|
|
9818
10355
|
// If still connected, send the token to the WS
|
|
@@ -9830,7 +10367,7 @@ class WebSocketClient extends Emitter {
|
|
|
9830
10367
|
}
|
|
9831
10368
|
|
|
9832
10369
|
startHeartbeat() {
|
|
9833
|
-
logger$
|
|
10370
|
+
logger$5.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
9834
10371
|
|
|
9835
10372
|
if (!this.socket) {
|
|
9836
10373
|
this.heartbeat.stop();
|
|
@@ -9844,7 +10381,7 @@ class WebSocketClient extends Emitter {
|
|
|
9844
10381
|
}
|
|
9845
10382
|
|
|
9846
10383
|
stopHeartbeat() {
|
|
9847
|
-
logger$
|
|
10384
|
+
logger$5.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
9848
10385
|
|
|
9849
10386
|
this.heartbeat.stop();
|
|
9850
10387
|
}
|
|
@@ -9874,7 +10411,7 @@ class WebSocketClient extends Emitter {
|
|
|
9874
10411
|
}
|
|
9875
10412
|
|
|
9876
10413
|
reconnect(reason ) {
|
|
9877
|
-
logger$
|
|
10414
|
+
logger$5.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
9878
10415
|
if (!this.socket) {
|
|
9879
10416
|
return;
|
|
9880
10417
|
}
|
|
@@ -9930,7 +10467,7 @@ class WebSocketClient extends Emitter {
|
|
|
9930
10467
|
this.close();
|
|
9931
10468
|
}
|
|
9932
10469
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
9933
|
-
logger$
|
|
10470
|
+
logger$5.log('Wazo WS url computed to reconnect', { url });
|
|
9934
10471
|
|
|
9935
10472
|
return url;
|
|
9936
10473
|
}
|
|
@@ -9938,12 +10475,12 @@ class WebSocketClient extends Emitter {
|
|
|
9938
10475
|
_onHeartbeat(message ) {
|
|
9939
10476
|
if (message.payload === 'pong') {
|
|
9940
10477
|
this.heartbeat.onHeartbeat();
|
|
9941
|
-
logger$
|
|
10478
|
+
logger$5.log('on heartbeat received from Wazo WS');
|
|
9942
10479
|
}
|
|
9943
10480
|
}
|
|
9944
10481
|
|
|
9945
10482
|
async _onHeartbeatTimeout() {
|
|
9946
|
-
logger$
|
|
10483
|
+
logger$5.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
9947
10484
|
|
|
9948
10485
|
this.close();
|
|
9949
10486
|
this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
@@ -9985,6 +10522,8 @@ WebSocketClient.eventLists = [
|
|
|
9985
10522
|
CHATD_USER_ROOM_CREATED,
|
|
9986
10523
|
CONFERENCE_USER_PARTICIPANT_JOINED,
|
|
9987
10524
|
CONFERENCE_USER_PARTICIPANT_LEFT,
|
|
10525
|
+
MEETING_USER_PARTICIPANT_JOINED,
|
|
10526
|
+
MEETING_USER_PARTICIPANT_LEFT,
|
|
9988
10527
|
CONFERENCE_USER_PARTICIPANT_TALK_STARTED,
|
|
9989
10528
|
CONFERENCE_USER_PARTICIPANT_TALK_STOPPED,
|
|
9990
10529
|
SWITCHBOARD_QUEUED_CALLS_UPDATED,
|
|
@@ -10055,6 +10594,8 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
10055
10594
|
CONFERENCE_USER_PARTICIPANT_LEFT: CONFERENCE_USER_PARTICIPANT_LEFT,
|
|
10056
10595
|
CONFERENCE_USER_PARTICIPANT_TALK_STARTED: CONFERENCE_USER_PARTICIPANT_TALK_STARTED,
|
|
10057
10596
|
CONFERENCE_USER_PARTICIPANT_TALK_STOPPED: CONFERENCE_USER_PARTICIPANT_TALK_STOPPED,
|
|
10597
|
+
MEETING_USER_PARTICIPANT_JOINED: MEETING_USER_PARTICIPANT_JOINED,
|
|
10598
|
+
MEETING_USER_PARTICIPANT_LEFT: MEETING_USER_PARTICIPANT_LEFT,
|
|
10058
10599
|
SWITCHBOARD_QUEUED_CALLS_UPDATED: SWITCHBOARD_QUEUED_CALLS_UPDATED,
|
|
10059
10600
|
SWITCHBOARD_QUEUED_CALL_ANSWERED: SWITCHBOARD_QUEUED_CALL_ANSWERED,
|
|
10060
10601
|
SWITCHBOARD_HELD_CALLS_UPDATED: SWITCHBOARD_HELD_CALLS_UPDATED,
|
|
@@ -10096,7 +10637,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
10096
10637
|
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
10097
10638
|
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
10098
10639
|
|
|
10099
|
-
const logger$
|
|
10640
|
+
const logger$4 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
10100
10641
|
|
|
10101
10642
|
class Websocket extends Emitter {
|
|
10102
10643
|
|
|
@@ -10120,7 +10661,7 @@ class Websocket extends Emitter {
|
|
|
10120
10661
|
}
|
|
10121
10662
|
|
|
10122
10663
|
open(host , session ) {
|
|
10123
|
-
logger$
|
|
10664
|
+
logger$4.info('open simple WebSocket', { host, token: session.token });
|
|
10124
10665
|
this.ws = new WebSocketClient(
|
|
10125
10666
|
{
|
|
10126
10667
|
host,
|
|
@@ -10148,7 +10689,7 @@ class Websocket extends Emitter {
|
|
|
10148
10689
|
}
|
|
10149
10690
|
|
|
10150
10691
|
updateToken(token ) {
|
|
10151
|
-
logger$
|
|
10692
|
+
logger$4.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
10152
10693
|
|
|
10153
10694
|
if (!this.ws) {
|
|
10154
10695
|
return;
|
|
@@ -10176,7 +10717,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
10176
10717
|
|
|
10177
10718
|
//
|
|
10178
10719
|
|
|
10179
|
-
const logger$
|
|
10720
|
+
const logger$3 = IssueReporter$1.loggerFor('room');
|
|
10180
10721
|
|
|
10181
10722
|
class Participant extends Emitter {
|
|
10182
10723
|
|
|
@@ -10210,6 +10751,7 @@ class Participant extends Emitter {
|
|
|
10210
10751
|
|
|
10211
10752
|
|
|
10212
10753
|
/**
|
|
10754
|
+
* @param room Room The room where the participant is
|
|
10213
10755
|
* @param rawParticipant string Participant sent via the Wazo WS
|
|
10214
10756
|
* @param extra Object extra status of the participant
|
|
10215
10757
|
*/
|
|
@@ -10297,7 +10839,7 @@ class Participant extends Emitter {
|
|
|
10297
10839
|
}
|
|
10298
10840
|
|
|
10299
10841
|
onTalking(isTalking ) {
|
|
10300
|
-
logger$
|
|
10842
|
+
logger$3.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
10301
10843
|
this.isTalking = isTalking;
|
|
10302
10844
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
10303
10845
|
// directly from asterisk, there's no need to do so
|
|
@@ -10400,7 +10942,7 @@ class Participant extends Emitter {
|
|
|
10400
10942
|
}
|
|
10401
10943
|
|
|
10402
10944
|
updateStatus(status , broadcast = true) {
|
|
10403
|
-
logger$
|
|
10945
|
+
logger$3.info('updating participant status', { name: this.name, status });
|
|
10404
10946
|
|
|
10405
10947
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
10406
10948
|
if (status.audioMuted) {
|
|
@@ -10437,13 +10979,18 @@ class Participant extends Emitter {
|
|
|
10437
10979
|
// Poor man's object comparison
|
|
10438
10980
|
if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
|
|
10439
10981
|
this.extra = { ...this.extra, ...status.extra };
|
|
10982
|
+
|
|
10983
|
+
if (this.extra.contact && !(this.extra.contact instanceof Contact)) {
|
|
10984
|
+
this.extra.contact = new Contact(this.extra.contact);
|
|
10985
|
+
}
|
|
10986
|
+
|
|
10440
10987
|
this.triggerUpdate(this.ON_EXTRA_CHANGE, broadcast);
|
|
10441
10988
|
}
|
|
10442
10989
|
}
|
|
10443
10990
|
|
|
10444
10991
|
broadcastStatus(inboundStatus = null) {
|
|
10445
10992
|
const status = inboundStatus || this.getStatus();
|
|
10446
|
-
logger$
|
|
10993
|
+
logger$3.info('broadcasting participant status', { callId: this.callId, status });
|
|
10447
10994
|
|
|
10448
10995
|
this.room.sendSignal({
|
|
10449
10996
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -10464,18 +11011,24 @@ class RemoteParticipant extends Participant {
|
|
|
10464
11011
|
}
|
|
10465
11012
|
}
|
|
10466
11013
|
|
|
10467
|
-
|
|
11014
|
+
//
|
|
11015
|
+
|
|
11016
|
+
class LocalParticipant extends Participant {
|
|
11017
|
+
}
|
|
11018
|
+
|
|
11019
|
+
//
|
|
10468
11020
|
|
|
10469
11021
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
10470
11022
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
10471
11023
|
|
|
10472
|
-
const logger$
|
|
11024
|
+
const logger$2 = IssueReporter$1.loggerFor('sdk-room');
|
|
10473
11025
|
|
|
10474
11026
|
class Room$1 extends Emitter {
|
|
10475
11027
|
|
|
10476
11028
|
|
|
10477
11029
|
|
|
10478
11030
|
|
|
11031
|
+
|
|
10479
11032
|
|
|
10480
11033
|
|
|
10481
11034
|
|
|
@@ -10497,6 +11050,8 @@ class Room$1 extends Emitter {
|
|
|
10497
11050
|
|
|
10498
11051
|
|
|
10499
11052
|
|
|
11053
|
+
|
|
11054
|
+
|
|
10500
11055
|
|
|
10501
11056
|
|
|
10502
11057
|
|
|
@@ -10514,6 +11069,7 @@ class Room$1 extends Emitter {
|
|
|
10514
11069
|
* @param extension string
|
|
10515
11070
|
* @param sourceId number
|
|
10516
11071
|
* @param callId string
|
|
11072
|
+
* @param meetingUuid string
|
|
10517
11073
|
* @param extra Object
|
|
10518
11074
|
*/
|
|
10519
11075
|
constructor(
|
|
@@ -10521,15 +11077,17 @@ class Room$1 extends Emitter {
|
|
|
10521
11077
|
extension ,
|
|
10522
11078
|
sourceId ,
|
|
10523
11079
|
callId ,
|
|
11080
|
+
meetingUuid ,
|
|
10524
11081
|
extra = {},
|
|
10525
11082
|
) {
|
|
10526
11083
|
super();
|
|
10527
|
-
logger$
|
|
11084
|
+
logger$2.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
10528
11085
|
|
|
10529
11086
|
// Represents the room callSession
|
|
10530
11087
|
this.callSession = callSession;
|
|
10531
11088
|
this.extension = extension;
|
|
10532
11089
|
this.sourceId = sourceId;
|
|
11090
|
+
this.meetingUuid = meetingUuid;
|
|
10533
11091
|
this.callId = callId;
|
|
10534
11092
|
this.participants = [];
|
|
10535
11093
|
this.connected = false;
|
|
@@ -10549,6 +11107,8 @@ class Room$1 extends Emitter {
|
|
|
10549
11107
|
// Sugar syntax for `room.EVENT_NAME`
|
|
10550
11108
|
this.CONFERENCE_USER_PARTICIPANT_JOINED = Wazo.Websocket.CONFERENCE_USER_PARTICIPANT_JOINED;
|
|
10551
11109
|
this.CONFERENCE_USER_PARTICIPANT_LEFT = Wazo.Websocket.CONFERENCE_USER_PARTICIPANT_LEFT;
|
|
11110
|
+
this.MEETING_USER_PARTICIPANT_JOINED = Wazo.Websocket.MEETING_USER_PARTICIPANT_JOINED;
|
|
11111
|
+
this.MEETING_USER_PARTICIPANT_LEFT = Wazo.Websocket.MEETING_USER_PARTICIPANT_LEFT;
|
|
10552
11112
|
this.ON_SHARE_SCREEN_ENDED = Wazo.Phone.ON_SHARE_SCREEN_ENDED;
|
|
10553
11113
|
this.ON_MESSAGE = Wazo.Phone.ON_MESSAGE;
|
|
10554
11114
|
this.ON_CHAT = Wazo.Phone.ON_CHAT;
|
|
@@ -10583,10 +11143,11 @@ class Room$1 extends Emitter {
|
|
|
10583
11143
|
* @param audioOnly boolean
|
|
10584
11144
|
* @param extra Object
|
|
10585
11145
|
* @param room ?Room
|
|
11146
|
+
* @param meeting ?Meeting
|
|
10586
11147
|
* @returns {Promise<Room>}
|
|
10587
11148
|
*/
|
|
10588
|
-
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
10589
|
-
logger$
|
|
11149
|
+
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
11150
|
+
logger$2.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
10590
11151
|
|
|
10591
11152
|
if (!room) {
|
|
10592
11153
|
await Wazo.Phone.connect();
|
|
@@ -10599,7 +11160,7 @@ class Room$1 extends Emitter {
|
|
|
10599
11160
|
|
|
10600
11161
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
10601
11162
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
10602
|
-
logger$
|
|
11163
|
+
logger$2.info('room call received via WS', { callId: data.call_id });
|
|
10603
11164
|
if (room) {
|
|
10604
11165
|
room.setCallId(data.call_id);
|
|
10605
11166
|
}
|
|
@@ -10620,34 +11181,44 @@ class Room$1 extends Emitter {
|
|
|
10620
11181
|
room.setCallId(room.callSession.call.id);
|
|
10621
11182
|
}
|
|
10622
11183
|
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
11184
|
+
if (!meeting) {
|
|
11185
|
+
// Fetch conference source
|
|
11186
|
+
const sources = await getApiClient().dird.fetchConferenceSource('default');
|
|
11187
|
+
// Retrieve conference sources
|
|
11188
|
+
const contacts = await getApiClient().dird.fetchConferenceContacts(sources.items[0]);
|
|
11189
|
+
// Retrieve conference
|
|
11190
|
+
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
10629
11191
|
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
11192
|
+
logger$2.info('connected to room', {
|
|
11193
|
+
sourceId: conference ? conference.sourceId : null,
|
|
11194
|
+
name: conference ? conference.name : null,
|
|
11195
|
+
});
|
|
10634
11196
|
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
11197
|
+
if (conference) {
|
|
11198
|
+
room.setSourceId(conference.sourceId);
|
|
11199
|
+
room.setName(conference.name);
|
|
11200
|
+
}
|
|
11201
|
+
} else if (meeting) {
|
|
11202
|
+
logger$2.info('Already connected to meeting', {
|
|
11203
|
+
uuid: meeting.uuid,
|
|
11204
|
+
name: meeting.name,
|
|
11205
|
+
});
|
|
11206
|
+
|
|
11207
|
+
room.setMeetingUuid(meeting.uuid);
|
|
11208
|
+
room.setName(meeting.name);
|
|
10638
11209
|
}
|
|
10639
11210
|
|
|
10640
11211
|
return room;
|
|
10641
11212
|
}
|
|
10642
11213
|
|
|
10643
11214
|
static disconnect() {
|
|
10644
|
-
logger$
|
|
11215
|
+
logger$2.info('static disconnection to room');
|
|
10645
11216
|
|
|
10646
11217
|
Wazo.Phone.disconnect();
|
|
10647
11218
|
}
|
|
10648
11219
|
|
|
10649
11220
|
async disconnect() {
|
|
10650
|
-
logger$
|
|
11221
|
+
logger$2.info('disconnection to room called');
|
|
10651
11222
|
|
|
10652
11223
|
await Wazo.Phone.hangup(this.callSession);
|
|
10653
11224
|
this.callSession = null;
|
|
@@ -10662,20 +11233,24 @@ class Room$1 extends Emitter {
|
|
|
10662
11233
|
Wazo.Phone.phone.off(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
10663
11234
|
Wazo.Websocket.off(this.CONFERENCE_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
|
|
10664
11235
|
Wazo.Websocket.off(this.CONFERENCE_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
document.body.removeChild(this.roomAudioElement);
|
|
10668
|
-
}
|
|
11236
|
+
Wazo.Websocket.off(this.MEETING_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
|
|
11237
|
+
Wazo.Websocket.off(this.MEETING_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
|
|
10669
11238
|
}
|
|
10670
11239
|
|
|
10671
11240
|
setSourceId(sourceId ) {
|
|
10672
|
-
logger$
|
|
11241
|
+
logger$2.info('set room source id', { sourceId });
|
|
10673
11242
|
|
|
10674
11243
|
this.sourceId = sourceId;
|
|
10675
11244
|
}
|
|
10676
11245
|
|
|
11246
|
+
setMeetingUuid(meetingUuid ) {
|
|
11247
|
+
logger$2.info('set meeting uuid', { meetingUuid });
|
|
11248
|
+
|
|
11249
|
+
this.meetingUuid = meetingUuid;
|
|
11250
|
+
}
|
|
11251
|
+
|
|
10677
11252
|
setCallId(callId ) {
|
|
10678
|
-
logger$
|
|
11253
|
+
logger$2.info('set room call id', { callId });
|
|
10679
11254
|
|
|
10680
11255
|
if (callId) {
|
|
10681
11256
|
this.callId = callId;
|
|
@@ -10683,7 +11258,7 @@ class Room$1 extends Emitter {
|
|
|
10683
11258
|
}
|
|
10684
11259
|
|
|
10685
11260
|
setName(name ) {
|
|
10686
|
-
logger$
|
|
11261
|
+
logger$2.info('set room name', { name });
|
|
10687
11262
|
|
|
10688
11263
|
this.name = name;
|
|
10689
11264
|
}
|
|
@@ -10702,7 +11277,7 @@ class Room$1 extends Emitter {
|
|
|
10702
11277
|
}
|
|
10703
11278
|
|
|
10704
11279
|
async startScreenSharing(constraints ) {
|
|
10705
|
-
logger$
|
|
11280
|
+
logger$2.info('start room screen sharing', { constraints });
|
|
10706
11281
|
|
|
10707
11282
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
10708
11283
|
if (!screensharingStream) {
|
|
@@ -10715,18 +11290,26 @@ class Room$1 extends Emitter {
|
|
|
10715
11290
|
return screensharingStream;
|
|
10716
11291
|
}
|
|
10717
11292
|
|
|
10718
|
-
stopScreenSharing(restoreLocalStream = true) {
|
|
10719
|
-
logger$
|
|
11293
|
+
async stopScreenSharing(restoreLocalStream = true) {
|
|
11294
|
+
logger$2.info('stop room screen sharing');
|
|
10720
11295
|
|
|
10721
|
-
Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
11296
|
+
const reinvited = await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
10722
11297
|
|
|
10723
11298
|
if (this.localParticipant) {
|
|
10724
11299
|
this.localParticipant.onStopScreensharing();
|
|
10725
11300
|
}
|
|
11301
|
+
|
|
11302
|
+
if (!reinvited && this.localParticipant) {
|
|
11303
|
+
// When we had video and we made a screenshare we don't reinvite when stopping the screensahre
|
|
11304
|
+
// So not REINVITE even is fired, we have to restore the video stream manually
|
|
11305
|
+
const localVideoStream = Wazo.Phone.getLocalVideoStream(this.callSession);
|
|
11306
|
+
// $FlowFixMe
|
|
11307
|
+
this._associateStreamTo(localVideoStream, this.localParticipant);
|
|
11308
|
+
}
|
|
10726
11309
|
}
|
|
10727
11310
|
|
|
10728
11311
|
turnCameraOff() {
|
|
10729
|
-
logger$
|
|
11312
|
+
logger$2.info('turn room camera off');
|
|
10730
11313
|
|
|
10731
11314
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
10732
11315
|
|
|
@@ -10736,7 +11319,7 @@ class Room$1 extends Emitter {
|
|
|
10736
11319
|
}
|
|
10737
11320
|
|
|
10738
11321
|
turnCameraOn() {
|
|
10739
|
-
logger$
|
|
11322
|
+
logger$2.info('turn room camera on');
|
|
10740
11323
|
|
|
10741
11324
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
10742
11325
|
|
|
@@ -10746,7 +11329,7 @@ class Room$1 extends Emitter {
|
|
|
10746
11329
|
}
|
|
10747
11330
|
|
|
10748
11331
|
mute() {
|
|
10749
|
-
logger$
|
|
11332
|
+
logger$2.info('mute room');
|
|
10750
11333
|
|
|
10751
11334
|
Wazo.Phone.mute(this.callSession);
|
|
10752
11335
|
|
|
@@ -10754,7 +11337,7 @@ class Room$1 extends Emitter {
|
|
|
10754
11337
|
}
|
|
10755
11338
|
|
|
10756
11339
|
unmute() {
|
|
10757
|
-
logger$
|
|
11340
|
+
logger$2.info('unmute room');
|
|
10758
11341
|
|
|
10759
11342
|
Wazo.Phone.unmute(this.callSession);
|
|
10760
11343
|
|
|
@@ -10774,7 +11357,7 @@ class Room$1 extends Emitter {
|
|
|
10774
11357
|
}
|
|
10775
11358
|
|
|
10776
11359
|
hold() {
|
|
10777
|
-
logger$
|
|
11360
|
+
logger$2.info('hold room');
|
|
10778
11361
|
|
|
10779
11362
|
Wazo.Phone.hold(this.callSession, true);
|
|
10780
11363
|
|
|
@@ -10784,7 +11367,7 @@ class Room$1 extends Emitter {
|
|
|
10784
11367
|
}
|
|
10785
11368
|
|
|
10786
11369
|
resume() {
|
|
10787
|
-
logger$
|
|
11370
|
+
logger$2.info('resume room');
|
|
10788
11371
|
|
|
10789
11372
|
Wazo.Phone.resume(this.callSession, true);
|
|
10790
11373
|
|
|
@@ -10794,13 +11377,13 @@ class Room$1 extends Emitter {
|
|
|
10794
11377
|
}
|
|
10795
11378
|
|
|
10796
11379
|
sendDTMF(tone ) {
|
|
10797
|
-
logger$
|
|
11380
|
+
logger$2.info('send room DTMF', { tone });
|
|
10798
11381
|
|
|
10799
11382
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
10800
11383
|
}
|
|
10801
11384
|
|
|
10802
11385
|
async sendReinvite(newConstraints = null) {
|
|
10803
|
-
logger$
|
|
11386
|
+
logger$2.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
10804
11387
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
10805
11388
|
|
|
10806
11389
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -10825,6 +11408,22 @@ class Room$1 extends Emitter {
|
|
|
10825
11408
|
return response;
|
|
10826
11409
|
}
|
|
10827
11410
|
|
|
11411
|
+
hasALocalVideoTrack() {
|
|
11412
|
+
return Wazo.Phone.hasALocalVideoTrack(this.callSession);
|
|
11413
|
+
}
|
|
11414
|
+
|
|
11415
|
+
getLocalStream() {
|
|
11416
|
+
return Wazo.Phone.getLocalStream(this.callSession);
|
|
11417
|
+
}
|
|
11418
|
+
|
|
11419
|
+
getRemoteStream() {
|
|
11420
|
+
return Wazo.Phone.getRemoteStream(this.callSession);
|
|
11421
|
+
}
|
|
11422
|
+
|
|
11423
|
+
getRemoteVideoStream() {
|
|
11424
|
+
return Wazo.Phone.getRemoteVideoStream(this.callSession);
|
|
11425
|
+
}
|
|
11426
|
+
|
|
10828
11427
|
_bindEvents() {
|
|
10829
11428
|
if (!Wazo.Phone.phone || !Wazo.Phone.phone.currentSipSession) {
|
|
10830
11429
|
return;
|
|
@@ -10843,35 +11442,18 @@ class Room$1 extends Emitter {
|
|
|
10843
11442
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
10844
11443
|
|
|
10845
11444
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
10846
|
-
logger$
|
|
11445
|
+
logger$2.info('on room audio stream');
|
|
10847
11446
|
|
|
10848
11447
|
this.audioStream = stream;
|
|
10849
|
-
if (
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
if (!this.roomAudioElement) {
|
|
10853
|
-
roomAudioElement = document.createElement('audio');
|
|
10854
|
-
// $FlowFixMe
|
|
10855
|
-
document.body.appendChild(roomAudioElement);
|
|
10856
|
-
}
|
|
10857
|
-
if (!roomAudioElement) {
|
|
10858
|
-
return;
|
|
10859
|
-
}
|
|
10860
|
-
this.roomAudioElement = roomAudioElement;
|
|
11448
|
+
if (!this.roomAudioElement) {
|
|
11449
|
+
const sessionId = Wazo.Phone.phone.getSipSessionId(Wazo.Phone.phone.currentSipSession);
|
|
11450
|
+
this.roomAudioElement = Wazo.Phone.phone.createAudioElementFor(sessionId);
|
|
10861
11451
|
this.roomAudioElement.srcObject = stream;
|
|
10862
|
-
this.roomAudioElement.autoplay = true;
|
|
10863
|
-
this.roomAudioElement.id = 'audio-room';
|
|
10864
|
-
|
|
10865
|
-
// $FlowFixMe
|
|
10866
|
-
if (this.roomAudioElement.setSinkId) {
|
|
10867
|
-
// $FlowFixMe
|
|
10868
|
-
this.roomAudioElement.setSinkId(Wazo.Phone.getOutputDevice());
|
|
10869
|
-
}
|
|
10870
11452
|
}
|
|
10871
11453
|
});
|
|
10872
11454
|
|
|
10873
11455
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
10874
|
-
logger$
|
|
11456
|
+
logger$2.info('on room video stream', { streamId });
|
|
10875
11457
|
|
|
10876
11458
|
this._mapMsid(sipSession.body.body);
|
|
10877
11459
|
|
|
@@ -10886,7 +11468,7 @@ class Room$1 extends Emitter {
|
|
|
10886
11468
|
});
|
|
10887
11469
|
|
|
10888
11470
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
10889
|
-
logger$
|
|
11471
|
+
logger$2.info('on room remove stream');
|
|
10890
11472
|
|
|
10891
11473
|
const participant = this.participants.find(someParticipant =>
|
|
10892
11474
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -10941,6 +11523,9 @@ class Room$1 extends Emitter {
|
|
|
10941
11523
|
Wazo.Websocket.on(this.CONFERENCE_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
|
|
10942
11524
|
Wazo.Websocket.on(this.CONFERENCE_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
|
|
10943
11525
|
|
|
11526
|
+
Wazo.Websocket.on(this.MEETING_USER_PARTICIPANT_JOINED, this._boundOnParticipantJoined);
|
|
11527
|
+
Wazo.Websocket.on(this.MEETING_USER_PARTICIPANT_LEFT, this._boundOnParticipantLeft);
|
|
11528
|
+
|
|
10944
11529
|
// Phone events
|
|
10945
11530
|
Wazo.Phone.on(this.ON_MESSAGE, this._boundOnMessage);
|
|
10946
11531
|
Wazo.Phone.on(this.ON_CHAT, this._boundOnChat);
|
|
@@ -10951,15 +11536,15 @@ class Room$1 extends Emitter {
|
|
|
10951
11536
|
Wazo.Phone.on(event, (...args) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
|
|
10952
11537
|
}
|
|
10953
11538
|
|
|
10954
|
-
_onMessage(message )
|
|
11539
|
+
_onMessage(message ) {
|
|
10955
11540
|
if (message.method !== 'MESSAGE') {
|
|
10956
|
-
return;
|
|
11541
|
+
return null;
|
|
10957
11542
|
}
|
|
10958
11543
|
let body;
|
|
10959
11544
|
try {
|
|
10960
11545
|
body = JSON.parse(message.body);
|
|
10961
11546
|
} catch (e) {
|
|
10962
|
-
return;
|
|
11547
|
+
return null;
|
|
10963
11548
|
}
|
|
10964
11549
|
|
|
10965
11550
|
switch (body.type) {
|
|
@@ -10978,6 +11563,8 @@ class Room$1 extends Emitter {
|
|
|
10978
11563
|
}
|
|
10979
11564
|
|
|
10980
11565
|
this.eventEmitter.emit(this.ON_MESSAGE, body);
|
|
11566
|
+
|
|
11567
|
+
return body;
|
|
10981
11568
|
}
|
|
10982
11569
|
|
|
10983
11570
|
_onChat(content ) {
|
|
@@ -11013,7 +11600,7 @@ class Room$1 extends Emitter {
|
|
|
11013
11600
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
11014
11601
|
if (requester) {
|
|
11015
11602
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
11016
|
-
logger$
|
|
11603
|
+
logger$2.info('trigger room requester status', { origin });
|
|
11017
11604
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
11018
11605
|
}
|
|
11019
11606
|
break;
|
|
@@ -11042,25 +11629,26 @@ class Room$1 extends Emitter {
|
|
|
11042
11629
|
const session = Wazo.Auth.getSession();
|
|
11043
11630
|
let participants = [];
|
|
11044
11631
|
|
|
11045
|
-
// @TODO: we could use a better function name here
|
|
11046
|
-
const isJoining = part => {
|
|
11047
|
-
this.__associateStreams(part);
|
|
11048
|
-
// @VALIDATE: no need to publicize ourselves, no?
|
|
11049
|
-
if (part instanceof RemoteParticipant) {
|
|
11050
|
-
this.eventEmitter.emit(this.CONFERENCE_USER_PARTICIPANT_JOINED, part);
|
|
11051
|
-
}
|
|
11052
|
-
};
|
|
11053
|
-
|
|
11054
11632
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
11055
11633
|
if (participant.user_uuid === session.uuid) {
|
|
11056
|
-
logger$
|
|
11634
|
+
logger$2.info('room current user joined');
|
|
11057
11635
|
|
|
11058
11636
|
// Retrieve participants via an API calls
|
|
11059
11637
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
11060
|
-
|
|
11061
|
-
|
|
11638
|
+
let response;
|
|
11639
|
+
try {
|
|
11640
|
+
if (this.meetingUuid) {
|
|
11641
|
+
logger$2.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
11642
|
+
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
11643
|
+
} else {
|
|
11644
|
+
logger$2.info('fetching conference participants', { conferenceId });
|
|
11645
|
+
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
11646
|
+
}
|
|
11647
|
+
} catch (e) {
|
|
11648
|
+
logger$2.error('room participants fetching, error', e);
|
|
11649
|
+
}
|
|
11062
11650
|
if (response) {
|
|
11063
|
-
logger$
|
|
11651
|
+
logger$2.info('conference participants fetched', { nb: response.items.length });
|
|
11064
11652
|
participants = response.items.map(item => {
|
|
11065
11653
|
const isMe = item.call_id === this.callId;
|
|
11066
11654
|
|
|
@@ -11073,25 +11661,10 @@ class Room$1 extends Emitter {
|
|
|
11073
11661
|
|
|
11074
11662
|
const localParticipant = participants.find(someParticipant => someParticipant instanceof Wazo.LocalParticipant);
|
|
11075
11663
|
if (!this.localParticipant && localParticipant) {
|
|
11076
|
-
this.localParticipant
|
|
11077
|
-
|
|
11078
|
-
const localVideoStream = this._getLocalVideoStream();
|
|
11079
|
-
if (localVideoStream) {
|
|
11080
|
-
this._saveLocalVideoStream(localVideoStream);
|
|
11081
|
-
}
|
|
11082
|
-
|
|
11083
|
-
this.connected = true;
|
|
11084
|
-
|
|
11085
|
-
// we're in the room, now let's request everyone's status
|
|
11086
|
-
if (this.localParticipant) {
|
|
11087
|
-
this.sendSignal({
|
|
11088
|
-
type: SIGNAL_TYPE_PARTICIPANT_REQUEST,
|
|
11089
|
-
origin: this.localParticipant.getStatus(),
|
|
11090
|
-
});
|
|
11091
|
-
}
|
|
11664
|
+
this._onLocalParticipantJoined(localParticipant);
|
|
11092
11665
|
}
|
|
11093
11666
|
|
|
11094
|
-
participants.forEach(someParticipant =>
|
|
11667
|
+
participants.forEach(someParticipant => this._isParticipantJoining(someParticipant));
|
|
11095
11668
|
this.eventEmitter.emit(this.ON_JOINED, localParticipant, participants);
|
|
11096
11669
|
}
|
|
11097
11670
|
|
|
@@ -11102,16 +11675,45 @@ class Room$1 extends Emitter {
|
|
|
11102
11675
|
? new Wazo.RemoteParticipant(this, participant)
|
|
11103
11676
|
: null;
|
|
11104
11677
|
|
|
11105
|
-
logger$
|
|
11678
|
+
logger$2.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
11106
11679
|
|
|
11107
11680
|
if (remoteParticipant) {
|
|
11108
11681
|
this.participants.push(remoteParticipant);
|
|
11109
|
-
|
|
11682
|
+
this._isParticipantJoining(remoteParticipant);
|
|
11110
11683
|
}
|
|
11111
11684
|
|
|
11112
11685
|
return remoteParticipant;
|
|
11113
11686
|
}
|
|
11114
11687
|
|
|
11688
|
+
_onLocalParticipantJoined(localParticipant ) {
|
|
11689
|
+
this.localParticipant = localParticipant;
|
|
11690
|
+
|
|
11691
|
+
const localVideoStream = this._getLocalVideoStream();
|
|
11692
|
+
if (localVideoStream) {
|
|
11693
|
+
this._saveLocalVideoStream(localVideoStream);
|
|
11694
|
+
}
|
|
11695
|
+
|
|
11696
|
+
this.connected = true;
|
|
11697
|
+
|
|
11698
|
+
localParticipant.broadcastStatus();
|
|
11699
|
+
|
|
11700
|
+
// we're in the room, now let's request everyone's status
|
|
11701
|
+
if (this.localParticipant) {
|
|
11702
|
+
this.sendSignal({
|
|
11703
|
+
type: SIGNAL_TYPE_PARTICIPANT_REQUEST,
|
|
11704
|
+
origin: this.localParticipant.getStatus(),
|
|
11705
|
+
});
|
|
11706
|
+
}
|
|
11707
|
+
}
|
|
11708
|
+
|
|
11709
|
+
_isParticipantJoining(participant ) {
|
|
11710
|
+
this.__associateStreams(participant);
|
|
11711
|
+
// @VALIDATE: no need to publicize ourselves, no?
|
|
11712
|
+
if (participant instanceof RemoteParticipant) {
|
|
11713
|
+
this.eventEmitter.emit(this.CONFERENCE_USER_PARTICIPANT_JOINED, participant);
|
|
11714
|
+
}
|
|
11715
|
+
}
|
|
11716
|
+
|
|
11115
11717
|
_saveLocalVideoStream(stream ) {
|
|
11116
11718
|
const { localParticipant } = this;
|
|
11117
11719
|
|
|
@@ -11157,9 +11759,11 @@ class Room$1 extends Emitter {
|
|
|
11157
11759
|
_onParticipantTrackUpdate(oldParticipant , update ) {
|
|
11158
11760
|
const newParticipant = oldParticipant;
|
|
11159
11761
|
|
|
11160
|
-
const { trackId } = this._callIdStreamIdMap[newParticipant.callId] || {};
|
|
11762
|
+
const { trackId, streamId } = this._callIdStreamIdMap[newParticipant.callId] || {};
|
|
11161
11763
|
const pc = Wazo.Phone.phone.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
11162
|
-
|
|
11764
|
+
// Can't use `getReceivers` here because on FF we make the mapping based on the streamId
|
|
11765
|
+
const stream = pc.getRemoteStreams().find(someStream =>
|
|
11766
|
+
someStream.id === streamId || someStream.getTracks().some(track => track.id === trackId));
|
|
11163
11767
|
|
|
11164
11768
|
if (update === 'downgrade') {
|
|
11165
11769
|
newParticipant.streams = [];
|
|
@@ -11189,15 +11793,41 @@ class Room$1 extends Emitter {
|
|
|
11189
11793
|
return;
|
|
11190
11794
|
}
|
|
11191
11795
|
|
|
11192
|
-
|
|
11796
|
+
const streamId = this._getStreamIdFrTrackId(trackId);
|
|
11797
|
+
const key = this._getUnassociatedMapIdFromTrackIdOrStreamId(trackId, streamId);
|
|
11798
|
+
const stream = this._unassociatedVideoStreams[key];
|
|
11799
|
+
|
|
11800
|
+
if (stream) {
|
|
11193
11801
|
// Try to associate stream
|
|
11194
|
-
this._associateStreamTo(
|
|
11802
|
+
this._associateStreamTo(stream, participant);
|
|
11195
11803
|
|
|
11196
|
-
delete this._unassociatedVideoStreams[
|
|
11804
|
+
delete this._unassociatedVideoStreams[key];
|
|
11197
11805
|
delete this._unassociatedParticipants[participant.callId];
|
|
11198
11806
|
}
|
|
11199
11807
|
}
|
|
11200
11808
|
|
|
11809
|
+
_getUnassociatedMapIdFromTrackIdOrStreamId(trackId , streamId ) {
|
|
11810
|
+
// Find by trackId
|
|
11811
|
+
if (trackId in this._unassociatedVideoStreams) {
|
|
11812
|
+
return trackId;
|
|
11813
|
+
}
|
|
11814
|
+
|
|
11815
|
+
// Find by streamId
|
|
11816
|
+
if (streamId && streamId in this._unassociatedVideoStreams) {
|
|
11817
|
+
return streamId;
|
|
11818
|
+
}
|
|
11819
|
+
|
|
11820
|
+
// Find in all the streams by streamId (used on FF where we can't map by trackId)
|
|
11821
|
+
const idx = Object.values(this._unassociatedVideoStreams).findIndex((stream ) => stream.id === streamId);
|
|
11822
|
+
return idx === -1 ? null : Object.keys(this._unassociatedVideoStreams)[idx];
|
|
11823
|
+
}
|
|
11824
|
+
|
|
11825
|
+
_getStreamIdFrTrackId(trackId ) {
|
|
11826
|
+
const mapping = Object.values(this._callIdStreamIdMap).find((map ) => map.trackId === trackId);
|
|
11827
|
+
|
|
11828
|
+
return mapping ? mapping.streamId : null;
|
|
11829
|
+
}
|
|
11830
|
+
|
|
11201
11831
|
_associateStreamTo(rawStream , participant ) {
|
|
11202
11832
|
const stream = new Wazo.Stream(rawStream, participant);
|
|
11203
11833
|
participant.streams.push(stream);
|
|
@@ -11221,7 +11851,141 @@ class Room$1 extends Emitter {
|
|
|
11221
11851
|
|
|
11222
11852
|
//
|
|
11223
11853
|
|
|
11224
|
-
|
|
11854
|
+
const logger$1 = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
11855
|
+
|
|
11856
|
+
class SipRoom extends Room$1 {
|
|
11857
|
+
|
|
11858
|
+
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
11859
|
+
logger$1.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
11860
|
+
|
|
11861
|
+
if (!room) {
|
|
11862
|
+
await Wazo.Phone.connect();
|
|
11863
|
+
|
|
11864
|
+
const withCamera = constraints && !!constraints.video;
|
|
11865
|
+
|
|
11866
|
+
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
11867
|
+
// eslint-disable-next-line no-param-reassign
|
|
11868
|
+
room = new SipRoom(callSession, extension, null, null, extra);
|
|
11869
|
+
}
|
|
11870
|
+
|
|
11871
|
+
if (room && room.callSession && room.callSession.call) {
|
|
11872
|
+
room.setCallId(room.callSession.call.id);
|
|
11873
|
+
}
|
|
11874
|
+
|
|
11875
|
+
logger$1.info('connected to room', {
|
|
11876
|
+
extension: room.extension,
|
|
11877
|
+
});
|
|
11878
|
+
|
|
11879
|
+
return room;
|
|
11880
|
+
}
|
|
11881
|
+
|
|
11882
|
+
mute() {
|
|
11883
|
+
logger$1.info('mute sip room');
|
|
11884
|
+
|
|
11885
|
+
Wazo.Phone.mute(this.callSession, false);
|
|
11886
|
+
|
|
11887
|
+
this.sendMuteStatus();
|
|
11888
|
+
}
|
|
11889
|
+
|
|
11890
|
+
unmute() {
|
|
11891
|
+
logger$1.info('unmute sip room');
|
|
11892
|
+
|
|
11893
|
+
Wazo.Phone.unmute(this.callSession, false);
|
|
11894
|
+
|
|
11895
|
+
this.sendUnMuteStatus();
|
|
11896
|
+
}
|
|
11897
|
+
|
|
11898
|
+
getLocalGuestName() {
|
|
11899
|
+
return Wazo.Phone.phone.client.userAgent.options.displayName;
|
|
11900
|
+
}
|
|
11901
|
+
|
|
11902
|
+
// Overridden to not listen to websocket messages
|
|
11903
|
+
_transferEvents() {
|
|
11904
|
+
// Phone events
|
|
11905
|
+
Wazo.Phone.on(this.ON_MESSAGE, this._boundOnMessage);
|
|
11906
|
+
Wazo.Phone.on(this.ON_CHAT, this._boundOnChat);
|
|
11907
|
+
Wazo.Phone.on(this.ON_SIGNAL, this._boundOnSignal);
|
|
11908
|
+
Wazo.Phone.on(this.ON_VIDEO_INPUT_CHANGE, this._boundSaveLocalVideoStream);
|
|
11909
|
+
|
|
11910
|
+
[this.ON_AUDIO_STREAM, this.ON_VIDEO_STREAM, this.ON_REMOVE_STREAM].forEach(event =>
|
|
11911
|
+
Wazo.Phone.on(event, (...args) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
|
|
11912
|
+
}
|
|
11913
|
+
|
|
11914
|
+
_onMessage(message ) {
|
|
11915
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
11916
|
+
const body = super._onMessage(message);
|
|
11917
|
+
if (!body) {
|
|
11918
|
+
return;
|
|
11919
|
+
}
|
|
11920
|
+
|
|
11921
|
+
const getChannel = () => body.channels[0];
|
|
11922
|
+
|
|
11923
|
+
switch (body.type) {
|
|
11924
|
+
case 'ConfbridgeWelcome':
|
|
11925
|
+
body.channels.forEach(channel => {
|
|
11926
|
+
this._onParticipantJoined(channel);
|
|
11927
|
+
});
|
|
11928
|
+
|
|
11929
|
+
break;
|
|
11930
|
+
case 'ConfbridgeJoin': {
|
|
11931
|
+
const channel = getChannel();
|
|
11932
|
+
this._onParticipantJoined(channel);
|
|
11933
|
+
break;
|
|
11934
|
+
}
|
|
11935
|
+
case 'ConfbridgeLeave': {
|
|
11936
|
+
const channel = getChannel();
|
|
11937
|
+
this._onParticipantLeft({
|
|
11938
|
+
data: {
|
|
11939
|
+
call_id: channel.id,
|
|
11940
|
+
},
|
|
11941
|
+
});
|
|
11942
|
+
break;
|
|
11943
|
+
}
|
|
11944
|
+
}
|
|
11945
|
+
}
|
|
11946
|
+
|
|
11947
|
+
async _onParticipantJoined(channel ) {
|
|
11948
|
+
const isLocal = channel.channelvars.WAZO_SIP_CALL_ID === this._getCurrentSipCallIs();
|
|
11949
|
+
const callId = channel.id;
|
|
11950
|
+
const ParticipantClass = isLocal ? Wazo.LocalParticipant : Wazo.RemoteParticipant;
|
|
11951
|
+
const name = channel.caller ? channel.caller.name : null;
|
|
11952
|
+
const extra = isLocal ? { guestName: this.getLocalGuestName() } : {};
|
|
11953
|
+
const participant = new ParticipantClass(this, {
|
|
11954
|
+
caller_id_name: name,
|
|
11955
|
+
call_id: callId,
|
|
11956
|
+
}, extra);
|
|
11957
|
+
|
|
11958
|
+
const participantIdx = this.participants.findIndex(other => other.callId === participant.callId);
|
|
11959
|
+
if (participantIdx !== -1 && name) {
|
|
11960
|
+
this.participants[participantIdx].name = name;
|
|
11961
|
+
return;
|
|
11962
|
+
}
|
|
11963
|
+
|
|
11964
|
+
if (isLocal) {
|
|
11965
|
+
// Should be updated by the Wazo WS but we don't have it for now
|
|
11966
|
+
if (this.callSession) {
|
|
11967
|
+
this.callSession.ringing = false;
|
|
11968
|
+
}
|
|
11969
|
+
|
|
11970
|
+
this._onLocalParticipantJoined(participant);
|
|
11971
|
+
|
|
11972
|
+
// Give some time for the stream to be updated
|
|
11973
|
+
setTimeout(() => {
|
|
11974
|
+
this.eventEmitter.emit(this.ON_JOINED, participant, this.participants);
|
|
11975
|
+
}, 1000);
|
|
11976
|
+
}
|
|
11977
|
+
|
|
11978
|
+
this.participants.push(participant);
|
|
11979
|
+
|
|
11980
|
+
this._isParticipantJoining(participant);
|
|
11981
|
+
|
|
11982
|
+
return participant;
|
|
11983
|
+
}
|
|
11984
|
+
|
|
11985
|
+
_getCurrentSipCallIs() {
|
|
11986
|
+
return Wazo.Phone.getSipSessionId(Wazo.Phone.phone.currentSipSession);
|
|
11987
|
+
}
|
|
11988
|
+
|
|
11225
11989
|
}
|
|
11226
11990
|
|
|
11227
11991
|
/* global document */
|
|
@@ -11274,9 +12038,7 @@ class Stream {
|
|
|
11274
12038
|
return false;
|
|
11275
12039
|
}
|
|
11276
12040
|
|
|
11277
|
-
|
|
11278
|
-
return this.htmlStream.getTracks().find(track => track.kind === 'video'
|
|
11279
|
-
&& track.readyState !== 'ended' && 'width' in track.getSettings());
|
|
12041
|
+
return this.htmlStream.getTracks().some(track => track.kind === 'video' && track.readyState !== 'ended');
|
|
11280
12042
|
}
|
|
11281
12043
|
|
|
11282
12044
|
get id() {
|
|
@@ -12161,6 +12923,7 @@ const Wazo = {
|
|
|
12161
12923
|
Phone: Phone$1,
|
|
12162
12924
|
Websocket: Websocket$1,
|
|
12163
12925
|
Room: Room$1,
|
|
12926
|
+
SipRoom,
|
|
12164
12927
|
RemoteParticipant,
|
|
12165
12928
|
LocalParticipant,
|
|
12166
12929
|
Stream,
|
|
@@ -12180,6 +12943,7 @@ const Wazo = {
|
|
|
12180
12943
|
ServerError,
|
|
12181
12944
|
Call,
|
|
12182
12945
|
CallLog,
|
|
12946
|
+
CTIPhone,
|
|
12183
12947
|
Recording,
|
|
12184
12948
|
ChatMessage,
|
|
12185
12949
|
ChatRoom,
|
|
@@ -12195,6 +12959,8 @@ const Wazo = {
|
|
|
12195
12959
|
CallSession,
|
|
12196
12960
|
IndirectTransfer,
|
|
12197
12961
|
SwitchboardCall,
|
|
12962
|
+
WebRTCPhone,
|
|
12963
|
+
Meeting,
|
|
12198
12964
|
},
|
|
12199
12965
|
|
|
12200
12966
|
// Api
|