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
package/README.md
CHANGED
|
@@ -21,19 +21,25 @@ npm install camstreamerlib
|
|
|
21
21
|
|
|
22
22
|
- [VapixAPI](doc/VapixAPI.md) is a module to access Axis camera VAPIX interface.
|
|
23
23
|
|
|
24
|
+
- [VapixEvents](doc/VapixEvents.md) is a module which allows receiving camera events from the VAPIX API.
|
|
25
|
+
|
|
24
26
|
- [CamStreamerAPI](doc/CamStreamerAPI.md) is a module for easy control of video streaming in the CamStreamer ACAP application (RTMP, HLS, SRT and MPEG-TS protocols).
|
|
25
27
|
|
|
26
|
-
- [CamOverlayAPI](doc/CamOverlayAPI.md) is a module to access CamOverlay
|
|
28
|
+
- [CamOverlayAPI](doc/CamOverlayAPI.md) is a module to access CamOverlay API.
|
|
27
29
|
|
|
28
30
|
- [CamOverlayDrawingAPI](doc/CamOverlayDrawingAPI.md) is a module for easy control of CamOverlay drawing API. For more details on supported video overlay drawing functions see https://camstreamer.com/camoverlay-api1
|
|
29
31
|
|
|
30
32
|
- [CamOverlayPainter/](doc/CamOverlayPainter.md) contains three modules which makes easier to use CamOverlayDrawingAPI.
|
|
31
33
|
|
|
34
|
+
- [CamScripterAPI](doc/CamScripterAPI.md) is a module to access CamScripter API.
|
|
35
|
+
|
|
32
36
|
- [CamScripterAPICameraEventsGenerator](doc/CamScripterAPICameraEventsGenerator.md) is a module which allows generating events on an Axis camera. These events can be used for triggers in the Axis camera rule engine (events/actions). It is also an easy way how to integrate events and metadata in VMS systems which support Axis camera events.
|
|
33
37
|
|
|
38
|
+
- [CamSwitcherAPI](doc/CamSwitcherAPI.md) is a module to access CamSwitcher API.
|
|
39
|
+
|
|
34
40
|
- [CamSwitcherEvents](doc/CamSwitcherEvents.md) is a module which allows receiving events from CamSwitcher ACAP application.
|
|
35
41
|
|
|
36
|
-
- [
|
|
42
|
+
- [PlaneTrackerAPI](doc/PlaneTrackerAPI.md) is a module to access PlaneTracker API.
|
|
37
43
|
|
|
38
44
|
- [GenetecAgent](doc/GenetecAgent.md) is a module which allows receiving and sending data to Genetec VMS.
|
|
39
45
|
|
package/cjs/CamOverlayAPI.d.ts
CHANGED
|
@@ -1,31 +1,53 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { TNetworkCamera } from './types/common';
|
|
5
|
-
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { IClient, TBlobResponse, TResponse } from './internal/types';
|
|
4
|
+
import { THttpRequestOptions, TProxyParams, TNetworkCamera } from './types/common';
|
|
5
|
+
import { ProxyClient } from './internal/ProxyClient';
|
|
6
|
+
import { ImageType, TCoordinates, TFile, TFileList, TFileType, TStorage, TStorageDataList, TWidget } from './types/CamOverlayAPI/CamOverlayAPI';
|
|
7
|
+
import { TField } from './types/CamOverlayAPI';
|
|
8
|
+
export declare const allowedWidgetNames: {
|
|
9
|
+
readonly accuweather: "accuweather";
|
|
10
|
+
readonly infoticker: "infoticker";
|
|
11
|
+
readonly customGraphics: "customGraphics";
|
|
12
|
+
readonly ptzCompass: "ptzCompass";
|
|
13
|
+
readonly images: "images";
|
|
14
|
+
readonly ptz: "ptz";
|
|
15
|
+
readonly pip: "pip";
|
|
16
|
+
readonly screenSharing: "screenSharing";
|
|
17
|
+
readonly web_camera: "web_camera";
|
|
18
|
+
};
|
|
19
|
+
export declare class CamOverlayAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
6
20
|
private client;
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
constructor(client: Client);
|
|
22
|
+
static getBasePath: () => string;
|
|
23
|
+
static getProxyPath: () => string;
|
|
24
|
+
static getFilePreviewPath: (path: string) => string;
|
|
25
|
+
getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
|
|
26
|
+
checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
|
|
27
|
+
getNetworkCameraList(options?: THttpRequestOptions): Promise<TNetworkCamera[]>;
|
|
28
|
+
wsAuthorization(options?: THttpRequestOptions): Promise<string>;
|
|
29
|
+
getMjpegStreamImage(mjpegUrl: string, options?: THttpRequestOptions): Promise<TBlobResponse<Client>>;
|
|
30
|
+
listFiles(fileType: TFileType, options?: THttpRequestOptions): Promise<TFileList>;
|
|
31
|
+
uploadFile(fileType: TFileType, formData: FormData, storage: TStorage, options?: THttpRequestOptions): Promise<void>;
|
|
32
|
+
removeFile(fileType: TFileType, fileParams: TFile, options?: THttpRequestOptions): Promise<void>;
|
|
33
|
+
getFileStorage(fileType: TFileType, options?: THttpRequestOptions): Promise<TStorageDataList>;
|
|
34
|
+
getFilePreviewFromCamera(path: string, options?: THttpRequestOptions): Promise<TBlobResponse<Client>>;
|
|
35
|
+
updateInfoticker(serviceId: number, text: string, options?: THttpRequestOptions): Promise<void>;
|
|
36
|
+
setEnabled(serviceId: number, enabled: boolean, options?: THttpRequestOptions): Promise<void>;
|
|
37
|
+
isEnabled(serviceId: number, options?: THttpRequestOptions): Promise<boolean>;
|
|
38
|
+
getSingleWidget(serviceId: number, options?: THttpRequestOptions): Promise<TWidget>;
|
|
39
|
+
getWidgets(options?: THttpRequestOptions): Promise<TWidget[]>;
|
|
40
|
+
updateSingleWidget(widget: TWidget, options?: THttpRequestOptions): Promise<void>;
|
|
41
|
+
updateWidgets(widgets: TWidget[], options?: THttpRequestOptions): Promise<void>;
|
|
42
|
+
updateCGText(serviceId: number, fields: TField[], options?: THttpRequestOptions): Promise<void>;
|
|
43
|
+
updateCGImagePos(serviceId: number, coordinates?: TCoordinates, x?: number, y?: number, options?: THttpRequestOptions): Promise<void>;
|
|
44
|
+
updateCGImage(serviceId: number, path: string, coordinates?: TCoordinates, x?: number, y?: number, options?: THttpRequestOptions): Promise<void>;
|
|
45
|
+
updateCGImageFromData(serviceId: number, imageType: ImageType, imageData: Buffer, coordinates?: TCoordinates, x?: number, y?: number, options?: THttpRequestOptions): Promise<void>;
|
|
27
46
|
private promiseCGUpdate;
|
|
28
|
-
private
|
|
29
|
-
private
|
|
47
|
+
private _get;
|
|
48
|
+
private _post;
|
|
49
|
+
private _getBlob;
|
|
30
50
|
private parseBlobResponse;
|
|
51
|
+
private _postUrlEncoded;
|
|
52
|
+
private _postJsonEncoded;
|
|
31
53
|
}
|
package/cjs/CamOverlayAPI.js
CHANGED
|
@@ -1,100 +1,155 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CamOverlayAPI = void 0;
|
|
4
|
-
const
|
|
5
|
-
const DefaultClient_1 = require("./node/DefaultClient");
|
|
6
|
-
const CamOverlayAPI_1 = require("./types/CamOverlayAPI");
|
|
3
|
+
exports.CamOverlayAPI = exports.allowedWidgetNames = void 0;
|
|
4
|
+
const utils_1 = require("./internal/utils");
|
|
7
5
|
const errors_1 = require("./errors/errors");
|
|
8
|
-
const
|
|
6
|
+
const common_1 = require("./types/common");
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const ProxyClient_1 = require("./internal/ProxyClient");
|
|
9
|
+
const CamOverlayAPI_1 = require("./types/CamOverlayAPI/CamOverlayAPI");
|
|
10
|
+
exports.allowedWidgetNames = {
|
|
11
|
+
accuweather: 'accuweather',
|
|
12
|
+
infoticker: 'infoticker',
|
|
13
|
+
customGraphics: 'customGraphics',
|
|
14
|
+
ptzCompass: 'ptzCompass',
|
|
15
|
+
images: 'images',
|
|
16
|
+
ptz: 'ptz',
|
|
17
|
+
pip: 'pip',
|
|
18
|
+
screenSharing: 'screenSharing',
|
|
19
|
+
web_camera: 'web_camera',
|
|
20
|
+
};
|
|
21
|
+
const BASE_PATH = '/local/camoverlay/api';
|
|
9
22
|
class CamOverlayAPI {
|
|
10
23
|
client;
|
|
11
|
-
constructor(
|
|
12
|
-
|
|
13
|
-
this.client = options;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
this.client = new DefaultClient_1.DefaultClient(options);
|
|
17
|
-
}
|
|
24
|
+
constructor(client) {
|
|
25
|
+
this.client = client;
|
|
18
26
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
static getBasePath = () => BASE_PATH;
|
|
28
|
+
static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
29
|
+
static getFilePreviewPath = (path) => `${BASE_PATH}/image.cgi?path=${encodeURIComponent(path)}`;
|
|
30
|
+
getClient(proxyParams) {
|
|
31
|
+
return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
|
|
22
32
|
}
|
|
23
|
-
async
|
|
24
|
-
const response = await this.
|
|
25
|
-
return
|
|
33
|
+
async checkCameraTime(options) {
|
|
34
|
+
const response = await this._get({ path: `${BASE_PATH}/camera_time.cgi` }, options);
|
|
35
|
+
return zod_1.z.boolean().parse(response.state);
|
|
26
36
|
}
|
|
27
|
-
async
|
|
28
|
-
const response = await this.
|
|
29
|
-
return response.
|
|
37
|
+
async getNetworkCameraList(options) {
|
|
38
|
+
const response = await this._get({ path: `${BASE_PATH}/network_camera_list.cgi` }, options);
|
|
39
|
+
return common_1.networkCameraListSchema.parse(response.camera_list);
|
|
30
40
|
}
|
|
31
|
-
async
|
|
32
|
-
const
|
|
33
|
-
return
|
|
41
|
+
async wsAuthorization(options) {
|
|
42
|
+
const response = await this._get({ path: `${BASE_PATH}/ws_authorization.cgi` }, options);
|
|
43
|
+
return CamOverlayAPI_1.WSResponseSchema.parse(response).data;
|
|
34
44
|
}
|
|
35
|
-
async
|
|
36
|
-
|
|
45
|
+
async getMjpegStreamImage(mjpegUrl, options) {
|
|
46
|
+
return await this._getBlob({
|
|
47
|
+
path: `${BASE_PATH}/fetch_mjpeg_image.cgi?mjpeg_url=${encodeURIComponent(decodeURIComponent(mjpegUrl))}`,
|
|
48
|
+
}, options);
|
|
49
|
+
}
|
|
50
|
+
async listFiles(fileType, options) {
|
|
51
|
+
const files = await this._get({
|
|
52
|
+
path: `${BASE_PATH}/upload_${fileType}.cgi`,
|
|
53
|
+
parameters: {
|
|
54
|
+
action: 'list',
|
|
55
|
+
},
|
|
56
|
+
}, options);
|
|
37
57
|
return CamOverlayAPI_1.fileListSchema.parse(files.list);
|
|
38
58
|
}
|
|
39
|
-
async uploadFile(fileType,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
59
|
+
async uploadFile(fileType, formData, storage, options) {
|
|
60
|
+
await this._post({
|
|
61
|
+
path: `${BASE_PATH}/upload_${fileType}.cgi`,
|
|
62
|
+
data: formData,
|
|
63
|
+
parameters: {
|
|
64
|
+
action: 'upload',
|
|
65
|
+
storage: storage,
|
|
66
|
+
},
|
|
67
|
+
}, options);
|
|
68
|
+
}
|
|
69
|
+
async removeFile(fileType, fileParams, options) {
|
|
70
|
+
const path = `${BASE_PATH}/upload_${fileType}.cgi`;
|
|
71
|
+
await this._postUrlEncoded(path, {
|
|
72
|
+
action: 'remove',
|
|
73
|
+
...fileParams,
|
|
74
|
+
}, undefined, options);
|
|
45
75
|
}
|
|
46
|
-
async
|
|
47
|
-
const
|
|
48
|
-
|
|
76
|
+
async getFileStorage(fileType, options) {
|
|
77
|
+
const data = await this._get({
|
|
78
|
+
path: `${BASE_PATH}/upload_${fileType}.cgi`,
|
|
79
|
+
parameters: {
|
|
80
|
+
action: 'get_storage',
|
|
81
|
+
},
|
|
82
|
+
}, options);
|
|
83
|
+
if (data.code !== 200) {
|
|
84
|
+
throw new Error('Error occured while fetching file storage data');
|
|
85
|
+
}
|
|
86
|
+
return CamOverlayAPI_1.storageDataListSchema.parse(data.list);
|
|
49
87
|
}
|
|
50
|
-
async
|
|
51
|
-
|
|
52
|
-
return CamOverlayAPI_1.storageSchema.parse(data);
|
|
88
|
+
async getFilePreviewFromCamera(path, options) {
|
|
89
|
+
return await this._getBlob({ path: CamOverlayAPI.getFilePreviewPath(path) }, options);
|
|
53
90
|
}
|
|
54
|
-
async updateInfoticker(
|
|
55
|
-
await this.
|
|
91
|
+
async updateInfoticker(serviceId, text, options) {
|
|
92
|
+
await this._get({ path: `${BASE_PATH}/infoticker.cgi?service_id=${serviceId}&text=${text}` }, options);
|
|
56
93
|
}
|
|
57
|
-
async setEnabled(
|
|
58
|
-
await this.
|
|
94
|
+
async setEnabled(serviceId, enabled, options) {
|
|
95
|
+
await this._post({ path: `${BASE_PATH}/enabled.cgi?id_${serviceId}=${enabled ? 1 : 0}`, data: '' }, options);
|
|
59
96
|
}
|
|
60
|
-
async isEnabled(
|
|
61
|
-
const
|
|
97
|
+
async isEnabled(serviceId, options) {
|
|
98
|
+
const agent = this.getClient(options?.proxyParams);
|
|
99
|
+
const res = await agent.get({ path: `${BASE_PATH}/services.cgi?action=get`, timeout: options?.timeout });
|
|
62
100
|
if (res.ok) {
|
|
63
101
|
const data = JSON.parse(await res.text());
|
|
64
102
|
for (const service of data.services) {
|
|
65
|
-
if (service.id ===
|
|
103
|
+
if (service.id === serviceId) {
|
|
66
104
|
return service.enabled === 1;
|
|
67
105
|
}
|
|
68
106
|
}
|
|
69
107
|
throw new errors_1.ServiceNotFoundError();
|
|
70
108
|
}
|
|
71
109
|
else {
|
|
72
|
-
throw new Error(await (0,
|
|
110
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
73
111
|
}
|
|
74
112
|
}
|
|
75
|
-
async
|
|
76
|
-
const data = await this.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
113
|
+
async getSingleWidget(serviceId, options) {
|
|
114
|
+
const data = await this._get({
|
|
115
|
+
path: `${BASE_PATH}/services.cgi`,
|
|
116
|
+
parameters: {
|
|
117
|
+
action: 'get',
|
|
118
|
+
service_id: serviceId.toString(),
|
|
119
|
+
},
|
|
120
|
+
}, options);
|
|
121
|
+
return CamOverlayAPI_1.widgetsSchema.parse(data);
|
|
81
122
|
}
|
|
82
|
-
async
|
|
83
|
-
const
|
|
84
|
-
|
|
123
|
+
async getWidgets(options) {
|
|
124
|
+
const widgetList = await this._get({
|
|
125
|
+
path: `${BASE_PATH}/services.cgi`,
|
|
126
|
+
parameters: {
|
|
127
|
+
action: 'get',
|
|
128
|
+
},
|
|
129
|
+
}, options);
|
|
130
|
+
const widgets = widgetList.services;
|
|
131
|
+
widgets.forEach((widget) => {
|
|
132
|
+
const parsedWidget = CamOverlayAPI_1.widgetsSchema.safeParse(widget);
|
|
133
|
+
if (!parsedWidget.success) {
|
|
134
|
+
console.warn(`[SERVICE SCHEMA MISMATCH]: Service ${widget.name} (${widget.id}) does not match the current schema, or is a hidden service.`);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return widgets;
|
|
85
138
|
}
|
|
86
|
-
async
|
|
87
|
-
const path =
|
|
88
|
-
await this.
|
|
139
|
+
async updateSingleWidget(widget, options) {
|
|
140
|
+
const path = `${BASE_PATH}/services.cgi`;
|
|
141
|
+
await this._postJsonEncoded(path, JSON.stringify(widget), {
|
|
89
142
|
action: 'set',
|
|
90
|
-
service_id:
|
|
91
|
-
});
|
|
143
|
+
service_id: widget.id.toString(),
|
|
144
|
+
}, undefined, options);
|
|
92
145
|
}
|
|
93
|
-
async
|
|
94
|
-
const path =
|
|
95
|
-
await this.
|
|
146
|
+
async updateWidgets(widgets, options) {
|
|
147
|
+
const path = `${BASE_PATH}/services.cgi`;
|
|
148
|
+
await this._postJsonEncoded(path, JSON.stringify({ services: widgets }), {
|
|
149
|
+
action: 'set',
|
|
150
|
+
}, undefined, options);
|
|
96
151
|
}
|
|
97
|
-
updateCGText(
|
|
152
|
+
updateCGText(serviceId, fields, options) {
|
|
98
153
|
const params = {};
|
|
99
154
|
for (const field of fields) {
|
|
100
155
|
const name = field.field_name;
|
|
@@ -103,74 +158,102 @@ class CamOverlayAPI {
|
|
|
103
158
|
params[`${name}_color`] = field.color;
|
|
104
159
|
}
|
|
105
160
|
}
|
|
106
|
-
return this.promiseCGUpdate(
|
|
161
|
+
return this.promiseCGUpdate(serviceId, 'update_text', params, undefined, undefined, options);
|
|
107
162
|
}
|
|
108
|
-
updateCGImagePos(
|
|
163
|
+
updateCGImagePos(serviceId, coordinates = '', x = 0, y = 0, options) {
|
|
109
164
|
const params = {
|
|
110
165
|
coord_system: coordinates,
|
|
111
166
|
pos_x: x,
|
|
112
167
|
pos_y: y,
|
|
113
168
|
};
|
|
114
|
-
return this.promiseCGUpdate(
|
|
169
|
+
return this.promiseCGUpdate(serviceId, 'update_image', params, undefined, undefined, options);
|
|
115
170
|
}
|
|
116
|
-
updateCGImage(
|
|
171
|
+
updateCGImage(serviceId, path, coordinates = '', x = 0, y = 0, options) {
|
|
117
172
|
const params = {
|
|
118
173
|
coord_system: coordinates,
|
|
119
174
|
pos_x: x,
|
|
120
175
|
pos_y: y,
|
|
121
176
|
image: path,
|
|
122
177
|
};
|
|
123
|
-
return this.promiseCGUpdate(
|
|
178
|
+
return this.promiseCGUpdate(serviceId, 'update_image', params, undefined, undefined, options);
|
|
124
179
|
}
|
|
125
|
-
updateCGImageFromData(
|
|
180
|
+
updateCGImageFromData(serviceId, imageType, imageData, coordinates = '', x = 0, y = 0, options) {
|
|
126
181
|
const contentType = imageType === CamOverlayAPI_1.ImageType.PNG ? 'image/png' : 'image/jpeg';
|
|
127
182
|
const params = {
|
|
128
183
|
coord_system: coordinates,
|
|
129
184
|
pos_x: x,
|
|
130
185
|
pos_y: y,
|
|
131
186
|
};
|
|
132
|
-
return this.promiseCGUpdate(
|
|
187
|
+
return this.promiseCGUpdate(serviceId, 'update_image', params, contentType, imageData, options);
|
|
133
188
|
}
|
|
134
|
-
async promiseCGUpdate(
|
|
135
|
-
const path =
|
|
189
|
+
async promiseCGUpdate(serviceId, action, params = {}, contentType, data, options) {
|
|
190
|
+
const path = `${BASE_PATH}/customGraphics.cgi`;
|
|
136
191
|
let headers = {};
|
|
137
192
|
if (contentType !== undefined && data) {
|
|
138
193
|
headers = { 'Content-Type': contentType };
|
|
139
194
|
}
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
195
|
+
const agent = this.getClient(options?.proxyParams);
|
|
196
|
+
const res = await agent.post({
|
|
197
|
+
path,
|
|
198
|
+
data: data ?? '',
|
|
199
|
+
parameters: {
|
|
200
|
+
action: action,
|
|
201
|
+
service_id: serviceId.toString(),
|
|
202
|
+
...params,
|
|
203
|
+
},
|
|
204
|
+
headers,
|
|
205
|
+
timeout: options?.timeout,
|
|
206
|
+
});
|
|
145
207
|
if (!res.ok) {
|
|
146
|
-
throw new Error(await (0,
|
|
208
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
147
209
|
}
|
|
148
210
|
}
|
|
149
|
-
async
|
|
150
|
-
const
|
|
211
|
+
async _get(params, options) {
|
|
212
|
+
const agent = this.getClient(options?.proxyParams);
|
|
213
|
+
const res = await agent.get({ ...params, timeout: options?.timeout });
|
|
151
214
|
if (res.ok) {
|
|
152
|
-
return await res.json();
|
|
215
|
+
return (await res.json());
|
|
153
216
|
}
|
|
154
217
|
else {
|
|
155
|
-
throw new Error(await (0,
|
|
218
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
156
219
|
}
|
|
157
220
|
}
|
|
158
|
-
async
|
|
159
|
-
const
|
|
221
|
+
async _post(params, options) {
|
|
222
|
+
const agent = this.getClient(options?.proxyParams);
|
|
223
|
+
const res = await agent.post({ ...params, timeout: options?.timeout });
|
|
160
224
|
if (res.ok) {
|
|
161
|
-
return await res.json();
|
|
225
|
+
return (await res.json());
|
|
162
226
|
}
|
|
163
227
|
else {
|
|
164
|
-
throw new Error(await (0,
|
|
228
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async _getBlob(params, options) {
|
|
232
|
+
const agent = this.getClient(options?.proxyParams);
|
|
233
|
+
const res = await agent.get({ ...params, timeout: options?.timeout });
|
|
234
|
+
if (res.ok) {
|
|
235
|
+
return await this.parseBlobResponse(res);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
165
239
|
}
|
|
166
240
|
}
|
|
167
241
|
async parseBlobResponse(response) {
|
|
168
242
|
try {
|
|
169
|
-
return await response.blob();
|
|
243
|
+
return (await response.blob());
|
|
170
244
|
}
|
|
171
245
|
catch (err) {
|
|
172
246
|
throw new errors_1.ParsingBlobError(err);
|
|
173
247
|
}
|
|
174
248
|
}
|
|
249
|
+
async _postUrlEncoded(path, params, headers, options) {
|
|
250
|
+
const data = (0, utils_1.paramToUrl)(params);
|
|
251
|
+
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
252
|
+
return this._post({ path, data, headers: { ...baseHeaders, ...headers } }, options);
|
|
253
|
+
}
|
|
254
|
+
async _postJsonEncoded(path, data, parameters, headers, options) {
|
|
255
|
+
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
256
|
+
return this._post({ path, data, parameters, headers: { ...baseHeaders, ...headers } }, options);
|
|
257
|
+
}
|
|
175
258
|
}
|
|
176
259
|
exports.CamOverlayAPI = CamOverlayAPI;
|
|
@@ -1,53 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
3
4
|
import * as EventEmitter from 'events';
|
|
4
|
-
import {
|
|
5
|
-
export type CamOverlayDrawingOptions = WsOptions & {
|
|
6
|
-
camera?: number | number[];
|
|
7
|
-
zIndex?: number;
|
|
8
|
-
};
|
|
9
|
-
export type TCairoResponse = {
|
|
10
|
-
message: string;
|
|
11
|
-
call_id: number;
|
|
12
|
-
};
|
|
13
|
-
export type TCairoCreateResponse = {
|
|
14
|
-
var: string;
|
|
15
|
-
call_id: number;
|
|
16
|
-
};
|
|
17
|
-
export type TUploadImageResponse = {
|
|
18
|
-
var: string;
|
|
19
|
-
width: number;
|
|
20
|
-
height: number;
|
|
21
|
-
call_id: number;
|
|
22
|
-
};
|
|
23
|
-
export type TErrorResponse = {
|
|
24
|
-
error: string;
|
|
25
|
-
call_id?: number;
|
|
26
|
-
};
|
|
27
|
-
export type TService = {
|
|
28
|
-
id: number;
|
|
29
|
-
enabled: number;
|
|
30
|
-
schedule: string;
|
|
31
|
-
name: string;
|
|
32
|
-
identifier: string;
|
|
33
|
-
cameraList: number[];
|
|
34
|
-
};
|
|
35
|
-
export type TServiceList = {
|
|
36
|
-
services: TService[];
|
|
37
|
-
};
|
|
38
|
-
export type TAlign = 'A_RIGHT' | 'A_LEFT' | 'A_CENTER';
|
|
39
|
-
export type TextFit = 'TFM_SCALE' | 'TFM_TRUNCATE' | 'TFM_OVERFLOW';
|
|
40
|
-
export type TWriteTextParams = [string, string, number, number, number, number, TAlign, TextFit?];
|
|
41
|
-
export interface CamOverlayDrawingAPI {
|
|
42
|
-
on(event: 'open', listener: () => void): this;
|
|
43
|
-
on(event: 'close', listener: () => void): this;
|
|
44
|
-
on(event: 'error', listener: (err: Error) => void): this;
|
|
45
|
-
on(event: 'message', listener: (msg: string) => void): this;
|
|
46
|
-
emit(event: 'open'): boolean;
|
|
47
|
-
emit(event: 'close'): boolean;
|
|
48
|
-
emit(event: 'error', err: Error): boolean;
|
|
49
|
-
emit(event: 'message', msg: string): boolean;
|
|
50
|
-
}
|
|
5
|
+
import { CamOverlayDrawingOptions, TCairoCreateResponse, TCairoResponse, TUploadImageResponse, TWriteTextParams } from './types/CamOverlayDrawingAPI';
|
|
51
6
|
export declare class CamOverlayDrawingAPI extends EventEmitter {
|
|
52
7
|
private tls;
|
|
53
8
|
private tlsInsecure;
|
|
@@ -124,10 +124,10 @@ class CamOverlayDrawingAPI extends EventEmitter {
|
|
|
124
124
|
}
|
|
125
125
|
if (dataJSON.call_id !== undefined) {
|
|
126
126
|
if (errorResponse !== undefined) {
|
|
127
|
-
this.sendMessages[dataJSON.call_id]
|
|
127
|
+
this.sendMessages[dataJSON.call_id]?.reject(new Error(errorResponse.error));
|
|
128
128
|
}
|
|
129
129
|
else {
|
|
130
|
-
this.sendMessages[dataJSON.call_id]
|
|
130
|
+
this.sendMessages[dataJSON.call_id]?.resolve(dataJSON);
|
|
131
131
|
}
|
|
132
132
|
delete this.sendMessages[dataJSON.call_id];
|
|
133
133
|
}
|
|
@@ -197,6 +197,9 @@ class CamOverlayDrawingAPI extends EventEmitter {
|
|
|
197
197
|
const now = Date.now();
|
|
198
198
|
for (const callId in this.sendMessages) {
|
|
199
199
|
const msg = this.sendMessages[callId];
|
|
200
|
+
if (!msg) {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
200
203
|
if (now - msg.sentTimestamp > 10000) {
|
|
201
204
|
reconnect = true;
|
|
202
205
|
msg.reject(new Error('Message timeout'));
|
|
@@ -223,7 +226,7 @@ class CamOverlayDrawingAPI extends EventEmitter {
|
|
|
223
226
|
}
|
|
224
227
|
reportClose() {
|
|
225
228
|
for (const callId in this.sendMessages) {
|
|
226
|
-
this.sendMessages[callId]
|
|
229
|
+
this.sendMessages[callId]?.reject(new Error('Connection lost'));
|
|
227
230
|
}
|
|
228
231
|
this.sendMessages = {};
|
|
229
232
|
this.emit('close');
|
|
@@ -1,42 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { CamOverlayDrawingAPI
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type TTmf = 'TFM_OVERFLOW' | 'TFM_SCALE' | 'TFM_TRUNCATE';
|
|
8
|
-
export type TObjectFitType = 'fill' | 'fit' | 'none';
|
|
9
|
-
export type TFrameOptions = {
|
|
10
|
-
enabled?: boolean;
|
|
11
|
-
x: number;
|
|
12
|
-
y: number;
|
|
13
|
-
width: number;
|
|
14
|
-
height: number;
|
|
15
|
-
text?: string;
|
|
16
|
-
fontColor?: TRgb;
|
|
17
|
-
font?: string;
|
|
18
|
-
bgColor?: TRgba;
|
|
19
|
-
bgImage?: string;
|
|
20
|
-
bgType?: TObjectFitType;
|
|
21
|
-
borderRadius?: number;
|
|
22
|
-
borderWidth?: number;
|
|
23
|
-
borderColor?: TRgba;
|
|
24
|
-
customDraw?: TDrawingCallback;
|
|
25
|
-
layer?: number;
|
|
26
|
-
};
|
|
27
|
-
export type TFrameInfo = {
|
|
28
|
-
width: number;
|
|
29
|
-
height: number;
|
|
30
|
-
};
|
|
31
|
-
export type TDrawingCallback = (cod: CamOverlayDrawingAPI, cairo: string, info: TFrameInfo) => Promise<void>;
|
|
32
|
-
export interface Frame {
|
|
33
|
-
on(event: 'open', listener: () => void): this;
|
|
34
|
-
on(event: 'close', listener: () => void): this;
|
|
35
|
-
on(event: 'layoutChanged', listener: () => void): this;
|
|
36
|
-
emit(event: 'open'): boolean;
|
|
37
|
-
emit(event: 'close'): boolean;
|
|
38
|
-
emit(event: 'layoutChanged'): boolean;
|
|
39
|
-
}
|
|
3
|
+
import { CamOverlayDrawingAPI } from '../CamOverlayDrawingAPI';
|
|
4
|
+
import { TAlign, TCairoCreateResponse, TUploadImageResponse } from '../types/CamOverlayDrawingAPI';
|
|
5
|
+
import { ResourceManager } from './ResourceManager';
|
|
6
|
+
import { TBg, TBorder, TDrawingCallback, TFrame, TFrameOptions, TObjectFitType, TRgb, TRgba, TText, TTmf } from '../types/CamOverlayPainter';
|
|
40
7
|
export declare class Frame extends EventEmitter {
|
|
41
8
|
protected enabled: boolean;
|
|
42
9
|
protected posX: number;
|
|
@@ -64,17 +31,21 @@ export declare class Frame extends EventEmitter {
|
|
|
64
31
|
disable(): void;
|
|
65
32
|
setFramePosition(x: number, y: number): void;
|
|
66
33
|
setFrameSize(width: number, height: number): void;
|
|
34
|
+
getFrameInfo(): TFrame;
|
|
67
35
|
setText(text: string, align: TAlign, textType?: TTmf, fontColor?: TRgb): void;
|
|
68
36
|
setFontColor(fontColor: TRgb): void;
|
|
69
37
|
setFont(fontName: string): void;
|
|
70
38
|
setFontData(fontData: TCairoCreateResponse): void;
|
|
39
|
+
getTextInfo(): TText;
|
|
71
40
|
setBgColor(color: TRgba): void;
|
|
72
41
|
setBgImage(imageName: string, type?: TObjectFitType): void;
|
|
73
42
|
setBgImageData(imageData: TUploadImageResponse, type?: TObjectFitType): void;
|
|
74
43
|
setBgType(type: TObjectFitType): void;
|
|
44
|
+
getBgInfo(): TBg;
|
|
75
45
|
setBorderRadius(radius: number): void;
|
|
76
46
|
setBorderWidth(width: number): void;
|
|
77
47
|
setBorderColor(color: TRgba): void;
|
|
48
|
+
getBorderInfo(): TBorder;
|
|
78
49
|
setCustomDraw(customDraw: TDrawingCallback): void;
|
|
79
50
|
resetFont(): void;
|
|
80
51
|
resetBgColor(): void;
|