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.
Files changed (64) hide show
  1. package/README.md +117 -2
  2. package/dist/@SipConnector-C-73R76v.cjs +1 -0
  3. package/dist/{@SipConnector-BDiunWqH.js → @SipConnector-D4SHRHKj.js} +2086 -810
  4. package/dist/ApiManager/@ApiManager.d.ts +1 -1
  5. package/dist/ApiManager/{eventNames.d.ts → events.d.ts} +1 -0
  6. package/dist/ApiManager/index.d.ts +2 -1
  7. package/dist/AutoConnectorManager/@AutoConnectorManager.d.ts +1 -1
  8. package/dist/AutoConnectorManager/{eventNames.d.ts → events.d.ts} +1 -0
  9. package/dist/AutoConnectorManager/index.d.ts +1 -0
  10. package/dist/CallManager/CallStateMachine.d.ts +83 -0
  11. package/dist/CallManager/MCUSession.d.ts +2 -1
  12. package/dist/CallManager/RemoteStreamsManager.d.ts +1 -0
  13. package/dist/CallManager/{eventNames.d.ts → events.d.ts} +2 -1
  14. package/dist/CallManager/index.d.ts +2 -3
  15. package/dist/CallManager/types.d.ts +2 -1
  16. package/dist/ConnectionManager/ConnectionFlow.d.ts +1 -1
  17. package/dist/ConnectionManager/ConnectionStateMachine.d.ts +61 -12
  18. package/dist/ConnectionManager/RegistrationManager.d.ts +1 -1
  19. package/dist/ConnectionManager/{eventNames.d.ts → events.d.ts} +2 -1
  20. package/dist/ConnectionManager/index.d.ts +3 -3
  21. package/dist/IncomingCallManager/IncomingCallStateMachine.d.ts +114 -0
  22. package/dist/IncomingCallManager/{eventNames.d.ts → events.d.ts} +2 -1
  23. package/dist/IncomingCallManager/index.d.ts +2 -1
  24. package/dist/MainStreamHealthMonitor/@MainStreamHealthMonitor.d.ts +16 -0
  25. package/dist/MainStreamHealthMonitor/events.d.ts +8 -0
  26. package/dist/MainStreamHealthMonitor/index.d.ts +1 -0
  27. package/dist/MainStreamRecovery/@MainStreamRecovery.d.ts +12 -0
  28. package/dist/MainStreamRecovery/index.d.ts +1 -0
  29. package/dist/PresentationManager/PresentationStateMachine.d.ts +101 -0
  30. package/dist/PresentationManager/{eventNames.d.ts → events.d.ts} +1 -0
  31. package/dist/PresentationManager/index.d.ts +1 -0
  32. package/dist/SipConnector/@SipConnector.d.ts +8 -2
  33. package/dist/SipConnector/events.d.ts +24 -0
  34. package/dist/SipConnector/index.d.ts +1 -1
  35. package/dist/StatsManager/@StatsManager.d.ts +14 -3
  36. package/dist/StatsManager/events.d.ts +2 -0
  37. package/dist/StatsManager/index.d.ts +1 -1
  38. package/dist/StatsPeerConnection/@StatsPeerConnection.d.ts +1 -1
  39. package/dist/StatsPeerConnection/{eventNames.d.ts → events.d.ts} +1 -0
  40. package/dist/StatsPeerConnection/index.d.ts +4 -3
  41. package/dist/StatsPeerConnection/types.d.ts +2 -0
  42. package/dist/VideoSendingBalancerManager/@VideoSendingBalancerManager.d.ts +1 -1
  43. package/dist/VideoSendingBalancerManager/{eventNames.d.ts → events.d.ts} +1 -0
  44. package/dist/VideoSendingBalancerManager/index.d.ts +2 -2
  45. package/dist/__fixtures__/RTCSessionMock.d.ts +1 -0
  46. package/dist/doMock.cjs +1 -1
  47. package/dist/doMock.js +10 -9
  48. package/dist/index.cjs +1 -1
  49. package/dist/index.d.ts +2 -0
  50. package/dist/index.js +206 -188
  51. package/dist/session/createSession.d.ts +26 -0
  52. package/dist/session/index.d.ts +5 -0
  53. package/dist/session/selectors.d.ts +10 -0
  54. package/dist/session/types.d.ts +20 -0
  55. package/dist/tools/BaseStateMachine.d.ts +18 -0
  56. package/dist/tools/index.d.ts +1 -1
  57. package/package.json +12 -9
  58. package/dist/@SipConnector-YhZPG7vq.cjs +0 -1
  59. package/dist/CallManager/@CallManager.d.ts +0 -58
  60. package/dist/ConnectionManager/@ConnectionManager.d.ts +0 -57
  61. package/dist/IncomingCallManager/@IncomingCallManager.d.ts +0 -29
  62. package/dist/PresentationManager/@PresentationManager.d.ts +0 -49
  63. package/dist/SipConnector/eventNames.d.ts +0 -23
  64. package/dist/StatsManager/eventNames.d.ts +0 -2
@@ -1,6 +1,6 @@
1
1
  import { CallManager } from '../CallManager';
2
2
  import { ConnectionManager } from '../ConnectionManager';
3
- import { TEventMap, TEvents } from './eventNames';
3
+ import { TEventMap, TEvents } from './events';
4
4
  import { TChannels, TMediaState, TOptionsInfoMediaState } from './types';
5
5
  declare class ApiManager {
6
6
  readonly events: TEvents;
@@ -91,3 +91,4 @@ export type TEventMap = {
91
91
  };
92
92
  };
93
93
  export type TEvents = TypedEvents<TEventMap>;
94
+ export declare const createEvents: () => TypedEvents<TEventMap, readonly (keyof TEventMap)[]>;
@@ -1,3 +1,4 @@
1
1
  export { default as ApiManager } from './@ApiManager';
2
2
  export { EContentTypeReceived, EContentTypeSent, EEventsMainCAM, EEventsMic, EEventsSyncMediaState, EHeader, EShareState, EUseLicense, } from './constants';
3
- export type { TEvent as TApiEvent } from './eventNames';
3
+ export { createEvents } from './events';
4
+ export type { TEventMap, TEvent as TApiEvent, TEvents as TApiEvents } from './events';
@@ -1,7 +1,7 @@
1
1
  import { CallManager } from '../CallManager';
2
2
  import { ConnectionManager } from '../ConnectionManager';
3
3
  import { ConnectionQueueManager } from '../ConnectionQueueManager';
4
- import { TEventMap, TEvents } from './eventNames';
4
+ import { TEventMap, TEvents } from './events';
5
5
  import { IAutoConnectorOptions, TParametersAutoConnect } from './types';
6
6
  declare class AutoConnectorManager {
7
7
  readonly events: TEvents;
@@ -20,3 +20,4 @@ export type TEventMap = {
20
20
  'limit-reached-attempts': Error;
21
21
  };
22
22
  export type TEvents = TypedEvents<TEventMap>;
23
+ export declare const createEvents: () => TypedEvents<TEventMap, readonly (keyof TEventMap)[]>;
@@ -1,2 +1,3 @@
1
1
  export { default as AutoConnectorManager } from './@AutoConnectorManager';
2
+ export { createEvents } from './events';
2
3
  export type { IAutoConnectorOptions } from './types';
@@ -0,0 +1,83 @@
1
+ import { BaseStateMachine } from '../tools/BaseStateMachine';
2
+ import { ActorRefFrom, SnapshotFrom } from 'xstate';
3
+ import { TEvents } from './events';
4
+ export declare enum EState {
5
+ IDLE = "call:idle",
6
+ CONNECTING = "call:connecting",
7
+ RINGING = "call:ringing",
8
+ ACCEPTED = "call:accepted",
9
+ IN_CALL = "call:inCall",
10
+ ENDED = "call:ended",
11
+ FAILED = "call:failed"
12
+ }
13
+ type TCallEvent = {
14
+ type: 'CALL.CONNECTING';
15
+ } | {
16
+ type: 'CALL.RINGING';
17
+ } | {
18
+ type: 'CALL.ACCEPTED';
19
+ } | {
20
+ type: 'CALL.CONFIRMED';
21
+ } | {
22
+ type: 'CALL.ENDED';
23
+ } | {
24
+ type: 'CALL.FAILED';
25
+ error?: unknown;
26
+ } | {
27
+ type: 'CALL.RESET';
28
+ };
29
+ interface ICallContext {
30
+ lastError?: Error;
31
+ }
32
+ declare const callMachine: import('xstate').StateMachine<ICallContext, {
33
+ type: "CALL.CONNECTING";
34
+ } | {
35
+ type: "CALL.RINGING";
36
+ } | {
37
+ type: "CALL.ACCEPTED";
38
+ } | {
39
+ type: "CALL.CONFIRMED";
40
+ } | {
41
+ type: "CALL.ENDED";
42
+ } | {
43
+ type: "CALL.FAILED";
44
+ error?: unknown;
45
+ } | {
46
+ type: "CALL.RESET";
47
+ }, {}, never, {
48
+ type: "rememberError";
49
+ params: import('xstate').NonReducibleUnknown;
50
+ } | {
51
+ type: "resetError";
52
+ params: import('xstate').NonReducibleUnknown;
53
+ }, never, never, EState, string, import('xstate').NonReducibleUnknown, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
54
+ id: "call";
55
+ states: {
56
+ readonly "call:idle": {};
57
+ readonly "call:connecting": {};
58
+ readonly "call:ringing": {};
59
+ readonly "call:accepted": {};
60
+ readonly "call:inCall": {};
61
+ readonly "call:ended": {};
62
+ readonly "call:failed": {};
63
+ };
64
+ }>;
65
+ export type TCallSnapshot = SnapshotFrom<typeof callMachine>;
66
+ export type TCallActor = ActorRefFrom<typeof callMachine>;
67
+ export declare class CallStateMachine extends BaseStateMachine<typeof callMachine, EState> {
68
+ constructor(events: TEvents);
69
+ get isIdle(): boolean;
70
+ get isConnecting(): boolean;
71
+ get isRinging(): boolean;
72
+ get isAccepted(): boolean;
73
+ get isInCall(): boolean;
74
+ get isEnded(): boolean;
75
+ get isFailed(): boolean;
76
+ get isActive(): boolean;
77
+ get isPending(): boolean;
78
+ get lastError(): Error | undefined;
79
+ reset(): void;
80
+ send(event: TCallEvent): void;
81
+ private subscribeToEvents;
82
+ }
83
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { RTCSession } from '@krivega/jssip';
2
- import { TEvents } from './eventNames';
2
+ import { TEvents } from './events';
3
3
  import { IMCUSession } from './types';
4
4
  export declare class MCUSession implements IMCUSession {
5
5
  protected readonly events: TEvents;
@@ -12,6 +12,7 @@ export declare class MCUSession implements IMCUSession {
12
12
  get connection(): RTCPeerConnection | undefined;
13
13
  get isCallActive(): boolean;
14
14
  getEstablishedRTCSession: () => RTCSession | undefined;
15
+ renegotiate(): Promise<boolean>;
15
16
  startCall: IMCUSession['startCall'];
16
17
  endCall(): Promise<void>;
17
18
  answerToIncomingCall: IMCUSession['answerToIncomingCall'];
@@ -2,6 +2,7 @@ export declare class RemoteStreamsManager {
2
2
  private readonly participantGroups;
3
3
  private readonly trackToGroup;
4
4
  private readonly trackDisposers;
5
+ get mainStream(): MediaStream | undefined;
5
6
  reset(): void;
6
7
  addTrack(track: MediaStreamTrack, { onRemoved, streamHint, }?: {
7
8
  streamHint?: string;
@@ -1,5 +1,5 @@
1
- import { IncomingInfoEvent, OutgoingInfoEvent, EndEvent } from '@krivega/jssip';
2
1
  import { TypedEvents } from 'events-constructor';
2
+ import { IncomingInfoEvent, OutgoingInfoEvent, EndEvent } from '@krivega/jssip';
3
3
  export declare enum EEvent {
4
4
  PEER_CONNECTION = "peerconnection",
5
5
  CONNECTING = "connecting",
@@ -94,3 +94,4 @@ export type TEventMap = {
94
94
  };
95
95
  };
96
96
  export type TEvents = TypedEvents<TEventMap>;
97
+ export declare const createEvents: () => TypedEvents<TEventMap, readonly (keyof TEventMap)[]>;
@@ -1,7 +1,6 @@
1
1
  export { default as CallManager } from './@CallManager';
2
2
  export { ECallCause } from './causes';
3
- export type { TEventMap } from './eventNames';
4
- export { EEvent as ECallEvent } from './eventNames';
5
- export type { TEvent as TCallEvent, TEvents as TCallEvents } from './eventNames';
3
+ export { EEvent as ECallEvent, createEvents } from './events';
6
4
  export { default as hasCanceledCallError } from './hasCanceledCallError';
7
5
  export type { TCustomError, TGetUri } from './types';
6
+ export type { TEventMap, TEvent as TCallEvent, TEvents as TCallEvents } from './events';
@@ -1,6 +1,6 @@
1
1
  import { RTCSession, UA } from '@krivega/jssip';
2
2
  import { TContentHint } from '../PresentationManager';
3
- import { Originator } from './eventNames';
3
+ import { Originator } from './events';
4
4
  import { TTools } from './RecvSession';
5
5
  export type TOnAddedTransceiver = (transceiver: RTCRtpTransceiver, track: MediaStreamTrack, streams: MediaStream[]) => Promise<void>;
6
6
  export type TGetUri = (id: string) => string;
@@ -67,6 +67,7 @@ export interface IMCUSession {
67
67
  getEstablishedRTCSession: () => RTCSession | undefined;
68
68
  startCall: TStartCall;
69
69
  endCall: () => Promise<void>;
70
+ renegotiate: () => Promise<boolean>;
70
71
  answerToIncomingCall: (incomingRTCSession: RTCSession, params: TParamsAnswerToIncomingCall) => Promise<RTCPeerConnection>;
71
72
  replaceMediaStream: TReplaceMediaStream;
72
73
  restartIce: (options?: {
@@ -2,7 +2,7 @@ import { UA, WebSocketInterface } from '@krivega/jssip';
2
2
  import { TGetUri } from '../CallManager';
3
3
  import { TJsSIP } from '../types';
4
4
  import { default as ConnectionStateMachine } from './ConnectionStateMachine';
5
- import { TEvents } from './eventNames';
5
+ import { TEvents } from './events';
6
6
  import { default as RegistrationManager } from './RegistrationManager';
7
7
  import { default as UAFactory } from './UAFactory';
8
8
  export type TOptionsExtraHeaders = {
@@ -1,4 +1,6 @@
1
- import { TEvents } from './eventNames';
1
+ import { BaseStateMachine } from '../tools/BaseStateMachine';
2
+ import { ActorRefFrom, SnapshotFrom } from 'xstate';
3
+ import { TEvents } from './events';
2
4
  export declare enum EEvents {
3
5
  START_CONNECT = "START_CONNECT",
4
6
  START_INIT_UA = "START_INIT_UA",
@@ -10,23 +12,67 @@ export declare enum EEvents {
10
12
  RESET = "RESET"
11
13
  }
12
14
  type TConnectionMachineEvent = `${EEvents}`;
15
+ type TConnectionFailedEvent = {
16
+ type: typeof EEvents.CONNECTION_FAILED;
17
+ error?: Error;
18
+ };
19
+ interface IConnectionMachineContext {
20
+ error?: Error;
21
+ }
13
22
  export declare enum EState {
14
- IDLE = "idle",
15
- CONNECTING = "connecting",
16
- INITIALIZING = "initializing",
17
- CONNECTED = "connected",
18
- REGISTERED = "registered",
19
- DISCONNECTED = "disconnected",
20
- FAILED = "failed"
23
+ IDLE = "connection:idle",
24
+ CONNECTING = "connection:connecting",
25
+ INITIALIZING = "connection:initializing",
26
+ CONNECTED = "connection:connected",
27
+ REGISTERED = "connection:registered",
28
+ DISCONNECTED = "connection:disconnected",
29
+ FAILED = "connection:failed"
30
+ }
31
+ declare enum EAction {
32
+ LOG_TRANSITION = "logTransition",
33
+ LOG_STATE_CHANGE = "logStateChange",
34
+ SET_ERROR = "setError",
35
+ CLEAR_ERROR = "clearError"
21
36
  }
22
- export default class ConnectionStateMachine {
23
- private readonly actor;
37
+ declare const connectionMachine: import('xstate').StateMachine<IConnectionMachineContext, TConnectionFailedEvent | {
38
+ type: TConnectionMachineEvent;
39
+ }, {}, never, {
40
+ type: EAction.LOG_TRANSITION;
41
+ params: {
42
+ from: string;
43
+ to: string;
44
+ event: string;
45
+ };
46
+ } | {
47
+ type: EAction.LOG_STATE_CHANGE;
48
+ params: {
49
+ state: string;
50
+ };
51
+ } | {
52
+ type: EAction.SET_ERROR;
53
+ params: import('xstate').NonReducibleUnknown;
54
+ } | {
55
+ type: EAction.CLEAR_ERROR;
56
+ params: import('xstate').NonReducibleUnknown;
57
+ }, never, never, EState, string, import('xstate').NonReducibleUnknown, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
58
+ id: "connection";
59
+ states: {
60
+ readonly "connection:idle": {};
61
+ readonly "connection:connecting": {};
62
+ readonly "connection:initializing": {};
63
+ readonly "connection:connected": {};
64
+ readonly "connection:registered": {};
65
+ readonly "connection:disconnected": {};
66
+ readonly "connection:failed": {};
67
+ };
68
+ }>;
69
+ export type TConnectionSnapshot = SnapshotFrom<typeof connectionMachine>;
70
+ export type TConnectionActor = ActorRefFrom<typeof connectionMachine>;
71
+ export default class ConnectionStateMachine extends BaseStateMachine<typeof connectionMachine, EState> {
24
72
  private readonly stateChangeListeners;
25
73
  private readonly events;
26
74
  private unsubscribeFromEvents?;
27
- private readonly actorSubscription?;
28
75
  constructor(events: TEvents);
29
- get state(): EState;
30
76
  get isIdle(): boolean;
31
77
  get isConnecting(): boolean;
32
78
  get isInitializing(): boolean;
@@ -34,6 +80,7 @@ export default class ConnectionStateMachine {
34
80
  get isRegistered(): boolean;
35
81
  get isDisconnected(): boolean;
36
82
  get isFailed(): boolean;
83
+ get error(): Error | undefined;
37
84
  get isPending(): boolean;
38
85
  get isPendingConnect(): boolean;
39
86
  get isPendingInitUa(): boolean;
@@ -56,5 +103,7 @@ export default class ConnectionStateMachine {
56
103
  private readonly toFailed;
57
104
  private readonly toIdle;
58
105
  private subscribeToEvents;
106
+ private readonly handleRegistrationFailed;
107
+ private readonly handleConnectFailed;
59
108
  }
60
109
  export {};
@@ -1,5 +1,5 @@
1
1
  import { RegisteredEvent, UA, UnRegisteredEvent, DisconnectEvent } from '@krivega/jssip';
2
- import { TEvents } from './eventNames';
2
+ import { TEvents } from './events';
3
3
  interface IDependencies {
4
4
  events: TEvents;
5
5
  getUaProtected: () => UA;
@@ -1,5 +1,5 @@
1
- import { ConnectedEvent, ConnectingEventUA, DisconnectEvent, IncomingMessageEvent, IncomingRequest, OutgoingMessageEvent, RegisteredEvent, RTCSessionEvent, UnRegisteredEvent } from '@krivega/jssip';
2
1
  import { TypedEvents } from 'events-constructor';
2
+ import { ConnectedEvent, ConnectingEventUA, DisconnectEvent, IncomingMessageEvent, IncomingRequest, OutgoingMessageEvent, RegisteredEvent, RTCSessionEvent, UnRegisteredEvent } from '@krivega/jssip';
3
3
  import { TConnectionConfigurationWithUa, TParametersConnection } from './ConnectionFlow';
4
4
  export declare enum EEvent {
5
5
  CONNECTING = "connecting",
@@ -44,3 +44,4 @@ export type TEventMap = {
44
44
  'connect-parameters-resolve-failed': unknown;
45
45
  };
46
46
  export type TEvents = TypedEvents<TEventMap>;
47
+ export declare const createEvents: () => TypedEvents<TEventMap, readonly (keyof TEventMap)[]>;
@@ -1,5 +1,5 @@
1
1
  export { default as ConnectionManager } from './@ConnectionManager';
2
- export type { TParametersConnection, TConnectionConfigurationWithUa } from './ConnectionFlow';
3
- export { EVENT_NAMES as CONNECTION_MANAGER_EVENT_NAMES, EEvent as EConnectionManagerEvent, } from './eventNames';
4
- export type { TEvent as TConnectionManagerEvent, TEvents as TConnectionManagerEvents, } from './eventNames';
5
2
  export { hasNotReadyForConnectionError, createNotReadyForConnectionError } from './utils';
3
+ export { EVENT_NAMES as CONNECTION_MANAGER_EVENT_NAMES, EEvent as EConnectionManagerEvent, createEvents, } from './events';
4
+ export type { TParametersConnection, TConnectionConfigurationWithUa } from './ConnectionFlow';
5
+ export type { TEvent as TConnectionManagerEvent, TEvents as TConnectionManagerEvents, } from './events';
@@ -0,0 +1,114 @@
1
+ import { BaseStateMachine } from '../tools/BaseStateMachine';
2
+ import { ActorRefFrom, SnapshotFrom } from 'xstate';
3
+ import { TEvents as TConnectionEvents } from '../ConnectionManager/events';
4
+ import { TEvents as TIncomingEvents, TRemoteCallerData } from './events';
5
+ export declare enum EState {
6
+ IDLE = "incoming:idle",
7
+ RINGING = "incoming:ringing",
8
+ CONSUMED = "incoming:consumed",
9
+ DECLINED = "incoming:declined",
10
+ TERMINATED = "incoming:terminated",
11
+ FAILED = "incoming:failed"
12
+ }
13
+ declare enum EAction {
14
+ LOG_TRANSITION = "logTransition",
15
+ LOG_STATE_CHANGE = "logStateChange",
16
+ REMEMBER_INCOMING = "rememberIncoming",
17
+ REMEMBER_REASON = "rememberReason",
18
+ CLEAR_INCOMING = "clearIncoming"
19
+ }
20
+ type TIncomingEvent = {
21
+ type: 'INCOMING.RINGING';
22
+ data: TRemoteCallerData;
23
+ } | {
24
+ type: 'INCOMING.CONSUMED';
25
+ } | {
26
+ type: 'INCOMING.DECLINED';
27
+ data: TRemoteCallerData;
28
+ } | {
29
+ type: 'INCOMING.TERMINATED';
30
+ data: TRemoteCallerData;
31
+ } | {
32
+ type: 'INCOMING.FAILED';
33
+ data: TRemoteCallerData;
34
+ } | {
35
+ type: 'INCOMING.CLEAR';
36
+ };
37
+ interface IIncomingContext {
38
+ remoteCallerData?: TRemoteCallerData;
39
+ lastReason?: EState.CONSUMED | EState.DECLINED | EState.TERMINATED | EState.FAILED;
40
+ }
41
+ declare const incomingMachine: import('xstate').StateMachine<IIncomingContext, {
42
+ type: "INCOMING.RINGING";
43
+ data: TRemoteCallerData;
44
+ } | {
45
+ type: "INCOMING.CONSUMED";
46
+ } | {
47
+ type: "INCOMING.DECLINED";
48
+ data: TRemoteCallerData;
49
+ } | {
50
+ type: "INCOMING.TERMINATED";
51
+ data: TRemoteCallerData;
52
+ } | {
53
+ type: "INCOMING.FAILED";
54
+ data: TRemoteCallerData;
55
+ } | {
56
+ type: "INCOMING.CLEAR";
57
+ }, {}, never, {
58
+ type: EAction.LOG_TRANSITION;
59
+ params: {
60
+ from: string;
61
+ to: string;
62
+ event: string;
63
+ };
64
+ } | {
65
+ type: EAction.LOG_STATE_CHANGE;
66
+ params: {
67
+ state: string;
68
+ };
69
+ } | {
70
+ type: EAction.REMEMBER_INCOMING;
71
+ params: import('xstate').NonReducibleUnknown;
72
+ } | {
73
+ type: EAction.REMEMBER_REASON;
74
+ params: import('xstate').NonReducibleUnknown;
75
+ } | {
76
+ type: EAction.CLEAR_INCOMING;
77
+ params: import('xstate').NonReducibleUnknown;
78
+ }, never, never, EState, string, import('xstate').NonReducibleUnknown, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
79
+ id: "incoming";
80
+ states: {
81
+ readonly "incoming:idle": {};
82
+ readonly "incoming:ringing": {};
83
+ readonly "incoming:consumed": {};
84
+ readonly "incoming:declined": {};
85
+ readonly "incoming:terminated": {};
86
+ readonly "incoming:failed": {};
87
+ };
88
+ }>;
89
+ export type TIncomingSnapshot = SnapshotFrom<typeof incomingMachine>;
90
+ export type TIncomingActor = ActorRefFrom<typeof incomingMachine>;
91
+ type TDeps = {
92
+ incomingEvents: TIncomingEvents;
93
+ connectionEvents: TConnectionEvents;
94
+ };
95
+ export declare class IncomingCallStateMachine extends BaseStateMachine<typeof incomingMachine, EState> {
96
+ constructor({ incomingEvents, connectionEvents }: TDeps);
97
+ get isIdle(): boolean;
98
+ get isRinging(): boolean;
99
+ get isConsumed(): boolean;
100
+ get isDeclined(): boolean;
101
+ get isTerminated(): boolean;
102
+ get isFailed(): boolean;
103
+ get isActive(): boolean;
104
+ get isFinished(): boolean;
105
+ get remoteCallerData(): TRemoteCallerData | undefined;
106
+ get lastReason(): EState.CONSUMED | EState.DECLINED | EState.TERMINATED | EState.FAILED | undefined;
107
+ reset(): void;
108
+ send(event: TIncomingEvent): void;
109
+ toConsumed(): void;
110
+ private subscribeIncomingEvents;
111
+ private subscribeConnectionEvents;
112
+ private toClearIncoming;
113
+ }
114
+ export {};
@@ -1,5 +1,5 @@
1
- import { RTCSession } from '@krivega/jssip';
2
1
  import { TypedEvents } from 'events-constructor';
2
+ import { RTCSession } from '@krivega/jssip';
3
3
  export declare enum EEvent {
4
4
  INCOMING_CALL = "incomingCall",
5
5
  DECLINED_INCOMING_CALL = "declinedIncomingCall",
@@ -26,3 +26,4 @@ export type TEventMap = {
26
26
  failedIncomingCall: TRemoteCallerData;
27
27
  };
28
28
  export type TEvents = TypedEvents<TEventMap>;
29
+ export declare const createEvents: () => TypedEvents<TEventMap, readonly (keyof TEventMap)[]>;
@@ -1,2 +1,3 @@
1
1
  export { default as IncomingCallManager } from './@IncomingCallManager';
2
- export type { TEvent as TIncomingCallEvent } from './eventNames';
2
+ export { createEvents } from './events';
3
+ export type { TEvent as TIncomingCallEvent, TRemoteCallerData } from './events';
@@ -0,0 +1,16 @@
1
+ import { CallManager } from '../CallManager';
2
+ import { StatsManager } from '../StatsManager';
3
+ import { TEventMap, TEvents } from './events';
4
+ declare class MainStreamHealthMonitor {
5
+ readonly events: TEvents;
6
+ private readonly statsManager;
7
+ private readonly callManager;
8
+ constructor(statsManager: StatsManager, callManager: CallManager);
9
+ private get mainVideoTrack();
10
+ private get isMutedMainVideoTrack();
11
+ on<T extends keyof TEventMap>(eventName: T, handler: (data: TEventMap[T]) => void): () => void;
12
+ private readonly handleStatsCollected;
13
+ private readonly hasNoIncomingFrames;
14
+ private subscribe;
15
+ }
16
+ export default MainStreamHealthMonitor;
@@ -0,0 +1,8 @@
1
+ import { TypedEvents } from 'events-constructor';
2
+ export declare const NO_INBOUND_FRAMES_EVENT_NAME: "no-inbound-frames";
3
+ export declare const EVENT_NAMES: readonly ["no-inbound-frames"];
4
+ export type TEventMap = {
5
+ [NO_INBOUND_FRAMES_EVENT_NAME]: Record<string, never>;
6
+ };
7
+ export type TEvents = TypedEvents<TEventMap>;
8
+ export declare const createEvents: () => TypedEvents<TEventMap, readonly "no-inbound-frames"[]>;
@@ -0,0 +1 @@
1
+ export { default as MainStreamHealthMonitor } from './@MainStreamHealthMonitor';
@@ -0,0 +1,12 @@
1
+ import { CallManager } from '../CallManager';
2
+ declare class MainStreamRecovery {
3
+ private readonly renegotiateRequester;
4
+ private readonly renegotiateThrottled;
5
+ private readonly callManager;
6
+ constructor(callManager: CallManager, throttleRecoveryTimeout?: number);
7
+ recover(): void;
8
+ private readonly requestRenegotiate;
9
+ private subscribe;
10
+ private cancel;
11
+ }
12
+ export default MainStreamRecovery;
@@ -0,0 +1 @@
1
+ export { default as MainStreamRecovery } from './@MainStreamRecovery';
@@ -0,0 +1,101 @@
1
+ import { BaseStateMachine } from '../tools/BaseStateMachine';
2
+ import { ActorRefFrom, SnapshotFrom } from 'xstate';
3
+ import { TCallEvents } from '../CallManager';
4
+ export declare enum EState {
5
+ IDLE = "presentation:idle",
6
+ STARTING = "presentation:starting",
7
+ ACTIVE = "presentation:active",
8
+ STOPPING = "presentation:stopping",
9
+ FAILED = "presentation:failed"
10
+ }
11
+ declare enum EAction {
12
+ LOG_TRANSITION = "logTransition",
13
+ LOG_STATE_CHANGE = "logStateChange",
14
+ SET_ERROR = "setError",
15
+ CLEAR_ERROR = "clearError"
16
+ }
17
+ type TPresentationEvent = {
18
+ type: 'SCREEN.STARTING';
19
+ } | {
20
+ type: 'SCREEN.STARTED';
21
+ } | {
22
+ type: 'SCREEN.ENDING';
23
+ } | {
24
+ type: 'SCREEN.ENDED';
25
+ } | {
26
+ type: 'SCREEN.FAILED';
27
+ error?: unknown;
28
+ } | {
29
+ type: 'CALL.ENDED';
30
+ } | {
31
+ type: 'CALL.FAILED';
32
+ error?: unknown;
33
+ } | {
34
+ type: 'PRESENTATION.RESET';
35
+ };
36
+ interface IPresentationContext {
37
+ lastError?: Error;
38
+ }
39
+ declare const presentationMachine: import('xstate').StateMachine<IPresentationContext, {
40
+ type: "SCREEN.STARTING";
41
+ } | {
42
+ type: "SCREEN.STARTED";
43
+ } | {
44
+ type: "SCREEN.ENDING";
45
+ } | {
46
+ type: "SCREEN.ENDED";
47
+ } | {
48
+ type: "SCREEN.FAILED";
49
+ error?: unknown;
50
+ } | {
51
+ type: "CALL.ENDED";
52
+ } | {
53
+ type: "CALL.FAILED";
54
+ error?: unknown;
55
+ } | {
56
+ type: "PRESENTATION.RESET";
57
+ }, {}, never, {
58
+ type: EAction.LOG_TRANSITION;
59
+ params: {
60
+ from: string;
61
+ to: string;
62
+ event: string;
63
+ };
64
+ } | {
65
+ type: EAction.LOG_STATE_CHANGE;
66
+ params: {
67
+ state: string;
68
+ };
69
+ } | {
70
+ type: EAction.SET_ERROR;
71
+ params: import('xstate').NonReducibleUnknown;
72
+ } | {
73
+ type: EAction.CLEAR_ERROR;
74
+ params: import('xstate').NonReducibleUnknown;
75
+ }, never, never, EState, string, import('xstate').NonReducibleUnknown, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
76
+ id: "presentation";
77
+ states: {
78
+ readonly "presentation:idle": {};
79
+ readonly "presentation:starting": {};
80
+ readonly "presentation:active": {};
81
+ readonly "presentation:stopping": {};
82
+ readonly "presentation:failed": {};
83
+ };
84
+ }>;
85
+ export type TPresentationSnapshot = SnapshotFrom<typeof presentationMachine>;
86
+ export type TPresentationActor = ActorRefFrom<typeof presentationMachine>;
87
+ export declare class PresentationStateMachine extends BaseStateMachine<typeof presentationMachine, EState> {
88
+ constructor(callEvents: TCallEvents);
89
+ get isIdle(): boolean;
90
+ get isStarting(): boolean;
91
+ get isActive(): boolean;
92
+ get isStopping(): boolean;
93
+ get isFailed(): boolean;
94
+ get isPending(): boolean;
95
+ get isActiveOrPending(): boolean;
96
+ get lastError(): Error | undefined;
97
+ reset(): void;
98
+ send(event: TPresentationEvent): void;
99
+ private subscribeCallEvents;
100
+ }
101
+ export {};
@@ -16,3 +16,4 @@ export type TEventMap = {
16
16
  'presentation:failed': Error;
17
17
  };
18
18
  export type TEvents = TypedEvents<TEventMap>;
19
+ export declare const createEvents: () => TypedEvents<TEventMap, readonly (keyof TEventMap)[]>;
@@ -1,2 +1,3 @@
1
1
  export { hasCanceledStartPresentationError, default as PresentationManager, } from './@PresentationManager';
2
+ export { createEvents } from './events';
2
3
  export type { TContentHint, TOnAddedTransceiver } from './types';