@wazo/sdk 0.37.21 → 0.37.25
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 +36 -5
- package/esm/__tests__/web-rtc-client.test.js +77 -66
- 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 +3 -0
- package/esm/api-client.js +36 -5
- package/esm/checker/Checker.js +77 -66
- package/esm/checker/checks/aor.js +36 -5
- package/esm/checker/checks/api.js +36 -5
- package/esm/checker/checks/index.js +77 -66
- package/esm/checker/checks/webrtc-transport.js +77 -66
- package/esm/checker/checks/webrtc.js +77 -66
- package/esm/domain/AdHocAPIConference.js +36 -5
- 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 +3 -0
- package/esm/domain/Features.js +36 -5
- package/esm/domain/Meeting.js +15 -5
- package/esm/domain/Phone/CTIPhone.js +40 -5
- package/esm/domain/Phone/WebRTCPhone.js +45 -16
- 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 +3 -0
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +125 -81
- package/esm/lib/WazoSessionDescriptionHandler.js +0 -38
- package/esm/service/CallApi.js +36 -5
- package/esm/service/getApiClient.js +36 -5
- package/esm/simple/Auth.js +125 -81
- package/esm/simple/Configuration.js +125 -81
- package/esm/simple/Directory.js +36 -5
- package/esm/simple/Phone.js +125 -81
- package/esm/simple/index.js +125 -81
- package/esm/simple/room/LocalParticipant.js +125 -81
- package/esm/simple/room/Participant.js +125 -81
- package/esm/simple/room/RemoteParticipant.js +125 -81
- package/esm/simple/room/Room.js +125 -81
- package/esm/simple/room/SipRoom.js +125 -81
- package/esm/simple/room/Stream.js +125 -81
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +125 -81
- package/esm/simple/utils.js +125 -81
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/web-rtc-client.js +77 -66
- package/lib/__tests__/api-client.test.js +36 -5
- package/lib/__tests__/web-rtc-client.test.js +77 -66
- 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 +3 -0
- package/lib/api-client.js +36 -5
- package/lib/checker/Checker.js +77 -66
- package/lib/checker/checks/aor.js +36 -5
- package/lib/checker/checks/api.js +36 -5
- package/lib/checker/checks/index.js +77 -66
- package/lib/checker/checks/webrtc-transport.js +77 -66
- package/lib/checker/checks/webrtc.js +77 -66
- package/lib/domain/AdHocAPIConference.js +36 -5
- 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 +3 -0
- package/lib/domain/Features.js +36 -5
- package/lib/domain/Meeting.js +19 -5
- package/lib/domain/Phone/CTIPhone.js +40 -5
- package/lib/domain/Phone/WebRTCPhone.js +45 -16
- 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 +3 -0
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +125 -81
- package/lib/lib/WazoSessionDescriptionHandler.js +0 -38
- package/lib/service/CallApi.js +36 -5
- package/lib/service/getApiClient.js +36 -5
- package/lib/simple/Auth.js +125 -81
- package/lib/simple/Configuration.js +125 -81
- package/lib/simple/Directory.js +36 -5
- package/lib/simple/Phone.js +125 -81
- package/lib/simple/index.js +125 -81
- package/lib/simple/room/LocalParticipant.js +125 -81
- package/lib/simple/room/Participant.js +125 -81
- package/lib/simple/room/RemoteParticipant.js +125 -81
- package/lib/simple/room/Room.js +125 -81
- package/lib/simple/room/SipRoom.js +125 -81
- package/lib/simple/room/Stream.js +125 -81
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +125 -81
- package/lib/simple/utils.js +125 -81
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/web-rtc-client.js +77 -66
- 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 +3 -0
- 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 +45 -16
- 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 -23
|
@@ -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,11 +1873,14 @@ export default class WebRTCClient extends Emitter {
|
|
|
1871
1873
|
|
|
1872
1874
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
1873
1875
|
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
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
|
+
}
|
|
1879
1884
|
|
|
1880
1885
|
if (withEvent) {
|
|
1881
1886
|
this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
|
|
@@ -2085,13 +2090,17 @@ export default class WebRTCClient extends Emitter {
|
|
|
2085
2090
|
const nbStats = this.sessionNetworkStats[sessionId].length;
|
|
2086
2091
|
const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
|
|
2087
2092
|
const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
|
|
2093
|
+
const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
|
|
2088
2094
|
const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
|
|
2089
2095
|
const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
|
|
2096
|
+
const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
|
|
2090
2097
|
const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
|
|
2091
2098
|
const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
|
|
2092
2099
|
const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
|
|
2093
|
-
let audioBytesSent = 0;
|
|
2094
|
-
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;
|
|
2095
2104
|
let videoBytesSent = 0;
|
|
2096
2105
|
let videoBytesReceived = 0;
|
|
2097
2106
|
let transportSent = 0;
|
|
@@ -2100,25 +2109,27 @@ export default class WebRTCClient extends Emitter {
|
|
|
2100
2109
|
|
|
2101
2110
|
stats.forEach(report => {
|
|
2102
2111
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
2103
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
2112
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
2113
|
+
audioContentSent += Number(report.bytesSent);
|
|
2104
2114
|
}
|
|
2105
2115
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
2106
|
-
audioBytesSent += report.bytesSent;
|
|
2116
|
+
audioBytesSent += Number(report.bytesSent);
|
|
2107
2117
|
}
|
|
2108
2118
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
2109
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
2119
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
2110
2120
|
}
|
|
2111
2121
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
2112
|
-
packetsLost += report.packetsLost;
|
|
2113
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
2114
|
-
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);
|
|
2115
2126
|
}
|
|
2116
2127
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
2117
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
2128
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
2118
2129
|
}
|
|
2119
2130
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
2120
2131
|
if ('framesPerSecond' in report) {
|
|
2121
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
2132
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
2122
2133
|
}
|
|
2123
2134
|
if ('framerateMean' in report) {
|
|
2124
2135
|
// framerateMean is only available in FF
|
|
@@ -2126,24 +2137,31 @@ export default class WebRTCClient extends Emitter {
|
|
|
2126
2137
|
}
|
|
2127
2138
|
}
|
|
2128
2139
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
2129
|
-
packetsLost += report.packetsLost;
|
|
2130
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
2131
|
-
networkStats.jitter = report.jitter;
|
|
2140
|
+
packetsLost += Number(report.packetsLost);
|
|
2141
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
2142
|
+
networkStats.jitter = Number(report.jitter);
|
|
2132
2143
|
}
|
|
2133
2144
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
2134
|
-
packetsLost += report.packetsLost;
|
|
2145
|
+
packetsLost += Number(report.packetsLost);
|
|
2135
2146
|
}
|
|
2136
2147
|
if (report.type === 'transport') {
|
|
2137
|
-
transportSent += report.bytesSent;
|
|
2138
|
-
transportReceived += report.bytesReceived;
|
|
2148
|
+
transportSent += Number(report.bytesSent);
|
|
2149
|
+
transportReceived += Number(report.bytesReceived);
|
|
2139
2150
|
}
|
|
2140
2151
|
});
|
|
2141
2152
|
|
|
2142
2153
|
networkStats.packetsLost = packetsLost;
|
|
2154
|
+
|
|
2143
2155
|
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
2144
2156
|
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
2145
2157
|
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
2146
2158
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
2159
|
+
|
|
2160
|
+
networkStats.totalAudioContentSent = audioContentSent;
|
|
2161
|
+
networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
|
|
2162
|
+
networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
|
|
2163
|
+
networkStats.audioContentReceived = audioContentReceived;
|
|
2164
|
+
|
|
2147
2165
|
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
2148
2166
|
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
2149
2167
|
networkStats.totalVideoBytesReceived = videoBytesReceived;
|