@camera.ui/browser 0.0.6 → 0.0.32
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/dist/bundle.js +1 -0
- package/dist/client/node/src/client.d.ts +0 -1
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.browser.d.ts +19 -9
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.node.d.ts +4 -2
- package/dist/client/node/src/proxy/cameraDevice/index.d.ts +0 -4
- package/dist/client/node/src/proxy/deviceManager.d.ts +1 -2
- package/dist/client/node/src/socket.d.ts +5 -1
- package/dist/client/node/src/types.d.ts +5 -3
- package/dist/shared/types/index.d.ts +2 -2
- package/dist/src/api/database/types.d.ts +20 -5
- package/dist/src/api/go2rtc/api/application.d.ts +2 -2
- package/dist/src/api/go2rtc/api/snapshot.d.ts +3 -2
- package/dist/src/api/go2rtc/api/streams.d.ts +6 -5
- package/dist/src/api/go2rtc/types.d.ts +14 -0
- package/dist/src/api/schemas/cameras.schema.d.ts +25 -29
- package/dist/src/api/schemas/config.schema.d.ts +2 -2
- package/dist/src/api/services/cameras.service.d.ts +4 -1
- package/dist/src/api/utils/constants.d.ts +15 -0
- package/dist/src/api.d.ts +4 -4
- package/dist/src/camera/index.d.ts +25 -13
- package/dist/src/camera/streaming/peer-connection.d.ts +6 -5
- package/dist/src/camera/streaming/streaming-session.d.ts +5 -6
- package/dist/src/camera/streaming/webrtc-connection.d.ts +7 -8
- package/dist/src/camera/types.d.ts +28 -8
- package/dist/src/plugins/base.d.ts +1 -1
- package/dist/src/plugins/index.d.ts +7 -2
- package/dist/src/plugins/plugin.d.ts +5 -2
- package/dist/src/plugins/types.d.ts +5 -1
- package/dist/src/plugins/worker.d.ts +1 -0
- package/dist/src/proxy/client/cameraDevice.d.ts +9 -14
- package/dist/src/proxy/client/deviceManager.d.ts +4 -12
- package/dist/src/proxy/client/pluginsManager.d.ts +3 -11
- package/dist/src/proxy/client/queue.d.ts +11 -0
- package/dist/src/proxy/client/systemManager.d.ts +3 -11
- package/dist/src/proxy/constants.d.ts +7 -0
- package/dist/src/proxy/index.d.ts +12 -6
- package/dist/src/proxy/proxies/camera.d.ts +40 -9
- package/dist/src/proxy/proxies/plugin.d.ts +3 -23
- package/dist/src/proxy/proxies/server.d.ts +6 -6
- package/dist/src/proxy/queue.d.ts +15 -0
- package/dist/src/proxy/types.d.ts +67 -6
- package/dist/src/proxy/ws/index.d.ts +0 -9
- package/dist/src/services/config/constants.d.ts +6 -0
- package/dist/src/services/config/index.d.ts +1 -1
- package/dist/src/services/logger/index.d.ts +2 -0
- package/package.json +8 -7
- package/webpack.config.ts +43 -0
- package/dist/bundle.browser.js +0 -1
- package/dist/src/api/utils/cert.d.ts +0 -17
- /package/dist/src/plugins/{storage.d.ts → storageController.d.ts} +0 -0
|
@@ -2,7 +2,7 @@ import { RtpPacket } from 'werift';
|
|
|
2
2
|
import { ReplaySubject, Subject } from 'rxjs';
|
|
3
3
|
import { Subscribed } from '../subscribed';
|
|
4
4
|
import type { WebrtcConnection } from './webrtc-connection';
|
|
5
|
-
import type { FfmpegOptions, SpawnInput,
|
|
5
|
+
import type { FfmpegOptions, SpawnInput, CameraDevice } from '../types';
|
|
6
6
|
export declare class StreamingSession extends Subscribed {
|
|
7
7
|
readonly onCallEnded: ReplaySubject<void>;
|
|
8
8
|
readonly onVideoRtp: Subject<RtpPacket>;
|
|
@@ -12,20 +12,19 @@ export declare class StreamingSession extends Subscribed {
|
|
|
12
12
|
private readonly returnAudioSplitter;
|
|
13
13
|
private readonly onUsingOpus;
|
|
14
14
|
private hasEnded;
|
|
15
|
-
private
|
|
16
|
-
private ffmpegPath;
|
|
15
|
+
private cameraDevice;
|
|
17
16
|
private connection;
|
|
18
17
|
private logger;
|
|
19
18
|
get isUsingOpus(): Promise<boolean>;
|
|
20
|
-
constructor(
|
|
21
|
-
private bindToConnection;
|
|
19
|
+
constructor(cameraDevice: CameraDevice, connection: WebrtcConnection);
|
|
22
20
|
reservePort(bufferPorts?: number): Promise<number>;
|
|
23
21
|
startTranscoding(ffmpegOptions: FfmpegOptions): Promise<void>;
|
|
24
22
|
transcodeReturnAudio(ffmpegOptions: {
|
|
25
23
|
input: SpawnInput[];
|
|
26
24
|
}): Promise<void>;
|
|
27
|
-
private callEnded;
|
|
28
25
|
stop(): void;
|
|
29
26
|
sendAudioPacket(rtp: RtpPacket): void;
|
|
30
27
|
requestKeyFrame(): void;
|
|
28
|
+
private bindToConnection;
|
|
29
|
+
private callEnded;
|
|
31
30
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReplaySubject, Subject, type Observable } from 'rxjs';
|
|
2
2
|
import { Subscribed } from '../subscribed';
|
|
3
3
|
import type { RtpPacket } from 'werift';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
4
|
+
import type { StreamingConnectionOptions, CameraDevice } from '../types';
|
|
5
|
+
import type { IceServer } from '../../services/config/types';
|
|
6
6
|
export declare class WebrtcConnection extends Subscribed {
|
|
7
7
|
readonly onCameraConnected: ReplaySubject<void>;
|
|
8
8
|
readonly onCallAnswered: ReplaySubject<string>;
|
|
@@ -19,14 +19,13 @@ export declare class WebrtcConnection extends Subscribed {
|
|
|
19
19
|
private readonly onOfferSent;
|
|
20
20
|
private hasEnded;
|
|
21
21
|
private logger;
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
private cameraDevice;
|
|
23
|
+
constructor(cameraDevice: CameraDevice, sourceName: string, iceServers: IceServer[], options: StreamingConnectionOptions);
|
|
24
|
+
sendAudioPacket(rtp: RtpPacket): void;
|
|
25
|
+
stop(): void;
|
|
26
|
+
requestKeyFrame(): void;
|
|
25
27
|
private initiateCall;
|
|
26
28
|
private handleMessage;
|
|
27
29
|
private sendMessage;
|
|
28
|
-
sendAudioPacket(rtp: RtpPacket): void;
|
|
29
30
|
private callEnded;
|
|
30
|
-
stop(): void;
|
|
31
|
-
requestKeyFrame(): void;
|
|
32
31
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Observable, Subject } from 'rxjs';
|
|
2
2
|
import type { ConnectionState, RTCIceCandidate } from 'werift';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CameraInput, Camera, CameraPublicProperties, CameraInputSettings } from '../api/database/types';
|
|
4
4
|
import type { StreamingSession } from './streaming/streaming-session';
|
|
5
5
|
export type SpawnInput = string | number;
|
|
6
|
+
export type PrebufferType = 'recording' | 'stream';
|
|
6
7
|
export interface BaseLogger {
|
|
7
8
|
log: (...args: any[]) => void;
|
|
8
9
|
error: (...args: any[]) => void;
|
|
@@ -34,28 +35,40 @@ export interface BasicPeerConnection {
|
|
|
34
35
|
}
|
|
35
36
|
export interface CameraDevice {
|
|
36
37
|
id: string;
|
|
38
|
+
disabled: boolean;
|
|
37
39
|
name: string;
|
|
38
|
-
pluginId: string;
|
|
39
40
|
nativeId?: string;
|
|
41
|
+
isCloud: boolean;
|
|
42
|
+
hasLight: boolean;
|
|
43
|
+
hasSiren: boolean;
|
|
44
|
+
hasMotionDetector: boolean;
|
|
45
|
+
hasAudioDetector: boolean;
|
|
46
|
+
hasObjectDetector: boolean;
|
|
47
|
+
hasPtz: boolean;
|
|
40
48
|
type: string;
|
|
41
49
|
model: string;
|
|
42
|
-
sources:
|
|
50
|
+
sources: Input[];
|
|
51
|
+
logger: BaseLogger;
|
|
43
52
|
onLightDetected: Observable<LightState>;
|
|
44
53
|
onMotionDetected: Observable<MotionState>;
|
|
45
54
|
onAudioDetected: Observable<AudioState>;
|
|
46
55
|
onObjectDetected: Observable<ObjectState>;
|
|
47
56
|
onDoorbellPressed: Observable<DoorbellState>;
|
|
48
57
|
onSirenDetected: Observable<SirenState>;
|
|
58
|
+
snapshot(sourceName?: string): Promise<ArrayBuffer>;
|
|
59
|
+
setPrebufferSource(sourceName: string, address: string | null, type: 'recording' | 'stream'): Promise<void>;
|
|
60
|
+
getFfmpegPath(): Promise<string>;
|
|
61
|
+
getIceServers(): Promise<RTCIceServer[]>;
|
|
49
62
|
getValue<T extends keyof StateValues>(stateName: T): StateValue<T>;
|
|
50
|
-
createSession(
|
|
51
|
-
streamVideo(
|
|
52
|
-
recordToFile(
|
|
53
|
-
updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): void
|
|
63
|
+
createSession(sourceName: string, options?: StreamingConnectionOptions): Promise<StreamingSession>;
|
|
64
|
+
streamVideo(sourceName: string, options: FfmpegOptions): Promise<StreamingSession>;
|
|
65
|
+
recordToFile(sourceName: string, outputPath: string, duration?: number): Promise<void>;
|
|
66
|
+
updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): Promise<void>;
|
|
54
67
|
onStateChange<T extends keyof StateValues>(stateName: T): Observable<{
|
|
55
68
|
newState: StateValues[T];
|
|
56
69
|
oldState: StateValues[T];
|
|
57
70
|
}>;
|
|
58
|
-
onPropertyChange<T extends keyof
|
|
71
|
+
onPropertyChange<T extends keyof CameraPublicProperties>(property: T): Observable<{
|
|
59
72
|
oldState: Camera[T];
|
|
60
73
|
newState: Camera[T];
|
|
61
74
|
}>;
|
|
@@ -84,10 +97,17 @@ export type Go2RtcOutgoingMessage = Go2RtcOfferMessage | Go2RtcIceCandidateMessa
|
|
|
84
97
|
export interface CameraConfig {
|
|
85
98
|
name: string;
|
|
86
99
|
nativeId?: string;
|
|
100
|
+
isCloud?: boolean;
|
|
101
|
+
hasLight?: boolean;
|
|
102
|
+
hasSiren?: boolean;
|
|
87
103
|
disabled?: boolean;
|
|
88
104
|
model?: string;
|
|
89
105
|
sources: CameraInputSettings[];
|
|
90
106
|
}
|
|
107
|
+
export interface Input extends CameraInput {
|
|
108
|
+
readonly isStreamPrebuffering?: boolean;
|
|
109
|
+
readonly isRecordingPrebuffering?: boolean;
|
|
110
|
+
}
|
|
91
111
|
export interface BaseState {
|
|
92
112
|
timestamp: number;
|
|
93
113
|
lastTriggered: number;
|
|
@@ -3,7 +3,7 @@ import type { CameraDevice } from '../camera/types';
|
|
|
3
3
|
import type { PluginLogger } from '../services/logger';
|
|
4
4
|
import type { PluginConfigService } from './config';
|
|
5
5
|
import type { BasePlugin as BasePluginMethods } from './types';
|
|
6
|
-
import type { Storage } from './
|
|
6
|
+
import type { Storage } from './storageController';
|
|
7
7
|
export declare class BasePlugin implements BasePluginMethods {
|
|
8
8
|
id: string;
|
|
9
9
|
api: API;
|
|
@@ -26,11 +26,16 @@ export declare class PluginManager {
|
|
|
26
26
|
initializePlugin(plugin: Plugin, pluginName: string): Promise<void>;
|
|
27
27
|
loadPlugin(absolutePath: string, pluginId?: string, storagePath?: string): Promise<Plugin>;
|
|
28
28
|
removePlugin(plugin: Plugin, removeFromDb?: boolean, removeStorage?: boolean): Promise<void>;
|
|
29
|
-
startPluginChild(pluginName: string): Promise<void>;
|
|
30
29
|
startPluginChilds(): Promise<void>;
|
|
30
|
+
startPluginChild(pluginName: string): Promise<void>;
|
|
31
|
+
stopPluginChild(pluginName: string): Promise<void>;
|
|
31
32
|
private loadInstalledPlugins;
|
|
32
|
-
private loadDefaultPaths;
|
|
33
33
|
private removeOrphanedPlugins;
|
|
34
|
+
private buildDependencyGraph;
|
|
35
|
+
private groupPlugins;
|
|
36
|
+
private topologicalSort;
|
|
34
37
|
private handlePluginRegistration;
|
|
38
|
+
private loadDefaultPaths;
|
|
35
39
|
private addNpmPrefixToSearchPaths;
|
|
40
|
+
private isDependencyForOthers;
|
|
36
41
|
}
|
|
@@ -16,7 +16,7 @@ export interface Context {
|
|
|
16
16
|
* Represents a loaded camera.ui plugin.
|
|
17
17
|
*/
|
|
18
18
|
export declare class Plugin {
|
|
19
|
-
|
|
19
|
+
_disabled: boolean;
|
|
20
20
|
private logger;
|
|
21
21
|
private configService;
|
|
22
22
|
private _info;
|
|
@@ -35,8 +35,11 @@ export declare class Plugin {
|
|
|
35
35
|
private loadContext?;
|
|
36
36
|
private pluginInitializer?;
|
|
37
37
|
private pluginConstructor;
|
|
38
|
-
get info(): CameraUiPlugin;
|
|
39
38
|
get contract(): PluginContract;
|
|
39
|
+
get info(): CameraUiPlugin;
|
|
40
|
+
set info(value: CameraUiPlugin);
|
|
41
|
+
get disabled(): boolean;
|
|
42
|
+
set disabled(value: boolean);
|
|
40
43
|
constructor(pluginName: string, installPath: string, packageJSON: IPackageJson, pluginId: string, scope?: string, storagePath?: string);
|
|
41
44
|
getPluginConstructor(pluginName: string): PluginConstructor;
|
|
42
45
|
initialize(api: CameraUiAPI): void | Promise<void>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Camera } from '../api/database/types';
|
|
2
2
|
import type { CameraDevice } from '../camera/types';
|
|
3
|
+
export type PluginGraph = Map<string, string[]>;
|
|
4
|
+
export type PluginCycles = Map<string, string[]>;
|
|
5
|
+
export type PluginGroups = Map<string, string[]>;
|
|
3
6
|
export interface SchemaConfig {
|
|
4
7
|
rootSchema: PluginRootSchema;
|
|
5
8
|
config: Record<string, any>;
|
|
@@ -23,12 +26,13 @@ export interface JSONObject {
|
|
|
23
26
|
}
|
|
24
27
|
export type JSONArray = JSONValue[];
|
|
25
28
|
export type PluginConfig = Record<string, any>;
|
|
26
|
-
export type CameraExtension = 'hub' | 'prebuffer' | 'motionDetection' | 'objectDetection' | '
|
|
29
|
+
export type CameraExtension = 'hub' | 'prebuffer' | 'motionDetection' | 'objectDetection' | 'audioDetection' | 'ptz';
|
|
27
30
|
export declare const CAMERA_EXTENSIONS: CameraExtension[];
|
|
28
31
|
export interface PluginContract {
|
|
29
32
|
pluginName: string;
|
|
30
33
|
builtIns?: CameraExtension[];
|
|
31
34
|
extension?: CameraExtension;
|
|
35
|
+
dependencies?: string[];
|
|
32
36
|
}
|
|
33
37
|
export declare const enum PLUGIN_STATUS {
|
|
34
38
|
READY = "ready",
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import { CameraDeviceHub } from '../../camera';
|
|
2
2
|
import type { Camera } from '../../api/database/types';
|
|
3
|
-
import type { StateValues, OnSetEvent } from '../../camera/types';
|
|
4
|
-
import type {
|
|
5
|
-
export declare class
|
|
3
|
+
import type { StateValues, OnSetEvent, BaseLogger, PrebufferType } from '../../camera/types';
|
|
4
|
+
import type { IceServer } from '../../services/config/types';
|
|
5
|
+
export declare class CameraDeviceClientProxy extends CameraDeviceHub {
|
|
6
6
|
private targetId;
|
|
7
7
|
private targetName;
|
|
8
8
|
private clientTargetId;
|
|
9
9
|
private subTargetId;
|
|
10
|
+
private pluginId;
|
|
10
11
|
private api;
|
|
11
|
-
private log;
|
|
12
12
|
private client;
|
|
13
13
|
private subscriber;
|
|
14
|
-
private
|
|
15
|
-
private requestIdCounter;
|
|
16
|
-
private pendingRequests;
|
|
17
|
-
private requestQueue;
|
|
18
|
-
private isProcessing;
|
|
14
|
+
private messageQueue;
|
|
19
15
|
private close?;
|
|
20
|
-
constructor(camera: Camera, logger:
|
|
16
|
+
constructor(camera: Camera, logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string);
|
|
17
|
+
setPrebufferSource(sourceName: string, address: string | null, type: PrebufferType): Promise<void>;
|
|
18
|
+
getFfmpegPath(): Promise<string>;
|
|
19
|
+
getIceServers(): Promise<IceServer[]>;
|
|
21
20
|
updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): Promise<void>;
|
|
22
21
|
refreshStates(): Promise<void>;
|
|
23
22
|
private listenToSubscriberEvents;
|
|
24
23
|
private onRequest;
|
|
25
|
-
private enqueueAndProcessRequest;
|
|
26
|
-
private processNextRequest;
|
|
27
|
-
private onReply;
|
|
28
|
-
private resolveRequest;
|
|
29
24
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { CameraDeviceClientProxy } from '../client/cameraDevice';
|
|
2
|
+
import type { CameraConfig, CameraDevice, BaseLogger } from '../../camera/types';
|
|
1
3
|
import type { DeviceManagerProxyMethods, DeviceManagerProxyEventCallbacks } from '../types';
|
|
2
|
-
import type { Logger, PluginLogger } from '../../services/logger';
|
|
3
|
-
import type { CameraConfig, CameraDevice } from '../../camera/types';
|
|
4
4
|
export declare class DeviceManager implements DeviceManagerProxyMethods {
|
|
5
5
|
private pluginId;
|
|
6
6
|
private pluginName;
|
|
@@ -10,18 +10,14 @@ export declare class DeviceManager implements DeviceManagerProxyMethods {
|
|
|
10
10
|
private logger;
|
|
11
11
|
private client;
|
|
12
12
|
private subscriber;
|
|
13
|
+
private messageQueue;
|
|
13
14
|
private reqServerAddress;
|
|
14
15
|
private pubServerAddress;
|
|
15
16
|
private serverPublicKey;
|
|
16
17
|
private MAX_LISTENERS_PER_EVENT;
|
|
17
|
-
private timeout;
|
|
18
|
-
private requestIdCounter;
|
|
19
|
-
private pendingRequests;
|
|
20
|
-
private requestQueue;
|
|
21
|
-
private isProcessing;
|
|
22
18
|
private devices;
|
|
23
19
|
private eventListeners;
|
|
24
|
-
constructor(logger:
|
|
20
|
+
constructor(logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string, cameraDevices?: CameraDeviceClientProxy[]);
|
|
25
21
|
getCameraById(id: string): Promise<CameraDevice | undefined>;
|
|
26
22
|
getCameraByName(name: string): Promise<CameraDevice | undefined>;
|
|
27
23
|
createCamera(cameraConfig: CameraConfig): Promise<CameraDevice>;
|
|
@@ -32,9 +28,5 @@ export declare class DeviceManager implements DeviceManagerProxyMethods {
|
|
|
32
28
|
removeAllListeners<E extends keyof DeviceManagerProxyEventCallbacks>(eventType?: E): void;
|
|
33
29
|
private listenToSubscriberEvents;
|
|
34
30
|
private onRequest;
|
|
35
|
-
private enqueueAndProcessRequest;
|
|
36
|
-
private processNextRequest;
|
|
37
|
-
private onReply;
|
|
38
|
-
private resolveRequest;
|
|
39
31
|
private addCamera;
|
|
40
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { BaseLogger } from '../../camera/types';
|
|
1
2
|
import type { PluginsManagerProxyMethods, PluginsManagerProxyEventCallbacks } from '../types';
|
|
2
|
-
import type { Logger, PluginLogger } from '../../services/logger';
|
|
3
3
|
export declare class PluginsManager implements PluginsManagerProxyMethods {
|
|
4
4
|
private pluginId;
|
|
5
5
|
private pluginName;
|
|
@@ -12,24 +12,16 @@ export declare class PluginsManager implements PluginsManagerProxyMethods {
|
|
|
12
12
|
private client;
|
|
13
13
|
private subscriber;
|
|
14
14
|
private dealer;
|
|
15
|
+
private messageQueue;
|
|
15
16
|
private MAX_LISTENERS_PER_EVENT;
|
|
16
|
-
private timeout;
|
|
17
|
-
private requestIdCounter;
|
|
18
|
-
private pendingRequests;
|
|
19
|
-
private requestQueue;
|
|
20
|
-
private isProcessing;
|
|
21
17
|
private eventListeners;
|
|
22
|
-
constructor(logger:
|
|
18
|
+
constructor(logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, routerAddress: string, serverPublicKey: string);
|
|
23
19
|
listen<E extends keyof PluginsManagerProxyEventCallbacks>(eventType: E, callback: PluginsManagerProxyEventCallbacks[E]): void;
|
|
24
20
|
removeListener<E extends keyof PluginsManagerProxyEventCallbacks>(eventType: E, callbackToRemove: PluginsManagerProxyEventCallbacks[E]): void;
|
|
25
21
|
removeAllListeners<E extends keyof PluginsManagerProxyEventCallbacks>(eventType?: E): void;
|
|
26
22
|
private listenToSubscriberEvents;
|
|
27
23
|
private listenToRouterRequests;
|
|
28
24
|
private onRequest;
|
|
29
|
-
private enqueueAndProcessRequest;
|
|
30
|
-
private processNextRequest;
|
|
31
|
-
private onReply;
|
|
32
|
-
private resolveRequest;
|
|
33
25
|
private isPluginMessage;
|
|
34
26
|
private isStorageMessage;
|
|
35
27
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Request } from 'zeromq';
|
|
2
|
+
export declare class ClientMessageQueue {
|
|
3
|
+
private requestClient;
|
|
4
|
+
private queue;
|
|
5
|
+
private isProcessing;
|
|
6
|
+
private pendingResponses;
|
|
7
|
+
constructor(requestClient: Request);
|
|
8
|
+
enqueue(message: any, timeout?: number): Promise<any>;
|
|
9
|
+
private processQueue;
|
|
10
|
+
private listenToReplies;
|
|
11
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { BaseLogger } from '../../camera/types';
|
|
1
2
|
import type { SystemManagerProxyMethods, SystemManagerProxyEventCallbacks } from '../types';
|
|
2
|
-
import type { Logger, PluginLogger } from '../../services/logger';
|
|
3
3
|
export declare class SystemManager implements SystemManagerProxyMethods {
|
|
4
4
|
private pluginId;
|
|
5
5
|
private pluginName;
|
|
@@ -9,21 +9,13 @@ export declare class SystemManager implements SystemManagerProxyMethods {
|
|
|
9
9
|
private logger;
|
|
10
10
|
private client;
|
|
11
11
|
private subscriber;
|
|
12
|
+
private messageQueue;
|
|
12
13
|
private MAX_LISTENERS_PER_EVENT;
|
|
13
|
-
private timeout;
|
|
14
|
-
private requestIdCounter;
|
|
15
|
-
private pendingRequests;
|
|
16
|
-
private requestQueue;
|
|
17
|
-
private isProcessing;
|
|
18
14
|
private eventListeners;
|
|
19
|
-
constructor(logger:
|
|
15
|
+
constructor(logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string);
|
|
20
16
|
listen<E extends keyof SystemManagerProxyEventCallbacks>(eventType: E, callback: SystemManagerProxyEventCallbacks[E]): void;
|
|
21
17
|
removeListener<E extends keyof SystemManagerProxyEventCallbacks>(eventType: E, callbackToRemove: SystemManagerProxyEventCallbacks[E]): void;
|
|
22
18
|
removeAllListeners<E extends keyof SystemManagerProxyEventCallbacks>(eventType?: E): void;
|
|
23
19
|
private listenToSubscriberEvents;
|
|
24
20
|
private onRequest;
|
|
25
|
-
private enqueueAndProcessRequest;
|
|
26
|
-
private processNextRequest;
|
|
27
|
-
private onReply;
|
|
28
|
-
private resolveRequest;
|
|
29
21
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SocketOptions, Router, Reply, Publisher, Request, Dealer, Subscriber } from 'zeromq';
|
|
2
|
+
export declare const ROUTER_OPTIONS: SocketOptions<Router>;
|
|
3
|
+
export declare const REPLY_OPTIONS: SocketOptions<Reply>;
|
|
4
|
+
export declare const PUBLISHER_OPTIONS: SocketOptions<Publisher>;
|
|
5
|
+
export declare const REQUEST_OPTIONS: SocketOptions<Request>;
|
|
6
|
+
export declare const SUBSCRIBER_OPTIONS: SocketOptions<Subscriber>;
|
|
7
|
+
export declare const DEALER_OPTIONS: SocketOptions<Dealer>;
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
+
import { Reply, Router, Publisher } from 'zeromq';
|
|
1
2
|
import { ServerProxy } from './proxies/server';
|
|
2
3
|
import { CameraDeviceProxy } from './proxies/camera';
|
|
3
4
|
import { PluginProxy } from './proxies/plugin';
|
|
4
|
-
import type {
|
|
5
|
+
import type { ProxyBridge } from './ws';
|
|
6
|
+
import type { ProxyEvents, TargetID, QueueItem } from './types';
|
|
5
7
|
export declare class ProxyServer {
|
|
6
8
|
server?: ServerProxy;
|
|
7
9
|
camera?: CameraDeviceProxy;
|
|
8
10
|
plugin?: PluginProxy;
|
|
9
11
|
private logger;
|
|
10
12
|
private configService;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
router: Router;
|
|
14
|
+
reqServer: Reply;
|
|
15
|
+
pubServer: Publisher;
|
|
16
|
+
socketBridge?: ProxyBridge;
|
|
17
|
+
private messageQueue;
|
|
15
18
|
constructor();
|
|
16
19
|
initialize(): Promise<void>;
|
|
17
20
|
close(): Promise<void>;
|
|
21
|
+
sendMessage(item: QueueItem): Promise<void>;
|
|
18
22
|
publishEvent<K extends keyof ProxyEvents>(targetId: TargetID, type: K, data: ProxyEvents[K]): Promise<void>;
|
|
19
|
-
private
|
|
23
|
+
private listenToRequestMessages;
|
|
24
|
+
private listenToRouterMessages;
|
|
25
|
+
private isProxyMessage;
|
|
20
26
|
}
|
|
@@ -1,13 +1,30 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { CameraDeviceProxyMessageStructure, CameraDeviceProxyMethods, CameraDeviceListenerMessagePayload, CameraId } from '../types';
|
|
1
|
+
import type { CameraInput } from '../../api/database/types';
|
|
3
2
|
import type { OnSetEvent, StateValues } from '../../camera/types';
|
|
4
|
-
import type {
|
|
3
|
+
import type { IceServer } from '../../services/config/types';
|
|
4
|
+
import type { FfmpegOptions, PrebufferType } from '../../camera/types';
|
|
5
|
+
import type { ProxyServer } from '..';
|
|
6
|
+
import type { CameraDeviceProxyMessageStructure, CameraDeviceProxyMethods, CameraDeviceListenerMessagePayload, CameraId } from '../types';
|
|
5
7
|
export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
|
|
6
8
|
private api;
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
|
|
9
|
+
private configService;
|
|
10
|
+
private camerasService;
|
|
11
|
+
private pluginsService;
|
|
12
|
+
private proxyServer;
|
|
13
|
+
constructor(proxyServer: ProxyServer);
|
|
14
|
+
snapshot(data: {
|
|
15
|
+
sourceName: string;
|
|
16
|
+
cameraId: string;
|
|
17
|
+
pluginId: string;
|
|
18
|
+
}): Promise<ArrayBuffer>;
|
|
19
|
+
setPrebufferSource(data: {
|
|
20
|
+
sourceName: string;
|
|
21
|
+
address: string | null;
|
|
22
|
+
type: PrebufferType;
|
|
23
|
+
cameraId: string;
|
|
24
|
+
pluginId: string;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
getFffmpegPath(): string;
|
|
27
|
+
getIceServers(): IceServer[];
|
|
11
28
|
updateState<T extends keyof StateValues>(data: {
|
|
12
29
|
stateName: T;
|
|
13
30
|
eventData: OnSetEvent<T>;
|
|
@@ -15,8 +32,22 @@ export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
|
|
|
15
32
|
}): void;
|
|
16
33
|
refreshStates(data: {
|
|
17
34
|
cameraId: string;
|
|
18
|
-
}):
|
|
19
|
-
|
|
35
|
+
}): {
|
|
36
|
+
sources: CameraInput[];
|
|
37
|
+
states: StateValues;
|
|
38
|
+
} | undefined;
|
|
39
|
+
streamVideo(data: {
|
|
40
|
+
sourceName: string;
|
|
41
|
+
options: FfmpegOptions;
|
|
42
|
+
cameraId: string;
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
recordToFile(data: {
|
|
45
|
+
sourceName: string;
|
|
46
|
+
outputPath: string;
|
|
47
|
+
duration?: number;
|
|
48
|
+
cameraId: string;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
handleMessage(msg: CameraDeviceProxyMessageStructure): Promise<void>;
|
|
20
51
|
publishCameraMessage<K extends keyof StateValues>(cameraId: CameraId, stateName: K, data: {
|
|
21
52
|
newEvent: StateValues[K];
|
|
22
53
|
oldEvent: StateValues[K];
|
|
@@ -1,30 +1,10 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
/// <reference types="node" />
|
|
5
|
-
/// <reference types="node" />
|
|
6
|
-
import type { Router } from 'zeromq';
|
|
7
1
|
import { type CameraStorage, type BasePlugin } from '../../plugins/types';
|
|
2
|
+
import type { ProxyServer } from '..';
|
|
8
3
|
import type { MethodKeys } from '../types';
|
|
9
4
|
export declare class PluginProxy {
|
|
10
|
-
private logger;
|
|
11
5
|
private pluginsService;
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
private pluginRequestIdCounter;
|
|
15
|
-
private storageRequestIdCounter;
|
|
16
|
-
pendingRequests: Map<string, {
|
|
17
|
-
resolve: (value: unknown) => void;
|
|
18
|
-
reject: (reason?: any) => void;
|
|
19
|
-
timeout: NodeJS.Timeout;
|
|
20
|
-
}>;
|
|
21
|
-
private requestQueue;
|
|
22
|
-
private isProcessing;
|
|
23
|
-
constructor(router: Router);
|
|
6
|
+
private proxyServer;
|
|
7
|
+
constructor(proxyServer: ProxyServer);
|
|
24
8
|
onRequestPluginFn<K extends Exclude<MethodKeys<BasePlugin>, 'configureCameras'>>(pluginId: string, fn: K, ...args: Parameters<BasePlugin[K]>): Promise<ReturnType<BasePlugin[K]>>;
|
|
25
9
|
onRequestStorageFn<K extends MethodKeys<CameraStorage>>(pluginId: string, cameraId: string, fn: K, ...args: Parameters<CameraStorage[K]>): Promise<ReturnType<CameraStorage[K]>>;
|
|
26
|
-
private enqueueAndProcessRequest;
|
|
27
|
-
private processNextRequest;
|
|
28
|
-
private onReply;
|
|
29
|
-
private resolveRequest;
|
|
30
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ApiProxyMethods,
|
|
1
|
+
import type { ProxyServer } from '..';
|
|
2
|
+
import type { ApiProxyMethods, ProxyMessageStructure } from '../types';
|
|
3
3
|
import type { Camera } from '../../api/database/types';
|
|
4
4
|
import type { CameraConfig } from '../../camera/types';
|
|
5
5
|
export declare interface ServerProxy {
|
|
@@ -7,11 +7,11 @@ export declare interface ServerProxy {
|
|
|
7
7
|
removeListener(): any;
|
|
8
8
|
removeAllListeners(): any;
|
|
9
9
|
}
|
|
10
|
-
export declare class ServerProxy implements ApiProxyMethods
|
|
10
|
+
export declare class ServerProxy implements ApiProxyMethods {
|
|
11
11
|
private camerasService;
|
|
12
12
|
private pluginsService;
|
|
13
|
-
private
|
|
14
|
-
constructor(
|
|
13
|
+
private proxyServer;
|
|
14
|
+
constructor(proxyServer: ProxyServer);
|
|
15
15
|
getCameraByName(data: {
|
|
16
16
|
name: string;
|
|
17
17
|
}): Promise<Camera | undefined>;
|
|
@@ -30,5 +30,5 @@ export declare class ServerProxy implements ApiProxyMethods, SystemProxyMethods
|
|
|
30
30
|
id: string;
|
|
31
31
|
pluginId: string;
|
|
32
32
|
}): Promise<void>;
|
|
33
|
-
|
|
33
|
+
handleMessage(msg: ProxyMessageStructure): Promise<void>;
|
|
34
34
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Reply, Router } from 'zeromq';
|
|
2
|
+
import type { QueueItem } from './types';
|
|
3
|
+
export declare class MessageQueue {
|
|
4
|
+
private queue;
|
|
5
|
+
private isProcessing;
|
|
6
|
+
private pendingResponses;
|
|
7
|
+
private reqServer;
|
|
8
|
+
private router;
|
|
9
|
+
constructor(reqServer: Reply, router: Router);
|
|
10
|
+
addToQueue(item: QueueItem): Promise<void>;
|
|
11
|
+
receiveResponse(requestId: string, response: any): void;
|
|
12
|
+
receiveError(requestId: string, error: Error): void;
|
|
13
|
+
private processQueue;
|
|
14
|
+
private sendMessage;
|
|
15
|
+
}
|