camstreamerlib 4.0.0-beta.3 → 4.0.0-beta.31
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/README.md +8 -2
- package/cjs/CamOverlayAPI.d.ts +48 -26
- package/cjs/CamOverlayAPI.js +171 -88
- package/cjs/CamOverlayDrawingAPI.d.ts +2 -47
- package/cjs/CamOverlayDrawingAPI.js +6 -3
- package/cjs/CamOverlayPainter/Frame.d.ts +8 -37
- package/cjs/CamOverlayPainter/Frame.js +33 -0
- package/cjs/CamOverlayPainter/Painter.d.ts +16 -10
- package/cjs/CamOverlayPainter/Painter.js +6 -5
- package/cjs/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/cjs/CamOverlayPainter/ResourceManager.js +8 -11
- package/cjs/CamScripterAPI.d.ts +34 -16
- package/cjs/CamScripterAPI.js +50 -41
- package/cjs/CamScripterAPICameraEventsGenerator.d.ts +1 -1
- package/cjs/CamScripterAPICameraEventsGenerator.js +6 -3
- package/cjs/CamStreamerAPI.d.ts +17 -14
- package/cjs/CamStreamerAPI.js +32 -32
- package/cjs/CamSwitcherAPI.d.ts +43 -37
- package/cjs/CamSwitcherAPI.js +123 -114
- package/cjs/CamSwitcherEvents.d.ts +1 -1
- package/cjs/PlaneTrackerAPI.d.ts +43 -0
- package/cjs/PlaneTrackerAPI.js +211 -0
- package/cjs/VapixAPI.d.ts +56 -42
- package/cjs/VapixAPI.js +305 -216
- package/cjs/VapixEvents.d.ts +1 -1
- package/cjs/VapixEvents.js +3 -3
- package/cjs/errors/errors.d.ts +3 -0
- package/cjs/errors/errors.js +8 -1
- package/cjs/events/AxisCameraStationEvents.d.ts +7 -4
- package/cjs/events/AxisCameraStationEvents.js +23 -18
- package/cjs/events/GenetecAgent.d.ts +6 -3
- package/cjs/events/GenetecAgent.js +30 -19
- package/cjs/index.d.ts +14 -1
- package/cjs/index.js +23 -2
- package/cjs/internal/Digest.js +6 -6
- package/cjs/internal/ProxyClient.d.ts +8 -9
- package/cjs/internal/ProxyClient.js +25 -29
- package/cjs/internal/types.d.ts +42 -0
- package/cjs/internal/types.js +2 -0
- package/cjs/internal/utils.d.ts +4 -1
- package/cjs/internal/utils.js +22 -3
- package/cjs/internal/versionCompare.d.ts +2 -2
- package/cjs/node/DefaultClient.d.ts +5 -6
- package/cjs/node/DefaultClient.js +12 -14
- package/cjs/node/HttpRequestSender.d.ts +1 -0
- package/cjs/node/HttpRequestSender.js +13 -3
- package/cjs/node/HttpServer.js +1 -1
- package/cjs/node/WsClient.d.ts +2 -1
- package/cjs/node/index.d.ts +2 -0
- package/cjs/node/index.js +18 -1
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.d.ts +3071 -0
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +127 -0
- package/cjs/types/CamOverlayAPI/accuweatherSchema.d.ts +114 -0
- package/cjs/types/CamOverlayAPI/accuweatherSchema.js +50 -0
- package/cjs/types/CamOverlayAPI/customGraphicsSchema.d.ts +783 -0
- package/cjs/types/CamOverlayAPI/customGraphicsSchema.js +75 -0
- package/cjs/types/CamOverlayAPI/imagesSchema.d.ts +122 -0
- package/cjs/types/CamOverlayAPI/imagesSchema.js +12 -0
- package/cjs/types/CamOverlayAPI/index.d.ts +9 -0
- package/cjs/types/CamOverlayAPI/index.js +25 -0
- package/cjs/types/CamOverlayAPI/infotickerSchema.d.ts +130 -0
- package/cjs/types/CamOverlayAPI/infotickerSchema.js +29 -0
- package/cjs/types/CamOverlayAPI/pipSchema.d.ts +166 -0
- package/cjs/types/CamOverlayAPI/pipSchema.js +42 -0
- package/cjs/types/CamOverlayAPI/ptzCompassSchema.d.ts +126 -0
- package/cjs/types/CamOverlayAPI/ptzCompassSchema.js +28 -0
- package/cjs/types/CamOverlayAPI/ptzSchema.d.ts +146 -0
- package/cjs/types/CamOverlayAPI/ptzSchema.js +15 -0
- package/cjs/types/CamOverlayAPI/screenSharingSchema.d.ts +79 -0
- package/cjs/types/CamOverlayAPI/screenSharingSchema.js +11 -0
- package/cjs/types/CamOverlayAPI/webCameraSharingSchema.d.ts +79 -0
- package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +11 -0
- package/cjs/types/CamOverlayDrawingAPI.d.ts +58 -0
- package/cjs/types/CamOverlayDrawingAPI.js +2 -0
- package/cjs/types/CamOverlayPainter.d.ts +74 -0
- package/cjs/types/CamOverlayPainter.js +2 -0
- package/cjs/types/CamScripterAPI.d.ts +82 -17
- package/cjs/types/CamScripterAPI.js +22 -7
- package/cjs/types/CamStreamerAPI.d.ts +16 -5
- package/cjs/types/CamStreamerAPI.js +5 -1
- package/cjs/types/CamSwitcherAPI.d.ts +4 -6
- package/cjs/types/CamSwitcherEvents.d.ts +77 -0
- package/cjs/types/CamSwitcherEvents.js +8 -0
- package/cjs/types/PlaneTrackerAPI.d.ts +8 -0
- package/cjs/types/PlaneTrackerAPI.js +2 -0
- package/cjs/types/VapixAPI.d.ts +635 -520
- package/cjs/types/VapixAPI.js +62 -24
- package/cjs/types/common.d.ts +14 -5
- package/cjs/web/DefaultClient.d.ts +5 -5
- package/cjs/web/DefaultClient.js +22 -10
- package/cjs/web/WsClient.js +2 -2
- package/esm/CamOverlayAPI.d.ts +48 -26
- package/esm/CamOverlayAPI.js +167 -84
- package/esm/CamOverlayDrawingAPI.d.ts +2 -47
- package/esm/CamOverlayDrawingAPI.js +6 -3
- package/esm/CamOverlayPainter/Frame.d.ts +8 -37
- package/esm/CamOverlayPainter/Frame.js +33 -0
- package/esm/CamOverlayPainter/Painter.d.ts +16 -10
- package/esm/CamOverlayPainter/Painter.js +5 -3
- package/esm/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/esm/CamOverlayPainter/ResourceManager.js +7 -11
- package/esm/CamScripterAPI.d.ts +34 -16
- package/esm/CamScripterAPI.js +46 -37
- package/esm/CamScripterAPICameraEventsGenerator.d.ts +1 -1
- package/esm/CamScripterAPICameraEventsGenerator.js +6 -3
- package/esm/CamStreamerAPI.d.ts +17 -14
- package/esm/CamStreamerAPI.js +32 -32
- package/esm/CamSwitcherAPI.d.ts +43 -37
- package/esm/CamSwitcherAPI.js +116 -107
- package/esm/CamSwitcherEvents.d.ts +1 -1
- package/esm/PlaneTrackerAPI.d.ts +43 -0
- package/esm/PlaneTrackerAPI.js +207 -0
- package/esm/VapixAPI.d.ts +56 -42
- package/esm/VapixAPI.js +297 -208
- package/esm/VapixEvents.d.ts +1 -1
- package/esm/VapixEvents.js +3 -3
- package/esm/errors/errors.d.ts +3 -0
- package/esm/errors/errors.js +6 -0
- package/esm/events/AxisCameraStationEvents.d.ts +7 -4
- package/esm/events/AxisCameraStationEvents.js +18 -13
- package/esm/events/GenetecAgent.d.ts +6 -3
- package/esm/events/GenetecAgent.js +20 -9
- package/esm/index.d.ts +14 -1
- package/esm/index.js +14 -1
- package/esm/internal/Digest.js +6 -6
- package/esm/internal/ProxyClient.d.ts +8 -9
- package/esm/internal/ProxyClient.js +25 -29
- package/esm/internal/types.d.ts +42 -0
- package/esm/internal/types.js +1 -0
- package/esm/internal/utils.d.ts +4 -1
- package/esm/internal/utils.js +17 -1
- package/esm/internal/versionCompare.d.ts +2 -2
- package/esm/node/DefaultClient.d.ts +5 -6
- package/esm/node/DefaultClient.js +12 -14
- package/esm/node/HttpRequestSender.d.ts +1 -0
- package/esm/node/HttpRequestSender.js +13 -3
- package/esm/node/HttpServer.js +1 -1
- package/esm/node/WsClient.d.ts +2 -1
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/types/CamOverlayAPI/CamOverlayAPI.d.ts +3071 -0
- package/esm/types/CamOverlayAPI/CamOverlayAPI.js +124 -0
- package/esm/types/CamOverlayAPI/accuweatherSchema.d.ts +114 -0
- package/esm/types/CamOverlayAPI/accuweatherSchema.js +46 -0
- package/esm/types/CamOverlayAPI/customGraphicsSchema.d.ts +783 -0
- package/esm/types/CamOverlayAPI/customGraphicsSchema.js +71 -0
- package/esm/types/CamOverlayAPI/imagesSchema.d.ts +122 -0
- package/esm/types/CamOverlayAPI/imagesSchema.js +8 -0
- package/esm/types/CamOverlayAPI/index.d.ts +9 -0
- package/esm/types/CamOverlayAPI/index.js +9 -0
- package/esm/types/CamOverlayAPI/infotickerSchema.d.ts +130 -0
- package/esm/types/CamOverlayAPI/infotickerSchema.js +25 -0
- package/esm/types/CamOverlayAPI/pipSchema.d.ts +166 -0
- package/esm/types/CamOverlayAPI/pipSchema.js +38 -0
- package/esm/types/CamOverlayAPI/ptzCompassSchema.d.ts +126 -0
- package/esm/types/CamOverlayAPI/ptzCompassSchema.js +24 -0
- package/esm/types/CamOverlayAPI/ptzSchema.d.ts +146 -0
- package/esm/types/CamOverlayAPI/ptzSchema.js +11 -0
- package/esm/types/CamOverlayAPI/screenSharingSchema.d.ts +79 -0
- package/esm/types/CamOverlayAPI/screenSharingSchema.js +7 -0
- package/esm/types/CamOverlayAPI/webCameraSharingSchema.d.ts +79 -0
- package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +7 -0
- package/esm/types/CamOverlayDrawingAPI.d.ts +58 -0
- package/esm/types/CamOverlayDrawingAPI.js +1 -0
- package/esm/types/CamOverlayPainter.d.ts +74 -0
- package/esm/types/CamOverlayPainter.js +1 -0
- package/esm/types/CamScripterAPI.d.ts +82 -17
- package/esm/types/CamScripterAPI.js +21 -6
- package/esm/types/CamStreamerAPI.d.ts +16 -5
- package/esm/types/CamStreamerAPI.js +4 -0
- package/esm/types/CamSwitcherAPI.d.ts +4 -6
- package/esm/types/CamSwitcherEvents.d.ts +77 -0
- package/esm/types/CamSwitcherEvents.js +8 -0
- package/esm/types/PlaneTrackerAPI.d.ts +8 -0
- package/esm/types/PlaneTrackerAPI.js +1 -0
- package/esm/types/VapixAPI.d.ts +635 -520
- package/esm/types/VapixAPI.js +61 -23
- package/esm/types/common.d.ts +14 -5
- package/esm/web/DefaultClient.d.ts +5 -5
- package/esm/web/DefaultClient.js +22 -10
- package/esm/web/WsClient.js +2 -2
- package/package.json +9 -8
- package/cjs/internal/common.d.ts +0 -39
- package/cjs/internal/common.js +0 -27
- package/cjs/node/WsEventClient.d.ts +0 -13
- package/cjs/node/WsEventClient.js +0 -22
- package/cjs/types/CamOverlayAPI.d.ts +0 -188
- package/cjs/types/CamOverlayAPI.js +0 -47
- package/esm/internal/common.d.ts +0 -39
- package/esm/internal/common.js +0 -20
- package/esm/node/WsEventClient.d.ts +0 -13
- package/esm/node/WsEventClient.js +0 -18
- package/esm/types/CamOverlayAPI.d.ts +0 -188
- package/esm/types/CamOverlayAPI.js +0 -44
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as fs from 'fs/promises';
|
|
2
|
-
export
|
|
2
|
+
export class ResourceManager {
|
|
3
3
|
co;
|
|
4
4
|
imgFileNames = {};
|
|
5
5
|
fontFileNames = {};
|
|
@@ -15,30 +15,26 @@ export default class ResourceManager {
|
|
|
15
15
|
this.fontFileNames[moniker] = process.env.INSTALL_PATH + '/fonts/' + fileName;
|
|
16
16
|
}
|
|
17
17
|
async image(moniker) {
|
|
18
|
-
if (moniker
|
|
18
|
+
if (this.images[moniker] !== undefined) {
|
|
19
19
|
return this.images[moniker];
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
if (this.imgFileNames[moniker] !== undefined) {
|
|
22
22
|
const imgData = await fs.readFile(this.imgFileNames[moniker]);
|
|
23
23
|
this.images[moniker] = await this.co.uploadImageData(imgData);
|
|
24
24
|
return this.images[moniker];
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
throw new Error('Error! Unknown image requested!');
|
|
28
|
-
}
|
|
26
|
+
throw new Error('Error! Unknown image requested!');
|
|
29
27
|
}
|
|
30
28
|
async font(moniker) {
|
|
31
|
-
if (moniker
|
|
29
|
+
if (this.fonts[moniker] !== undefined) {
|
|
32
30
|
return this.fonts[moniker];
|
|
33
31
|
}
|
|
34
|
-
|
|
32
|
+
if (this.fontFileNames[moniker] !== undefined) {
|
|
35
33
|
const fontData = await fs.readFile(this.fontFileNames[moniker]);
|
|
36
34
|
this.fonts[moniker] = await this.co.uploadFontData(fontData);
|
|
37
35
|
return this.fonts[moniker];
|
|
38
36
|
}
|
|
39
|
-
|
|
40
|
-
throw new Error('Error! Unknown font requested!');
|
|
41
|
-
}
|
|
37
|
+
throw new Error('Error! Unknown font requested!');
|
|
42
38
|
}
|
|
43
39
|
clear() {
|
|
44
40
|
this.images = {};
|
package/esm/CamScripterAPI.d.ts
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { ProxyClient } from './internal/ProxyClient';
|
|
2
|
+
import { IClient, TResponse } from './internal/types';
|
|
3
|
+
import { TNodeState, TPackageInfoList, TStorage, TStorageType } from './types/CamScripterAPI';
|
|
4
|
+
import { THttpRequestOptions, TNetworkCamera, TProxyParams } from './types/common';
|
|
5
|
+
export declare class CamScripterAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
6
|
+
client: Client;
|
|
7
|
+
constructor(client: Client);
|
|
8
|
+
static getProxyUrlPath: () => string;
|
|
9
|
+
getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
|
|
10
|
+
checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
|
|
11
|
+
getNetworkCameraList(options?: THttpRequestOptions): Promise<TNetworkCamera[]>;
|
|
12
|
+
getStorageInfo(options?: THttpRequestOptions): Promise<TStorage>;
|
|
13
|
+
getPackageList(options?: THttpRequestOptions): Promise<TPackageInfoList>;
|
|
14
|
+
installPackages(formData: FormData, storage: TStorageType, options?: THttpRequestOptions): Promise<{
|
|
15
|
+
status: number;
|
|
16
|
+
message: string;
|
|
17
|
+
}>;
|
|
18
|
+
uninstallPackage(packageId: string, options?: THttpRequestOptions): Promise<{
|
|
19
|
+
status: number;
|
|
20
|
+
message: string;
|
|
21
|
+
}>;
|
|
22
|
+
importSettings(packageId: string, formData: FormData, options?: THttpRequestOptions): Promise<{
|
|
23
|
+
status: number;
|
|
24
|
+
message: string;
|
|
25
|
+
}>;
|
|
26
|
+
exportSettings(packageId: string, formData: FormData, options?: THttpRequestOptions): Promise<{
|
|
27
|
+
status: number;
|
|
28
|
+
message: string;
|
|
29
|
+
}>;
|
|
30
|
+
getNodejsStatus(options?: THttpRequestOptions): Promise<TNodeState>;
|
|
31
|
+
installNodejs(storage: TStorageType, options?: THttpRequestOptions): Promise<{
|
|
32
|
+
status: number;
|
|
33
|
+
message: string;
|
|
34
|
+
}>;
|
|
17
35
|
private get;
|
|
18
36
|
private post;
|
|
19
37
|
}
|
package/esm/CamScripterAPI.js
CHANGED
|
@@ -1,52 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { packageInfoListSchema, storageSchema, } from './types/CamScripterAPI';
|
|
1
|
+
import { ProxyClient } from './internal/ProxyClient';
|
|
2
|
+
import { responseStringify } from './internal/utils';
|
|
3
|
+
import { cameraTimeResponseSchema, camscripterApiResponseSchema, nodeStateSchema, packageInfoListSchema, storageSchema, } from './types/CamScripterAPI';
|
|
4
4
|
import { networkCameraListSchema } from './types/common';
|
|
5
|
-
|
|
5
|
+
const BASE_PATH = '/local/camscripter';
|
|
6
|
+
export class CamScripterAPI {
|
|
6
7
|
client;
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
9
|
-
this.client = options;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
this.client = new DefaultClient(options);
|
|
13
|
-
}
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
14
10
|
}
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
12
|
+
getClient(proxyParams) {
|
|
13
|
+
return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
|
|
17
14
|
}
|
|
18
|
-
async
|
|
19
|
-
const data = await this.get(
|
|
20
|
-
return
|
|
15
|
+
async checkCameraTime(options) {
|
|
16
|
+
const data = await this.get(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
17
|
+
return cameraTimeResponseSchema.parse(data).state;
|
|
18
|
+
}
|
|
19
|
+
async getNetworkCameraList(options) {
|
|
20
|
+
const data = await this.get(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
|
|
21
|
+
return networkCameraListSchema.parse(data.camera_list);
|
|
21
22
|
}
|
|
22
|
-
async
|
|
23
|
-
const
|
|
24
|
-
return
|
|
23
|
+
async getStorageInfo(options) {
|
|
24
|
+
const data = await this.get(`${BASE_PATH}/package/get_storage.cgi`, undefined, options);
|
|
25
|
+
return storageSchema.parse(data);
|
|
25
26
|
}
|
|
26
|
-
async getPackageList() {
|
|
27
|
-
const data = await this.get(
|
|
27
|
+
async getPackageList(options) {
|
|
28
|
+
const data = await this.get(`${BASE_PATH}/package/list.cgi`, undefined, options);
|
|
28
29
|
return packageInfoListSchema.parse(data);
|
|
29
30
|
}
|
|
30
|
-
async installPackages(formData, storage) {
|
|
31
|
-
await this.post(
|
|
31
|
+
async installPackages(formData, storage, options) {
|
|
32
|
+
const data = await this.post(`${BASE_PATH}/package/install.cgi?storage=${storage}`, formData, undefined, options);
|
|
33
|
+
return camscripterApiResponseSchema.parse(data);
|
|
32
34
|
}
|
|
33
|
-
async uninstallPackage(packageId) {
|
|
34
|
-
await this.get(
|
|
35
|
+
async uninstallPackage(packageId, options) {
|
|
36
|
+
const data = await this.get(`${BASE_PATH}/package/remove.cgi?package_name=${packageId}`, undefined, options);
|
|
37
|
+
return camscripterApiResponseSchema.parse(data);
|
|
35
38
|
}
|
|
36
|
-
async importSettings(packageId, formData) {
|
|
37
|
-
await this.post(
|
|
39
|
+
async importSettings(packageId, formData, options) {
|
|
40
|
+
const data = await this.post(`${BASE_PATH}/package/data.cgi?action=IMPORT&package_name=${packageId}`, formData, undefined, options);
|
|
41
|
+
return camscripterApiResponseSchema.parse(data);
|
|
38
42
|
}
|
|
39
|
-
async exportSettings(packageId, formData) {
|
|
40
|
-
await this.post(
|
|
43
|
+
async exportSettings(packageId, formData, options) {
|
|
44
|
+
const data = await this.post(`${BASE_PATH}/package/data.cgi?action=EXPORT&package_name=${packageId}`, formData, undefined, options);
|
|
45
|
+
return camscripterApiResponseSchema.parse(data);
|
|
41
46
|
}
|
|
42
|
-
async getNodejsStatus() {
|
|
43
|
-
|
|
47
|
+
async getNodejsStatus(options) {
|
|
48
|
+
const data = await this.get(`${BASE_PATH}/diagnostics.cgi`, undefined, options);
|
|
49
|
+
return nodeStateSchema.parse(data);
|
|
44
50
|
}
|
|
45
|
-
async installNodejs(storage) {
|
|
46
|
-
await this.get(
|
|
51
|
+
async installNodejs(storage, options) {
|
|
52
|
+
const data = await this.get(`${BASE_PATH}/node_update.cgi?storage=${storage}`, undefined, options);
|
|
53
|
+
return camscripterApiResponseSchema.parse(data);
|
|
47
54
|
}
|
|
48
|
-
async get(path,
|
|
49
|
-
const
|
|
55
|
+
async get(path, parameters, options) {
|
|
56
|
+
const agent = this.getClient(options?.proxyParams);
|
|
57
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
50
58
|
if (res.ok) {
|
|
51
59
|
return await res.json();
|
|
52
60
|
}
|
|
@@ -54,8 +62,9 @@ export class CamOverlayAPI {
|
|
|
54
62
|
throw new Error(await responseStringify(res));
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
|
-
async post(path, data,
|
|
58
|
-
const
|
|
65
|
+
async post(path, data, parameters, options) {
|
|
66
|
+
const agent = this.getClient(options?.proxyParams);
|
|
67
|
+
const res = await agent.post({ path, data, parameters, timeout: options?.timeout });
|
|
59
68
|
if (res.ok) {
|
|
60
69
|
return await res.json();
|
|
61
70
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as EventEmitter from 'events';
|
|
3
|
-
import { WsOptions } from './internal/
|
|
3
|
+
import { WsOptions } from './internal/types';
|
|
4
4
|
export type CamScripterOptions = WsOptions;
|
|
5
5
|
export type TDeclaration = {
|
|
6
6
|
type?: '' | 'SOURCE' | 'DATA';
|
|
@@ -88,10 +88,10 @@ export class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
|
88
88
|
}
|
|
89
89
|
if (dataJSON.call_id !== undefined) {
|
|
90
90
|
if (errorResponse !== undefined) {
|
|
91
|
-
this.sendMessages[dataJSON.call_id]
|
|
91
|
+
this.sendMessages[dataJSON.call_id]?.reject(new Error(errorResponse.error));
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
|
-
this.sendMessages[dataJSON.call_id]
|
|
94
|
+
this.sendMessages[dataJSON.call_id]?.resolve(dataJSON);
|
|
95
95
|
}
|
|
96
96
|
delete this.sendMessages[dataJSON.call_id];
|
|
97
97
|
}
|
|
@@ -124,6 +124,9 @@ export class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
|
124
124
|
const now = Date.now();
|
|
125
125
|
for (const callId in this.sendMessages) {
|
|
126
126
|
const msg = this.sendMessages[callId];
|
|
127
|
+
if (!msg) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
127
130
|
if (now - msg.sentTimestamp > 10000) {
|
|
128
131
|
reconnect = true;
|
|
129
132
|
msg.reject(new Error('Message timeout'));
|
|
@@ -147,7 +150,7 @@ export class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
|
147
150
|
}
|
|
148
151
|
reportClose() {
|
|
149
152
|
for (const callId in this.sendMessages) {
|
|
150
|
-
this.sendMessages[callId]
|
|
153
|
+
this.sendMessages[callId]?.reject(new Error('Connection lost'));
|
|
151
154
|
}
|
|
152
155
|
this.sendMessages = {};
|
|
153
156
|
this.emit('close');
|
package/esm/CamStreamerAPI.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { ProxyClient } from './internal/ProxyClient';
|
|
2
|
+
import { IClient, TResponse } from './internal/types';
|
|
3
|
+
import { TStreamAttributes, TStreamList } from './types/CamStreamerAPI';
|
|
4
|
+
import { THttpRequestOptions, TProxyParams } from './types/common';
|
|
5
|
+
export declare class CamStreamerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
6
|
+
client: Client;
|
|
7
|
+
constructor(client: Client);
|
|
8
|
+
getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
|
|
9
|
+
getStreamList(options?: THttpRequestOptions): Promise<TStreamList>;
|
|
10
|
+
getStream(streamId: string, options?: THttpRequestOptions): Promise<TStreamAttributes>;
|
|
11
|
+
getStreamParameter(streamId: string, paramName: string, options?: THttpRequestOptions): Promise<string>;
|
|
12
|
+
setStream(streamId: string, params: Partial<TStreamAttributes>, options?: THttpRequestOptions): Promise<void>;
|
|
13
|
+
setStreamParameter(streamId: string, paramName: string, value: string, options?: THttpRequestOptions): Promise<void>;
|
|
14
|
+
isStreaming(streamId: string, options?: THttpRequestOptions): Promise<boolean>;
|
|
15
|
+
deleteStream(streamId: string, options?: THttpRequestOptions): Promise<void>;
|
|
16
|
+
wsAuthorization(options?: THttpRequestOptions): Promise<string>;
|
|
17
|
+
getUtcTime(options?: THttpRequestOptions): Promise<number>;
|
|
15
18
|
private get;
|
|
16
19
|
}
|
package/esm/CamStreamerAPI.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { streamAttributesSchema, streamListSchema
|
|
1
|
+
import { ProxyClient } from './internal/ProxyClient';
|
|
2
|
+
import { responseStringify } from './internal/utils';
|
|
3
|
+
import { streamAttributesSchema, streamListSchema } from './types/CamStreamerAPI';
|
|
4
|
+
const BASE_PATH = '/local/camstreamer';
|
|
4
5
|
export class CamStreamerAPI {
|
|
5
6
|
client;
|
|
6
|
-
constructor(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.client = new DefaultClient(options);
|
|
12
|
-
}
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
getClient(proxyParams) {
|
|
11
|
+
return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
|
|
13
12
|
}
|
|
14
|
-
async getStreamList() {
|
|
15
|
-
const streamListRes = await this.get(
|
|
13
|
+
async getStreamList(options) {
|
|
14
|
+
const streamListRes = await this.get(`${BASE_PATH}/stream/list.cgi`, undefined, options);
|
|
16
15
|
return streamListSchema.parse(streamListRes.data);
|
|
17
16
|
}
|
|
18
|
-
async getStream(
|
|
19
|
-
const stream = await this.get(
|
|
17
|
+
async getStream(streamId, options) {
|
|
18
|
+
const stream = await this.get(`${BASE_PATH}/stream/get.cgi?stream_id=${streamId}`, undefined, options);
|
|
20
19
|
return streamAttributesSchema.parse(stream.data);
|
|
21
20
|
}
|
|
22
|
-
async getStreamParameter(
|
|
23
|
-
const stream = await this.get(
|
|
21
|
+
async getStreamParameter(streamId, paramName, options) {
|
|
22
|
+
const stream = await this.get(`${BASE_PATH}/stream/get.cgi?stream_id=${streamId}`, undefined, options);
|
|
24
23
|
return stream.data[paramName];
|
|
25
24
|
}
|
|
26
|
-
async setStream(
|
|
25
|
+
async setStream(streamId, params, options) {
|
|
27
26
|
const { streamDelay, startTime, stopTime, ...rest } = params;
|
|
28
|
-
await this.get(
|
|
29
|
-
stream_id:
|
|
27
|
+
await this.get(`${BASE_PATH}/stream/set.cgi`, {
|
|
28
|
+
stream_id: streamId,
|
|
30
29
|
streamDelay: streamDelay ?? '',
|
|
31
30
|
startTime: startTime ?? 'null',
|
|
32
31
|
stopTime: stopTime ?? 'null',
|
|
33
32
|
...rest,
|
|
34
|
-
});
|
|
33
|
+
}, options);
|
|
35
34
|
}
|
|
36
|
-
async setStreamParameter(
|
|
37
|
-
await this.get(
|
|
35
|
+
async setStreamParameter(streamId, paramName, value, options) {
|
|
36
|
+
await this.get(`${BASE_PATH}/stream/set.cgi?stream_id=${streamId}&${paramName}=${value}`, undefined, options);
|
|
38
37
|
}
|
|
39
|
-
async isStreaming(
|
|
40
|
-
const response = await this.get(
|
|
38
|
+
async isStreaming(streamId, options) {
|
|
39
|
+
const response = await this.get(`${BASE_PATH}/get_streamstat.cgi?stream_id=${streamId}`, undefined, options);
|
|
41
40
|
return response.data.is_streaming === 1;
|
|
42
41
|
}
|
|
43
|
-
async deleteStream(
|
|
44
|
-
await this.get(
|
|
42
|
+
async deleteStream(streamId, options) {
|
|
43
|
+
await this.get(`${BASE_PATH}/stream/remove.cgi`, { stream_id: streamId }, options);
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
return this.get(
|
|
45
|
+
wsAuthorization(options) {
|
|
46
|
+
return this.get(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
|
|
48
47
|
}
|
|
49
|
-
async getUtcTime() {
|
|
50
|
-
return await this.get(
|
|
48
|
+
async getUtcTime(options) {
|
|
49
|
+
return await this.get(`${BASE_PATH}/get_utc_time.cgi`, undefined, options);
|
|
51
50
|
}
|
|
52
|
-
async get(path, parameters) {
|
|
53
|
-
const
|
|
51
|
+
async get(path, parameters, options) {
|
|
52
|
+
const agent = this.getClient(options?.proxyParams);
|
|
53
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
54
54
|
if (res.ok) {
|
|
55
55
|
return await res.json();
|
|
56
56
|
}
|
package/esm/CamSwitcherAPI.d.ts
CHANGED
|
@@ -1,46 +1,52 @@
|
|
|
1
|
-
import { IClient } from './internal/
|
|
1
|
+
import { IClient, TResponse } from './internal/types';
|
|
2
2
|
import { TAudioPushInfo, TOutputInfo, TStorageInfo, TStreamSaveList, TClipList, TStreamSaveLoadList, TClipSaveLoadList, TPlaylistSaveLoadList, TTrackerSaveList, TrackerSaveLoadList, TClipSaveList, TPlaylistSaveList, TCameraOptions, TGlobalAudioSettings, TSecondaryAudioSettings } from './types/CamSwitcherAPI';
|
|
3
|
-
import { TAudioChannel, TNetworkCamera, TStorageType } from './types/common';
|
|
4
|
-
|
|
3
|
+
import { TAudioChannel, THttpRequestOptions, TNetworkCamera, TProxyParams, TStorageType } from './types/common';
|
|
4
|
+
import { ProxyClient } from './internal/ProxyClient';
|
|
5
|
+
export declare class CamSwitcherAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
5
6
|
client: Client;
|
|
7
|
+
private CustomFormData;
|
|
6
8
|
private vapixAgent;
|
|
7
|
-
constructor(client: Client
|
|
9
|
+
constructor(client: Client, CustomFormData?: {
|
|
10
|
+
new (form?: HTMLFormElement | undefined, submitter?: HTMLElement | null | undefined): FormData;
|
|
11
|
+
prototype: FormData;
|
|
12
|
+
});
|
|
8
13
|
static getProxyUrlPath: () => string;
|
|
9
14
|
static getWsEventsUrlPath: () => string;
|
|
10
15
|
static getClipPreviewUrlPath: (id: string, storage: TStorageType) => string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
|
|
17
|
+
generateSilence(sampleRate: number, channels: TAudioChannel, options?: THttpRequestOptions): Promise<void>;
|
|
18
|
+
checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
|
|
19
|
+
getNetworkCameraList(options?: THttpRequestOptions): Promise<TNetworkCamera[]>;
|
|
20
|
+
getMaxFps(source: number, options?: THttpRequestOptions): Promise<number>;
|
|
21
|
+
getStorageInfo(options?: THttpRequestOptions): Promise<TStorageInfo[]>;
|
|
22
|
+
wsAuthorization(options?: THttpRequestOptions): Promise<string>;
|
|
23
|
+
getOutputInfo(options?: THttpRequestOptions): Promise<TOutputInfo>;
|
|
24
|
+
getAudioPushInfo(options?: THttpRequestOptions): Promise<TAudioPushInfo>;
|
|
25
|
+
getStreamSaveList(options?: THttpRequestOptions): Promise<TStreamSaveLoadList>;
|
|
26
|
+
getClipSaveList(options?: THttpRequestOptions): Promise<TClipSaveLoadList>;
|
|
27
|
+
getPlaylistSaveList(options?: THttpRequestOptions): Promise<TPlaylistSaveLoadList>;
|
|
28
|
+
getTrackerSaveList(options?: THttpRequestOptions): Promise<TrackerSaveLoadList>;
|
|
29
|
+
setStreamSaveList(data: TStreamSaveList, options?: THttpRequestOptions): Promise<boolean>;
|
|
30
|
+
setClipSaveList(data: TClipSaveList, options?: THttpRequestOptions): Promise<boolean>;
|
|
31
|
+
setPlaylistSaveList(data: TPlaylistSaveList, options?: THttpRequestOptions): Promise<boolean>;
|
|
32
|
+
setTrackerSaveList(data: TTrackerSaveList, options?: THttpRequestOptions): Promise<boolean>;
|
|
33
|
+
playlistSwitch(playlistName: string, options?: THttpRequestOptions): Promise<void>;
|
|
34
|
+
playlistQueuePush(playlistName: string, options?: THttpRequestOptions): Promise<void>;
|
|
35
|
+
playlistQueueClear(options?: THttpRequestOptions): Promise<void>;
|
|
36
|
+
playlistQueueList(options?: THttpRequestOptions): Promise<string[]>;
|
|
37
|
+
playlistQueuePlayNext(options?: THttpRequestOptions): Promise<void>;
|
|
38
|
+
addNewClip(file: any, clipType: 'video' | 'audio', storage: TStorageType, id: string, fileName?: string, options?: THttpRequestOptions): Promise<void>;
|
|
39
|
+
removeClip(id: string, storage: TStorageType, options?: THttpRequestOptions): Promise<any>;
|
|
40
|
+
getClipList(options?: THttpRequestOptions): Promise<TClipList>;
|
|
41
|
+
setCamSwitchOptions(data: TCameraOptions, cameraFWVersion: string, options?: THttpRequestOptions): Promise<boolean>;
|
|
42
|
+
setGlobalAudioSettings(settings: TGlobalAudioSettings, options?: THttpRequestOptions): Promise<boolean>;
|
|
43
|
+
setSecondaryAudioSettings(settings: TSecondaryAudioSettings, options?: THttpRequestOptions): Promise<boolean>;
|
|
44
|
+
setDefaultPlaylist(id: string, options?: THttpRequestOptions): Promise<boolean>;
|
|
45
|
+
setPermanentRtspUrlToken(token: string, options?: THttpRequestOptions): Promise<boolean>;
|
|
46
|
+
getCamSwitchOptions(options?: THttpRequestOptions): Promise<Partial<TCameraOptions>>;
|
|
47
|
+
getGlobalAudioSettings(options?: THttpRequestOptions): Promise<TGlobalAudioSettings>;
|
|
48
|
+
getSecondaryAudioSettings(options?: THttpRequestOptions): Promise<TSecondaryAudioSettings>;
|
|
49
|
+
getPermanentRtspUrlToken(options?: THttpRequestOptions): Promise<string>;
|
|
44
50
|
private get;
|
|
45
51
|
private set;
|
|
46
52
|
private setParamFromCameraJSON;
|