sip-connector 19.8.3 → 19.9.1
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 +0 -101
- package/dist/@SipConnector-DhKRV_I3.cjs +1 -0
- package/dist/{@SipConnector-BmkeKEDD.js → @SipConnector-LWYRHYnw.js} +597 -714
- package/dist/ApiManager/@ApiManager.d.ts +0 -1
- package/dist/ApiManager/constants.d.ts +3 -8
- package/dist/ApiManager/eventNames.d.ts +7 -5
- package/dist/ApiManager/index.d.ts +0 -1
- package/dist/ApiManager/types.d.ts +0 -6
- package/dist/AutoConnectorManager/@AutoConnectorManager.d.ts +3 -0
- package/dist/AutoConnectorManager/NotActiveCallSubscriber.d.ts +15 -0
- package/dist/AutoConnectorManager/PingServerIfNotActiveCallRequester.d.ts +1 -3
- package/dist/AutoConnectorManager/RegistrationFailedOutOfCallSubscriber.d.ts +1 -1
- package/dist/CallManager/@CallManager.d.ts +30 -15
- package/dist/CallManager/MCUSession.d.ts +0 -1
- package/dist/CallManager/RecvSession.d.ts +29 -0
- package/dist/CallManager/index.d.ts +0 -1
- package/dist/CallManager/types.d.ts +13 -31
- package/dist/SipConnector/@SipConnector.d.ts +1 -2
- package/dist/SipConnector/eventNames.d.ts +4 -2
- package/dist/__fixtures__/RTCPeerConnectionMock.d.ts +13 -17
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +131 -130
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/package.json +13 -5
- package/dist/@SipConnector-BHakZWEK.cjs +0 -1
- package/dist/CallManager/AbstractCallStrategy.d.ts +0 -54
- package/dist/CallManager/MCUCallStrategy.d.ts +0 -31
- package/dist/TransceiverManager/@TransceiverManager.d.ts +0 -70
- package/dist/TransceiverManager/index.d.ts +0 -1
- package/dist/TransceiverManager/types.d.ts +0 -11
|
@@ -26,7 +26,8 @@ export declare enum EHeader {
|
|
|
26
26
|
AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE",
|
|
27
27
|
AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT",
|
|
28
28
|
VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT",
|
|
29
|
-
TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION"
|
|
29
|
+
TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION",
|
|
30
|
+
AUDIO_ID = "X-WEBRTC-AUDIOID"
|
|
30
31
|
}
|
|
31
32
|
export declare enum EShareState {
|
|
32
33
|
AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT",
|
|
@@ -44,8 +45,7 @@ export declare enum EContentTypeReceived {
|
|
|
44
45
|
PARTICIPANT_STATE = "application/vinteo.webrtc.partstate",
|
|
45
46
|
NOTIFY = "application/vinteo.webrtc.notify",
|
|
46
47
|
SHARE_STATE = "application/vinteo.webrtc.sharedesktop",
|
|
47
|
-
MAIN_CAM = "application/vinteo.webrtc.maincam"
|
|
48
|
-
RESTART = "application/vinteo.webrtc.restart"
|
|
48
|
+
MAIN_CAM = "application/vinteo.webrtc.maincam"
|
|
49
49
|
}
|
|
50
50
|
export declare enum EContentTypeSent {
|
|
51
51
|
CHANNELS = "application/vinteo.webrtc.channels",
|
|
@@ -75,8 +75,3 @@ export declare enum EUseLicense {
|
|
|
75
75
|
VIDEO = "VIDEO",
|
|
76
76
|
AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION"
|
|
77
77
|
}
|
|
78
|
-
export declare enum ETracksDirection {
|
|
79
|
-
SENDRECV = "SENDRECV",
|
|
80
|
-
SENDONLY = "SENDONLY",
|
|
81
|
-
RECVONLY = "RECVONLY"
|
|
82
|
-
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { TypedEvents } from 'events-constructor';
|
|
2
2
|
import { EUseLicense, EEventsMainCAM } from './constants';
|
|
3
|
-
import { TChannels, TParametersModeratorsList, TParametersWebcast, TParametersConferenceParticipantTokenIssued
|
|
3
|
+
import { TChannels, TParametersModeratorsList, TParametersWebcast, TParametersConferenceParticipantTokenIssued } from './types';
|
|
4
4
|
export declare enum EEvent {
|
|
5
5
|
CHANNELS_NOTIFY = "channels:notify",
|
|
6
6
|
PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators",
|
|
7
7
|
PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators",
|
|
8
8
|
PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream",
|
|
9
9
|
PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators",
|
|
10
|
+
PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id",
|
|
10
11
|
PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants",
|
|
11
12
|
PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request",
|
|
12
13
|
PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request",
|
|
@@ -28,10 +29,9 @@ export declare enum EEvent {
|
|
|
28
29
|
AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream",
|
|
29
30
|
NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream",
|
|
30
31
|
MUST_STOP_PRESENTATION = "mustStopPresentation",
|
|
31
|
-
NEW_DTMF = "newDTMF"
|
|
32
|
-
RESTART = "restart"
|
|
32
|
+
NEW_DTMF = "newDTMF"
|
|
33
33
|
}
|
|
34
|
-
export declare const EVENT_NAMES: readonly ["participation:accepting-word-request", "participation:cancelling-word-request", "participant:move-request-to-stream", "channels:notify", "conference:participant-token-issued", "account:changed", "account:deleted", "webcast:started", "webcast:stopped", "participant:added-to-list-moderators", "participant:removed-from-list-moderators", "participant:move-request-to-spectators", "participant:move-request-to-participants", "channels", "enterRoom", "shareState", "main-cam-control", "useLicense", "admin-start-main-cam", "admin-stop-main-cam", "admin-start-mic", "admin-stop-mic", "admin-force-sync-media-state", "availableSecondRemoteStream", "notAvailableSecondRemoteStream", "mustStopPresentation", "newDTMF"
|
|
34
|
+
export declare const EVENT_NAMES: readonly ["participation:accepting-word-request", "participation:cancelling-word-request", "participant:move-request-to-stream", "channels:notify", "conference:participant-token-issued", "account:changed", "account:deleted", "webcast:started", "webcast:stopped", "participant:added-to-list-moderators", "participant:removed-from-list-moderators", "participant:move-request-to-spectators", "participant:move-request-to-spectators-with-audio-id", "participant:move-request-to-participants", "channels", "enterRoom", "shareState", "main-cam-control", "useLicense", "admin-start-main-cam", "admin-stop-main-cam", "admin-start-mic", "admin-stop-mic", "admin-force-sync-media-state", "availableSecondRemoteStream", "notAvailableSecondRemoteStream", "mustStopPresentation", "newDTMF"];
|
|
35
35
|
export type TEvent = (typeof EVENT_NAMES)[number];
|
|
36
36
|
export type TEventMap = {
|
|
37
37
|
'channels:notify': TChannels;
|
|
@@ -39,6 +39,9 @@ export type TEventMap = {
|
|
|
39
39
|
'participant:removed-from-list-moderators': TParametersModeratorsList;
|
|
40
40
|
'participant:move-request-to-stream': TParametersModeratorsList;
|
|
41
41
|
'participant:move-request-to-spectators': Record<string, never>;
|
|
42
|
+
'participant:move-request-to-spectators-with-audio-id': {
|
|
43
|
+
audioId: string;
|
|
44
|
+
};
|
|
42
45
|
'participant:move-request-to-participants': Record<string, never>;
|
|
43
46
|
'participation:accepting-word-request': TParametersModeratorsList;
|
|
44
47
|
'participation:cancelling-word-request': TParametersModeratorsList;
|
|
@@ -79,6 +82,5 @@ export type TEventMap = {
|
|
|
79
82
|
newDTMF: {
|
|
80
83
|
originator: string;
|
|
81
84
|
};
|
|
82
|
-
restart: TRestartData;
|
|
83
85
|
};
|
|
84
86
|
export type TEvents = TypedEvents<TEventMap>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { default as ApiManager } from './@ApiManager';
|
|
2
2
|
export { EContentTypeReceived, EContentTypeSent, EEventsMainCAM, EEventsMic, EEventsSyncMediaState, EHeader, EShareState, EUseLicense, } from './constants';
|
|
3
3
|
export type { TEvent as TApiEvent } from './eventNames';
|
|
4
|
-
export type { TRestartData } from './types';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ETracksDirection } from './constants';
|
|
2
1
|
export declare enum ECMDNotify {
|
|
3
2
|
CHANNELS = "channels",
|
|
4
3
|
WEBCAST_STARTED = "WebcastStarted",
|
|
@@ -98,8 +97,3 @@ export type TOptionsInfoMediaState = {
|
|
|
98
97
|
export type TOptionsExtraHeaders = {
|
|
99
98
|
extraHeaders?: string[];
|
|
100
99
|
};
|
|
101
|
-
export type TRestartData = {
|
|
102
|
-
tracksDirection: ETracksDirection;
|
|
103
|
-
audioTrackCount: number;
|
|
104
|
-
videoTrackCount: number;
|
|
105
|
-
};
|
|
@@ -17,6 +17,7 @@ declare class AutoConnectorManager {
|
|
|
17
17
|
private readonly canRetryOnError;
|
|
18
18
|
private readonly networkInterfacesSubscriber;
|
|
19
19
|
private readonly resumeFromSleepModeSubscriber;
|
|
20
|
+
private readonly notActiveCallSubscriber;
|
|
20
21
|
constructor({ connectionQueueManager, connectionManager, callManager, }: {
|
|
21
22
|
connectionQueueManager: ConnectionQueueManager;
|
|
22
23
|
connectionManager: ConnectionManager;
|
|
@@ -40,6 +41,8 @@ declare class AutoConnectorManager {
|
|
|
40
41
|
private handleLimitReached;
|
|
41
42
|
private handleSucceededAttempt;
|
|
42
43
|
private subscribeToConnectTriggers;
|
|
44
|
+
private subscribeToNotActiveCall;
|
|
45
|
+
private unsubscribeFromNotActiveCall;
|
|
43
46
|
private subscribeToHardwareTriggers;
|
|
44
47
|
private unsubscribeFromHardwareTriggers;
|
|
45
48
|
private stopPingRequester;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CallManager } from '../CallManager';
|
|
2
|
+
declare class NotActiveCallSubscriber {
|
|
3
|
+
private readonly callManager;
|
|
4
|
+
private disposers;
|
|
5
|
+
constructor({ callManager }: {
|
|
6
|
+
callManager: CallManager;
|
|
7
|
+
});
|
|
8
|
+
subscribe(parameters: {
|
|
9
|
+
onActive?: () => void;
|
|
10
|
+
onInactive: () => void;
|
|
11
|
+
}): void;
|
|
12
|
+
unsubscribe(): void;
|
|
13
|
+
private handleCallStatusChange;
|
|
14
|
+
}
|
|
15
|
+
export default NotActiveCallSubscriber;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { CallManager } from '../CallManager';
|
|
2
2
|
import { ConnectionManager } from '../ConnectionManager';
|
|
3
3
|
declare class PingServerIfNotActiveCallRequester {
|
|
4
|
-
private readonly callManager;
|
|
5
4
|
private readonly pingServerRequester;
|
|
6
|
-
private
|
|
5
|
+
private readonly notActiveCallSubscriber;
|
|
7
6
|
constructor({ connectionManager, callManager, }: {
|
|
8
7
|
connectionManager: ConnectionManager;
|
|
9
8
|
callManager: CallManager;
|
|
@@ -13,6 +12,5 @@ declare class PingServerIfNotActiveCallRequester {
|
|
|
13
12
|
}): void;
|
|
14
13
|
stop(): void;
|
|
15
14
|
private unsubscribeCallStatusChange;
|
|
16
|
-
private handleCallStatusChange;
|
|
17
15
|
}
|
|
18
16
|
export default PingServerIfNotActiveCallRequester;
|
|
@@ -3,9 +3,9 @@ import { ConnectionManager } from '../ConnectionManager';
|
|
|
3
3
|
import { ISubscriber } from './types';
|
|
4
4
|
declare class RegistrationFailedOutOfCallSubscriber implements ISubscriber {
|
|
5
5
|
private readonly connectionManager;
|
|
6
|
-
private readonly callManager;
|
|
7
6
|
private isRegistrationFailed;
|
|
8
7
|
private disposers;
|
|
8
|
+
private readonly notActiveCallSubscriber;
|
|
9
9
|
constructor({ connectionManager, callManager, }: {
|
|
10
10
|
connectionManager: ConnectionManager;
|
|
11
11
|
callManager: CallManager;
|
|
@@ -1,28 +1,43 @@
|
|
|
1
|
+
import { RTCSession } from '@krivega/jssip';
|
|
1
2
|
import { TEvents, TEventMap } from './eventNames';
|
|
2
|
-
import {
|
|
3
|
+
import { TStartCall, TCallConfiguration, TReplaceMediaStream, TAnswerToIncomingCall } from './types';
|
|
3
4
|
declare class CallManager {
|
|
4
5
|
readonly events: TEvents;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
protected isPendingCall: boolean;
|
|
7
|
+
protected isPendingAnswer: boolean;
|
|
8
|
+
protected rtcSession?: RTCSession;
|
|
9
|
+
protected remoteStreams: Record<string, MediaStream>;
|
|
10
|
+
protected readonly callConfiguration: TCallConfiguration;
|
|
11
|
+
private readonly remoteStreamsManager;
|
|
12
|
+
private readonly mcuSession;
|
|
13
|
+
constructor();
|
|
7
14
|
get requested(): boolean;
|
|
8
|
-
get connection():
|
|
9
|
-
get isCallActive():
|
|
10
|
-
getEstablishedRTCSession:
|
|
15
|
+
get connection(): RTCPeerConnection | undefined;
|
|
16
|
+
get isCallActive(): boolean;
|
|
17
|
+
getEstablishedRTCSession: () => RTCSession | undefined;
|
|
11
18
|
on<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
|
|
12
19
|
onRace<T extends keyof TEventMap>(eventNames: T[], handler: (data: TEventMap[T], eventName: string) => void): () => void;
|
|
13
20
|
once<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
|
|
14
21
|
onceRace<T extends keyof TEventMap>(eventNames: T[], handler: (data: TEventMap[T], eventName: string) => void): () => void;
|
|
15
22
|
wait<T extends keyof TEventMap>(eventName: T): Promise<TEventMap[T]>;
|
|
16
23
|
off<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): void;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
startCall: TStartCall;
|
|
25
|
+
endCall(): Promise<void>;
|
|
26
|
+
answerToIncomingCall: TAnswerToIncomingCall;
|
|
27
|
+
getCallConfiguration(): {
|
|
28
|
+
answer?: boolean;
|
|
29
|
+
number?: string;
|
|
30
|
+
};
|
|
31
|
+
getRemoteStreams(): MediaStream[] | undefined;
|
|
32
|
+
replaceMediaStream(mediaStream: Parameters<TReplaceMediaStream>[0], options?: Parameters<TReplaceMediaStream>[1]): Promise<void>;
|
|
33
|
+
restartIce(options?: {
|
|
34
|
+
useUpdate?: boolean;
|
|
35
|
+
extraHeaders?: string[];
|
|
36
|
+
rtcOfferConstraints?: RTCOfferOptions;
|
|
37
|
+
sendEncodings?: RTCRtpEncodingParameters[];
|
|
38
|
+
degradationPreference?: RTCDegradationPreference;
|
|
39
|
+
}): Promise<boolean>;
|
|
40
|
+
private readonly reset;
|
|
26
41
|
private subscribeCallStatusChange;
|
|
27
42
|
private maybeTriggerCallStatus;
|
|
28
43
|
}
|
|
@@ -24,7 +24,6 @@ export declare class MCUSession implements IMCUSession {
|
|
|
24
24
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
25
25
|
degradationPreference?: RTCDegradationPreference;
|
|
26
26
|
}): Promise<boolean>;
|
|
27
|
-
addTransceiver(kind: 'audio' | 'video', options?: RTCRtpTransceiverInit): Promise<RTCRtpTransceiver>;
|
|
28
27
|
private readonly handleCall;
|
|
29
28
|
private subscribeToSessionEvents;
|
|
30
29
|
private unsubscribeFromSessionEvents;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type TConferenceNumber = string;
|
|
2
|
+
type TSendOfferParams = {
|
|
3
|
+
quality: 'low' | 'medium' | 'high';
|
|
4
|
+
audioChannel: string;
|
|
5
|
+
};
|
|
6
|
+
type TConfig = Pick<TSendOfferParams, 'quality' | 'audioChannel'> & {
|
|
7
|
+
pcConfig?: RTCConfiguration;
|
|
8
|
+
};
|
|
9
|
+
type TTools = {
|
|
10
|
+
sendOffer: (params: TSendOfferParams & {
|
|
11
|
+
conferenceNumber: TConferenceNumber;
|
|
12
|
+
}, offer: RTCSessionDescriptionInit) => Promise<RTCSessionDescription>;
|
|
13
|
+
};
|
|
14
|
+
declare class RecvSession {
|
|
15
|
+
private readonly config;
|
|
16
|
+
private readonly tools;
|
|
17
|
+
private readonly connection;
|
|
18
|
+
constructor(config: TConfig, tools: TTools);
|
|
19
|
+
get settings(): TConfig;
|
|
20
|
+
get peerConnection(): RTCPeerConnection;
|
|
21
|
+
close(): void;
|
|
22
|
+
call(conferenceNumber: TConferenceNumber): Promise<void>;
|
|
23
|
+
private createOffer;
|
|
24
|
+
private setRemoteDescription;
|
|
25
|
+
private waitForTracks;
|
|
26
|
+
private addTransceivers;
|
|
27
|
+
private addRecvOnlyTransceiver;
|
|
28
|
+
}
|
|
29
|
+
export default RecvSession;
|
|
@@ -4,5 +4,4 @@ export type { TEventMap } from './eventNames';
|
|
|
4
4
|
export { EEvent as ECallEvent } from './eventNames';
|
|
5
5
|
export type { TEvent as TCallEvent, TEvents as TCallEvents } from './eventNames';
|
|
6
6
|
export { default as hasCanceledCallError } from './hasCanceledCallError';
|
|
7
|
-
export { MCUCallStrategy } from './MCUCallStrategy';
|
|
8
7
|
export type { TCustomError, TGetServerUrl } from './types';
|
|
@@ -37,43 +37,26 @@ export type TCallConfiguration = {
|
|
|
37
37
|
answer?: boolean;
|
|
38
38
|
number?: string;
|
|
39
39
|
};
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
replaceMediaStream: (mediaStream: MediaStream, options?: {
|
|
52
|
-
deleteExisting?: boolean;
|
|
53
|
-
addMissing?: boolean;
|
|
54
|
-
forceRenegotiation?: boolean;
|
|
55
|
-
contentHint?: TContentHint;
|
|
56
|
-
degradationPreference?: RTCDegradationPreference;
|
|
57
|
-
sendEncodings?: RTCRtpEncodingParameters[];
|
|
58
|
-
onAddedTransceiver?: TOnAddedTransceiver;
|
|
59
|
-
}) => Promise<void>;
|
|
60
|
-
restartIce: (options?: {
|
|
61
|
-
extraHeaders?: string[];
|
|
62
|
-
useUpdate?: boolean;
|
|
63
|
-
rtcOfferConstraints?: RTCOfferOptions;
|
|
64
|
-
sendEncodings?: RTCRtpEncodingParameters[];
|
|
65
|
-
degradationPreference?: RTCDegradationPreference;
|
|
66
|
-
}) => Promise<boolean>;
|
|
67
|
-
}
|
|
40
|
+
export type TStartCall = (ua: UA, getSipServerUrl: TGetServerUrl, params: TParamsCall) => Promise<RTCPeerConnection>;
|
|
41
|
+
export type TReplaceMediaStream = (mediaStream: MediaStream, options?: {
|
|
42
|
+
deleteExisting?: boolean;
|
|
43
|
+
addMissing?: boolean;
|
|
44
|
+
forceRenegotiation?: boolean;
|
|
45
|
+
contentHint?: TContentHint;
|
|
46
|
+
degradationPreference?: RTCDegradationPreference;
|
|
47
|
+
sendEncodings?: RTCRtpEncodingParameters[];
|
|
48
|
+
onAddedTransceiver?: TOnAddedTransceiver;
|
|
49
|
+
}) => Promise<void>;
|
|
50
|
+
export type TAnswerToIncomingCall = (extractIncomingRTCSession: () => RTCSession, params: TParamsAnswerToIncomingCall) => Promise<RTCPeerConnection>;
|
|
68
51
|
export interface IMCUSession {
|
|
69
52
|
readonly connection: RTCPeerConnection | undefined;
|
|
70
53
|
readonly isCallActive: boolean;
|
|
71
54
|
getEstablishedRTCSession: () => RTCSession | undefined;
|
|
72
|
-
startCall:
|
|
55
|
+
startCall: TStartCall;
|
|
73
56
|
endCall: () => Promise<void>;
|
|
74
57
|
answerToIncomingCall: (incomingRTCSession: RTCSession, params: TParamsAnswerToIncomingCall) => Promise<RTCPeerConnection>;
|
|
75
58
|
getRemoteTracks: () => MediaStreamTrack[] | undefined;
|
|
76
|
-
replaceMediaStream:
|
|
59
|
+
replaceMediaStream: TReplaceMediaStream;
|
|
77
60
|
restartIce: (options?: {
|
|
78
61
|
useUpdate?: boolean;
|
|
79
62
|
extraHeaders?: string[];
|
|
@@ -81,6 +64,5 @@ export interface IMCUSession {
|
|
|
81
64
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
82
65
|
degradationPreference?: RTCDegradationPreference;
|
|
83
66
|
}) => Promise<boolean>;
|
|
84
|
-
addTransceiver: (kind: 'audio' | 'video', options?: RTCRtpTransceiverInit) => Promise<RTCRtpTransceiver>;
|
|
85
67
|
}
|
|
86
68
|
export {};
|
|
@@ -6,7 +6,6 @@ import { ConnectionQueueManager } from '../ConnectionQueueManager';
|
|
|
6
6
|
import { IncomingCallManager } from '../IncomingCallManager';
|
|
7
7
|
import { PresentationManager, TContentHint, TOnAddedTransceiver } from '../PresentationManager';
|
|
8
8
|
import { StatsManager } from '../StatsManager';
|
|
9
|
-
import { TransceiverManager } from '../TransceiverManager';
|
|
10
9
|
import { VideoSendingBalancerManager } from '../VideoSendingBalancerManager';
|
|
11
10
|
import { TJsSIP } from '../types';
|
|
12
11
|
import { IBalancerOptions } from '../VideoSendingBalancer';
|
|
@@ -22,7 +21,6 @@ declare class SipConnector {
|
|
|
22
21
|
readonly presentationManager: PresentationManager;
|
|
23
22
|
readonly statsManager: StatsManager;
|
|
24
23
|
readonly videoSendingBalancerManager: VideoSendingBalancerManager;
|
|
25
|
-
readonly transceiverManager: TransceiverManager;
|
|
26
24
|
private readonly preferredMimeTypesVideoCodecs?;
|
|
27
25
|
private readonly excludeMimeTypesVideoCodecs?;
|
|
28
26
|
constructor({ JsSIP }: {
|
|
@@ -108,6 +106,7 @@ declare class SipConnector {
|
|
|
108
106
|
askPermissionToStartPresentationP2P(...args: Parameters<ApiManager['askPermissionToStartPresentationP2P']>): Promise<void>;
|
|
109
107
|
askPermissionToStartPresentation(...args: Parameters<ApiManager['askPermissionToStartPresentation']>): Promise<void>;
|
|
110
108
|
askPermissionToEnableCam(...args: Parameters<ApiManager['askPermissionToEnableCam']>): Promise<void>;
|
|
109
|
+
private subscribeDisconnectedFromOutOfCall;
|
|
111
110
|
private setCodecPreferences;
|
|
112
111
|
private subscribe;
|
|
113
112
|
private readonly bridgeEvents;
|
|
@@ -7,11 +7,13 @@ import { TEventMap as TIncomingCallManagerEventMap } from '../IncomingCallManage
|
|
|
7
7
|
import { TEventMap as TPresentationManagerEventMap } from '../PresentationManager/eventNames';
|
|
8
8
|
import { TEventMap as TStatsManagerEventMap } from '../StatsPeerConnection/eventNames';
|
|
9
9
|
import { TEventMap as TVideoBalancerManagerEventMap } from '../VideoSendingBalancerManager/eventNames';
|
|
10
|
-
export declare const EVENT_NAMES: readonly ("auto-connect:before-attempt" | "auto-connect:success" | "auto-connect:failed-all-attempts" | "auto-connect:cancelled-attempts" | "auto-connect:changed-attempt-status" | "auto-connect:stop-attempts-by-error" | "auto-connect:limit-reached-attempts" | "connection:connecting" | "connection:connected" | "connection:disconnected" | "connection:disconnecting" | "connection:newRTCSession" | "connection:registered" | "connection:unregistered" | "connection:registrationFailed" | "connection:newMessage" | "connection:sipEvent" | "connection:connect-started" | "connection:connect-succeeded" | "connection:connected-with-configuration" | "connection:connect-failed" | "connection:connect-parameters-resolve-success" | "connection:connect-parameters-resolve-failed" | "call:peerconnection" | "call:connecting" | "call:sending" | "call:progress" | "call:accepted" | "call:confirmed" | "call:ended" | "call:failed" | "call:newDTMF" | "call:newInfo" | "call:reinvite" | "call:update" | "call:refer" | "call:replaces" | "call:sdp" | "call:icecandidate" | "call:getusermediafailed" | "call:peerconnection:createofferfailed" | "call:peerconnection:createanswerfailed" | "call:peerconnection:setlocaldescriptionfailed" | "call:peerconnection:setremotedescriptionfailed" | "call:presentation:start" | "call:presentation:started" | "call:presentation:end" | "call:presentation:ended" | "call:presentation:failed" | "call:peerconnection:confirmed" | "call:peerconnection:ontrack" | "call:ended:fromserver" | "call:call-status-changed" | "api:channels:notify" | "api:participant:added-to-list-moderators" | "api:participant:removed-from-list-moderators" | "api:participant:move-request-to-stream" | "api:participant:move-request-to-spectators" | "api:participant:move-request-to-participants" | "api:participation:accepting-word-request" | "api:participation:cancelling-word-request" | "api:webcast:started" | "api:webcast:stopped" | "api:account:changed" | "api:account:deleted" | "api:conference:participant-token-issued" | "api:channels" | "api:enterRoom" | "api:shareState" | "api:main-cam-control" | "api:useLicense" | "api:admin-start-main-cam" | "api:admin-stop-main-cam" | "api:admin-start-mic" | "api:admin-stop-mic" | "api:admin-force-sync-media-state" | "api:availableSecondRemoteStream" | "api:notAvailableSecondRemoteStream" | "api:mustStopPresentation" | "api:newDTMF" | "
|
|
10
|
+
export declare const EVENT_NAMES: readonly [...("auto-connect:before-attempt" | "auto-connect:success" | "auto-connect:failed-all-attempts" | "auto-connect:cancelled-attempts" | "auto-connect:changed-attempt-status" | "auto-connect:stop-attempts-by-error" | "auto-connect:limit-reached-attempts" | "connection:connecting" | "connection:connected" | "connection:disconnected" | "connection:disconnecting" | "connection:newRTCSession" | "connection:registered" | "connection:unregistered" | "connection:registrationFailed" | "connection:newMessage" | "connection:sipEvent" | "connection:connect-started" | "connection:connect-succeeded" | "connection:connected-with-configuration" | "connection:connect-failed" | "connection:connect-parameters-resolve-success" | "connection:connect-parameters-resolve-failed" | "call:peerconnection" | "call:connecting" | "call:sending" | "call:progress" | "call:accepted" | "call:confirmed" | "call:ended" | "call:failed" | "call:newDTMF" | "call:newInfo" | "call:reinvite" | "call:update" | "call:refer" | "call:replaces" | "call:sdp" | "call:icecandidate" | "call:getusermediafailed" | "call:peerconnection:createofferfailed" | "call:peerconnection:createanswerfailed" | "call:peerconnection:setlocaldescriptionfailed" | "call:peerconnection:setremotedescriptionfailed" | "call:presentation:start" | "call:presentation:started" | "call:presentation:end" | "call:presentation:ended" | "call:presentation:failed" | "call:peerconnection:confirmed" | "call:peerconnection:ontrack" | "call:ended:fromserver" | "call:call-status-changed" | "api:channels:notify" | "api:participant:added-to-list-moderators" | "api:participant:removed-from-list-moderators" | "api:participant:move-request-to-stream" | "api:participant:move-request-to-spectators" | "api:participant:move-request-to-spectators-with-audio-id" | "api:participant:move-request-to-participants" | "api:participation:accepting-word-request" | "api:participation:cancelling-word-request" | "api:webcast:started" | "api:webcast:stopped" | "api:account:changed" | "api:account:deleted" | "api:conference:participant-token-issued" | "api:channels" | "api:enterRoom" | "api:shareState" | "api:main-cam-control" | "api:useLicense" | "api:admin-start-main-cam" | "api:admin-stop-main-cam" | "api:admin-start-mic" | "api:admin-stop-mic" | "api:admin-force-sync-media-state" | "api:availableSecondRemoteStream" | "api:notAvailableSecondRemoteStream" | "api:mustStopPresentation" | "api:newDTMF" | "incoming-call:incomingCall" | "incoming-call:declinedIncomingCall" | "incoming-call:terminatedIncomingCall" | "incoming-call:failedIncomingCall" | "presentation:presentation:start" | "presentation:presentation:started" | "presentation:presentation:end" | "presentation:presentation:ended" | "presentation:presentation:failed" | "stats:collected" | "video-balancer:balancing-scheduled" | "video-balancer:balancing-started" | "video-balancer:balancing-stopped" | "video-balancer:parameters-updated")[], "disconnected-from-out-of-call"];
|
|
11
11
|
export type TEvent = (typeof EVENT_NAMES)[number];
|
|
12
12
|
type PrefixedEventMap<T extends Record<string, unknown>, Prefix extends string> = {
|
|
13
13
|
[K in keyof T as `${Prefix}:${string & K}`]: T[K];
|
|
14
14
|
};
|
|
15
|
-
export type TEventMap = PrefixedEventMap<TAutoConnectorManagerEventMap, 'auto-connect'> & PrefixedEventMap<TConnectionManagerEventMap, 'connection'> & PrefixedEventMap<TCallManagerEventMap, 'call'> & PrefixedEventMap<TApiManagerEventMap, 'api'> & PrefixedEventMap<TIncomingCallManagerEventMap, 'incoming-call'> & PrefixedEventMap<TPresentationManagerEventMap, 'presentation'> & PrefixedEventMap<TStatsManagerEventMap, 'stats'> & PrefixedEventMap<TVideoBalancerManagerEventMap, 'video-balancer'
|
|
15
|
+
export type TEventMap = PrefixedEventMap<TAutoConnectorManagerEventMap, 'auto-connect'> & PrefixedEventMap<TConnectionManagerEventMap, 'connection'> & PrefixedEventMap<TCallManagerEventMap, 'call'> & PrefixedEventMap<TApiManagerEventMap, 'api'> & PrefixedEventMap<TIncomingCallManagerEventMap, 'incoming-call'> & PrefixedEventMap<TPresentationManagerEventMap, 'presentation'> & PrefixedEventMap<TStatsManagerEventMap, 'stats'> & PrefixedEventMap<TVideoBalancerManagerEventMap, 'video-balancer'> & {
|
|
16
|
+
'disconnected-from-out-of-call': Record<string, never>;
|
|
17
|
+
};
|
|
16
18
|
export type TEvents = TypedEvents<TEventMap>;
|
|
17
19
|
export {};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MediaStreamTrackMock } from 'webrtc-mock';
|
|
2
2
|
import { default as RTCRtpSenderMock } from './RTCRtpSenderMock';
|
|
3
3
|
import { RTCPeerConnectionDeprecated } from '@krivega/jssip';
|
|
4
|
-
import { MediaStreamTrackMock } from 'webrtc-mock';
|
|
5
4
|
export declare enum EEvent {
|
|
6
5
|
TRACK = "track"
|
|
7
6
|
}
|
|
8
|
-
declare
|
|
9
|
-
declare class RTCPeerConnectionMock implements RTCPeerConnectionDeprecated {
|
|
7
|
+
declare class RTCPeerConnectionMock extends EventTarget implements RTCPeerConnectionDeprecated {
|
|
10
8
|
senders: RTCRtpSender[];
|
|
11
9
|
receivers: RTCRtpReceiver[];
|
|
12
10
|
canTrickleIceCandidates: boolean | null;
|
|
@@ -33,34 +31,32 @@ declare class RTCPeerConnectionMock implements RTCPeerConnectionDeprecated {
|
|
|
33
31
|
remoteDescription: RTCSessionDescription | null;
|
|
34
32
|
sctp: null;
|
|
35
33
|
signalingState: RTCSignalingState;
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
close: jest.Mock<any, any, any>;
|
|
35
|
+
setLocalDescription: jest.Mock<Promise<void>, [_description: RTCSessionDescriptionInit], any>;
|
|
36
|
+
setRemoteDescription: jest.Mock<Promise<void>, [_description: RTCSessionDescriptionInit], any>;
|
|
37
|
+
addTransceiver: jest.Mock<RTCRtpTransceiver, [_trackOrKind: string | MediaStreamTrack, _init?: RTCRtpTransceiverInit | undefined], any>;
|
|
38
|
+
createOffer: {
|
|
39
|
+
(options?: RTCOfferOptions): Promise<RTCSessionDescriptionInit>;
|
|
40
|
+
(successCallback: RTCSessionDescriptionCallback, failureCallback: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise<void>;
|
|
41
|
+
};
|
|
42
|
+
constructor(_configuration?: RTCConfiguration, tracks?: MediaStreamTrackMock[]);
|
|
38
43
|
getRemoteStreams(): MediaStream[];
|
|
39
44
|
addIceCandidate(_candidate: RTCIceCandidate | RTCIceCandidateInit): Promise<void>;
|
|
40
|
-
addTransceiver(_trackOrKind: MediaStreamTrack | string, _init?: RTCRtpTransceiverInit): RTCRtpTransceiver;
|
|
41
|
-
close(): void;
|
|
42
45
|
restartIce(): void;
|
|
43
46
|
createAnswer(options?: RTCAnswerOptions): Promise<RTCSessionDescriptionInit>;
|
|
44
47
|
createAnswer(successCallback: RTCSessionDescriptionCallback, failureCallback: RTCPeerConnectionErrorCallback): Promise<void>;
|
|
45
48
|
createDataChannel(_label: string, _dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
|
|
46
|
-
createOffer(options?: RTCOfferOptions): Promise<RTCSessionDescriptionInit>;
|
|
47
|
-
createOffer(successCallback: RTCSessionDescriptionCallback, failureCallback: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise<void>;
|
|
48
49
|
getConfiguration(): RTCConfiguration;
|
|
49
50
|
getIdentityAssertion(): Promise<string>;
|
|
50
51
|
getStats(_selector?: MediaStreamTrack | null): Promise<RTCStatsReport>;
|
|
51
52
|
getTransceivers(): RTCRtpTransceiver[];
|
|
52
53
|
removeTrack(_sender: RTCRtpSender): void;
|
|
53
54
|
setConfiguration(_configuration: RTCConfiguration): void;
|
|
54
|
-
setLocalDescription(_description: RTCSessionDescriptionInit): Promise<void>;
|
|
55
|
-
setRemoteDescription(_description: RTCSessionDescriptionInit): Promise<void>;
|
|
56
|
-
addEventListener<K extends keyof RTCPeerConnectionEventMap>(type: K, listener: (this: RTCPeerConnection, event_: RTCPeerConnectionEventMap[K]) => unknown, options?: AddEventListenerOptions | boolean): void;
|
|
57
|
-
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: AddEventListenerOptions | boolean): void;
|
|
58
|
-
removeEventListener<K extends keyof RTCPeerConnectionEventMap>(type: K, listener: (this: RTCPeerConnection, event_: RTCPeerConnectionEventMap[K]) => unknown, options?: EventListenerOptions | boolean): void;
|
|
59
|
-
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: EventListenerOptions | boolean): void;
|
|
60
|
-
dispatchEvent(_event: Event): boolean;
|
|
61
55
|
getReceivers: () => RTCRtpReceiver[];
|
|
62
56
|
getSenders: () => RTCRtpSender[];
|
|
63
57
|
addTrack: (track: MediaStreamTrack, ..._streams: MediaStream[]) => RTCRtpSenderMock;
|
|
64
58
|
addTrackWithMid: (track: MediaStreamTrack, mid?: string) => RTCRtpSenderMock;
|
|
59
|
+
dispatchTrack(kind: 'audio' | 'video'): void;
|
|
60
|
+
private dispatchTrackInternal;
|
|
65
61
|
}
|
|
66
62
|
export default RTCPeerConnectionMock;
|
package/dist/doMock.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("node:events"),U=require("@krivega/jssip/lib/NameAddrHeader"),H=require("@krivega/jssip/lib/URI"),q=require("@krivega/jssip/lib/SIPMessage"),a=require("@krivega/jssip"),f=require("webrtc-mock"),S=require("events-constructor"),D=require("./@SipConnector-BHakZWEK.cjs");class N extends q.IncomingRequest{headers;constructor(e){super(),this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)??""}}const G="incomingCall",x="declinedIncomingCall",z="failedIncomingCall",Y="terminatedIncomingCall",y="connecting",j="connected",B="disconnected",K="newRTCSession",J="registered",$="unregistered",Q="registrationFailed",X="newMessage",Z="sipEvent",ee="availableSecondRemoteStream",te="notAvailableSecondRemoteStream",re="mustStopPresentation",ne="shareState",oe="enterRoom",ie="useLicense",se="peerconnection:confirmed",ae="peerconnection:ontrack",ce="channels",de="channels:notify",Ee="ended:fromserver",he="main-cam-control",ue="admin-stop-main-cam",me="admin-start-main-cam",le="admin-stop-mic",pe="admin-start-mic",ge="admin-force-sync-media-state",_e="participant:added-to-list-moderators",Te="participant:removed-from-list-moderators",Ie="participant:move-request-to-stream",Se="participant:move-request-to-spectators",Ne="participant:move-request-to-participants",we="participation:accepting-word-request",Ce="participation:cancelling-word-request",Re="webcast:started",fe="webcast:stopped",Ae="account:changed",Me="account:deleted",Oe="conference:participant-token-issued",Pe="ended",ve="sending",De="reinvite",ye="replaces",Le="refer",Fe="progress",We="accepted",be="confirmed",ke="peerconnection",Ve="failed",Ue="muted",He="unmuted",qe="newDTMF",Ge="newInfo",xe="hold",ze="unhold",Ye="update",je="sdp",Be="icecandidate",Ke="getusermediafailed",Je="peerconnection:createofferfailed",$e="peerconnection:createanswerfailed",Qe="peerconnection:setlocaldescriptionfailed",Xe="peerconnection:setremotedescriptionfailed",Ze="presentation:start",et="presentation:started",tt="presentation:end",rt="presentation:ended",nt="presentation:failed",ot=[G,x,Y,z,we,Ce,Ie,de,Oe,Ae,Me,Re,fe,_e,Te],L=[y,j,B,K,J,$,Q,X,Z],it=[ee,te,re,ne,oe,ie,se,ae,ce,Ee,he,me,ue,le,pe,ge,Se,Ne],_=[Pe,y,ve,De,ye,Le,Fe,We,be,ke,Ve,Ue,He,qe,Ge,xe,ze,Ye,je,Be,Ke,Je,$e,Qe,Xe,Ze,et,tt,rt,nt];[...L,...ot];[..._,...it];class st{originator;connection;events;remote_identity;mutedOptions={audio:!1,video:!1};constructor({originator:e="local",eventHandlers:t,remoteIdentity:r}){this.originator=e,this.events=new S.Events(_),this.initEvents(t),this.remote_identity=r}get contact(){throw new Error("Method not implemented.")}get direction(){throw new Error("Method not implemented.")}get local_identity(){throw new Error("Method not implemented.")}get start_time(){throw new Error("Method not implemented.")}get end_time(){throw new Error("Method not implemented.")}get status(){throw new Error("Method not implemented.")}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}set data(e){throw new Error("Method not implemented.")}isInProgress(){throw new Error("Method not implemented.")}isEnded(){throw new Error("Method not implemented.")}isReadyToReOffer(){throw new Error("Method not implemented.")}answer(e){throw new Error("Method not implemented.")}terminate(e){throw new Error("Method not implemented.")}async sendInfo(e,t,r){throw new Error("Method not implemented.")}hold(e,t){throw new Error("Method not implemented.")}unhold(e,t){throw new Error("Method not implemented.")}async renegotiate(e,t){throw new Error("Method not implemented.")}isOnHold(){throw new Error("Method not implemented.")}mute(e){throw new Error("Method not implemented.")}unmute(e){throw new Error("Method not implemented.")}isMuted(){throw new Error("Method not implemented.")}refer(e,t){throw new Error("Method not implemented.")}resetLocalMedia(){throw new Error("Method not implemented.")}async replaceMediaStream(e,t){throw new Error("Method not implemented.")}addListener(e,t){throw new Error("Method not implemented.")}once(e,t){throw new Error("Method not implemented.")}removeListener(e,t){throw new Error("Method not implemented.")}off(e,t){return this.events.off(e,t),this}removeAllListeners(e){return console.warn("Method not implemented. Event:",e),this}setMaxListeners(e){throw new Error("Method not implemented.")}getMaxListeners(){throw new Error("Method not implemented.")}listeners(e){throw new Error("Method not implemented.")}rawListeners(e){throw new Error("Method not implemented.")}emit(e,...t){throw new Error("Method not implemented.")}listenerCount(e){throw new Error("Method not implemented.")}prependListener(e,t){throw new Error("Method not implemented.")}prependOnceListener(e,t){throw new Error("Method not implemented.")}eventNames(){throw new Error("Method not implemented.")}initEvents(e){e&&Object.entries(e).forEach(([t,r])=>{this.on(t,r)})}on(e,t){return _.includes(e)&&this.events.on(e,t),this}trigger(e,t){this.events.trigger(e,t)}sendDTMF(){this.trigger("newDTMF",{originator:this.originator})}async startPresentation(e){return this.trigger("presentation:start",e),this.trigger("presentation:started",e),e}async stopPresentation(e){return this.trigger("presentation:end",e),this.trigger("presentation:ended",e),e}isEstablished(){return!0}}class A{stats=new Map().set("codec",{mimeType:"video/h264"});dtmf=null;track=null;transport=null;transform=null;parameters={encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}};parametersGets;constructor({track:e}={}){this.track=e??null}async getStats(){return this.stats}async replaceTrack(e){this.track=e??null}async setParameters(e){if(e!==this.parametersGets)throw new Error("Failed to execute 'setParameters' on 'RTCRtpSender': Read-only field modified in setParameters().");const{transactionId:t}=this.parameters;this.parameters={...this.parameters,...e,transactionId:`${Number(t)+1}`}}getParameters(){return this.parametersGets={...this.parameters},this.parametersGets}setStreams(){throw new Error("Method not implemented.")}}class M{currentDirection="sendrecv";direction="sendrecv";mid=null;receiver;sender;stopped=!1;constructor(e){this.sender=e}setCodecPreferences(e){}stop(){}}const at=["track"];class ct{senders=[];receivers=[];canTrickleIceCandidates;connectionState;currentLocalDescription;currentRemoteDescription;iceConnectionState;iceGatheringState;idpErrorInfo;idpLoginUrl;localDescription;onconnectionstatechange;ondatachannel;onicecandidate;onicecandidateerror=null;oniceconnectionstatechange;onicegatheringstatechange;onnegotiationneeded;onsignalingstatechange;ontrack;peerIdentity=void 0;pendingLocalDescription;pendingRemoteDescription;remoteDescription;sctp=null;signalingState;events;constructor(e,t){this.events=new S.Events(at),this.receivers=t.map(r=>({track:r}))}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(e){throw new Error("Method not implemented.")}addTransceiver(e,t){throw new Error("Method not implemented.")}close(){throw new Error("Method not implemented.")}restartIce(){throw new Error("Method not implemented.")}async createAnswer(e,t){throw new Error("Method not implemented.")}createDataChannel(e,t){throw new Error("Method not implemented.")}async createOffer(e,t,r){throw new Error("Method not implemented.")}getConfiguration(){throw new Error("Method not implemented.")}async getIdentityAssertion(){throw new Error("Method not implemented.")}async getStats(e){throw new Error("Method not implemented.")}getTransceivers(){throw new Error("Method not implemented.")}removeTrack(e){throw new Error("Method not implemented.")}setConfiguration(e){throw new Error("Method not implemented.")}async setLocalDescription(e){throw new Error("Method not implemented.")}async setRemoteDescription(e){throw new Error("Method not implemented.")}addEventListener(e,t,r){this.events.on(e,t)}removeEventListener(e,t,r){this.events.off(e,t)}dispatchEvent(e){throw new Error("Method not implemented.")}getReceivers=()=>this.receivers;getSenders=()=>this.senders;addTrack=(e,...t)=>{const r=new A({track:e}),n=new M(r);return n.mid=e.kind==="audio"?"0":"1",this.senders.push(r),this.events.trigger("track",{track:e,transceiver:n}),r};addTrackWithMid=(e,t)=>{const r=new A({track:e}),n=new M(r);return t===void 0?n.mid=e.kind==="audio"?"0":"1":n.mid=t,this.senders.push(r),this.events.trigger("track",{track:e,transceiver:n}),r}}function dt(o){const e=o.match(/(purgatory)|[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const O=400,F="777",Et=o=>o.getVideoTracks().length>0;class s extends st{static presentationError;static startPresentationError;static countStartPresentationError=Number.POSITIVE_INFINITY;static countStartsPresentation=0;url;status_code;answer=jest.fn(({mediaStream:e})=>{if(this.originator!=="remote")throw new Error("answer available only for remote sessions");this.initPeerconnection(e),setTimeout(()=>{this.trigger("connecting"),setTimeout(()=>{this.trigger("accepted")},100),setTimeout(()=>{this.trigger("confirmed")},200)},O)});replaceMediaStream=jest.fn(async e=>{});_isReadyToReOffer=jest.fn(()=>!0);addTransceiver=jest.fn((e,t)=>({}));restartIce=jest.fn(async e=>!0);isEndedInner=!1;delayStartPresentation=0;timeoutStartPresentation;timeoutConnect;timeoutNewInfo;timeoutAccepted;timeoutConfirmed;constructor({eventHandlers:e,originator:t,remoteIdentity:r=new a.NameAddrHeader(new a.URI("sip","caller1","test1.com",5060),"Test Caller 1"),delayStartPresentation:n=0}){super({originator:t,eventHandlers:e,remoteIdentity:r}),this.delayStartPresentation=n}static get C(){return a.SessionStatus}static setPresentationError(e){this.presentationError=e}static resetPresentationError(){this.presentationError=void 0}static setStartPresentationError(e,{count:t=Number.POSITIVE_INFINITY}={}){this.startPresentationError=e,this.countStartPresentationError=t}static resetStartPresentationError(){this.startPresentationError=void 0,this.countStartPresentationError=Number.POSITIVE_INFINITY,this.countStartsPresentation=0}startPresentation=async e=>(s.countStartsPresentation+=1,new Promise((t,r)=>{this.timeoutStartPresentation=setTimeout(()=>{if(s.presentationError){this.trigger("presentation:start",e),this.trigger("presentation:failed",e),r(s.presentationError);return}if(s.startPresentationError&&s.countStartsPresentation<s.countStartPresentationError){this.trigger("presentation:start",e),this.trigger("presentation:failed",e),r(s.startPresentationError);return}t(super.startPresentation(e))},this.delayStartPresentation)}));stopPresentation=async e=>{if(s.presentationError)throw this.trigger("presentation:end",e),this.trigger("presentation:failed",e),s.presentationError;return super.stopPresentation(e)};initPeerconnection(e){return e?(this.createPeerconnection(e),!0):!1}createPeerconnection(e){const t=f.createAudioMediaStreamTrackMock();t.id="mainaudio1";const r=[t];if(Et(e)){const c=f.createVideoMediaStreamTrackMock();c.id="mainvideo1",r.push(c)}this.connection=new ct(void 0,r),this.addStream(e),this.trigger("peerconnection",{peerconnection:this.connection})}connect(e,{mediaStream:t}={}){const r=dt(e);return this.initPeerconnection(t),this.timeoutConnect=setTimeout(()=>{e.includes(F)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:"Rejected"}):(this.trigger("connecting"),this.timeoutNewInfo=setTimeout(()=>{this.newInfo({originator:D.Originator.REMOTE,request:{getHeader:n=>n==="content-type"?"application/vinteo.webrtc.roomname":n==="x-webrtc-enter-room"?r:n==="x-webrtc-participant-name"?"Test Caller 1":""}})},100),this.timeoutAccepted=setTimeout(()=>{this.trigger("accepted")},200),this.timeoutConfirmed=setTimeout(()=>{this.trigger("confirmed")},300))},O),this.connection}terminate({status_code:e,cause:t}={}){return this.status_code=e,this.trigger("ended",{status_code:e,cause:t,originator:"local"}),this.isEndedInner=!1,this}async terminateAsync({status_code:e,cause:t}={}){this.terminate({status_code:e,cause:t})}terminateRemote({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e,originator:"remote"}),this}addStream(e,t="getTracks"){e[t]().forEach(r=>this.connection.addTrack(r))}forEachSenders(e){const t=this.connection.getSenders();for(const r of t)e(r);return t}toggleMuteAudio(e){this.forEachSenders(({track:t})=>{t?.kind==="audio"&&(t.enabled=!e)})}toggleMuteVideo(e){this.forEachSenders(({track:t})=>{t?.kind==="video"&&(t.enabled=!e)})}mute(e){e.audio&&(this.mutedOptions.audio=!0,this.toggleMuteAudio(this.mutedOptions.audio)),e.video&&(this.mutedOptions.video=!0,this.toggleMuteVideo(this.mutedOptions.video)),this.onmute(e)}unmute(e){e.audio&&(this.mutedOptions.audio=!1),e.video&&(this.mutedOptions.video=!1),this.trigger("unmuted",e)}isMuted(){return this.mutedOptions}onmute({audio:e,video:t}){this.trigger("muted",{audio:e,video:t})}async sendInfo(){}isEnded(){return this.isEndedInner}newInfo(e){this.trigger("newInfo",e)}clear(){clearTimeout(this.timeoutStartPresentation),clearTimeout(this.timeoutConnect),clearTimeout(this.timeoutNewInfo),clearTimeout(this.timeoutAccepted),clearTimeout(this.timeoutConfirmed)}}class ht{extraHeaders=[];setExtraHeaders(e){this.extraHeaders=e}setExtraContactParams(){}}const d="PASSWORD_CORRECT",T="PASSWORD_CORRECT_2",W="NAME_INCORRECT",h=400,g={url:"wss://sipServerUrl/webrtc/wss/",sip_uri:"sip:sipServerUrl;transport=ws",via_transport:"WSS"},P={status_code:200,reason_phrase:"OK"},v={status_code:401,reason_phrase:"Unauthorized"};class i{static isAvailableTelephony=!0;static startError;static countStartError=Number.POSITIVE_INFINITY;static countStarts=0;events;registratorInner;call=jest.fn((e,t)=>{const{mediaStream:r,eventHandlers:n}=t;return this.session=new s({eventHandlers:n,originator:"local"}),this.session.connect(e,{mediaStream:r}),this.session});sendOptions=jest.fn((e,t,r)=>{console.log("sendOptions",e,t,r)});start=jest.fn(()=>{if(i.countStarts+=1,i.startError&&i.countStarts<i.countStartError){this.trigger("disconnected",i.startError);return}this.register()});stop=jest.fn(()=>{this.startedTimeout&&clearTimeout(this.startedTimeout),this.stopedTimeout&&clearTimeout(this.stopedTimeout),this.unregister(),this.isStarted()?this.stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:!0,socket:g})},h):this.trigger("disconnected",{error:!0,socket:g})});removeAllListeners=jest.fn(()=>(this.events.removeEventHandlers(),this));once=jest.fn((e,t)=>(this.events.once(e,t),this));startedTimeout;stopedTimeout;session;isRegisteredInner;isConnectedInner;configuration;constructor(e){this.events=new S.Events(L);const[t,r]=e.uri.split(":"),[n,c]=r.split("@"),p={...e,uri:new a.URI(t,n,c)};this.configuration=p,this.registratorInner=new ht}static setStartError(e,{count:t=Number.POSITIVE_INFINITY}={}){i.startError=e,i.countStartError=t}static resetStartError(){i.startError=void 0,i.countStartError=Number.POSITIVE_INFINITY,i.countStarts=0}static setAvailableTelephony(){i.isAvailableTelephony=!0}static setNotAvailableTelephony(){i.isAvailableTelephony=!1}static reset(){i.resetStartError(),i.setAvailableTelephony()}on(e,t){return this.events.on(e,t),this}off(e,t){return this.events.off(e,t),this}trigger(e,t){this.events.trigger(e,t)}terminateSessions(){this.session?.terminate()}set(e,t){return this.configuration[e]=t,!0}register(){this.startedTimeout&&clearTimeout(this.startedTimeout);const{password:e,register:t,uri:r}=this.configuration;t===!0&&r.user.includes(W)?(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:v,cause:a.C.causes.REJECTED})},h)):!this.isRegistered()&&t===!0&&(e===d||e===T)?(this.isRegisteredInner=!0,this.startedTimeout=setTimeout(()=>{this.trigger("registered",{response:P})},h)):t===!0&&e!==d&&e!==T&&(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:v,cause:a.C.causes.REJECTED})},h)),i.isAvailableTelephony?(this.trigger("connected",{socket:g}),this.isConnectedInner=!0):this.stop()}unregister(){this.isRegisteredInner=!1,this.isConnectedInner=!1,this.trigger("unregistered",{response:P})}isRegistered(){return this.isRegisteredInner===!0}isConnected(){return this.isConnectedInner===!0}isStarted(){return this.configuration.register===!0&&this.isRegisteredInner===!0||this.configuration.register!==!0&&this.isConnectedInner===!0}newSipEvent(e){this.trigger("sipEvent",e)}registrator(){return this.registratorInner}}class ut{url;constructor(e){this.url=e}}class mt extends V.EventEmitter{contentType;body;constructor(e,t){super(),this.contentType=e,this.body=t}}const I="remote",lt=(o,e)=>{const t=new N(e),r={originator:I,request:t,info:new mt("","")};o.newInfo(r)},pt=(o,e)=>{const r={event:"sipEvent",request:new N(e)};o.newSipEvent(r)},gt=(o,{incomingNumber:e="1234",displayName:t,host:r})=>{const n=new s({originator:I,eventHandlers:{}}),c=new H("sip",e,r);n.remote_identity=new U(c,t);const p=new N([]);o.trigger("newRTCSession",{originator:I,session:n,request:p})},_t=(o,e)=>{e?o.trigger("failed",e):o.trigger("failed",o)},w={triggerNewInfo:lt,triggerNewSipEvent:pt,triggerIncomingSession:gt,triggerFailIncomingSession:_t,WebSocketInterface:ut,UA:i,C:{INVITE:"INVITE"}},u="user",E="displayName",m="SIP_SERVER_URL",C="SIP_WEB_SOCKET_SERVER_URL",Tt=new w.WebSocketInterface(C),R={displayName:"DISPLAY_NAME",userAgent:"Chrome",sipServerUrl:m,sipWebSocketServerURL:C},It={...R,displayName:"DISPLAY_NAME",register:!1},b={...R,user:u,password:d,register:!0},St={...b,displayName:E},Nt={...R,displayName:E,register:!1},l={session_timers:!1,sockets:[Tt],user_agent:"Chrome",sdpSemantics:"unified-plan",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},wt={...l,password:d,uri:new a.URI("sip",u,m),display_name:"DISPLAY_NAME",register:!0},Ct={...l,password:d,uri:new a.URI("sip",u,m),display_name:E,register:!0},Rt={...l,display_name:E,register:!1},ft={...l,display_name:"DISPLAY_NAME",register:!1},k="10.10.10.10",At=[`X-Vinteo-Remote: ${k}`],Mt=()=>new D.SipConnector({JsSIP:w});exports.FAILED_CONFERENCE_NUMBER=F;exports.JsSIP=w;exports.NAME_INCORRECT=W;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=T;exports.SIP_SERVER_URL=m;exports.SIP_WEB_SOCKET_SERVER_URL=C;exports.dataForConnectionWithAuthorization=b;exports.dataForConnectionWithAuthorizationWithDisplayName=St;exports.dataForConnectionWithoutAuthorization=Nt;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=It;exports.displayName=E;exports.doMockSipConnector=Mt;exports.extraHeadersRemoteAddress=At;exports.remoteAddress=k;exports.uaConfigurationWithAuthorization=wt;exports.uaConfigurationWithAuthorizationWithDisplayName=Ct;exports.uaConfigurationWithoutAuthorization=Rt;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=ft;exports.user=u;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("node:events"),U=require("@krivega/jssip/lib/NameAddrHeader"),j=require("@krivega/jssip/lib/URI"),H=require("@krivega/jssip/lib/SIPMessage"),a=require("@krivega/jssip"),_=require("webrtc-mock"),v=require("events-constructor"),D=require("./@SipConnector-DhKRV_I3.cjs");class N extends H.IncomingRequest{headers;constructor(e){super(),this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)??""}}const q="incomingCall",G="declinedIncomingCall",x="failedIncomingCall",z="terminatedIncomingCall",y="connecting",Y="connected",B="disconnected",K="newRTCSession",J="registered",Q="unregistered",$="registrationFailed",X="newMessage",Z="sipEvent",ee="availableSecondRemoteStream",te="notAvailableSecondRemoteStream",re="mustStopPresentation",ne="shareState",oe="enterRoom",ie="useLicense",se="peerconnection:confirmed",ae="peerconnection:ontrack",ce="channels",de="channels:notify",Ee="ended:fromserver",he="main-cam-control",ue="admin-stop-main-cam",me="admin-start-main-cam",le="admin-stop-mic",pe="admin-start-mic",ge="admin-force-sync-media-state",_e="participant:added-to-list-moderators",Te="participant:removed-from-list-moderators",Ie="participant:move-request-to-stream",Se="participant:move-request-to-spectators",Ne="participant:move-request-to-participants",we="participation:accepting-word-request",Ce="participation:cancelling-word-request",fe="webcast:started",Re="webcast:stopped",Ae="account:changed",Me="account:deleted",Oe="conference:participant-token-issued",Pe="ended",ve="sending",De="reinvite",ye="replaces",Le="refer",Fe="progress",ke="accepted",We="confirmed",be="peerconnection",Ve="failed",Ue="muted",je="unmuted",He="newDTMF",qe="newInfo",Ge="hold",xe="unhold",ze="update",Ye="sdp",Be="icecandidate",Ke="getusermediafailed",Je="peerconnection:createofferfailed",Qe="peerconnection:createanswerfailed",$e="peerconnection:setlocaldescriptionfailed",Xe="peerconnection:setremotedescriptionfailed",Ze="presentation:start",et="presentation:started",tt="presentation:end",rt="presentation:ended",nt="presentation:failed",ot=[q,G,z,x,we,Ce,Ie,de,Oe,Ae,Me,fe,Re,_e,Te],L=[y,Y,B,K,J,Q,$,X,Z],it=[ee,te,re,ne,oe,ie,se,ae,ce,Ee,he,me,ue,le,pe,ge,Se,Ne],T=[Pe,y,ve,De,ye,Le,Fe,ke,We,be,Ve,Ue,je,He,qe,Ge,xe,ze,Ye,Be,Ke,Je,Qe,$e,Xe,Ze,et,tt,rt,nt];[...L,...ot];[...T,...it];class st{originator;connection;events;remote_identity;mutedOptions={audio:!1,video:!1};constructor({originator:e="local",eventHandlers:t,remoteIdentity:r}){this.originator=e,this.events=new v.Events(T),this.initEvents(t),this.remote_identity=r}get contact(){throw new Error("Method not implemented.")}get direction(){throw new Error("Method not implemented.")}get local_identity(){throw new Error("Method not implemented.")}get start_time(){throw new Error("Method not implemented.")}get end_time(){throw new Error("Method not implemented.")}get status(){throw new Error("Method not implemented.")}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}set data(e){throw new Error("Method not implemented.")}isInProgress(){throw new Error("Method not implemented.")}isEnded(){throw new Error("Method not implemented.")}isReadyToReOffer(){throw new Error("Method not implemented.")}answer(e){throw new Error("Method not implemented.")}terminate(e){throw new Error("Method not implemented.")}async sendInfo(e,t,r){throw new Error("Method not implemented.")}hold(e,t){throw new Error("Method not implemented.")}unhold(e,t){throw new Error("Method not implemented.")}async renegotiate(e,t){throw new Error("Method not implemented.")}isOnHold(){throw new Error("Method not implemented.")}mute(e){throw new Error("Method not implemented.")}unmute(e){throw new Error("Method not implemented.")}isMuted(){throw new Error("Method not implemented.")}refer(e,t){throw new Error("Method not implemented.")}resetLocalMedia(){throw new Error("Method not implemented.")}async replaceMediaStream(e,t){throw new Error("Method not implemented.")}addListener(e,t){throw new Error("Method not implemented.")}once(e,t){throw new Error("Method not implemented.")}removeListener(e,t){throw new Error("Method not implemented.")}off(e,t){return this.events.off(e,t),this}removeAllListeners(e){return console.warn("Method not implemented. Event:",e),this}setMaxListeners(e){throw new Error("Method not implemented.")}getMaxListeners(){throw new Error("Method not implemented.")}listeners(e){throw new Error("Method not implemented.")}rawListeners(e){throw new Error("Method not implemented.")}emit(e,...t){throw new Error("Method not implemented.")}listenerCount(e){throw new Error("Method not implemented.")}prependListener(e,t){throw new Error("Method not implemented.")}prependOnceListener(e,t){throw new Error("Method not implemented.")}eventNames(){throw new Error("Method not implemented.")}initEvents(e){e&&Object.entries(e).forEach(([t,r])=>{this.on(t,r)})}on(e,t){return T.includes(e)&&this.events.on(e,t),this}trigger(e,t){this.events.trigger(e,t)}sendDTMF(){this.trigger("newDTMF",{originator:this.originator})}async startPresentation(e){return this.trigger("presentation:start",e),this.trigger("presentation:started",e),e}async stopPresentation(e){return this.trigger("presentation:end",e),this.trigger("presentation:ended",e),e}isEstablished(){return!0}}class R{stats=new Map().set("codec",{mimeType:"video/h264"});dtmf=null;track=null;transport=null;transform=null;parameters={encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}};parametersGets;constructor({track:e}={}){this.track=e??null}async getStats(){return this.stats}async replaceTrack(e){this.track=e??null}async setParameters(e){if(e!==this.parametersGets)throw new Error("Failed to execute 'setParameters' on 'RTCRtpSender': Read-only field modified in setParameters().");const{transactionId:t}=this.parameters;this.parameters={...this.parameters,...e,transactionId:`${Number(t)+1}`}}getParameters(){return this.parametersGets={...this.parameters},this.parametersGets}setStreams(){throw new Error("Method not implemented.")}}class A{currentDirection="sendrecv";direction="sendrecv";mid=null;receiver;sender;stopped=!1;constructor(e){this.sender=e}setCodecPreferences(e){}stop(){}}class at extends EventTarget{senders=[];receivers=[];canTrickleIceCandidates;connectionState;currentLocalDescription;currentRemoteDescription;iceConnectionState;iceGatheringState;idpErrorInfo;idpLoginUrl;localDescription;onconnectionstatechange;ondatachannel;onicecandidate;onicecandidateerror=null;oniceconnectionstatechange;onicegatheringstatechange;onnegotiationneeded;onsignalingstatechange;ontrack;peerIdentity=void 0;pendingLocalDescription;pendingRemoteDescription;remoteDescription;sctp=null;signalingState;close=jest.fn();setLocalDescription=jest.fn(async e=>{});setRemoteDescription=jest.fn(async e=>{});addTransceiver=jest.fn((e,t)=>({}));createOffer=jest.fn(async(e,t,r)=>({type:"offer",sdp:"offer-sdp"}));constructor(e,t){super(),this.receivers=t?.map(r=>({track:r}))??[]}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(e){throw new Error("Method not implemented.")}restartIce(){throw new Error("Method not implemented.")}async createAnswer(e,t){throw new Error("Method not implemented.")}createDataChannel(e,t){throw new Error("Method not implemented.")}getConfiguration(){throw new Error("Method not implemented.")}async getIdentityAssertion(){throw new Error("Method not implemented.")}async getStats(e){throw new Error("Method not implemented.")}getTransceivers(){throw new Error("Method not implemented.")}removeTrack(e){throw new Error("Method not implemented.")}setConfiguration(e){throw new Error("Method not implemented.")}getReceivers=()=>this.receivers;getSenders=()=>this.senders;addTrack=(e,...t)=>{const r=new R({track:e}),o=new A(r);return o.mid=e.kind==="audio"?"0":"1",this.senders.push(r),this.dispatchTrackInternal(e),r};addTrackWithMid=(e,t)=>{const r=new R({track:e}),o=new A(r);return t===void 0?o.mid=e.kind==="audio"?"0":"1":o.mid=t,this.senders.push(r),this.dispatchTrackInternal(e),r};dispatchTrack(e){this.dispatchTrackInternal(new _.MediaStreamTrackMock(e))}dispatchTrackInternal(e){const t=new Event("track");Object.defineProperty(t,"track",{value:e}),this.dispatchEvent(t)}}function ct(n){const e=n.match(/(purgatory)|[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const M=400,F="777",dt=n=>n.getVideoTracks().length>0;class s extends st{static presentationError;static startPresentationError;static countStartPresentationError=Number.POSITIVE_INFINITY;static countStartsPresentation=0;url;status_code;answer=jest.fn(({mediaStream:e})=>{if(this.originator!=="remote")throw new Error("answer available only for remote sessions");this.initPeerconnection(e),setTimeout(()=>{this.trigger("connecting"),setTimeout(()=>{this.trigger("accepted")},100),setTimeout(()=>{this.trigger("confirmed")},200)},M)});replaceMediaStream=jest.fn(async e=>{});_isReadyToReOffer=jest.fn(()=>!0);addTransceiver=jest.fn((e,t)=>({}));restartIce=jest.fn(async e=>!0);isEndedInner=!1;delayStartPresentation=0;timeoutStartPresentation;timeoutConnect;timeoutNewInfo;timeoutAccepted;timeoutConfirmed;constructor({eventHandlers:e,originator:t,remoteIdentity:r=new a.NameAddrHeader(new a.URI("sip","caller1","test1.com",5060),"Test Caller 1"),delayStartPresentation:o=0}){super({originator:t,eventHandlers:e,remoteIdentity:r}),this.delayStartPresentation=o}static get C(){return a.SessionStatus}static setPresentationError(e){this.presentationError=e}static resetPresentationError(){this.presentationError=void 0}static setStartPresentationError(e,{count:t=Number.POSITIVE_INFINITY}={}){this.startPresentationError=e,this.countStartPresentationError=t}static resetStartPresentationError(){this.startPresentationError=void 0,this.countStartPresentationError=Number.POSITIVE_INFINITY,this.countStartsPresentation=0}startPresentation=async e=>(s.countStartsPresentation+=1,new Promise((t,r)=>{this.timeoutStartPresentation=setTimeout(()=>{if(s.presentationError){this.trigger("presentation:start",e),this.trigger("presentation:failed",e),r(s.presentationError);return}if(s.startPresentationError&&s.countStartsPresentation<s.countStartPresentationError){this.trigger("presentation:start",e),this.trigger("presentation:failed",e),r(s.startPresentationError);return}t(super.startPresentation(e))},this.delayStartPresentation)}));stopPresentation=async e=>{if(s.presentationError)throw this.trigger("presentation:end",e),this.trigger("presentation:failed",e),s.presentationError;return super.stopPresentation(e)};initPeerconnection(e){return e?(this.createPeerconnection(e),!0):!1}createPeerconnection(e){const t=_.createAudioMediaStreamTrackMock();t.id="mainaudio1";const r=[t];if(dt(e)){const c=_.createVideoMediaStreamTrackMock();c.id="mainvideo1",r.push(c)}this.connection=new at(void 0,r),this.addStream(e),this.trigger("peerconnection",{peerconnection:this.connection})}connect(e,{mediaStream:t}={}){const r=ct(e);return this.initPeerconnection(t),this.timeoutConnect=setTimeout(()=>{e.includes(F)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:"Rejected"}):(this.trigger("connecting"),this.timeoutNewInfo=setTimeout(()=>{this.newInfo({originator:D.Originator.REMOTE,request:{getHeader:o=>o==="content-type"?"application/vinteo.webrtc.roomname":o==="x-webrtc-enter-room"?r:o==="x-webrtc-participant-name"?"Test Caller 1":""}})},100),this.timeoutAccepted=setTimeout(()=>{this.trigger("accepted")},200),this.timeoutConfirmed=setTimeout(()=>{this.trigger("confirmed")},300))},M),this.connection}terminate({status_code:e,cause:t}={}){return this.status_code=e,this.trigger("ended",{status_code:e,cause:t,originator:"local"}),this.isEndedInner=!1,this}async terminateAsync({status_code:e,cause:t}={}){this.terminate({status_code:e,cause:t})}terminateRemote({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e,originator:"remote"}),this}addStream(e,t="getTracks"){e[t]().forEach(r=>this.connection.addTrack(r))}forEachSenders(e){const t=this.connection.getSenders();for(const r of t)e(r);return t}toggleMuteAudio(e){this.forEachSenders(({track:t})=>{t?.kind==="audio"&&(t.enabled=!e)})}toggleMuteVideo(e){this.forEachSenders(({track:t})=>{t?.kind==="video"&&(t.enabled=!e)})}mute(e){e.audio&&(this.mutedOptions.audio=!0,this.toggleMuteAudio(this.mutedOptions.audio)),e.video&&(this.mutedOptions.video=!0,this.toggleMuteVideo(this.mutedOptions.video)),this.onmute(e)}unmute(e){e.audio&&(this.mutedOptions.audio=!1),e.video&&(this.mutedOptions.video=!1),this.trigger("unmuted",e)}isMuted(){return this.mutedOptions}onmute({audio:e,video:t}){this.trigger("muted",{audio:e,video:t})}async sendInfo(){}isEnded(){return this.isEndedInner}newInfo(e){this.trigger("newInfo",e)}clear(){clearTimeout(this.timeoutStartPresentation),clearTimeout(this.timeoutConnect),clearTimeout(this.timeoutNewInfo),clearTimeout(this.timeoutAccepted),clearTimeout(this.timeoutConfirmed)}}class Et{extraHeaders=[];setExtraHeaders(e){this.extraHeaders=e}setExtraContactParams(){}}const d="PASSWORD_CORRECT",I="PASSWORD_CORRECT_2",k="NAME_INCORRECT",h=400,g={url:"wss://sipServerUrl/webrtc/wss/",sip_uri:"sip:sipServerUrl;transport=ws",via_transport:"WSS"},O={status_code:200,reason_phrase:"OK"},P={status_code:401,reason_phrase:"Unauthorized"};class i{static isAvailableTelephony=!0;static startError;static countStartError=Number.POSITIVE_INFINITY;static countStarts=0;events;registratorInner;call=jest.fn((e,t)=>{const{mediaStream:r,eventHandlers:o}=t;return this.session=new s({eventHandlers:o,originator:"local"}),this.session.connect(e,{mediaStream:r}),this.session});sendOptions=jest.fn((e,t,r)=>{console.log("sendOptions",e,t,r)});start=jest.fn(()=>{if(i.countStarts+=1,i.startError&&i.countStarts<i.countStartError){this.trigger("disconnected",i.startError);return}this.register()});stop=jest.fn(()=>{this.startedTimeout&&clearTimeout(this.startedTimeout),this.stopedTimeout&&clearTimeout(this.stopedTimeout),this.unregister(),this.isStarted()?this.stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:!0,socket:g})},h):this.trigger("disconnected",{error:!0,socket:g})});removeAllListeners=jest.fn(()=>(this.events.removeEventHandlers(),this));once=jest.fn((e,t)=>(this.events.once(e,t),this));startedTimeout;stopedTimeout;session;isRegisteredInner;isConnectedInner;configuration;constructor(e){this.events=new v.Events(L);const[t,r]=e.uri.split(":"),[o,c]=r.split("@"),p={...e,uri:new a.URI(t,o,c)};this.configuration=p,this.registratorInner=new Et}static setStartError(e,{count:t=Number.POSITIVE_INFINITY}={}){i.startError=e,i.countStartError=t}static resetStartError(){i.startError=void 0,i.countStartError=Number.POSITIVE_INFINITY,i.countStarts=0}static setAvailableTelephony(){i.isAvailableTelephony=!0}static setNotAvailableTelephony(){i.isAvailableTelephony=!1}static reset(){i.resetStartError(),i.setAvailableTelephony()}on(e,t){return this.events.on(e,t),this}off(e,t){return this.events.off(e,t),this}trigger(e,t){this.events.trigger(e,t)}terminateSessions(){this.session?.terminate()}set(e,t){return this.configuration[e]=t,!0}register(){this.startedTimeout&&clearTimeout(this.startedTimeout);const{password:e,register:t,uri:r}=this.configuration;t===!0&&r.user.includes(k)?(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:P,cause:a.C.causes.REJECTED})},h)):!this.isRegistered()&&t===!0&&(e===d||e===I)?(this.isRegisteredInner=!0,this.startedTimeout=setTimeout(()=>{this.trigger("registered",{response:O})},h)):t===!0&&e!==d&&e!==I&&(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:P,cause:a.C.causes.REJECTED})},h)),i.isAvailableTelephony?(this.trigger("connected",{socket:g}),this.isConnectedInner=!0):this.stop()}unregister(){this.isRegisteredInner=!1,this.isConnectedInner=!1,this.trigger("unregistered",{response:O})}isRegistered(){return this.isRegisteredInner===!0}isConnected(){return this.isConnectedInner===!0}isStarted(){return this.configuration.register===!0&&this.isRegisteredInner===!0||this.configuration.register!==!0&&this.isConnectedInner===!0}newSipEvent(e){this.trigger("sipEvent",e)}registrator(){return this.registratorInner}}class ht{url;constructor(e){this.url=e}}class ut extends V.EventEmitter{contentType;body;constructor(e,t){super(),this.contentType=e,this.body=t}}const S="remote",mt=(n,e)=>{const t=new N(e),r={originator:S,request:t,info:new ut("","")};n.newInfo(r)},lt=(n,e)=>{const r={event:"sipEvent",request:new N(e)};n.newSipEvent(r)},pt=(n,{incomingNumber:e="1234",displayName:t,host:r})=>{const o=new s({originator:S,eventHandlers:{}}),c=new j("sip",e,r);o.remote_identity=new U(c,t);const p=new N([]);n.trigger("newRTCSession",{originator:S,session:o,request:p})},gt=(n,e)=>{e?n.trigger("failed",e):n.trigger("failed",n)},w={triggerNewInfo:mt,triggerNewSipEvent:lt,triggerIncomingSession:pt,triggerFailIncomingSession:gt,WebSocketInterface:ht,UA:i,C:{INVITE:"INVITE"}},u="user",E="displayName",m="SIP_SERVER_URL",C="SIP_WEB_SOCKET_SERVER_URL",_t=new w.WebSocketInterface(C),f={displayName:"DISPLAY_NAME",userAgent:"Chrome",sipServerUrl:m,sipWebSocketServerURL:C},Tt={...f,displayName:"DISPLAY_NAME",register:!1},W={...f,user:u,password:d,register:!0},It={...W,displayName:E},St={...f,displayName:E,register:!1},l={session_timers:!1,sockets:[_t],user_agent:"Chrome",sdpSemantics:"unified-plan",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},Nt={...l,password:d,uri:new a.URI("sip",u,m),display_name:"DISPLAY_NAME",register:!0},wt={...l,password:d,uri:new a.URI("sip",u,m),display_name:E,register:!0},Ct={...l,display_name:E,register:!1},ft={...l,display_name:"DISPLAY_NAME",register:!1},b="10.10.10.10",Rt=[`X-Vinteo-Remote: ${b}`],At=()=>new D.SipConnector({JsSIP:w});exports.FAILED_CONFERENCE_NUMBER=F;exports.JsSIP=w;exports.NAME_INCORRECT=k;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=I;exports.SIP_SERVER_URL=m;exports.SIP_WEB_SOCKET_SERVER_URL=C;exports.dataForConnectionWithAuthorization=W;exports.dataForConnectionWithAuthorizationWithDisplayName=It;exports.dataForConnectionWithoutAuthorization=St;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=Tt;exports.displayName=E;exports.doMockSipConnector=At;exports.extraHeadersRemoteAddress=Rt;exports.remoteAddress=b;exports.uaConfigurationWithAuthorization=Nt;exports.uaConfigurationWithAuthorizationWithDisplayName=wt;exports.uaConfigurationWithoutAuthorization=Ct;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=ft;exports.user=u;
|