@wazo/sdk 0.37.22 → 0.37.26
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 +37 -6
- package/esm/__tests__/web-rtc-client.test.js +78 -68
- package/esm/api/call-logd.js +7 -0
- package/esm/api/calld.js +10 -0
- package/esm/api/chatd.js +7 -0
- package/esm/api/confd.js +13 -5
- package/esm/api/ctid-ng.js +10 -0
- package/esm/api/dird.js +4 -1
- package/esm/api-client.js +37 -6
- package/esm/checker/Checker.js +78 -68
- package/esm/checker/checks/aor.js +37 -6
- package/esm/checker/checks/api.js +37 -6
- package/esm/checker/checks/index.js +78 -68
- package/esm/checker/checks/webrtc-transport.js +78 -68
- package/esm/checker/checks/webrtc.js +78 -68
- package/esm/domain/AdHocAPIConference.js +37 -6
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +7 -0
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +4 -1
- package/esm/domain/Features.js +37 -6
- package/esm/domain/Meeting.js +15 -5
- package/esm/domain/Phone/CTIPhone.js +41 -6
- package/esm/domain/Phone/WebRTCPhone.js +41 -15
- package/esm/domain/Recording.js +3 -0
- package/esm/domain/Voicemail.js +3 -0
- package/esm/domain/__tests__/Call.test.js +3 -0
- package/esm/domain/__tests__/CallLog.test.js +7 -0
- package/esm/domain/__tests__/Contact.test.js +4 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +122 -82
- package/esm/lib/WazoSessionDescriptionHandler.js +0 -38
- package/esm/service/CallApi.js +37 -6
- package/esm/service/getApiClient.js +37 -6
- package/esm/simple/Auth.js +122 -82
- package/esm/simple/Configuration.js +122 -82
- package/esm/simple/Directory.js +37 -6
- package/esm/simple/Phone.js +122 -82
- package/esm/simple/index.js +122 -82
- package/esm/simple/room/LocalParticipant.js +122 -82
- package/esm/simple/room/Participant.js +122 -82
- package/esm/simple/room/RemoteParticipant.js +122 -82
- package/esm/simple/room/Room.js +122 -82
- package/esm/simple/room/SipRoom.js +122 -82
- package/esm/simple/room/Stream.js +122 -82
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +122 -82
- package/esm/simple/utils.js +122 -82
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/web-rtc-client.js +78 -68
- package/lib/__tests__/api-client.test.js +37 -6
- package/lib/__tests__/web-rtc-client.test.js +78 -68
- package/lib/api/call-logd.js +7 -0
- package/lib/api/calld.js +10 -0
- package/lib/api/chatd.js +7 -0
- package/lib/api/confd.js +13 -5
- package/lib/api/ctid-ng.js +10 -0
- package/lib/api/dird.js +4 -1
- package/lib/api-client.js +37 -6
- package/lib/checker/Checker.js +78 -68
- package/lib/checker/checks/aor.js +37 -6
- package/lib/checker/checks/api.js +37 -6
- package/lib/checker/checks/index.js +78 -68
- package/lib/checker/checks/webrtc-transport.js +78 -68
- package/lib/checker/checks/webrtc.js +78 -68
- package/lib/domain/AdHocAPIConference.js +37 -6
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +7 -0
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +4 -1
- package/lib/domain/Features.js +37 -6
- package/lib/domain/Meeting.js +19 -5
- package/lib/domain/Phone/CTIPhone.js +41 -6
- package/lib/domain/Phone/WebRTCPhone.js +41 -15
- package/lib/domain/Recording.js +3 -0
- package/lib/domain/Voicemail.js +3 -0
- package/lib/domain/__tests__/Call.test.js +3 -0
- package/lib/domain/__tests__/CallLog.test.js +7 -0
- package/lib/domain/__tests__/Contact.test.js +4 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +122 -82
- package/lib/lib/WazoSessionDescriptionHandler.js +0 -38
- package/lib/service/CallApi.js +37 -6
- package/lib/service/getApiClient.js +37 -6
- package/lib/simple/Auth.js +122 -82
- package/lib/simple/Configuration.js +122 -82
- package/lib/simple/Directory.js +37 -6
- package/lib/simple/Phone.js +122 -82
- package/lib/simple/index.js +122 -82
- package/lib/simple/room/LocalParticipant.js +122 -82
- package/lib/simple/room/Participant.js +122 -82
- package/lib/simple/room/RemoteParticipant.js +122 -82
- package/lib/simple/room/Room.js +122 -82
- package/lib/simple/room/SipRoom.js +122 -82
- package/lib/simple/room/Stream.js +122 -82
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +122 -82
- package/lib/simple/utils.js +122 -82
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/web-rtc-client.js +78 -68
- package/package.json +1 -1
- package/src/domain/Call.js +3 -0
- package/src/domain/CallLog.js +4 -0
- package/src/domain/ChatMessage.js +4 -0
- package/src/domain/ChatRoom.js +3 -0
- package/src/domain/Contact.js +4 -1
- package/src/domain/Meeting.js +15 -5
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +41 -15
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -0
- package/src/domain/__tests__/Meeting.test.js +50 -0
- package/src/lib/WazoSessionDescriptionHandler.js +1 -35
- package/src/web-rtc-client.js +41 -24
package/esm/simple/Phone.js
CHANGED
|
@@ -95,6 +95,9 @@ class Call {
|
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
static parseMany(plain ) {
|
|
98
|
+
if (!plain) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
98
101
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
99
102
|
}
|
|
100
103
|
|
|
@@ -2101,6 +2104,9 @@ class Contact {
|
|
|
2101
2104
|
}
|
|
2102
2105
|
|
|
2103
2106
|
static parseMany(response ) {
|
|
2107
|
+
if (!response || !response.results) {
|
|
2108
|
+
return [];
|
|
2109
|
+
}
|
|
2104
2110
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
2105
2111
|
}
|
|
2106
2112
|
|
|
@@ -2471,7 +2477,7 @@ class Contact {
|
|
|
2471
2477
|
this[key] = old[key] || this[key];
|
|
2472
2478
|
});
|
|
2473
2479
|
|
|
2474
|
-
if (old.lineState
|
|
2480
|
+
if (old.lineState) {
|
|
2475
2481
|
this.lineState = old.lineState;
|
|
2476
2482
|
}
|
|
2477
2483
|
|
|
@@ -3178,8 +3184,9 @@ class ExternalApp {
|
|
|
3178
3184
|
|
|
3179
3185
|
|
|
3180
3186
|
|
|
3181
|
-
|
|
3187
|
+
|
|
3182
3188
|
|
|
3189
|
+
|
|
3183
3190
|
|
|
3184
3191
|
|
|
3185
3192
|
class Meeting {
|
|
@@ -3190,9 +3197,10 @@ class Meeting {
|
|
|
3190
3197
|
|
|
3191
3198
|
|
|
3192
3199
|
|
|
3193
|
-
|
|
3200
|
+
|
|
3194
3201
|
|
|
3195
3202
|
|
|
3203
|
+
|
|
3196
3204
|
|
|
3197
3205
|
static parse(plain ) {
|
|
3198
3206
|
return new Meeting({
|
|
@@ -3202,12 +3210,16 @@ class Meeting {
|
|
|
3202
3210
|
ownerUuids: plain.owner_uuids,
|
|
3203
3211
|
port: plain.port,
|
|
3204
3212
|
uuid: plain.uuid,
|
|
3205
|
-
|
|
3213
|
+
extension: plain.exten,
|
|
3206
3214
|
persistent: plain.persistent,
|
|
3215
|
+
creationTime: moment(plain.creation_time).toDate(),
|
|
3207
3216
|
});
|
|
3208
3217
|
}
|
|
3209
3218
|
|
|
3210
3219
|
static parseMany(items ) {
|
|
3220
|
+
if (!items) {
|
|
3221
|
+
return [];
|
|
3222
|
+
}
|
|
3211
3223
|
return items.map(plain => Meeting.parse(plain));
|
|
3212
3224
|
}
|
|
3213
3225
|
|
|
@@ -3222,8 +3234,9 @@ class Meeting {
|
|
|
3222
3234
|
ownerUuids,
|
|
3223
3235
|
port,
|
|
3224
3236
|
uri,
|
|
3225
|
-
|
|
3237
|
+
extension,
|
|
3226
3238
|
persistent,
|
|
3239
|
+
creationTime,
|
|
3227
3240
|
} = {}) {
|
|
3228
3241
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3229
3242
|
this.uri = uri;
|
|
@@ -3231,8 +3244,9 @@ class Meeting {
|
|
|
3231
3244
|
this.ownerUuids = ownerUuids;
|
|
3232
3245
|
this.port = port;
|
|
3233
3246
|
this.uuid = uuid;
|
|
3234
|
-
this.
|
|
3247
|
+
this.extension = extension;
|
|
3235
3248
|
this.persistent = persistent;
|
|
3249
|
+
this.creationTime = creationTime;
|
|
3236
3250
|
|
|
3237
3251
|
// Useful to compare instead of instanceof with minified code
|
|
3238
3252
|
this.type = 'Meeting';
|
|
@@ -3410,6 +3424,10 @@ class ChatMessage {
|
|
|
3410
3424
|
|
|
3411
3425
|
|
|
3412
3426
|
static parseMany(plain ) {
|
|
3427
|
+
if (!plain || !plain.items) {
|
|
3428
|
+
return [];
|
|
3429
|
+
}
|
|
3430
|
+
|
|
3413
3431
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
3414
3432
|
}
|
|
3415
3433
|
|
|
@@ -3519,6 +3537,9 @@ class Voicemail {
|
|
|
3519
3537
|
}
|
|
3520
3538
|
|
|
3521
3539
|
static parseMany(plain ) {
|
|
3540
|
+
if (!plain) {
|
|
3541
|
+
return [];
|
|
3542
|
+
}
|
|
3522
3543
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
3523
3544
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
3524
3545
|
|
|
@@ -3620,6 +3641,9 @@ class Recording {
|
|
|
3620
3641
|
|
|
3621
3642
|
|
|
3622
3643
|
static parseMany(recordings = []) {
|
|
3644
|
+
if (!recordings) {
|
|
3645
|
+
return [];
|
|
3646
|
+
}
|
|
3623
3647
|
return recordings.map(item => Recording.parse(item));
|
|
3624
3648
|
}
|
|
3625
3649
|
|
|
@@ -3721,6 +3745,10 @@ class CallLog {
|
|
|
3721
3745
|
}
|
|
3722
3746
|
|
|
3723
3747
|
static parseMany(plain ) {
|
|
3748
|
+
if (!plain || !plain.items) {
|
|
3749
|
+
return [];
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3724
3752
|
return plain.items.map(item => CallLog.parse(item));
|
|
3725
3753
|
}
|
|
3726
3754
|
|
|
@@ -4290,6 +4318,10 @@ class CTIPhone extends Emitter {
|
|
|
4290
4318
|
return false;
|
|
4291
4319
|
}
|
|
4292
4320
|
|
|
4321
|
+
hasAVideoTrack() {
|
|
4322
|
+
return false;
|
|
4323
|
+
}
|
|
4324
|
+
|
|
4293
4325
|
getLocalStreamForCall() {
|
|
4294
4326
|
return null;
|
|
4295
4327
|
}
|
|
@@ -4683,6 +4715,9 @@ class ChatRoom {
|
|
|
4683
4715
|
|
|
4684
4716
|
|
|
4685
4717
|
static parseMany(plain ) {
|
|
4718
|
+
if (!plain || !plain.items) {
|
|
4719
|
+
return [];
|
|
4720
|
+
}
|
|
4686
4721
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4687
4722
|
}
|
|
4688
4723
|
|
|
@@ -5664,10 +5699,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5664
5699
|
candidates
|
|
5665
5700
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5666
5701
|
|
|
5667
|
-
const areCandidateValid = (candidates ) =>
|
|
5668
|
-
getSrflxOrRelay(candidates)
|
|
5669
|
-
.length > 0;
|
|
5670
|
-
|
|
5671
5702
|
const getVideoDirection = (sdp ) => {
|
|
5672
5703
|
const parsedSdp = sdpParser.parse(sdp);
|
|
5673
5704
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5720,8 +5751,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5720
5751
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5721
5752
|
|
|
5722
5753
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5723
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5724
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5725
5754
|
|
|
5726
5755
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5727
5756
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -5911,38 +5940,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5911
5940
|
this._peerConnection = undefined;
|
|
5912
5941
|
}
|
|
5913
5942
|
|
|
5914
|
-
async _waitForValidGatheredIce() {
|
|
5915
|
-
let tries = 0;
|
|
5916
|
-
|
|
5917
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
5918
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
5919
|
-
tries,
|
|
5920
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
5921
|
-
});
|
|
5922
|
-
|
|
5923
|
-
tries++;
|
|
5924
|
-
|
|
5925
|
-
// eslint-disable-next-line no-await-in-loop
|
|
5926
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
5927
|
-
}
|
|
5928
|
-
|
|
5929
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
5930
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
5931
|
-
const error = new Error(errorMsg);
|
|
5932
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
5933
|
-
|
|
5934
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
5935
|
-
this.eventEmitter.emit('error', error);
|
|
5936
|
-
|
|
5937
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5938
|
-
}
|
|
5939
|
-
|
|
5940
|
-
// eslint-disable-next-line
|
|
5941
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5942
|
-
|
|
5943
|
-
return this.getLocalSessionDescription();
|
|
5944
|
-
}
|
|
5945
|
-
|
|
5946
5943
|
// Overridden to send `inactive` in conference
|
|
5947
5944
|
updateDirection(options , isConference = false,
|
|
5948
5945
|
audioOnly = false) {
|
|
@@ -6710,7 +6707,7 @@ class WebRTCClient extends Emitter {
|
|
|
6710
6707
|
}
|
|
6711
6708
|
|
|
6712
6709
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6713
|
-
logger$9.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6710
|
+
logger$9.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
|
|
6714
6711
|
const inviterOptions = {
|
|
6715
6712
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6716
6713
|
conference,
|
|
@@ -7786,6 +7783,7 @@ class WebRTCClient extends Emitter {
|
|
|
7786
7783
|
const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
|
|
7787
7784
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
7788
7785
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
7786
|
+
const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
|
|
7789
7787
|
|
|
7790
7788
|
logger$9.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
7791
7789
|
|
|
@@ -7793,7 +7791,8 @@ class WebRTCClient extends Emitter {
|
|
|
7793
7791
|
constraints: {
|
|
7794
7792
|
// Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
|
|
7795
7793
|
audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
|
|
7796
|
-
video: screenSharing ? (isDesktop
|
|
7794
|
+
video: screenSharing ? (isDesktop
|
|
7795
|
+
? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
|
|
7797
7796
|
: this._getVideoConstraints(enableVideo),
|
|
7798
7797
|
screen: screenSharing,
|
|
7799
7798
|
desktop: isDesktop,
|
|
@@ -8128,12 +8127,14 @@ class WebRTCClient extends Emitter {
|
|
|
8128
8127
|
|
|
8129
8128
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8130
8129
|
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8130
|
+
if (pc) {
|
|
8131
|
+
pc.oniceconnectionstatechange = () => {
|
|
8132
|
+
logger$9.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8133
|
+
if (pc.iceConnectionState === 'disconnected') {
|
|
8134
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
8135
|
+
}
|
|
8136
|
+
};
|
|
8137
|
+
}
|
|
8137
8138
|
|
|
8138
8139
|
if (withEvent) {
|
|
8139
8140
|
this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
|
|
@@ -8343,13 +8344,17 @@ class WebRTCClient extends Emitter {
|
|
|
8343
8344
|
const nbStats = this.sessionNetworkStats[sessionId].length;
|
|
8344
8345
|
const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
|
|
8345
8346
|
const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
|
|
8347
|
+
const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
|
|
8346
8348
|
const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
|
|
8347
8349
|
const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
|
|
8350
|
+
const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
|
|
8348
8351
|
const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
|
|
8349
8352
|
const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
|
|
8350
8353
|
const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
|
|
8351
|
-
let audioBytesSent = 0;
|
|
8352
|
-
let audioBytesReceived = 0;
|
|
8354
|
+
let audioBytesSent = 0; // content + header
|
|
8355
|
+
let audioBytesReceived = 0; // content + header
|
|
8356
|
+
let audioContentSent = 0; // useful to detect blank call
|
|
8357
|
+
let audioContentReceived = 0;
|
|
8353
8358
|
let videoBytesSent = 0;
|
|
8354
8359
|
let videoBytesReceived = 0;
|
|
8355
8360
|
let transportSent = 0;
|
|
@@ -8358,25 +8363,27 @@ class WebRTCClient extends Emitter {
|
|
|
8358
8363
|
|
|
8359
8364
|
stats.forEach(report => {
|
|
8360
8365
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8361
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8366
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8367
|
+
audioContentSent += Number(report.bytesSent);
|
|
8362
8368
|
}
|
|
8363
8369
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8364
|
-
audioBytesSent += report.bytesSent;
|
|
8370
|
+
audioBytesSent += Number(report.bytesSent);
|
|
8365
8371
|
}
|
|
8366
8372
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8367
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8373
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8368
8374
|
}
|
|
8369
8375
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
8370
|
-
packetsLost += report.packetsLost;
|
|
8371
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
8372
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8376
|
+
packetsLost += Number(report.packetsLost);
|
|
8377
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8378
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8379
|
+
audioContentReceived += Number(report.bytesReceived);
|
|
8373
8380
|
}
|
|
8374
8381
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8375
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8382
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8376
8383
|
}
|
|
8377
8384
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8378
8385
|
if ('framesPerSecond' in report) {
|
|
8379
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
8386
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
8380
8387
|
}
|
|
8381
8388
|
if ('framerateMean' in report) {
|
|
8382
8389
|
// framerateMean is only available in FF
|
|
@@ -8384,24 +8391,31 @@ class WebRTCClient extends Emitter {
|
|
|
8384
8391
|
}
|
|
8385
8392
|
}
|
|
8386
8393
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
8387
|
-
packetsLost += report.packetsLost;
|
|
8388
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
8389
|
-
networkStats.jitter = report.jitter;
|
|
8394
|
+
packetsLost += Number(report.packetsLost);
|
|
8395
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
8396
|
+
networkStats.jitter = Number(report.jitter);
|
|
8390
8397
|
}
|
|
8391
8398
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
8392
|
-
packetsLost += report.packetsLost;
|
|
8399
|
+
packetsLost += Number(report.packetsLost);
|
|
8393
8400
|
}
|
|
8394
8401
|
if (report.type === 'transport') {
|
|
8395
|
-
transportSent += report.bytesSent;
|
|
8396
|
-
transportReceived += report.bytesReceived;
|
|
8402
|
+
transportSent += Number(report.bytesSent);
|
|
8403
|
+
transportReceived += Number(report.bytesReceived);
|
|
8397
8404
|
}
|
|
8398
8405
|
});
|
|
8399
8406
|
|
|
8400
8407
|
networkStats.packetsLost = packetsLost;
|
|
8408
|
+
|
|
8401
8409
|
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8402
8410
|
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8403
8411
|
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8404
8412
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8413
|
+
|
|
8414
|
+
networkStats.totalAudioContentSent = audioContentSent;
|
|
8415
|
+
networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
|
|
8416
|
+
networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
|
|
8417
|
+
networkStats.audioContentReceived = audioContentReceived;
|
|
8418
|
+
|
|
8405
8419
|
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8406
8420
|
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8407
8421
|
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
@@ -8613,6 +8627,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8613
8627
|
constraints,
|
|
8614
8628
|
audioOnly,
|
|
8615
8629
|
conference,
|
|
8630
|
+
iceRestart,
|
|
8616
8631
|
});
|
|
8617
8632
|
|
|
8618
8633
|
if (!sipSession) {
|
|
@@ -8716,6 +8731,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8716
8731
|
|
|
8717
8732
|
this.client.downgradeToAudio(sipSession);
|
|
8718
8733
|
|
|
8734
|
+
if (callSession) {
|
|
8735
|
+
callSession.cameraEnabled = false;
|
|
8736
|
+
this._updateCallSession(callSession);
|
|
8737
|
+
}
|
|
8738
|
+
|
|
8719
8739
|
if (withMessage) {
|
|
8720
8740
|
this._sendReinviteMessage(callSession, false);
|
|
8721
8741
|
}
|
|
@@ -8743,6 +8763,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8743
8763
|
|
|
8744
8764
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
8745
8765
|
|
|
8766
|
+
if (callSession) {
|
|
8767
|
+
callSession.cameraEnabled = true;
|
|
8768
|
+
this._updateCallSession(callSession);
|
|
8769
|
+
}
|
|
8770
|
+
|
|
8746
8771
|
// If no stream is returned, it means we have to reinvite
|
|
8747
8772
|
if (!newStream) {
|
|
8748
8773
|
return true;
|
|
@@ -8979,18 +9004,20 @@ class WebRTCPhone extends Emitter {
|
|
|
8979
9004
|
screenTrack,
|
|
8980
9005
|
});
|
|
8981
9006
|
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
9007
|
+
if (screenTrack) {
|
|
9008
|
+
screenTrack.onended = () => {
|
|
9009
|
+
logger$8.info('WebRTC phone - on screenshare ended', {
|
|
9010
|
+
hadVideo,
|
|
9011
|
+
id: this.getSipSessionId(sipSession),
|
|
9012
|
+
screenTrack,
|
|
9013
|
+
});
|
|
8988
9014
|
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
9015
|
+
this.eventEmitter.emit(
|
|
9016
|
+
ON_SHARE_SCREEN_ENDING,
|
|
9017
|
+
this._createCallSession(sipSession, callSession),
|
|
9018
|
+
);
|
|
9019
|
+
};
|
|
9020
|
+
}
|
|
8994
9021
|
|
|
8995
9022
|
this.currentScreenShare = {
|
|
8996
9023
|
stream: screenStream,
|
|
@@ -9010,7 +9037,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9010
9037
|
}
|
|
9011
9038
|
|
|
9012
9039
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9013
|
-
logger$8.info('WebRTC phone -
|
|
9040
|
+
logger$8.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9014
9041
|
|
|
9015
9042
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9016
9043
|
this.currentSipSession = sipSession;
|
|
@@ -9522,7 +9549,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9522
9549
|
// @TODO: line is not used here
|
|
9523
9550
|
async makeCall(number , line , cameraEnabled ,
|
|
9524
9551
|
audioOnly = false, conference = false) {
|
|
9525
|
-
logger$8.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9552
|
+
logger$8.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
|
|
9526
9553
|
if (!number) {
|
|
9527
9554
|
return Promise.resolve(null);
|
|
9528
9555
|
}
|
|
@@ -9883,9 +9910,13 @@ class WebRTCPhone extends Emitter {
|
|
|
9883
9910
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
9884
9911
|
&& this.currentSipSession.state === SessionState.Established) {
|
|
9885
9912
|
this.shouldSendReinvite = false;
|
|
9913
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
9914
|
+
const isConference = pc ? pc.sfu : false;
|
|
9915
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
9916
|
+
|
|
9886
9917
|
try {
|
|
9887
9918
|
// Send reinvite with iceRestart
|
|
9888
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
9919
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
9889
9920
|
} catch (e) {
|
|
9890
9921
|
logger$8.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
9891
9922
|
}
|
|
@@ -9969,6 +10000,15 @@ class WebRTCPhone extends Emitter {
|
|
|
9969
10000
|
return this.client.getSipSessionId(sipSession);
|
|
9970
10001
|
}
|
|
9971
10002
|
|
|
10003
|
+
_updateCallSession(callSession ) {
|
|
10004
|
+
const sipSession = this.findSipSession(callSession);
|
|
10005
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10006
|
+
|
|
10007
|
+
if (sipSessionId) {
|
|
10008
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10009
|
+
}
|
|
10010
|
+
}
|
|
10011
|
+
|
|
9972
10012
|
_onMessage(message ) {
|
|
9973
10013
|
if (!message || message.method !== 'MESSAGE') {
|
|
9974
10014
|
return;
|