sip-connector 20.2.0 → 20.3.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/README.md +117 -2
- package/dist/@SipConnector-C-73R76v.cjs +1 -0
- package/dist/{@SipConnector-BDiunWqH.js → @SipConnector-D4SHRHKj.js} +2086 -810
- package/dist/ApiManager/@ApiManager.d.ts +1 -1
- package/dist/ApiManager/{eventNames.d.ts → events.d.ts} +1 -0
- package/dist/ApiManager/index.d.ts +2 -1
- package/dist/AutoConnectorManager/@AutoConnectorManager.d.ts +1 -1
- package/dist/AutoConnectorManager/{eventNames.d.ts → events.d.ts} +1 -0
- package/dist/AutoConnectorManager/index.d.ts +1 -0
- package/dist/CallManager/CallStateMachine.d.ts +83 -0
- package/dist/CallManager/MCUSession.d.ts +2 -1
- package/dist/CallManager/RemoteStreamsManager.d.ts +1 -0
- package/dist/CallManager/{eventNames.d.ts → events.d.ts} +2 -1
- package/dist/CallManager/index.d.ts +2 -3
- package/dist/CallManager/types.d.ts +2 -1
- package/dist/ConnectionManager/ConnectionFlow.d.ts +1 -1
- package/dist/ConnectionManager/ConnectionStateMachine.d.ts +61 -12
- package/dist/ConnectionManager/RegistrationManager.d.ts +1 -1
- package/dist/ConnectionManager/{eventNames.d.ts → events.d.ts} +2 -1
- package/dist/ConnectionManager/index.d.ts +3 -3
- package/dist/IncomingCallManager/IncomingCallStateMachine.d.ts +114 -0
- package/dist/IncomingCallManager/{eventNames.d.ts → events.d.ts} +2 -1
- package/dist/IncomingCallManager/index.d.ts +2 -1
- package/dist/MainStreamHealthMonitor/@MainStreamHealthMonitor.d.ts +16 -0
- package/dist/MainStreamHealthMonitor/events.d.ts +8 -0
- package/dist/MainStreamHealthMonitor/index.d.ts +1 -0
- package/dist/MainStreamRecovery/@MainStreamRecovery.d.ts +12 -0
- package/dist/MainStreamRecovery/index.d.ts +1 -0
- package/dist/PresentationManager/PresentationStateMachine.d.ts +101 -0
- package/dist/PresentationManager/{eventNames.d.ts → events.d.ts} +1 -0
- package/dist/PresentationManager/index.d.ts +1 -0
- package/dist/SipConnector/@SipConnector.d.ts +8 -2
- package/dist/SipConnector/events.d.ts +24 -0
- package/dist/SipConnector/index.d.ts +1 -1
- package/dist/StatsManager/@StatsManager.d.ts +14 -3
- package/dist/StatsManager/events.d.ts +2 -0
- package/dist/StatsManager/index.d.ts +1 -1
- package/dist/StatsPeerConnection/@StatsPeerConnection.d.ts +1 -1
- package/dist/StatsPeerConnection/{eventNames.d.ts → events.d.ts} +1 -0
- package/dist/StatsPeerConnection/index.d.ts +4 -3
- package/dist/StatsPeerConnection/types.d.ts +2 -0
- package/dist/VideoSendingBalancerManager/@VideoSendingBalancerManager.d.ts +1 -1
- package/dist/VideoSendingBalancerManager/{eventNames.d.ts → events.d.ts} +1 -0
- package/dist/VideoSendingBalancerManager/index.d.ts +2 -2
- package/dist/__fixtures__/RTCSessionMock.d.ts +1 -0
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +10 -9
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +206 -188
- package/dist/session/createSession.d.ts +26 -0
- package/dist/session/index.d.ts +5 -0
- package/dist/session/selectors.d.ts +10 -0
- package/dist/session/types.d.ts +20 -0
- package/dist/tools/BaseStateMachine.d.ts +18 -0
- package/dist/tools/index.d.ts +1 -1
- package/package.json +12 -9
- package/dist/@SipConnector-YhZPG7vq.cjs +0 -1
- package/dist/CallManager/@CallManager.d.ts +0 -58
- package/dist/ConnectionManager/@ConnectionManager.d.ts +0 -57
- package/dist/IncomingCallManager/@IncomingCallManager.d.ts +0 -29
- package/dist/PresentationManager/@PresentationManager.d.ts +0 -49
- package/dist/SipConnector/eventNames.d.ts +0 -23
- package/dist/StatsManager/eventNames.d.ts +0 -2
|
@@ -7,9 +7,10 @@ import { IncomingCallManager } from '../IncomingCallManager';
|
|
|
7
7
|
import { PresentationManager, TContentHint, TOnAddedTransceiver } from '../PresentationManager';
|
|
8
8
|
import { StatsManager } from '../StatsManager';
|
|
9
9
|
import { VideoSendingBalancerManager } from '../VideoSendingBalancerManager';
|
|
10
|
+
import { ISession } from '../session';
|
|
10
11
|
import { TJsSIP } from '../types';
|
|
11
12
|
import { IBalancerOptions } from '../VideoSendingBalancer';
|
|
12
|
-
import { TEventMap, TEvents } from './
|
|
13
|
+
import { TEventMap, TEvents } from './events';
|
|
13
14
|
declare class SipConnector {
|
|
14
15
|
readonly events: TEvents;
|
|
15
16
|
readonly connectionManager: ConnectionManager;
|
|
@@ -21,6 +22,9 @@ declare class SipConnector {
|
|
|
21
22
|
readonly presentationManager: PresentationManager;
|
|
22
23
|
readonly statsManager: StatsManager;
|
|
23
24
|
readonly videoSendingBalancerManager: VideoSendingBalancerManager;
|
|
25
|
+
readonly session: ISession;
|
|
26
|
+
private readonly mainStreamHealthMonitor;
|
|
27
|
+
private readonly mainStreamRecovery;
|
|
24
28
|
private readonly preferredMimeTypesVideoCodecs?;
|
|
25
29
|
private readonly excludeMimeTypesVideoCodecs?;
|
|
26
30
|
constructor({ JsSIP }: {
|
|
@@ -34,7 +38,7 @@ declare class SipConnector {
|
|
|
34
38
|
get requestedConnection(): boolean;
|
|
35
39
|
get isPendingConnect(): boolean;
|
|
36
40
|
get isPendingInitUa(): boolean;
|
|
37
|
-
get connectionState(): import('../
|
|
41
|
+
get connectionState(): import('../session').EConnectionStatus;
|
|
38
42
|
get isRegistered(): boolean;
|
|
39
43
|
get isRegisterConfig(): boolean;
|
|
40
44
|
get socket(): import('@krivega/jssip').WebSocketInterface | undefined;
|
|
@@ -108,10 +112,12 @@ declare class SipConnector {
|
|
|
108
112
|
askPermissionToEnableCam(...args: Parameters<ApiManager['askPermissionToEnableCam']>): Promise<void>;
|
|
109
113
|
private subscribeDisconnectedFromOutOfCall;
|
|
110
114
|
private subscribeConnectedWithConfigurationFromOutOfCall;
|
|
115
|
+
private mayBeStopPresentationAndNotify;
|
|
111
116
|
private subscribeToApiEvents;
|
|
112
117
|
private readonly sendOffer;
|
|
113
118
|
private setCodecPreferences;
|
|
114
119
|
private subscribe;
|
|
120
|
+
private subscribeToMainStreamHealthMonitorEvents;
|
|
115
121
|
private readonly bridgeEvents;
|
|
116
122
|
private readonly resolveHandleAddTransceiver;
|
|
117
123
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TypedEvents } from 'events-constructor';
|
|
2
|
+
import { TEventMap as TApiManagerEventMap } from '../ApiManager/events';
|
|
3
|
+
import { TEventMap as TAutoConnectorManagerEventMap } from '../AutoConnectorManager/events';
|
|
4
|
+
import { TEventMap as TCallManagerEventMap } from '../CallManager/events';
|
|
5
|
+
import { TConnectionConfigurationWithUa } from '../ConnectionManager';
|
|
6
|
+
import { TEventMap as TConnectionManagerEventMap } from '../ConnectionManager/events';
|
|
7
|
+
import { TEventMap as TIncomingCallManagerEventMap } from '../IncomingCallManager/events';
|
|
8
|
+
import { TEventMap as TPresentationManagerEventMap } from '../PresentationManager/events';
|
|
9
|
+
import { TEventMap as TStatsManagerEventMap } from '../StatsPeerConnection/events';
|
|
10
|
+
import { TEventMap as TVideoBalancerManagerEventMap } from '../VideoSendingBalancerManager/events';
|
|
11
|
+
export declare const EVENT_NAMES: readonly [...("call:connecting" | "call:accepted" | "call:ended" | "call:failed" | "connection:connecting" | "connection:connected" | "connection:registered" | "connection:disconnected" | "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:disconnecting" | "connection:newRTCSession" | "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:sending" | "call:progress" | "call:confirmed" | "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" | "call:remote-streams-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-participants" | "api:participant:move-request-to-spectators" | "api:participant:move-request-to-spectators-synthetic" | "api:participant:move-request-to-spectators-with-audio-id" | "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", "connected-with-configuration-from-out-of-call", "stopped-presentation-by-server-command"];
|
|
12
|
+
export type TEvent = (typeof EVENT_NAMES)[number];
|
|
13
|
+
type PrefixedEventMap<T extends Record<string, unknown>, Prefix extends string> = {
|
|
14
|
+
[K in keyof T as `${Prefix}:${string & K}`]: T[K];
|
|
15
|
+
};
|
|
16
|
+
type TSipConnectorEventMap = {
|
|
17
|
+
'disconnected-from-out-of-call': Record<string, never>;
|
|
18
|
+
'connected-with-configuration-from-out-of-call': TConnectionConfigurationWithUa;
|
|
19
|
+
'stopped-presentation-by-server-command': Record<string, never>;
|
|
20
|
+
};
|
|
21
|
+
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'> & TSipConnectorEventMap;
|
|
22
|
+
export type TEvents = TypedEvents<TEventMap>;
|
|
23
|
+
export declare const createEvents: () => TypedEvents<TEventMap, readonly ("call:connecting" | "call:accepted" | "call:ended" | "call:failed" | "connection:connecting" | "connection:connected" | "connection:registered" | "connection:disconnected" | "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:disconnecting" | "connection:newRTCSession" | "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:sending" | "call:progress" | "call:confirmed" | "call:newDTMF" | "call:newInfo" | "call:hold" | "call:unhold" | "call:muted" | "call:unmuted" | "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" | "call:remote-streams-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-participants" | "api:participant:move-request-to-spectators" | "api:participant:move-request-to-spectators-synthetic" | "api:participant:move-request-to-spectators-with-audio-id" | "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" | keyof TSipConnectorEventMap)[]>;
|
|
24
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as SipConnector } from './@SipConnector';
|
|
2
|
-
export type { TEvent, TEvents } from './
|
|
2
|
+
export type { TEvent, TEvents } from './events';
|
|
@@ -2,16 +2,27 @@ import { StatsPeerConnection, TEventMap } from '../StatsPeerConnection';
|
|
|
2
2
|
import { ApiManager } from '../ApiManager';
|
|
3
3
|
import { CallManager } from '../CallManager';
|
|
4
4
|
declare class StatsManager {
|
|
5
|
-
availableIncomingBitrate: number | undefined;
|
|
6
5
|
readonly statsPeerConnection: StatsPeerConnection;
|
|
6
|
+
private availableStats;
|
|
7
|
+
private previousAvailableStats;
|
|
7
8
|
private readonly callManager;
|
|
8
9
|
private readonly apiManager;
|
|
9
|
-
private previousAvailableIncomingBitrate;
|
|
10
10
|
constructor({ callManager, apiManager, }: {
|
|
11
11
|
callManager: CallManager;
|
|
12
12
|
apiManager: ApiManager;
|
|
13
13
|
});
|
|
14
|
-
get events(): import('../StatsPeerConnection
|
|
14
|
+
get events(): import('../StatsPeerConnection').TEvents;
|
|
15
|
+
get availableIncomingBitrate(): number | undefined;
|
|
16
|
+
get isNotValidFramesStats(): boolean;
|
|
17
|
+
private get previousAvailableIncomingBitrate();
|
|
18
|
+
private get previousInboundRtp();
|
|
19
|
+
private get previousFramesReceived();
|
|
20
|
+
private get previousFramesDecoded();
|
|
21
|
+
private get inboundRtp();
|
|
22
|
+
private get framesReceived();
|
|
23
|
+
private get framesDecoded();
|
|
24
|
+
private get isFramesReceived();
|
|
25
|
+
private get isFramesDecoded();
|
|
15
26
|
on<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
|
|
16
27
|
once<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
|
|
17
28
|
onceRace<T extends keyof TEventMap>(eventNames: T[], handler: (data: TEventMap[T], eventName: string) => void): () => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as StatsManager } from './@StatsManager';
|
|
2
|
-
export type { TEventMap } from './
|
|
2
|
+
export type { TEventMap } from './events';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { EStatsTypes } from './constants';
|
|
2
|
-
export type { TEventMap } from './eventNames';
|
|
3
1
|
export { default as StatsPeerConnection } from './@StatsPeerConnection';
|
|
4
|
-
export
|
|
2
|
+
export { EStatsTypes } from './constants';
|
|
3
|
+
export { createEvents } from './events';
|
|
5
4
|
export { default as hasAvailableStats } from './utils/hasAvailableStats';
|
|
5
|
+
export type { TEventMap, TEvents } from './events';
|
|
6
|
+
export type { TInboundStats, TOutboundStats, TStats } from './types';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EStatsTypes } from './constants';
|
|
2
|
+
import { TEventMap } from './events';
|
|
2
3
|
export type TMedia = {
|
|
3
4
|
trackIdentifier?: string;
|
|
4
5
|
item?: RTCRtpSynchronizationSource;
|
|
@@ -166,3 +167,4 @@ export type TParsedStatistics = {
|
|
|
166
167
|
[EStatsTypes.REMOTE_CANDIDATE]?: TCandidate;
|
|
167
168
|
[EStatsTypes.TRANSPORT]?: RTCTransportStats;
|
|
168
169
|
};
|
|
170
|
+
export type TStats = TEventMap['collected'];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApiManager } from '../ApiManager';
|
|
2
2
|
import { CallManager } from '../CallManager';
|
|
3
3
|
import { IBalancerOptions } from '../VideoSendingBalancer/types';
|
|
4
|
-
import { TEventMap, TEvents } from './
|
|
4
|
+
import { TEventMap, TEvents } from './events';
|
|
5
5
|
type TOptions = IBalancerOptions & {
|
|
6
6
|
balancingStartDelay?: number;
|
|
7
7
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default as VideoSendingBalancerManager } from './@VideoSendingBalancerManager';
|
|
2
|
-
export { EEvent, EVENT_NAMES } from './
|
|
3
|
-
export type { TEvent, TEventMap, TEvents } from './
|
|
2
|
+
export { EEvent, EVENT_NAMES } from './events';
|
|
3
|
+
export type { TEvent, TEventMap, TEvents } from './events';
|
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"),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-YhZPG7vq.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",$="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",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",We="accepted",be="confirmed",ke="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",$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=[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,We,be,ke,Ve,Ue,je,He,qe,Ge,xe,ze,Ye,Be,Ke,Je,$e,Qe,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,...t),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,...t){const r=new Event("track");Object.defineProperty(r,"track",{value:e}),Object.defineProperty(r,"streams",{value:t.length===0?[new MediaStream([e])]:t}),this.dispatchEvent(r)}}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.trigger("peerconnection",{peerconnection:this.connection}),this.addStream(e)}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,e))}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",W="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(W)?(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(`wss://${C}/webrtc/wss/`),f={displayName:"DISPLAY_NAME",userAgent:"Chrome",sipServerIp:m,sipServerUrl:C},Tt={...f,displayName:"DISPLAY_NAME",register:!1},b={...f,user:u,password:d,register:!0},It={...b,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},k="10.10.10.10",Rt=[`X-Vinteo-Remote: ${k}`],At=()=>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=I;exports.SIP_SERVER_URL=m;exports.SIP_WEB_SOCKET_SERVER_URL=C;exports.dataForConnectionWithAuthorization=b;exports.dataForConnectionWithAuthorizationWithDisplayName=It;exports.dataForConnectionWithoutAuthorization=St;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=Tt;exports.displayName=E;exports.doMockSipConnector=At;exports.extraHeadersRemoteAddress=Rt;exports.remoteAddress=k;exports.uaConfigurationWithAuthorization=Nt;exports.uaConfigurationWithAuthorizationWithDisplayName=wt;exports.uaConfigurationWithoutAuthorization=Ct;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-C-73R76v.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",$="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",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",We="accepted",be="confirmed",ke="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",$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=[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,We,be,ke,Ve,Ue,je,He,qe,Ge,xe,ze,Ye,Be,Ke,Je,$e,Qe,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,...t),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,...t){const r=new Event("track");Object.defineProperty(r,"track",{value:e}),Object.defineProperty(r,"streams",{value:t.length===0?[new MediaStream([e])]:t}),this.dispatchEvent(r)}}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;renegotiate=jest.fn(async()=>!0);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.trigger("peerconnection",{peerconnection:this.connection}),this.addStream(e)}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,e))}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",W="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(W)?(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(`wss://${C}/webrtc/wss/`),f={displayName:"DISPLAY_NAME",userAgent:"Chrome",sipServerIp:m,sipServerUrl:C},Tt={...f,displayName:"DISPLAY_NAME",register:!1},b={...f,user:u,password:d,register:!0},It={...b,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},k="10.10.10.10",Rt=[`X-Vinteo-Remote: ${k}`],At=()=>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=I;exports.SIP_SERVER_URL=m;exports.SIP_WEB_SOCKET_SERVER_URL=C;exports.dataForConnectionWithAuthorization=b;exports.dataForConnectionWithAuthorizationWithDisplayName=It;exports.dataForConnectionWithoutAuthorization=St;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=Tt;exports.displayName=E;exports.doMockSipConnector=At;exports.extraHeadersRemoteAddress=Rt;exports.remoteAddress=k;exports.uaConfigurationWithAuthorization=Nt;exports.uaConfigurationWithAuthorizationWithDisplayName=wt;exports.uaConfigurationWithoutAuthorization=Ct;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=ft;exports.user=u;
|
package/dist/doMock.js
CHANGED
|
@@ -3,9 +3,9 @@ import k from "@krivega/jssip/lib/NameAddrHeader";
|
|
|
3
3
|
import F from "@krivega/jssip/lib/URI";
|
|
4
4
|
import { IncomingRequest as b } from "@krivega/jssip/lib/SIPMessage";
|
|
5
5
|
import { NameAddrHeader as V, URI as E, SessionStatus as W, C as N } from "@krivega/jssip";
|
|
6
|
-
import { MediaStreamTrackMock as
|
|
6
|
+
import { MediaStreamTrackMock as j, createAudioMediaStreamTrackMock as U, createVideoMediaStreamTrackMock as G } from "webrtc-mock";
|
|
7
7
|
import { Events as O } from "events-constructor";
|
|
8
|
-
import { O as H, S as x } from "./@SipConnector-
|
|
8
|
+
import { O as H, S as x } from "./@SipConnector-D4SHRHKj.js";
|
|
9
9
|
class T extends b {
|
|
10
10
|
headers;
|
|
11
11
|
constructor(e) {
|
|
@@ -15,7 +15,7 @@ class T extends b {
|
|
|
15
15
|
return this.headers.get(e) ?? "";
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
const Y = "incomingCall", q = "declinedIncomingCall", z = "failedIncomingCall", B = "terminatedIncomingCall", P = "connecting", K = "connected", $ = "disconnected", J = "newRTCSession", Q = "registered", X = "unregistered", Z = "registrationFailed", ee = "newMessage", te = "sipEvent", re = "availableSecondRemoteStream", ne = "notAvailableSecondRemoteStream", oe = "mustStopPresentation", se = "shareState", ie = "enterRoom", ae = "useLicense", ce = "peerconnection:confirmed", de = "peerconnection:ontrack", Ee = "channels", he = "channels:notify", me = "ended:fromserver", ue = "main-cam-control", le = "admin-stop-main-cam", pe = "admin-start-main-cam", ge = "admin-stop-mic", Te = "admin-start-mic", _e = "admin-force-sync-media-state", Ie = "participant:added-to-list-moderators", Se = "participant:removed-from-list-moderators", Ne = "participant:move-request-to-stream", we = "participant:move-request-to-spectators", fe = "participant:move-request-to-participants", Ce = "participation:accepting-word-request", Re = "participation:cancelling-word-request", Ae = "webcast:started", Me = "webcast:stopped", Oe = "account:changed", Pe = "account:deleted", ve = "conference:participant-token-issued", De = "ended", ye = "sending", Le = "reinvite", ke = "replaces", Fe = "refer", be = "progress", Ve = "accepted", We = "confirmed",
|
|
18
|
+
const Y = "incomingCall", q = "declinedIncomingCall", z = "failedIncomingCall", B = "terminatedIncomingCall", P = "connecting", K = "connected", $ = "disconnected", J = "newRTCSession", Q = "registered", X = "unregistered", Z = "registrationFailed", ee = "newMessage", te = "sipEvent", re = "availableSecondRemoteStream", ne = "notAvailableSecondRemoteStream", oe = "mustStopPresentation", se = "shareState", ie = "enterRoom", ae = "useLicense", ce = "peerconnection:confirmed", de = "peerconnection:ontrack", Ee = "channels", he = "channels:notify", me = "ended:fromserver", ue = "main-cam-control", le = "admin-stop-main-cam", pe = "admin-start-main-cam", ge = "admin-stop-mic", Te = "admin-start-mic", _e = "admin-force-sync-media-state", Ie = "participant:added-to-list-moderators", Se = "participant:removed-from-list-moderators", Ne = "participant:move-request-to-stream", we = "participant:move-request-to-spectators", fe = "participant:move-request-to-participants", Ce = "participation:accepting-word-request", Re = "participation:cancelling-word-request", Ae = "webcast:started", Me = "webcast:stopped", Oe = "account:changed", Pe = "account:deleted", ve = "conference:participant-token-issued", De = "ended", ye = "sending", Le = "reinvite", ke = "replaces", Fe = "refer", be = "progress", Ve = "accepted", We = "confirmed", je = "peerconnection", Ue = "failed", Ge = "muted", He = "unmuted", xe = "newDTMF", Ye = "newInfo", qe = "hold", ze = "unhold", Be = "update", Ke = "sdp", $e = "icecandidate", Je = "getusermediafailed", Qe = "peerconnection:createofferfailed", Xe = "peerconnection:createanswerfailed", Ze = "peerconnection:setlocaldescriptionfailed", et = "peerconnection:setremotedescriptionfailed", tt = "presentation:start", rt = "presentation:started", nt = "presentation:end", ot = "presentation:ended", st = "presentation:failed", it = [
|
|
19
19
|
Y,
|
|
20
20
|
q,
|
|
21
21
|
B,
|
|
@@ -70,8 +70,8 @@ const Y = "incomingCall", q = "declinedIncomingCall", z = "failedIncomingCall",
|
|
|
70
70
|
be,
|
|
71
71
|
Ve,
|
|
72
72
|
We,
|
|
73
|
-
Ue,
|
|
74
73
|
je,
|
|
74
|
+
Ue,
|
|
75
75
|
Ge,
|
|
76
76
|
He,
|
|
77
77
|
xe,
|
|
@@ -421,7 +421,7 @@ class dt extends EventTarget {
|
|
|
421
421
|
return t === void 0 ? o.mid = e.kind === "audio" ? "0" : "1" : o.mid = t, this.senders.push(r), this.dispatchTrackInternal(e), r;
|
|
422
422
|
};
|
|
423
423
|
dispatchTrack(e) {
|
|
424
|
-
this.dispatchTrackInternal(new
|
|
424
|
+
this.dispatchTrackInternal(new j(e));
|
|
425
425
|
}
|
|
426
426
|
dispatchTrackInternal(e, ...t) {
|
|
427
427
|
const r = new Event(
|
|
@@ -449,6 +449,7 @@ class i extends ct {
|
|
|
449
449
|
static countStartsPresentation = 0;
|
|
450
450
|
url;
|
|
451
451
|
status_code;
|
|
452
|
+
renegotiate = jest.fn(async () => !0);
|
|
452
453
|
/**
|
|
453
454
|
* answer
|
|
454
455
|
*
|
|
@@ -533,7 +534,7 @@ class i extends ct {
|
|
|
533
534
|
return e ? (this.createPeerconnection(e), !0) : !1;
|
|
534
535
|
}
|
|
535
536
|
createPeerconnection(e) {
|
|
536
|
-
const t =
|
|
537
|
+
const t = U();
|
|
537
538
|
t.id = "mainaudio1";
|
|
538
539
|
const r = [t];
|
|
539
540
|
if (mt(e)) {
|
|
@@ -873,7 +874,7 @@ const g = "remote", Tt = (n, e) => {
|
|
|
873
874
|
...m,
|
|
874
875
|
display_name: "DISPLAY_NAME",
|
|
875
876
|
register: !1
|
|
876
|
-
}, ft = "10.10.10.10",
|
|
877
|
+
}, ft = "10.10.10.10", jt = [`X-Vinteo-Remote: ${ft}`], Ut = () => new x({
|
|
877
878
|
JsSIP: D
|
|
878
879
|
});
|
|
879
880
|
export {
|
|
@@ -889,8 +890,8 @@ export {
|
|
|
889
890
|
kt as dataForConnectionWithoutAuthorization,
|
|
890
891
|
yt as dataForConnectionWithoutAuthorizationWithoutDisplayName,
|
|
891
892
|
h as displayName,
|
|
892
|
-
|
|
893
|
-
|
|
893
|
+
Ut as doMockSipConnector,
|
|
894
|
+
jt as extraHeadersRemoteAddress,
|
|
894
895
|
ft as remoteAddress,
|
|
895
896
|
Ft as uaConfigurationWithAuthorization,
|
|
896
897
|
bt as uaConfigurationWithAuthorizationWithDisplayName,
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("events-constructor");const o=require("./@SipConnector-YhZPG7vq.cjs"),k=require("@krivega/cancelable-promise"),$=require("repeated-calls"),q=require("ts-debounce"),W=require("ua-parser-js"),H=require("sequent-promises"),j=require("stack-promises"),K=n=>n instanceof Object&&("originator"in n||"cause"in n),X=n=>{if(k.isCanceledError(n))return!0;if(!K(n))return!1;const{originator:e,cause:t}=n;return typeof t=="string"?t===o.ECallCause.REQUEST_TIMEOUT||t===o.ECallCause.REJECTED||e==="local"&&(t===o.ECallCause.CANCELED||t===o.ECallCause.BYE):!1},Y=()=>globalThis.process?.versions?.electron!==void 0,L=()=>{const n=new W.UAParser,{name:e}=n.getBrowser(),t=Y();return{isChrome:e==="Chrome"||t}},M=n=>{const{url:e,cause:t}=n;let r=e;return(t===o.ECallCause.BAD_MEDIA_DESCRIPTION||t===o.ECallCause.NOT_FOUND)&&(r=`${n.message.to.uri.user}@${n.message.to.uri.host}`),r};var V=(n=>(n.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",n.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",n.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",n.NOT_FOUND_ERROR="NOT_FOUND_ERROR",n.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",n.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",n))(V||{});const G=new Error("Unknown error"),J=(n=G)=>{const{cause:e,socket:t}=n;let r="CONNECT_SERVER_FAILED";switch(e){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case o.ECallCause.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case o.ECallCause.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t!==void 0&&t._ws?.readyState===3?r="WS_CONNECTION_FAILED":M(n)!==void 0&&M(n)!==""&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},z=n=>{let e="";try{e=JSON.stringify(n)}catch(t){o.logger("failed to stringify message",t)}return e},Q=new Error("Unknown error"),Z=(n=Q)=>{const{code:e,cause:t,message:r}=n,a=M(n),s={code:"",cause:"",message:""};return typeof r=="object"&&r!==null?s.message=z(r):r&&(s.message=String(r)),a!==void 0&&a!==""&&(s.link=a),e!==void 0&&e!==""&&(s.code=e),t!==void 0&&t!==""&&(s.cause=t),s},ee=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:V,getLinkError:M,getTypeFromError:J,getValuesFromError:Z},Symbol.toStringTag,{value:"Module"})),ne=({sessionId:n,remoteAddress:e,isMutedAudio:t,isMutedVideo:r,isRegistered:a,isPresentationCall:s})=>{const c=[],l=t?"0":"1",g=r?"0":"1";return c.push(`X-Vinteo-Mic-State: ${l}`,`X-Vinteo-MainCam-State: ${g}`),(a===!1||a===void 0)&&c.push("X-Vinteo-Purgatory-Call: yes"),n!==void 0&&n!==""&&c.push(`X-Vinteo-Session: ${n}`),s===!0&&c.push("X-Vinteo-Presentation-Call: yes"),e!==void 0&&e!==""&&c.push(`X-Vinteo-Remote: ${e}`),c},te="[@*!|]",oe="_",re=n=>{let e=n;return e=e.replaceAll(new RegExp(te,"g"),oe),e},se=({appName:n,appVersion:e,browserName:t,browserVersion:r})=>{const s=`${re(n)} ${e}`;return`ChromeNew - ${t===void 0?s:`${t} ${r}, ${s}`}`},ae=({isUnifiedSdpSemantic:n,appVersion:e,browserName:t,browserVersion:r,appName:a})=>n?se({appVersion:e,browserName:t,browserVersion:r,appName:a}):"Chrome",x="purgatory",y=n=>n===x,ce=n=>e=>[...e].map(r=>async()=>n(r)),ie=async({accumulatedKeys:n,sendKey:e,canRunTask:t})=>{const a=ce(e)(n);return H.sequentPromises(a,t)},le=n=>t=>(o.logger("onStartMainCam"),n.on("api:admin-start-main-cam",t)),ue=n=>t=>(o.logger("onStartMic"),n.on("api:admin-start-mic",t)),ge=n=>t=>(o.logger("onStopMainCam"),n.on("api:admin-stop-main-cam",t)),de=n=>t=>(o.logger("onStopMic"),n.on("api:admin-stop-mic",t)),Ce=({sipConnector:n})=>{const e=(u,d)=>({isSyncForced:C})=>{if(C===!0){u();return}d()},t=le(n),r=ge(n),a=ue(n),s=de(n);let c,l,g,p;const b=({onStartMainCamForced:u,onStartMainCamNotForced:d,onStopMainCamForced:C,onStopMainCamNotForced:h,onStartMicForced:R,onStartMicNotForced:O,onStopMicForced:_,onStopMicNotForced:v})=>{const S=e(u,d);c=t(S);const f=e(C,h);l=r(f);const N=e(R,O);g=a(N);const m=e(_,v);p=s(m)},P=()=>{c?.(),l?.(),g?.(),p?.()};return{start:u=>{b(u)},stop:()=>{P()}}},Se=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:x,createSyncMediaState:Ce,createUaParser:L,error:ee,getExtraHeaders:ne,getUserAgent:ae,hasPurgatory:y,prepareMediaStream:o.prepareMediaStream,sendDtmfAccumulated:ie,sendOffer:o.sendOffer,setEncodingsToSender:o.setEncodingsToSender,setParametersToSender:o.setParametersToSender},Symbol.toStringTag,{value:"Module"})),fe=()=>L().isChrome,me=n=>{if(!k.isCanceledError(n)&&!$.hasCanceledError(n)&&!o.hasNotReadyForConnectionError(n))throw n;return{configuration:void 0,isSuccessful:!1}},pe=({kind:n,readyState:e})=>n==="video"&&e==="live",w=(n,e,{onEnterPurgatory:t,onEnterConference:r})=>{y(n)?t&&t():r&&r({isSuccessProgressCall:e})},I=(n,e)=>{n(),e&&e()},U=(n,e,t)=>{throw n&&n(),e(),t},Ee=new Set(["on","once","onceRace","wait","off","sendDTMF","hangUp","declineToIncomingCall","sendChannels","checkTelephony","waitChannels","ping","startAutoConnect","stopAutoConnect","connection","isConfigured","isRegistered"]);class he{on;once;onceRace;wait;off;sendDTMF;hangUp;declineToIncomingCall;sendChannels;checkTelephony;waitChannels;ping;startAutoConnect;stopAutoConnect;connection;isConfigured;isRegistered;sipConnector;constructor(e){return this.sipConnector=e,new Proxy(this,{get:(t,r,a)=>{if(typeof r=="string"&&Ee.has(r)&&r in this.sipConnector){const c=Reflect.get(this.sipConnector,r,this.sipConnector);return typeof c=="function"?c.bind(this.sipConnector):c}const s=Reflect.get(t,r,a);return typeof s=="function"?s.bind(t):s}})}connectToServer=async(e,t)=>this.sipConnector.connect(e,t).then(r=>(o.logger("connectToServer then"),{configuration:r,isSuccessful:!0})).catch(async r=>(o.logger("connectToServer catch: error",r),me(r)));callToServer=async e=>{const{conference:t,mediaStream:r,extraHeaders:a,iceServers:s,contentHint:c,degradationPreference:l,sendEncodings:g,offerToReceiveAudio:p,offerToReceiveVideo:b,directionVideo:P,directionAudio:T,onBeforeProgressCall:E,onSuccessProgressCall:u,onEnterPurgatory:d,onEnterConference:C,onFailProgressCall:h,onFinishProgressCall:R,onEndedCall:O,onAddedTransceiver:_}=e;o.logger("callToServer",e);const v=async()=>(o.logger("startCall"),this.sipConnector.call({mediaStream:r,extraHeaders:a,iceServers:s,contentHint:c,offerToReceiveAudio:p,offerToReceiveVideo:b,directionVideo:P,directionAudio:T,degradationPreference:l,onAddedTransceiver:_,sendEncodings:g,number:t}));let S=!1,f;const m=(o.logger("subscribeEnterConference: onEnterConference",C),this.sipConnector.on("api:enterRoom",({room:i})=>{o.logger("enterRoom",{_room:i,isSuccessProgressCall:S}),f=i,(d??C)&&w(f,S,{onEnterPurgatory:d,onEnterConference:C})})),A=i=>(o.logger("onSuccess"),S=!0,u&&u({isPurgatory:y(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{I(m,O)}),i),F=i=>(o.logger("onFail"),U(h,m,i)),D=()=>{o.logger("onFinish"),R&&R()};return o.logger("onBeforeProgressCall"),E&&E(t),v().then(A).catch(i=>F(i)).finally(D)};disconnectFromServer=async()=>this.sipConnector.disconnect().then(()=>(o.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(o.logger("disconnectFromServer: catch",e),{isSuccessful:!1}));answerToIncomingCall=async e=>{const{mediaStream:t,extraHeaders:r,iceServers:a,contentHint:s,degradationPreference:c,sendEncodings:l,offerToReceiveAudio:g,offerToReceiveVideo:p,directionVideo:b,directionAudio:P,onBeforeProgressCall:T,onSuccessProgressCall:E,onEnterPurgatory:u,onEnterConference:d,onFailProgressCall:C,onFinishProgressCall:h,onEndedCall:R,onAddedTransceiver:O}=e;o.logger("answerToIncomingCall",e);const _=async()=>this.sipConnector.answerToIncomingCall({mediaStream:t,extraHeaders:r,iceServers:a,contentHint:s,offerToReceiveAudio:g,offerToReceiveVideo:p,directionVideo:b,directionAudio:P,degradationPreference:c,onAddedTransceiver:O,sendEncodings:l}),v=()=>{const{remoteCallerData:i}=this.sipConnector;return i.incomingNumber};let S=!1,f;const m=(o.logger("subscribeEnterConference: onEnterConference",d),this.sipConnector.on("api:enterRoom",i=>{o.logger("enterRoom",{room:i.room,isSuccessProgressCall:S}),f=i.room,(u??d)&&w(f,S,{onEnterPurgatory:u,onEnterConference:d})})),A=i=>(o.logger("onSuccess"),S=!0,E&&E({isPurgatory:y(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{I(m,R)}),i),F=i=>(o.logger("onFail"),U(C,m,i)),D=()=>{o.logger("onFinish"),h&&h()};if(o.logger("onBeforeProgressCall"),T){const i=v();T(i)}return _().then(A).catch(i=>F(i)).finally(D)};updatePresentation=async({mediaStream:e,isP2P:t,contentHint:r,degradationPreference:a,sendEncodings:s,onAddedTransceiver:c})=>(o.logger("updatePresentation"),this.sipConnector.updatePresentation(e,{isP2P:t,contentHint:r,degradationPreference:a,onAddedTransceiver:c,sendEncodings:s}));startPresentation=async({mediaStream:e,isP2P:t,contentHint:r,degradationPreference:a,sendEncodings:s,callLimit:c,onAddedTransceiver:l})=>(o.logger("startPresentation"),this.sipConnector.startPresentation(e,{isP2P:t,contentHint:r,callLimit:c,degradationPreference:a,onAddedTransceiver:l,sendEncodings:s}));stopShareSipConnector=async({isP2P:e=!1}={})=>(o.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{o.logger(t)}));sendRefusalToTurnOnMic=async()=>{o.logger("sendRefusalToTurnOnMic"),await this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{o.logger("sendRefusalToTurnOnMic: error",e)})};sendRefusalToTurnOnCam=async()=>{o.logger("sendRefusalToTurnOnCam"),await this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{o.logger("sendRefusalToTurnOnCam: error",e)})};sendMediaState=async({isEnabledCam:e,isEnabledMic:t})=>{o.logger("sendMediaState"),await this.sipConnector.sendMediaState({cam:e,mic:t})};replaceMediaStream=async(e,{deleteExisting:t,addMissing:r,forceRenegotiation:a,contentHint:s,degradationPreference:c,sendEncodings:l,onAddedTransceiver:g})=>(o.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(e,{deleteExisting:t,addMissing:r,forceRenegotiation:a,contentHint:s,degradationPreference:c,onAddedTransceiver:g,sendEncodings:l}));askPermissionToEnableCam=async()=>{o.logger("askPermissionToEnableCam"),await this.sipConnector.askPermissionToEnableCam()};resolveHandleReadyRemoteStreamsDebounced=({onReadyRemoteStreams:e})=>q.debounce(()=>{const t=this.sipConnector.getRemoteStreams();o.logger("remoteStreams",t),e(t)},200);resolveHandleReadyRemoteStreams=({onReadyRemoteStreams:e})=>({track:t})=>{pe(t)&&e()};getRemoteStreams=()=>(o.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams());onUseLicense=e=>(o.logger("onUseLicense"),this.sipConnector.on("api:useLicense",e));onMustStopPresentation=e=>(o.logger("onMustStopPresentation"),this.sipConnector.on("api:mustStopPresentation",e));onMoveToSpectators=e=>(o.logger("onMoveToSpectators"),this.sipConnector.on("api:participant:move-request-to-spectators",e));onMoveToParticipants=e=>(o.logger("onMoveToParticipants"),this.sipConnector.on("api:participant:move-request-to-participants",e));onStats=e=>(o.logger("onStats"),this.sipConnector.on("stats:collected",e));offStats=e=>{o.logger("offStats"),this.sipConnector.off("stats:collected",e)}}var B=(n=>(n.VP8="video/VP8",n.VP9="video/VP9",n.H264="video/H264",n.AV1="video/AV1",n.rtx="video/rtx",n.red="video/red",n.flexfec03="video/flexfec-03",n))(B||{});exports.ECallCause=o.ECallCause;exports.EStatsTypes=o.EStatsTypes;exports.EUseLicense=o.EUseLicense;exports.SipConnector=o.SipConnector;exports.StatsPeerConnection=o.StatsPeerConnection;exports.disableDebug=o.disableDebug;exports.enableDebug=o.enableDebug;exports.getCodecFromSender=o.getCodecFromSender;exports.hasCanceledStartPresentationError=o.hasCanceledStartPresentationError;Object.defineProperty(exports,"hasConnectionPromiseIsNotActualError",{enumerable:!0,get:()=>j.isPromiseIsNotActualError});exports.EMimeTypesVideoCodecs=B;exports.SipConnectorFacade=he;exports.hasAvailableStats=fe;exports.hasCanceledCallError=X;exports.tools=Se;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./@SipConnector-C-73R76v.cjs");require("events-constructor");const k=require("@krivega/cancelable-promise"),q=require("repeated-calls"),W=require("ts-debounce"),H=require("ua-parser-js"),j=require("sequent-promises"),K=require("stack-promises"),X=e=>e instanceof Object&&("originator"in e||"cause"in e),Y=e=>{if(k.isCanceledError(e))return!0;if(!X(e))return!1;const{originator:n,cause:o}=e;return typeof o=="string"?o===t.ECallCause.REQUEST_TIMEOUT||o===t.ECallCause.REJECTED||n==="local"&&(o===t.ECallCause.CANCELED||o===t.ECallCause.BYE):!1},G=e=>e.connection.value,L=e=>e.call.value,J=e=>e.incoming.value,z=e=>{if(e.incoming.value!==t.EState$1.IDLE)return e.incoming.context.remoteCallerData},Q=e=>e.presentation.value,Z=e=>{const n=L(e);return n===t.EState.IN_CALL||n===t.EState.ACCEPTED},ee={selectConnectionStatus:G,selectCallStatus:L,selectIncomingStatus:J,selectIncomingRemoteCaller:z,selectPresentationStatus:Q,selectIsInCall:Z},ne=()=>globalThis.process?.versions?.electron!==void 0,V=()=>{const e=new H.UAParser,{name:n}=e.getBrowser(),o=ne();return{isChrome:n==="Chrome"||o}},M=e=>{const{url:n,cause:o}=e;let r=n;return(o===t.ECallCause.BAD_MEDIA_DESCRIPTION||o===t.ECallCause.NOT_FOUND)&&(r=`${e.message.to.uri.user}@${e.message.to.uri.host}`),r};var x=(e=>(e.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",e.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",e.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",e.NOT_FOUND_ERROR="NOT_FOUND_ERROR",e.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",e.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",e))(x||{});const te=new Error("Unknown error"),oe=(e=te)=>{const{cause:n,socket:o}=e;let r="CONNECT_SERVER_FAILED";switch(n){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case t.ECallCause.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case t.ECallCause.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:o!==void 0&&o._ws?.readyState===3?r="WS_CONNECTION_FAILED":M(e)!==void 0&&M(e)!==""&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},re=e=>{let n="";try{n=JSON.stringify(e)}catch(o){t.logger("failed to stringify message",o)}return n},se=new Error("Unknown error"),ae=(e=se)=>{const{code:n,cause:o,message:r}=e,a=M(e),s={code:"",cause:"",message:""};return typeof r=="object"&&r!==null?s.message=re(r):r&&(s.message=String(r)),a!==void 0&&a!==""&&(s.link=a),n!==void 0&&n!==""&&(s.code=n),o!==void 0&&o!==""&&(s.cause=o),s},ce=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:x,getLinkError:M,getTypeFromError:oe,getValuesFromError:ae},Symbol.toStringTag,{value:"Module"})),ie=({sessionId:e,remoteAddress:n,isMutedAudio:o,isMutedVideo:r,isRegistered:a,isPresentationCall:s})=>{const c=[],l=o?"0":"1",g=r?"0":"1";return c.push(`X-Vinteo-Mic-State: ${l}`,`X-Vinteo-MainCam-State: ${g}`),(a===!1||a===void 0)&&c.push("X-Vinteo-Purgatory-Call: yes"),e!==void 0&&e!==""&&c.push(`X-Vinteo-Session: ${e}`),s===!0&&c.push("X-Vinteo-Presentation-Call: yes"),n!==void 0&&n!==""&&c.push(`X-Vinteo-Remote: ${n}`),c},le="[@*!|]",ue="_",ge=e=>{let n=e;return n=n.replaceAll(new RegExp(le,"g"),ue),n},Ce=({appName:e,appVersion:n,browserName:o,browserVersion:r})=>{const s=`${ge(e)} ${n}`;return`ChromeNew - ${o===void 0?s:`${o} ${r}, ${s}`}`},de=({isUnifiedSdpSemantic:e,appVersion:n,browserName:o,browserVersion:r,appName:a})=>e?Ce({appVersion:n,browserName:o,browserVersion:r,appName:a}):"Chrome",$="purgatory",y=e=>e===$,Se=e=>n=>[...n].map(r=>async()=>e(r)),fe=async({accumulatedKeys:e,sendKey:n,canRunTask:o})=>{const a=Se(n)(e);return j.sequentPromises(a,o)},me=e=>o=>(t.logger("onStartMainCam"),e.on("api:admin-start-main-cam",o)),Ee=e=>o=>(t.logger("onStartMic"),e.on("api:admin-start-mic",o)),pe=e=>o=>(t.logger("onStopMainCam"),e.on("api:admin-stop-main-cam",o)),he=e=>o=>(t.logger("onStopMic"),e.on("api:admin-stop-mic",o)),Re=({sipConnector:e})=>{const n=(u,C)=>({isSyncForced:d})=>{if(d===!0){u();return}C()},o=me(e),r=pe(e),a=Ee(e),s=he(e);let c,l,g,E;const b=({onStartMainCamForced:u,onStartMainCamNotForced:C,onStopMainCamForced:d,onStopMainCamNotForced:h,onStartMicForced:R,onStartMicNotForced:T,onStopMicForced:O,onStopMicNotForced:_})=>{const S=n(u,C);c=o(S);const f=n(d,h);l=r(f);const A=n(R,T);g=a(A);const m=n(O,_);E=s(m)},P=()=>{c?.(),l?.(),g?.(),E?.()};return{start:u=>{b(u)},stop:()=>{P()}}},be=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:$,createSyncMediaState:Re,createUaParser:V,error:ce,getExtraHeaders:ie,getUserAgent:de,hasPurgatory:y,prepareMediaStream:t.prepareMediaStream,sendDtmfAccumulated:fe,sendOffer:t.sendOffer,setEncodingsToSender:t.setEncodingsToSender,setParametersToSender:t.setParametersToSender},Symbol.toStringTag,{value:"Module"})),Pe=()=>V().isChrome,ve=e=>{if(!k.isCanceledError(e)&&!q.hasCanceledError(e)&&!t.hasNotReadyForConnectionError(e))throw e;return{configuration:void 0,isSuccessful:!1}},Te=({kind:e,readyState:n})=>e==="video"&&n==="live",I=(e,n,{onEnterPurgatory:o,onEnterConference:r})=>{y(e)?o&&o():r&&r({isSuccessProgressCall:n})},w=(e,n)=>{e(),n&&n()},U=(e,n,o)=>{throw e&&e(),n(),o},Oe=new Set(["on","once","onceRace","wait","off","sendDTMF","hangUp","declineToIncomingCall","sendChannels","checkTelephony","waitChannels","ping","startAutoConnect","stopAutoConnect","connection","isConfigured","isRegistered"]);class _e{on;once;onceRace;wait;off;sendDTMF;hangUp;declineToIncomingCall;sendChannels;checkTelephony;waitChannels;ping;startAutoConnect;stopAutoConnect;connection;isConfigured;isRegistered;sipConnector;constructor(n){return this.sipConnector=n,new Proxy(this,{get:(o,r,a)=>{if(typeof r=="string"&&Oe.has(r)&&r in this.sipConnector){const c=Reflect.get(this.sipConnector,r,this.sipConnector);return typeof c=="function"?c.bind(this.sipConnector):c}const s=Reflect.get(o,r,a);return typeof s=="function"?s.bind(o):s}})}connectToServer=async(n,o)=>this.sipConnector.connect(n,o).then(r=>(t.logger("connectToServer then"),{configuration:r,isSuccessful:!0})).catch(async r=>(t.logger("connectToServer catch: error",r),ve(r)));callToServer=async n=>{const{conference:o,mediaStream:r,extraHeaders:a,iceServers:s,contentHint:c,degradationPreference:l,sendEncodings:g,offerToReceiveAudio:E,offerToReceiveVideo:b,directionVideo:P,directionAudio:v,onBeforeProgressCall:p,onSuccessProgressCall:u,onEnterPurgatory:C,onEnterConference:d,onFailProgressCall:h,onFinishProgressCall:R,onEndedCall:T,onAddedTransceiver:O}=n;t.logger("callToServer",n);const _=async()=>(t.logger("startCall"),this.sipConnector.call({mediaStream:r,extraHeaders:a,iceServers:s,contentHint:c,offerToReceiveAudio:E,offerToReceiveVideo:b,directionVideo:P,directionAudio:v,degradationPreference:l,onAddedTransceiver:O,sendEncodings:g,number:o}));let S=!1,f;const m=(t.logger("subscribeEnterConference: onEnterConference",d),this.sipConnector.on("api:enterRoom",({room:i})=>{t.logger("enterRoom",{_room:i,isSuccessProgressCall:S}),f=i,(C??d)&&I(f,S,{onEnterPurgatory:C,onEnterConference:d})})),N=i=>(t.logger("onSuccess"),S=!0,u&&u({isPurgatory:y(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{w(m,T)}),i),D=i=>(t.logger("onFail"),U(h,m,i)),F=()=>{t.logger("onFinish"),R&&R()};return t.logger("onBeforeProgressCall"),p&&p(o),_().then(N).catch(i=>D(i)).finally(F)};disconnectFromServer=async()=>this.sipConnector.disconnect().then(()=>(t.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(n=>(t.logger("disconnectFromServer: catch",n),{isSuccessful:!1}));answerToIncomingCall=async n=>{const{mediaStream:o,extraHeaders:r,iceServers:a,contentHint:s,degradationPreference:c,sendEncodings:l,offerToReceiveAudio:g,offerToReceiveVideo:E,directionVideo:b,directionAudio:P,onBeforeProgressCall:v,onSuccessProgressCall:p,onEnterPurgatory:u,onEnterConference:C,onFailProgressCall:d,onFinishProgressCall:h,onEndedCall:R,onAddedTransceiver:T}=n;t.logger("answerToIncomingCall",n);const O=async()=>this.sipConnector.answerToIncomingCall({mediaStream:o,extraHeaders:r,iceServers:a,contentHint:s,offerToReceiveAudio:g,offerToReceiveVideo:E,directionVideo:b,directionAudio:P,degradationPreference:c,onAddedTransceiver:T,sendEncodings:l}),_=()=>{const{remoteCallerData:i}=this.sipConnector;return i.incomingNumber};let S=!1,f;const m=(t.logger("subscribeEnterConference: onEnterConference",C),this.sipConnector.on("api:enterRoom",i=>{t.logger("enterRoom",{room:i.room,isSuccessProgressCall:S}),f=i.room,(u??C)&&I(f,S,{onEnterPurgatory:u,onEnterConference:C})})),N=i=>(t.logger("onSuccess"),S=!0,p&&p({isPurgatory:y(f)}),this.sipConnector.onceRace(["call:ended","call:failed"],()=>{w(m,R)}),i),D=i=>(t.logger("onFail"),U(d,m,i)),F=()=>{t.logger("onFinish"),h&&h()};if(t.logger("onBeforeProgressCall"),v){const i=_();v(i)}return O().then(N).catch(i=>D(i)).finally(F)};updatePresentation=async({mediaStream:n,isP2P:o,contentHint:r,degradationPreference:a,sendEncodings:s,onAddedTransceiver:c})=>(t.logger("updatePresentation"),this.sipConnector.updatePresentation(n,{isP2P:o,contentHint:r,degradationPreference:a,onAddedTransceiver:c,sendEncodings:s}));startPresentation=async({mediaStream:n,isP2P:o,contentHint:r,degradationPreference:a,sendEncodings:s,callLimit:c,onAddedTransceiver:l})=>(t.logger("startPresentation"),this.sipConnector.startPresentation(n,{isP2P:o,contentHint:r,callLimit:c,degradationPreference:a,onAddedTransceiver:l,sendEncodings:s}));stopShareSipConnector=async({isP2P:n=!1}={})=>(t.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:n}).catch(o=>{t.logger(o)}));sendRefusalToTurnOnMic=async()=>{t.logger("sendRefusalToTurnOnMic"),await this.sipConnector.sendRefusalToTurnOnMic().catch(n=>{t.logger("sendRefusalToTurnOnMic: error",n)})};sendRefusalToTurnOnCam=async()=>{t.logger("sendRefusalToTurnOnCam"),await this.sipConnector.sendRefusalToTurnOnCam().catch(n=>{t.logger("sendRefusalToTurnOnCam: error",n)})};sendMediaState=async({isEnabledCam:n,isEnabledMic:o})=>{t.logger("sendMediaState"),await this.sipConnector.sendMediaState({cam:n,mic:o})};replaceMediaStream=async(n,{deleteExisting:o,addMissing:r,forceRenegotiation:a,contentHint:s,degradationPreference:c,sendEncodings:l,onAddedTransceiver:g})=>(t.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(n,{deleteExisting:o,addMissing:r,forceRenegotiation:a,contentHint:s,degradationPreference:c,onAddedTransceiver:g,sendEncodings:l}));askPermissionToEnableCam=async()=>{t.logger("askPermissionToEnableCam"),await this.sipConnector.askPermissionToEnableCam()};resolveHandleReadyRemoteStreamsDebounced=({onReadyRemoteStreams:n})=>W.debounce(()=>{const o=this.sipConnector.getRemoteStreams();t.logger("remoteStreams",o),n(o)},200);resolveHandleReadyRemoteStreams=({onReadyRemoteStreams:n})=>({track:o})=>{Te(o)&&n()};getRemoteStreams=()=>(t.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams());onUseLicense=n=>(t.logger("onUseLicense"),this.sipConnector.on("api:useLicense",n));onMustStopPresentation=n=>(t.logger("onMustStopPresentation"),this.sipConnector.on("api:mustStopPresentation",n));onMoveToSpectators=n=>(t.logger("onMoveToSpectators"),this.sipConnector.on("api:participant:move-request-to-spectators",n));onMoveToParticipants=n=>(t.logger("onMoveToParticipants"),this.sipConnector.on("api:participant:move-request-to-participants",n));onStats=n=>(t.logger("onStats"),this.sipConnector.on("stats:collected",n));offStats=n=>{t.logger("offStats"),this.sipConnector.off("stats:collected",n)}}var B=(e=>(e.VP8="video/VP8",e.VP9="video/VP9",e.H264="video/H264",e.AV1="video/AV1",e.rtx="video/rtx",e.red="video/red",e.flexfec03="video/flexfec-03",e))(B||{});exports.ECallCause=t.ECallCause;exports.ECallStatus=t.EState;exports.EConnectionStatus=t.EState$2;exports.EIncomingStatus=t.EState$1;exports.EPresentationStatus=t.EState$3;exports.EStatsTypes=t.EStatsTypes;exports.EUseLicense=t.EUseLicense;exports.SipConnector=t.SipConnector;exports.StatsPeerConnection=t.StatsPeerConnection;exports.disableDebug=t.disableDebug;exports.enableDebug=t.enableDebug;exports.getCodecFromSender=t.getCodecFromSender;exports.hasCanceledStartPresentationError=t.hasCanceledStartPresentationError;Object.defineProperty(exports,"hasConnectionPromiseIsNotActualError",{enumerable:!0,get:()=>K.isPromiseIsNotActualError});exports.EMimeTypesVideoCodecs=B;exports.SipConnectorFacade=_e;exports.hasAvailableStats=Pe;exports.hasCanceledCallError=Y;exports.sessionSelectors=ee;exports.tools=be;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,3 +14,5 @@ export { EMimeTypesVideoCodecs } from './types';
|
|
|
14
14
|
export type { TJsSIP } from './types';
|
|
15
15
|
export { default as getCodecFromSender } from './utils/getCodecFromSender';
|
|
16
16
|
export { hasConnectionPromiseIsNotActualError } from './ConnectionQueueManager';
|
|
17
|
+
export { sessionSelectors, ECallStatus, EConnectionStatus, EIncomingStatus, EPresentationStatus, } from './session';
|
|
18
|
+
export type { ISession, TSessionSnapshot } from './session';
|