@camstack/addon-provider-onvif 0.1.7 → 0.1.9

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.
@@ -0,0 +1,14 @@
1
+ import { ICamstackAddon, IConfigurable, AddonManifest, AddonContext, CapabilityProviderMap, ConfigUISchema } from '@camstack/types';
2
+
3
+ declare class OnvifProviderAddon implements ICamstackAddon, IConfigurable {
4
+ readonly manifest: AddonManifest;
5
+ private provider;
6
+ initialize(context: AddonContext): Promise<void>;
7
+ shutdown(): Promise<void>;
8
+ getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
9
+ getConfigSchema(): ConfigUISchema;
10
+ getConfig(): Record<string, unknown>;
11
+ onConfigChange(_config: Record<string, unknown>): Promise<void>;
12
+ }
13
+
14
+ export { OnvifProviderAddon };
@@ -0,0 +1,14 @@
1
+ import { ICamstackAddon, IConfigurable, AddonManifest, AddonContext, CapabilityProviderMap, ConfigUISchema } from '@camstack/types';
2
+
3
+ declare class OnvifProviderAddon implements ICamstackAddon, IConfigurable {
4
+ readonly manifest: AddonManifest;
5
+ private provider;
6
+ initialize(context: AddonContext): Promise<void>;
7
+ shutdown(): Promise<void>;
8
+ getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
9
+ getConfigSchema(): ConfigUISchema;
10
+ getConfig(): Record<string, unknown>;
11
+ onConfigChange(_config: Record<string, unknown>): Promise<void>;
12
+ }
13
+
14
+ export { OnvifProviderAddon };
@@ -0,0 +1,169 @@
1
+ export { OnvifProviderAddon } from './addon.mjs';
2
+ import { IScopedLogger, IDevice, DeviceType, DeviceCapabilityName, CamstackContext, IDeviceCapability, DeviceState, DeviceMetadata, IDeviceProvider, ProviderStatus, DiscoveredDevice, LiveEvent } from '@camstack/types';
3
+
4
+ declare class OnvifClient {
5
+ private readonly host;
6
+ private readonly port;
7
+ private readonly username;
8
+ private readonly password;
9
+ private readonly logger;
10
+ private cam;
11
+ constructor(host: string, port: number, username: string, password: string, logger: IScopedLogger);
12
+ /** Connect to the camera */
13
+ connect(): Promise<void>;
14
+ /** Get device info */
15
+ getDeviceInfo(): Promise<{
16
+ manufacturer: string;
17
+ model: string;
18
+ firmwareVersion: string;
19
+ serialNumber: string;
20
+ }>;
21
+ /** Get RTSP stream URI */
22
+ getStreamUri(profileToken?: string): Promise<string>;
23
+ /** Get available media profiles */
24
+ getProfiles(): Promise<Array<{
25
+ token: string;
26
+ name: string;
27
+ videoWidth?: number;
28
+ videoHeight?: number;
29
+ }>>;
30
+ /** Get snapshot URI */
31
+ getSnapshotUri(profileToken?: string): Promise<string>;
32
+ /** Check if PTZ is supported */
33
+ hasPtz(): boolean;
34
+ /** PTZ move (continuous) */
35
+ ptzMove(options: {
36
+ x?: number;
37
+ y?: number;
38
+ zoom?: number;
39
+ speed?: number;
40
+ }): Promise<void>;
41
+ /** PTZ stop */
42
+ ptzStop(): Promise<void>;
43
+ /** PTZ absolute move */
44
+ ptzAbsoluteMove(options: {
45
+ x: number;
46
+ y: number;
47
+ zoom: number;
48
+ }): Promise<void>;
49
+ /** Get PTZ presets */
50
+ getPtzPresets(): Promise<Array<{
51
+ token: string;
52
+ name: string;
53
+ }>>;
54
+ /** Go to PTZ preset */
55
+ gotoPreset(presetToken: string): Promise<void>;
56
+ disconnect(): void;
57
+ }
58
+
59
+ interface OnvifDeviceConfig {
60
+ readonly cameraId: string;
61
+ readonly cameraName: string;
62
+ readonly providerId: string;
63
+ readonly rtspUrl: string;
64
+ readonly subStreamUrl?: string;
65
+ readonly snapshotUrl?: string;
66
+ readonly hasPtz: boolean;
67
+ readonly profiles: ReadonlyArray<{
68
+ token: string;
69
+ name: string;
70
+ videoWidth?: number;
71
+ videoHeight?: number;
72
+ }>;
73
+ readonly manufacturer?: string;
74
+ readonly model?: string;
75
+ readonly firmware?: string;
76
+ }
77
+ declare class OnvifDevice implements IDevice {
78
+ private readonly client;
79
+ private readonly config;
80
+ readonly id: string;
81
+ readonly name: string;
82
+ readonly providerId: string;
83
+ readonly type: DeviceType;
84
+ readonly capabilities: DeviceCapabilityName[];
85
+ readonly ctx: CamstackContext;
86
+ private readonly capabilityMap;
87
+ constructor(client: OnvifClient, config: OnvifDeviceConfig, ctx: CamstackContext);
88
+ getCapability<T extends IDeviceCapability>(cap: DeviceCapabilityName): T | null;
89
+ hasCapability(cap: DeviceCapabilityName): boolean;
90
+ getState(): DeviceState;
91
+ getMetadata(): DeviceMetadata;
92
+ private createCamera;
93
+ private createPtz;
94
+ }
95
+
96
+ interface OnvifProviderConfig {
97
+ readonly id: string;
98
+ readonly name: string;
99
+ /** Discovery settings */
100
+ readonly discovery?: {
101
+ readonly enabled: boolean;
102
+ readonly timeout: number;
103
+ };
104
+ /** Manually added cameras (in addition to discovered) */
105
+ readonly cameras?: readonly OnvifCameraConfig[];
106
+ /** Default credentials for discovered cameras */
107
+ readonly defaultUsername?: string;
108
+ readonly defaultPassword?: string;
109
+ }
110
+ interface OnvifCameraConfig {
111
+ readonly id: string;
112
+ readonly name: string;
113
+ readonly host: string;
114
+ readonly port?: number;
115
+ readonly username?: string;
116
+ readonly password?: string;
117
+ /** Override RTSP URL (skip ONVIF stream URI query) */
118
+ readonly rtspUrl?: string;
119
+ }
120
+ interface DiscoveredOnvifCamera {
121
+ readonly host: string;
122
+ readonly port: number;
123
+ readonly name?: string;
124
+ readonly manufacturer?: string;
125
+ readonly model?: string;
126
+ readonly firmwareVersion?: string;
127
+ readonly hardwareId?: string;
128
+ readonly scopes?: readonly string[];
129
+ }
130
+
131
+ declare class OnvifProvider implements IDeviceProvider {
132
+ private readonly config;
133
+ readonly id: string;
134
+ readonly type = "onvif";
135
+ readonly name: string;
136
+ readonly discoveryMode: 'both';
137
+ readonly ctx: CamstackContext;
138
+ private devices;
139
+ private readonly clients;
140
+ private lastDiscoveredCameras;
141
+ constructor(config: OnvifProviderConfig, ctx: CamstackContext);
142
+ start(): Promise<void>;
143
+ private addCamera;
144
+ private loadAdoptedCameras;
145
+ stop(): Promise<void>;
146
+ getStatus(): ProviderStatus;
147
+ discoverDevices(): Promise<DiscoveredDevice[]>;
148
+ adoptDevice(externalId: string, config?: Record<string, unknown>): Promise<IDevice>;
149
+ private persistAdoptedCamera;
150
+ getDevices(): IDevice[];
151
+ getDeviceConfigSchema(): {
152
+ id: string;
153
+ name: string;
154
+ host: string;
155
+ port: string;
156
+ username: string;
157
+ password: string;
158
+ rtspUrl: string;
159
+ };
160
+ subscribeLiveEvents(_callback: (event: LiveEvent) => void): () => void;
161
+ }
162
+
163
+ /**
164
+ * Discovers ONVIF cameras on the local network via WS-Discovery.
165
+ * Returns a list of found cameras after the given timeout.
166
+ */
167
+ declare function discoverOnvifCameras(timeout?: number): Promise<readonly DiscoveredOnvifCamera[]>;
168
+
169
+ export { type DiscoveredOnvifCamera, type OnvifCameraConfig, OnvifClient, OnvifDevice, OnvifProvider, type OnvifProviderConfig, discoverOnvifCameras };
@@ -0,0 +1,169 @@
1
+ export { OnvifProviderAddon } from './addon.js';
2
+ import { IScopedLogger, IDevice, DeviceType, DeviceCapabilityName, CamstackContext, IDeviceCapability, DeviceState, DeviceMetadata, IDeviceProvider, ProviderStatus, DiscoveredDevice, LiveEvent } from '@camstack/types';
3
+
4
+ declare class OnvifClient {
5
+ private readonly host;
6
+ private readonly port;
7
+ private readonly username;
8
+ private readonly password;
9
+ private readonly logger;
10
+ private cam;
11
+ constructor(host: string, port: number, username: string, password: string, logger: IScopedLogger);
12
+ /** Connect to the camera */
13
+ connect(): Promise<void>;
14
+ /** Get device info */
15
+ getDeviceInfo(): Promise<{
16
+ manufacturer: string;
17
+ model: string;
18
+ firmwareVersion: string;
19
+ serialNumber: string;
20
+ }>;
21
+ /** Get RTSP stream URI */
22
+ getStreamUri(profileToken?: string): Promise<string>;
23
+ /** Get available media profiles */
24
+ getProfiles(): Promise<Array<{
25
+ token: string;
26
+ name: string;
27
+ videoWidth?: number;
28
+ videoHeight?: number;
29
+ }>>;
30
+ /** Get snapshot URI */
31
+ getSnapshotUri(profileToken?: string): Promise<string>;
32
+ /** Check if PTZ is supported */
33
+ hasPtz(): boolean;
34
+ /** PTZ move (continuous) */
35
+ ptzMove(options: {
36
+ x?: number;
37
+ y?: number;
38
+ zoom?: number;
39
+ speed?: number;
40
+ }): Promise<void>;
41
+ /** PTZ stop */
42
+ ptzStop(): Promise<void>;
43
+ /** PTZ absolute move */
44
+ ptzAbsoluteMove(options: {
45
+ x: number;
46
+ y: number;
47
+ zoom: number;
48
+ }): Promise<void>;
49
+ /** Get PTZ presets */
50
+ getPtzPresets(): Promise<Array<{
51
+ token: string;
52
+ name: string;
53
+ }>>;
54
+ /** Go to PTZ preset */
55
+ gotoPreset(presetToken: string): Promise<void>;
56
+ disconnect(): void;
57
+ }
58
+
59
+ interface OnvifDeviceConfig {
60
+ readonly cameraId: string;
61
+ readonly cameraName: string;
62
+ readonly providerId: string;
63
+ readonly rtspUrl: string;
64
+ readonly subStreamUrl?: string;
65
+ readonly snapshotUrl?: string;
66
+ readonly hasPtz: boolean;
67
+ readonly profiles: ReadonlyArray<{
68
+ token: string;
69
+ name: string;
70
+ videoWidth?: number;
71
+ videoHeight?: number;
72
+ }>;
73
+ readonly manufacturer?: string;
74
+ readonly model?: string;
75
+ readonly firmware?: string;
76
+ }
77
+ declare class OnvifDevice implements IDevice {
78
+ private readonly client;
79
+ private readonly config;
80
+ readonly id: string;
81
+ readonly name: string;
82
+ readonly providerId: string;
83
+ readonly type: DeviceType;
84
+ readonly capabilities: DeviceCapabilityName[];
85
+ readonly ctx: CamstackContext;
86
+ private readonly capabilityMap;
87
+ constructor(client: OnvifClient, config: OnvifDeviceConfig, ctx: CamstackContext);
88
+ getCapability<T extends IDeviceCapability>(cap: DeviceCapabilityName): T | null;
89
+ hasCapability(cap: DeviceCapabilityName): boolean;
90
+ getState(): DeviceState;
91
+ getMetadata(): DeviceMetadata;
92
+ private createCamera;
93
+ private createPtz;
94
+ }
95
+
96
+ interface OnvifProviderConfig {
97
+ readonly id: string;
98
+ readonly name: string;
99
+ /** Discovery settings */
100
+ readonly discovery?: {
101
+ readonly enabled: boolean;
102
+ readonly timeout: number;
103
+ };
104
+ /** Manually added cameras (in addition to discovered) */
105
+ readonly cameras?: readonly OnvifCameraConfig[];
106
+ /** Default credentials for discovered cameras */
107
+ readonly defaultUsername?: string;
108
+ readonly defaultPassword?: string;
109
+ }
110
+ interface OnvifCameraConfig {
111
+ readonly id: string;
112
+ readonly name: string;
113
+ readonly host: string;
114
+ readonly port?: number;
115
+ readonly username?: string;
116
+ readonly password?: string;
117
+ /** Override RTSP URL (skip ONVIF stream URI query) */
118
+ readonly rtspUrl?: string;
119
+ }
120
+ interface DiscoveredOnvifCamera {
121
+ readonly host: string;
122
+ readonly port: number;
123
+ readonly name?: string;
124
+ readonly manufacturer?: string;
125
+ readonly model?: string;
126
+ readonly firmwareVersion?: string;
127
+ readonly hardwareId?: string;
128
+ readonly scopes?: readonly string[];
129
+ }
130
+
131
+ declare class OnvifProvider implements IDeviceProvider {
132
+ private readonly config;
133
+ readonly id: string;
134
+ readonly type = "onvif";
135
+ readonly name: string;
136
+ readonly discoveryMode: 'both';
137
+ readonly ctx: CamstackContext;
138
+ private devices;
139
+ private readonly clients;
140
+ private lastDiscoveredCameras;
141
+ constructor(config: OnvifProviderConfig, ctx: CamstackContext);
142
+ start(): Promise<void>;
143
+ private addCamera;
144
+ private loadAdoptedCameras;
145
+ stop(): Promise<void>;
146
+ getStatus(): ProviderStatus;
147
+ discoverDevices(): Promise<DiscoveredDevice[]>;
148
+ adoptDevice(externalId: string, config?: Record<string, unknown>): Promise<IDevice>;
149
+ private persistAdoptedCamera;
150
+ getDevices(): IDevice[];
151
+ getDeviceConfigSchema(): {
152
+ id: string;
153
+ name: string;
154
+ host: string;
155
+ port: string;
156
+ username: string;
157
+ password: string;
158
+ rtspUrl: string;
159
+ };
160
+ subscribeLiveEvents(_callback: (event: LiveEvent) => void): () => void;
161
+ }
162
+
163
+ /**
164
+ * Discovers ONVIF cameras on the local network via WS-Discovery.
165
+ * Returns a list of found cameras after the given timeout.
166
+ */
167
+ declare function discoverOnvifCameras(timeout?: number): Promise<readonly DiscoveredOnvifCamera[]>;
168
+
169
+ export { type DiscoveredOnvifCamera, type OnvifCameraConfig, OnvifClient, OnvifDevice, OnvifProvider, type OnvifProviderConfig, discoverOnvifCameras };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-onvif",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "ONVIF camera device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",
@@ -21,9 +21,9 @@
21
21
  "types": "./dist/index.d.ts",
22
22
  "exports": {
23
23
  ".": {
24
+ "types": "./dist/index.d.ts",
24
25
  "import": "./dist/index.mjs",
25
- "require": "./dist/index.js",
26
- "types": "./dist/index.d.ts"
26
+ "require": "./dist/index.js"
27
27
  },
28
28
  "./package.json": "./package.json"
29
29
  },