sip-connector 15.3.0 → 16.0.0
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/LICENSE +1 -1
- package/README.md +526 -88
- package/dist/@SipConnector-DcaeAFrM.cjs +1 -0
- package/dist/{@SipConnector-Gt9XLkRE.js → @SipConnector-uiUlVCMv.js} +962 -401
- package/dist/CallManager/types.d.ts +2 -0
- package/dist/PresentationManager/@PresentationManager.d.ts +5 -3
- package/dist/SipConnector/@SipConnector.d.ts +14 -4
- package/dist/SipConnector/eventNames.d.ts +1 -1
- package/dist/SipConnectorFacade/SipConnectorFacade.d.ts +10 -21
- package/dist/StatsPeerConnection/StatsPeerConnection.d.ts +1 -1
- package/dist/StatsPeerConnection/__fixtures__/callStaticsState.d.ts +3 -3
- package/dist/StatsPeerConnection/eventNames.d.ts +3 -3
- package/dist/StatsPeerConnection/index.d.ts +1 -0
- package/dist/StatsPeerConnection/parseStatsReports.d.ts +3 -3
- package/dist/StatsPeerConnection/requestAllStatistics.d.ts +1 -1
- package/dist/StatsPeerConnection/{typings.d.ts → types.d.ts} +2 -2
- package/dist/VideoSendingBalancer/SenderBalancer.d.ts +3 -1
- package/dist/VideoSendingBalancer/TrackMonitor.d.ts +38 -0
- package/dist/VideoSendingBalancer/VideoSendingBalancer.d.ts +8 -9
- package/dist/VideoSendingBalancer/VideoSendingEventHandler.d.ts +4 -9
- package/dist/VideoSendingBalancer/__fixtures__/createMockTrack.d.ts +5 -0
- package/dist/VideoSendingBalancer/__fixtures__/index.d.ts +1 -0
- package/dist/VideoSendingBalancer/index.d.ts +1 -2
- package/dist/VideoSendingBalancer/types.d.ts +0 -1
- package/dist/VideoSendingBalancerManager/@VideoSendingBalancerManager.d.ts +47 -0
- package/dist/VideoSendingBalancerManager/eventNames.d.ts +20 -0
- package/dist/VideoSendingBalancerManager/index.d.ts +3 -0
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +281 -748
- package/dist/logger.d.ts +0 -1
- package/dist/tools/setCodecPreferences.d.ts +5 -0
- package/dist/tools/setParametersToSender/index.d.ts +1 -0
- package/package.json +5 -5
- package/dist/@SipConnector-DV4Ywba-.cjs +0 -1
- package/dist/tools/generateSimulcastEncodings.d.ts +0 -7
- package/dist/tools/resolveUpdateTransceiver.d.ts +0 -6
- package/dist/tools/scaleResolutionAndBitrate.d.ts +0 -10
- /package/dist/{PresentationManager → SipConnector}/constants.d.ts +0 -0
|
@@ -15,6 +15,7 @@ type TParamsAnswerToIncomingCall = {
|
|
|
15
15
|
directionVideo?: RTCRtpTransceiverDirection;
|
|
16
16
|
directionAudio?: RTCRtpTransceiverDirection;
|
|
17
17
|
contentHint?: TContentHint;
|
|
18
|
+
degradationPreference?: RTCDegradationPreference;
|
|
18
19
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
19
20
|
offerToReceiveAudio?: boolean;
|
|
20
21
|
offerToReceiveVideo?: boolean;
|
|
@@ -52,6 +53,7 @@ export interface ICallStrategy {
|
|
|
52
53
|
addMissing?: boolean;
|
|
53
54
|
forceRenegotiation?: boolean;
|
|
54
55
|
contentHint?: TContentHint;
|
|
56
|
+
degradationPreference?: RTCDegradationPreference;
|
|
55
57
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
56
58
|
onAddedTransceiver?: TOnAddedTransceiver;
|
|
57
59
|
}) => Promise<void>;
|
|
@@ -7,15 +7,16 @@ declare class PresentationManager {
|
|
|
7
7
|
promisePendingStartPresentation?: Promise<MediaStream>;
|
|
8
8
|
promisePendingStopPresentation?: Promise<MediaStream | undefined>;
|
|
9
9
|
streamPresentationCurrent?: MediaStream;
|
|
10
|
+
private readonly maxBitrate?;
|
|
10
11
|
private cancelableSendPresentationWithRepeatedCalls;
|
|
11
12
|
private readonly callManager;
|
|
12
|
-
constructor({ callManager }: {
|
|
13
|
+
constructor({ callManager, maxBitrate, }: {
|
|
13
14
|
callManager: CallManager;
|
|
15
|
+
maxBitrate?: number;
|
|
14
16
|
});
|
|
15
17
|
get isPendingPresentation(): boolean;
|
|
16
|
-
startPresentation(beforeStartPresentation: () => Promise<void>, stream: MediaStream, { isNeedReinvite,
|
|
18
|
+
startPresentation(beforeStartPresentation: () => Promise<void>, stream: MediaStream, { isNeedReinvite, contentHint, sendEncodings, onAddedTransceiver, }?: {
|
|
17
19
|
isNeedReinvite?: boolean;
|
|
18
|
-
maxBitrate?: number;
|
|
19
20
|
contentHint?: TContentHint;
|
|
20
21
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
21
22
|
onAddedTransceiver?: TOnAddedTransceiver;
|
|
@@ -38,6 +39,7 @@ declare class PresentationManager {
|
|
|
38
39
|
private subscribe;
|
|
39
40
|
private sendPresentationWithDuplicatedCalls;
|
|
40
41
|
private sendPresentation;
|
|
42
|
+
private readonly setMaxBitrate;
|
|
41
43
|
private readonly getRtcSessionProtected;
|
|
42
44
|
private readonly handleEnded;
|
|
43
45
|
private reset;
|
|
@@ -5,9 +5,11 @@ import { ConnectionManager } from '../ConnectionManager';
|
|
|
5
5
|
import { IncomingCallManager } from '../IncomingCallManager';
|
|
6
6
|
import { PresentationManager } from '../PresentationManager';
|
|
7
7
|
import { StatsManager } from '../StatsManager';
|
|
8
|
+
import { VideoSendingBalancerManager } from '../VideoSendingBalancerManager';
|
|
8
9
|
import { EVENT_NAMES, TEvent } from './eventNames';
|
|
9
10
|
import { TContentHint, TOnAddedTransceiver } from '../PresentationManager/types';
|
|
10
11
|
import { TJsSIP } from '../types';
|
|
12
|
+
import { IBalancerOptions } from '../VideoSendingBalancer';
|
|
11
13
|
declare class SipConnector {
|
|
12
14
|
readonly events: Events<typeof EVENT_NAMES>;
|
|
13
15
|
readonly connectionManager: ConnectionManager;
|
|
@@ -16,8 +18,15 @@ declare class SipConnector {
|
|
|
16
18
|
readonly incomingCallManager: IncomingCallManager;
|
|
17
19
|
readonly presentationManager: PresentationManager;
|
|
18
20
|
readonly statsManager: StatsManager;
|
|
21
|
+
readonly videoSendingBalancerManager: VideoSendingBalancerManager;
|
|
22
|
+
private readonly preferredMimeTypesVideoCodecs?;
|
|
23
|
+
private readonly excludeMimeTypesVideoCodecs?;
|
|
19
24
|
constructor({ JsSIP }: {
|
|
20
25
|
JsSIP: TJsSIP;
|
|
26
|
+
}, { preferredMimeTypesVideoCodecs, excludeMimeTypesVideoCodecs, videoBalancerOptions, }?: {
|
|
27
|
+
preferredMimeTypesVideoCodecs?: string[];
|
|
28
|
+
excludeMimeTypesVideoCodecs?: string[];
|
|
29
|
+
videoBalancerOptions?: IBalancerOptions;
|
|
21
30
|
});
|
|
22
31
|
get requestedConnection(): boolean;
|
|
23
32
|
get isPendingConnect(): boolean;
|
|
@@ -57,11 +66,11 @@ declare class SipConnector {
|
|
|
57
66
|
getCallConfiguration: CallManager['getCallConfiguration'];
|
|
58
67
|
getRemoteStreams: CallManager['getRemoteStreams'];
|
|
59
68
|
replaceMediaStream: CallManager['replaceMediaStream'];
|
|
60
|
-
startPresentation(
|
|
69
|
+
startPresentation(mediaStream: MediaStream, options?: {
|
|
61
70
|
isP2P?: boolean;
|
|
62
71
|
isNeedReinvite?: boolean;
|
|
63
|
-
maxBitrate?: number;
|
|
64
72
|
contentHint?: TContentHint;
|
|
73
|
+
degradationPreference?: RTCDegradationPreference;
|
|
65
74
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
66
75
|
onAddedTransceiver?: TOnAddedTransceiver;
|
|
67
76
|
callLimit?: number;
|
|
@@ -69,11 +78,11 @@ declare class SipConnector {
|
|
|
69
78
|
stopPresentation(options?: {
|
|
70
79
|
isP2P?: boolean;
|
|
71
80
|
}): Promise<MediaStream | undefined>;
|
|
72
|
-
updatePresentation(
|
|
81
|
+
updatePresentation(mediaStream: MediaStream, options?: {
|
|
73
82
|
isP2P?: boolean;
|
|
74
83
|
isNeedReinvite?: boolean;
|
|
75
|
-
maxBitrate?: number;
|
|
76
84
|
contentHint?: TContentHint;
|
|
85
|
+
degradationPreference?: RTCDegradationPreference;
|
|
77
86
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
78
87
|
onAddedTransceiver?: TOnAddedTransceiver;
|
|
79
88
|
}): Promise<MediaStream | undefined>;
|
|
@@ -93,6 +102,7 @@ declare class SipConnector {
|
|
|
93
102
|
askPermissionToStartPresentationP2P(...args: Parameters<ApiManager['askPermissionToStartPresentationP2P']>): Promise<void>;
|
|
94
103
|
askPermissionToStartPresentation(...args: Parameters<ApiManager['askPermissionToStartPresentation']>): Promise<void>;
|
|
95
104
|
askPermissionToEnableCam(...args: Parameters<ApiManager['askPermissionToEnableCam']>): Promise<void>;
|
|
105
|
+
private setCodecPreferences;
|
|
96
106
|
private subscribe;
|
|
97
107
|
}
|
|
98
108
|
export default SipConnector;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Events } from 'events-constructor';
|
|
2
|
-
export declare const EVENT_NAMES: readonly ("connection:connecting" | "connection:connected" | "connection:disconnected" | "connection:newRTCSession" | "connection:registered" | "connection:unregistered" | "connection:registrationFailed" | "connection:newMessage" | "connection:sipEvent" | "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" | "api:newDTMF" | "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:participant:move-request-to-spectators-over-sfu" | "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" | "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")[];
|
|
2
|
+
export declare const EVENT_NAMES: readonly ("connection:connecting" | "connection:connected" | "connection:disconnected" | "connection:newRTCSession" | "connection:registered" | "connection:unregistered" | "connection:registrationFailed" | "connection:newMessage" | "connection:sipEvent" | "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" | "api:newDTMF" | "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:participant:move-request-to-spectators-over-sfu" | "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" | "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")[];
|
|
3
3
|
export type TEvent = (typeof EVENT_NAMES)[number];
|
|
4
4
|
export type TEvents = Events<typeof EVENT_NAMES>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { UA } from '@krivega/jssip';
|
|
2
2
|
import { EUseLicense } from '../ApiManager';
|
|
3
|
+
import { TOnAddedTransceiver } from '../CallManager/types';
|
|
3
4
|
import { TContentHint } from '../PresentationManager';
|
|
4
5
|
import { SipConnector } from '../SipConnector';
|
|
5
6
|
import { TEventMap as TStatsEventMap } from '../StatsManager';
|
|
6
|
-
import { TSimulcastEncoding } from '../types';
|
|
7
7
|
type TEnterRoomHandlers = {
|
|
8
8
|
onEnterPurgatory?: () => void;
|
|
9
9
|
onEnterConference?: (parameters_: {
|
|
@@ -49,12 +49,7 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
49
49
|
isConfigured: IProxyMethods['isConfigured'];
|
|
50
50
|
isRegistered: IProxyMethods['isRegistered'];
|
|
51
51
|
readonly sipConnector: SipConnector;
|
|
52
|
-
|
|
53
|
-
private readonly excludeMimeTypesVideoCodecs?;
|
|
54
|
-
constructor(sipConnector: SipConnector, { preferredMimeTypesVideoCodecs, excludeMimeTypesVideoCodecs, }?: {
|
|
55
|
-
preferredMimeTypesVideoCodecs?: string[];
|
|
56
|
-
excludeMimeTypesVideoCodecs?: string[];
|
|
57
|
-
});
|
|
52
|
+
constructor(sipConnector: SipConnector);
|
|
58
53
|
connectToServer: (parameters: {
|
|
59
54
|
userAgent: string;
|
|
60
55
|
sipWebSocketServerURL: string;
|
|
@@ -75,7 +70,6 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
75
70
|
extraHeaders?: string[] | undefined;
|
|
76
71
|
iceServers?: RTCIceServer[];
|
|
77
72
|
contentHint?: TContentHint;
|
|
78
|
-
simulcastEncodings?: TSimulcastEncoding[];
|
|
79
73
|
degradationPreference?: RTCDegradationPreference;
|
|
80
74
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
81
75
|
offerToReceiveAudio?: boolean;
|
|
@@ -94,6 +88,7 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
94
88
|
onFailProgressCall?: () => void;
|
|
95
89
|
onFinishProgressCall?: () => void;
|
|
96
90
|
onEndedCall?: () => void;
|
|
91
|
+
onAddedTransceiver?: TOnAddedTransceiver;
|
|
97
92
|
}) => Promise<RTCPeerConnection>;
|
|
98
93
|
disconnectFromServer: () => Promise<{
|
|
99
94
|
isSuccessful: boolean;
|
|
@@ -103,7 +98,6 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
103
98
|
extraHeaders?: string[] | undefined;
|
|
104
99
|
iceServers?: RTCIceServer[];
|
|
105
100
|
contentHint?: TContentHint;
|
|
106
|
-
simulcastEncodings?: TSimulcastEncoding[];
|
|
107
101
|
degradationPreference?: RTCDegradationPreference;
|
|
108
102
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
109
103
|
offerToReceiveAudio?: boolean;
|
|
@@ -122,28 +116,23 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
122
116
|
isSuccessProgressCall: boolean;
|
|
123
117
|
}) => void;
|
|
124
118
|
onEndedCall?: () => void;
|
|
119
|
+
onAddedTransceiver?: TOnAddedTransceiver;
|
|
125
120
|
}) => Promise<RTCPeerConnection | undefined>;
|
|
126
|
-
updatePresentation: ({ mediaStream, isP2P,
|
|
121
|
+
updatePresentation: ({ mediaStream, isP2P, contentHint, degradationPreference, sendEncodings, onAddedTransceiver, }: {
|
|
127
122
|
mediaStream: MediaStream;
|
|
128
123
|
isP2P: boolean;
|
|
129
|
-
maxBitrate?: number;
|
|
130
124
|
contentHint?: TContentHint;
|
|
131
|
-
simulcastEncodings?: TSimulcastEncoding[];
|
|
132
125
|
degradationPreference?: RTCDegradationPreference;
|
|
133
126
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
134
|
-
|
|
135
|
-
excludeMimeTypesVideoCodecs?: string[];
|
|
127
|
+
onAddedTransceiver?: TOnAddedTransceiver;
|
|
136
128
|
}) => Promise<MediaStream | undefined>;
|
|
137
|
-
startPresentation: ({ mediaStream, isP2P,
|
|
129
|
+
startPresentation: ({ mediaStream, isP2P, contentHint, degradationPreference, sendEncodings, callLimit, onAddedTransceiver, }: {
|
|
138
130
|
mediaStream: MediaStream;
|
|
139
131
|
isP2P: boolean;
|
|
140
|
-
maxBitrate?: number;
|
|
141
132
|
contentHint?: TContentHint;
|
|
142
|
-
simulcastEncodings?: TSimulcastEncoding[];
|
|
143
133
|
degradationPreference?: RTCDegradationPreference;
|
|
144
134
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
145
|
-
|
|
146
|
-
excludeMimeTypesVideoCodecs?: string[];
|
|
135
|
+
onAddedTransceiver?: TOnAddedTransceiver;
|
|
147
136
|
callLimit?: number;
|
|
148
137
|
}) => Promise<MediaStream | undefined>;
|
|
149
138
|
stopShareSipConnector: ({ isP2P }?: {
|
|
@@ -155,14 +144,14 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
155
144
|
isEnabledCam: boolean;
|
|
156
145
|
isEnabledMic: boolean;
|
|
157
146
|
}) => Promise<void>;
|
|
158
|
-
replaceMediaStream: (mediaStream: MediaStream, { deleteExisting, addMissing, forceRenegotiation, contentHint,
|
|
147
|
+
replaceMediaStream: (mediaStream: MediaStream, { deleteExisting, addMissing, forceRenegotiation, contentHint, degradationPreference, sendEncodings, onAddedTransceiver, }: {
|
|
159
148
|
deleteExisting?: boolean;
|
|
160
149
|
addMissing?: boolean;
|
|
161
150
|
forceRenegotiation?: boolean;
|
|
162
151
|
contentHint?: TContentHint;
|
|
163
|
-
simulcastEncodings?: TSimulcastEncoding[];
|
|
164
152
|
degradationPreference?: RTCDegradationPreference;
|
|
165
153
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
154
|
+
onAddedTransceiver?: TOnAddedTransceiver;
|
|
166
155
|
}) => Promise<void>;
|
|
167
156
|
askPermissionToEnableCam: () => Promise<void>;
|
|
168
157
|
resolveHandleReadyRemoteStreamsDebounced: ({ onReadyRemoteStreams, }: {
|
|
@@ -15,6 +15,6 @@ declare class StatsPeerConnection {
|
|
|
15
15
|
onceRace<T extends keyof TEventMap>(eventNames: T[], handler: (data: TEventMap[T], eventName: string) => void): () => void;
|
|
16
16
|
wait<T extends keyof TEventMap>(eventName: T): Promise<TEventMap[T]>;
|
|
17
17
|
off<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): void;
|
|
18
|
-
private readonly
|
|
18
|
+
private readonly collectStatistics;
|
|
19
19
|
}
|
|
20
20
|
export default StatsPeerConnection;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TInboundStats, TOutboundStats } from '../types';
|
|
2
2
|
export type TStats = {
|
|
3
|
-
inbound:
|
|
4
|
-
outbound:
|
|
3
|
+
inbound: TInboundStats;
|
|
4
|
+
outbound: TOutboundStats;
|
|
5
5
|
};
|
|
6
6
|
export declare const statisticsMockBase: {
|
|
7
7
|
outbound: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { TypedEvents } from 'events-constructor';
|
|
2
|
-
import {
|
|
2
|
+
import { TInboundStats, TOutboundStats } from './types';
|
|
3
3
|
export type TEventMap = {
|
|
4
4
|
collected: {
|
|
5
|
-
outbound:
|
|
6
|
-
inbound:
|
|
5
|
+
outbound: TOutboundStats;
|
|
6
|
+
inbound: TInboundStats;
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
9
|
export declare const EVENT_NAMES: readonly ["collected"];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { EStatsTypes } from './constants';
|
|
2
2
|
export type { TEventMap } from './eventNames';
|
|
3
3
|
export { default as StatsPeerConnection } from './StatsPeerConnection';
|
|
4
|
+
export type { TInboundStats, TOutboundStats } from './types';
|
|
4
5
|
export { default as hasAvailableStats } from './utils/hasAvailableStats';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TInboundStats, TOutboundStats, TSynchronizationSources } from './types';
|
|
2
2
|
declare const parseStatsReports: ({ audioSenderStats, videoSenderFirstStats, videoSenderSecondStats, audioReceiverStats, videoReceiverFirstStats, videoReceiverSecondStats, synchronizationSources, }: {
|
|
3
3
|
audioSenderStats?: RTCStatsReport;
|
|
4
4
|
videoSenderFirstStats?: RTCStatsReport;
|
|
@@ -8,7 +8,7 @@ declare const parseStatsReports: ({ audioSenderStats, videoSenderFirstStats, vid
|
|
|
8
8
|
videoReceiverSecondStats?: RTCStatsReport;
|
|
9
9
|
synchronizationSources: TSynchronizationSources;
|
|
10
10
|
}) => {
|
|
11
|
-
inbound:
|
|
12
|
-
outbound:
|
|
11
|
+
inbound: TInboundStats;
|
|
12
|
+
outbound: TOutboundStats;
|
|
13
13
|
};
|
|
14
14
|
export default parseStatsReports;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TSynchronizationSources } from './
|
|
1
|
+
import { TSynchronizationSources } from './types';
|
|
2
2
|
declare const requestAllStatistics: (peerConnection: RTCPeerConnection) => Promise<{
|
|
3
3
|
synchronizationSources: TSynchronizationSources;
|
|
4
4
|
audioSenderStats: RTCStatsReport | undefined;
|
|
@@ -158,13 +158,13 @@ export type TInboundAudio = {
|
|
|
158
158
|
remoteOutboundRtp?: TRemoteOutboundRtp;
|
|
159
159
|
synchronizationSources?: TMedia;
|
|
160
160
|
};
|
|
161
|
-
export type
|
|
161
|
+
export type TInboundStats = {
|
|
162
162
|
video: TInboundVideo;
|
|
163
163
|
secondVideo: TInboundVideo;
|
|
164
164
|
audio: TInboundAudio;
|
|
165
165
|
additional: TAdditional;
|
|
166
166
|
};
|
|
167
|
-
export type
|
|
167
|
+
export type TOutboundStats = {
|
|
168
168
|
video: TOutboundVideo;
|
|
169
169
|
secondVideo: TOutboundVideo;
|
|
170
170
|
audio: TOutboundAudio;
|
|
@@ -23,7 +23,9 @@ export declare class SenderBalancer {
|
|
|
23
23
|
* @param headers - Заголовки от сервера с командами управления
|
|
24
24
|
* @returns Promise с результатом балансировки
|
|
25
25
|
*/
|
|
26
|
-
balance(connection: RTCPeerConnection, headers?: IMainCamHeaders): Promise<TResultSetParametersToSender
|
|
26
|
+
balance(connection: RTCPeerConnection, headers?: IMainCamHeaders): Promise<TResultSetParametersToSender & {
|
|
27
|
+
sender: RTCRtpSender | undefined;
|
|
28
|
+
}>;
|
|
27
29
|
/**
|
|
28
30
|
* Обрабатывает отправитель в зависимости от команды управления
|
|
29
31
|
* @param context - Контекст балансировки
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TrackMonitor следит за изменением MediaStreamTrack, который отправляется
|
|
3
|
+
* локальным RTCRtpSender-ом.
|
|
4
|
+
*
|
|
5
|
+
* 1. Обнаруживает смену sender или его track (replaceTrack).
|
|
6
|
+
* 2. При изменении разрешения (resize-event или polling) вызывает callback.
|
|
7
|
+
* 3. При replaceTrack вызывает callback сразу после замены и перенастраивает слежение.
|
|
8
|
+
*/
|
|
9
|
+
export declare class TrackMonitor {
|
|
10
|
+
private currentSender?;
|
|
11
|
+
private originalReplaceTrack?;
|
|
12
|
+
private lastWidth?;
|
|
13
|
+
private lastHeight?;
|
|
14
|
+
private readonly maxPollIntervalMs;
|
|
15
|
+
private currentPollIntervalMs;
|
|
16
|
+
private readonly pollIntervalMs;
|
|
17
|
+
private readonly setTimeoutRequest;
|
|
18
|
+
constructor({ pollIntervalMs, maxPollIntervalMs, }: {
|
|
19
|
+
pollIntervalMs?: number;
|
|
20
|
+
maxPollIntervalMs?: number;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
|
|
24
|
+
*/
|
|
25
|
+
subscribe(sender: RTCRtpSender | undefined, callback: () => void): void;
|
|
26
|
+
/** Останавливает всю активность мониторинга */
|
|
27
|
+
unsubscribe(): void;
|
|
28
|
+
private attachSender;
|
|
29
|
+
private detachSender;
|
|
30
|
+
private attachTrack;
|
|
31
|
+
/**
|
|
32
|
+
* Периодически опрашивает track с экспоненциальной адаптацией частоты.
|
|
33
|
+
* При отсутствии изменений интервал удваивается до maxPollIntervalMs,
|
|
34
|
+
* при обнаружении изменений сбрасывается до начального.
|
|
35
|
+
*/
|
|
36
|
+
private schedulePoll;
|
|
37
|
+
private detachTrack;
|
|
38
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiManager } from '../ApiManager';
|
|
2
2
|
import { TResultSetParametersToSender } from '../tools';
|
|
3
3
|
import { IBalancerOptions } from './types';
|
|
4
4
|
/**
|
|
@@ -9,8 +9,12 @@ declare class VideoSendingBalancer {
|
|
|
9
9
|
private readonly eventHandler;
|
|
10
10
|
private readonly senderBalancer;
|
|
11
11
|
private readonly parametersSetterWithQueue;
|
|
12
|
+
private readonly getConnection;
|
|
12
13
|
private serverHeaders?;
|
|
13
|
-
|
|
14
|
+
private readonly trackMonitor;
|
|
15
|
+
constructor(apiManager: ApiManager, getConnection: () => RTCPeerConnection | undefined, { ignoreForCodec, onSetParameters, pollIntervalMs, }?: IBalancerOptions & {
|
|
16
|
+
pollIntervalMs?: number;
|
|
17
|
+
});
|
|
14
18
|
/**
|
|
15
19
|
* Подписывается на события управления главной камерой
|
|
16
20
|
*/
|
|
@@ -23,22 +27,17 @@ declare class VideoSendingBalancer {
|
|
|
23
27
|
* Сбрасывает состояние балансировщика
|
|
24
28
|
*/
|
|
25
29
|
reset(): void;
|
|
26
|
-
/**
|
|
27
|
-
* Перебалансирует текущее состояние
|
|
28
|
-
* @returns Promise с результатом балансировки
|
|
29
|
-
*/
|
|
30
|
-
reBalance(): Promise<TResultSetParametersToSender>;
|
|
31
30
|
/**
|
|
32
31
|
* Выполняет балансировку на основе текущего состояния
|
|
33
32
|
* @returns Promise с результатом балансировки
|
|
34
33
|
*/
|
|
35
|
-
|
|
34
|
+
balance(): Promise<TResultSetParametersToSender>;
|
|
36
35
|
/**
|
|
37
36
|
* Обработчик событий управления главной камерой
|
|
38
37
|
* @param headers - Заголовки от сервера
|
|
39
38
|
*/
|
|
40
39
|
private readonly handleMainCamControl;
|
|
41
40
|
}
|
|
42
|
-
declare const resolveVideoSendingBalancer: (
|
|
41
|
+
declare const resolveVideoSendingBalancer: (apiManager: ApiManager, getConnection: () => RTCPeerConnection | undefined, options?: IBalancerOptions) => VideoSendingBalancer;
|
|
43
42
|
export default VideoSendingBalancer;
|
|
44
43
|
export { resolveVideoSendingBalancer };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiManager } from '../ApiManager';
|
|
2
2
|
import { IEventHandler, IMainCamHeaders } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Обработчик событий управления главной камерой
|
|
5
|
-
* Отвечает за подписку и отписку от событий
|
|
5
|
+
* Отвечает за подписку и отписку от событий apiManager
|
|
6
6
|
*/
|
|
7
7
|
export declare class VideoSendingEventHandler implements IEventHandler {
|
|
8
|
-
private readonly
|
|
8
|
+
private readonly apiManager;
|
|
9
9
|
private currentHandler?;
|
|
10
|
-
constructor(
|
|
10
|
+
constructor(apiManager: ApiManager);
|
|
11
11
|
/**
|
|
12
12
|
* Подписывается на события управления главной камерой
|
|
13
13
|
* @param handler - Обработчик события
|
|
@@ -17,9 +17,4 @@ export declare class VideoSendingEventHandler implements IEventHandler {
|
|
|
17
17
|
* Отписывается от событий управления главной камерой
|
|
18
18
|
*/
|
|
19
19
|
unsubscribe(): void;
|
|
20
|
-
/**
|
|
21
|
-
* Получает соединение из SipConnector
|
|
22
|
-
* @returns RTCPeerConnection или undefined
|
|
23
|
-
*/
|
|
24
|
-
getConnection(): RTCPeerConnection | undefined;
|
|
25
20
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as createMockTrack } from './createMockTrack';
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { calcScaleResolutionDownBy } from './calcResolution';
|
|
1
|
+
export type { IBalancerOptions } from './types';
|
|
3
2
|
export { resolveVideoSendingBalancer, default as VideoSendingBalancer, } from './VideoSendingBalancer';
|
|
@@ -29,7 +29,6 @@ export interface IParametersSetter {
|
|
|
29
29
|
export interface IEventHandler {
|
|
30
30
|
subscribe: (handler: (headers: IMainCamHeaders) => void) => void;
|
|
31
31
|
unsubscribe: () => void;
|
|
32
|
-
getConnection: () => RTCPeerConnection | undefined;
|
|
33
32
|
}
|
|
34
33
|
export interface ITaskQueue<T> {
|
|
35
34
|
add: (task: () => Promise<T>) => Promise<T>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ApiManager } from '../ApiManager';
|
|
2
|
+
import { CallManager } from '../CallManager';
|
|
3
|
+
import { IBalancerOptions } from '../VideoSendingBalancer/types';
|
|
4
|
+
import { TEventMap, TEvents } from './eventNames';
|
|
5
|
+
type TOptions = IBalancerOptions & {
|
|
6
|
+
balancingStartDelay?: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Менеджер для управления VideoSendingBalancer
|
|
10
|
+
* Автоматически запускает балансировку через 10 секунд после начала звонка
|
|
11
|
+
*/
|
|
12
|
+
declare class VideoSendingBalancerManager {
|
|
13
|
+
isBalancingActive: boolean;
|
|
14
|
+
readonly events: TEvents;
|
|
15
|
+
private readonly callManager;
|
|
16
|
+
private readonly balancingStartDelay;
|
|
17
|
+
private readonly videoSendingBalancer;
|
|
18
|
+
private startBalancingTimer?;
|
|
19
|
+
constructor(callManager: CallManager, apiManager: ApiManager, balancerOptions?: TOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Проверить, запланирован ли запуск балансировки
|
|
22
|
+
*/
|
|
23
|
+
get isBalancingScheduled(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Принудительно запустить балансировку
|
|
26
|
+
*/
|
|
27
|
+
startBalancing(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Остановить балансировку
|
|
30
|
+
*/
|
|
31
|
+
stopBalancing(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Выполнить ручную балансировку
|
|
34
|
+
*/
|
|
35
|
+
balance(): Promise<import('../tools').TResultSetParametersToSender>;
|
|
36
|
+
on<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
|
|
37
|
+
once<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
|
|
38
|
+
onceRace<T extends keyof TEventMap>(eventNames: T[], handler: (data: TEventMap[T], eventName: string) => void): () => void;
|
|
39
|
+
wait<T extends keyof TEventMap>(eventName: T): Promise<TEventMap[T]>;
|
|
40
|
+
off<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): void;
|
|
41
|
+
private subscribe;
|
|
42
|
+
private readonly handleCallStarted;
|
|
43
|
+
private readonly handleCallEnded;
|
|
44
|
+
private scheduleBalancingStart;
|
|
45
|
+
private clearStartTimer;
|
|
46
|
+
}
|
|
47
|
+
export default VideoSendingBalancerManager;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TypedEvents } from 'events-constructor';
|
|
2
|
+
export declare enum EEvent {
|
|
3
|
+
BALANCING_SCHEDULED = "balancing-scheduled",
|
|
4
|
+
BALANCING_STARTED = "balancing-started",
|
|
5
|
+
BALANCING_STOPPED = "balancing-stopped",
|
|
6
|
+
PARAMETERS_UPDATED = "parameters-updated"
|
|
7
|
+
}
|
|
8
|
+
export declare const EVENT_NAMES: readonly ["balancing-scheduled", "balancing-started", "balancing-stopped", "parameters-updated"];
|
|
9
|
+
export type TEvent = (typeof EVENT_NAMES)[number];
|
|
10
|
+
export type TEventMap = {
|
|
11
|
+
'balancing-scheduled': {
|
|
12
|
+
delay: number;
|
|
13
|
+
};
|
|
14
|
+
'balancing-started': {
|
|
15
|
+
delay: number;
|
|
16
|
+
};
|
|
17
|
+
'balancing-stopped': Record<string, never>;
|
|
18
|
+
'parameters-updated': RTCRtpSendParameters;
|
|
19
|
+
};
|
|
20
|
+
export type TEvents = TypedEvents<TEventMap>;
|
package/dist/doMock.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("node:events"),V=require("@krivega/jssip/lib/NameAddrHeader"),k=require("@krivega/jssip/lib/URI"),U=require("@krivega/jssip/lib/SIPMessage"),a=require("@krivega/jssip"),f=require("webrtc-mock"),S=require("events-constructor"),P=require("./@SipConnector-DV4Ywba-.cjs");class N extends U.IncomingRequest{headers;constructor(e){super(),this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)??""}}const H="incomingCall",q="declinedIncomingCall",G="failedIncomingCall",x="terminatedIncomingCall",v="connecting",z="connected",j="disconnected",Y="newRTCSession",B="registered",K="unregistered",J="registrationFailed",$="newMessage",Q="sipEvent",X="availableSecondRemoteStream",Z="notAvailableSecondRemoteStream",ee="mustStopPresentation",te="shareState",re="enterRoom",ne="useLicense",oe="peerconnection:confirmed",se="peerconnection:ontrack",ie="channels",ae="channels:notify",ce="ended:fromserver",de="main-cam-control",Ee="admin-stop-main-cam",he="admin-start-main-cam",ue="admin-stop-mic",me="admin-start-mic",le="admin-force-sync-media-state",pe="participant:added-to-list-moderators",ge="participant:removed-from-list-moderators",_e="participant:move-request-to-stream",Te="participant:move-request-to-spectators",Ie="participant:move-request-to-participants",Se="participation:accepting-word-request",Ne="participation:cancelling-word-request",we="webcast:started",Ce="webcast:stopped",Re="account:changed",fe="account:deleted",Ae="conference:participant-token-issued",Me="ended",Oe="sending",Pe="reinvite",ve="replaces",De="refer",ye="progress",Le="accepted",Fe="confirmed",We="peerconnection",be="failed",Ve="muted",ke="unmuted",Ue="newDTMF",He="newInfo",qe="hold",Ge="unhold",xe="update",ze="sdp",je="icecandidate",Ye="getusermediafailed",Be="peerconnection:createofferfailed",Ke="peerconnection:createanswerfailed",Je="peerconnection:setlocaldescriptionfailed",$e="peerconnection:setremotedescriptionfailed",Qe="presentation:start",Xe="presentation:started",Ze="presentation:end",et="presentation:ended",tt="presentation:failed",rt=[H,q,x,G,Se,Ne,_e,ae,Ae,Re,fe,we,Ce,pe,ge],D=[v,z,j,Y,B,K,J,$,Q],nt=[X,Z,ee,te,re,ne,oe,se,ie,ce,de,he,Ee,ue,me,le,Te,Ie],_=[Me,v,Oe,Pe,ve,De,ye,Le,Fe,We,be,Ve,ke,Ue,He,qe,Ge,xe,ze,je,Ye,Be,Ke,Je,$e,Qe,Xe,Ze,et,tt];[...D,...rt];[..._,...nt];class ot{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 st{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.")}}const it=["track"];class at{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(it),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=>{const t=new st({track:e});return this.senders.push(t),this.events.trigger("track",{track:e}),t}}function ct(n){const e=n.match(/(purgatory)|[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const A=400,y="777",dt=n=>n.getVideoTracks().length>0;class i extends ot{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)},A)});replaceMediaStream=jest.fn(async e=>{});isEndedInner=!1;constructor({eventHandlers:e,originator:t,remoteIdentity:r=new a.NameAddrHeader(new a.URI("sip","caller1","test1.com",5060),"Test Caller 1")}){super({originator:t,eventHandlers:e,remoteIdentity:r})}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=>{if(i.countStartsPresentation+=1,i.presentationError)throw this.trigger("presentation:start",e),this.trigger("presentation:failed",e),i.presentationError;if(i.startPresentationError&&i.countStartsPresentation<i.countStartPresentationError)throw this.trigger("presentation:start",e),this.trigger("presentation:failed",e),i.startPresentationError;return super.startPresentation(e)};stopPresentation=async e=>{if(i.presentationError)throw this.trigger("presentation:end",e),this.trigger("presentation:failed",e),i.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(dt(e)){const c=f.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),setTimeout(()=>{e.includes(y)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:"Rejected"}):(this.trigger("connecting"),setTimeout(()=>{this.newInfo({originator:P.Originator.REMOTE,request:{getHeader:s=>s==="content-type"?"application/vinteo.webrtc.roomname":s==="x-webrtc-enter-room"?r:s==="x-webrtc-participant-name"?"Test Caller 1":""}})},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},A),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&&t.kind==="audio"&&(t.enabled=!e)})}toggleMuteVideo(e){this.forEachSenders(({track:t})=>{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)}}class Et{extraHeaders=[];setExtraHeaders(e){this.extraHeaders=e}setExtraContactParams(){}}const d="PASSWORD_CORRECT",T="PASSWORD_CORRECT_2",L="NAME_INCORRECT",h=400,g={url:"wss://sipServerUrl/webrtc/wss/",sip_uri:"sip:sipServerUrl;transport=ws",via_transport:"WSS"},M={status_code:200,reason_phrase:"OK"},O={status_code:401,reason_phrase:"Unauthorized"};class o{static isAvailableTelephony=!0;static startError;static countStartError=Number.POSITIVE_INFINITY;static countStarts=0;events;registratorInner;call=jest.fn((e,t)=>{const{mediaStream:r,eventHandlers:s}=t;return this.session=new i({eventHandlers:s,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(o.countStarts+=1,o.startError&&o.countStarts<o.countStartError){this.trigger("disconnected",o.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(D);const[t,r]=e.uri.split(":"),[s,c]=r.split("@"),p={...e,uri:new a.URI(t,s,c)};this.configuration=p,this.registratorInner=new Et}static setStartError(e,{count:t=Number.POSITIVE_INFINITY}={}){o.startError=e,o.countStartError=t}static resetStartError(){o.startError=void 0,o.countStartError=Number.POSITIVE_INFINITY,o.countStarts=0}static setAvailableTelephony(){o.isAvailableTelephony=!0}static setNotAvailableTelephony(){o.isAvailableTelephony=!1}static reset(){o.resetStartError(),o.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(L)?(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:O,cause:a.C.causes.REJECTED})},h)):!this.isRegistered()&&t===!0&&(e===d||e===T)?(this.isRegisteredInner=!0,this.startedTimeout=setTimeout(()=>{this.trigger("registered",{response:M})},h)):t===!0&&e!==d&&e!==T&&(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:O,cause:a.C.causes.REJECTED})},h)),o.isAvailableTelephony?(this.trigger("connected",{socket:g}),this.isConnectedInner=!0):this.stop()}unregister(){this.isRegisteredInner=!1,this.isConnectedInner=!1,this.trigger("unregistered",{response:M})}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 b.EventEmitter{contentType;body;constructor(e,t){super(),this.contentType=e,this.body=t}}const I="remote",mt=(n,e)=>{const t=new N(e),r={originator:I,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 s=new i({originator:I,eventHandlers:{}}),c=new k("sip",e,r);s.remote_identity=new V(c,t);const p=new N([]);n.trigger("newRTCSession",{originator:I,session:s,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:o,C:{INVITE:"INVITE"}},u="user",E="displayName",m="SIP_SERVER_URL",C="SIP_WEB_SOCKET_SERVER_URL",_t=new w.WebSocketInterface(C),R={userAgent:"Chrome",sipServerUrl:m,sipWebSocketServerURL:C},Tt={...R},F={...R,user:u,password:d,register:!0},It={...F,displayName:E},St={...R,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:"",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},Rt={...l,display_name:"",register:!1},W="10.10.10.10",ft=[`X-Vinteo-Remote: ${W}`],At=()=>new P.SipConnector({JsSIP:w});exports.FAILED_CONFERENCE_NUMBER=y;exports.JsSIP=w;exports.NAME_INCORRECT=L;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=T;exports.SIP_SERVER_URL=m;exports.SIP_WEB_SOCKET_SERVER_URL=C;exports.dataForConnectionWithAuthorization=F;exports.dataForConnectionWithAuthorizationWithDisplayName=It;exports.dataForConnectionWithoutAuthorization=St;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=Tt;exports.displayName=E;exports.doMockSipConnector=At;exports.extraHeadersRemoteAddress=ft;exports.remoteAddress=W;exports.uaConfigurationWithAuthorization=Nt;exports.uaConfigurationWithAuthorizationWithDisplayName=wt;exports.uaConfigurationWithoutAuthorization=Ct;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=Rt;exports.user=u;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("node:events"),V=require("@krivega/jssip/lib/NameAddrHeader"),k=require("@krivega/jssip/lib/URI"),U=require("@krivega/jssip/lib/SIPMessage"),a=require("@krivega/jssip"),f=require("webrtc-mock"),S=require("events-constructor"),P=require("./@SipConnector-DcaeAFrM.cjs");class N extends U.IncomingRequest{headers;constructor(e){super(),this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)??""}}const H="incomingCall",q="declinedIncomingCall",G="failedIncomingCall",x="terminatedIncomingCall",v="connecting",z="connected",j="disconnected",Y="newRTCSession",B="registered",K="unregistered",J="registrationFailed",$="newMessage",Q="sipEvent",X="availableSecondRemoteStream",Z="notAvailableSecondRemoteStream",ee="mustStopPresentation",te="shareState",re="enterRoom",ne="useLicense",oe="peerconnection:confirmed",se="peerconnection:ontrack",ie="channels",ae="channels:notify",ce="ended:fromserver",de="main-cam-control",Ee="admin-stop-main-cam",he="admin-start-main-cam",ue="admin-stop-mic",me="admin-start-mic",le="admin-force-sync-media-state",pe="participant:added-to-list-moderators",ge="participant:removed-from-list-moderators",_e="participant:move-request-to-stream",Te="participant:move-request-to-spectators",Ie="participant:move-request-to-participants",Se="participation:accepting-word-request",Ne="participation:cancelling-word-request",we="webcast:started",Ce="webcast:stopped",Re="account:changed",fe="account:deleted",Ae="conference:participant-token-issued",Me="ended",Oe="sending",Pe="reinvite",ve="replaces",De="refer",ye="progress",Le="accepted",Fe="confirmed",We="peerconnection",be="failed",Ve="muted",ke="unmuted",Ue="newDTMF",He="newInfo",qe="hold",Ge="unhold",xe="update",ze="sdp",je="icecandidate",Ye="getusermediafailed",Be="peerconnection:createofferfailed",Ke="peerconnection:createanswerfailed",Je="peerconnection:setlocaldescriptionfailed",$e="peerconnection:setremotedescriptionfailed",Qe="presentation:start",Xe="presentation:started",Ze="presentation:end",et="presentation:ended",tt="presentation:failed",rt=[H,q,x,G,Se,Ne,_e,ae,Ae,Re,fe,we,Ce,pe,ge],D=[v,z,j,Y,B,K,J,$,Q],nt=[X,Z,ee,te,re,ne,oe,se,ie,ce,de,he,Ee,ue,me,le,Te,Ie],_=[Me,v,Oe,Pe,ve,De,ye,Le,Fe,We,be,Ve,ke,Ue,He,qe,Ge,xe,ze,je,Ye,Be,Ke,Je,$e,Qe,Xe,Ze,et,tt];[...D,...rt];[..._,...nt];class ot{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 st{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.")}}const it=["track"];class at{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(it),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=>{const t=new st({track:e});return this.senders.push(t),this.events.trigger("track",{track:e}),t}}function ct(n){const e=n.match(/(purgatory)|[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const A=400,y="777",dt=n=>n.getVideoTracks().length>0;class i extends ot{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)},A)});replaceMediaStream=jest.fn(async e=>{});isEndedInner=!1;constructor({eventHandlers:e,originator:t,remoteIdentity:r=new a.NameAddrHeader(new a.URI("sip","caller1","test1.com",5060),"Test Caller 1")}){super({originator:t,eventHandlers:e,remoteIdentity:r})}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=>{if(i.countStartsPresentation+=1,i.presentationError)throw this.trigger("presentation:start",e),this.trigger("presentation:failed",e),i.presentationError;if(i.startPresentationError&&i.countStartsPresentation<i.countStartPresentationError)throw this.trigger("presentation:start",e),this.trigger("presentation:failed",e),i.startPresentationError;return super.startPresentation(e)};stopPresentation=async e=>{if(i.presentationError)throw this.trigger("presentation:end",e),this.trigger("presentation:failed",e),i.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(dt(e)){const c=f.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),setTimeout(()=>{e.includes(y)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:"Rejected"}):(this.trigger("connecting"),setTimeout(()=>{this.newInfo({originator:P.Originator.REMOTE,request:{getHeader:s=>s==="content-type"?"application/vinteo.webrtc.roomname":s==="x-webrtc-enter-room"?r:s==="x-webrtc-participant-name"?"Test Caller 1":""}})},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},A),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&&t.kind==="audio"&&(t.enabled=!e)})}toggleMuteVideo(e){this.forEachSenders(({track:t})=>{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)}}class Et{extraHeaders=[];setExtraHeaders(e){this.extraHeaders=e}setExtraContactParams(){}}const d="PASSWORD_CORRECT",T="PASSWORD_CORRECT_2",L="NAME_INCORRECT",h=400,g={url:"wss://sipServerUrl/webrtc/wss/",sip_uri:"sip:sipServerUrl;transport=ws",via_transport:"WSS"},M={status_code:200,reason_phrase:"OK"},O={status_code:401,reason_phrase:"Unauthorized"};class o{static isAvailableTelephony=!0;static startError;static countStartError=Number.POSITIVE_INFINITY;static countStarts=0;events;registratorInner;call=jest.fn((e,t)=>{const{mediaStream:r,eventHandlers:s}=t;return this.session=new i({eventHandlers:s,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(o.countStarts+=1,o.startError&&o.countStarts<o.countStartError){this.trigger("disconnected",o.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(D);const[t,r]=e.uri.split(":"),[s,c]=r.split("@"),p={...e,uri:new a.URI(t,s,c)};this.configuration=p,this.registratorInner=new Et}static setStartError(e,{count:t=Number.POSITIVE_INFINITY}={}){o.startError=e,o.countStartError=t}static resetStartError(){o.startError=void 0,o.countStartError=Number.POSITIVE_INFINITY,o.countStarts=0}static setAvailableTelephony(){o.isAvailableTelephony=!0}static setNotAvailableTelephony(){o.isAvailableTelephony=!1}static reset(){o.resetStartError(),o.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(L)?(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:O,cause:a.C.causes.REJECTED})},h)):!this.isRegistered()&&t===!0&&(e===d||e===T)?(this.isRegisteredInner=!0,this.startedTimeout=setTimeout(()=>{this.trigger("registered",{response:M})},h)):t===!0&&e!==d&&e!==T&&(this.isRegisteredInner=!1,this.isConnectedInner=!1,this.startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:O,cause:a.C.causes.REJECTED})},h)),o.isAvailableTelephony?(this.trigger("connected",{socket:g}),this.isConnectedInner=!0):this.stop()}unregister(){this.isRegisteredInner=!1,this.isConnectedInner=!1,this.trigger("unregistered",{response:M})}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 b.EventEmitter{contentType;body;constructor(e,t){super(),this.contentType=e,this.body=t}}const I="remote",mt=(n,e)=>{const t=new N(e),r={originator:I,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 s=new i({originator:I,eventHandlers:{}}),c=new k("sip",e,r);s.remote_identity=new V(c,t);const p=new N([]);n.trigger("newRTCSession",{originator:I,session:s,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:o,C:{INVITE:"INVITE"}},u="user",E="displayName",m="SIP_SERVER_URL",C="SIP_WEB_SOCKET_SERVER_URL",_t=new w.WebSocketInterface(C),R={userAgent:"Chrome",sipServerUrl:m,sipWebSocketServerURL:C},Tt={...R},F={...R,user:u,password:d,register:!0},It={...F,displayName:E},St={...R,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:"",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},Rt={...l,display_name:"",register:!1},W="10.10.10.10",ft=[`X-Vinteo-Remote: ${W}`],At=()=>new P.SipConnector({JsSIP:w});exports.FAILED_CONFERENCE_NUMBER=y;exports.JsSIP=w;exports.NAME_INCORRECT=L;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=T;exports.SIP_SERVER_URL=m;exports.SIP_WEB_SOCKET_SERVER_URL=C;exports.dataForConnectionWithAuthorization=F;exports.dataForConnectionWithAuthorizationWithDisplayName=It;exports.dataForConnectionWithoutAuthorization=St;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=Tt;exports.displayName=E;exports.doMockSipConnector=At;exports.extraHeadersRemoteAddress=ft;exports.remoteAddress=W;exports.uaConfigurationWithAuthorization=Nt;exports.uaConfigurationWithAuthorizationWithDisplayName=wt;exports.uaConfigurationWithoutAuthorization=Ct;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=Rt;exports.user=u;
|