@wazo/sdk 1.0.0-alpha.0 → 1.0.0-alpha.10
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/README.md +16 -7
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/__voice__/call.test.js +57 -2
- package/esm/__tests__/api-client.test.js +20 -1
- package/esm/api/auth.js +16 -2
- package/esm/checker/checks/webrtc.js +2 -2
- package/esm/domain/CallLog.js +2 -3
- package/esm/domain/Phone/CTIPhone.js +2 -2
- package/esm/domain/Phone/WebRTCPhone.js +64 -63
- package/esm/index.js +5 -1
- package/esm/service/CallApi.js +4 -4
- package/esm/simple/Auth.js +19 -15
- package/esm/simple/Phone.js +6 -5
- package/esm/simple/__tests__/Auth.test.js +8 -64
- package/esm/simple/index.js +2 -1
- package/esm/simple/room/Room.js +2 -2
- package/esm/simple/room/SipRoom.js +2 -2
- package/esm/state-machine/call-state-machine.js +2 -2
- package/esm/state-machine/softphone-state-machine.js +1 -2
- package/esm/state-machine/utils.js +8 -3
- package/esm/types/api/auth.d.ts +3 -0
- package/esm/types/api/auth.d.ts.map +1 -1
- package/esm/types/checker/checks/index.d.ts +1 -1
- package/esm/types/checker/checks/webrtc-transport.d.ts +2 -2
- package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -1
- package/esm/types/domain/CallLog.d.ts.map +1 -1
- package/esm/types/domain/CallSession.d.ts +3 -3
- package/esm/types/domain/CallSession.d.ts.map +1 -1
- package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +22 -22
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/esm/types/domain/types.d.ts +0 -4
- package/esm/types/domain/types.d.ts.map +1 -1
- package/esm/types/index.d.ts +5 -1
- package/esm/types/index.d.ts.map +1 -1
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +3 -3
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/esm/types/service/CallApi.d.ts +5 -5
- package/esm/types/service/CallApi.d.ts.map +1 -1
- package/esm/types/simple/Auth.d.ts +6 -1
- package/esm/types/simple/Auth.d.ts.map +1 -1
- package/esm/types/simple/Phone.d.ts +8 -8
- package/esm/types/simple/Phone.d.ts.map +1 -1
- package/esm/types/simple/index.d.ts +3 -1
- package/esm/types/simple/index.d.ts.map +1 -1
- package/esm/types/state-machine/softphone-state-machine.d.ts +1 -2
- package/esm/types/state-machine/softphone-state-machine.d.ts.map +1 -1
- package/esm/types/state-machine/utils.d.ts +2 -2
- package/esm/types/state-machine/utils.d.ts.map +1 -1
- package/esm/types/utils/api-requester.d.ts.map +1 -1
- package/esm/types/utils/sdp.d.ts +3 -2
- package/esm/types/utils/sdp.d.ts.map +1 -1
- package/esm/types/utils/webrtc.d.ts +1 -0
- package/esm/types/utils/webrtc.d.ts.map +1 -1
- package/esm/types/voice/call.d.ts +30 -12
- package/esm/types/voice/call.d.ts.map +1 -1
- package/esm/types/voice/softphone.d.ts +25 -13
- package/esm/types/voice/softphone.d.ts.map +1 -1
- package/esm/types/web-rtc-client.d.ts +39 -38
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/utils/__tests__/api-requester.test.js +17 -0
- package/esm/utils/api-requester.js +9 -1
- package/esm/utils/sdp.js +22 -9
- package/esm/utils/webrtc.js +24 -4
- package/esm/voice/call.js +130 -38
- package/esm/voice/softphone.js +145 -35
- package/esm/web-rtc-client.js +61 -58
- package/lib/__tests__/__voice__/call.test.js +56 -1
- package/lib/__tests__/api-client.test.js +20 -1
- package/lib/api/auth.js +16 -2
- package/lib/checker/checks/webrtc.js +1 -1
- package/lib/domain/CallLog.js +2 -3
- package/lib/domain/Phone/CTIPhone.js +2 -2
- package/lib/domain/Phone/WebRTCPhone.js +63 -62
- package/lib/index.js +11 -3
- package/lib/service/CallApi.js +2 -2
- package/lib/simple/Auth.js +21 -15
- package/lib/simple/Phone.js +3 -2
- package/lib/simple/__tests__/Auth.test.js +11 -64
- package/lib/simple/index.js +2 -1
- package/lib/simple/room/Room.js +1 -1
- package/lib/simple/room/SipRoom.js +1 -1
- package/lib/state-machine/call-state-machine.js +2 -2
- package/lib/state-machine/softphone-state-machine.js +1 -2
- package/lib/state-machine/utils.js +8 -3
- package/lib/types/api/auth.d.ts +3 -0
- package/lib/types/api/auth.d.ts.map +1 -1
- package/lib/types/checker/checks/index.d.ts +1 -1
- package/lib/types/checker/checks/webrtc-transport.d.ts +2 -2
- package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -1
- package/lib/types/domain/CallLog.d.ts.map +1 -1
- package/lib/types/domain/CallSession.d.ts +3 -3
- package/lib/types/domain/CallSession.d.ts.map +1 -1
- package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +22 -22
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/lib/types/domain/types.d.ts +0 -4
- package/lib/types/domain/types.d.ts.map +1 -1
- package/lib/types/index.d.ts +5 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +3 -3
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/lib/types/service/CallApi.d.ts +5 -5
- package/lib/types/service/CallApi.d.ts.map +1 -1
- package/lib/types/simple/Auth.d.ts +6 -1
- package/lib/types/simple/Auth.d.ts.map +1 -1
- package/lib/types/simple/Phone.d.ts +8 -8
- package/lib/types/simple/Phone.d.ts.map +1 -1
- package/lib/types/simple/index.d.ts +3 -1
- package/lib/types/simple/index.d.ts.map +1 -1
- package/lib/types/state-machine/softphone-state-machine.d.ts +1 -2
- package/lib/types/state-machine/softphone-state-machine.d.ts.map +1 -1
- package/lib/types/state-machine/utils.d.ts +2 -2
- package/lib/types/state-machine/utils.d.ts.map +1 -1
- package/lib/types/utils/api-requester.d.ts.map +1 -1
- package/lib/types/utils/sdp.d.ts +3 -2
- package/lib/types/utils/sdp.d.ts.map +1 -1
- package/lib/types/utils/webrtc.d.ts +1 -0
- package/lib/types/utils/webrtc.d.ts.map +1 -1
- package/lib/types/voice/call.d.ts +30 -12
- package/lib/types/voice/call.d.ts.map +1 -1
- package/lib/types/voice/softphone.d.ts +25 -13
- package/lib/types/voice/softphone.d.ts.map +1 -1
- package/lib/types/web-rtc-client.d.ts +39 -38
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/utils/__tests__/api-requester.test.js +17 -0
- package/lib/utils/api-requester.js +9 -1
- package/lib/utils/sdp.js +25 -10
- package/lib/utils/webrtc.js +25 -4
- package/lib/voice/call.js +131 -36
- package/lib/voice/softphone.js +150 -35
- package/lib/web-rtc-client.js +59 -57
- package/package.json +1 -1
- package/src/__tests__/__voice__/call.test.ts +63 -2
- package/src/__tests__/api-client.test.ts +22 -1
- package/src/api/auth.ts +30 -3
- package/src/checker/checks/webrtc-transport.ts +2 -2
- package/src/checker/checks/webrtc.ts +2 -2
- package/src/domain/CallLog.ts +2 -3
- package/src/domain/CallSession.ts +3 -3
- package/src/domain/Phone/CTIPhone.ts +3 -2
- package/src/domain/Phone/WebRTCPhone.ts +95 -93
- package/src/domain/types.ts +0 -5
- package/src/index.ts +6 -1
- package/src/lib/WazoSessionDescriptionHandler.ts +3 -3
- package/src/service/CallApi.ts +7 -7
- package/src/simple/Auth.ts +21 -16
- package/src/simple/Phone.ts +12 -11
- package/src/simple/__tests__/Auth.test.ts +9 -87
- package/src/simple/index.ts +2 -1
- package/src/simple/room/Room.ts +3 -3
- package/src/simple/room/SipRoom.ts +3 -3
- package/src/state-machine/call-state-machine.ts +2 -2
- package/src/state-machine/softphone-state-machine.ts +1 -2
- package/src/state-machine/utils.ts +12 -5
- package/src/utils/__tests__/api-requester.test.ts +20 -0
- package/src/utils/api-requester.ts +9 -1
- package/src/utils/sdp.ts +26 -11
- package/src/utils/webrtc.ts +27 -5
- package/src/voice/call.ts +169 -50
- package/src/voice/softphone.ts +180 -41
- package/src/web-rtc-client.ts +106 -99
|
@@ -8,11 +8,11 @@ import { Inviter, Invitation, Session, SessionDescriptionHandlerOptions } from '
|
|
|
8
8
|
import { SessionDescriptionHandler } from 'sip.js/lib/platform/web';
|
|
9
9
|
import CallSession from '../CallSession';
|
|
10
10
|
import type { Phone, AvailablePhoneOptions } from './Phone';
|
|
11
|
-
import
|
|
11
|
+
import WebRTCClient from '../../web-rtc-client';
|
|
12
12
|
import Emitter from '../../utils/Emitter';
|
|
13
13
|
import IssueReporter from '../../service/IssueReporter';
|
|
14
|
-
import { PeerConnection,
|
|
15
|
-
import {
|
|
14
|
+
import { PeerConnection, SipCall } from '../types';
|
|
15
|
+
import { getCallDisplayName, getCallNumber, getSipCallId } from '../../utils/sdp';
|
|
16
16
|
import { downgradeToAudio, getStreamFromConstraints, getWebRtcStats, setLocalMediaStream, upgradeToVideo } from '../../utils/webrtc';
|
|
17
17
|
|
|
18
18
|
export const ON_USER_AGENT = 'onUserAgent';
|
|
@@ -61,8 +61,10 @@ export const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
|
61
61
|
export const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
62
62
|
export const events = [ON_USER_AGENT, ON_REGISTERED, ON_UNREGISTERED, ON_PROGRESS, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_INCOMING, ON_CALL_OUTGOING, ON_CALL_MUTED, ON_CALL_UNMUTED, ON_CALL_RESUMED, ON_CALL_HELD, ON_CALL_UNHELD, ON_CAMERA_DISABLED, ON_CALL_FAILED, ON_CALL_ENDED, ON_CALL_REJECTED, ON_MESSAGE, ON_REINVITE, ON_TRACK, ON_AUDIO_STREAM, ON_VIDEO_STREAM, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_TERMINATE_SOUND, ON_PLAY_RING_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_HANGUP_SOUND, ON_PLAY_PROGRESS_SOUND, ON_VIDEO_INPUT_CHANGE, ON_SHARE_SCREEN_STARTED, ON_CALL_ERROR, ON_CHAT, ON_SIGNAL, ON_NETWORK_STATS, ON_DISCONNECTED, ON_EARLY_MEDIA];
|
|
63
63
|
const logger = IssueReporter.loggerFor('webrtc-phone');
|
|
64
|
+
|
|
65
|
+
// @deprecated: Use Wazo.Voice.Softphone instead
|
|
64
66
|
export default class WebRTCPhone extends Emitter implements Phone {
|
|
65
|
-
client:
|
|
67
|
+
client: WebRTCClient;
|
|
66
68
|
|
|
67
69
|
allowVideo: boolean;
|
|
68
70
|
|
|
@@ -70,7 +72,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
70
72
|
|
|
71
73
|
incomingSessions: string[];
|
|
72
74
|
|
|
73
|
-
currentSipSession?:
|
|
75
|
+
currentSipSession?: SipCall;
|
|
74
76
|
|
|
75
77
|
currentCallSession?: CallSession;
|
|
76
78
|
|
|
@@ -96,7 +98,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
96
98
|
|
|
97
99
|
shouldSendReinvite: boolean;
|
|
98
100
|
|
|
99
|
-
constructor(client:
|
|
101
|
+
constructor(client: WebRTCClient, audioOutputDeviceId: string | undefined, allowVideo = false, audioRingDeviceId?: string) {
|
|
100
102
|
super();
|
|
101
103
|
this.client = client;
|
|
102
104
|
this.allowVideo = allowVideo;
|
|
@@ -161,7 +163,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
161
163
|
async sendReinvite(callSession?: CallSession, constraints: Record<string, any> | null | undefined = null, conference = false, audioOnly = false, iceRestart = false): Promise<OutgoingInviteRequest | void> {
|
|
162
164
|
const sipSession = this.findSipSession(callSession);
|
|
163
165
|
logger.info('WebRTC phone - send reinvite', {
|
|
164
|
-
sessionId: sipSession
|
|
166
|
+
sessionId: getSipCallId(sipSession),
|
|
165
167
|
constraints,
|
|
166
168
|
audioOnly,
|
|
167
169
|
conference,
|
|
@@ -358,7 +360,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
358
360
|
content: {
|
|
359
361
|
type: ON_MESSAGE_TRACK_UPDATED,
|
|
360
362
|
update: isUpgrade ? 'upgrade' : 'downgrade',
|
|
361
|
-
sipCallId: sipSession &&
|
|
363
|
+
sipCallId: sipSession && getSipCallId(sipSession),
|
|
362
364
|
callId: callSession ? callSession.callId : null,
|
|
363
365
|
number: callSession ? callSession.number : null,
|
|
364
366
|
},
|
|
@@ -366,8 +368,8 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
366
368
|
}, 2500);
|
|
367
369
|
}
|
|
368
370
|
|
|
369
|
-
_bindEvents(sipSession:
|
|
370
|
-
const sipSessionId =
|
|
371
|
+
_bindEvents(sipSession: SipCall) {
|
|
372
|
+
const sipSessionId = getSipCallId(sipSession);
|
|
371
373
|
|
|
372
374
|
if (sipSession instanceof Invitation) {
|
|
373
375
|
// Monkey patch to know when canceled with the CANCEL message
|
|
@@ -382,7 +384,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
382
384
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
383
385
|
const callSession = this._createCallSession(sipSession);
|
|
384
386
|
|
|
385
|
-
|
|
387
|
+
if (sipSessionId) {
|
|
388
|
+
delete this.callSessions[sipSessionId];
|
|
389
|
+
}
|
|
386
390
|
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
387
391
|
};
|
|
388
392
|
}
|
|
@@ -391,7 +395,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
391
395
|
switch (newState) {
|
|
392
396
|
case SessionState.Terminating:
|
|
393
397
|
logger.info('WebRTC phone - call terminating', {
|
|
394
|
-
sipId: sipSession
|
|
398
|
+
sipId: getSipCallId(sipSession),
|
|
395
399
|
});
|
|
396
400
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
397
401
|
break;
|
|
@@ -399,7 +403,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
399
403
|
case SessionState.Terminated:
|
|
400
404
|
{
|
|
401
405
|
logger.info('WebRTC phone - call terminated', {
|
|
402
|
-
sipId: sipSession
|
|
406
|
+
sipId: getSipCallId(sipSession),
|
|
403
407
|
});
|
|
404
408
|
|
|
405
409
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
@@ -435,7 +439,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
435
439
|
const [stream] = event.streams;
|
|
436
440
|
const kind = event && event.track && event.track.kind;
|
|
437
441
|
logger.info('on track stream called on the peer connection', {
|
|
438
|
-
callId:
|
|
442
|
+
callId: getSipCallId(sipSession),
|
|
439
443
|
streamId: stream ? stream.id : null,
|
|
440
444
|
tracks: stream ? stream.getTracks() : null,
|
|
441
445
|
kind,
|
|
@@ -470,9 +474,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
470
474
|
|
|
471
475
|
const screenTrack = screenShareStream.getVideoTracks()[0];
|
|
472
476
|
const sipSession = this.currentSipSession;
|
|
473
|
-
const pc = sipSession && this.client.getPeerConnection(
|
|
477
|
+
const pc = sipSession && this.client.getPeerConnection(getSipCallId(sipSession));
|
|
474
478
|
const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
|
|
475
|
-
const localStream = sipSession && this.client.getLocalStream(
|
|
479
|
+
const localStream = sipSession && this.client.getLocalStream(getSipCallId(sipSession));
|
|
476
480
|
const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
|
|
477
481
|
const hadVideo = !!videoTrack;
|
|
478
482
|
|
|
@@ -491,7 +495,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
491
495
|
sender.replaceTrack(screenTrack);
|
|
492
496
|
}
|
|
493
497
|
|
|
494
|
-
this._onScreenSharing(screenShareStream, sipSession as
|
|
498
|
+
this._onScreenSharing(screenShareStream, sipSession as SipCall, callSession, hadVideo, constraints.desktop);
|
|
495
499
|
|
|
496
500
|
return screenShareStream;
|
|
497
501
|
}
|
|
@@ -545,14 +549,14 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
545
549
|
return reinvited;
|
|
546
550
|
}
|
|
547
551
|
|
|
548
|
-
_onScreenSharing(screenStream: MediaStream, sipSession:
|
|
552
|
+
_onScreenSharing(screenStream: MediaStream, sipSession: SipCall, callSession: CallSession | null | undefined, hadVideo: boolean, desktop?: boolean | null | undefined) {
|
|
549
553
|
const screenTrack = screenStream.getVideoTracks()[0];
|
|
550
|
-
const sipSessionId =
|
|
554
|
+
const sipSessionId = getSipCallId(sipSession);
|
|
551
555
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
552
556
|
const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
|
|
553
557
|
logger.info('WebRTC phone - on screensharing', {
|
|
554
558
|
hadVideo,
|
|
555
|
-
id:
|
|
559
|
+
id: getSipCallId(sipSession),
|
|
556
560
|
screenTrack,
|
|
557
561
|
});
|
|
558
562
|
|
|
@@ -560,7 +564,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
560
564
|
screenTrack.onended = () => {
|
|
561
565
|
logger.info('WebRTC phone - on screenshare ended', {
|
|
562
566
|
hadVideo,
|
|
563
|
-
id:
|
|
567
|
+
id: getSipCallId(sipSession),
|
|
564
568
|
screenTrack,
|
|
565
569
|
});
|
|
566
570
|
this.eventEmitter.emit(ON_SHARE_SCREEN_ENDING, this._createCallSession(sipSession, callSession));
|
|
@@ -580,9 +584,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
580
584
|
}), screenStream);
|
|
581
585
|
}
|
|
582
586
|
|
|
583
|
-
_onCallAccepted(sipSession:
|
|
587
|
+
_onCallAccepted(sipSession: SipCall, cameraEnabled: boolean): CallSession {
|
|
584
588
|
logger.info('WebRTC phone - on call accepted', {
|
|
585
|
-
sipId: sipSession
|
|
589
|
+
sipId: getSipCallId(sipSession),
|
|
586
590
|
cameraEnabled,
|
|
587
591
|
});
|
|
588
592
|
|
|
@@ -590,7 +594,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
590
594
|
|
|
591
595
|
if (this.currentSipSession && !this.isCurrentCallSipSession(callSession)) {
|
|
592
596
|
logger.info('WebRTC phone - on call accepted with another ongoing call, holding it', {
|
|
593
|
-
sipId: sipSession
|
|
597
|
+
sipId: getSipCallId(sipSession),
|
|
594
598
|
cameraEnabled,
|
|
595
599
|
});
|
|
596
600
|
|
|
@@ -600,7 +604,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
600
604
|
this.currentSipSession = sipSession;
|
|
601
605
|
this.currentCallSession = callSession;
|
|
602
606
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call accepted');
|
|
603
|
-
const sipSessionId =
|
|
607
|
+
const sipSessionId = getSipCallId(sipSession);
|
|
604
608
|
|
|
605
609
|
if (sipSessionId) {
|
|
606
610
|
this.removeIncomingSessions(sipSessionId);
|
|
@@ -671,11 +675,11 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
671
675
|
return this.currentSipSession && this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
672
676
|
}
|
|
673
677
|
|
|
674
|
-
_onCallTerminated(sipSession:
|
|
675
|
-
const sipSessionId =
|
|
678
|
+
_onCallTerminated(sipSession: SipCall): boolean {
|
|
679
|
+
const sipSessionId = getSipCallId(sipSession);
|
|
676
680
|
|
|
677
681
|
logger.info('WebRTC phone - on call terminated', {
|
|
678
|
-
sipId: sipSession
|
|
682
|
+
sipId: getSipCallId(sipSession),
|
|
679
683
|
sipSessionId,
|
|
680
684
|
ids: Object.keys(this.callSessions),
|
|
681
685
|
});
|
|
@@ -699,9 +703,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
699
703
|
|
|
700
704
|
if (sipSessionId) {
|
|
701
705
|
this.removeIncomingSessions(sipSessionId);
|
|
702
|
-
}
|
|
703
706
|
|
|
704
|
-
|
|
707
|
+
delete this.callSessions[sipSessionId];
|
|
708
|
+
}
|
|
705
709
|
|
|
706
710
|
if (isCurrentSession) {
|
|
707
711
|
this.currentSipSession = undefined;
|
|
@@ -711,7 +715,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
711
715
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
712
716
|
// Re-trigger incoming call event for remaining incoming calls
|
|
713
717
|
logger.info('WebRTC phone - check to re-trigger incoming call', {
|
|
714
|
-
sipId: sipSession
|
|
718
|
+
sipId: getSipCallId(sipSession),
|
|
715
719
|
shouldRetrigger,
|
|
716
720
|
hasIncomingCallSession,
|
|
717
721
|
});
|
|
@@ -786,7 +790,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
786
790
|
return false;
|
|
787
791
|
}
|
|
788
792
|
|
|
789
|
-
return this.currentSipSession &&
|
|
793
|
+
return this.currentSipSession && getSipCallId(this.currentSipSession) === callSession.getId();
|
|
790
794
|
}
|
|
791
795
|
|
|
792
796
|
hasVideo(callSession: CallSession): boolean {
|
|
@@ -829,7 +833,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
829
833
|
return Promise.resolve(null);
|
|
830
834
|
}
|
|
831
835
|
|
|
832
|
-
const sipSessionId = this.
|
|
836
|
+
const sipSessionId = this.getSipCallIdFromCallSession(callSession);
|
|
833
837
|
|
|
834
838
|
if (sipSessionId && !(sipSessionId in this.callSessions)) {
|
|
835
839
|
logger.warn('Call session already ended or not found, can\'t accept it.', {
|
|
@@ -855,7 +859,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
855
859
|
const sipSession = this.client.getSipSession(callSession.getId()) as Invitation;
|
|
856
860
|
|
|
857
861
|
if (sipSession) {
|
|
858
|
-
logger.info('accept call, session found', { sipId: sipSession
|
|
862
|
+
logger.info('accept call, session found', { sipId: getSipCallId(sipSession) });
|
|
859
863
|
|
|
860
864
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
861
865
|
return callSession.sipCallId;
|
|
@@ -870,7 +874,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
870
874
|
|
|
871
875
|
logger.warn(error, {
|
|
872
876
|
id: callSession ? callSession.getId() : 'n/a',
|
|
873
|
-
ids: this.client.
|
|
877
|
+
ids: this.client.getSipCallIds(),
|
|
874
878
|
});
|
|
875
879
|
|
|
876
880
|
if (callSession) {
|
|
@@ -900,7 +904,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
900
904
|
|
|
901
905
|
if (sipSession) {
|
|
902
906
|
logger.info('WebRTC rejecting', {
|
|
903
|
-
sipId: sipSession
|
|
907
|
+
sipId: getSipCallId(sipSession),
|
|
904
908
|
});
|
|
905
909
|
this.client.hangup(sipSession);
|
|
906
910
|
}
|
|
@@ -921,7 +925,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
921
925
|
|
|
922
926
|
if (sipSession) {
|
|
923
927
|
logger.info('WebRTC atxfer', {
|
|
924
|
-
sipId: sipSession
|
|
928
|
+
sipId: getSipCallId(sipSession),
|
|
925
929
|
});
|
|
926
930
|
return this.client.atxfer(sipSession);
|
|
927
931
|
}
|
|
@@ -952,13 +956,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
952
956
|
}
|
|
953
957
|
|
|
954
958
|
logger.info('WebRTC resuming', {
|
|
955
|
-
sipId: sipSession
|
|
959
|
+
sipId: getSipCallId(sipSession),
|
|
956
960
|
});
|
|
957
961
|
|
|
958
962
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
959
|
-
if (this.currentSipSession && this.currentSipSession
|
|
963
|
+
if (this.currentSipSession && getSipCallId(this.currentSipSession) !== getSipCallId(sipSession)) {
|
|
960
964
|
logger.info('WebRTC hold call after resume', {
|
|
961
|
-
id: this.currentSipSession
|
|
965
|
+
id: getSipCallId(this.currentSipSession),
|
|
962
966
|
});
|
|
963
967
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, withEvent);
|
|
964
968
|
}
|
|
@@ -973,15 +977,15 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
973
977
|
return promise;
|
|
974
978
|
}
|
|
975
979
|
|
|
976
|
-
async holdSipSession(sipSession:
|
|
980
|
+
async holdSipSession(sipSession: SipCall, callSession?: CallSession, withEvent = true): Promise<OutgoingInviteRequest | void> {
|
|
977
981
|
if (!sipSession) {
|
|
978
982
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
979
983
|
}
|
|
980
984
|
|
|
981
|
-
const sessionId =
|
|
985
|
+
const sessionId = getSipCallId(sipSession);
|
|
982
986
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
983
987
|
logger.info('WebRTC hold sip session', {
|
|
984
|
-
sipId: sipSession
|
|
988
|
+
sipId: getSipCallId(sipSession),
|
|
985
989
|
hasVideo,
|
|
986
990
|
});
|
|
987
991
|
|
|
@@ -1006,13 +1010,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1006
1010
|
return promise;
|
|
1007
1011
|
}
|
|
1008
1012
|
|
|
1009
|
-
async unholdSipSession(sipSession:
|
|
1013
|
+
async unholdSipSession(sipSession: SipCall, callSession: CallSession | null | undefined, withEvent = true): Promise<MediaStream | void | null> {
|
|
1010
1014
|
if (!sipSession) {
|
|
1011
1015
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
1012
1016
|
}
|
|
1013
1017
|
|
|
1014
1018
|
const isConference = !!callSession && callSession.isConference();
|
|
1015
|
-
const sessionId =
|
|
1019
|
+
const sessionId = getSipCallId(sipSession);
|
|
1016
1020
|
logger.info('WebRTC unhold sip session', {
|
|
1017
1021
|
sessionId,
|
|
1018
1022
|
isConference,
|
|
@@ -1078,7 +1082,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1078
1082
|
}
|
|
1079
1083
|
|
|
1080
1084
|
logger.info('WebRTC muting', {
|
|
1081
|
-
sipId: sipSession
|
|
1085
|
+
sipId: getSipCallId(sipSession),
|
|
1082
1086
|
});
|
|
1083
1087
|
this.client.mute(sipSession);
|
|
1084
1088
|
|
|
@@ -1106,7 +1110,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1106
1110
|
}
|
|
1107
1111
|
|
|
1108
1112
|
logger.info('WebRTC unmuting', {
|
|
1109
|
-
sipId: sipSession
|
|
1113
|
+
sipId: getSipCallId(sipSession),
|
|
1110
1114
|
});
|
|
1111
1115
|
this.client.unmute(sipSession);
|
|
1112
1116
|
|
|
@@ -1141,7 +1145,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1141
1145
|
}
|
|
1142
1146
|
|
|
1143
1147
|
logger.info('WebRTC turn camera on', {
|
|
1144
|
-
sipId: sipSession
|
|
1148
|
+
sipId: getSipCallId(sipSession),
|
|
1145
1149
|
});
|
|
1146
1150
|
this.client.toggleCameraOn(sipSession);
|
|
1147
1151
|
this.eventEmitter.emit(ON_CAMERA_RESUMED, this._createCameraResumedCallSession(sipSession, callSession));
|
|
@@ -1155,7 +1159,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1155
1159
|
}
|
|
1156
1160
|
|
|
1157
1161
|
logger.info('WebRTC turn camera off', {
|
|
1158
|
-
sipId: sipSession
|
|
1162
|
+
sipId: getSipCallId(sipSession),
|
|
1159
1163
|
});
|
|
1160
1164
|
this.client.toggleCameraOff(sipSession);
|
|
1161
1165
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -1169,7 +1173,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1169
1173
|
}
|
|
1170
1174
|
|
|
1171
1175
|
logger.info('WebRTC send key', {
|
|
1172
|
-
sipId: sipSession
|
|
1176
|
+
sipId: getSipCallId(sipSession),
|
|
1173
1177
|
tone,
|
|
1174
1178
|
});
|
|
1175
1179
|
this.client.sendDTMF(sipSession, tone);
|
|
@@ -1201,10 +1205,10 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1201
1205
|
});
|
|
1202
1206
|
}
|
|
1203
1207
|
|
|
1204
|
-
let sipSession:
|
|
1208
|
+
let sipSession: SipCall;
|
|
1205
1209
|
|
|
1206
1210
|
try {
|
|
1207
|
-
sipSession = this.client.call(number, this.allowVideo ? cameraEnabled : false, audioOnly, conference, options) as
|
|
1211
|
+
sipSession = this.client.call(number, this.allowVideo ? cameraEnabled : false, audioOnly, conference, options) as SipCall;
|
|
1208
1212
|
|
|
1209
1213
|
this._bindEvents(sipSession);
|
|
1210
1214
|
} catch (error: any) {
|
|
@@ -1247,7 +1251,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1247
1251
|
}
|
|
1248
1252
|
|
|
1249
1253
|
logger.info('WebRTC transfer', {
|
|
1250
|
-
sipId: sipSession
|
|
1254
|
+
sipId: getSipCallId(sipSession),
|
|
1251
1255
|
target,
|
|
1252
1256
|
});
|
|
1253
1257
|
this.client.transfer(sipSession, target);
|
|
@@ -1257,8 +1261,8 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1257
1261
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
1258
1262
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
1259
1263
|
logger.info('WebRTC indirect transfer', {
|
|
1260
|
-
sipId: sipSession ? sipSession
|
|
1261
|
-
target: sipSessionTarget ? sipSessionTarget
|
|
1264
|
+
sipId: sipSession ? getSipCallId(sipSession) : null,
|
|
1265
|
+
target: sipSessionTarget ? getSipCallId(sipSessionTarget) : null,
|
|
1262
1266
|
});
|
|
1263
1267
|
|
|
1264
1268
|
if (!sipSessionTarget) {
|
|
@@ -1294,10 +1298,10 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1294
1298
|
console.error('Call is unknown to the WebRTC phone', callSession ? callSession.sipCallId : null, callSession ? callSession.callId : null);
|
|
1295
1299
|
return false;
|
|
1296
1300
|
}
|
|
1297
|
-
const sipSessionId =
|
|
1301
|
+
const sipSessionId = getSipCallId(sipSession);
|
|
1298
1302
|
|
|
1299
1303
|
logger.info('WebRTC hangup', {
|
|
1300
|
-
sipId: sipSession
|
|
1304
|
+
sipId: getSipCallId(sipSession),
|
|
1301
1305
|
sipSessionId,
|
|
1302
1306
|
});
|
|
1303
1307
|
await this.client.hangup(sipSession);
|
|
@@ -1430,7 +1434,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1430
1434
|
}
|
|
1431
1435
|
|
|
1432
1436
|
// eslint-disable-next-line @typescript-eslint/default-param-last
|
|
1433
|
-
sendMessage(sipSession:
|
|
1437
|
+
sendMessage(sipSession: SipCall | null = null, body: string, contentType = 'text/plain'): void {
|
|
1434
1438
|
return this.client.sendMessage(sipSession, body, contentType);
|
|
1435
1439
|
}
|
|
1436
1440
|
|
|
@@ -1482,11 +1486,11 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1482
1486
|
|
|
1483
1487
|
bindClientEvents() {
|
|
1484
1488
|
this.client.unbind();
|
|
1485
|
-
this.client.on(this.client.INVITE, (sipSession:
|
|
1489
|
+
this.client.on(this.client.INVITE, (sipSession: SipCall, wantsToDoVideo: boolean) => {
|
|
1486
1490
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
1487
1491
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
1488
1492
|
logger.info('WebRTC invite received', {
|
|
1489
|
-
sipId: sipSession
|
|
1493
|
+
sipId: getSipCallId(sipSession),
|
|
1490
1494
|
withVideo,
|
|
1491
1495
|
autoAnswer,
|
|
1492
1496
|
});
|
|
@@ -1525,13 +1529,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1525
1529
|
// if `_createCallSession` is called too soon `hasVideo` will return false because the stream doesn't exists yet
|
|
1526
1530
|
setTimeout(() => {
|
|
1527
1531
|
// Update callSession
|
|
1528
|
-
this._createCallSession(sipSession, this.callSessions[
|
|
1532
|
+
this._createCallSession(sipSession, this.callSessions[getSipCallId(sipSession)]);
|
|
1529
1533
|
|
|
1530
1534
|
this.eventEmitter.emit.apply(this.eventEmitter, [this.client.ON_REINVITE, ...args]);
|
|
1531
1535
|
}, 2000);
|
|
1532
1536
|
});
|
|
1533
|
-
this.client.on(this.client.ACCEPTED, async (sipSession:
|
|
1534
|
-
const sessionId =
|
|
1537
|
+
this.client.on(this.client.ACCEPTED, async (sipSession: SipCall) => {
|
|
1538
|
+
const sessionId = getSipCallId(sipSession);
|
|
1535
1539
|
const hasSession = (sessionId in this.callSessions);
|
|
1536
1540
|
logger.info('WebRTC call accepted', {
|
|
1537
1541
|
sipId: sessionId,
|
|
@@ -1557,13 +1561,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1557
1561
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
1558
1562
|
});
|
|
1559
1563
|
this.client.on(this.client.REJECTED, session => {
|
|
1560
|
-
logger.info('WebRTC call rejected', session
|
|
1564
|
+
logger.info('WebRTC call rejected', { id: getSipCallId(session) });
|
|
1561
1565
|
|
|
1562
1566
|
const callSession = this._createCallSession(session);
|
|
1563
1567
|
|
|
1564
1568
|
// `_createCallSession` add the CallSession in `this.callSessions`.
|
|
1565
1569
|
// so we have to remove it or `callCount` will always return 1 even if the call was rejected
|
|
1566
|
-
delete this.callSessions[
|
|
1570
|
+
delete this.callSessions[getSipCallId(session)];
|
|
1567
1571
|
|
|
1568
1572
|
callSession.endTime = new Date();
|
|
1569
1573
|
|
|
@@ -1583,7 +1587,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1583
1587
|
const callSession = this._createCallSession(session, null, {
|
|
1584
1588
|
incoming: false,
|
|
1585
1589
|
ringing: true,
|
|
1586
|
-
callId:
|
|
1590
|
+
callId: getSipCallId(session),
|
|
1587
1591
|
});
|
|
1588
1592
|
|
|
1589
1593
|
this.eventEmitter.emit(ON_PROGRESS, callSession, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
@@ -1594,7 +1598,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1594
1598
|
const callSession = this._createCallSession(session, null, {
|
|
1595
1599
|
incoming: false,
|
|
1596
1600
|
ringing: true,
|
|
1597
|
-
callId:
|
|
1601
|
+
callId: getSipCallId(session),
|
|
1598
1602
|
});
|
|
1599
1603
|
|
|
1600
1604
|
this.eventEmitter.emit(ON_EARLY_MEDIA, callSession, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
@@ -1655,12 +1659,12 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1655
1659
|
this.eventEmitter.emit(ON_MESSAGE, message);
|
|
1656
1660
|
});
|
|
1657
1661
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
1658
|
-
const callSession = this.getCallSession(
|
|
1662
|
+
const callSession = this.getCallSession(getSipCallId(session));
|
|
1659
1663
|
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
1660
1664
|
});
|
|
1661
1665
|
// Used when upgrading directly in screenshare mode
|
|
1662
|
-
this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession:
|
|
1663
|
-
const sipSessionId =
|
|
1666
|
+
this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession: SipCall, response: any, desktop: boolean) => {
|
|
1667
|
+
const sipSessionId = getSipCallId(sipSession);
|
|
1664
1668
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
1665
1669
|
const callSession = this.callSessions[sipSessionId];
|
|
1666
1670
|
logger.info('Updrading directly in screensharing mode', {
|
|
@@ -1673,12 +1677,12 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1673
1677
|
}
|
|
1674
1678
|
|
|
1675
1679
|
// Find a corresponding sipSession from a CallSession
|
|
1676
|
-
findSipSession(callSession?: CallSession):
|
|
1677
|
-
const keys = this.client.
|
|
1680
|
+
findSipSession(callSession?: CallSession): SipCall | null | undefined {
|
|
1681
|
+
const keys = this.client.getSipCallIds();
|
|
1678
1682
|
const keyIndex = keys.findIndex(sessionId => callSession && callSession.isId(sessionId));
|
|
1679
1683
|
|
|
1680
1684
|
if (keyIndex === -1) {
|
|
1681
|
-
const currentSipSessionId = this.currentSipSession ?
|
|
1685
|
+
const currentSipSessionId = this.currentSipSession ? getSipCallId(this.currentSipSession) : this.client.getSipCallIds()[0];
|
|
1682
1686
|
return currentSipSessionId ? this.client.getSipSession(currentSipSessionId) : null;
|
|
1683
1687
|
}
|
|
1684
1688
|
|
|
@@ -1689,13 +1693,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1689
1693
|
return this.callSessions[sipSessionId];
|
|
1690
1694
|
}
|
|
1691
1695
|
|
|
1692
|
-
|
|
1696
|
+
getSipCallIdFromCallSession(callSession: CallSession): string | null {
|
|
1693
1697
|
const sipSession = this.findSipSession(callSession);
|
|
1694
|
-
return sipSession ?
|
|
1698
|
+
return sipSession ? getSipCallId(sipSession) : null;
|
|
1695
1699
|
}
|
|
1696
1700
|
|
|
1697
1701
|
_updateCallSession(callSession: CallSession): void {
|
|
1698
|
-
const sipSessionId = this.
|
|
1702
|
+
const sipSessionId = this.getSipCallIdFromCallSession(callSession);
|
|
1699
1703
|
|
|
1700
1704
|
if (sipSessionId) {
|
|
1701
1705
|
this.callSessions[sipSessionId] = callSession;
|
|
@@ -1735,7 +1739,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1735
1739
|
}
|
|
1736
1740
|
}
|
|
1737
1741
|
|
|
1738
|
-
_createIncomingCallSession(sipSession:
|
|
1742
|
+
_createIncomingCallSession(sipSession: SipCall, cameraEnabled: boolean, fromSession?: CallSession | null | undefined, autoAnswer = false): CallSession {
|
|
1739
1743
|
return this._createCallSession(sipSession, fromSession, {
|
|
1740
1744
|
incoming: true,
|
|
1741
1745
|
ringing: true,
|
|
@@ -1744,7 +1748,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1744
1748
|
});
|
|
1745
1749
|
}
|
|
1746
1750
|
|
|
1747
|
-
_createOutgoingCallSession(sipSession:
|
|
1751
|
+
_createOutgoingCallSession(sipSession: SipCall, cameraEnabled: boolean, fromSession?: CallSession): CallSession {
|
|
1748
1752
|
return this._createCallSession(sipSession, fromSession, {
|
|
1749
1753
|
incoming: false,
|
|
1750
1754
|
ringing: true,
|
|
@@ -1752,51 +1756,48 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1752
1756
|
});
|
|
1753
1757
|
}
|
|
1754
1758
|
|
|
1755
|
-
_createAcceptedCallSession(sipSession:
|
|
1759
|
+
_createAcceptedCallSession(sipSession: SipCall, cameraEnabled?: boolean, fromSession?: CallSession): CallSession {
|
|
1756
1760
|
return this._createCallSession(sipSession, fromSession, {
|
|
1757
1761
|
cameraEnabled: cameraEnabled !== undefined ? cameraEnabled : false,
|
|
1758
1762
|
});
|
|
1759
1763
|
}
|
|
1760
1764
|
|
|
1761
|
-
_createMutedCallSession(sipSession:
|
|
1765
|
+
_createMutedCallSession(sipSession: SipCall, fromSession?: CallSession): CallSession {
|
|
1762
1766
|
return this._createCallSession(sipSession, fromSession, {
|
|
1763
1767
|
muted: true,
|
|
1764
1768
|
});
|
|
1765
1769
|
}
|
|
1766
1770
|
|
|
1767
|
-
_createUnmutedCallSession(sipSession:
|
|
1771
|
+
_createUnmutedCallSession(sipSession: SipCall, fromSession?: CallSession): CallSession {
|
|
1768
1772
|
return this._createCallSession(sipSession, fromSession, {
|
|
1769
1773
|
muted: false,
|
|
1770
1774
|
});
|
|
1771
1775
|
}
|
|
1772
1776
|
|
|
1773
|
-
_createCameraResumedCallSession(sipSession:
|
|
1777
|
+
_createCameraResumedCallSession(sipSession: SipCall, fromSession?: CallSession): CallSession {
|
|
1774
1778
|
return this._createCallSession(sipSession, fromSession, {
|
|
1775
1779
|
videoMuted: false,
|
|
1776
1780
|
});
|
|
1777
1781
|
}
|
|
1778
1782
|
|
|
1779
|
-
_createCameraDisabledCallSession(sipSession:
|
|
1783
|
+
_createCameraDisabledCallSession(sipSession: SipCall, fromSession?: CallSession): CallSession {
|
|
1780
1784
|
return this._createCallSession(sipSession, fromSession, {
|
|
1781
1785
|
videoMuted: true,
|
|
1782
1786
|
});
|
|
1783
1787
|
}
|
|
1784
1788
|
|
|
1785
|
-
_createCallSession(sipSession:
|
|
1786
|
-
|
|
1787
|
-
const
|
|
1788
|
-
|
|
1789
|
-
const
|
|
1790
|
-
|
|
1791
|
-
state,
|
|
1792
|
-
} = sipSession || {};
|
|
1793
|
-
const sessionId = getSipSessionId(sipSession);
|
|
1789
|
+
_createCallSession(sipSession: SipCall, fromSession?: CallSession | null | undefined, extra: Record<string, any> = {}): CallSession {
|
|
1790
|
+
const number = getCallNumber(sipSession);
|
|
1791
|
+
const displayName = getCallDisplayName(sipSession);
|
|
1792
|
+
const { state } = sipSession || {};
|
|
1793
|
+
const sessionId = getSipCallId(sipSession);
|
|
1794
|
+
|
|
1794
1795
|
fromSession = fromSession || this.callSessions[sessionId];
|
|
1795
1796
|
const callSession = new CallSession({
|
|
1796
1797
|
callId: fromSession && fromSession.callId,
|
|
1797
1798
|
sipCallId: sessionId,
|
|
1798
1799
|
sipStatus: state,
|
|
1799
|
-
displayName
|
|
1800
|
+
displayName,
|
|
1800
1801
|
// @ts-ignore: date / number
|
|
1801
1802
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
1802
1803
|
creationTime: fromSession ? fromSession.creationTime : null,
|
|
@@ -1817,6 +1818,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1817
1818
|
...extra,
|
|
1818
1819
|
});
|
|
1819
1820
|
this.callSessions[sessionId] = callSession;
|
|
1821
|
+
|
|
1820
1822
|
return callSession;
|
|
1821
1823
|
}
|
|
1822
1824
|
|
package/src/domain/types.ts
CHANGED
|
@@ -264,11 +264,6 @@ export type PeerConnection = RTCPeerConnection & {
|
|
|
264
264
|
addStream: (stream: MediaStream) => void;
|
|
265
265
|
sfu: any;
|
|
266
266
|
};
|
|
267
|
-
// @TODO, rename it to SipCall
|
|
268
|
-
export type WazoSession = (Invitation | Inviter) & {
|
|
269
|
-
remoteTag?: any;
|
|
270
|
-
callId?: string;
|
|
271
|
-
};
|
|
272
267
|
|
|
273
268
|
export type SipCall = (Invitation | Inviter) & {
|
|
274
269
|
remoteTag?: any;
|
package/src/index.ts
CHANGED
|
@@ -4,8 +4,10 @@ export { default as Emitter } from './utils/Emitter';
|
|
|
4
4
|
export { default as IssueReporter } from './service/IssueReporter';
|
|
5
5
|
export { default as BadResponse } from './domain/BadResponse';
|
|
6
6
|
export { default as ServerError } from './domain/ServerError';
|
|
7
|
+
export { default as InvalidStateTransition } from './domain/InvalidStateTransition';
|
|
8
|
+
export { default as InvalidState } from './domain/InvalidState';
|
|
7
9
|
export { default as SFUNotAvailableError } from './domain/SFUNotAvailableError';
|
|
8
|
-
export { default as
|
|
10
|
+
export { default as ApiCall } from './domain/Call';
|
|
9
11
|
export { default as CallLog } from './domain/CallLog';
|
|
10
12
|
export { default as Recording } from './domain/Recording';
|
|
11
13
|
export { default as ChatMessage } from './domain/ChatMessage';
|
|
@@ -51,6 +53,9 @@ export { default as WazoApiClient } from './api-client';
|
|
|
51
53
|
export { default as Agent, AgentResponse, AgentArguments } from './domain/Agent';
|
|
52
54
|
export { default as ExternalApp } from './domain/ExternalApp';
|
|
53
55
|
export { default as SessionDescriptionHandler } from './lib/WazoSessionDescriptionHandler';
|
|
56
|
+
export { default as Call } from './voice/call';
|
|
57
|
+
export { Softphone } from './voice/softphone';
|
|
58
|
+
|
|
54
59
|
export * from './types/WebSocketMessage';
|
|
55
60
|
export * from './utils/PhoneNumberUtil';
|
|
56
61
|
export * from './utils/string';
|