camstreamerlib 3.5.2 → 4.0.0-beta.2
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/CamOverlayAPI.d.ts +11 -28
- package/CamOverlayAPI.js +116 -138
- package/CamOverlayDrawingAPI.js +26 -18
- package/CamOverlayPainter/Frame.js +167 -182
- package/CamOverlayPainter/Painter.js +80 -101
- package/CamOverlayPainter/ResourceManager.js +31 -46
- package/CamScripterAPI.d.ts +19 -0
- package/CamScripterAPI.js +66 -0
- package/CamScripterAPICameraEventsGenerator.js +22 -16
- package/CamStreamerAPI.d.ts +5 -27
- package/CamStreamerAPI.js +45 -71
- package/CamSwitcherAPI.d.ts +38 -71
- package/CamSwitcherAPI.js +329 -91
- package/CamSwitcherEvents.d.ts +15 -33
- package/CamSwitcherEvents.js +53 -97
- package/CreatePackage.js +5 -7
- package/README.md +3 -1
- package/VapixAPI.d.ts +66 -0
- package/VapixAPI.js +454 -0
- package/VapixEvents.js +18 -16
- package/errors/errors.d.ts +34 -0
- package/errors/errors.js +66 -0
- package/events/AxisCameraStationEvents.js +29 -42
- package/events/GenetecAgent.d.ts +14 -15
- package/events/GenetecAgent.js +81 -100
- package/internal/Digest.js +5 -11
- package/internal/ProxyClient.d.ts +11 -0
- package/internal/ProxyClient.js +40 -0
- package/internal/common.d.ts +19 -4
- package/internal/common.js +11 -26
- package/internal/constants.d.ts +1 -0
- package/internal/constants.js +1 -0
- package/internal/transformers.d.ts +5 -0
- package/internal/transformers.js +25 -0
- package/internal/utils.d.ts +11 -0
- package/internal/utils.js +34 -0
- package/internal/versionCompare.d.ts +6 -0
- package/internal/versionCompare.js +44 -0
- package/node/DefaultClient.d.ts +15 -0
- package/node/DefaultClient.js +50 -0
- package/{internal → node}/HttpRequestSender.d.ts +2 -2
- package/node/HttpRequestSender.js +85 -0
- package/{HttpServer.d.ts → node/HttpServer.d.ts} +1 -1
- package/{HttpServer.js → node/HttpServer.js} +22 -24
- package/{internal → node}/WsClient.d.ts +1 -1
- package/{internal → node}/WsClient.js +32 -39
- package/node/WsEventClient.d.ts +13 -0
- package/node/WsEventClient.js +18 -0
- package/package.json +7 -3
- package/types/CamOverlayAPI.d.ts +188 -0
- package/types/CamOverlayAPI.js +44 -0
- package/types/CamScripterAPI.d.ts +67 -0
- package/types/CamScripterAPI.js +17 -0
- package/types/CamStreamerAPI.d.ts +139 -0
- package/types/CamStreamerAPI.js +25 -0
- package/types/CamSwitcherAPI.d.ts +814 -0
- package/types/CamSwitcherAPI.js +134 -0
- package/types/CamswitcherEvents.d.ts +491 -0
- package/types/CamswitcherEvents.js +59 -0
- package/types/VapixAPI.d.ts +1704 -0
- package/types/VapixAPI.js +129 -0
- package/types/common.d.ts +37 -0
- package/types/common.js +11 -0
- package/web/DefaultClient.d.ts +6 -0
- package/web/DefaultClient.js +16 -0
- package/web/WsClient.d.ts +13 -0
- package/web/WsClient.js +58 -0
- package/CameraVapix.d.ts +0 -98
- package/CameraVapix.js +0 -441
- package/DefaultAgent.d.ts +0 -15
- package/DefaultAgent.js +0 -68
- package/internal/HttpRequestSender.js +0 -117
package/CamOverlayAPI.d.ts
CHANGED
|
@@ -1,36 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
field_name: string;
|
|
6
|
-
text: string;
|
|
7
|
-
color?: string;
|
|
8
|
-
};
|
|
9
|
-
export type TService = Record<string, any>;
|
|
10
|
-
export type TServiceList = {
|
|
11
|
-
services: TService[];
|
|
12
|
-
};
|
|
13
|
-
export type TNetworkCameraList = {
|
|
14
|
-
name: string;
|
|
15
|
-
ip: string;
|
|
16
|
-
}[];
|
|
17
|
-
export type TImage = {
|
|
18
|
-
name: string;
|
|
19
|
-
path: string;
|
|
20
|
-
storage: string;
|
|
21
|
-
};
|
|
22
|
-
export declare enum ImageType {
|
|
23
|
-
PNG = 0,
|
|
24
|
-
JPEG = 1
|
|
25
|
-
}
|
|
26
|
-
export type TCoordinates = 'top_left' | 'top_right' | 'top' | 'bottom_left' | 'bottom_right' | 'bottom' | 'left' | 'right' | 'center' | '';
|
|
2
|
+
import { IClient } from './internal/common';
|
|
3
|
+
import { CamOverlayOptions, ImageType, TCoordinates, TField, TFile, TFileList, TFileType, TService, TServiceList, TStorage } from './types/CamOverlayAPI';
|
|
4
|
+
import { TNetworkCamera } from './types/common';
|
|
27
5
|
export declare class CamOverlayAPI {
|
|
28
6
|
private client;
|
|
29
7
|
constructor(options?: CamOverlayOptions | IClient);
|
|
30
8
|
checkCameraTime(): Promise<boolean>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
9
|
+
getNetworkCameraList(): Promise<TNetworkCamera[]>;
|
|
10
|
+
wsAutoratization(): Promise<string>;
|
|
11
|
+
getMjpegStreamImage(mjpegUrl: string): Promise<Blob>;
|
|
12
|
+
listFiles(fileType: TFileType): Promise<TFileList>;
|
|
13
|
+
uploadFile(fileType: TFileType, file: Blob, fileName: string): Promise<void>;
|
|
14
|
+
removeFile(fileType: TFileType, file: TFile): Promise<void>;
|
|
15
|
+
getFileStorage(fileType: TFileType): Promise<TStorage>;
|
|
34
16
|
updateInfoticker(serviceID: number, text: string): Promise<void>;
|
|
35
17
|
setEnabled(serviceID: number, enabled: boolean): Promise<void>;
|
|
36
18
|
isEnabled(serviceID: number): Promise<boolean>;
|
|
@@ -45,4 +27,5 @@ export declare class CamOverlayAPI {
|
|
|
45
27
|
private promiseCGUpdate;
|
|
46
28
|
private get;
|
|
47
29
|
private post;
|
|
30
|
+
private parseBlobResponse;
|
|
48
31
|
}
|
package/CamOverlayAPI.js
CHANGED
|
@@ -1,122 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CamOverlayAPI = exports.ImageType = void 0;
|
|
13
|
-
const common_1 = require("./internal/common");
|
|
14
|
-
const DefaultAgent_1 = require("./DefaultAgent");
|
|
15
|
-
var ImageType;
|
|
16
|
-
(function (ImageType) {
|
|
17
|
-
ImageType[ImageType["PNG"] = 0] = "PNG";
|
|
18
|
-
ImageType[ImageType["JPEG"] = 1] = "JPEG";
|
|
19
|
-
})(ImageType || (exports.ImageType = ImageType = {}));
|
|
20
|
-
class CamOverlayAPI {
|
|
1
|
+
import { isClient, responseStringify } from './internal/common';
|
|
2
|
+
import { DefaultClient } from './node/DefaultClient';
|
|
3
|
+
import { fileListSchema, ImageType, serviceSchema, storageSchema, } from './types/CamOverlayAPI';
|
|
4
|
+
import { ParsingBlobError, ServiceNotFoundError } from './errors/errors';
|
|
5
|
+
import { networkCameraListSchema } from './types/common';
|
|
6
|
+
export class CamOverlayAPI {
|
|
7
|
+
client;
|
|
21
8
|
constructor(options = {}) {
|
|
22
|
-
if (
|
|
9
|
+
if (isClient(options)) {
|
|
23
10
|
this.client = options;
|
|
24
11
|
}
|
|
25
12
|
else {
|
|
26
|
-
this.client = new
|
|
13
|
+
this.client = new DefaultClient(options);
|
|
27
14
|
}
|
|
28
15
|
}
|
|
29
|
-
checkCameraTime() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const res = yield this.client.get(path);
|
|
78
|
-
if (res.ok) {
|
|
79
|
-
const data = JSON.parse(yield res.text());
|
|
80
|
-
for (const service of data.services) {
|
|
81
|
-
if (service.id === serviceID) {
|
|
82
|
-
return service.enabled === 1;
|
|
83
|
-
}
|
|
16
|
+
async checkCameraTime() {
|
|
17
|
+
const cameraTime = await this.get('/local/camoverlay/api/camera_time.cgi');
|
|
18
|
+
return cameraTime.state;
|
|
19
|
+
}
|
|
20
|
+
async getNetworkCameraList() {
|
|
21
|
+
const response = await this.get('/local/camoverlay/api/network_camera_list.cgi');
|
|
22
|
+
return networkCameraListSchema.parse(response.camera_list);
|
|
23
|
+
}
|
|
24
|
+
async wsAutoratization() {
|
|
25
|
+
const response = await this.get(`/local/camoverlay/api/ws_authorization.cgi`);
|
|
26
|
+
return response.data;
|
|
27
|
+
}
|
|
28
|
+
async getMjpegStreamImage(mjpegUrl) {
|
|
29
|
+
const res = await this.get(`/local/camoverlay/api/fetch_mjpeg_image.cgi?mjpeg_url=${encodeURIComponent(decodeURIComponent(mjpegUrl))}`);
|
|
30
|
+
return await this.parseBlobResponse(res);
|
|
31
|
+
}
|
|
32
|
+
async listFiles(fileType) {
|
|
33
|
+
const files = await this.get(`/local/camoverlay/api/upload_${fileType}.cgi?action=list`);
|
|
34
|
+
return fileListSchema.parse(files.list);
|
|
35
|
+
}
|
|
36
|
+
async uploadFile(fileType, file, fileName) {
|
|
37
|
+
const formData = new FormData();
|
|
38
|
+
formData.append('target', 'SD0');
|
|
39
|
+
formData.append('uploadedFile[]', file, fileName);
|
|
40
|
+
const path = `/local/camoverlay/api/upload_${fileType}.cgi?action=upload`;
|
|
41
|
+
await this.post(path, formData);
|
|
42
|
+
}
|
|
43
|
+
async removeFile(fileType, file) {
|
|
44
|
+
const path = `/local/camoverlay/api/upload_${fileType}.cgi?action=remove`;
|
|
45
|
+
await this.post(path, JSON.stringify(file));
|
|
46
|
+
}
|
|
47
|
+
async getFileStorage(fileType) {
|
|
48
|
+
const data = await this.get(`/local/camoverlay/api/upload_${fileType}.cgi?action=get_storage`);
|
|
49
|
+
return storageSchema.parse(data);
|
|
50
|
+
}
|
|
51
|
+
async updateInfoticker(serviceID, text) {
|
|
52
|
+
await this.get(`/local/camoverlay/api/infoticker.cgi?service_id=${serviceID}&text=${text}`);
|
|
53
|
+
}
|
|
54
|
+
async setEnabled(serviceID, enabled) {
|
|
55
|
+
await this.post(`/local/camoverlay/api/enabled.cgi?id_${serviceID}=${enabled ? 1 : 0}`, '');
|
|
56
|
+
}
|
|
57
|
+
async isEnabled(serviceID) {
|
|
58
|
+
const res = await this.client.get('/local/camoverlay/api/services.cgi?action=get');
|
|
59
|
+
if (res.ok) {
|
|
60
|
+
const data = JSON.parse(await res.text());
|
|
61
|
+
for (const service of data.services) {
|
|
62
|
+
if (service.id === serviceID) {
|
|
63
|
+
return service.enabled === 1;
|
|
84
64
|
}
|
|
85
|
-
throw new Error('Service not found.');
|
|
86
65
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
66
|
+
throw new ServiceNotFoundError();
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error(await responseStringify(res));
|
|
70
|
+
}
|
|
91
71
|
}
|
|
92
|
-
getSingleService(serviceId) {
|
|
93
|
-
|
|
94
|
-
|
|
72
|
+
async getSingleService(serviceId) {
|
|
73
|
+
const data = await this.get('/local/camoverlay/api/services.cgi', {
|
|
74
|
+
action: 'get',
|
|
75
|
+
service_id: serviceId.toString(),
|
|
95
76
|
});
|
|
77
|
+
return serviceSchema.parse(data);
|
|
96
78
|
}
|
|
97
|
-
getServices() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return serviceList.services;
|
|
101
|
-
});
|
|
79
|
+
async getServices() {
|
|
80
|
+
const serviceList = await this.get('/local/camoverlay/api/services.cgi?action=get');
|
|
81
|
+
return serviceSchema.parse(serviceList).services;
|
|
102
82
|
}
|
|
103
|
-
updateSingleService(serviceId, serviceJson) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
service_id: serviceId.toString(),
|
|
109
|
-
});
|
|
83
|
+
async updateSingleService(serviceId, serviceJson) {
|
|
84
|
+
const path = '/local/camoverlay/api/services.cgi';
|
|
85
|
+
await this.post(path, JSON.stringify(serviceJson), {
|
|
86
|
+
action: 'set',
|
|
87
|
+
service_id: serviceId.toString(),
|
|
110
88
|
});
|
|
111
89
|
}
|
|
112
|
-
updateServices(servicesJson) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const res = yield this.client.post(path, JSON.stringify(servicesJson));
|
|
116
|
-
if (!res.ok) {
|
|
117
|
-
throw new Error(yield (0, common_1.responseStringify)(res));
|
|
118
|
-
}
|
|
119
|
-
});
|
|
90
|
+
async updateServices(servicesJson) {
|
|
91
|
+
const path = '/local/camoverlay/api/services.cgi?action=set';
|
|
92
|
+
await this.post(path, JSON.stringify(servicesJson));
|
|
120
93
|
}
|
|
121
94
|
updateCGText(serviceID, fields) {
|
|
122
95
|
const params = {};
|
|
@@ -155,40 +128,45 @@ class CamOverlayAPI {
|
|
|
155
128
|
};
|
|
156
129
|
return this.promiseCGUpdate(serviceID, 'update_image', params, contentType, imageData);
|
|
157
130
|
}
|
|
158
|
-
promiseCGUpdate(serviceID, action, params = {}, contentType, data) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
131
|
+
async promiseCGUpdate(serviceID, action, params = {}, contentType, data) {
|
|
132
|
+
const path = `/local/camoverlay/api/customGraphics.cgi`;
|
|
133
|
+
let headers = {};
|
|
134
|
+
if (contentType !== undefined && data) {
|
|
135
|
+
headers = { 'Content-Type': contentType };
|
|
136
|
+
}
|
|
137
|
+
const res = await this.client.post(path, data ?? '', {
|
|
138
|
+
action: action,
|
|
139
|
+
service_id: serviceID.toString(),
|
|
140
|
+
...params,
|
|
141
|
+
}, headers);
|
|
142
|
+
if (!res.ok) {
|
|
143
|
+
throw new Error(await responseStringify(res));
|
|
144
|
+
}
|
|
170
145
|
}
|
|
171
|
-
get(path, params) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
});
|
|
146
|
+
async get(path, params) {
|
|
147
|
+
const res = await this.client.get(path, params);
|
|
148
|
+
if (res.ok) {
|
|
149
|
+
return await res.json();
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
throw new Error(await responseStringify(res));
|
|
153
|
+
}
|
|
181
154
|
}
|
|
182
|
-
post(path, data, params) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
155
|
+
async post(path, data, params) {
|
|
156
|
+
const res = await this.client.post(path, data, params);
|
|
157
|
+
if (res.ok) {
|
|
158
|
+
return await res.json();
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
throw new Error(await responseStringify(res));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async parseBlobResponse(response) {
|
|
165
|
+
try {
|
|
166
|
+
return await response.blob();
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
throw new ParsingBlobError(err);
|
|
170
|
+
}
|
|
192
171
|
}
|
|
193
172
|
}
|
|
194
|
-
exports.CamOverlayAPI = CamOverlayAPI;
|
package/CamOverlayDrawingAPI.js
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import * as EventEmitter from 'events';
|
|
2
|
+
import { WsClient } from './node/WsClient';
|
|
3
|
+
export class CamOverlayDrawingAPI extends EventEmitter {
|
|
4
|
+
tls;
|
|
5
|
+
tlsInsecure;
|
|
6
|
+
ip;
|
|
7
|
+
port;
|
|
8
|
+
user;
|
|
9
|
+
pass;
|
|
10
|
+
cameraList;
|
|
11
|
+
zIndex;
|
|
12
|
+
callId;
|
|
13
|
+
sendMessages;
|
|
14
|
+
timeoutCheckTimer;
|
|
15
|
+
wsConnected;
|
|
16
|
+
ws;
|
|
7
17
|
constructor(options) {
|
|
8
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
9
18
|
super();
|
|
10
|
-
this.tls =
|
|
11
|
-
this.tlsInsecure =
|
|
12
|
-
this.ip =
|
|
13
|
-
this.port =
|
|
14
|
-
this.user =
|
|
15
|
-
this.pass =
|
|
16
|
-
this.zIndex =
|
|
19
|
+
this.tls = options?.tls ?? false;
|
|
20
|
+
this.tlsInsecure = options?.tlsInsecure ?? false;
|
|
21
|
+
this.ip = options?.ip ?? '127.0.0.1';
|
|
22
|
+
this.port = options?.port ?? (this.tls ? 443 : 80);
|
|
23
|
+
this.user = options?.user ?? '';
|
|
24
|
+
this.pass = options?.pass ?? '';
|
|
25
|
+
this.zIndex = options?.zIndex ?? 0;
|
|
17
26
|
this.cameraList = [0];
|
|
18
27
|
if (options && Array.isArray(options.camera)) {
|
|
19
28
|
this.cameraList = options.camera;
|
|
20
29
|
}
|
|
21
|
-
else if (typeof
|
|
30
|
+
else if (typeof options?.camera === 'number') {
|
|
22
31
|
this.cameraList = [options.camera];
|
|
23
32
|
}
|
|
24
33
|
this.callId = 0;
|
|
@@ -88,7 +97,7 @@ class CamOverlayDrawingAPI extends EventEmitter {
|
|
|
88
97
|
tls: this.tls,
|
|
89
98
|
tlsInsecure: this.tlsInsecure,
|
|
90
99
|
};
|
|
91
|
-
this.ws = new
|
|
100
|
+
this.ws = new WsClient(options);
|
|
92
101
|
this.ws.on('open', () => {
|
|
93
102
|
console.log('CamOverlay connection opened');
|
|
94
103
|
this.wsConnected = true;
|
|
@@ -110,7 +119,7 @@ class CamOverlayDrawingAPI extends EventEmitter {
|
|
|
110
119
|
if ('error' in dataJSON) {
|
|
111
120
|
errorResponse = dataJSON;
|
|
112
121
|
}
|
|
113
|
-
if (dataJSON.call_id !== undefined
|
|
122
|
+
if (dataJSON.call_id !== undefined) {
|
|
114
123
|
if (errorResponse !== undefined) {
|
|
115
124
|
this.sendMessages[dataJSON.call_id].reject(new Error(errorResponse.error));
|
|
116
125
|
}
|
|
@@ -217,4 +226,3 @@ class CamOverlayDrawingAPI extends EventEmitter {
|
|
|
217
226
|
this.emit('close');
|
|
218
227
|
}
|
|
219
228
|
}
|
|
220
|
-
exports.CamOverlayDrawingAPI = CamOverlayDrawingAPI;
|