@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
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
/* global btoa */
|
|
3
|
+
|
|
4
|
+
import Meeting from '../Meeting';
|
|
5
|
+
|
|
6
|
+
describe('Meeting domain', () => {
|
|
7
|
+
it('can return username and secret from an base64 encrypted string', () => {
|
|
8
|
+
const USERNAME = 'username';
|
|
9
|
+
const SECRET = 'secret';
|
|
10
|
+
|
|
11
|
+
const args = {
|
|
12
|
+
guest_sip_authorization: btoa(`${USERNAME}:${SECRET}`),
|
|
13
|
+
creation_time: '',
|
|
14
|
+
ingress_http_uri: '',
|
|
15
|
+
name: '',
|
|
16
|
+
owner_uuids: [],
|
|
17
|
+
port: '',
|
|
18
|
+
uuid: '',
|
|
19
|
+
exten: '',
|
|
20
|
+
persistent: false,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const meeting = Meeting.parse(args);
|
|
24
|
+
|
|
25
|
+
const { username, secret } = meeting.getGuestSipCredentials();
|
|
26
|
+
|
|
27
|
+
expect(username).toEqual(USERNAME);
|
|
28
|
+
expect(secret).toEqual(SECRET);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should return a date from a string', () => {
|
|
32
|
+
const args = {
|
|
33
|
+
creation_time: '2021-12-21T15:56:42.880Z',
|
|
34
|
+
guest_sip_authorization: '',
|
|
35
|
+
ingress_http_uri: '',
|
|
36
|
+
name: '',
|
|
37
|
+
owner_uuids: [],
|
|
38
|
+
port: '',
|
|
39
|
+
uuid: '',
|
|
40
|
+
exten: '',
|
|
41
|
+
persistent: false,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const { creationTime } = Meeting.parse(args);
|
|
45
|
+
|
|
46
|
+
expect(creationTime.getDate()).toEqual(21);
|
|
47
|
+
expect(creationTime.getFullYear()).toEqual(2021);
|
|
48
|
+
expect(creationTime.getMonth()).toEqual(11);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -12,11 +12,9 @@ import { SessionDescriptionHandler }
|
|
|
12
12
|
import { SessionDescriptionHandlerOptions }
|
|
13
13
|
from 'sip.js/lib/platform/web/session-description-handler/session-description-handler-options';
|
|
14
14
|
import IssueReporter from '../service/IssueReporter';
|
|
15
|
-
import {
|
|
15
|
+
import { fixSdp, parseCandidate } from '../utils/sdp';
|
|
16
16
|
|
|
17
17
|
const wazoLogger = IssueReporter ? IssueReporter.loggerFor('webrtc-sdh') : console;
|
|
18
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
19
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
20
18
|
|
|
21
19
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
22
20
|
export const wazoMediaStreamFactory = (constraints: Object): Promise<MediaStream> => {
|
|
@@ -206,38 +204,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
206
204
|
this._peerConnection = undefined;
|
|
207
205
|
}
|
|
208
206
|
|
|
209
|
-
async _waitForValidGatheredIce(): Object {
|
|
210
|
-
let tries = 0;
|
|
211
|
-
|
|
212
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
213
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
214
|
-
tries,
|
|
215
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
tries++;
|
|
219
|
-
|
|
220
|
-
// eslint-disable-next-line no-await-in-loop
|
|
221
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
225
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
226
|
-
const error = new Error(errorMsg);
|
|
227
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
228
|
-
|
|
229
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
230
|
-
this.eventEmitter.emit('error', error);
|
|
231
|
-
|
|
232
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// eslint-disable-next-line
|
|
236
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
237
|
-
|
|
238
|
-
return this.getLocalSessionDescription();
|
|
239
|
-
}
|
|
240
|
-
|
|
241
207
|
// Overridden to send `inactive` in conference
|
|
242
208
|
updateDirection(options?: SessionDescriptionHandlerOptions, isConference: boolean = false,
|
|
243
209
|
audioOnly: boolean = false): Promise<void> {
|
package/src/web-rtc-client.js
CHANGED
|
@@ -453,7 +453,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
call(number: string, enableVideo?: boolean, audioOnly: boolean = false, conference: boolean = false): Session {
|
|
456
|
-
logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
456
|
+
logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
|
|
457
457
|
const inviterOptions: Object = {
|
|
458
458
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
459
459
|
conference,
|
|
@@ -1529,6 +1529,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
1529
1529
|
const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
|
|
1530
1530
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
1531
1531
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
1532
|
+
const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
|
|
1532
1533
|
|
|
1533
1534
|
logger.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
1534
1535
|
|
|
@@ -1536,7 +1537,8 @@ export default class WebRTCClient extends Emitter {
|
|
|
1536
1537
|
constraints: {
|
|
1537
1538
|
// Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
|
|
1538
1539
|
audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
|
|
1539
|
-
video: screenSharing ? (isDesktop
|
|
1540
|
+
video: screenSharing ? (isDesktop
|
|
1541
|
+
? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
|
|
1540
1542
|
: this._getVideoConstraints(enableVideo),
|
|
1541
1543
|
screen: screenSharing,
|
|
1542
1544
|
desktop: isDesktop,
|
|
@@ -1871,12 +1873,14 @@ export default class WebRTCClient extends Emitter {
|
|
|
1871
1873
|
|
|
1872
1874
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
1873
1875
|
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1876
|
+
if (pc) {
|
|
1877
|
+
pc.oniceconnectionstatechange = () => {
|
|
1878
|
+
logger.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
1879
|
+
if (pc.iceConnectionState === 'disconnected') {
|
|
1880
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
1881
|
+
}
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1880
1884
|
|
|
1881
1885
|
if (withEvent) {
|
|
1882
1886
|
this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
|
|
@@ -2086,13 +2090,17 @@ export default class WebRTCClient extends Emitter {
|
|
|
2086
2090
|
const nbStats = this.sessionNetworkStats[sessionId].length;
|
|
2087
2091
|
const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
|
|
2088
2092
|
const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
|
|
2093
|
+
const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
|
|
2089
2094
|
const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
|
|
2090
2095
|
const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
|
|
2096
|
+
const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
|
|
2091
2097
|
const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
|
|
2092
2098
|
const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
|
|
2093
2099
|
const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
|
|
2094
|
-
let audioBytesSent = 0;
|
|
2095
|
-
let audioBytesReceived = 0;
|
|
2100
|
+
let audioBytesSent = 0; // content + header
|
|
2101
|
+
let audioBytesReceived = 0; // content + header
|
|
2102
|
+
let audioContentSent = 0; // useful to detect blank call
|
|
2103
|
+
let audioContentReceived = 0;
|
|
2096
2104
|
let videoBytesSent = 0;
|
|
2097
2105
|
let videoBytesReceived = 0;
|
|
2098
2106
|
let transportSent = 0;
|
|
@@ -2101,25 +2109,27 @@ export default class WebRTCClient extends Emitter {
|
|
|
2101
2109
|
|
|
2102
2110
|
stats.forEach(report => {
|
|
2103
2111
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
2104
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
2112
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
2113
|
+
audioContentSent += Number(report.bytesSent);
|
|
2105
2114
|
}
|
|
2106
2115
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
2107
|
-
audioBytesSent += report.bytesSent;
|
|
2116
|
+
audioBytesSent += Number(report.bytesSent);
|
|
2108
2117
|
}
|
|
2109
2118
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
2110
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
2119
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
2111
2120
|
}
|
|
2112
2121
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
2113
|
-
packetsLost += report.packetsLost;
|
|
2114
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
2115
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
2122
|
+
packetsLost += Number(report.packetsLost);
|
|
2123
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
2124
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
2125
|
+
audioContentReceived += Number(report.bytesReceived);
|
|
2116
2126
|
}
|
|
2117
2127
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
2118
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
2128
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
2119
2129
|
}
|
|
2120
2130
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
2121
2131
|
if ('framesPerSecond' in report) {
|
|
2122
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
2132
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
2123
2133
|
}
|
|
2124
2134
|
if ('framerateMean' in report) {
|
|
2125
2135
|
// framerateMean is only available in FF
|
|
@@ -2127,24 +2137,31 @@ export default class WebRTCClient extends Emitter {
|
|
|
2127
2137
|
}
|
|
2128
2138
|
}
|
|
2129
2139
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
2130
|
-
packetsLost += report.packetsLost;
|
|
2131
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
2132
|
-
networkStats.jitter = report.jitter;
|
|
2140
|
+
packetsLost += Number(report.packetsLost);
|
|
2141
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
2142
|
+
networkStats.jitter = Number(report.jitter);
|
|
2133
2143
|
}
|
|
2134
2144
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
2135
|
-
packetsLost += report.packetsLost;
|
|
2145
|
+
packetsLost += Number(report.packetsLost);
|
|
2136
2146
|
}
|
|
2137
2147
|
if (report.type === 'transport') {
|
|
2138
|
-
transportSent += report.bytesSent;
|
|
2139
|
-
transportReceived += report.bytesReceived;
|
|
2148
|
+
transportSent += Number(report.bytesSent);
|
|
2149
|
+
transportReceived += Number(report.bytesReceived);
|
|
2140
2150
|
}
|
|
2141
2151
|
});
|
|
2142
2152
|
|
|
2143
2153
|
networkStats.packetsLost = packetsLost;
|
|
2154
|
+
|
|
2144
2155
|
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
2145
2156
|
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
2146
2157
|
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
2147
2158
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
2159
|
+
|
|
2160
|
+
networkStats.totalAudioContentSent = audioContentSent;
|
|
2161
|
+
networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
|
|
2162
|
+
networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
|
|
2163
|
+
networkStats.audioContentReceived = audioContentReceived;
|
|
2164
|
+
|
|
2148
2165
|
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
2149
2166
|
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
2150
2167
|
networkStats.totalVideoBytesReceived = videoBytesReceived;
|