@wazo/sdk 0.37.0 → 0.37.4
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 +91 -23
- package/esm/__tests__/web-rtc-client.test.js +165 -56
- package/esm/api/agentd.js +7 -1
- package/esm/api/amid.js +7 -1
- package/esm/api/application.js +7 -1
- package/esm/api/auth.js +7 -1
- package/esm/api/call-logd.js +17 -23
- package/esm/api/calld.js +10 -18
- package/esm/api/chatd.js +7 -1
- package/esm/api/confd.js +78 -1
- package/esm/api/ctid-ng.js +7 -1
- package/esm/api/dird.js +7 -1
- package/esm/api/webhookd.js +7 -1
- package/esm/api-client.js +91 -23
- package/esm/checker/Checker.js +169 -56
- package/esm/checker/checks/aor.js +91 -23
- package/esm/checker/checks/api.js +91 -23
- package/esm/checker/checks/index.js +169 -56
- package/esm/checker/checks/wazo-websocket.js +11 -1
- package/esm/checker/checks/webrtc-transport.js +165 -56
- package/esm/checker/checks/webrtc.js +165 -56
- package/esm/domain/AdHocAPIConference.js +1722 -1654
- package/esm/domain/CallLog.js +10 -22
- package/esm/domain/CallSession.js +1 -18
- package/esm/domain/Features.js +91 -23
- package/esm/domain/IndirectTransfer.js +0 -17
- package/esm/domain/Meeting.js +71 -0
- package/esm/domain/Phone/CTIPhone.js +98 -26
- package/esm/domain/Phone/Phone.js +0 -17
- package/esm/domain/Phone/WebRTCPhone.js +47 -27
- package/esm/domain/Room.js +0 -17
- package/esm/domain/SwitchboardCall.js +0 -17
- package/esm/domain/__tests__/CallLog.test.js +10 -22
- package/esm/domain/__tests__/CallSession.test.js +1 -18
- package/esm/domain/__tests__/IndirectTransfer.test.js +1 -18
- package/esm/domain/__tests__/Room.test.js +1 -18
- package/esm/index.js +3880 -3111
- package/esm/lib/WazoSessionDescriptionHandler.js +24 -10
- package/esm/service/CallApi.js +91 -23
- package/esm/service/IssueReporter.js +7 -1
- package/esm/service/__tests__/IssueReporter.test.js +9 -1
- package/esm/service/getApiClient.js +91 -23
- package/esm/simple/Auth.js +1126 -360
- package/esm/simple/Configuration.js +1126 -360
- package/esm/simple/Directory.js +91 -23
- package/esm/simple/Phone.js +3724 -2958
- package/esm/simple/Websocket.js +13 -1
- package/esm/simple/index.js +1128 -362
- package/esm/simple/room/LocalParticipant.js +1097 -331
- package/esm/simple/room/Participant.js +1097 -331
- package/esm/simple/room/RemoteParticipant.js +1097 -331
- package/esm/simple/room/Room.js +1097 -331
- package/esm/simple/room/SipRoom.js +12996 -0
- package/esm/simple/room/Stream.js +1128 -362
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +5157 -4389
- package/esm/simple/utils.js +1128 -362
- package/esm/utils/__tests__/api-requester.test.js +7 -1
- package/esm/utils/api-requester.js +7 -1
- package/esm/web-rtc-client.js +165 -56
- package/esm/websocket-client.js +12 -2
- package/lib/__tests__/api-client.test.js +91 -23
- package/lib/__tests__/web-rtc-client.test.js +165 -56
- package/lib/api/agentd.js +7 -1
- package/lib/api/amid.js +7 -1
- package/lib/api/application.js +7 -1
- package/lib/api/auth.js +7 -1
- package/lib/api/call-logd.js +17 -23
- package/lib/api/calld.js +10 -18
- package/lib/api/chatd.js +7 -1
- package/lib/api/confd.js +78 -1
- package/lib/api/ctid-ng.js +7 -1
- package/lib/api/dird.js +7 -1
- package/lib/api/webhookd.js +7 -1
- package/lib/api-client.js +91 -23
- package/lib/checker/Checker.js +169 -56
- package/lib/checker/checks/aor.js +91 -23
- package/lib/checker/checks/api.js +91 -23
- package/lib/checker/checks/index.js +169 -56
- package/lib/checker/checks/wazo-websocket.js +11 -1
- package/lib/checker/checks/webrtc-transport.js +165 -56
- package/lib/checker/checks/webrtc.js +165 -56
- package/lib/domain/AdHocAPIConference.js +1722 -1654
- package/lib/domain/CallLog.js +10 -22
- package/lib/domain/CallSession.js +1 -18
- package/lib/domain/Features.js +91 -23
- package/lib/domain/IndirectTransfer.js +0 -17
- package/lib/domain/Meeting.js +73 -0
- package/lib/domain/Phone/CTIPhone.js +98 -26
- package/lib/domain/Phone/Phone.js +0 -16
- package/lib/domain/Phone/WebRTCPhone.js +47 -27
- package/lib/domain/Room.js +0 -17
- package/lib/domain/SwitchboardCall.js +0 -17
- package/lib/domain/__tests__/CallLog.test.js +10 -22
- package/lib/domain/__tests__/CallSession.test.js +1 -18
- package/lib/domain/__tests__/IndirectTransfer.test.js +1 -18
- package/lib/domain/__tests__/Room.test.js +1 -18
- package/lib/index.js +3880 -3111
- package/lib/lib/WazoSessionDescriptionHandler.js +24 -10
- package/lib/service/CallApi.js +91 -23
- package/lib/service/IssueReporter.js +7 -1
- package/lib/service/__tests__/IssueReporter.test.js +9 -1
- package/lib/service/getApiClient.js +91 -23
- package/lib/simple/Auth.js +1126 -360
- package/lib/simple/Configuration.js +1126 -360
- package/lib/simple/Directory.js +91 -23
- package/lib/simple/Phone.js +3724 -2958
- package/lib/simple/Websocket.js +13 -1
- package/lib/simple/index.js +1128 -362
- package/lib/simple/room/LocalParticipant.js +1097 -331
- package/lib/simple/room/Participant.js +1097 -331
- package/lib/simple/room/RemoteParticipant.js +1097 -331
- package/lib/simple/room/Room.js +1097 -331
- package/lib/simple/room/SipRoom.js +13006 -0
- package/lib/simple/room/Stream.js +1128 -362
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +5157 -4389
- package/lib/simple/utils.js +1128 -362
- package/lib/utils/__tests__/api-requester.test.js +7 -1
- package/lib/utils/api-requester.js +7 -1
- package/lib/web-rtc-client.js +165 -56
- package/lib/websocket-client.js +13 -1
- package/package.json +1 -1
- package/src/api/calld.js +3 -0
- package/src/api/confd.js +13 -0
- package/src/domain/CallLog.js +10 -22
- package/src/domain/CallSession.js +1 -2
- package/src/domain/Meeting.js +59 -0
- package/src/domain/Phone/CTIPhone.js +6 -2
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +22 -8
- package/src/index.js +6 -0
- package/src/lib/WazoSessionDescriptionHandler.js +17 -9
- package/src/service/IssueReporter.js +7 -1
- package/src/service/__tests__/IssueReporter.test.js +2 -0
- package/src/simple/Phone.js +13 -4
- package/src/simple/index.js +8 -0
- package/src/simple/room/Participant.js +7 -0
- package/src/simple/room/Room.js +157 -79
- package/src/simple/room/SipRoom.js +147 -0
- package/src/simple/room/Stream.js +1 -3
- package/src/simple/room/__tests__/RemoteParticipant.test.js +3 -2
- package/src/types/WebSocketMessage.js +21 -0
- package/src/web-rtc-client.js +57 -24
- package/src/websocket-client.js +4 -0
|
@@ -600,7 +600,13 @@ class IssueReporter {
|
|
|
600
600
|
}
|
|
601
601
|
|
|
602
602
|
_isLevelAbove(level1 , level2 ) {
|
|
603
|
-
|
|
603
|
+
const index1 = LOG_LEVELS.indexOf(level1);
|
|
604
|
+
const index2 = LOG_LEVELS.indexOf(level2);
|
|
605
|
+
if (index1 === -1 || index2 === -1) {
|
|
606
|
+
return false;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
return index1 > index2;
|
|
604
610
|
}
|
|
605
611
|
|
|
606
612
|
_makeCategory(category ) {
|
|
@@ -772,7 +778,9 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
772
778
|
.then(() => {
|
|
773
779
|
if (isConference && (options.constraints && !options.constraints.video) && !('hold' in options) && !audioOnly) {
|
|
774
780
|
// Add a video an empty bundle to be able to replaceTrack when joining a conference without video
|
|
775
|
-
this.peerConnection.addTransceiver
|
|
781
|
+
if (this.peerConnection.addTransceiver) {
|
|
782
|
+
this.peerConnection.addTransceiver('video', { streams: [this._localMediaStream], direction: 'sendrecv' });
|
|
783
|
+
}
|
|
776
784
|
}
|
|
777
785
|
})
|
|
778
786
|
.then(() => this.createLocalOfferOrAnswer(options))
|
|
@@ -799,12 +807,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
799
807
|
};
|
|
800
808
|
})
|
|
801
809
|
.then((sessionDescription) => this.applyModifiers(sessionDescription, modifiers))
|
|
802
|
-
.then((sessionDescription) => {
|
|
803
|
-
// Set new constraints to avoid the constraints check issue in `sdh.getLocalMediaStream` later.
|
|
804
|
-
this.localMediaStreamConstraints = options.constraints;
|
|
805
|
-
|
|
806
|
-
return sessionDescription;
|
|
807
|
-
})
|
|
808
810
|
.then((sessionDescription) => ({ body: sessionDescription.sdp, contentType: 'application/sdp' }))
|
|
809
811
|
.catch((error) => {
|
|
810
812
|
wazoLogger.error('error when creating media', error);
|
|
@@ -999,6 +1001,9 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
999
1001
|
|
|
1000
1002
|
// set the transceiver direction to the answer direction
|
|
1001
1003
|
this._peerConnection.getTransceivers().forEach((transceiver) => {
|
|
1004
|
+
if (transceiver.stopped) {
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1002
1007
|
if (transceiver.direction /* guarding, but should always be true */) {
|
|
1003
1008
|
const { receiver } = transceiver;
|
|
1004
1009
|
if (isConference && audioOnly && receiver.track && receiver.track.kind === 'video') {
|
|
@@ -1043,10 +1048,15 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
1043
1048
|
if (kind !== 'audio' && kind !== 'video') {
|
|
1044
1049
|
throw new Error(`Unknown new track kind ${kind}.`);
|
|
1045
1050
|
}
|
|
1046
|
-
const sender = pc.getSenders().find((otherSender) =>
|
|
1051
|
+
const sender = pc.getSenders && pc.getSenders().find((otherSender) =>
|
|
1052
|
+
otherSender.track && otherSender.track.kind === kind);
|
|
1047
1053
|
|
|
1048
1054
|
// Do not reuse sender video tracks in SFU
|
|
1049
1055
|
if (sender && (!sfu || newTrack.kind === 'audio')) {
|
|
1056
|
+
if (sender.track) {
|
|
1057
|
+
// eslint-disable-next-line no-param-reassign
|
|
1058
|
+
newTrack.enabled = sender.track.enabled;
|
|
1059
|
+
}
|
|
1050
1060
|
trackUpdates.push(
|
|
1051
1061
|
new Promise((resolve) => {
|
|
1052
1062
|
this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - replacing sender ${kind} track`);
|
|
@@ -1080,7 +1090,11 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
1080
1090
|
// Review: could make streamless tracks a configurable option?
|
|
1081
1091
|
// https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addTrack#Usage_notes
|
|
1082
1092
|
try {
|
|
1083
|
-
pc.addTrack
|
|
1093
|
+
if (pc.addTrack) {
|
|
1094
|
+
pc.addTrack(newTrack, localStream);
|
|
1095
|
+
} else {
|
|
1096
|
+
pc.addStream(localStream);
|
|
1097
|
+
}
|
|
1084
1098
|
} catch (error) {
|
|
1085
1099
|
this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to add sender ${kind} track`);
|
|
1086
1100
|
throw error;
|
|
@@ -3037,6 +3051,65 @@ class ExternalApp {
|
|
|
3037
3051
|
}
|
|
3038
3052
|
}
|
|
3039
3053
|
|
|
3054
|
+
//
|
|
3055
|
+
|
|
3056
|
+
|
|
3057
|
+
|
|
3058
|
+
|
|
3059
|
+
|
|
3060
|
+
|
|
3061
|
+
|
|
3062
|
+
|
|
3063
|
+
|
|
3064
|
+
|
|
3065
|
+
|
|
3066
|
+
class Meeting {
|
|
3067
|
+
|
|
3068
|
+
|
|
3069
|
+
|
|
3070
|
+
|
|
3071
|
+
|
|
3072
|
+
|
|
3073
|
+
|
|
3074
|
+
|
|
3075
|
+
|
|
3076
|
+
|
|
3077
|
+
static parse(plain ) {
|
|
3078
|
+
return new Meeting({
|
|
3079
|
+
guestSipAuthorization: plain.guest_sip_authorization,
|
|
3080
|
+
hostname: plain.hostname,
|
|
3081
|
+
name: plain.name,
|
|
3082
|
+
ownerUuids: plain.owner_uuids,
|
|
3083
|
+
port: plain.port,
|
|
3084
|
+
uuid: plain.uuid,
|
|
3085
|
+
number: plain.number,
|
|
3086
|
+
});
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3089
|
+
static newFrom(meeting ) {
|
|
3090
|
+
return newFrom(meeting, Meeting);
|
|
3091
|
+
}
|
|
3092
|
+
|
|
3093
|
+
constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, hostname, number } = {}) {
|
|
3094
|
+
this.guestSipAuthorization = guestSipAuthorization;
|
|
3095
|
+
this.hostname = hostname;
|
|
3096
|
+
this.name = name;
|
|
3097
|
+
this.ownerUuids = ownerUuids;
|
|
3098
|
+
this.port = port;
|
|
3099
|
+
this.uuid = uuid;
|
|
3100
|
+
this.number = number;
|
|
3101
|
+
|
|
3102
|
+
// Useful to compare instead of instanceof with minified code
|
|
3103
|
+
this.type = 'Meeting';
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
getGuestSipCredentials() {
|
|
3107
|
+
// eslint-disable-next-line no-undef
|
|
3108
|
+
const [username, secret] = atob(this.guestSipAuthorization).split(':');
|
|
3109
|
+
return { username, secret };
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
|
|
3040
3113
|
/* */
|
|
3041
3114
|
|
|
3042
3115
|
var confdMethods = (client , baseUrl ) => ({
|
|
@@ -3101,6 +3174,18 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3101
3174
|
return null;
|
|
3102
3175
|
}
|
|
3103
3176
|
},
|
|
3177
|
+
|
|
3178
|
+
createMyMeeting: (name ) =>
|
|
3179
|
+
client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
|
|
3180
|
+
|
|
3181
|
+
deleteMyMeeting: (meetingUuid ) =>
|
|
3182
|
+
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
3183
|
+
|
|
3184
|
+
getMeeting: (meetingUuid ) =>
|
|
3185
|
+
client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
3186
|
+
|
|
3187
|
+
guestGetMeeting: (meetingUuid ) =>
|
|
3188
|
+
client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
|
|
3104
3189
|
});
|
|
3105
3190
|
|
|
3106
3191
|
//
|
|
@@ -3685,7 +3770,11 @@ class CallLog {
|
|
|
3685
3770
|
answered: plain.answered,
|
|
3686
3771
|
callDirection: plain.call_direction,
|
|
3687
3772
|
destination: {
|
|
3688
|
-
|
|
3773
|
+
// @TEMP: Temporarily assuming empty numbers are meetings
|
|
3774
|
+
// which is admittedly a very dangerous assumption. Did i mention it was temporary?
|
|
3775
|
+
extension: plain.requested_extension
|
|
3776
|
+
|| plain.destination_extension
|
|
3777
|
+
|| `meeting-${plain.requested_name || plain.destination_name || ''}`,
|
|
3689
3778
|
name: plain.requested_name || plain.destination_name || '',
|
|
3690
3779
|
},
|
|
3691
3780
|
source: {
|
|
@@ -3701,27 +3790,11 @@ class CallLog {
|
|
|
3701
3790
|
}
|
|
3702
3791
|
|
|
3703
3792
|
static parseNew(plain , session ) {
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
extension: plain.requested_extension || plain.destination_extension,
|
|
3710
|
-
name: plain.requested_name || plain.destination_name || '',
|
|
3711
|
-
},
|
|
3712
|
-
source: {
|
|
3713
|
-
extension: plain.source_extension,
|
|
3714
|
-
name: plain.source_name,
|
|
3715
|
-
},
|
|
3716
|
-
id: plain.id,
|
|
3717
|
-
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
3718
|
-
start: moment__default['default'](plain.start).toDate(),
|
|
3719
|
-
end: plain.end ? moment__default['default'](plain.end).toDate() : null,
|
|
3720
|
-
recordings: Recording.parseMany(plain.recordings),
|
|
3721
|
-
// @TODO: FIXME add verification declined vs missed call
|
|
3722
|
-
newMissedCall: session
|
|
3723
|
-
&& session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
|
|
3724
|
-
});
|
|
3793
|
+
const callLog = CallLog.parse(plain);
|
|
3794
|
+
// @TODO: FIXME add verification declined vs missed call
|
|
3795
|
+
callLog.newMissedCall = session
|
|
3796
|
+
&& session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
|
|
3797
|
+
return callLog;
|
|
3725
3798
|
}
|
|
3726
3799
|
|
|
3727
3800
|
static newFrom(profile ) {
|
|
@@ -4478,6 +4551,9 @@ var calldMethods = (client , baseUrl ) => ({
|
|
|
4478
4551
|
getConferenceParticipantsAsUser: async (conferenceId ) =>
|
|
4479
4552
|
client.get(`${baseUrl}/users/me/conferences/${conferenceId}/participants`),
|
|
4480
4553
|
|
|
4554
|
+
getMeetingParticipantsAsUser: async (meetingUuid ) =>
|
|
4555
|
+
client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
|
|
4556
|
+
|
|
4481
4557
|
listTrunks: () => client.get(`${baseUrl}/trunks`),
|
|
4482
4558
|
|
|
4483
4559
|
mute: (callId ) =>
|
|
@@ -5110,6 +5186,7 @@ const MAX_REGISTER_TRIES = 10;
|
|
|
5110
5186
|
|
|
5111
5187
|
|
|
5112
5188
|
|
|
5189
|
+
|
|
5113
5190
|
|
|
5114
5191
|
|
|
5115
5192
|
|
|
@@ -5136,6 +5213,7 @@ class WebRTCClient extends Emitter {
|
|
|
5136
5213
|
|
|
5137
5214
|
|
|
5138
5215
|
|
|
5216
|
+
|
|
5139
5217
|
|
|
5140
5218
|
// sugar
|
|
5141
5219
|
|
|
@@ -5174,6 +5252,8 @@ class WebRTCClient extends Emitter {
|
|
|
5174
5252
|
super();
|
|
5175
5253
|
this.uaConfigOverrides = uaConfigOverrides;
|
|
5176
5254
|
this.config = config;
|
|
5255
|
+
this.skipRegister = config.skipRegister;
|
|
5256
|
+
|
|
5177
5257
|
this._buildConfig(config, session).then((newConfig ) => {
|
|
5178
5258
|
this.config = newConfig;
|
|
5179
5259
|
this.userAgent = this.createUserAgent(uaConfigOverrides);
|
|
@@ -5301,14 +5381,22 @@ class WebRTCClient extends Emitter {
|
|
|
5301
5381
|
}
|
|
5302
5382
|
|
|
5303
5383
|
register(tries = 0) {
|
|
5304
|
-
|
|
5384
|
+
const logInfo = {
|
|
5305
5385
|
userAgent: !!this.userAgent,
|
|
5306
5386
|
registered: this.isRegistered(),
|
|
5307
5387
|
connectionPromise: !!this.connectionPromise,
|
|
5308
5388
|
registerer: !!this.registerer,
|
|
5309
5389
|
waiting: this.registerer && this.registerer.waiting,
|
|
5310
5390
|
tries,
|
|
5311
|
-
|
|
5391
|
+
skipRegister: this.skipRegister,
|
|
5392
|
+
};
|
|
5393
|
+
|
|
5394
|
+
if (this.skipRegister) {
|
|
5395
|
+
logger.info('sdk webrtc skip register...', logInfo);
|
|
5396
|
+
return Promise.resolve();
|
|
5397
|
+
}
|
|
5398
|
+
|
|
5399
|
+
logger.info('sdk webrtc registering...', logInfo);
|
|
5312
5400
|
|
|
5313
5401
|
if (!this.userAgent) {
|
|
5314
5402
|
logger.info('sdk webrtc recreating User Agent');
|
|
@@ -5639,12 +5727,18 @@ class WebRTCClient extends Emitter {
|
|
|
5639
5727
|
}
|
|
5640
5728
|
|
|
5641
5729
|
if (pc.getSenders) {
|
|
5730
|
+
if (!pc.getSenders().length) {
|
|
5731
|
+
return false;
|
|
5732
|
+
}
|
|
5642
5733
|
pc.getSenders().forEach(sender => {
|
|
5643
5734
|
if (sender && sender.track && sender.track.kind === 'audio') {
|
|
5644
5735
|
muted = muted && !sender.track.enabled;
|
|
5645
5736
|
}
|
|
5646
5737
|
});
|
|
5647
5738
|
} else {
|
|
5739
|
+
if (!pc.getLocalStreams().length) {
|
|
5740
|
+
return false;
|
|
5741
|
+
}
|
|
5648
5742
|
pc.getLocalStreams().forEach(stream => {
|
|
5649
5743
|
stream.getAudioTracks().forEach(track => {
|
|
5650
5744
|
muted = muted && !track.enabled;
|
|
@@ -5701,6 +5795,9 @@ class WebRTCClient extends Emitter {
|
|
|
5701
5795
|
if (!this._isWeb()) {
|
|
5702
5796
|
options.sessionDescriptionHandlerModifiers = [modifiers.holdModifier];
|
|
5703
5797
|
}
|
|
5798
|
+
options.sessionDescriptionHandlerOptions = {
|
|
5799
|
+
constraints: options.constraints,
|
|
5800
|
+
};
|
|
5704
5801
|
|
|
5705
5802
|
// Send re-INVITE
|
|
5706
5803
|
return session.invite(options);
|
|
@@ -5740,6 +5837,9 @@ class WebRTCClient extends Emitter {
|
|
|
5740
5837
|
// (eg: holdModifier)
|
|
5741
5838
|
options.sessionDescriptionHandlerModifiers = [];
|
|
5742
5839
|
}
|
|
5840
|
+
options.sessionDescriptionHandlerOptions = {
|
|
5841
|
+
constraints: options.constraints,
|
|
5842
|
+
};
|
|
5743
5843
|
|
|
5744
5844
|
// Send re-INVITE
|
|
5745
5845
|
return session.invite(options);
|
|
@@ -5922,7 +6022,8 @@ class WebRTCClient extends Emitter {
|
|
|
5922
6022
|
}
|
|
5923
6023
|
const sdh = session.sessionDescriptionHandler;
|
|
5924
6024
|
const pc = sdh.peerConnection;
|
|
5925
|
-
const
|
|
6025
|
+
const sessionId = this.getSipSessionId(session);
|
|
6026
|
+
const localStream = this.getLocalStream(sessionId);
|
|
5926
6027
|
|
|
5927
6028
|
// Release old video stream
|
|
5928
6029
|
if (localStream) {
|
|
@@ -5948,11 +6049,8 @@ class WebRTCClient extends Emitter {
|
|
|
5948
6049
|
|
|
5949
6050
|
// let's update the local stream
|
|
5950
6051
|
this.eventEmitter.emit('onVideoInputChange', stream);
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
} catch (_) {
|
|
5954
|
-
// Nothing to do
|
|
5955
|
-
}
|
|
6052
|
+
this.setLocalMediaStream(sessionId, stream);
|
|
6053
|
+
|
|
5956
6054
|
return stream;
|
|
5957
6055
|
});
|
|
5958
6056
|
}
|
|
@@ -6254,9 +6352,11 @@ class WebRTCClient extends Emitter {
|
|
|
6254
6352
|
remoteStream.removeTrack(track);
|
|
6255
6353
|
});
|
|
6256
6354
|
|
|
6257
|
-
pc.getReceivers
|
|
6258
|
-
|
|
6259
|
-
|
|
6355
|
+
if (pc.getReceivers) {
|
|
6356
|
+
pc.getReceivers().forEach(receiver => {
|
|
6357
|
+
remoteStream.addTrack(receiver.track);
|
|
6358
|
+
});
|
|
6359
|
+
}
|
|
6260
6360
|
}
|
|
6261
6361
|
|
|
6262
6362
|
getMediaConfiguration(enableVideo , conference = false, constraints = null) {
|
|
@@ -6291,6 +6391,25 @@ class WebRTCClient extends Emitter {
|
|
|
6291
6391
|
return sessionId in this.conferences;
|
|
6292
6392
|
}
|
|
6293
6393
|
|
|
6394
|
+
createAudioElementFor(sessionId ) {
|
|
6395
|
+
const audio = document.createElement('audio');
|
|
6396
|
+
audio.setAttribute('id', `audio-${sessionId}`);
|
|
6397
|
+
|
|
6398
|
+
if (audio.setSinkId && this.audioOutputDeviceId) {
|
|
6399
|
+
audio.setSinkId(this.audioOutputDeviceId);
|
|
6400
|
+
}
|
|
6401
|
+
|
|
6402
|
+
if (document.body) {
|
|
6403
|
+
document.body.appendChild(audio);
|
|
6404
|
+
}
|
|
6405
|
+
this.audioElements[sessionId] = audio;
|
|
6406
|
+
|
|
6407
|
+
audio.volume = this.audioOutputVolume;
|
|
6408
|
+
audio.autoplay = true;
|
|
6409
|
+
|
|
6410
|
+
return audio;
|
|
6411
|
+
}
|
|
6412
|
+
|
|
6294
6413
|
_onTransportError() {
|
|
6295
6414
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
6296
6415
|
this.attemptReconnection();
|
|
@@ -6520,7 +6639,7 @@ class WebRTCClient extends Emitter {
|
|
|
6520
6639
|
let hadRemoteVideo = false;
|
|
6521
6640
|
|
|
6522
6641
|
// Monkey patch `onInviteRequest` to be able to know if there was a remote video stream before `onInvite` is called
|
|
6523
|
-
//
|
|
6642
|
+
// Because when `onInvite` is called we already got the video track
|
|
6524
6643
|
session.onInviteRequest = (request) => {
|
|
6525
6644
|
hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
|
|
6526
6645
|
|
|
@@ -6595,20 +6714,10 @@ class WebRTCClient extends Emitter {
|
|
|
6595
6714
|
const isConference = this.isConference(sessionId);
|
|
6596
6715
|
|
|
6597
6716
|
if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
|
|
6598
|
-
|
|
6599
|
-
audio.setAttribute('id', `audio-${sessionId}`);
|
|
6600
|
-
|
|
6601
|
-
if (audio.setSinkId && this.audioOutputDeviceId) {
|
|
6602
|
-
audio.setSinkId(this.audioOutputDeviceId);
|
|
6603
|
-
}
|
|
6604
|
-
|
|
6605
|
-
if (document.body) {
|
|
6606
|
-
document.body.appendChild(audio);
|
|
6607
|
-
}
|
|
6608
|
-
this.audioElements[sessionId] = audio;
|
|
6717
|
+
this.createAudioElementFor(sessionId);
|
|
6609
6718
|
}
|
|
6610
6719
|
|
|
6611
|
-
const audioElement = this.audioElements[
|
|
6720
|
+
const audioElement = this.audioElements[sessionId];
|
|
6612
6721
|
const stream = newStream || this.getRemoteStream(sessionId);
|
|
6613
6722
|
|
|
6614
6723
|
if (!this._isWeb() || !stream) {
|