@wazo/sdk 0.37.0-rc.5 → 0.37.2
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 +93 -16
- package/esm/__tests__/web-rtc-client.test.js +153 -54
- package/esm/api/agentd.js +24 -3
- package/esm/api/amid.js +7 -1
- package/esm/api/application.js +24 -3
- package/esm/api/auth.js +24 -3
- package/esm/api/call-logd.js +78 -20
- package/esm/api/calld.js +24 -20
- package/esm/api/chatd.js +24 -3
- package/esm/api/confd.js +24 -3
- package/esm/api/ctid-ng.js +24 -3
- package/esm/api/dird.js +27 -6
- package/esm/api/webhookd.js +7 -1
- package/esm/api-client.js +93 -16
- package/esm/checker/Checker.js +156 -54
- package/esm/checker/checks/aor.js +95 -16
- package/esm/checker/checks/api.js +94 -16
- package/esm/checker/checks/index.js +156 -54
- package/esm/checker/checks/wazo-websocket.js +7 -1
- package/esm/checker/checks/webrtc-transport.js +153 -54
- package/esm/checker/checks/webrtc.js +153 -54
- package/esm/domain/AdHocAPIConference.js +1717 -1640
- package/esm/domain/CallLog.js +71 -19
- package/esm/domain/CallSession.js +1 -18
- package/esm/domain/Contact.js +3 -3
- package/esm/domain/Features.js +93 -16
- package/esm/domain/IndirectTransfer.js +0 -17
- package/esm/domain/Phone/CTIPhone.js +100 -19
- package/esm/domain/Phone/Phone.js +0 -17
- package/esm/domain/Phone/WebRTCPhone.js +51 -36
- package/esm/domain/Recording.js +51 -0
- package/esm/domain/Room.js +0 -17
- package/esm/domain/SwitchboardCall.js +0 -17
- package/esm/domain/__tests__/CallLog.test.js +89 -19
- package/esm/domain/__tests__/CallSession.test.js +1 -18
- package/esm/domain/__tests__/Contact.test.js +3 -3
- package/esm/domain/__tests__/IndirectTransfer.test.js +1 -18
- package/esm/domain/__tests__/Room.test.js +1 -18
- package/esm/domain/__tests__/Session.test.js +7 -0
- package/esm/index.js +3436 -2911
- package/esm/lib/WazoSessionDescriptionHandler.js +28 -10
- package/esm/service/CallApi.js +93 -16
- package/esm/service/IssueReporter.js +7 -1
- package/esm/service/__tests__/IssueReporter.test.js +26 -2
- package/esm/service/getApiClient.js +93 -16
- package/esm/simple/Auth.js +619 -97
- package/esm/simple/Configuration.js +619 -97
- package/esm/simple/Directory.js +93 -16
- package/esm/simple/Phone.js +3261 -2739
- package/esm/simple/Websocket.js +7 -1
- package/esm/simple/index.js +619 -97
- package/esm/simple/room/LocalParticipant.js +619 -97
- package/esm/simple/room/Participant.js +619 -97
- package/esm/simple/room/RemoteParticipant.js +619 -97
- package/esm/simple/room/Room.js +619 -97
- package/esm/simple/room/Stream.js +619 -97
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +619 -97
- package/esm/simple/utils.js +619 -97
- package/esm/utils/__tests__/api-requester.test.js +32 -6
- package/esm/utils/api-requester.js +24 -3
- package/esm/web-rtc-client.js +153 -54
- package/esm/websocket-client.js +7 -1
- package/lib/__tests__/api-client.test.js +93 -16
- package/lib/__tests__/web-rtc-client.test.js +154 -55
- package/lib/api/agentd.js +24 -3
- package/lib/api/amid.js +7 -1
- package/lib/api/application.js +24 -3
- package/lib/api/auth.js +24 -3
- package/lib/api/call-logd.js +78 -20
- package/lib/api/calld.js +24 -20
- package/lib/api/chatd.js +24 -3
- package/lib/api/confd.js +24 -3
- package/lib/api/ctid-ng.js +24 -3
- package/lib/api/dird.js +27 -6
- package/lib/api/webhookd.js +7 -1
- package/lib/api-client.js +93 -16
- package/lib/checker/Checker.js +157 -55
- package/lib/checker/checks/aor.js +95 -16
- package/lib/checker/checks/api.js +94 -16
- package/lib/checker/checks/index.js +157 -55
- package/lib/checker/checks/wazo-websocket.js +7 -1
- package/lib/checker/checks/webrtc-transport.js +154 -55
- package/lib/checker/checks/webrtc.js +154 -55
- package/lib/domain/AdHocAPIConference.js +1717 -1640
- package/lib/domain/CallLog.js +71 -19
- package/lib/domain/CallSession.js +1 -18
- package/lib/domain/Contact.js +3 -3
- package/lib/domain/Features.js +93 -16
- package/lib/domain/IndirectTransfer.js +0 -17
- package/lib/domain/Phone/CTIPhone.js +100 -19
- package/lib/domain/Phone/Phone.js +0 -16
- package/lib/domain/Phone/WebRTCPhone.js +51 -36
- package/lib/domain/Recording.js +57 -0
- package/lib/domain/Room.js +0 -17
- package/lib/domain/SwitchboardCall.js +0 -17
- package/lib/domain/__tests__/CallLog.test.js +89 -19
- package/lib/domain/__tests__/CallSession.test.js +1 -18
- package/lib/domain/__tests__/Contact.test.js +3 -3
- package/lib/domain/__tests__/IndirectTransfer.test.js +1 -18
- package/lib/domain/__tests__/Room.test.js +1 -18
- package/lib/domain/__tests__/Session.test.js +7 -0
- package/lib/index.js +3437 -2912
- package/lib/lib/WazoSessionDescriptionHandler.js +28 -10
- package/lib/service/CallApi.js +93 -16
- package/lib/service/IssueReporter.js +7 -1
- package/lib/service/__tests__/IssueReporter.test.js +26 -2
- package/lib/service/getApiClient.js +93 -16
- package/lib/simple/Auth.js +620 -98
- package/lib/simple/Configuration.js +620 -98
- package/lib/simple/Directory.js +93 -16
- package/lib/simple/Phone.js +3262 -2740
- package/lib/simple/Websocket.js +7 -1
- package/lib/simple/index.js +620 -98
- package/lib/simple/room/LocalParticipant.js +620 -98
- package/lib/simple/room/Participant.js +620 -98
- package/lib/simple/room/RemoteParticipant.js +620 -98
- package/lib/simple/room/Room.js +620 -98
- package/lib/simple/room/Stream.js +620 -98
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +620 -98
- package/lib/simple/utils.js +620 -98
- package/lib/utils/__tests__/api-requester.test.js +32 -6
- package/lib/utils/api-requester.js +24 -3
- package/lib/web-rtc-client.js +154 -55
- package/lib/websocket-client.js +7 -1
- package/package.json +1 -1
- package/src/api-client.js +4 -0
- package/src/checker/checks/aor.js +2 -0
- package/src/checker/checks/api.js +1 -0
- package/src/domain/CallLog.js +18 -11
- package/src/domain/CallSession.js +1 -2
- package/src/domain/Contact.js +3 -3
- package/src/domain/Phone/CTIPhone.js +6 -2
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +26 -16
- package/src/domain/Recording.js +48 -0
- package/src/domain/__tests__/CallLog.test.js +19 -0
- package/src/domain/__tests__/Session.test.js +7 -0
- package/src/index.js +6 -0
- package/src/lib/WazoSessionDescriptionHandler.js +21 -9
- package/src/service/IssueReporter.js +7 -1
- package/src/service/__tests__/IssueReporter.test.js +20 -1
- package/src/simple/Phone.js +5 -1
- package/src/simple/index.js +6 -0
- package/src/simple/room/Room.js +18 -15
- package/src/simple/room/Stream.js +1 -4
- package/src/utils/__tests__/api-requester.test.js +9 -4
- package/src/utils/api-requester.js +17 -2
- package/src/web-rtc-client.js +40 -13
|
@@ -8,12 +8,11 @@ import { jsonToGraphQLQuery } from 'json-to-graphql-query/lib/jsonToGraphQLQuery
|
|
|
8
8
|
import { Invitation } from 'sip.js/lib/api/invitation';
|
|
9
9
|
import 'webrtc-adapter';
|
|
10
10
|
import { UserAgentState } from 'sip.js/lib/api/user-agent-state';
|
|
11
|
-
import 'sip.js/lib/api/message';
|
|
12
11
|
import { Parser } from 'sip.js/lib/core/messages/parser';
|
|
13
12
|
import { C } from 'sip.js/lib/core/messages/methods/constants';
|
|
14
13
|
import { URI } from 'sip.js/lib/grammar/uri';
|
|
15
14
|
import { UserAgent } from 'sip.js/lib/api/user-agent';
|
|
16
|
-
import { holdModifier } from 'sip.js/lib/platform/web/modifiers/modifiers';
|
|
15
|
+
import { stripVideo, holdModifier } from 'sip.js/lib/platform/web/modifiers/modifiers';
|
|
17
16
|
import { Registerer } from 'sip.js/lib/api/registerer';
|
|
18
17
|
import { Inviter } from 'sip.js/lib/api/inviter';
|
|
19
18
|
import { Messager } from 'sip.js/lib/api/messager';
|
|
@@ -129,7 +128,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
129
128
|
|
|
130
129
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
131
130
|
|
|
132
|
-
const logger$
|
|
131
|
+
const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
133
132
|
|
|
134
133
|
// Use a function here to be able to mock it in tests
|
|
135
134
|
const realFetch = () => {
|
|
@@ -164,6 +163,7 @@ class ApiRequester {
|
|
|
164
163
|
|
|
165
164
|
|
|
166
165
|
|
|
166
|
+
|
|
167
167
|
|
|
168
168
|
|
|
169
169
|
|
|
@@ -203,6 +203,8 @@ class ApiRequester {
|
|
|
203
203
|
this.token = token;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
this.shouldLogErrors = true;
|
|
207
|
+
|
|
206
208
|
methods.forEach(method => {
|
|
207
209
|
// $FlowFixMe
|
|
208
210
|
ApiRequester.prototype[method] = function sugar(...args) {
|
|
@@ -226,6 +228,14 @@ class ApiRequester {
|
|
|
226
228
|
this.fetchOptions = options;
|
|
227
229
|
}
|
|
228
230
|
|
|
231
|
+
disableErrorLogging() {
|
|
232
|
+
this.shouldLogErrors = false;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
enableErrorLogging() {
|
|
236
|
+
this.shouldLogErrors = true;
|
|
237
|
+
}
|
|
238
|
+
|
|
229
239
|
async call(
|
|
230
240
|
path ,
|
|
231
241
|
method = 'get',
|
|
@@ -257,7 +267,7 @@ class ApiRequester {
|
|
|
257
267
|
};
|
|
258
268
|
|
|
259
269
|
if (this.refreshTokenPromise) {
|
|
260
|
-
logger$
|
|
270
|
+
logger$b.info('A token is already refreshing, waiting ...', { url });
|
|
261
271
|
await this.refreshTokenPromise;
|
|
262
272
|
}
|
|
263
273
|
|
|
@@ -277,7 +287,7 @@ class ApiRequester {
|
|
|
277
287
|
return promise.then(async (err ) => {
|
|
278
288
|
// Check if the token is still valid
|
|
279
289
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
280
|
-
logger$
|
|
290
|
+
logger$b.warn('token expired', { error: err.reason });
|
|
281
291
|
// Replay the call after refreshing the token
|
|
282
292
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
283
293
|
}
|
|
@@ -286,7 +296,9 @@ class ApiRequester {
|
|
|
286
296
|
? exceptionClass.fromText(err, response.status)
|
|
287
297
|
: exceptionClass.fromResponse(err, response.status);
|
|
288
298
|
|
|
289
|
-
|
|
299
|
+
if (this.shouldLogErrors) {
|
|
300
|
+
logger$b.error('API error', error);
|
|
301
|
+
}
|
|
290
302
|
|
|
291
303
|
throw error;
|
|
292
304
|
});
|
|
@@ -294,7 +306,9 @@ class ApiRequester {
|
|
|
294
306
|
|
|
295
307
|
return newParse(response, isJson);
|
|
296
308
|
}).catch(error => {
|
|
297
|
-
|
|
309
|
+
if (this.shouldLogErrors) {
|
|
310
|
+
logger$b.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
311
|
+
}
|
|
298
312
|
|
|
299
313
|
throw error;
|
|
300
314
|
});
|
|
@@ -321,13 +335,13 @@ class ApiRequester {
|
|
|
321
335
|
) {
|
|
322
336
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
323
337
|
let newPath = path;
|
|
324
|
-
logger$
|
|
338
|
+
logger$b.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
325
339
|
|
|
326
340
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
327
341
|
|
|
328
342
|
return this.refreshTokenPromise.then(() => {
|
|
329
343
|
this.refreshTokenPromise = null;
|
|
330
|
-
logger$
|
|
344
|
+
logger$b.info('token refreshed', { isTokenNotFound });
|
|
331
345
|
if (isTokenNotFound) {
|
|
332
346
|
const pathParts = path.split('/');
|
|
333
347
|
pathParts.pop();
|
|
@@ -605,7 +619,13 @@ class IssueReporter {
|
|
|
605
619
|
}
|
|
606
620
|
|
|
607
621
|
_isLevelAbove(level1 , level2 ) {
|
|
608
|
-
|
|
622
|
+
const index1 = LOG_LEVELS.indexOf(level1);
|
|
623
|
+
const index2 = LOG_LEVELS.indexOf(level2);
|
|
624
|
+
if (index1 === -1 || index2 === -1) {
|
|
625
|
+
return false;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
return index1 > index2;
|
|
609
629
|
}
|
|
610
630
|
|
|
611
631
|
_makeCategory(category ) {
|
|
@@ -1593,7 +1613,7 @@ class Contact {
|
|
|
1593
1613
|
|
|
1594
1614
|
return new Contact({
|
|
1595
1615
|
sourceId: single.id || '',
|
|
1596
|
-
name: single.displayName,
|
|
1616
|
+
name: single.displayName || '',
|
|
1597
1617
|
number: numbers.length ? numbers[0].number : '',
|
|
1598
1618
|
numbers,
|
|
1599
1619
|
emails,
|
|
@@ -1624,7 +1644,7 @@ class Contact {
|
|
|
1624
1644
|
|
|
1625
1645
|
return new Contact({
|
|
1626
1646
|
sourceId: single.id || '',
|
|
1627
|
-
name: single.name,
|
|
1647
|
+
name: single.name || '',
|
|
1628
1648
|
number: numbers.length ? numbers[0].number : '',
|
|
1629
1649
|
numbers,
|
|
1630
1650
|
emails,
|
|
@@ -1725,7 +1745,7 @@ class Contact {
|
|
|
1725
1745
|
} = {}) {
|
|
1726
1746
|
this.id = id;
|
|
1727
1747
|
this.uuid = uuid;
|
|
1728
|
-
this.name = name;
|
|
1748
|
+
this.name = name || '';
|
|
1729
1749
|
this.number = number;
|
|
1730
1750
|
this.numbers = numbers;
|
|
1731
1751
|
this.email = email;
|
|
@@ -3339,7 +3359,7 @@ class CallSession {
|
|
|
3339
3359
|
return newFrom(callSession, CallSession);
|
|
3340
3360
|
}
|
|
3341
3361
|
|
|
3342
|
-
static parseCall(
|
|
3362
|
+
static parseCall(call ) {
|
|
3343
3363
|
return new CallSession({
|
|
3344
3364
|
callId: call.id,
|
|
3345
3365
|
sipCallId: call.sipCallId,
|
|
@@ -3366,17 +3386,66 @@ class CallSession {
|
|
|
3366
3386
|
|
|
3367
3387
|
//
|
|
3368
3388
|
|
|
3389
|
+
|
|
3390
|
+
|
|
3391
|
+
|
|
3392
|
+
|
|
3393
|
+
|
|
3394
|
+
|
|
3395
|
+
|
|
3396
|
+
|
|
3397
|
+
|
|
3398
|
+
|
|
3399
|
+
|
|
3400
|
+
|
|
3401
|
+
|
|
3402
|
+
|
|
3403
|
+
|
|
3404
|
+
|
|
3405
|
+
class Recording {
|
|
3406
|
+
|
|
3407
|
+
|
|
3408
|
+
|
|
3409
|
+
|
|
3410
|
+
|
|
3411
|
+
|
|
3412
|
+
static parseMany(recordings ) {
|
|
3413
|
+
return recordings.map(item => Recording.parse(item));
|
|
3414
|
+
}
|
|
3415
|
+
|
|
3416
|
+
static parse(plain ) {
|
|
3417
|
+
return new Recording({
|
|
3418
|
+
deleted: plain.deleted,
|
|
3419
|
+
fileName: plain.filename,
|
|
3420
|
+
end: plain.end_time ? moment(plain.end_time).toDate() : null,
|
|
3421
|
+
start: moment(plain.start_time).toDate(),
|
|
3422
|
+
uuid: plain.uuid,
|
|
3423
|
+
});
|
|
3424
|
+
}
|
|
3425
|
+
|
|
3426
|
+
constructor({ deleted, end, fileName, start, uuid } ) {
|
|
3427
|
+
this.deleted = deleted;
|
|
3428
|
+
this.end = end;
|
|
3429
|
+
this.fileName = fileName;
|
|
3430
|
+
this.start = start;
|
|
3431
|
+
this.uuid = uuid;
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
|
|
3435
|
+
//
|
|
3436
|
+
|
|
3369
3437
|
|
|
3370
|
-
|
|
3438
|
+
|
|
3371
3439
|
|
|
3372
3440
|
|
|
3373
3441
|
|
|
3374
3442
|
|
|
3375
3443
|
|
|
3376
|
-
|
|
3444
|
+
|
|
3377
3445
|
|
|
3378
3446
|
|
|
3379
3447
|
|
|
3448
|
+
|
|
3380
3449
|
|
|
3381
3450
|
|
|
3382
3451
|
|
|
@@ -3389,7 +3458,7 @@ class CallSession {
|
|
|
3389
3458
|
|
|
3390
3459
|
|
|
3391
3460
|
|
|
3392
|
-
|
|
3461
|
+
|
|
3393
3462
|
|
|
3394
3463
|
|
|
3395
3464
|
|
|
@@ -3404,13 +3473,14 @@ class CallSession {
|
|
|
3404
3473
|
|
|
3405
3474
|
|
|
3406
3475
|
|
|
3407
|
-
|
|
3476
|
+
|
|
3477
|
+
|
|
3408
3478
|
|
|
3409
3479
|
|
|
3410
3480
|
class CallLog {
|
|
3411
3481
|
|
|
3412
3482
|
|
|
3413
|
-
|
|
3483
|
+
|
|
3414
3484
|
|
|
3415
3485
|
|
|
3416
3486
|
|
|
@@ -3427,7 +3497,7 @@ class CallLog {
|
|
|
3427
3497
|
|
|
3428
3498
|
|
|
3429
3499
|
|
|
3430
|
-
|
|
3500
|
+
|
|
3431
3501
|
|
|
3432
3502
|
static merge(current , toMerge ) {
|
|
3433
3503
|
const onlyUnique = (value, index, self) => self.indexOf(value) === index;
|
|
@@ -3444,7 +3514,7 @@ class CallLog {
|
|
|
3444
3514
|
|
|
3445
3515
|
static parse(plain ) {
|
|
3446
3516
|
return new CallLog({
|
|
3447
|
-
answer: moment(plain.answer).toDate(),
|
|
3517
|
+
answer: plain.answer ? moment(plain.answer).toDate() : null,
|
|
3448
3518
|
answered: plain.answered,
|
|
3449
3519
|
callDirection: plain.call_direction,
|
|
3450
3520
|
destination: {
|
|
@@ -3458,13 +3528,14 @@ class CallLog {
|
|
|
3458
3528
|
id: plain.id,
|
|
3459
3529
|
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
3460
3530
|
start: moment(plain.start).toDate(),
|
|
3461
|
-
end: moment(plain.end).toDate(),
|
|
3531
|
+
end: plain.end ? moment(plain.end).toDate() : null,
|
|
3532
|
+
recordings: Recording.parseMany(plain.recordings),
|
|
3462
3533
|
});
|
|
3463
3534
|
}
|
|
3464
3535
|
|
|
3465
3536
|
static parseNew(plain , session ) {
|
|
3466
3537
|
return new CallLog({
|
|
3467
|
-
answer: moment(plain.answer).toDate(),
|
|
3538
|
+
answer: plain.answer ? moment(plain.answer).toDate() : null,
|
|
3468
3539
|
answered: plain.answered,
|
|
3469
3540
|
callDirection: plain.call_direction,
|
|
3470
3541
|
destination: {
|
|
@@ -3478,7 +3549,8 @@ class CallLog {
|
|
|
3478
3549
|
id: plain.id,
|
|
3479
3550
|
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
3480
3551
|
start: moment(plain.start).toDate(),
|
|
3481
|
-
end: moment(plain.end).toDate(),
|
|
3552
|
+
end: plain.end ? moment(plain.end).toDate() : null,
|
|
3553
|
+
recordings: Recording.parseMany(plain.recordings),
|
|
3482
3554
|
// @TODO: FIXME add verification declined vs missed call
|
|
3483
3555
|
newMissedCall: session
|
|
3484
3556
|
&& session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
|
|
@@ -3660,11 +3732,414 @@ class IndirectTransfer {
|
|
|
3660
3732
|
}
|
|
3661
3733
|
|
|
3662
3734
|
//
|
|
3735
|
+
|
|
3736
|
+
class CallApi {
|
|
3737
|
+
static async fetchCallLogs(offset , limit ) {
|
|
3738
|
+
return getApiClient().callLogd.listCallLogs(offset, limit);
|
|
3739
|
+
}
|
|
3740
|
+
|
|
3741
|
+
static async fetchDistinctCallLogs(offset , limit , distinct = 'peer_exten') {
|
|
3742
|
+
return getApiClient().callLogd.listDistinctCallLogs(offset, limit, distinct);
|
|
3743
|
+
}
|
|
3744
|
+
|
|
3745
|
+
static async fetchActiveCalls() {
|
|
3746
|
+
return getApiClient().calld.listCalls();
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3749
|
+
static async fetchCallLogsFromDate(from , number ) {
|
|
3750
|
+
return getApiClient().callLogd.listCallLogsFromDate(from, number);
|
|
3751
|
+
}
|
|
3752
|
+
|
|
3753
|
+
static async search(query , limit ) {
|
|
3754
|
+
return getApiClient().callLogd.search(query, limit);
|
|
3755
|
+
}
|
|
3756
|
+
|
|
3757
|
+
static async searchBy(field , value , limit ) {
|
|
3758
|
+
return getApiClient().callLogd.searchBy(field, value, limit);
|
|
3759
|
+
}
|
|
3760
|
+
|
|
3761
|
+
static async fetchSIP(session , line ) {
|
|
3762
|
+
const lineToUse = line || session.primaryLine();
|
|
3763
|
+
return getApiClient().confd.getUserLineSip(session.uuid, lineToUse ? lineToUse.id : null);
|
|
3764
|
+
}
|
|
3765
|
+
|
|
3766
|
+
static async cancelCall(callSession ) {
|
|
3767
|
+
return getApiClient().calld.cancelCall(callSession.callId);
|
|
3768
|
+
}
|
|
3769
|
+
|
|
3770
|
+
static async makeCall(callFromLine , extension , isMobile = false,
|
|
3771
|
+
callbackAllLines = false) {
|
|
3772
|
+
const lineId = callFromLine ? callFromLine.id : null;
|
|
3773
|
+
|
|
3774
|
+
const response = await getApiClient().calld.makeCall(extension, isMobile, lineId, callbackAllLines);
|
|
3775
|
+
return Call.parse(response);
|
|
3776
|
+
}
|
|
3777
|
+
|
|
3778
|
+
static async relocateCall(callId , line , contactIdentifier ) {
|
|
3779
|
+
return getApiClient().calld.relocateCall(callId, 'line', line, contactIdentifier);
|
|
3780
|
+
}
|
|
3781
|
+
|
|
3782
|
+
static async hold(callId ) {
|
|
3783
|
+
return getApiClient().calld.hold(callId);
|
|
3784
|
+
}
|
|
3785
|
+
|
|
3786
|
+
static async resume(callId ) {
|
|
3787
|
+
return getApiClient().calld.resume(callId);
|
|
3788
|
+
}
|
|
3789
|
+
|
|
3790
|
+
static async mute(callId ) {
|
|
3791
|
+
return getApiClient().calld.mute(callId);
|
|
3792
|
+
}
|
|
3793
|
+
|
|
3794
|
+
static async sendDTMF(callId , digits ) {
|
|
3795
|
+
return getApiClient().calld.sendDTMF(callId, digits);
|
|
3796
|
+
}
|
|
3797
|
+
|
|
3798
|
+
static async unmute(callId ) {
|
|
3799
|
+
return getApiClient().calld.unmute(callId);
|
|
3800
|
+
}
|
|
3801
|
+
|
|
3802
|
+
static async transferCall(callId , number , flow ) {
|
|
3803
|
+
return getApiClient().calld.transferCall(callId, number, flow);
|
|
3804
|
+
}
|
|
3805
|
+
|
|
3806
|
+
static async cancelCallTransfer(transferId ) {
|
|
3807
|
+
return getApiClient().calld.cancelCallTransfer(transferId);
|
|
3808
|
+
}
|
|
3809
|
+
|
|
3810
|
+
static async confirmCallTransfer(transferId ) {
|
|
3811
|
+
return getApiClient().calld.confirmCallTransfer(transferId);
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3814
|
+
|
|
3815
|
+
//
|
|
3816
|
+
|
|
3817
|
+
const TRANSFER_FLOW_ATTENDED = 'attended';
|
|
3663
3818
|
const TRANSFER_FLOW_BLIND = 'blind';
|
|
3664
3819
|
|
|
3665
3820
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3666
3821
|
|
|
3667
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3822
|
+
const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3823
|
+
|
|
3824
|
+
class CTIPhone extends Emitter {
|
|
3825
|
+
|
|
3826
|
+
|
|
3827
|
+
|
|
3828
|
+
|
|
3829
|
+
|
|
3830
|
+
|
|
3831
|
+
|
|
3832
|
+
|
|
3833
|
+
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
3834
|
+
super();
|
|
3835
|
+
logger$a.info('CTI Phone created');
|
|
3836
|
+
this.session = session;
|
|
3837
|
+
this.isMobile = isMobile;
|
|
3838
|
+
this.callbackAllLines = callbackAllLines;
|
|
3839
|
+
}
|
|
3840
|
+
|
|
3841
|
+
getOptions() {
|
|
3842
|
+
// @FIXME: temporarily disabling this option
|
|
3843
|
+
// const hold = this.session.hasEngineVersionGte(MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD);
|
|
3844
|
+
|
|
3845
|
+
return {
|
|
3846
|
+
accept: false,
|
|
3847
|
+
decline: true,
|
|
3848
|
+
mute: true,
|
|
3849
|
+
hold: false,
|
|
3850
|
+
transfer: true,
|
|
3851
|
+
sendKey: true,
|
|
3852
|
+
addParticipant: false,
|
|
3853
|
+
record: true,
|
|
3854
|
+
merge: false,
|
|
3855
|
+
};
|
|
3856
|
+
}
|
|
3857
|
+
|
|
3858
|
+
hasAnActiveCall() {
|
|
3859
|
+
return !!this.currentCall;
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
callCount() {
|
|
3863
|
+
return this.currentCall ? 1 : 0;
|
|
3864
|
+
}
|
|
3865
|
+
|
|
3866
|
+
isWebRTC() {
|
|
3867
|
+
return false;
|
|
3868
|
+
}
|
|
3869
|
+
|
|
3870
|
+
getUserAgent() {
|
|
3871
|
+
return 'cti-phone';
|
|
3872
|
+
}
|
|
3873
|
+
|
|
3874
|
+
startHeartbeat() {
|
|
3875
|
+
}
|
|
3876
|
+
|
|
3877
|
+
setOnHeartbeatTimeout() {
|
|
3878
|
+
}
|
|
3879
|
+
|
|
3880
|
+
setOnHeartbeatCallback() {
|
|
3881
|
+
}
|
|
3882
|
+
|
|
3883
|
+
stopHeartbeat() {
|
|
3884
|
+
}
|
|
3885
|
+
|
|
3886
|
+
bindClientEvents() {
|
|
3887
|
+
}
|
|
3888
|
+
|
|
3889
|
+
onConnect() {
|
|
3890
|
+
}
|
|
3891
|
+
|
|
3892
|
+
onDisconnect() {
|
|
3893
|
+
}
|
|
3894
|
+
|
|
3895
|
+
async makeCall(number , line ) {
|
|
3896
|
+
logger$a.info('make CTI call', { number });
|
|
3897
|
+
|
|
3898
|
+
if (!number) {
|
|
3899
|
+
return null;
|
|
3900
|
+
}
|
|
3901
|
+
try {
|
|
3902
|
+
this.currentCall = await CallApi.makeCall(line, number, this.isMobile, this.callbackAllLines);
|
|
3903
|
+
} catch (_) {
|
|
3904
|
+
// We have to deal with error like `User has no mobile phone number` error in the UI.
|
|
3905
|
+
}
|
|
3906
|
+
if (!this.currentCall) {
|
|
3907
|
+
return null;
|
|
3908
|
+
}
|
|
3909
|
+
const callSession = CallSession.parseCall(this.currentCall);
|
|
3910
|
+
this.eventEmitter.emit('onCallOutgoing', callSession);
|
|
3911
|
+
|
|
3912
|
+
return callSession;
|
|
3913
|
+
}
|
|
3914
|
+
|
|
3915
|
+
accept(callSession ) {
|
|
3916
|
+
if (!callSession) {
|
|
3917
|
+
return Promise.resolve(null);
|
|
3918
|
+
}
|
|
3919
|
+
logger$a.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3920
|
+
|
|
3921
|
+
if (!this.currentCall) {
|
|
3922
|
+
this.currentCall = callSession.call;
|
|
3923
|
+
}
|
|
3924
|
+
|
|
3925
|
+
return Promise.resolve(callSession.getId());
|
|
3926
|
+
}
|
|
3927
|
+
|
|
3928
|
+
endCurrentCall(callSession ) {
|
|
3929
|
+
if (!callSession) {
|
|
3930
|
+
return;
|
|
3931
|
+
}
|
|
3932
|
+
logger$a.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3933
|
+
|
|
3934
|
+
this.currentCall = undefined;
|
|
3935
|
+
this.eventEmitter.emit('onCallEnded', callSession);
|
|
3936
|
+
}
|
|
3937
|
+
|
|
3938
|
+
async hangup(callSession ) {
|
|
3939
|
+
if (!callSession) {
|
|
3940
|
+
return Promise.resolve(false);
|
|
3941
|
+
}
|
|
3942
|
+
logger$a.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3943
|
+
|
|
3944
|
+
try {
|
|
3945
|
+
await CallApi.cancelCall(callSession);
|
|
3946
|
+
if (this.currentCall && callSession.callId === this.currentCall.id) {
|
|
3947
|
+
this.endCurrentCall(callSession);
|
|
3948
|
+
}
|
|
3949
|
+
|
|
3950
|
+
this.eventEmitter.emit('onCallEnded', callSession);
|
|
3951
|
+
return true;
|
|
3952
|
+
} catch (e) {
|
|
3953
|
+
logger$a.error('hangup CTI call, error', e);
|
|
3954
|
+
|
|
3955
|
+
this.eventEmitter.emit('onCallFailed', callSession);
|
|
3956
|
+
return false;
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
|
|
3960
|
+
ignore() {}
|
|
3961
|
+
|
|
3962
|
+
async reject(callSession ) {
|
|
3963
|
+
if (!callSession) {
|
|
3964
|
+
return;
|
|
3965
|
+
}
|
|
3966
|
+
logger$a.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
3967
|
+
|
|
3968
|
+
await CallApi.cancelCall(callSession);
|
|
3969
|
+
this.eventEmitter.emit('onCallEnded', callSession);
|
|
3970
|
+
}
|
|
3971
|
+
|
|
3972
|
+
async transfer(callSession , number ) {
|
|
3973
|
+
if (!callSession) {
|
|
3974
|
+
return;
|
|
3975
|
+
}
|
|
3976
|
+
logger$a.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
3977
|
+
|
|
3978
|
+
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
3979
|
+
}
|
|
3980
|
+
|
|
3981
|
+
indirectTransfer() {}
|
|
3982
|
+
|
|
3983
|
+
async initiateCTIIndirectTransfer(callSession , number ) {
|
|
3984
|
+
if (!callSession) {
|
|
3985
|
+
return;
|
|
3986
|
+
}
|
|
3987
|
+
logger$a.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
3988
|
+
|
|
3989
|
+
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
3990
|
+
}
|
|
3991
|
+
|
|
3992
|
+
async cancelCTIIndirectTransfer(transferId ) {
|
|
3993
|
+
logger$a.info('cancel CTI transfer', { transferId });
|
|
3994
|
+
|
|
3995
|
+
return CallApi.cancelCallTransfer(transferId);
|
|
3996
|
+
}
|
|
3997
|
+
|
|
3998
|
+
async confirmCTIIndirectTransfer(transferId ) {
|
|
3999
|
+
logger$a.info('confirm CTI transfer', { transferId });
|
|
4000
|
+
|
|
4001
|
+
return CallApi.confirmCallTransfer(transferId);
|
|
4002
|
+
}
|
|
4003
|
+
|
|
4004
|
+
sendKey(callSession , digits ) {
|
|
4005
|
+
if (!callSession) {
|
|
4006
|
+
return;
|
|
4007
|
+
}
|
|
4008
|
+
logger$a.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4009
|
+
|
|
4010
|
+
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4011
|
+
}
|
|
4012
|
+
|
|
4013
|
+
onConnectionMade() {
|
|
4014
|
+
logger$a.info('on CTI connection made');
|
|
4015
|
+
|
|
4016
|
+
this.eventEmitter.emit('onCallAccepted');
|
|
4017
|
+
}
|
|
4018
|
+
|
|
4019
|
+
async close() {
|
|
4020
|
+
logger$a.info('CTI close');
|
|
4021
|
+
|
|
4022
|
+
return Promise.resolve();
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
async hold(callSession ) {
|
|
4026
|
+
if (!callSession) {
|
|
4027
|
+
return;
|
|
4028
|
+
}
|
|
4029
|
+
logger$a.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4030
|
+
|
|
4031
|
+
return CallApi.hold(callSession.callId);
|
|
4032
|
+
}
|
|
4033
|
+
|
|
4034
|
+
async resume(callSession ) {
|
|
4035
|
+
if (!callSession) {
|
|
4036
|
+
return;
|
|
4037
|
+
}
|
|
4038
|
+
logger$a.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4039
|
+
|
|
4040
|
+
return CallApi.resume(callSession.callId);
|
|
4041
|
+
}
|
|
4042
|
+
|
|
4043
|
+
async mute(callSession ) {
|
|
4044
|
+
if (!callSession) {
|
|
4045
|
+
return;
|
|
4046
|
+
}
|
|
4047
|
+
logger$a.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4048
|
+
|
|
4049
|
+
return CallApi.mute(callSession.callId);
|
|
4050
|
+
}
|
|
4051
|
+
|
|
4052
|
+
async unmute(callSession ) {
|
|
4053
|
+
if (!callSession) {
|
|
4054
|
+
return;
|
|
4055
|
+
}
|
|
4056
|
+
logger$a.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4057
|
+
|
|
4058
|
+
return CallApi.unmute(callSession.callId);
|
|
4059
|
+
}
|
|
4060
|
+
|
|
4061
|
+
putOnSpeaker() {}
|
|
4062
|
+
|
|
4063
|
+
putOffSpeaker() {}
|
|
4064
|
+
|
|
4065
|
+
turnCameraOff() {}
|
|
4066
|
+
|
|
4067
|
+
turnCameraOn() {}
|
|
4068
|
+
|
|
4069
|
+
changeAudioInputDevice() {}
|
|
4070
|
+
|
|
4071
|
+
changeVideoInputDevice() {}
|
|
4072
|
+
|
|
4073
|
+
changeAudioDevice() {}
|
|
4074
|
+
|
|
4075
|
+
changeRingDevice() {}
|
|
4076
|
+
|
|
4077
|
+
changeAudioVolume() {}
|
|
4078
|
+
|
|
4079
|
+
changeRingVolume() {}
|
|
4080
|
+
|
|
4081
|
+
hasVideo() {
|
|
4082
|
+
return false;
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4085
|
+
getLocalStreamForCall() {
|
|
4086
|
+
return null;
|
|
4087
|
+
}
|
|
4088
|
+
|
|
4089
|
+
getRemoteStreamForCall() {
|
|
4090
|
+
return null;
|
|
4091
|
+
}
|
|
4092
|
+
|
|
4093
|
+
getLocalVideoStream() {
|
|
4094
|
+
return null;
|
|
4095
|
+
}
|
|
4096
|
+
|
|
4097
|
+
setActiveSipSession() {}
|
|
4098
|
+
|
|
4099
|
+
isRegistered() {
|
|
4100
|
+
return true;
|
|
4101
|
+
}
|
|
4102
|
+
|
|
4103
|
+
hasIncomingCallSession() {
|
|
4104
|
+
return true;
|
|
4105
|
+
}
|
|
4106
|
+
|
|
4107
|
+
hasActiveRemoteVideoStream() {
|
|
4108
|
+
return false;
|
|
4109
|
+
}
|
|
4110
|
+
|
|
4111
|
+
getCurrentCallSession() {
|
|
4112
|
+
return this.currentCall ? CallSession.parseCall(this.currentCall) : null;
|
|
4113
|
+
}
|
|
4114
|
+
|
|
4115
|
+
enableRinging() {}
|
|
4116
|
+
|
|
4117
|
+
sendMessage() {}
|
|
4118
|
+
|
|
4119
|
+
disableRinging() {}
|
|
4120
|
+
|
|
4121
|
+
getLocalStream() {
|
|
4122
|
+
return null;
|
|
4123
|
+
}
|
|
4124
|
+
|
|
4125
|
+
getRemoteStream() {
|
|
4126
|
+
return null;
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4129
|
+
getRemoteVideoStream() {
|
|
4130
|
+
return null;
|
|
4131
|
+
}
|
|
4132
|
+
|
|
4133
|
+
getRemoteAudioStream() {
|
|
4134
|
+
return null;
|
|
4135
|
+
}
|
|
4136
|
+
|
|
4137
|
+
hasLocalVideo() {
|
|
4138
|
+
return false;
|
|
4139
|
+
}
|
|
4140
|
+
|
|
4141
|
+
useLocalVideoElement() {}
|
|
4142
|
+
}
|
|
3668
4143
|
|
|
3669
4144
|
/* */
|
|
3670
4145
|
|
|
@@ -4699,6 +5174,10 @@ class ApiClient {
|
|
|
4699
5174
|
this.fetchOptions = fetchOptions;
|
|
4700
5175
|
this.client.setFetchOptions(fetchOptions);
|
|
4701
5176
|
}
|
|
5177
|
+
|
|
5178
|
+
disableErrorLogging() {
|
|
5179
|
+
this.client.disableErrorLogging();
|
|
5180
|
+
}
|
|
4702
5181
|
}
|
|
4703
5182
|
|
|
4704
5183
|
/* eslint-disable dot-notation */
|
|
@@ -5240,23 +5719,6 @@ const areCandidateValid = (candidates ) =>
|
|
|
5240
5719
|
getSrflxOrRelay(candidates)
|
|
5241
5720
|
.length > 0;
|
|
5242
5721
|
|
|
5243
|
-
const toggleVideoDirection = (sdp , direction ) => {
|
|
5244
|
-
const parsedSdp = sdpParser.parse(sdp);
|
|
5245
|
-
parsedSdp.media = parsedSdp.media.map(media => ({
|
|
5246
|
-
...media,
|
|
5247
|
-
...(media.type === 'video' ? { direction } : {}),
|
|
5248
|
-
}));
|
|
5249
|
-
|
|
5250
|
-
return sdpParser.write(parsedSdp);
|
|
5251
|
-
};
|
|
5252
|
-
|
|
5253
|
-
const deactivateVideoModifier = (rawDescription ) => {
|
|
5254
|
-
const description = rawDescription;
|
|
5255
|
-
description.sdp = toggleVideoDirection(description.sdp, 'inactive');
|
|
5256
|
-
|
|
5257
|
-
return Promise.resolve(description);
|
|
5258
|
-
};
|
|
5259
|
-
|
|
5260
5722
|
const hasAnActiveVideo = (sdp ) => {
|
|
5261
5723
|
if (!sdp) {
|
|
5262
5724
|
return false;
|
|
@@ -5368,6 +5830,7 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5368
5830
|
const iceRestart = options.offerOptions ? options.offerOptions.iceRestart : false;
|
|
5369
5831
|
|
|
5370
5832
|
const isConference = options ? !!options.conference : false;
|
|
5833
|
+
const audioOnly = options ? !!options.audioOnly : false;
|
|
5371
5834
|
|
|
5372
5835
|
// We should wait for ice when iceRestart (reinvite) or for the first invite
|
|
5373
5836
|
// We shouldn't wait for ice when holding or resuming the call
|
|
@@ -5394,16 +5857,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5394
5857
|
};
|
|
5395
5858
|
|
|
5396
5859
|
return this.getLocalMediaStream(options)
|
|
5397
|
-
.then(() => this.updateDirection(options, isConference))
|
|
5860
|
+
.then(() => this.updateDirection(options, isConference, audioOnly))
|
|
5398
5861
|
.then(() => this.createDataChannel(options))
|
|
5399
5862
|
.then(() => {
|
|
5400
|
-
if (isConference && (options.constraints && !options.constraints.video) && !('hold' in options)) {
|
|
5863
|
+
if (isConference && (options.constraints && !options.constraints.video) && !('hold' in options) && !audioOnly) {
|
|
5401
5864
|
// Add a video an empty bundle to be able to replaceTrack when joining a conference without video
|
|
5402
5865
|
this.peerConnection.addTransceiver('video', { streams: [this._localMediaStream], direction: 'sendrecv' });
|
|
5403
5866
|
}
|
|
5404
5867
|
})
|
|
5405
5868
|
.then(() => this.createLocalOfferOrAnswer(options))
|
|
5406
|
-
.then(
|
|
5869
|
+
.then(sessionDescription => this.setLocalSessionDescription(sessionDescription))
|
|
5407
5870
|
.then(() => this.waitForIceGatheringComplete(iceRestart, iceTimeout))
|
|
5408
5871
|
.then(() => this.getLocalSessionDescription())
|
|
5409
5872
|
.then(description => {
|
|
@@ -5526,7 +5989,8 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5526
5989
|
}
|
|
5527
5990
|
|
|
5528
5991
|
// Overridden to send `inactive` in conference
|
|
5529
|
-
updateDirection(options , isConference = false
|
|
5992
|
+
updateDirection(options , isConference = false,
|
|
5993
|
+
audioOnly = false) {
|
|
5530
5994
|
if (this._peerConnection === undefined) {
|
|
5531
5995
|
return Promise.reject(new Error('Peer connection closed.'));
|
|
5532
5996
|
}
|
|
@@ -5541,14 +6005,17 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5541
6005
|
// if we are stable, assume we are creating a local offer
|
|
5542
6006
|
this.logger.debug('SessionDescriptionHandler.updateDirection - setting offer direction');
|
|
5543
6007
|
// determine the direction to offer given the current direction and hold state
|
|
5544
|
-
const directionToOffer = (currentDirection ) => {
|
|
6008
|
+
const directionToOffer = (currentDirection , transceiver /* RTCRtpTransceiver */) => {
|
|
5545
6009
|
if (isConference) {
|
|
6010
|
+
if (audioOnly && transceiver.receiver.track && transceiver.receiver.track.kind === 'video') {
|
|
6011
|
+
return 'sendonly';
|
|
6012
|
+
}
|
|
5546
6013
|
return options && options.hold ? 'sendonly' : 'sendrecv';
|
|
5547
6014
|
}
|
|
5548
6015
|
|
|
5549
6016
|
switch (currentDirection) {
|
|
5550
6017
|
case 'inactive':
|
|
5551
|
-
return options && options.hold ? 'inactive' : 'recvonly';
|
|
6018
|
+
return options && options.hold ? 'inactive' : (isConference && !audioOnly ? 'sendrecv' : 'recvonly');
|
|
5552
6019
|
case 'recvonly':
|
|
5553
6020
|
return options && options.hold ? 'inactive' : 'recvonly';
|
|
5554
6021
|
case 'sendonly':
|
|
@@ -5564,7 +6031,7 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5564
6031
|
// set the transceiver direction to the offer direction
|
|
5565
6032
|
this._peerConnection.getTransceivers().forEach((transceiver) => {
|
|
5566
6033
|
if (transceiver.direction /* guarding, but should always be true */) {
|
|
5567
|
-
const offerDirection = directionToOffer(transceiver.direction);
|
|
6034
|
+
const offerDirection = directionToOffer(transceiver.direction, transceiver);
|
|
5568
6035
|
if (transceiver.direction !== offerDirection) {
|
|
5569
6036
|
// eslint-disable-next-line no-param-reassign
|
|
5570
6037
|
transceiver.direction = offerDirection;
|
|
@@ -5623,6 +6090,13 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5623
6090
|
// set the transceiver direction to the answer direction
|
|
5624
6091
|
this._peerConnection.getTransceivers().forEach((transceiver) => {
|
|
5625
6092
|
if (transceiver.direction /* guarding, but should always be true */) {
|
|
6093
|
+
const { receiver } = transceiver;
|
|
6094
|
+
if (isConference && audioOnly && receiver.track && receiver.track.kind === 'video') {
|
|
6095
|
+
// eslint-disable-next-line no-param-reassign
|
|
6096
|
+
transceiver.direction = 'inactive';
|
|
6097
|
+
return;
|
|
6098
|
+
}
|
|
6099
|
+
|
|
5626
6100
|
if (transceiver.direction !== 'stopped' && transceiver.direction !== answerDirection) {
|
|
5627
6101
|
// eslint-disable-next-line no-param-reassign
|
|
5628
6102
|
transceiver.direction = answerDirection;
|
|
@@ -5661,8 +6135,8 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5661
6135
|
}
|
|
5662
6136
|
const sender = pc.getSenders().find((otherSender) => otherSender.track && otherSender.track.kind === kind);
|
|
5663
6137
|
|
|
5664
|
-
// Do not reuse sender tracks in SFU
|
|
5665
|
-
if (sender && !sfu) {
|
|
6138
|
+
// Do not reuse sender video tracks in SFU
|
|
6139
|
+
if (sender && (!sfu || newTrack.kind === 'audio')) {
|
|
5666
6140
|
trackUpdates.push(
|
|
5667
6141
|
new Promise((resolve) => {
|
|
5668
6142
|
this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - replacing sender ${kind} track`);
|
|
@@ -6214,9 +6688,15 @@ class WebRTCClient extends Emitter {
|
|
|
6214
6688
|
|
|
6215
6689
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6216
6690
|
logger$7.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6217
|
-
const inviterOptions
|
|
6691
|
+
const inviterOptions = {
|
|
6692
|
+
sessionDescriptionHandlerOptionsReInvite: {
|
|
6693
|
+
conference,
|
|
6694
|
+
audioOnly,
|
|
6695
|
+
},
|
|
6696
|
+
};
|
|
6697
|
+
|
|
6218
6698
|
if (audioOnly) {
|
|
6219
|
-
inviterOptions.sessionDescriptionHandlerModifiersReInvite = [
|
|
6699
|
+
inviterOptions.sessionDescriptionHandlerModifiersReInvite = [stripVideo];
|
|
6220
6700
|
}
|
|
6221
6701
|
|
|
6222
6702
|
const session = new Inviter(this.userAgent, this._makeURI(number), inviterOptions);
|
|
@@ -6245,10 +6725,11 @@ class WebRTCClient extends Emitter {
|
|
|
6245
6725
|
sessionDescriptionHandlerOptions: this.getMediaConfiguration(enableVideo || false, conference),
|
|
6246
6726
|
};
|
|
6247
6727
|
|
|
6248
|
-
inviteOptions.
|
|
6728
|
+
inviteOptions.sessionDescriptionHandlerOptions.audioOnly = audioOnly;
|
|
6249
6729
|
|
|
6730
|
+
inviteOptions.sessionDescriptionHandlerModifiers = [replaceLocalIpModifier];
|
|
6250
6731
|
if (audioOnly) {
|
|
6251
|
-
inviteOptions.sessionDescriptionHandlerModifiers.push(
|
|
6732
|
+
inviteOptions.sessionDescriptionHandlerModifiers.push(stripVideo);
|
|
6252
6733
|
}
|
|
6253
6734
|
|
|
6254
6735
|
// Do not await invite here or we'll miss the Establishing state transition
|
|
@@ -6462,6 +6943,9 @@ class WebRTCClient extends Emitter {
|
|
|
6462
6943
|
if (!this._isWeb()) {
|
|
6463
6944
|
options.sessionDescriptionHandlerModifiers = [holdModifier];
|
|
6464
6945
|
}
|
|
6946
|
+
options.sessionDescriptionHandlerOptions = {
|
|
6947
|
+
constraints: options.constraints,
|
|
6948
|
+
};
|
|
6465
6949
|
|
|
6466
6950
|
// Send re-INVITE
|
|
6467
6951
|
return session.invite(options);
|
|
@@ -6501,6 +6985,9 @@ class WebRTCClient extends Emitter {
|
|
|
6501
6985
|
// (eg: holdModifier)
|
|
6502
6986
|
options.sessionDescriptionHandlerModifiers = [];
|
|
6503
6987
|
}
|
|
6988
|
+
options.sessionDescriptionHandlerOptions = {
|
|
6989
|
+
constraints: options.constraints,
|
|
6990
|
+
};
|
|
6504
6991
|
|
|
6505
6992
|
// Send re-INVITE
|
|
6506
6993
|
return session.invite(options);
|
|
@@ -6730,7 +7217,8 @@ class WebRTCClient extends Emitter {
|
|
|
6730
7217
|
? this.video.deviceId.exact : undefined;
|
|
6731
7218
|
}
|
|
6732
7219
|
|
|
6733
|
-
reinvite(sipSession , newConstraints = null, conference = false
|
|
7220
|
+
reinvite(sipSession , newConstraints = null, conference = false,
|
|
7221
|
+
audioOnly = false) {
|
|
6734
7222
|
if (!sipSession) {
|
|
6735
7223
|
return false;
|
|
6736
7224
|
}
|
|
@@ -6740,16 +7228,17 @@ class WebRTCClient extends Emitter {
|
|
|
6740
7228
|
}
|
|
6741
7229
|
|
|
6742
7230
|
const wasMuted = this.isAudioMuted(sipSession);
|
|
6743
|
-
// When upgrading to video, remove the `
|
|
7231
|
+
// When upgrading to video, remove the `stripVideo` modifiers
|
|
6744
7232
|
if (newConstraints && newConstraints.video) {
|
|
6745
7233
|
const modifiers = sipSession.sessionDescriptionHandlerModifiersReInvite;
|
|
6746
7234
|
sipSession.sessionDescriptionHandlerModifiersReInvite = modifiers.filter(modifier =>
|
|
6747
|
-
modifier !==
|
|
7235
|
+
modifier !== stripVideo);
|
|
6748
7236
|
}
|
|
6749
7237
|
|
|
6750
7238
|
sipSession.sessionDescriptionHandlerOptionsReInvite = {
|
|
6751
7239
|
...sipSession.sessionDescriptionHandlerOptionsReInvite,
|
|
6752
7240
|
conference,
|
|
7241
|
+
audioOnly,
|
|
6753
7242
|
};
|
|
6754
7243
|
|
|
6755
7244
|
const shouldDoVideo = newConstraints ? newConstraints.video : this.sessionWantsToDoVideo(sipSession);
|
|
@@ -6789,6 +7278,8 @@ class WebRTCClient extends Emitter {
|
|
|
6789
7278
|
},
|
|
6790
7279
|
sessionDescriptionHandlerOptions: {
|
|
6791
7280
|
constraints,
|
|
7281
|
+
conference,
|
|
7282
|
+
audioOnly,
|
|
6792
7283
|
offerOptions: {
|
|
6793
7284
|
iceRestart: false,
|
|
6794
7285
|
},
|
|
@@ -7248,6 +7739,8 @@ class WebRTCClient extends Emitter {
|
|
|
7248
7739
|
|
|
7249
7740
|
// Invitation and Inviter extends Session
|
|
7250
7741
|
_setupSession(session ) {
|
|
7742
|
+
const sipSessionId = this.getSipSessionId(session);
|
|
7743
|
+
|
|
7251
7744
|
// When receiving an Invitation, the delegate is not defined.
|
|
7252
7745
|
if (!session.delegate) {
|
|
7253
7746
|
session.delegate = {};
|
|
@@ -7271,8 +7764,18 @@ class WebRTCClient extends Emitter {
|
|
|
7271
7764
|
};
|
|
7272
7765
|
};
|
|
7273
7766
|
|
|
7767
|
+
const oldInviteRequest = session.onInviteRequest.bind(session);
|
|
7768
|
+
let hadRemoteVideo = false;
|
|
7769
|
+
|
|
7770
|
+
// Monkey patch `onInviteRequest` to be able to know if there was a remote video stream before `onInvite` is called
|
|
7771
|
+
// Becase when `onInvite` is called we already got the video track
|
|
7772
|
+
session.onInviteRequest = (request) => {
|
|
7773
|
+
hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
|
|
7774
|
+
|
|
7775
|
+
oldInviteRequest(request);
|
|
7776
|
+
};
|
|
7777
|
+
|
|
7274
7778
|
session.delegate.onInvite = (request ) => {
|
|
7275
|
-
const sipSessionId = this.getSipSessionId(session);
|
|
7276
7779
|
let updatedCalleeName = null;
|
|
7277
7780
|
let updatedNumber = null;
|
|
7278
7781
|
if (session.assertedIdentity) {
|
|
@@ -7282,7 +7785,6 @@ class WebRTCClient extends Emitter {
|
|
|
7282
7785
|
logger$7.info('re-invite received', { updatedCalleeName, updatedNumber });
|
|
7283
7786
|
|
|
7284
7787
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
7285
|
-
const hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
|
|
7286
7788
|
|
|
7287
7789
|
// Update SDP
|
|
7288
7790
|
// Remote video is handled by the `track` event. Here we're dealing with video stream removal.
|
|
@@ -7332,7 +7834,7 @@ class WebRTCClient extends Emitter {
|
|
|
7332
7834
|
}
|
|
7333
7835
|
|
|
7334
7836
|
_isAudioOnly(session ) {
|
|
7335
|
-
return session.sessionDescriptionHandlerModifiersReInvite.find(modifier => modifier ===
|
|
7837
|
+
return session.sessionDescriptionHandlerModifiersReInvite.find(modifier => modifier === stripVideo);
|
|
7336
7838
|
}
|
|
7337
7839
|
|
|
7338
7840
|
_setupMedias(session , newStream ) {
|
|
@@ -7705,9 +8207,14 @@ class WebRTCPhone extends Emitter {
|
|
|
7705
8207
|
return true;
|
|
7706
8208
|
}
|
|
7707
8209
|
|
|
7708
|
-
async sendReinvite(callSession , constraints = null, conference = false
|
|
8210
|
+
async sendReinvite(callSession , constraints = null, conference = false,
|
|
8211
|
+
audioOnly = false) {
|
|
7709
8212
|
const sipSession = this.findSipSession(callSession);
|
|
7710
|
-
logger$6.info('WebRTC phone - send reinvite', {
|
|
8213
|
+
logger$6.info('WebRTC phone - send reinvite', {
|
|
8214
|
+
sessionId: sipSession ? sipSession.id : null,
|
|
8215
|
+
constraints,
|
|
8216
|
+
audioOnly,
|
|
8217
|
+
});
|
|
7711
8218
|
|
|
7712
8219
|
if (!sipSession) {
|
|
7713
8220
|
return null;
|
|
@@ -7733,7 +8240,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7733
8240
|
// Force reinvite in SDH
|
|
7734
8241
|
sipSession.sessionDescriptionHandler.localMediaStreamConstraints = null;
|
|
7735
8242
|
|
|
7736
|
-
return this.client.reinvite(sipSession, constraints, conference);
|
|
8243
|
+
return this.client.reinvite(sipSession, constraints, conference, audioOnly);
|
|
7737
8244
|
}
|
|
7738
8245
|
|
|
7739
8246
|
getUserAgent() {
|
|
@@ -7809,9 +8316,9 @@ class WebRTCPhone extends Emitter {
|
|
|
7809
8316
|
}
|
|
7810
8317
|
|
|
7811
8318
|
// Release local video stream when downgrading to audio
|
|
7812
|
-
const
|
|
8319
|
+
const localStream = sipSession.sessionDescriptionHandler.localMediaStream;
|
|
7813
8320
|
const pc = sipSession.sessionDescriptionHandler.peerConnection;
|
|
7814
|
-
const videoTracks =
|
|
8321
|
+
const videoTracks = localStream.getVideoTracks();
|
|
7815
8322
|
|
|
7816
8323
|
// Remove video senders
|
|
7817
8324
|
pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
|
|
@@ -7826,7 +8333,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7826
8333
|
videoTracks.forEach(videoTrack => {
|
|
7827
8334
|
videoTrack.enabled = false;
|
|
7828
8335
|
videoTrack.stop();
|
|
7829
|
-
|
|
8336
|
+
localStream.removeTrack(videoTrack);
|
|
7830
8337
|
});
|
|
7831
8338
|
|
|
7832
8339
|
this._sendReinviteMessage(callSession, false);
|
|
@@ -7843,12 +8350,14 @@ class WebRTCPhone extends Emitter {
|
|
|
7843
8350
|
|
|
7844
8351
|
const pc = sipSession.sessionDescriptionHandler.peerConnection;
|
|
7845
8352
|
const shouldScreenShare = constraints && constraints.screen;
|
|
8353
|
+
const options = sipSession.sessionDescriptionHandlerOptionsReInvite;
|
|
8354
|
+
const wasAudioOnly = options && options.audioOnly;
|
|
7846
8355
|
|
|
7847
8356
|
// Check if a video sender already exists
|
|
7848
8357
|
let videoSender;
|
|
7849
8358
|
if (isConference) {
|
|
7850
8359
|
const trans = pc.getTransceivers().find(transceiver => transceiver.mid === '1');
|
|
7851
|
-
videoSender = trans.sender;
|
|
8360
|
+
videoSender = trans ? trans.sender : null;
|
|
7852
8361
|
} else {
|
|
7853
8362
|
videoSender = pc.getSenders().find(sender => sender.track === null);
|
|
7854
8363
|
}
|
|
@@ -7885,6 +8394,11 @@ class WebRTCPhone extends Emitter {
|
|
|
7885
8394
|
this._onScreenSharing(newStream, sipSession, callSession, false);
|
|
7886
8395
|
}
|
|
7887
8396
|
|
|
8397
|
+
// We have to reinvite to change the direction on the bundle when upgrading from an audioOnly conference
|
|
8398
|
+
if (isConference && wasAudioOnly) {
|
|
8399
|
+
return true;
|
|
8400
|
+
}
|
|
8401
|
+
|
|
7888
8402
|
// No reinvite needed here
|
|
7889
8403
|
return false;
|
|
7890
8404
|
}
|
|
@@ -7969,7 +8483,7 @@ class WebRTCPhone extends Emitter {
|
|
|
7969
8483
|
event.track.enabled = false;
|
|
7970
8484
|
}
|
|
7971
8485
|
|
|
7972
|
-
return this.eventEmitter.emit(ON_VIDEO_STREAM, stream, event.track.id, event);
|
|
8486
|
+
return this.eventEmitter.emit(ON_VIDEO_STREAM, stream, event.track.id, event, sipSession);
|
|
7973
8487
|
};
|
|
7974
8488
|
|
|
7975
8489
|
peerConnection.onremovestream = event => {
|
|
@@ -8025,14 +8539,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8025
8539
|
const targetCallSession = callSession || this.currentCallSession;
|
|
8026
8540
|
const conference = this.isConference(targetCallSession);
|
|
8027
8541
|
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
// We have to downgrade to audio.
|
|
8034
|
-
await this.sendReinvite(targetCallSession, { audio: false, video: false }, conference);
|
|
8035
|
-
}
|
|
8542
|
+
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
8543
|
+
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
8544
|
+
// We have to downgrade to audio.
|
|
8545
|
+
const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
|
|
8546
|
+
await this.sendReinvite(targetCallSession, { audio: false, video: screenshareStopped }, conference);
|
|
8036
8547
|
}
|
|
8037
8548
|
} catch (e) {
|
|
8038
8549
|
console.warn(e);
|
|
@@ -8369,6 +8880,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8369
8880
|
}
|
|
8370
8881
|
}
|
|
8371
8882
|
|
|
8883
|
+
// @Deprecated
|
|
8372
8884
|
unhold(callSession , withEvent = true, isConference = false) {
|
|
8373
8885
|
logger$6.info('WebRTC unhold', { id: callSession ? callSession.getId() : null });
|
|
8374
8886
|
|
|
@@ -9366,6 +9878,7 @@ class Phone extends Emitter {
|
|
|
9366
9878
|
return this.phone && this.phone.hasLocalVideo(callSession);
|
|
9367
9879
|
}
|
|
9368
9880
|
|
|
9881
|
+
// @Deprecated
|
|
9369
9882
|
getLocalMediaStream(callSession ) {
|
|
9370
9883
|
logger$5.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
9371
9884
|
|
|
@@ -9384,17 +9897,20 @@ class Phone extends Emitter {
|
|
|
9384
9897
|
return this.phone ? this.phone.getRemoteVideoStream(callSession) : null;
|
|
9385
9898
|
}
|
|
9386
9899
|
|
|
9900
|
+
// @Deprecated
|
|
9387
9901
|
getRemoteStreamForCall(callSession ) {
|
|
9388
9902
|
logger$5.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
9389
9903
|
return this.getRemoteStream(callSession);
|
|
9390
9904
|
}
|
|
9391
9905
|
|
|
9392
9906
|
// Returns remote streams directly from the peerConnection
|
|
9907
|
+
// @Deprecated
|
|
9393
9908
|
getRemoteStreamsForCall(callSession ) {
|
|
9394
|
-
logger$5.warn('Phone.
|
|
9909
|
+
logger$5.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
9395
9910
|
return this.getLocalStream(callSession);
|
|
9396
9911
|
}
|
|
9397
9912
|
|
|
9913
|
+
// @Deprecated
|
|
9398
9914
|
getRemoteVideoStreamForCall(callSession ) {
|
|
9399
9915
|
logger$5.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
9400
9916
|
|
|
@@ -10104,10 +10620,7 @@ class Stream {
|
|
|
10104
10620
|
element.onloadedmetadata = () => {
|
|
10105
10621
|
const tracks = this.htmlStream ? this.htmlStream.getVideoTracks() : [];
|
|
10106
10622
|
tracks.forEach(track => {
|
|
10107
|
-
|
|
10108
|
-
if (!track.loaded) {
|
|
10109
|
-
track.enabled = true;
|
|
10110
|
-
}
|
|
10623
|
+
track.enabled = true;
|
|
10111
10624
|
// $FlowFixMe
|
|
10112
10625
|
track.loaded = true;
|
|
10113
10626
|
});
|
|
@@ -10548,6 +11061,7 @@ var api = {
|
|
|
10548
11061
|
check: async (server, session) => {
|
|
10549
11062
|
const client = new ApiClient({ server });
|
|
10550
11063
|
client.setToken(session.token);
|
|
11064
|
+
client.disableErrorLogging();
|
|
10551
11065
|
|
|
10552
11066
|
const handleApiError = (apiName, error) => {
|
|
10553
11067
|
const statusText = error instanceof ServerError ? 'server error' : 'api error';
|
|
@@ -10622,6 +11136,8 @@ var aor = {
|
|
|
10622
11136
|
check: async (server, session) => {
|
|
10623
11137
|
const apiClient = new ApiClient({ server });
|
|
10624
11138
|
apiClient.setToken(session.token);
|
|
11139
|
+
apiClient.disableErrorLogging();
|
|
11140
|
+
|
|
10625
11141
|
const line = session.primaryWebRtcLine();
|
|
10626
11142
|
if (!line) {
|
|
10627
11143
|
return 'No WebRTC line for this user';
|
|
@@ -11044,6 +11560,8 @@ const Wazo = {
|
|
|
11044
11560
|
ServerError,
|
|
11045
11561
|
Call,
|
|
11046
11562
|
CallLog,
|
|
11563
|
+
CTIPhone,
|
|
11564
|
+
Recording,
|
|
11047
11565
|
ChatMessage,
|
|
11048
11566
|
ChatRoom,
|
|
11049
11567
|
Contact,
|
|
@@ -11058,6 +11576,7 @@ const Wazo = {
|
|
|
11058
11576
|
CallSession,
|
|
11059
11577
|
IndirectTransfer,
|
|
11060
11578
|
SwitchboardCall,
|
|
11579
|
+
WebRTCPhone,
|
|
11061
11580
|
},
|
|
11062
11581
|
|
|
11063
11582
|
// Api
|
|
@@ -11492,13 +12011,15 @@ class Room extends Emitter {
|
|
|
11492
12011
|
}
|
|
11493
12012
|
});
|
|
11494
12013
|
|
|
11495
|
-
this.on(this.ON_VIDEO_STREAM, (stream, streamId) => {
|
|
12014
|
+
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
11496
12015
|
logger$1.info('on room video stream', { streamId });
|
|
11497
12016
|
|
|
12017
|
+
this._mapMsid(sipSession.body.body);
|
|
12018
|
+
|
|
11498
12019
|
// ON_VIDEO_STREAM is called before PARTICIPANT_JOINED, so we have to keep stream in `_unassociatedVideoStreams`.
|
|
11499
12020
|
this._unassociatedVideoStreams[streamId] = stream;
|
|
11500
12021
|
|
|
11501
|
-
const callId = this.
|
|
12022
|
+
const callId = this._getCallIdFromTrackId(streamId);
|
|
11502
12023
|
const participant = callId ? this._getParticipantFromCallId(callId) : null;
|
|
11503
12024
|
if (participant) {
|
|
11504
12025
|
this.__associateStreams(participant);
|
|
@@ -11542,11 +12063,12 @@ class Room extends Emitter {
|
|
|
11542
12063
|
const sdp = sdpParser.parse(rawSdp);
|
|
11543
12064
|
const labelMsidArray = sdp.media.filter(media => !!media.label).map(({ label, msid }) => ({
|
|
11544
12065
|
label: String(label),
|
|
11545
|
-
|
|
12066
|
+
streamId: msid.split(' ')[0],
|
|
12067
|
+
trackId: msid.split(' ')[1],
|
|
11546
12068
|
}));
|
|
11547
12069
|
|
|
11548
|
-
labelMsidArray.forEach(({ label,
|
|
11549
|
-
this._callIdStreamIdMap[String(label)] =
|
|
12070
|
+
labelMsidArray.forEach(({ label, streamId, trackId }) => {
|
|
12071
|
+
this._callIdStreamIdMap[String(label)] = { streamId, trackId };
|
|
11550
12072
|
|
|
11551
12073
|
const callId = String(label);
|
|
11552
12074
|
const participant = this._unassociatedParticipants[callId] || this._getParticipantFromCallId(callId);
|
|
@@ -11776,9 +12298,9 @@ class Room extends Emitter {
|
|
|
11776
12298
|
_onParticipantTrackUpdate(oldParticipant , update ) {
|
|
11777
12299
|
const newParticipant = oldParticipant;
|
|
11778
12300
|
|
|
11779
|
-
const
|
|
12301
|
+
const { trackId } = this._callIdStreamIdMap[newParticipant.callId] || {};
|
|
11780
12302
|
const pc = Wazo.Phone.phone.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
11781
|
-
const stream = pc.getRemoteStreams().find(
|
|
12303
|
+
const stream = pc.getRemoteStreams().find(someStream => someStream.getTracks().some(track => track.id === trackId));
|
|
11782
12304
|
|
|
11783
12305
|
if (update === 'downgrade') {
|
|
11784
12306
|
newParticipant.streams = [];
|
|
@@ -11798,21 +12320,21 @@ class Room extends Emitter {
|
|
|
11798
12320
|
|
|
11799
12321
|
// Associate audio/video streams to the participant and triggers events on it
|
|
11800
12322
|
__associateStreams(participant ) {
|
|
11801
|
-
const
|
|
11802
|
-
if (!
|
|
12323
|
+
const { trackId } = this._callIdStreamIdMap[participant.callId] || {};
|
|
12324
|
+
if (!trackId) {
|
|
11803
12325
|
this._unassociatedParticipants[participant.callId] = participant;
|
|
11804
12326
|
|
|
11805
12327
|
return;
|
|
11806
12328
|
}
|
|
11807
|
-
if (!
|
|
12329
|
+
if (!trackId || !participant || !this.localParticipant || participant.callId === this.localParticipant.callId) {
|
|
11808
12330
|
return;
|
|
11809
12331
|
}
|
|
11810
12332
|
|
|
11811
|
-
if (this._unassociatedVideoStreams[
|
|
12333
|
+
if (this._unassociatedVideoStreams[trackId]) {
|
|
11812
12334
|
// Try to associate stream
|
|
11813
|
-
this._associateStreamTo(this._unassociatedVideoStreams[
|
|
12335
|
+
this._associateStreamTo(this._unassociatedVideoStreams[trackId], participant);
|
|
11814
12336
|
|
|
11815
|
-
delete this._unassociatedVideoStreams[
|
|
12337
|
+
delete this._unassociatedVideoStreams[trackId];
|
|
11816
12338
|
delete this._unassociatedParticipants[participant.callId];
|
|
11817
12339
|
}
|
|
11818
12340
|
}
|
|
@@ -11825,8 +12347,8 @@ class Room extends Emitter {
|
|
|
11825
12347
|
participant.onStreamSubscribed(stream);
|
|
11826
12348
|
}
|
|
11827
12349
|
|
|
11828
|
-
|
|
11829
|
-
return Object.keys(this._callIdStreamIdMap).find(key => this._callIdStreamIdMap[key] ===
|
|
12350
|
+
_getCallIdFromTrackId(trackId ) {
|
|
12351
|
+
return Object.keys(this._callIdStreamIdMap).find(key => this._callIdStreamIdMap[key].trackId === trackId);
|
|
11830
12352
|
}
|
|
11831
12353
|
|
|
11832
12354
|
_getParticipantFromCallId(callId ) {
|