@camera.ui/browser 0.0.35 → 0.0.37
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 -1
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.browser.d.ts +30 -18
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.node.d.ts +10 -7
- package/dist/shared/types/index.d.ts +2 -0
- package/dist/src/api/database/types.d.ts +7 -25
- package/dist/src/api/schemas/cameras.schema.d.ts +112 -6
- package/dist/src/api/schemas/config.schema.d.ts +9 -9
- package/dist/src/api/services/cameras.service.d.ts +1 -2
- package/dist/src/api/ws/nsp/status.d.ts +10 -2
- package/dist/src/api/ws/nsp/streams.d.ts +0 -15
- package/dist/src/api/ws/types.d.ts +14 -0
- package/dist/src/api.d.ts +9 -36
- package/dist/src/camera/index.d.ts +35 -22
- package/dist/src/camera/streaming/browser/browser-peer-connection.d.ts +22 -0
- package/dist/src/camera/streaming/browser/browser-streaming-session.d.ts +17 -0
- package/dist/src/camera/streaming/browser/webrtc-browser-connection.d.ts +26 -0
- package/dist/src/camera/streaming/peer-connection.d.ts +5 -7
- package/dist/src/camera/streaming/streaming-session.d.ts +3 -3
- package/dist/src/camera/streaming/webrtc-connection.d.ts +4 -4
- package/dist/src/camera/types.d.ts +77 -23
- package/dist/src/go2rtc/index.d.ts +1 -0
- package/dist/src/plugins/api.d.ts +31 -0
- package/dist/src/plugins/base.d.ts +7 -11
- package/dist/src/plugins/cameraStorage.d.ts +5 -4
- package/dist/src/plugins/index.d.ts +0 -4
- package/dist/src/plugins/plugin.d.ts +2 -6
- package/dist/src/plugins/schema.d.ts +3 -3
- package/dist/src/plugins/storageController.d.ts +2 -2
- package/dist/src/plugins/types.d.ts +8 -21
- package/dist/src/plugins/worker.d.ts +0 -2
- package/dist/src/proxy/client/cameraDevice.d.ts +16 -11
- package/dist/src/proxy/client/deviceManager.d.ts +7 -5
- package/dist/src/proxy/client/pluginsManager.d.ts +5 -3
- package/dist/src/proxy/client/queue.d.ts +2 -0
- package/dist/src/proxy/client/systemManager.d.ts +5 -2
- package/dist/src/proxy/index.d.ts +2 -2
- package/dist/src/proxy/proxies/camera.d.ts +57 -47
- package/dist/src/proxy/proxies/plugin.d.ts +3 -2
- package/dist/src/proxy/queue.d.ts +2 -0
- package/dist/src/proxy/types.d.ts +50 -36
- package/dist/src/services/config/types.d.ts +1 -1
- package/dist/src/services/logger/index.d.ts +5 -4
- package/package.json +4 -4
- package/dist/src/plugins/child.d.ts +0 -18
- /package/dist/src/camera/{subscribed.d.ts → utils/subscribed.d.ts} +0 -0
|
@@ -1,38 +1,47 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { StreamingSession } from './streaming/streaming-session';
|
|
3
|
-
import
|
|
3
|
+
import { BrowserStreamingSession } from './streaming/browser/browser-streaming-session';
|
|
4
|
+
import type { Camera, CameraPublicProperties, CameraZone, CameraType, CameraInformation } from '../api/database/types';
|
|
4
5
|
import type { ProxyServer } from '../proxy';
|
|
5
|
-
import type { CameraDevice, BaseLogger, CameraDelegate } from './types';
|
|
6
|
+
import type { CameraDevice, BaseLogger, CameraDelegate, CameraPrebufferDelegate } from './types';
|
|
6
7
|
import type { IceServer } from '../services/config/types';
|
|
7
|
-
import type { StateValues, OnSetEvent, LightState, MotionState, AudioState, ObjectState, DoorbellState, SirenState, StreamingConnectionOptions, FfmpegOptions,
|
|
8
|
-
export declare class
|
|
8
|
+
import type { StateValues, OnSetEvent, LightState, MotionState, AudioState, ObjectState, DoorbellState, SirenState, BatteryState, StreamingConnectionOptions, FfmpegOptions, CameraSource } from './types';
|
|
9
|
+
export declare class CameraController implements CameraDevice {
|
|
10
|
+
private log;
|
|
9
11
|
private proxy?;
|
|
10
12
|
private cameraSubject;
|
|
11
|
-
private
|
|
13
|
+
private cameraState;
|
|
12
14
|
private lightState;
|
|
13
15
|
private motionState;
|
|
14
16
|
private audioState;
|
|
15
17
|
private objectState;
|
|
16
18
|
private doorbellState;
|
|
17
19
|
private sirenState;
|
|
18
|
-
|
|
20
|
+
private batteryState;
|
|
21
|
+
private snapshotCache;
|
|
22
|
+
onStarted: Observable<boolean>;
|
|
23
|
+
onLightSwitched: Observable<LightState>;
|
|
19
24
|
onMotionDetected: Observable<MotionState>;
|
|
20
25
|
onAudioDetected: Observable<AudioState>;
|
|
21
26
|
onObjectDetected: Observable<ObjectState>;
|
|
22
27
|
onDoorbellPressed: Observable<DoorbellState>;
|
|
23
28
|
onSirenDetected: Observable<SirenState>;
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
onBatteryChanged: Observable<BatteryState>;
|
|
30
|
+
private _delegate?;
|
|
31
|
+
private _prebufferDelegate?;
|
|
26
32
|
get id(): string;
|
|
27
33
|
get nativeId(): string | undefined;
|
|
28
34
|
get pluginId(): string;
|
|
35
|
+
get state(): boolean;
|
|
29
36
|
get disabled(): boolean;
|
|
30
37
|
get name(): string;
|
|
31
|
-
get type():
|
|
32
|
-
get
|
|
38
|
+
get type(): CameraType;
|
|
39
|
+
get info(): CameraInformation;
|
|
33
40
|
get isCloud(): boolean;
|
|
34
41
|
get hasLight(): boolean;
|
|
35
42
|
get hasSiren(): boolean;
|
|
43
|
+
get hasBinarySensor(): boolean;
|
|
44
|
+
get hasBattery(): boolean;
|
|
36
45
|
get hasMotionDetector(): boolean;
|
|
37
46
|
get hasAudioDetector(): boolean;
|
|
38
47
|
get hasObjectDetector(): boolean;
|
|
@@ -40,19 +49,23 @@ export declare class CameraDeviceHub implements CameraDevice {
|
|
|
40
49
|
get motionZones(): CameraZone[];
|
|
41
50
|
get objectZones(): CameraZone[];
|
|
42
51
|
get sources(): CameraSource[];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
get streamSource(): CameraSource;
|
|
53
|
+
get snapshotSource(): CameraSource;
|
|
54
|
+
get recordingSource(): CameraSource;
|
|
55
|
+
get detectionSource(): CameraSource;
|
|
56
|
+
get delegate(): CameraDelegate | undefined;
|
|
57
|
+
set delegate(delegate: CameraDelegate);
|
|
58
|
+
get prebufferDelegate(): CameraPrebufferDelegate | undefined;
|
|
59
|
+
set prebufferDelegate(delegate: CameraPrebufferDelegate);
|
|
60
|
+
constructor(camera: Camera, logger: BaseLogger, proxy?: ProxyServer);
|
|
61
|
+
connect(): Promise<void>;
|
|
62
|
+
disconnect(): Promise<void>;
|
|
63
|
+
reboot(): Promise<void>;
|
|
64
|
+
snapshot(forceNew?: boolean): Promise<ArrayBuffer>;
|
|
53
65
|
getFfmpegPath(): Promise<string>;
|
|
54
66
|
getIceServers(): Promise<IceServer[]>;
|
|
55
67
|
createSession(sourceName: string, options?: StreamingConnectionOptions): Promise<StreamingSession>;
|
|
68
|
+
createBrowserSession(): Promise<BrowserStreamingSession>;
|
|
56
69
|
streamVideo(sourceName: string, options: FfmpegOptions): Promise<StreamingSession>;
|
|
57
70
|
recordToFile(sourceName: string, outputPath: string, duration?: number): Promise<void>;
|
|
58
71
|
getValue<T extends keyof StateValues>(stateName: T): StateValues[T];
|
|
@@ -66,12 +79,12 @@ export declare class CameraDeviceHub implements CameraDevice {
|
|
|
66
79
|
newData: Camera[T];
|
|
67
80
|
}>;
|
|
68
81
|
updateCamera(updatedCamera: Camera): void;
|
|
69
|
-
|
|
82
|
+
updateCameraState(state: boolean): void;
|
|
70
83
|
removeCamera(): void;
|
|
71
84
|
removeAllListeners(): void;
|
|
72
85
|
private createStateObservable;
|
|
86
|
+
private subscribeToCameraState;
|
|
73
87
|
private subscribeToCameraChanges;
|
|
74
|
-
private subscribeToSourceChanges;
|
|
75
88
|
private subscribeToStateChanges;
|
|
76
89
|
private triggerProxyEvent;
|
|
77
90
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReplaySubject, Subject } from 'rxjs';
|
|
2
|
+
import { Subscribed } from '../../utils/subscribed';
|
|
3
|
+
import type { BasicBrowserPeerConnection, BaseLogger, CameraDevice } from '../../types';
|
|
4
|
+
import type { IceServer } from '../../../services/config/types';
|
|
5
|
+
export declare class BrowserPeerConnection extends Subscribed implements BasicBrowserPeerConnection {
|
|
6
|
+
onIceCandidate: Subject<RTCIceCandidate>;
|
|
7
|
+
onConnectionState: ReplaySubject<RTCPeerConnectionState>;
|
|
8
|
+
videoTransceiver: RTCRtpTransceiver;
|
|
9
|
+
audioTransceiver: RTCRtpTransceiver;
|
|
10
|
+
private cameraDevice;
|
|
11
|
+
private logger;
|
|
12
|
+
private pc;
|
|
13
|
+
constructor(cameraDevice: CameraDevice, iceServers: IceServer[], logger: BaseLogger);
|
|
14
|
+
createOffer(): Promise<RTCSessionDescriptionInit>;
|
|
15
|
+
acceptAnswer(answer: {
|
|
16
|
+
type: 'answer';
|
|
17
|
+
sdp: string;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
addIceCandidate(candidate: RTCIceCandidateInit): Promise<void>;
|
|
20
|
+
close(): void;
|
|
21
|
+
private createPeerCoonection;
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReplaySubject } from 'rxjs';
|
|
2
|
+
import { Subscribed } from '../../utils/subscribed';
|
|
3
|
+
import type { BaseLogger, CameraDevice } from '../../types';
|
|
4
|
+
import type { WebrtcBrowserConnection } from './webrtc-browser-connection';
|
|
5
|
+
export declare class BrowserStreamingSession extends Subscribed {
|
|
6
|
+
readonly onCallEnded: ReplaySubject<void>;
|
|
7
|
+
private readonly onUsingOpus;
|
|
8
|
+
private hasEnded;
|
|
9
|
+
private cameraDevice;
|
|
10
|
+
private connection;
|
|
11
|
+
private logger;
|
|
12
|
+
get isUsingOpus(): Promise<boolean>;
|
|
13
|
+
constructor(cameraDevice: CameraDevice, logger: BaseLogger, connection: WebrtcBrowserConnection);
|
|
14
|
+
stop(): void;
|
|
15
|
+
private bindToConnection;
|
|
16
|
+
private callEnded;
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReplaySubject, type Observable } from 'rxjs';
|
|
2
|
+
import { Subscribed } from '../../utils/subscribed';
|
|
3
|
+
import type { CameraDevice, BaseLogger } from '../../types';
|
|
4
|
+
import type { IceServer } from '../../../services/config/types';
|
|
5
|
+
export declare class WebrtcBrowserConnection extends Subscribed {
|
|
6
|
+
readonly onCameraConnected: ReplaySubject<void>;
|
|
7
|
+
readonly onCallAnswered: ReplaySubject<string>;
|
|
8
|
+
readonly onCallEnded: ReplaySubject<void>;
|
|
9
|
+
readonly onError: ReplaySubject<void>;
|
|
10
|
+
readonly onMessage: ReplaySubject<{
|
|
11
|
+
method: string;
|
|
12
|
+
}>;
|
|
13
|
+
readonly onWsOpen: Observable<unknown>;
|
|
14
|
+
private readonly pc;
|
|
15
|
+
private readonly ws;
|
|
16
|
+
private readonly onOfferSent;
|
|
17
|
+
private hasEnded;
|
|
18
|
+
private cameraDevice;
|
|
19
|
+
private logger;
|
|
20
|
+
constructor(cameraDevice: CameraDevice, sourceName: string, iceServers: IceServer[], logger: BaseLogger);
|
|
21
|
+
stop(): void;
|
|
22
|
+
private initiateCall;
|
|
23
|
+
private handleMessage;
|
|
24
|
+
private sendMessage;
|
|
25
|
+
private callEnded;
|
|
26
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ReplaySubject, Subject } from 'rxjs';
|
|
2
2
|
import { MediaStreamTrack, RTCSessionDescription } from 'werift';
|
|
3
|
-
import { Subscribed } from '../subscribed';
|
|
4
|
-
import type { WebSocket } from 'ws';
|
|
3
|
+
import { Subscribed } from '../utils/subscribed';
|
|
5
4
|
import type { RtpPacket, RtcpPacket, RTCIceCandidate } from 'werift';
|
|
6
|
-
import type { BasicPeerConnection, CameraDevice } from '../types';
|
|
5
|
+
import type { BasicPeerConnection, BaseLogger, CameraDevice } from '../types';
|
|
7
6
|
import type { IceServer } from '../../services/config/types';
|
|
8
7
|
export declare class WeriftPeerConnection extends Subscribed implements BasicPeerConnection {
|
|
9
8
|
onAudioRtp: Subject<RtpPacket>;
|
|
@@ -13,12 +12,11 @@ export declare class WeriftPeerConnection extends Subscribed implements BasicPee
|
|
|
13
12
|
onIceCandidate: Subject<RTCIceCandidate>;
|
|
14
13
|
onConnectionState: ReplaySubject<"closed" | "failed" | "disconnected" | "new" | "connecting" | "connected">;
|
|
15
14
|
returnAudioTrack: MediaStreamTrack;
|
|
16
|
-
private
|
|
17
|
-
private ws?;
|
|
15
|
+
private onRequestKeyFrame;
|
|
18
16
|
private cameraDevice;
|
|
19
17
|
private logger;
|
|
20
|
-
private
|
|
21
|
-
constructor(cameraDevice: CameraDevice, iceServers: IceServer[],
|
|
18
|
+
private pc;
|
|
19
|
+
constructor(cameraDevice: CameraDevice, iceServers: IceServer[], logger: BaseLogger);
|
|
22
20
|
createOffer(): Promise<RTCSessionDescription>;
|
|
23
21
|
acceptAnswer(answer: {
|
|
24
22
|
type: 'answer';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RtpPacket } from 'werift';
|
|
2
2
|
import { ReplaySubject, Subject } from 'rxjs';
|
|
3
|
-
import { Subscribed } from '../subscribed';
|
|
3
|
+
import { Subscribed } from '../utils/subscribed';
|
|
4
4
|
import type { WebrtcConnection } from './webrtc-connection';
|
|
5
|
-
import type { FfmpegOptions, SpawnInput, CameraDevice } from '../types';
|
|
5
|
+
import type { FfmpegOptions, SpawnInput, BaseLogger, CameraDevice } from '../types';
|
|
6
6
|
export declare class StreamingSession extends Subscribed {
|
|
7
7
|
readonly onCallEnded: ReplaySubject<void>;
|
|
8
8
|
readonly onVideoRtp: Subject<RtpPacket>;
|
|
@@ -16,7 +16,7 @@ export declare class StreamingSession extends Subscribed {
|
|
|
16
16
|
private connection;
|
|
17
17
|
private logger;
|
|
18
18
|
get isUsingOpus(): Promise<boolean>;
|
|
19
|
-
constructor(cameraDevice: CameraDevice, connection: WebrtcConnection);
|
|
19
|
+
constructor(cameraDevice: CameraDevice, logger: BaseLogger, connection: WebrtcConnection);
|
|
20
20
|
reservePort(bufferPorts?: number): Promise<number>;
|
|
21
21
|
startTranscoding(ffmpegOptions: FfmpegOptions): Promise<void>;
|
|
22
22
|
transcodeReturnAudio(ffmpegOptions: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReplaySubject, Subject, type Observable } from 'rxjs';
|
|
2
|
-
import { Subscribed } from '../subscribed';
|
|
2
|
+
import { Subscribed } from '../utils/subscribed';
|
|
3
3
|
import type { RtpPacket } from 'werift';
|
|
4
|
-
import type { StreamingConnectionOptions, CameraDevice } from '../types';
|
|
4
|
+
import type { StreamingConnectionOptions, BaseLogger, CameraDevice } from '../types';
|
|
5
5
|
import type { IceServer } from '../../services/config/types';
|
|
6
6
|
export declare class WebrtcConnection extends Subscribed {
|
|
7
7
|
readonly onCameraConnected: ReplaySubject<void>;
|
|
@@ -18,9 +18,9 @@ export declare class WebrtcConnection extends Subscribed {
|
|
|
18
18
|
private readonly ws;
|
|
19
19
|
private readonly onOfferSent;
|
|
20
20
|
private hasEnded;
|
|
21
|
-
private logger;
|
|
22
21
|
private cameraDevice;
|
|
23
|
-
|
|
22
|
+
private logger;
|
|
23
|
+
constructor(cameraDevice: CameraDevice, sourceName: string, iceServers: IceServer[], logger: BaseLogger, options: StreamingConnectionOptions);
|
|
24
24
|
sendAudioPacket(rtp: RtpPacket): void;
|
|
25
25
|
stop(): void;
|
|
26
26
|
requestKeyFrame(): void;
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
/// <reference types="pouchdb-core" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { Observable, Subject } from 'rxjs';
|
|
4
|
-
import type { ConnectionState, RTCIceCandidate } from 'werift';
|
|
5
|
-
import type { Camera, CameraPublicProperties, CameraInputSettings, CameraZone,
|
|
4
|
+
import type { ConnectionState, RTCIceCandidate as WeriftRTCICECandidate, RTCSessionDescription } from 'werift';
|
|
5
|
+
import type { Camera, CameraPublicProperties, CameraInputSettings, CameraZone, CameraInput, CameraType, CameraInformation } from '../api/database/types';
|
|
6
|
+
import type { IceServer } from '../services/config/types';
|
|
6
7
|
import type { StreamingSession } from './streaming/streaming-session';
|
|
8
|
+
import type { BrowserStreamingSession } from './streaming/browser/browser-streaming-session';
|
|
7
9
|
export type SpawnInput = string | number;
|
|
8
10
|
export type PrebufferType = 'recording' | 'stream';
|
|
11
|
+
export interface CameraSource extends CameraInput {
|
|
12
|
+
isPrebuffering(type: PrebufferType): Promise<boolean>;
|
|
13
|
+
getPrebufferRawUrl(type: PrebufferType): Promise<string | undefined>;
|
|
14
|
+
getStreamInfo(): Promise<StreamInfo | undefined>;
|
|
15
|
+
}
|
|
9
16
|
export interface BaseLogger {
|
|
10
17
|
log: (...args: any[]) => void;
|
|
11
18
|
error: (...args: any[]) => void;
|
|
12
19
|
warn: (...args: any[]) => void;
|
|
13
20
|
debug: (...args: any[]) => void;
|
|
21
|
+
trace: (...args: any[]) => void;
|
|
14
22
|
}
|
|
15
23
|
export interface FfmpegOptions {
|
|
16
24
|
input?: SpawnInput[];
|
|
@@ -22,56 +30,71 @@ export interface StreamingConnectionOptions {
|
|
|
22
30
|
createPeerConnection?: () => BasicPeerConnection;
|
|
23
31
|
}
|
|
24
32
|
export interface BasicPeerConnection {
|
|
25
|
-
createOffer(): Promise<
|
|
33
|
+
createOffer(): Promise<RTCSessionDescription>;
|
|
34
|
+
acceptAnswer(answer: {
|
|
35
|
+
type: 'answer';
|
|
26
36
|
sdp: string;
|
|
27
|
-
}>;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
addIceCandidate(candidate: Partial<WeriftRTCICECandidate>): Promise<void>;
|
|
39
|
+
onIceCandidate: Subject<WeriftRTCICECandidate>;
|
|
40
|
+
onConnectionState: Observable<ConnectionState>;
|
|
41
|
+
close(): void;
|
|
42
|
+
requestKeyFrame?: () => void;
|
|
43
|
+
}
|
|
44
|
+
export interface BasicBrowserPeerConnection {
|
|
45
|
+
createOffer(): Promise<RTCSessionDescriptionInit>;
|
|
28
46
|
acceptAnswer(answer: {
|
|
29
47
|
type: 'answer';
|
|
30
48
|
sdp: string;
|
|
31
49
|
}): Promise<void>;
|
|
32
50
|
addIceCandidate(candidate: Partial<RTCIceCandidate>): Promise<void>;
|
|
33
51
|
onIceCandidate: Subject<RTCIceCandidate>;
|
|
34
|
-
onConnectionState: Observable<
|
|
52
|
+
onConnectionState: Observable<RTCPeerConnectionState>;
|
|
35
53
|
close(): void;
|
|
36
|
-
requestKeyFrame?: () => void;
|
|
37
54
|
}
|
|
38
55
|
export interface CameraDevice {
|
|
39
56
|
id: string;
|
|
40
57
|
pluginId: string;
|
|
41
58
|
nativeId?: string;
|
|
59
|
+
state: boolean;
|
|
42
60
|
disabled: boolean;
|
|
43
61
|
name: string;
|
|
44
|
-
type:
|
|
45
|
-
|
|
62
|
+
type: CameraType;
|
|
63
|
+
info: CameraInformation;
|
|
46
64
|
sources: CameraSource[];
|
|
47
65
|
motionZones: CameraZone[];
|
|
48
66
|
objectZones: CameraZone[];
|
|
49
|
-
logger: BaseLogger;
|
|
50
67
|
isCloud: boolean;
|
|
51
68
|
hasLight: boolean;
|
|
52
69
|
hasSiren: boolean;
|
|
70
|
+
hasBinarySensor: boolean;
|
|
71
|
+
hasBattery: boolean;
|
|
53
72
|
hasMotionDetector: boolean;
|
|
54
73
|
hasAudioDetector: boolean;
|
|
55
74
|
hasObjectDetector: boolean;
|
|
56
75
|
hasPtz: boolean;
|
|
57
|
-
|
|
76
|
+
onStarted: Observable<boolean>;
|
|
77
|
+
onLightSwitched: Observable<LightState>;
|
|
58
78
|
onMotionDetected: Observable<MotionState>;
|
|
59
79
|
onAudioDetected: Observable<AudioState>;
|
|
60
80
|
onObjectDetected: Observable<ObjectState>;
|
|
61
81
|
onDoorbellPressed: Observable<DoorbellState>;
|
|
62
82
|
onSirenDetected: Observable<SirenState>;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
83
|
+
onBatteryChanged: Observable<BatteryState>;
|
|
84
|
+
streamSource: CameraSource;
|
|
85
|
+
snapshotSource: CameraSource;
|
|
86
|
+
recordingSource: CameraSource;
|
|
87
|
+
detectionSource: CameraSource;
|
|
88
|
+
delegate?: CameraDelegate;
|
|
89
|
+
prebufferDelegate?: CameraPrebufferDelegate;
|
|
90
|
+
connect(): Promise<void>;
|
|
91
|
+
disconnect(): Promise<void>;
|
|
92
|
+
reboot(): Promise<void>;
|
|
72
93
|
getFfmpegPath(): Promise<string>;
|
|
73
|
-
getIceServers(): Promise<
|
|
94
|
+
getIceServers(): Promise<IceServer[]>;
|
|
95
|
+
snapshot(forceNew?: boolean): Promise<ArrayBuffer>;
|
|
74
96
|
createSession(sourceName: string, options?: StreamingConnectionOptions): Promise<StreamingSession>;
|
|
97
|
+
createBrowserSession(sourceName: string): Promise<BrowserStreamingSession>;
|
|
75
98
|
streamVideo(sourceName: string, options: FfmpegOptions): Promise<StreamingSession>;
|
|
76
99
|
recordToFile(sourceName: string, outputPath: string, duration?: number): Promise<void>;
|
|
77
100
|
getValue<T extends keyof StateValues>(stateName: T): StateValue<T>;
|
|
@@ -91,6 +114,30 @@ export interface CameraDelegate {
|
|
|
91
114
|
prepareStream(requestId: string): Promise<void>;
|
|
92
115
|
onOffer(requestId: string, sdp: string): Promise<string>;
|
|
93
116
|
onCandidates(requestId: string, candidates: string): Promise<void>;
|
|
117
|
+
reboot(): Promise<void>;
|
|
118
|
+
}
|
|
119
|
+
export interface CameraPrebufferDelegate {
|
|
120
|
+
isPrebuffering(sourceName: string, type: PrebufferType): Promise<boolean>;
|
|
121
|
+
getPrebufferRawUrl(sourceName: string, type: PrebufferType): Promise<string | undefined>;
|
|
122
|
+
getStreamInfo(sourceName: string): Promise<StreamInfo | undefined>;
|
|
123
|
+
}
|
|
124
|
+
export interface AudioStreamOptions {
|
|
125
|
+
enabled?: boolean;
|
|
126
|
+
codec?: string;
|
|
127
|
+
bitrate?: number;
|
|
128
|
+
sampleRate?: number;
|
|
129
|
+
}
|
|
130
|
+
export interface VideoStreamOptions {
|
|
131
|
+
codec?: string;
|
|
132
|
+
width?: number;
|
|
133
|
+
height?: number;
|
|
134
|
+
bitrate?: number;
|
|
135
|
+
fps?: number;
|
|
136
|
+
idrInterval?: number;
|
|
137
|
+
}
|
|
138
|
+
export interface StreamInfo {
|
|
139
|
+
audio: AudioStreamOptions;
|
|
140
|
+
video: VideoStreamOptions;
|
|
94
141
|
}
|
|
95
142
|
export type Sdp = string;
|
|
96
143
|
export type IceCandiate = string;
|
|
@@ -118,8 +165,10 @@ export interface BaseCameraConfig {
|
|
|
118
165
|
isCloud?: boolean;
|
|
119
166
|
hasLight?: boolean;
|
|
120
167
|
hasSiren?: boolean;
|
|
168
|
+
hasBinarySensor?: boolean;
|
|
169
|
+
hasBattery?: boolean;
|
|
121
170
|
disabled?: boolean;
|
|
122
|
-
|
|
171
|
+
info?: Partial<CameraInformation>;
|
|
123
172
|
}
|
|
124
173
|
export type CameraConfig = (BaseCameraConfig & {
|
|
125
174
|
sources?: Omit<CameraInputSettings, '_id'>[];
|
|
@@ -149,6 +198,9 @@ export interface DoorbellSetEvent {
|
|
|
149
198
|
export interface SirenSetEvent {
|
|
150
199
|
state: boolean;
|
|
151
200
|
}
|
|
201
|
+
export interface BatterySetEvent {
|
|
202
|
+
state: number;
|
|
203
|
+
}
|
|
152
204
|
export interface DeviceSetEvent {
|
|
153
205
|
}
|
|
154
206
|
export type LightState = BaseState & LightSetEvent;
|
|
@@ -157,7 +209,8 @@ export type AudioState = BaseState & AudioSetEvent;
|
|
|
157
209
|
export type DoorbellState = BaseState & DoorbellSetEvent;
|
|
158
210
|
export type SirenState = BaseState & SirenSetEvent;
|
|
159
211
|
export type ObjectState = BaseState & ObjectSetEvent;
|
|
160
|
-
export type
|
|
212
|
+
export type BatteryState = BaseState & BatterySetEvent;
|
|
213
|
+
export type State = LightState | MotionState | AudioState | ObjectState | DoorbellState | SirenState | BatteryState;
|
|
161
214
|
export interface StateValues {
|
|
162
215
|
light: LightState;
|
|
163
216
|
motion: MotionState;
|
|
@@ -165,10 +218,11 @@ export interface StateValues {
|
|
|
165
218
|
object: ObjectState;
|
|
166
219
|
doorbell: DoorbellState;
|
|
167
220
|
siren: SirenState;
|
|
221
|
+
battery: BatteryState;
|
|
168
222
|
}
|
|
169
223
|
export type CameraStateCallbacks = {
|
|
170
224
|
[K in keyof StateValues]: (event: StateValues[K]) => void;
|
|
171
225
|
};
|
|
172
226
|
export type StateValue<T extends keyof StateValues> = StateValues[T];
|
|
173
|
-
export type OnSetEvent<T extends keyof StateValues> = T extends 'light' ? LightSetEvent : T extends 'motion' ? MotionSetEvent : T extends 'audio' ? AudioSetEvent : T extends 'doorbell' ? DoorbellSetEvent : T extends 'siren' ? SirenSetEvent : ObjectSetEvent;
|
|
227
|
+
export type OnSetEvent<T extends keyof StateValues> = T extends 'light' ? LightSetEvent : T extends 'motion' ? MotionSetEvent : T extends 'audio' ? AudioSetEvent : T extends 'doorbell' ? DoorbellSetEvent : T extends 'siren' ? SirenSetEvent : T extends 'battery' ? BatterySetEvent : ObjectSetEvent;
|
|
174
228
|
export type OnChangeCallback<T extends keyof StateValues> = (newEvent: StateValues[T], oldEvent: StateValues[T]) => void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import EventEmitter from 'events';
|
|
3
|
+
import { DeviceManager, PluginsManager, SystemManager } from '../proxy/client';
|
|
4
|
+
import { StorageController } from './storageController';
|
|
5
|
+
import type { ZmqInfo } from './types';
|
|
6
|
+
import type { Plugin } from './plugin';
|
|
7
|
+
import type { PluginLogger } from '../services/logger';
|
|
8
|
+
import type { BasePlugin } from './base';
|
|
9
|
+
import type { PluginConfigService } from './config';
|
|
10
|
+
export interface API {
|
|
11
|
+
on(event: 'finishLaunching', listener: () => void): this;
|
|
12
|
+
on(event: 'shutdown', listener: () => void): this;
|
|
13
|
+
readonly deviceManager: DeviceManager;
|
|
14
|
+
readonly pluginsManager: PluginsManager;
|
|
15
|
+
readonly systemManager: SystemManager;
|
|
16
|
+
readonly storageController: StorageController;
|
|
17
|
+
readonly configService: PluginConfigService;
|
|
18
|
+
readonly storagePath: string;
|
|
19
|
+
readonly configFile: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class PluginAPI extends EventEmitter implements API {
|
|
22
|
+
readonly deviceManager: DeviceManager;
|
|
23
|
+
readonly pluginsManager: PluginsManager;
|
|
24
|
+
readonly systemManager: SystemManager;
|
|
25
|
+
readonly storageController: StorageController;
|
|
26
|
+
readonly configService: PluginConfigService;
|
|
27
|
+
readonly storagePath: string;
|
|
28
|
+
readonly configFile: string;
|
|
29
|
+
readonly plugin: BasePlugin;
|
|
30
|
+
constructor(plugin: Plugin, logger: PluginLogger, proxyData: ZmqInfo);
|
|
31
|
+
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import type { API } from '
|
|
1
|
+
import type { API } from './api';
|
|
2
2
|
import type { CameraDevice } from '../camera/types';
|
|
3
3
|
import type { PluginLogger } from '../services/logger';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare class BasePlugin implements BasePluginMethods {
|
|
4
|
+
import type { PluginContract } from './types';
|
|
5
|
+
export declare abstract class BasePlugin {
|
|
6
|
+
static contract: PluginContract;
|
|
8
7
|
id: string;
|
|
9
8
|
api: API;
|
|
10
|
-
configService: PluginConfigService;
|
|
11
9
|
logger: PluginLogger;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
constructor(pluginId: string, log: PluginLogger, configService: PluginConfigService, storage: Storage, api: API);
|
|
15
|
-
onFormSubmit(actionId: string, payload: any): Promise<{
|
|
10
|
+
constructor(pluginId: string, log: PluginLogger, api: API);
|
|
11
|
+
abstract onFormSubmit(actionId: string, payload: any): Promise<{
|
|
16
12
|
toast?: string;
|
|
17
13
|
} | void>;
|
|
18
|
-
configureCameras(cameras: CameraDevice[]): void;
|
|
14
|
+
abstract configureCameras(cameras: CameraDevice[]): void;
|
|
19
15
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { API } from '
|
|
2
|
-
import type { PluginJsonSchemaForm, PluginJsonSchema,
|
|
3
|
-
export declare class CameraStorage
|
|
1
|
+
import type { API } from './api';
|
|
2
|
+
import type { PluginJsonSchemaForm, PluginJsonSchema, SchemaConfig } from './types';
|
|
3
|
+
export declare class CameraStorage {
|
|
4
4
|
private cameraId;
|
|
5
5
|
private instance;
|
|
6
6
|
private api;
|
|
7
7
|
private db;
|
|
8
8
|
private _schema;
|
|
9
9
|
private _values;
|
|
10
|
+
get values(): Record<string, any>;
|
|
10
11
|
constructor(api: API, instance: any, cameraId: string, schema?: PluginJsonSchemaForm);
|
|
11
12
|
/**
|
|
12
13
|
* Initialize the storage.
|
|
@@ -22,8 +23,8 @@ export declare class CameraStorage implements CameraStorageMethods {
|
|
|
22
23
|
* @param path - The path to the configuration value.
|
|
23
24
|
* @returns The value from the configuration.
|
|
24
25
|
*/
|
|
26
|
+
getValue<T = string>(path: string): Promise<T> | T | undefined;
|
|
25
27
|
getValue<T = string>(path: string, defaultValue: T): Promise<T> | T;
|
|
26
|
-
getValue<T = string>(path: string, defaultValue?: T): Promise<T> | T | undefined;
|
|
27
28
|
/**
|
|
28
29
|
* Set a new value for a given key/path in the configuration.
|
|
29
30
|
* If the schema of the value has an onSet function, and the value has changed, the onSet function will be called.
|
|
@@ -12,9 +12,7 @@ export declare class PluginManager {
|
|
|
12
12
|
plugins: Map<string, Plugin>;
|
|
13
13
|
pluginWorkers: Map<string, PluginWorker>;
|
|
14
14
|
searchPaths: Set<string>;
|
|
15
|
-
private api;
|
|
16
15
|
private configService;
|
|
17
|
-
private currentInitializingPlugin?;
|
|
18
16
|
constructor();
|
|
19
17
|
static isQualifiedPluginIdentifier(pluginName: string): boolean;
|
|
20
18
|
static extractPluginScope(pluginName: string): string;
|
|
@@ -23,7 +21,6 @@ export declare class PluginManager {
|
|
|
23
21
|
static loadPackageJSON(installPath: string): IPackageJson;
|
|
24
22
|
initializeInstalledPlugins(): Promise<void>;
|
|
25
23
|
initializeInstalledPlugin(plugin: Plugin, insertDb?: boolean): Promise<void>;
|
|
26
|
-
initializePlugin(plugin: Plugin, pluginName: string): Promise<void>;
|
|
27
24
|
loadPlugin(absolutePath: string, pluginId?: string, storagePath?: string): Promise<Plugin>;
|
|
28
25
|
removePlugin(plugin: Plugin, removeFromDb?: boolean, removeStorage?: boolean): Promise<void>;
|
|
29
26
|
startPluginChilds(): Promise<void>;
|
|
@@ -31,7 +28,6 @@ export declare class PluginManager {
|
|
|
31
28
|
stopPluginChild(pluginName: string): Promise<void>;
|
|
32
29
|
private loadInstalledPlugins;
|
|
33
30
|
private removeOrphanedPlugins;
|
|
34
|
-
private handlePluginRegistration;
|
|
35
31
|
private loadDefaultPaths;
|
|
36
32
|
private addNpmPrefixToSearchPaths;
|
|
37
33
|
private isDependencyForOthers;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
**/
|
|
7
7
|
import { PluginConfigService } from './config';
|
|
8
|
-
import type {
|
|
8
|
+
import type { PluginConstructor } from '../api';
|
|
9
9
|
import type { IPackageJson, CameraUiPlugin } from '../api/types';
|
|
10
10
|
import type { PluginContract } from './types';
|
|
11
11
|
export interface Context {
|
|
@@ -33,18 +33,14 @@ export declare class Plugin {
|
|
|
33
33
|
readonly storagePath: string;
|
|
34
34
|
private readonly main;
|
|
35
35
|
private loadContext?;
|
|
36
|
-
|
|
37
|
-
private pluginConstructor;
|
|
36
|
+
pluginConstructor?: PluginConstructor;
|
|
38
37
|
get contract(): PluginContract;
|
|
39
38
|
get info(): CameraUiPlugin;
|
|
40
39
|
set info(value: CameraUiPlugin);
|
|
41
40
|
get disabled(): boolean;
|
|
42
41
|
set disabled(value: boolean);
|
|
43
42
|
constructor(pluginName: string, installPath: string, packageJSON: IPackageJson, pluginId: string, scope?: string, storagePath?: string);
|
|
44
|
-
getPluginConstructor(pluginName: string): PluginConstructor;
|
|
45
|
-
initialize(api: CameraUiAPI): void | Promise<void>;
|
|
46
43
|
load(): Promise<void>;
|
|
47
|
-
registerPlugin(constructor: PluginConstructor, contract: PluginContract): void;
|
|
48
44
|
reparsePackageJson(): CameraUiPlugin;
|
|
49
45
|
private parsePackageJson;
|
|
50
46
|
}
|
|
@@ -18,8 +18,8 @@ type OptionalZodZobject = z.ZodOptional<z.ZodObject<Record<string, z.ZodTypeAny>
|
|
|
18
18
|
[x: string]: any;
|
|
19
19
|
}> | z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>> | z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
20
20
|
type OptionalZodArray = z.ZodOptional<z.ZodType<any, any, any>> | z.ZodType<any, any, any>;
|
|
21
|
-
type OptionalZodEnum = z.ZodOptional<z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>> | z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>;
|
|
22
|
-
type OptionalZodEnumMultiple = z.ZodOptional<z.ZodArray<z.ZodUnion<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>, 'many'>> | z.ZodArray<z.ZodUnion<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>, 'many'>;
|
|
21
|
+
type OptionalZodEnum = z.ZodOptional<z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>> | z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]> | z.ZodEffects<z.ZodAny, any, any> | z.ZodUnion<any>;
|
|
22
|
+
type OptionalZodEnumMultiple = z.ZodOptional<z.ZodArray<z.ZodUnion<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>, 'many'>> | z.ZodArray<z.ZodUnion<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>, 'many'> | z.ZodEffects<z.ZodAny, any, any> | z.ZodUnion<any>;
|
|
23
23
|
type ZodAny = z.ZodType<any, any, any>;
|
|
24
24
|
/**
|
|
25
25
|
* Generate root JSON schema from value.
|
|
@@ -137,7 +137,7 @@ export declare const generateStringSchema: (value: string) => JsonSchemaString;
|
|
|
137
137
|
* @param type - The type of the enum.
|
|
138
138
|
* @returns - The generated JSON schema for the enum.
|
|
139
139
|
*/
|
|
140
|
-
export declare const generateEnumSchema: (value:
|
|
140
|
+
export declare const generateEnumSchema: (value: string[]) => JsonSchemaEnum;
|
|
141
141
|
/**
|
|
142
142
|
* Generates a JSON schema for an object.
|
|
143
143
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CameraStorage } from './cameraStorage';
|
|
2
|
-
import type { API } from '
|
|
2
|
+
import type { API } from './api';
|
|
3
3
|
import type { PluginJsonSchemaForm } from './types';
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class StorageController {
|
|
5
5
|
private api;
|
|
6
6
|
private cameraStorages;
|
|
7
7
|
constructor(api: API);
|