@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
package/src/simple/room/Room.js
CHANGED
|
@@ -415,13 +415,15 @@ class Room extends Emitter {
|
|
|
415
415
|
}
|
|
416
416
|
});
|
|
417
417
|
|
|
418
|
-
this.on(this.ON_VIDEO_STREAM, (stream, streamId) => {
|
|
418
|
+
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
419
419
|
logger.info('on room video stream', { streamId });
|
|
420
420
|
|
|
421
|
+
this._mapMsid(sipSession.body.body);
|
|
422
|
+
|
|
421
423
|
// ON_VIDEO_STREAM is called before PARTICIPANT_JOINED, so we have to keep stream in `_unassociatedVideoStreams`.
|
|
422
424
|
this._unassociatedVideoStreams[streamId] = stream;
|
|
423
425
|
|
|
424
|
-
const callId = this.
|
|
426
|
+
const callId = this._getCallIdFromTrackId(streamId);
|
|
425
427
|
const participant = callId ? this._getParticipantFromCallId(callId) : null;
|
|
426
428
|
if (participant) {
|
|
427
429
|
this.__associateStreams(participant);
|
|
@@ -465,11 +467,12 @@ class Room extends Emitter {
|
|
|
465
467
|
const sdp = sdpParser.parse(rawSdp);
|
|
466
468
|
const labelMsidArray = sdp.media.filter(media => !!media.label).map(({ label, msid }) => ({
|
|
467
469
|
label: String(label),
|
|
468
|
-
|
|
470
|
+
streamId: msid.split(' ')[0],
|
|
471
|
+
trackId: msid.split(' ')[1],
|
|
469
472
|
}));
|
|
470
473
|
|
|
471
|
-
labelMsidArray.forEach(({ label,
|
|
472
|
-
this._callIdStreamIdMap[String(label)] =
|
|
474
|
+
labelMsidArray.forEach(({ label, streamId, trackId }) => {
|
|
475
|
+
this._callIdStreamIdMap[String(label)] = { streamId, trackId };
|
|
473
476
|
|
|
474
477
|
const callId = String(label);
|
|
475
478
|
const participant = this._unassociatedParticipants[callId] || this._getParticipantFromCallId(callId);
|
|
@@ -701,9 +704,9 @@ class Room extends Emitter {
|
|
|
701
704
|
_onParticipantTrackUpdate(oldParticipant: Participant, update: string): Participant {
|
|
702
705
|
const newParticipant = oldParticipant;
|
|
703
706
|
|
|
704
|
-
const
|
|
707
|
+
const { trackId } = this._callIdStreamIdMap[newParticipant.callId] || {};
|
|
705
708
|
const pc = Wazo.Phone.phone.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
706
|
-
const stream = pc.getRemoteStreams().find(
|
|
709
|
+
const stream = pc.getRemoteStreams().find(someStream => someStream.getTracks().some(track => track.id === trackId));
|
|
707
710
|
|
|
708
711
|
if (update === 'downgrade') {
|
|
709
712
|
newParticipant.streams = [];
|
|
@@ -723,21 +726,21 @@ class Room extends Emitter {
|
|
|
723
726
|
|
|
724
727
|
// Associate audio/video streams to the participant and triggers events on it
|
|
725
728
|
__associateStreams(participant: Participant) {
|
|
726
|
-
const
|
|
727
|
-
if (!
|
|
729
|
+
const { trackId } = this._callIdStreamIdMap[participant.callId] || {};
|
|
730
|
+
if (!trackId) {
|
|
728
731
|
this._unassociatedParticipants[participant.callId] = participant;
|
|
729
732
|
|
|
730
733
|
return;
|
|
731
734
|
}
|
|
732
|
-
if (!
|
|
735
|
+
if (!trackId || !participant || !this.localParticipant || participant.callId === this.localParticipant.callId) {
|
|
733
736
|
return;
|
|
734
737
|
}
|
|
735
738
|
|
|
736
|
-
if (this._unassociatedVideoStreams[
|
|
739
|
+
if (this._unassociatedVideoStreams[trackId]) {
|
|
737
740
|
// Try to associate stream
|
|
738
|
-
this._associateStreamTo(this._unassociatedVideoStreams[
|
|
741
|
+
this._associateStreamTo(this._unassociatedVideoStreams[trackId], participant);
|
|
739
742
|
|
|
740
|
-
delete this._unassociatedVideoStreams[
|
|
743
|
+
delete this._unassociatedVideoStreams[trackId];
|
|
741
744
|
delete this._unassociatedParticipants[participant.callId];
|
|
742
745
|
}
|
|
743
746
|
}
|
|
@@ -750,8 +753,8 @@ class Room extends Emitter {
|
|
|
750
753
|
participant.onStreamSubscribed(stream);
|
|
751
754
|
}
|
|
752
755
|
|
|
753
|
-
|
|
754
|
-
return Object.keys(this._callIdStreamIdMap).find(key => this._callIdStreamIdMap[key] ===
|
|
756
|
+
_getCallIdFromTrackId(trackId: string) {
|
|
757
|
+
return Object.keys(this._callIdStreamIdMap).find(key => this._callIdStreamIdMap[key].trackId === trackId);
|
|
755
758
|
}
|
|
756
759
|
|
|
757
760
|
_getParticipantFromCallId(callId: string) {
|
|
@@ -34,10 +34,7 @@ class Stream {
|
|
|
34
34
|
element.onloadedmetadata = () => {
|
|
35
35
|
const tracks = this.htmlStream ? this.htmlStream.getVideoTracks() : [];
|
|
36
36
|
tracks.forEach(track => {
|
|
37
|
-
|
|
38
|
-
if (!track.loaded) {
|
|
39
|
-
track.enabled = true;
|
|
40
|
-
}
|
|
37
|
+
track.enabled = true;
|
|
41
38
|
// $FlowFixMe
|
|
42
39
|
track.loaded = true;
|
|
43
40
|
});
|
|
@@ -50,11 +50,16 @@ describe('Retrieving headers', () => {
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
describe('Calling fetch', () => {
|
|
53
|
-
it('should call fetch without body but query string in get method', () => {
|
|
53
|
+
it('should call fetch without body but query string in get method', async () => {
|
|
54
54
|
jest.mock('node-fetch/lib/index', () => {});
|
|
55
|
-
global.fetch = jest.fn(() => Promise.resolve({
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
global.fetch = jest.fn(() => Promise.resolve({
|
|
56
|
+
json: () => Promise.resolve({}),
|
|
57
|
+
headers: {
|
|
58
|
+
get: () => '',
|
|
59
|
+
},
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
await new ApiRequester({ server }).call(path, method, body, {});
|
|
58
63
|
expect(global.fetch).toBeCalledWith(url, { method: 'get', body: null, headers: {}, agent: null });
|
|
59
64
|
});
|
|
60
65
|
});
|
|
@@ -56,6 +56,7 @@ export default class ApiRequester {
|
|
|
56
56
|
fetchOptions: Object;
|
|
57
57
|
refreshTokenCallback: Function;
|
|
58
58
|
refreshTokenPromise: ?Promise<any>;
|
|
59
|
+
shouldLogErrors: boolean;
|
|
59
60
|
|
|
60
61
|
head: Function;
|
|
61
62
|
get: Function;
|
|
@@ -95,6 +96,8 @@ export default class ApiRequester {
|
|
|
95
96
|
this.token = token;
|
|
96
97
|
}
|
|
97
98
|
|
|
99
|
+
this.shouldLogErrors = true;
|
|
100
|
+
|
|
98
101
|
methods.forEach(method => {
|
|
99
102
|
// $FlowFixMe
|
|
100
103
|
ApiRequester.prototype[method] = function sugar(...args) {
|
|
@@ -118,6 +121,14 @@ export default class ApiRequester {
|
|
|
118
121
|
this.fetchOptions = options;
|
|
119
122
|
}
|
|
120
123
|
|
|
124
|
+
disableErrorLogging() {
|
|
125
|
+
this.shouldLogErrors = false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
enableErrorLogging() {
|
|
129
|
+
this.shouldLogErrors = true;
|
|
130
|
+
}
|
|
131
|
+
|
|
121
132
|
async call(
|
|
122
133
|
path: string,
|
|
123
134
|
method: string = 'get',
|
|
@@ -178,7 +189,9 @@ export default class ApiRequester {
|
|
|
178
189
|
? exceptionClass.fromText(err, response.status)
|
|
179
190
|
: exceptionClass.fromResponse(err, response.status);
|
|
180
191
|
|
|
181
|
-
|
|
192
|
+
if (this.shouldLogErrors) {
|
|
193
|
+
logger.error('API error', error);
|
|
194
|
+
}
|
|
182
195
|
|
|
183
196
|
throw error;
|
|
184
197
|
});
|
|
@@ -186,7 +199,9 @@ export default class ApiRequester {
|
|
|
186
199
|
|
|
187
200
|
return newParse(response, isJson);
|
|
188
201
|
}).catch(error => {
|
|
189
|
-
|
|
202
|
+
if (this.shouldLogErrors) {
|
|
203
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
204
|
+
}
|
|
190
205
|
|
|
191
206
|
throw error;
|
|
192
207
|
});
|
package/src/web-rtc-client.js
CHANGED
|
@@ -15,12 +15,11 @@ import type SessionDescriptionHandlerConfiguration
|
|
|
15
15
|
import type SessionDescriptionHandler
|
|
16
16
|
from 'sip.js/lib/platform/web/session-description-handler/session-description-handler';
|
|
17
17
|
import { UserAgentState } from 'sip.js/lib/api/user-agent-state';
|
|
18
|
-
import { Message } from 'sip.js/lib/api/message';
|
|
19
18
|
import { Parser } from 'sip.js/lib/core/messages/parser';
|
|
20
19
|
import { C } from 'sip.js/lib/core/messages/methods/constants';
|
|
21
20
|
import { URI } from 'sip.js/lib/grammar/uri';
|
|
22
21
|
import { UserAgent } from 'sip.js/lib/api/user-agent';
|
|
23
|
-
import { holdModifier } from 'sip.js/lib/platform/web/modifiers/modifiers';
|
|
22
|
+
import { holdModifier, stripVideo } from 'sip.js/lib/platform/web/modifiers/modifiers';
|
|
24
23
|
import { Registerer } from 'sip.js/lib/api/registerer';
|
|
25
24
|
import { Inviter } from 'sip.js/lib/api/inviter';
|
|
26
25
|
import { Messager } from 'sip.js/lib/api/messager';
|
|
@@ -37,7 +36,7 @@ import Emitter from './utils/Emitter';
|
|
|
37
36
|
import ApiClient from './api-client';
|
|
38
37
|
import IssueReporter from './service/IssueReporter';
|
|
39
38
|
import Heartbeat from './utils/Heartbeat';
|
|
40
|
-
import {
|
|
39
|
+
import { hasAnActiveVideo } from './utils/sdp';
|
|
41
40
|
|
|
42
41
|
// We need to replace 0.0.0.0 to 127.0.0.1 in the sdp to avoid MOH during a createOffer.
|
|
43
42
|
export const replaceLocalIpModifier = (description: Object) => Promise.resolve({
|
|
@@ -432,9 +431,15 @@ export default class WebRTCClient extends Emitter {
|
|
|
432
431
|
|
|
433
432
|
call(number: string, enableVideo?: boolean, audioOnly: boolean = false, conference: boolean = false): Session {
|
|
434
433
|
logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
435
|
-
const inviterOptions = {
|
|
434
|
+
const inviterOptions: Object = {
|
|
435
|
+
sessionDescriptionHandlerOptionsReInvite: {
|
|
436
|
+
conference,
|
|
437
|
+
audioOnly,
|
|
438
|
+
},
|
|
439
|
+
};
|
|
440
|
+
|
|
436
441
|
if (audioOnly) {
|
|
437
|
-
inviterOptions.sessionDescriptionHandlerModifiersReInvite = [
|
|
442
|
+
inviterOptions.sessionDescriptionHandlerModifiersReInvite = [stripVideo];
|
|
438
443
|
}
|
|
439
444
|
|
|
440
445
|
const session = new Inviter(this.userAgent, this._makeURI(number), inviterOptions);
|
|
@@ -463,10 +468,11 @@ export default class WebRTCClient extends Emitter {
|
|
|
463
468
|
sessionDescriptionHandlerOptions: this.getMediaConfiguration(enableVideo || false, conference),
|
|
464
469
|
};
|
|
465
470
|
|
|
466
|
-
inviteOptions.
|
|
471
|
+
inviteOptions.sessionDescriptionHandlerOptions.audioOnly = audioOnly;
|
|
467
472
|
|
|
473
|
+
inviteOptions.sessionDescriptionHandlerModifiers = [replaceLocalIpModifier];
|
|
468
474
|
if (audioOnly) {
|
|
469
|
-
inviteOptions.sessionDescriptionHandlerModifiers.push(
|
|
475
|
+
inviteOptions.sessionDescriptionHandlerModifiers.push(stripVideo);
|
|
470
476
|
}
|
|
471
477
|
|
|
472
478
|
// Do not await invite here or we'll miss the Establishing state transition
|
|
@@ -680,6 +686,9 @@ export default class WebRTCClient extends Emitter {
|
|
|
680
686
|
if (!this._isWeb()) {
|
|
681
687
|
options.sessionDescriptionHandlerModifiers = [holdModifier];
|
|
682
688
|
}
|
|
689
|
+
options.sessionDescriptionHandlerOptions = {
|
|
690
|
+
constraints: options.constraints,
|
|
691
|
+
};
|
|
683
692
|
|
|
684
693
|
// Send re-INVITE
|
|
685
694
|
return session.invite(options);
|
|
@@ -719,6 +728,9 @@ export default class WebRTCClient extends Emitter {
|
|
|
719
728
|
// (eg: holdModifier)
|
|
720
729
|
options.sessionDescriptionHandlerModifiers = [];
|
|
721
730
|
}
|
|
731
|
+
options.sessionDescriptionHandlerOptions = {
|
|
732
|
+
constraints: options.constraints,
|
|
733
|
+
};
|
|
722
734
|
|
|
723
735
|
// Send re-INVITE
|
|
724
736
|
return session.invite(options);
|
|
@@ -948,7 +960,8 @@ export default class WebRTCClient extends Emitter {
|
|
|
948
960
|
? this.video.deviceId.exact : undefined;
|
|
949
961
|
}
|
|
950
962
|
|
|
951
|
-
reinvite(sipSession: Session, newConstraints: ?Object = null, conference: boolean = false
|
|
963
|
+
reinvite(sipSession: Session, newConstraints: ?Object = null, conference: boolean = false,
|
|
964
|
+
audioOnly: boolean = false) {
|
|
952
965
|
if (!sipSession) {
|
|
953
966
|
return false;
|
|
954
967
|
}
|
|
@@ -958,16 +971,17 @@ export default class WebRTCClient extends Emitter {
|
|
|
958
971
|
}
|
|
959
972
|
|
|
960
973
|
const wasMuted = this.isAudioMuted(sipSession);
|
|
961
|
-
// When upgrading to video, remove the `
|
|
974
|
+
// When upgrading to video, remove the `stripVideo` modifiers
|
|
962
975
|
if (newConstraints && newConstraints.video) {
|
|
963
976
|
const modifiers = sipSession.sessionDescriptionHandlerModifiersReInvite;
|
|
964
977
|
sipSession.sessionDescriptionHandlerModifiersReInvite = modifiers.filter(modifier =>
|
|
965
|
-
modifier !==
|
|
978
|
+
modifier !== stripVideo);
|
|
966
979
|
}
|
|
967
980
|
|
|
968
981
|
sipSession.sessionDescriptionHandlerOptionsReInvite = {
|
|
969
982
|
...sipSession.sessionDescriptionHandlerOptionsReInvite,
|
|
970
983
|
conference,
|
|
984
|
+
audioOnly,
|
|
971
985
|
};
|
|
972
986
|
|
|
973
987
|
const shouldDoVideo = newConstraints ? newConstraints.video : this.sessionWantsToDoVideo(sipSession);
|
|
@@ -1007,6 +1021,8 @@ export default class WebRTCClient extends Emitter {
|
|
|
1007
1021
|
},
|
|
1008
1022
|
sessionDescriptionHandlerOptions: {
|
|
1009
1023
|
constraints,
|
|
1024
|
+
conference,
|
|
1025
|
+
audioOnly,
|
|
1010
1026
|
offerOptions: {
|
|
1011
1027
|
iceRestart: false,
|
|
1012
1028
|
},
|
|
@@ -1466,6 +1482,8 @@ export default class WebRTCClient extends Emitter {
|
|
|
1466
1482
|
|
|
1467
1483
|
// Invitation and Inviter extends Session
|
|
1468
1484
|
_setupSession(session: Session) {
|
|
1485
|
+
const sipSessionId = this.getSipSessionId(session);
|
|
1486
|
+
|
|
1469
1487
|
// When receiving an Invitation, the delegate is not defined.
|
|
1470
1488
|
if (!session.delegate) {
|
|
1471
1489
|
session.delegate = {};
|
|
@@ -1489,8 +1507,18 @@ export default class WebRTCClient extends Emitter {
|
|
|
1489
1507
|
};
|
|
1490
1508
|
};
|
|
1491
1509
|
|
|
1510
|
+
const oldInviteRequest = session.onInviteRequest.bind(session);
|
|
1511
|
+
let hadRemoteVideo = false;
|
|
1512
|
+
|
|
1513
|
+
// Monkey patch `onInviteRequest` to be able to know if there was a remote video stream before `onInvite` is called
|
|
1514
|
+
// Becase when `onInvite` is called we already got the video track
|
|
1515
|
+
session.onInviteRequest = (request) => {
|
|
1516
|
+
hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
|
|
1517
|
+
|
|
1518
|
+
oldInviteRequest(request);
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1492
1521
|
session.delegate.onInvite = (request: IncomingRequestMessage) => {
|
|
1493
|
-
const sipSessionId = this.getSipSessionId(session);
|
|
1494
1522
|
let updatedCalleeName = null;
|
|
1495
1523
|
let updatedNumber = null;
|
|
1496
1524
|
if (session.assertedIdentity) {
|
|
@@ -1500,7 +1528,6 @@ export default class WebRTCClient extends Emitter {
|
|
|
1500
1528
|
logger.info('re-invite received', { updatedCalleeName, updatedNumber });
|
|
1501
1529
|
|
|
1502
1530
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
1503
|
-
const hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
|
|
1504
1531
|
|
|
1505
1532
|
// Update SDP
|
|
1506
1533
|
// Remote video is handled by the `track` event. Here we're dealing with video stream removal.
|
|
@@ -1550,7 +1577,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
1550
1577
|
}
|
|
1551
1578
|
|
|
1552
1579
|
_isAudioOnly(session: Session): boolean {
|
|
1553
|
-
return session.sessionDescriptionHandlerModifiersReInvite.find(modifier => modifier ===
|
|
1580
|
+
return session.sessionDescriptionHandlerModifiersReInvite.find(modifier => modifier === stripVideo);
|
|
1554
1581
|
}
|
|
1555
1582
|
|
|
1556
1583
|
_setupMedias(session: Session, newStream: ?MediaStream) {
|