@camera.ui/browser 0.0.32 → 0.0.34

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.
@@ -1,6 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import type { SocketService } from '../../socket';
3
- import type { Camera, CameraDevice, StateValue, StateValues, OnSetEvent, PrebufferType, LightState, MotionState, AudioState, ObjectState, DoorbellState, SirenState, BaseLogger, FfmpegOptions, Input } from '../../../../../shared/types';
3
+ import type { Camera, CameraDevice, StateValue, StateValues, OnSetEvent, PrebufferType, LightState, MotionState, AudioState, ObjectState, DoorbellState, SirenState, BaseLogger, FfmpegOptions, CameraInput } from '../../../../../shared/types';
4
4
  export declare class CameraDeviceClient implements CameraDevice {
5
5
  private socketService;
6
6
  private cameraSubject;
@@ -30,10 +30,12 @@ export declare class CameraDeviceClient implements CameraDevice {
30
30
  get hasAudioDetector(): boolean;
31
31
  get hasObjectDetector(): boolean;
32
32
  get hasPtz(): boolean;
33
- get sources(): Input[];
33
+ get sources(): CameraInput[];
34
34
  constructor(camera: Camera, socketService: SocketService, logger: BaseLogger);
35
- snapshot(sourceName?: string): Promise<ArrayBuffer>;
36
- setPrebufferSource(sourceName: string, address: string | null, type: PrebufferType, fromCamera?: boolean): Promise<void>;
35
+ snapshot(sourceName?: string, prebuffer?: boolean): Promise<ArrayBuffer>;
36
+ setPrebufferSource(sourceName: string, address: string, type: PrebufferType): Promise<void>;
37
+ removePrebufferSource(sourceName: string, type: 'recording' | 'stream'): Promise<void>;
38
+ removePrebufferSources(): Promise<void>;
37
39
  getFfmpegPath(): Promise<string>;
38
40
  getIceServers(): Promise<RTCIceServer[]>;
39
41
  getValue<T extends keyof StateValues>(stateName: T): StateValue<T>;
@@ -1,9 +1,12 @@
1
1
  import { CameraDeviceHub } from '../../../../../src/camera';
2
2
  import type { SocketService } from '../../socket';
3
- import type { Camera, StateValues, OnSetEvent, BaseLogger, IceServer } from '../../../../../shared/types';
3
+ import type { Camera, StateValues, OnSetEvent, BaseLogger, IceServer, PrebufferType } from '../../../../../shared/types';
4
4
  export declare class CameraDeviceClient extends CameraDeviceHub {
5
5
  private socketService;
6
6
  constructor(camera: Camera, socketService: SocketService, logger: BaseLogger);
7
+ setPrebufferSource(sourceName: string, address: string | null, type: PrebufferType): Promise<void>;
8
+ removePrebufferSource(sourceName: string, type: 'recording' | 'stream'): Promise<void>;
9
+ removePrebufferSources(): Promise<void>;
7
10
  getFfmpegPath(): Promise<string>;
8
11
  getIceServers(): Promise<IceServer[]>;
9
12
  updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): Promise<void>;
@@ -145,9 +145,15 @@ export interface Go2RtcFFMPEGSource {
145
145
  aac: string;
146
146
  opus: string;
147
147
  }
148
+ export interface PrebufferStreamSource {
149
+ source: string;
150
+ rawUrl?: string | string[] | null;
151
+ snapshotUrl: string;
152
+ prebuffering?: boolean;
153
+ }
148
154
  export interface Go2RtcPrebufferSource {
149
- stream?: string;
150
- recording?: string;
155
+ stream: PrebufferStreamSource;
156
+ recording: PrebufferStreamSource;
151
157
  }
152
158
  export interface StreamSources {
153
159
  webrtc: string;
@@ -1,8 +1,8 @@
1
1
  import type { ApplicationResponse, ExitData } from '../types';
2
- declare class ApplicationService {
2
+ declare class ApplicationApi {
3
3
  close(data: ExitData): Promise<void>;
4
4
  info(): Promise<ApplicationResponse>;
5
5
  restart(): Promise<void>;
6
6
  }
7
- declare const _default: ApplicationService;
7
+ declare const _default: ApplicationApi;
8
8
  export default _default;
@@ -0,0 +1,8 @@
1
+ import type { AxiosResponse } from 'axios';
2
+ declare class ConfigApi {
3
+ getConfig(): Promise<AxiosResponse>;
4
+ rewriteConfig(data: Record<string, any>): Promise<AxiosResponse>;
5
+ mergeConfig(data: Record<string, any>): Promise<AxiosResponse>;
6
+ }
7
+ declare const _default: ConfigApi;
8
+ export default _default;
@@ -1,7 +1,7 @@
1
1
  import type { SourceData } from '../types';
2
- declare class SnapshotService {
3
- jpeg(data: SourceData): Promise<string>;
4
- mp4(data: SourceData): Promise<string>;
2
+ declare class SnapshotApi {
3
+ jpeg(data: SourceData): Promise<ArrayBuffer>;
4
+ mp4(data: SourceData): Promise<ArrayBuffer>;
5
5
  }
6
- declare const _default: SnapshotService;
6
+ declare const _default: SnapshotApi;
7
7
  export default _default;
@@ -1,11 +1,11 @@
1
1
  import type { AxiosResponse } from 'axios';
2
2
  import type { StreamData, SourceData, IntercomData } from '../types';
3
- declare class StreamsService {
3
+ declare class StreamsApi {
4
4
  createStream(data: StreamData): Promise<AxiosResponse>;
5
5
  deleteStream(data: SourceData): Promise<AxiosResponse>;
6
6
  getStreamInfo(data: SourceData): Promise<AxiosResponse>;
7
7
  sendStreamToDst(data: IntercomData): Promise<AxiosResponse>;
8
8
  updateStreamSource(data: StreamData): Promise<AxiosResponse>;
9
9
  }
10
- declare const _default: StreamsService;
10
+ declare const _default: StreamsApi;
11
11
  export default _default;
@@ -1,3 +1,4 @@
1
1
  export { default as ApplicationApi } from './api/application';
2
- export { default as StreamsService } from './api/streams';
3
- export { default as SnapshotService } from './api/snapshot';
2
+ export { default as StreamsApi } from './api/streams';
3
+ export { default as SnapshotApi } from './api/snapshot';
4
+ export { default as ConfigApi } from './api/config';
@@ -403,7 +403,7 @@ export declare const patchGo2RtcSchema: zod.ZodObject<{
403
403
  rtsp?: string | undefined;
404
404
  output?: string | undefined;
405
405
  }>>>;
406
- streams: zod.ZodDefault<zod.ZodRecord<zod.ZodEffects<zod.ZodString, string, string>, zod.ZodUnion<[zod.ZodString, zod.ZodArray<zod.ZodString, "many">, zod.ZodNull]>>>;
406
+ streams: zod.ZodOptional<zod.ZodRecord<zod.ZodEffects<zod.ZodString, string, string>, zod.ZodUnion<[zod.ZodString, zod.ZodArray<zod.ZodString, "many">, zod.ZodNull]>>>;
407
407
  homekit: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodUnion<[zod.ZodOptional<zod.ZodObject<{
408
408
  pin: zod.ZodOptional<zod.ZodNumber>;
409
409
  name: zod.ZodOptional<zod.ZodString>;
@@ -481,7 +481,6 @@ export declare const patchGo2RtcSchema: zod.ZodObject<{
481
481
  rtmp: {
482
482
  listen: string;
483
483
  };
484
- streams: Record<string, string | string[] | null>;
485
484
  ffmpeg: Record<string, string> & {
486
485
  rtsp: string;
487
486
  bin: string;
@@ -510,6 +509,7 @@ export declare const patchGo2RtcSchema: zod.ZodObject<{
510
509
  srtp: {
511
510
  listen: string;
512
511
  };
512
+ streams?: Record<string, string | string[] | null> | undefined;
513
513
  homekit?: Record<string, {
514
514
  pin?: number | undefined;
515
515
  name?: string | undefined;
@@ -1,6 +1,5 @@
1
1
  import type { DBCamera, Camera } from '../database/types';
2
2
  import { type CameraExtension } from '../../plugins/types';
3
- import type { PrebufferType } from '../../camera/types';
4
3
  type DeepPartial<T> = T extends object ? {
5
4
  [P in keyof T]?: DeepPartial<T[P]>;
6
5
  } : T;
@@ -13,7 +12,8 @@ export default class CamerasService {
13
12
  private pluginsService;
14
13
  constructor();
15
14
  createCamera(cameraData: DBCamera): Promise<DBCamera>;
16
- createCameraSource(cameraName: string, sourceName: string, address: string | null, type: PrebufferType): Promise<string>;
15
+ createCameraSource(cameraName: string, sourceName: string, address: string): Promise<void>;
16
+ resetCameraSource(cameraName: string, sourceName: string): Promise<void>;
17
17
  createTransformedCamera(cameraData: DBCamera): Promise<Camera>;
18
18
  list(): Promise<DBCamera[]>;
19
19
  listTransformed(): Promise<Camera[]>;
@@ -38,6 +38,9 @@ export default class CamerasService {
38
38
  removeByPluginId(pluginId: string): Promise<void>;
39
39
  removeByPluginIdAndName(cameraname: string, pluginId: string): Promise<void>;
40
40
  removeAll(): Promise<void>;
41
- private transformCamera;
41
+ transformCamera(camera: DBCamera): Camera;
42
+ private addCameraSources;
43
+ private removeCameraSources;
44
+ private sourceIsPrebuffering;
42
45
  }
43
46
  export {};
@@ -2,7 +2,7 @@ import { Observable } from 'rxjs';
2
2
  import { StreamingSession } from './streaming/streaming-session';
3
3
  import type { Camera, CameraInput, CameraPublicProperties } from '../api/database/types';
4
4
  import type { ProxyServer } from '../proxy';
5
- import type { CameraDevice, BaseLogger, Input } from './types';
5
+ import type { CameraDevice, BaseLogger } from './types';
6
6
  import type { IceServer } from '../services/config/types';
7
7
  import type { StateValues, OnSetEvent, LightState, MotionState, AudioState, ObjectState, DoorbellState, SirenState, StreamingConnectionOptions, FfmpegOptions, PrebufferType } from './types';
8
8
  export declare class CameraDeviceHub implements CameraDevice {
@@ -34,10 +34,12 @@ export declare class CameraDeviceHub implements CameraDevice {
34
34
  get hasAudioDetector(): boolean;
35
35
  get hasObjectDetector(): boolean;
36
36
  get hasPtz(): boolean;
37
- get sources(): Input[];
37
+ get sources(): CameraInput[];
38
38
  constructor(camera: Camera, logger?: BaseLogger, proxy?: ProxyServer);
39
- snapshot(sourceName?: string): Promise<ArrayBuffer>;
40
- setPrebufferSource(sourceName: string, address: string | null, type: PrebufferType, fromCamera?: boolean): Promise<void>;
39
+ snapshot(sourceName?: string, prebuffer?: boolean): Promise<ArrayBuffer>;
40
+ setPrebufferSource(sourceName: string, address: string, type: PrebufferType): Promise<void>;
41
+ removePrebufferSource(sourceName: string, type: 'recording' | 'stream'): Promise<void>;
42
+ removePrebufferSources(): Promise<void>;
41
43
  getFfmpegPath(): Promise<string>;
42
44
  getIceServers(): Promise<IceServer[]>;
43
45
  getValue<T extends keyof StateValues>(stateName: T): StateValues[T];
@@ -47,7 +47,7 @@ export interface CameraDevice {
47
47
  hasPtz: boolean;
48
48
  type: string;
49
49
  model: string;
50
- sources: Input[];
50
+ sources: CameraInput[];
51
51
  logger: BaseLogger;
52
52
  onLightDetected: Observable<LightState>;
53
53
  onMotionDetected: Observable<MotionState>;
@@ -55,8 +55,10 @@ export interface CameraDevice {
55
55
  onObjectDetected: Observable<ObjectState>;
56
56
  onDoorbellPressed: Observable<DoorbellState>;
57
57
  onSirenDetected: Observable<SirenState>;
58
- snapshot(sourceName?: string): Promise<ArrayBuffer>;
59
- setPrebufferSource(sourceName: string, address: string | null, type: 'recording' | 'stream'): Promise<void>;
58
+ snapshot(sourceName?: string, prebuffer?: boolean): Promise<ArrayBuffer>;
59
+ setPrebufferSource(sourceName: string, address: string, type: 'recording' | 'stream'): Promise<void>;
60
+ removePrebufferSource(sourceName: string, type: 'recording' | 'stream'): Promise<void>;
61
+ removePrebufferSources(): Promise<void>;
60
62
  getFfmpegPath(): Promise<string>;
61
63
  getIceServers(): Promise<RTCIceServer[]>;
62
64
  getValue<T extends keyof StateValues>(stateName: T): StateValue<T>;
@@ -104,10 +106,6 @@ export interface CameraConfig {
104
106
  model?: string;
105
107
  sources: CameraInputSettings[];
106
108
  }
107
- export interface Input extends CameraInput {
108
- readonly isStreamPrebuffering?: boolean;
109
- readonly isRecordingPrebuffering?: boolean;
110
- }
111
109
  export interface BaseState {
112
110
  timestamp: number;
113
111
  lastTriggered: number;
@@ -1,11 +1,11 @@
1
1
  import type { API } from '../api';
2
2
  import type { PluginJsonSchemaForm, PluginJsonSchema, CameraStorage as CameraStorageMethods, SchemaConfig } from './types';
3
3
  export declare class CameraStorage implements CameraStorageMethods {
4
- schema: PluginJsonSchemaForm;
5
4
  private cameraId;
6
5
  private instance;
7
6
  private api;
8
7
  private db;
8
+ private _schema;
9
9
  private _values;
10
10
  constructor(api: API, instance: any, cameraId: string, schema?: PluginJsonSchemaForm);
11
11
  /**
@@ -13,6 +13,16 @@ export declare class CameraStorage implements CameraStorageMethods {
13
13
  * This will load the configuration from the database.
14
14
  */
15
15
  initializeStorage(): Promise<void>;
16
+ /**
17
+ * Get a value from the configuration by its key/path.
18
+ * If the schema has an onGet function, the onGet function will be called.
19
+ * If the onGet functions is undefined, the value from the configuration will be returned.
20
+ * If the schema has a default value, and the configuration value is undefined, the default value will be returned.
21
+ *
22
+ * @param path - The path to the configuration value.
23
+ * @returns The value from the configuration.
24
+ */
25
+ getValue<T = string>(path: string): Promise<T> | undefined;
16
26
  /**
17
27
  * Set a new value for a given key/path in the configuration.
18
28
  * If the schema of the value has an onSet function, and the value has changed, the onSet function will be called.
@@ -23,15 +33,12 @@ export declare class CameraStorage implements CameraStorageMethods {
23
33
  */
24
34
  setValue<T = string>(path: string, newValue: T): Promise<void>;
25
35
  /**
26
- * Get a value from the configuration by its key/path.
27
- * If the schema has an onGet function, the onGet function will be called.
28
- * If the onGet functions is undefined, the value from the configuration will be returned.
29
- * If the schema has a default value, and the configuration value is undefined, the default value will be returned.
36
+ * Check if a value exists by its config path/key.
30
37
  *
31
- * @param path - The path to the configuration value.
32
- * @returns The value from the configuration.
38
+ * @param path - The path to the value to check.
39
+ * @returns True if the value exists, false otherwise.
33
40
  */
34
- getValue<T = string>(path: string): T | Promise<T> | undefined;
41
+ hasValue(path: string): boolean;
35
42
  /**
36
43
  * Get the root schema and configuration.
37
44
  * This will also call the onGet functions for the schema.
@@ -73,6 +80,13 @@ export declare class CameraStorage implements CameraStorageMethods {
73
80
  * @param schema - The new schema to set.
74
81
  */
75
82
  changeSchema(path: string, newSchema: Partial<PluginJsonSchema>): Promise<void>;
83
+ /**
84
+ * Get a schema by its config path/key.
85
+ *
86
+ * @param path - The path to the schema to get.
87
+ * @returns The schema.
88
+ */
89
+ getSchema<T>(path: string): T | undefined;
76
90
  /**
77
91
  * Check if a schema exists by its config path/key.
78
92
  *
@@ -80,13 +94,6 @@ export declare class CameraStorage implements CameraStorageMethods {
80
94
  * @returns True if the schema exists, false otherwise.
81
95
  */
82
96
  hasSchema(path: string): boolean;
83
- /**
84
- * Check if a value exists by its config path/key.
85
- *
86
- * @param path - The path to the value to check.
87
- * @returns True if the value exists, false otherwise.
88
- */
89
- hasValue(path: string): boolean;
90
97
  private resolveOnGetFunctions;
91
98
  private resolveOnGetFunctionsForObject;
92
99
  private resolveOnGetFunctionsForSchema;
@@ -15,6 +15,8 @@ export declare class CameraDeviceClientProxy extends CameraDeviceHub {
15
15
  private close?;
16
16
  constructor(camera: Camera, logger: BaseLogger, pluginId: string, pluginName: string, reqServerAddress: string, pubServerAddress: string, serverPublicKey: string);
17
17
  setPrebufferSource(sourceName: string, address: string | null, type: PrebufferType): Promise<void>;
18
+ removePrebufferSource(sourceName: string, type: 'recording' | 'stream'): Promise<void>;
19
+ removePrebufferSources(): Promise<void>;
18
20
  getFfmpegPath(): Promise<string>;
19
21
  getIceServers(): Promise<IceServer[]>;
20
22
  updateState<T extends keyof StateValues>(stateName: T, eventData: OnSetEvent<T>): Promise<void>;
@@ -1,10 +1,12 @@
1
1
  import { Request } from 'zeromq';
2
+ import type { BaseLogger } from '../../camera/types';
2
3
  export declare class ClientMessageQueue {
4
+ private logger;
3
5
  private requestClient;
4
6
  private queue;
5
7
  private isProcessing;
6
8
  private pendingResponses;
7
- constructor(requestClient: Request);
9
+ constructor(requestClient: Request, logger: BaseLogger);
8
10
  enqueue(message: any, timeout?: number): Promise<any>;
9
11
  private processQueue;
10
12
  private listenToReplies;
@@ -20,7 +20,4 @@ export declare class ProxyServer {
20
20
  close(): Promise<void>;
21
21
  sendMessage(item: QueueItem): Promise<void>;
22
22
  publishEvent<K extends keyof ProxyEvents>(targetId: TargetID, type: K, data: ProxyEvents[K]): Promise<void>;
23
- private listenToRequestMessages;
24
- private listenToRouterMessages;
25
- private isProxyMessage;
26
23
  }
@@ -13,16 +13,27 @@ export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
13
13
  constructor(proxyServer: ProxyServer);
14
14
  snapshot(data: {
15
15
  sourceName: string;
16
+ prebuffer?: boolean;
16
17
  cameraId: string;
17
18
  pluginId: string;
18
19
  }): Promise<ArrayBuffer>;
19
20
  setPrebufferSource(data: {
20
21
  sourceName: string;
21
- address: string | null;
22
+ address: string;
22
23
  type: PrebufferType;
23
24
  cameraId: string;
24
25
  pluginId: string;
25
26
  }): Promise<void>;
27
+ removePrebufferSource(data: {
28
+ sourceName: string;
29
+ type: PrebufferType;
30
+ cameraId: string;
31
+ pluginId: string;
32
+ }): Promise<void>;
33
+ removePrebufferSources(data: {
34
+ cameraId: string;
35
+ pluginId: string;
36
+ }): Promise<void>;
26
37
  getFffmpegPath(): string;
27
38
  getIceServers(): IceServer[];
28
39
  updateState<T extends keyof StateValues>(data: {
@@ -1,15 +1,17 @@
1
- import type { Reply, Router } from 'zeromq';
2
1
  import type { QueueItem } from './types';
2
+ import type { ProxyServer } from '.';
3
3
  export declare class MessageQueue {
4
+ private logger;
4
5
  private queue;
5
6
  private isProcessing;
6
7
  private pendingResponses;
8
+ private proxyServer;
7
9
  private reqServer;
8
10
  private router;
9
- constructor(reqServer: Reply, router: Router);
11
+ constructor(proxyServer: ProxyServer);
10
12
  addToQueue(item: QueueItem): Promise<void>;
11
- receiveResponse(requestId: string, response: any): void;
12
- receiveError(requestId: string, error: Error): void;
13
13
  private processQueue;
14
- private sendMessage;
14
+ private listenToRouterMessages;
15
+ private listenToRequestMessages;
16
+ private isProxyMessage;
15
17
  }
@@ -18,6 +18,7 @@ export interface QueueItem {
18
18
  targetId: string;
19
19
  requestId: string;
20
20
  message: any;
21
+ fn: string;
21
22
  timeout?: number;
22
23
  onResponse?: (response: any) => void;
23
24
  onError?: (error: Error) => void;
@@ -191,16 +192,27 @@ export interface CameraDeviceProxyMessageStructure {
191
192
  export interface CameraDeviceProxyMethods {
192
193
  snapshot(data: {
193
194
  sourceName: string;
195
+ prebuffer?: boolean;
194
196
  cameraId: string;
195
197
  pluginId: string;
196
198
  }): Promise<ArrayBuffer>;
197
199
  setPrebufferSource(data: {
198
200
  sourceName: string;
199
- address: string | null;
201
+ address: string;
200
202
  type: PrebufferType;
201
203
  cameraId: string;
202
204
  pluginId: string;
203
205
  }): Promise<void>;
206
+ removePrebufferSource(data: {
207
+ sourceName: string;
208
+ type: PrebufferType;
209
+ cameraId: string;
210
+ pluginId: string;
211
+ }): Promise<void>;
212
+ removePrebufferSources(data: {
213
+ cameraId: string;
214
+ pluginId: string;
215
+ }): Promise<void>;
204
216
  getFffmpegPath(data: {
205
217
  cameraId: string;
206
218
  pluginId: string;
@@ -47,7 +47,8 @@ export declare class ConfigService {
47
47
  constructor();
48
48
  read(): void;
49
49
  writeConfig(newConfig?: IConfig): void;
50
- writeGo2RtcConfig(newConfig?: Go2RtcConfig): void;
50
+ writeGo2RtcConfigFile(newConfig?: Go2RtcConfig): void;
51
+ writeGo2RtcConfigApi(newConfig?: Go2RtcConfig): Promise<void>;
51
52
  mergeGo2RtcConfig(): Promise<void>;
52
53
  private defaultConfig;
53
54
  private defaultGo2RtcConfig;
@@ -61,8 +61,8 @@ export interface Go2RtcConfig {
61
61
  srtp: SRTP;
62
62
  rtmp: RTMP;
63
63
  webrtc: Webrtc;
64
- streams: Partial<Streams>;
65
64
  ffmpeg: Ffmpeg;
65
+ streams?: Partial<Streams>;
66
66
  homekit?: Partial<HomeKit>;
67
67
  hass?: Partial<Hass>;
68
68
  webtorrent?: Partial<Webtorrent>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camera.ui/browser",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "camera.ui browser client",
5
5
  "author": "seydx (https://github.com/seydx/camera.ui)",
6
6
  "main": "./dist/bundle.js",