camstreamerlib 4.0.0-beta.37 → 4.0.0-beta.38
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/cjs/CamOverlayAPI.js +42 -69
- package/cjs/CamScripterAPI.js +30 -24
- package/cjs/CamStreamerAPI.js +30 -33
- package/cjs/CamSwitcherAPI.js +57 -52
- package/cjs/PlaneTrackerAPI.js +55 -66
- package/cjs/VapixAPI.js +23 -22
- package/cjs/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +1 -1
- package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +4 -14
- package/cjs/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +1 -1
- package/cjs/{VapixEvents.js → node/VapixEvents.js} +1 -1
- package/cjs/node/events/GenetecAgent.js +5 -27
- package/cjs/node/index.js +17 -0
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +2 -2
- package/cjs/types/CamOverlayPainter.js +12 -0
- package/cjs/types/CamScripterAPICameraEventsGenerator.js +2 -0
- package/cjs/types/CamSwitcherAPI.js +38 -1
- package/cjs/types/GenetecAgent.js +31 -0
- package/cjs/types/PlaneTrackerAPI.js +277 -0
- package/cjs/types/VapixAPI.js +20 -2
- package/cjs/types/VapixEvents.js +2 -0
- package/esm/CamOverlayAPI.js +43 -70
- package/esm/CamScripterAPI.js +30 -24
- package/esm/CamStreamerAPI.js +30 -30
- package/esm/CamSwitcherAPI.js +58 -53
- package/esm/PlaneTrackerAPI.js +56 -67
- package/esm/VapixAPI.js +24 -23
- package/esm/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +1 -1
- package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +1 -11
- package/esm/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +1 -1
- package/esm/{VapixEvents.js → node/VapixEvents.js} +1 -1
- package/esm/node/events/GenetecAgent.js +1 -23
- package/esm/node/index.js +10 -0
- package/esm/types/CamOverlayAPI/CamOverlayAPI.js +1 -1
- package/esm/types/CamOverlayPainter.js +11 -1
- package/esm/types/CamSwitcherAPI.js +38 -1
- package/esm/types/GenetecAgent.js +28 -0
- package/esm/types/PlaneTrackerAPI.js +276 -1
- package/esm/types/VapixAPI.js +19 -1
- package/esm/types/VapixEvents.js +1 -0
- package/package.json +1 -1
- package/types/CamOverlayAPI.d.ts +16 -6
- package/types/CamScripterAPI.d.ts +34 -9
- package/types/CamStreamerAPI.d.ts +27 -5
- package/types/CamSwitcherAPI.d.ts +136 -23
- package/types/PlaneTrackerAPI.d.ts +201 -20
- package/types/VapixAPI.d.ts +46 -12
- package/types/bin/CreatePackage.d.ts +1 -0
- package/types/{CamOverlayDrawingAPI.d.ts → node/CamOverlayDrawingAPI.d.ts} +1 -1
- package/types/{CamOverlayPainter → node/CamOverlayPainter}/Frame.d.ts +2 -2
- package/types/{CamOverlayPainter → node/CamOverlayPainter}/Painter.d.ts +2 -13
- package/types/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.d.ts +1 -1
- package/types/node/CamScripterAPICameraEventsGenerator.d.ts +31 -0
- package/types/node/VapixEvents.d.ts +16 -0
- package/types/node/events/GenetecAgent.d.ts +1 -144
- package/types/node/index.d.ts +10 -0
- package/types/types/CamOverlayAPI/CamOverlayAPI.d.ts +2 -2
- package/types/types/CamOverlayDrawingAPI.d.ts +3 -13
- package/types/types/CamOverlayPainter.d.ts +12 -10
- package/types/types/CamScripterAPICameraEventsGenerator.d.ts +45 -0
- package/types/types/CamStreamerAPI.d.ts +2 -2
- package/types/types/CamSwitcherAPI.d.ts +111 -30
- package/types/types/GenetecAgent.d.ts +174 -0
- package/types/types/PlaneTrackerAPI.d.ts +859 -0
- package/types/types/VapixAPI.d.ts +54 -8
- package/types/types/VapixEvents.d.ts +15 -0
- package/types/types/common.d.ts +1 -0
- package/types/CamScripterAPICameraEventsGenerator.d.ts +0 -74
- package/types/VapixEvents.d.ts +0 -43
- /package/cjs/{CreatePackage.js → bin/CreatePackage.js} +0 -0
- /package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +0 -0
- /package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.js +0 -0
- /package/esm/{CreatePackage.js → bin/CreatePackage.js} +0 -0
- /package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +0 -0
- /package/esm/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.js +0 -0
- /package/{types/CreatePackage.d.ts → esm/types/CamScripterAPICameraEventsGenerator.js} +0 -0
package/cjs/CamOverlayAPI.js
CHANGED
|
@@ -20,68 +20,51 @@ class CamOverlayAPI {
|
|
|
20
20
|
return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
|
|
21
21
|
}
|
|
22
22
|
async checkCameraTime(options) {
|
|
23
|
-
const
|
|
24
|
-
return zod_1.z.boolean().parse(
|
|
23
|
+
const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
24
|
+
return zod_1.z.boolean().parse(res.state);
|
|
25
25
|
}
|
|
26
26
|
async getNetworkCameraList(options) {
|
|
27
|
-
const
|
|
28
|
-
return common_1.networkCameraListSchema.parse(
|
|
27
|
+
const res = await this._getJson(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
|
|
28
|
+
return common_1.networkCameraListSchema.parse(res.camera_list);
|
|
29
29
|
}
|
|
30
30
|
async wsAuthorization(options) {
|
|
31
|
-
const
|
|
32
|
-
return CamOverlayAPI_1.
|
|
31
|
+
const res = await this._getJson(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
|
|
32
|
+
return CamOverlayAPI_1.wsResponseSchema.parse(res).message;
|
|
33
33
|
}
|
|
34
34
|
async getMjpegStreamImage(mjpegUrl, options) {
|
|
35
|
-
return await this._getBlob({
|
|
36
|
-
path: `${BASE_PATH}/fetch_mjpeg_image.cgi?mjpeg_url=${encodeURIComponent(decodeURIComponent(mjpegUrl))}`,
|
|
37
|
-
}, options);
|
|
35
|
+
return await this._getBlob(`${BASE_PATH}/fetch_mjpeg_image.cgi`, { mjpeg_url: decodeURIComponent(mjpegUrl) }, options);
|
|
38
36
|
}
|
|
39
37
|
async listFiles(fileType, options) {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
parameters: {
|
|
43
|
-
action: 'list',
|
|
44
|
-
},
|
|
45
|
-
}, options);
|
|
46
|
-
return CamOverlayAPI_1.fileListSchema.parse(files.list);
|
|
38
|
+
const res = await this._getJson(`${BASE_PATH}/upload_${fileType}.cgi`, { action: 'list' }, options);
|
|
39
|
+
return CamOverlayAPI_1.fileListSchema.parse(res.list);
|
|
47
40
|
}
|
|
48
41
|
async uploadFile(fileType, formData, storage, options) {
|
|
49
|
-
await this._post({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
parameters: {
|
|
53
|
-
action: 'upload',
|
|
54
|
-
storage: storage,
|
|
55
|
-
},
|
|
42
|
+
await this._post(`${BASE_PATH}/upload_${fileType}.cgi`, formData, {
|
|
43
|
+
action: 'upload',
|
|
44
|
+
storage: storage,
|
|
56
45
|
}, options);
|
|
57
46
|
}
|
|
58
47
|
async removeFile(fileType, fileParams, options) {
|
|
59
|
-
|
|
60
|
-
await this._postUrlEncoded(path, {
|
|
48
|
+
await this._postUrlEncoded(`${BASE_PATH}/upload_${fileType}.cgi`, {
|
|
61
49
|
action: 'remove',
|
|
62
50
|
...fileParams,
|
|
63
|
-
},
|
|
51
|
+
}, options, undefined);
|
|
64
52
|
}
|
|
65
53
|
async getFileStorage(fileType, options) {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
parameters: {
|
|
69
|
-
action: 'get_storage',
|
|
70
|
-
},
|
|
71
|
-
}, options);
|
|
72
|
-
if (data.code !== 200) {
|
|
54
|
+
const res = await this._getJson(`${BASE_PATH}/upload_${fileType}.cgi`, { action: 'get_storage' }, options);
|
|
55
|
+
if (res.code !== 200) {
|
|
73
56
|
throw new Error('Error occured while fetching file storage data');
|
|
74
57
|
}
|
|
75
|
-
return CamOverlayAPI_1.storageDataListSchema.parse(
|
|
58
|
+
return CamOverlayAPI_1.storageDataListSchema.parse(res.list);
|
|
76
59
|
}
|
|
77
60
|
async getFilePreviewFromCamera(path, options) {
|
|
78
|
-
return await this._getBlob(
|
|
61
|
+
return await this._getBlob(CamOverlayAPI.getFilePreviewPath(path), undefined, options);
|
|
79
62
|
}
|
|
80
63
|
async updateInfoticker(serviceId, text, options) {
|
|
81
|
-
await this.
|
|
64
|
+
await this._getJson(`${BASE_PATH}/infoticker.cgi`, { service_id: serviceId, text: text }, options);
|
|
82
65
|
}
|
|
83
66
|
async setEnabled(serviceId, enabled, options) {
|
|
84
|
-
await this._post(
|
|
67
|
+
await this._post(`${BASE_PATH}/enabled.cgi`, '', { [`id_${serviceId}`]: enabled ? 1 : 0 }, options);
|
|
85
68
|
}
|
|
86
69
|
async isEnabled(serviceId, options) {
|
|
87
70
|
const agent = this.getClient(options?.proxyParams);
|
|
@@ -100,23 +83,15 @@ class CamOverlayAPI {
|
|
|
100
83
|
}
|
|
101
84
|
}
|
|
102
85
|
async getSingleService(serviceId, options) {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
action: 'get',
|
|
107
|
-
service_id: serviceId.toString(),
|
|
108
|
-
},
|
|
86
|
+
const res = await this._getJson(`${BASE_PATH}/services.cgi`, {
|
|
87
|
+
action: 'get',
|
|
88
|
+
service_id: serviceId,
|
|
109
89
|
}, options);
|
|
110
|
-
return CamOverlayAPI_1.servicesSchema.parse(
|
|
90
|
+
return CamOverlayAPI_1.servicesSchema.parse(res);
|
|
111
91
|
}
|
|
112
92
|
async getServices(options) {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
parameters: {
|
|
116
|
-
action: 'get',
|
|
117
|
-
},
|
|
118
|
-
}, options);
|
|
119
|
-
const services = CamOverlayAPI_1.serviceListSchema.parse(serviceList).services;
|
|
93
|
+
const res = await this._getJson(`${BASE_PATH}/services.cgi`, { action: 'get' }, options);
|
|
94
|
+
const services = CamOverlayAPI_1.serviceListSchema.parse(res).services;
|
|
120
95
|
services.forEach((service) => {
|
|
121
96
|
const parsedService = CamOverlayAPI_1.servicesSchema.safeParse(service);
|
|
122
97
|
if (!parsedService.success) {
|
|
@@ -126,17 +101,15 @@ class CamOverlayAPI {
|
|
|
126
101
|
return services;
|
|
127
102
|
}
|
|
128
103
|
async updateSingleService(service, options) {
|
|
129
|
-
|
|
130
|
-
await this._postJsonEncoded(path, JSON.stringify(service), {
|
|
104
|
+
await this._postJsonEncoded(`${BASE_PATH}/services.cgi`, JSON.stringify(service), {
|
|
131
105
|
action: 'set',
|
|
132
|
-
service_id: service.id
|
|
133
|
-
},
|
|
106
|
+
service_id: service.id,
|
|
107
|
+
}, options, undefined);
|
|
134
108
|
}
|
|
135
109
|
async updateServices(services, options) {
|
|
136
|
-
|
|
137
|
-
await this._postJsonEncoded(path, JSON.stringify({ services: services }), {
|
|
110
|
+
await this._postJsonEncoded(`${BASE_PATH}/services.cgi`, JSON.stringify({ services: services }), {
|
|
138
111
|
action: 'set',
|
|
139
|
-
},
|
|
112
|
+
}, options, undefined);
|
|
140
113
|
}
|
|
141
114
|
updateCGText(serviceId, fields, options) {
|
|
142
115
|
const params = {};
|
|
@@ -197,9 +170,9 @@ class CamOverlayAPI {
|
|
|
197
170
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
198
171
|
}
|
|
199
172
|
}
|
|
200
|
-
async
|
|
173
|
+
async _getJson(path, parameters, options) {
|
|
201
174
|
const agent = this.getClient(options?.proxyParams);
|
|
202
|
-
const res = await agent.get({
|
|
175
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
203
176
|
if (res.ok) {
|
|
204
177
|
return await res.json();
|
|
205
178
|
}
|
|
@@ -207,9 +180,9 @@ class CamOverlayAPI {
|
|
|
207
180
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
208
181
|
}
|
|
209
182
|
}
|
|
210
|
-
async _post(
|
|
183
|
+
async _post(path, data, parameters, options, headers) {
|
|
211
184
|
const agent = this.getClient(options?.proxyParams);
|
|
212
|
-
const res = await agent.post({
|
|
185
|
+
const res = await agent.post({ path, data, parameters, headers, timeout: options?.timeout });
|
|
213
186
|
if (res.ok) {
|
|
214
187
|
return await res.json();
|
|
215
188
|
}
|
|
@@ -217,9 +190,9 @@ class CamOverlayAPI {
|
|
|
217
190
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
218
191
|
}
|
|
219
192
|
}
|
|
220
|
-
async _getBlob(
|
|
193
|
+
async _getBlob(path, parameters, options) {
|
|
221
194
|
const agent = this.getClient(options?.proxyParams);
|
|
222
|
-
const res = await agent.get({
|
|
195
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
223
196
|
if (res.ok) {
|
|
224
197
|
return await this.parseBlobResponse(res);
|
|
225
198
|
}
|
|
@@ -235,14 +208,14 @@ class CamOverlayAPI {
|
|
|
235
208
|
throw new errors_1.ParsingBlobError(err);
|
|
236
209
|
}
|
|
237
210
|
}
|
|
238
|
-
async _postUrlEncoded(path,
|
|
239
|
-
const data = (0, utils_1.paramToUrl)(
|
|
211
|
+
async _postUrlEncoded(path, parameters, options, headers) {
|
|
212
|
+
const data = (0, utils_1.paramToUrl)(parameters);
|
|
240
213
|
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
241
|
-
return this._post(
|
|
214
|
+
return this._post(path, data, undefined, options, { ...baseHeaders, ...headers });
|
|
242
215
|
}
|
|
243
|
-
async _postJsonEncoded(path, data, parameters,
|
|
216
|
+
async _postJsonEncoded(path, data, parameters, options, headers) {
|
|
244
217
|
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
245
|
-
return this._post(
|
|
218
|
+
return this._post(path, data, parameters, options, { ...baseHeaders, ...headers });
|
|
246
219
|
}
|
|
247
220
|
}
|
|
248
221
|
exports.CamOverlayAPI = CamOverlayAPI;
|
package/cjs/CamScripterAPI.js
CHANGED
|
@@ -11,51 +11,57 @@ class CamScripterAPI {
|
|
|
11
11
|
constructor(client) {
|
|
12
12
|
this.client = client;
|
|
13
13
|
}
|
|
14
|
-
static
|
|
14
|
+
static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
15
15
|
getClient(proxyParams) {
|
|
16
16
|
return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
|
|
17
17
|
}
|
|
18
18
|
async checkCameraTime(options) {
|
|
19
|
-
const
|
|
20
|
-
return CamScripterAPI_1.cameraTimeResponseSchema.parse(
|
|
19
|
+
const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
20
|
+
return CamScripterAPI_1.cameraTimeResponseSchema.parse(res).state;
|
|
21
21
|
}
|
|
22
22
|
async getNetworkCameraList(options) {
|
|
23
|
-
const
|
|
24
|
-
return common_1.networkCameraListSchema.parse(
|
|
23
|
+
const res = await this._getJson(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
|
|
24
|
+
return common_1.networkCameraListSchema.parse(res.camera_list);
|
|
25
25
|
}
|
|
26
26
|
async getStorageInfo(options) {
|
|
27
|
-
const
|
|
28
|
-
return CamScripterAPI_1.storageSchema.parse(
|
|
27
|
+
const res = await this._getJson(`${BASE_PATH}/package/get_storage.cgi`, undefined, options);
|
|
28
|
+
return CamScripterAPI_1.storageSchema.parse(res);
|
|
29
29
|
}
|
|
30
30
|
async getPackageList(options) {
|
|
31
|
-
const
|
|
32
|
-
return CamScripterAPI_1.packageInfoListSchema.parse(
|
|
31
|
+
const res = await this._getJson(`${BASE_PATH}/package/list.cgi`, undefined, options);
|
|
32
|
+
return CamScripterAPI_1.packageInfoListSchema.parse(res);
|
|
33
33
|
}
|
|
34
34
|
async installPackages(formData, storage, options) {
|
|
35
|
-
const
|
|
36
|
-
return CamScripterAPI_1.camscripterApiResponseSchema.parse(
|
|
35
|
+
const res = await this._post(`${BASE_PATH}/package/install.cgi`, formData, { storage: storage }, options);
|
|
36
|
+
return CamScripterAPI_1.camscripterApiResponseSchema.parse(res);
|
|
37
37
|
}
|
|
38
38
|
async uninstallPackage(packageId, options) {
|
|
39
|
-
const
|
|
40
|
-
return CamScripterAPI_1.camscripterApiResponseSchema.parse(
|
|
39
|
+
const res = await this._getJson(`${BASE_PATH}/package/remove.cgi`, { package_name: packageId }, options);
|
|
40
|
+
return CamScripterAPI_1.camscripterApiResponseSchema.parse(res);
|
|
41
41
|
}
|
|
42
42
|
async importSettings(packageId, formData, options) {
|
|
43
|
-
const
|
|
44
|
-
|
|
43
|
+
const res = await this._post(`${BASE_PATH}/package/data.cgi`, formData, {
|
|
44
|
+
action: 'IMPORT',
|
|
45
|
+
package_name: packageId,
|
|
46
|
+
}, options);
|
|
47
|
+
return CamScripterAPI_1.camscripterApiResponseSchema.parse(res);
|
|
45
48
|
}
|
|
46
49
|
async exportSettings(packageId, formData, options) {
|
|
47
|
-
const
|
|
48
|
-
|
|
50
|
+
const res = await this._post(`${BASE_PATH}/package/data.cgi`, formData, {
|
|
51
|
+
action: 'EXPORT',
|
|
52
|
+
package_name: packageId,
|
|
53
|
+
}, options);
|
|
54
|
+
return CamScripterAPI_1.camscripterApiResponseSchema.parse(res);
|
|
49
55
|
}
|
|
50
56
|
async getNodejsStatus(options) {
|
|
51
|
-
const
|
|
52
|
-
return CamScripterAPI_1.nodeStateSchema.parse(
|
|
57
|
+
const res = await this._getJson(`${BASE_PATH}/diagnostics.cgi`, undefined, options);
|
|
58
|
+
return CamScripterAPI_1.nodeStateSchema.parse(res);
|
|
53
59
|
}
|
|
54
60
|
async installNodejs(storage, options) {
|
|
55
|
-
const
|
|
56
|
-
return CamScripterAPI_1.camscripterApiResponseSchema.parse(
|
|
61
|
+
const res = await this._getJson(`${BASE_PATH}/node_update.cgi`, { storage: storage }, options);
|
|
62
|
+
return CamScripterAPI_1.camscripterApiResponseSchema.parse(res);
|
|
57
63
|
}
|
|
58
|
-
async
|
|
64
|
+
async _getJson(path, parameters, options) {
|
|
59
65
|
const agent = this.getClient(options?.proxyParams);
|
|
60
66
|
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
61
67
|
if (res.ok) {
|
|
@@ -65,9 +71,9 @@ class CamScripterAPI {
|
|
|
65
71
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
|
-
async
|
|
74
|
+
async _post(path, data, parameters, options, headers) {
|
|
69
75
|
const agent = this.getClient(options?.proxyParams);
|
|
70
|
-
const res = await agent.post({ path, data, parameters, timeout: options?.timeout });
|
|
76
|
+
const res = await agent.post({ path, data, parameters, headers, timeout: options?.timeout });
|
|
71
77
|
if (res.ok) {
|
|
72
78
|
return await res.json();
|
|
73
79
|
}
|
package/cjs/CamStreamerAPI.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.parseCameraStreamResponse = exports.CamStreamerAPI = void 0;
|
|
7
|
-
const zod_1 =
|
|
4
|
+
const zod_1 = require("zod");
|
|
8
5
|
const ProxyClient_1 = require("./internal/ProxyClient");
|
|
9
6
|
const utils_1 = require("./internal/utils");
|
|
10
7
|
const CamStreamerAPI_1 = require("./types/CamStreamerAPI");
|
|
@@ -17,28 +14,42 @@ class CamStreamerAPI {
|
|
|
17
14
|
getClient(proxyParams) {
|
|
18
15
|
return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
|
|
19
16
|
}
|
|
17
|
+
async wsAuthorization(options) {
|
|
18
|
+
const res = await this._getJson(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
|
|
19
|
+
if (res.status !== 200) {
|
|
20
|
+
throw new Error(`Server error on ws authorization: ${res.message}`);
|
|
21
|
+
}
|
|
22
|
+
return zod_1.z.string().parse(res.data);
|
|
23
|
+
}
|
|
24
|
+
async getUtcTime(options) {
|
|
25
|
+
const res = await this._getJson(`${BASE_PATH}/get_utc_time.cgi`, undefined, options);
|
|
26
|
+
if (res.status !== 200) {
|
|
27
|
+
throw new Error(`Server error on get UTC time: ${res.message}`);
|
|
28
|
+
}
|
|
29
|
+
return zod_1.z.number().parse(res.data);
|
|
30
|
+
}
|
|
20
31
|
async getStreamList(options) {
|
|
21
|
-
const
|
|
22
|
-
const list = zod_1.
|
|
23
|
-
const
|
|
32
|
+
const res = await this._getJson(`${BASE_PATH}/stream/list.cgi`, undefined, options);
|
|
33
|
+
const list = zod_1.z.record(zod_1.z.string(), CamStreamerAPI_1.cameraStreamSchema).parse(res.data);
|
|
34
|
+
const streamList = {};
|
|
24
35
|
for (const [key, data] of Object.entries(list)) {
|
|
25
36
|
const streamId = parseInt(key);
|
|
26
|
-
|
|
37
|
+
streamList[streamId] = (0, exports.parseCameraStreamResponse)(data);
|
|
27
38
|
}
|
|
28
|
-
return
|
|
39
|
+
return streamList;
|
|
29
40
|
}
|
|
30
41
|
async getStream(streamId, options) {
|
|
31
|
-
const
|
|
32
|
-
const cameraData = CamStreamerAPI_1.cameraStreamSchema.parse(
|
|
42
|
+
const res = await this._getJson(`${BASE_PATH}/stream/get.cgi`, { stream_id: streamId }, options);
|
|
43
|
+
const cameraData = CamStreamerAPI_1.cameraStreamSchema.parse(res.data);
|
|
33
44
|
return (0, exports.parseCameraStreamResponse)(cameraData);
|
|
34
45
|
}
|
|
35
46
|
async getStreamParameter(streamId, paramName, options) {
|
|
36
|
-
const
|
|
37
|
-
return
|
|
47
|
+
const res = await this._getJson(`${BASE_PATH}/stream/get.cgi`, { stream_id: streamId }, options);
|
|
48
|
+
return zod_1.z.string().parse(res.data[paramName]);
|
|
38
49
|
}
|
|
39
50
|
async setStream(streamId, params, options) {
|
|
40
51
|
const { streamDelay, startTime, stopTime, ...rest } = params;
|
|
41
|
-
return await this.
|
|
52
|
+
return await this._getJson(`${BASE_PATH}/stream/set.cgi`, {
|
|
42
53
|
stream_id: streamId,
|
|
43
54
|
streamDelay: streamDelay ?? '',
|
|
44
55
|
startTime: startTime ?? null,
|
|
@@ -47,31 +58,17 @@ class CamStreamerAPI {
|
|
|
47
58
|
}, options);
|
|
48
59
|
}
|
|
49
60
|
async setStreamParameter(streamId, paramName, value, options) {
|
|
50
|
-
return await this.
|
|
61
|
+
return await this._getJson(`${BASE_PATH}/stream/set.cgi`, { stream_id: streamId, [paramName]: value }, options);
|
|
51
62
|
}
|
|
52
63
|
async isStreaming(streamId, options) {
|
|
53
|
-
const
|
|
54
|
-
return
|
|
64
|
+
const res = await this._getJson(`${BASE_PATH}/get_streamstat.cgi`, { stream_id: streamId }, options);
|
|
65
|
+
return res.data.is_streaming === 1;
|
|
55
66
|
}
|
|
56
67
|
async deleteStream(streamId, options) {
|
|
57
|
-
const res = await this.
|
|
68
|
+
const res = await this._getJson(`${BASE_PATH}/stream/remove.cgi`, { stream_id: streamId }, options);
|
|
58
69
|
return res.data.status === 200;
|
|
59
70
|
}
|
|
60
|
-
async
|
|
61
|
-
const res = await this.get(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
|
|
62
|
-
if (res.status !== 200) {
|
|
63
|
-
throw new Error(`Server error on ws authorization: ${res.message}`);
|
|
64
|
-
}
|
|
65
|
-
return res.data;
|
|
66
|
-
}
|
|
67
|
-
async getUtcTime(options) {
|
|
68
|
-
const res = await this.get(`${BASE_PATH}/get_utc_time.cgi`, undefined, options);
|
|
69
|
-
if (res.status !== 200) {
|
|
70
|
-
throw new Error(`Server error on get UTC time: ${res.message}`);
|
|
71
|
-
}
|
|
72
|
-
return res.data;
|
|
73
|
-
}
|
|
74
|
-
async get(path, parameters, options) {
|
|
71
|
+
async _getJson(path, parameters, options) {
|
|
75
72
|
const agent = this.getClient(options?.proxyParams);
|
|
76
73
|
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
77
74
|
if (res.ok) {
|
package/cjs/CamSwitcherAPI.js
CHANGED
|
@@ -20,9 +20,9 @@ class CamSwitcherAPI {
|
|
|
20
20
|
this.CustomFormData = CustomFormData;
|
|
21
21
|
this.vapixAgent = new VapixAPI_1.VapixAPI(client);
|
|
22
22
|
}
|
|
23
|
-
static
|
|
24
|
-
static
|
|
25
|
-
static
|
|
23
|
+
static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
24
|
+
static getWsEventsPath = () => `/local/camswitcher/events`;
|
|
25
|
+
static getClipPreviewPath = (id, storage) => `${BASE_PATH}/clip_preview.cgi?clip_name=${id}&storage=${storage}`;
|
|
26
26
|
getClient(proxyParams) {
|
|
27
27
|
return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
|
|
28
28
|
}
|
|
@@ -38,98 +38,105 @@ class CamSwitcherAPI {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
async checkCameraTime(options) {
|
|
41
|
-
const
|
|
42
|
-
return zod_1.z.boolean().parse(data);
|
|
41
|
+
const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
42
|
+
return zod_1.z.boolean().parse(res.data);
|
|
43
43
|
}
|
|
44
44
|
async getNetworkCameraList(options) {
|
|
45
|
-
const
|
|
46
|
-
return common_1.networkCameraListSchema.parse(data);
|
|
45
|
+
const res = await this._getJson(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
|
|
46
|
+
return common_1.networkCameraListSchema.parse(res.data);
|
|
47
47
|
}
|
|
48
48
|
async getMaxFps(source, options) {
|
|
49
|
-
const
|
|
50
|
-
video_source: source
|
|
49
|
+
const res = await this._getJson(`${BASE_PATH}/get_max_framerate.cgi`, {
|
|
50
|
+
video_source: source,
|
|
51
51
|
}, options);
|
|
52
|
-
return zod_1.z.number().parse(data);
|
|
52
|
+
return zod_1.z.number().parse(res.data);
|
|
53
53
|
}
|
|
54
54
|
async getStorageInfo(options) {
|
|
55
|
-
const
|
|
56
|
-
return CamSwitcherAPI_1.storageInfoListSchema.parse(data);
|
|
55
|
+
const res = await this._getJson(`${BASE_PATH}/get_storage.cgi`, undefined, options);
|
|
56
|
+
return CamSwitcherAPI_1.storageInfoListSchema.parse(res.data);
|
|
57
57
|
}
|
|
58
58
|
async wsAuthorization(options) {
|
|
59
|
-
const
|
|
60
|
-
return zod_1.z.string().parse(data);
|
|
59
|
+
const res = await this._getJson(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
|
|
60
|
+
return zod_1.z.string().parse(res.data);
|
|
61
61
|
}
|
|
62
62
|
async getOutputInfo(options) {
|
|
63
|
-
const
|
|
64
|
-
return CamSwitcherAPI_1.outputInfoSchema.parse(data);
|
|
63
|
+
const res = await this._getJson(`${BASE_PATH}/output_info.cgi`, undefined, options);
|
|
64
|
+
return CamSwitcherAPI_1.outputInfoSchema.parse(res.data);
|
|
65
65
|
}
|
|
66
66
|
async getAudioPushInfo(options) {
|
|
67
|
-
const
|
|
68
|
-
return CamSwitcherAPI_1.audioPushInfoSchema.parse(data);
|
|
67
|
+
const res = await this._getJson(`${BASE_PATH}/audio_push_info.cgi`, undefined, options);
|
|
68
|
+
return CamSwitcherAPI_1.audioPushInfoSchema.parse(res.data);
|
|
69
69
|
}
|
|
70
70
|
async getStreamSaveList(options) {
|
|
71
|
-
const
|
|
72
|
-
return CamSwitcherAPI_1.streamSaveLoadSchema.parse(data);
|
|
71
|
+
const res = await this._getJson(`${BASE_PATH}/streams.cgi`, { action: 'get' }, options);
|
|
72
|
+
return CamSwitcherAPI_1.streamSaveLoadSchema.parse(res.data);
|
|
73
73
|
}
|
|
74
74
|
async getClipSaveList(options) {
|
|
75
|
-
const
|
|
76
|
-
return CamSwitcherAPI_1.clipSaveLoadSchema.parse(data);
|
|
75
|
+
const res = await this._getJson(`${BASE_PATH}/clips.cgi`, { action: 'get' }, options);
|
|
76
|
+
return CamSwitcherAPI_1.clipSaveLoadSchema.parse(res.data);
|
|
77
77
|
}
|
|
78
78
|
async getPlaylistSaveList(options) {
|
|
79
|
-
const
|
|
80
|
-
return CamSwitcherAPI_1.playlistSaveLoadSchema.parse(data);
|
|
79
|
+
const res = await this._getJson(`${BASE_PATH}/playlists.cgi`, { action: 'get' }, options);
|
|
80
|
+
return CamSwitcherAPI_1.playlistSaveLoadSchema.parse(res.data);
|
|
81
81
|
}
|
|
82
82
|
async getTrackerSaveList(options) {
|
|
83
|
-
const
|
|
84
|
-
return CamSwitcherAPI_1.trackerSaveLoadSchema.parse(data);
|
|
83
|
+
const res = await this._getJson(`${BASE_PATH}/trackers.cgi`, { action: 'get' }, options);
|
|
84
|
+
return CamSwitcherAPI_1.trackerSaveLoadSchema.parse(res.data);
|
|
85
85
|
}
|
|
86
86
|
async setStreamSaveList(data, options) {
|
|
87
|
-
return await this.
|
|
87
|
+
return await this._post(`${BASE_PATH}/streams.cgi`, data, { action: 'set' }, options);
|
|
88
88
|
}
|
|
89
89
|
async setClipSaveList(data, options) {
|
|
90
|
-
return await this.
|
|
90
|
+
return await this._post(`${BASE_PATH}/clips.cgi`, data, { action: 'set' }, options);
|
|
91
91
|
}
|
|
92
92
|
async setPlaylistSaveList(data, options) {
|
|
93
|
-
return await this.
|
|
93
|
+
return await this._post(`${BASE_PATH}/playlists.cgi`, data, { action: 'set' }, options);
|
|
94
94
|
}
|
|
95
95
|
async setTrackerSaveList(data, options) {
|
|
96
|
-
return await this.
|
|
96
|
+
return await this._post(`${BASE_PATH}/trackers.cgi`, data, { action: 'set' }, options);
|
|
97
97
|
}
|
|
98
98
|
async playlistSwitch(playlistName, options) {
|
|
99
|
-
await this.
|
|
99
|
+
await this._getJson(`${BASE_PATH}/playlist_switch.cgi`, { playlist_name: playlistName }, options);
|
|
100
100
|
}
|
|
101
101
|
async playlistQueuePush(playlistName, options) {
|
|
102
|
-
await this.
|
|
102
|
+
await this._getJson(`${BASE_PATH}/playlist_queue_push.cgi`, { playlist_name: playlistName }, options);
|
|
103
103
|
}
|
|
104
104
|
async playlistQueueClear(options) {
|
|
105
|
-
await this.
|
|
105
|
+
await this._getJson(`${BASE_PATH}/playlist_queue_clear.cgi`, undefined, options);
|
|
106
106
|
}
|
|
107
107
|
async playlistQueueList(options) {
|
|
108
|
-
const
|
|
109
|
-
return CamSwitcherAPI_1.playlistQueueSchema.parse(data).playlistQueueList;
|
|
108
|
+
const res = await this._getJson(`${BASE_PATH}/playlist_queue_list.cgi`, undefined, options);
|
|
109
|
+
return CamSwitcherAPI_1.playlistQueueSchema.parse(res.data).playlistQueueList;
|
|
110
110
|
}
|
|
111
111
|
async playlistQueuePlayNext(options) {
|
|
112
|
-
await this.
|
|
112
|
+
await this._getJson(`${BASE_PATH}/playlist_queue_play_next.cgi`, undefined, options);
|
|
113
113
|
}
|
|
114
114
|
async addNewClip(file, clipType, storage, clipId, fileName, options) {
|
|
115
|
-
const path = `${BASE_PATH}/clip_upload.cgi
|
|
115
|
+
const path = `${BASE_PATH}/clip_upload.cgi`;
|
|
116
116
|
const formData = new this.CustomFormData();
|
|
117
117
|
formData.append('clip_name', clipId);
|
|
118
118
|
formData.append('clip_type', clipType);
|
|
119
119
|
formData.append('file', file, fileName);
|
|
120
120
|
const agent = this.getClient(options?.proxyParams);
|
|
121
|
-
const res = await agent.post({
|
|
121
|
+
const res = await agent.post({
|
|
122
|
+
path,
|
|
123
|
+
data: formData,
|
|
124
|
+
parameters: {
|
|
125
|
+
storage: storage,
|
|
126
|
+
},
|
|
127
|
+
timeout: options?.timeout,
|
|
128
|
+
});
|
|
122
129
|
const output = (await res.json());
|
|
123
130
|
if (output.status !== 200) {
|
|
124
131
|
throw new errors_1.AddNewClipError(output.message);
|
|
125
132
|
}
|
|
126
133
|
}
|
|
127
134
|
removeClip(clipId, storage, options) {
|
|
128
|
-
return this.
|
|
135
|
+
return this._getJson(`${BASE_PATH}/clip_remove.cgi`, { clip_name: clipId, storage }, options);
|
|
129
136
|
}
|
|
130
137
|
async getClipList(options) {
|
|
131
|
-
const
|
|
132
|
-
return CamSwitcherAPI_1.clipListSchema.parse(data).clip_list;
|
|
138
|
+
const res = await this._getJson(`${BASE_PATH}/clip_list.cgi`, undefined, options);
|
|
139
|
+
return CamSwitcherAPI_1.clipListSchema.parse(res.data).clip_list;
|
|
133
140
|
}
|
|
134
141
|
setCamSwitchOptions(data, cameraFWVersion, options) {
|
|
135
142
|
const bitrateVapixParams = parseBitrateOptionsToBitrateVapixParams(cameraFWVersion, data.bitrateMode, data);
|
|
@@ -230,7 +237,7 @@ class CamSwitcherAPI {
|
|
|
230
237
|
settings.source = res.clip_name;
|
|
231
238
|
settings.storage = res.storage;
|
|
232
239
|
}
|
|
233
|
-
return settings;
|
|
240
|
+
return CamSwitcherAPI_1.globalAudioSettingsSchema.parse(settings);
|
|
234
241
|
}
|
|
235
242
|
async getSecondaryAudioSettings(options) {
|
|
236
243
|
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SECONDARY_AUDIO, options);
|
|
@@ -242,30 +249,28 @@ class CamSwitcherAPI {
|
|
|
242
249
|
secondaryAudioLevel: res.secondary_audio_level ?? 1,
|
|
243
250
|
masterAudioLevel: res.master_audio_level ?? 1,
|
|
244
251
|
};
|
|
245
|
-
return settings;
|
|
252
|
+
return CamSwitcherAPI_1.secondaryAudioSettingsSchema.parse(settings);
|
|
246
253
|
}
|
|
247
254
|
async getPermanentRtspUrlToken(options) {
|
|
248
255
|
const paramName = CSW_PARAM_NAMES.RTSP_TOKEN;
|
|
249
256
|
const res = await this.vapixAgent.getParameter([paramName], options);
|
|
250
|
-
return res[paramName] ?? '';
|
|
257
|
+
return zod_1.z.string().parse(res[paramName] ?? '');
|
|
251
258
|
}
|
|
252
|
-
async
|
|
259
|
+
async _getJson(path, parameters, options) {
|
|
253
260
|
const agent = this.getClient(options?.proxyParams);
|
|
254
261
|
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
255
262
|
if (res.ok) {
|
|
256
|
-
|
|
257
|
-
return d.data;
|
|
263
|
+
return await res.json();
|
|
258
264
|
}
|
|
259
265
|
else {
|
|
260
266
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
261
267
|
}
|
|
262
268
|
}
|
|
263
|
-
async
|
|
269
|
+
async _post(path, data, parameters, options, headers) {
|
|
264
270
|
const agent = this.getClient(options?.proxyParams);
|
|
265
|
-
const res = await agent.post({ path, data
|
|
271
|
+
const res = await agent.post({ path, data, parameters, timeout: options?.timeout, headers });
|
|
266
272
|
if (res.ok) {
|
|
267
|
-
|
|
268
|
-
return parsed.message === 'OK';
|
|
273
|
+
return await res.json();
|
|
269
274
|
}
|
|
270
275
|
else {
|
|
271
276
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
@@ -306,7 +311,7 @@ const parseBitrateOptionsToBitrateVapixParams = (firmWareVersion, bitrateMode, c
|
|
|
306
311
|
if (!(0, versionCompare_1.isFirmwareVersionAtLeast)(firmWareVersion, constants_1.FIRMWARE_WITH_BITRATE_MODES_SUPPORT)) {
|
|
307
312
|
return `videomaxbitrate=${cameraOptions.maximumBitRate}`;
|
|
308
313
|
}
|
|
309
|
-
if (bitrateMode ===
|
|
314
|
+
if (bitrateMode === undefined) {
|
|
310
315
|
return '';
|
|
311
316
|
}
|
|
312
317
|
const data = {
|