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/cjs/VapixAPI.js
CHANGED
|
@@ -2,57 +2,67 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VapixAPI = void 0;
|
|
4
4
|
const prettifyXml = require("prettify-xml");
|
|
5
|
-
const
|
|
6
|
-
const common_1 = require("./internal/common");
|
|
5
|
+
const utils_1 = require("./internal/utils");
|
|
7
6
|
const VapixAPI_1 = require("./types/VapixAPI");
|
|
8
7
|
const errors_1 = require("./errors/errors");
|
|
9
8
|
const ProxyClient_1 = require("./internal/ProxyClient");
|
|
10
|
-
const utils_1 = require("./internal/utils");
|
|
11
9
|
const zod_1 = require("zod");
|
|
10
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
12
11
|
class VapixAPI {
|
|
13
12
|
client;
|
|
14
|
-
constructor(client
|
|
15
|
-
this.client =
|
|
13
|
+
constructor(client) {
|
|
14
|
+
this.client = client;
|
|
15
|
+
}
|
|
16
|
+
getClient(proxyParams) {
|
|
17
|
+
return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
|
|
16
18
|
}
|
|
17
|
-
async
|
|
19
|
+
async postUrlEncoded(path, parameters, headers, options) {
|
|
18
20
|
const data = (0, utils_1.paramToUrl)(parameters);
|
|
19
21
|
const head = { ...headers, 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
20
|
-
const
|
|
22
|
+
const agent = this.getClient(options?.proxyParams);
|
|
23
|
+
const res = await agent.post({ path, data, headers: head, timeout: options?.timeout });
|
|
21
24
|
if (!res.ok) {
|
|
22
|
-
throw new Error(await (0,
|
|
25
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
23
26
|
}
|
|
24
27
|
return res;
|
|
25
28
|
}
|
|
26
|
-
async postJson(
|
|
29
|
+
async postJson(path, jsonData, headers, options) {
|
|
27
30
|
const data = JSON.stringify(jsonData);
|
|
28
31
|
const head = { ...headers, 'Content-Type': 'application/json' };
|
|
29
|
-
const
|
|
32
|
+
const agent = this.getClient(options?.proxyParams);
|
|
33
|
+
const res = await agent.post({ path, data, headers: head, timeout: options?.timeout });
|
|
30
34
|
if (!res.ok) {
|
|
31
|
-
throw new Error(await (0,
|
|
35
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
32
36
|
}
|
|
33
37
|
return res;
|
|
34
38
|
}
|
|
35
|
-
async getCameraImage(
|
|
36
|
-
|
|
39
|
+
async getCameraImage(parameters, options) {
|
|
40
|
+
const agent = this.getClient(options?.proxyParams);
|
|
41
|
+
return await agent.get({ path: '/axis-cgi/jpg/image.cgi', parameters, timeout: options?.timeout });
|
|
37
42
|
}
|
|
38
|
-
async getEventDeclarations(
|
|
43
|
+
async getEventDeclarations(options) {
|
|
39
44
|
const data = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">' +
|
|
40
45
|
'<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
|
|
41
46
|
'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' +
|
|
42
47
|
'<GetEventInstances xmlns="http://www.axis.com/vapix/ws/event1"/>' +
|
|
43
48
|
'</s:Body>' +
|
|
44
49
|
'</s:Envelope>';
|
|
45
|
-
const
|
|
50
|
+
const agent = this.getClient(options?.proxyParams);
|
|
51
|
+
const res = await agent.post({
|
|
52
|
+
path: '/vapix/services',
|
|
53
|
+
data,
|
|
54
|
+
headers: { 'Content-Type': 'application/soap+xml' },
|
|
55
|
+
});
|
|
46
56
|
if (!res.ok) {
|
|
47
|
-
throw new Error(await (0,
|
|
57
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
48
58
|
}
|
|
49
59
|
const declarations = await res.text();
|
|
50
60
|
return prettifyXml(declarations);
|
|
51
61
|
}
|
|
52
|
-
async getSupportedAudioSampleRate(
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const res = await this.postJson(
|
|
62
|
+
async getSupportedAudioSampleRate(options) {
|
|
63
|
+
const path = '/axis-cgi/audio/streamingcapabilities.cgi';
|
|
64
|
+
const jsonData = { apiVersion: '1.0', method: 'list' };
|
|
65
|
+
const res = await this.postJson(path, jsonData, undefined, options);
|
|
56
66
|
const encoders = VapixAPI_1.audioSampleRatesResponseSchema.parse(await res.json()).data.encoders;
|
|
57
67
|
const data = encoders.aac ?? encoders.AAC ?? [];
|
|
58
68
|
return data.map((item) => {
|
|
@@ -62,7 +72,7 @@ class VapixAPI {
|
|
|
62
72
|
};
|
|
63
73
|
});
|
|
64
74
|
}
|
|
65
|
-
async performAutofocus(
|
|
75
|
+
async performAutofocus(options) {
|
|
66
76
|
try {
|
|
67
77
|
const data = {
|
|
68
78
|
apiVersion: '1',
|
|
@@ -75,24 +85,26 @@ class VapixAPI {
|
|
|
75
85
|
],
|
|
76
86
|
},
|
|
77
87
|
};
|
|
78
|
-
await this.postJson(
|
|
88
|
+
await this.postJson('/axis-cgi/opticscontrol.cgi', data, undefined, options);
|
|
79
89
|
}
|
|
80
90
|
catch (err) {
|
|
81
|
-
await this.
|
|
91
|
+
await this.postUrlEncoded('/axis-cgi/opticssetup.cgi', {
|
|
82
92
|
autofocus: 'perform',
|
|
83
93
|
source: '1',
|
|
84
|
-
});
|
|
94
|
+
}, undefined, options);
|
|
85
95
|
}
|
|
86
96
|
}
|
|
87
|
-
async checkSDCard(
|
|
88
|
-
const res = await this.
|
|
97
|
+
async checkSDCard(options) {
|
|
98
|
+
const res = await this.postUrlEncoded('/axis-cgi/disks/list.cgi', {
|
|
89
99
|
diskid: 'SD_DISK',
|
|
100
|
+
}, undefined, options);
|
|
101
|
+
const xmlText = await res.text();
|
|
102
|
+
const parser = new fast_xml_parser_1.XMLParser({
|
|
103
|
+
ignoreAttributes: false,
|
|
104
|
+
attributeNamePrefix: '',
|
|
105
|
+
allowBooleanAttributes: true,
|
|
90
106
|
});
|
|
91
|
-
const result =
|
|
92
|
-
ignoreAttrs: false,
|
|
93
|
-
mergeAttrs: true,
|
|
94
|
-
explicitArray: false,
|
|
95
|
-
});
|
|
107
|
+
const result = parser.parse(xmlText);
|
|
96
108
|
const data = result.root.disks.disk;
|
|
97
109
|
return {
|
|
98
110
|
totalSize: parseInt(data.totalsize),
|
|
@@ -100,53 +112,56 @@ class VapixAPI {
|
|
|
100
112
|
status: VapixAPI_1.sdCardWatchedStatuses.includes(data.status) ? data.status : 'disconnected',
|
|
101
113
|
};
|
|
102
114
|
}
|
|
103
|
-
mountSDCard(
|
|
104
|
-
return this._doSDCardMountAction('MOUNT',
|
|
115
|
+
mountSDCard(options) {
|
|
116
|
+
return this._doSDCardMountAction('MOUNT', options);
|
|
105
117
|
}
|
|
106
|
-
unmountSDCard(
|
|
107
|
-
return this._doSDCardMountAction('UNMOUNT',
|
|
118
|
+
unmountSDCard(options) {
|
|
119
|
+
return this._doSDCardMountAction('UNMOUNT', options);
|
|
108
120
|
}
|
|
109
|
-
async _doSDCardMountAction(action,
|
|
110
|
-
const res = await this.
|
|
121
|
+
async _doSDCardMountAction(action, options) {
|
|
122
|
+
const res = await this.postUrlEncoded('/axis-cgi/disks/mount.cgi', {
|
|
111
123
|
action: action,
|
|
112
124
|
diskid: 'SD_DISK',
|
|
125
|
+
}, undefined, options);
|
|
126
|
+
const textXml = await res.text();
|
|
127
|
+
const parser = new fast_xml_parser_1.XMLParser({
|
|
128
|
+
ignoreAttributes: false,
|
|
129
|
+
attributeNamePrefix: '',
|
|
130
|
+
allowBooleanAttributes: true,
|
|
113
131
|
});
|
|
114
|
-
const result =
|
|
115
|
-
ignoreAttrs: false,
|
|
116
|
-
mergeAttrs: true,
|
|
117
|
-
explicitArray: false,
|
|
118
|
-
});
|
|
132
|
+
const result = parser.parse(textXml);
|
|
119
133
|
const job = result.root.job;
|
|
120
134
|
if (job.result !== 'OK') {
|
|
121
|
-
throw new errors_1.SDCardActionError(action, await (0,
|
|
135
|
+
throw new errors_1.SDCardActionError(action, await (0, utils_1.responseStringify)(res));
|
|
122
136
|
}
|
|
123
137
|
return Number(job.jobid);
|
|
124
138
|
}
|
|
125
|
-
async fetchSDCardJobProgress(jobId,
|
|
126
|
-
const res = await this.
|
|
139
|
+
async fetchSDCardJobProgress(jobId, options) {
|
|
140
|
+
const res = await this.postUrlEncoded('/disks/job.cgi', {
|
|
127
141
|
jobid: String(jobId),
|
|
128
142
|
diskid: 'SD_DISK',
|
|
143
|
+
}, undefined, options);
|
|
144
|
+
const textXml = await res.text();
|
|
145
|
+
const parser = new fast_xml_parser_1.XMLParser({
|
|
146
|
+
ignoreAttributes: false,
|
|
147
|
+
attributeNamePrefix: '',
|
|
148
|
+
allowBooleanAttributes: true,
|
|
129
149
|
});
|
|
130
|
-
const
|
|
131
|
-
ignoreAttrs: false,
|
|
132
|
-
mergeAttrs: true,
|
|
133
|
-
explicitArray: false,
|
|
134
|
-
});
|
|
135
|
-
const job = result.root.job;
|
|
150
|
+
const job = parser.parse(textXml).root.job;
|
|
136
151
|
if (job.result !== 'OK') {
|
|
137
152
|
throw new errors_1.SDCardJobError();
|
|
138
153
|
}
|
|
139
154
|
return Number(job.progress);
|
|
140
155
|
}
|
|
141
|
-
downloadCameraReport(
|
|
142
|
-
return this.
|
|
156
|
+
downloadCameraReport(options) {
|
|
157
|
+
return this.postUrlEncoded('/axis-cgi/serverreport.cgi', { mode: 'text' }, undefined, options);
|
|
143
158
|
}
|
|
144
|
-
getSystemLog(
|
|
145
|
-
return this.
|
|
159
|
+
getSystemLog(options) {
|
|
160
|
+
return this.postUrlEncoded('/axis-cgi/admin/systemlog.cgi', undefined, undefined, options);
|
|
146
161
|
}
|
|
147
|
-
async getMaxFps(channel,
|
|
162
|
+
async getMaxFps(channel, options) {
|
|
148
163
|
const data = { apiVersion: '1.0', method: 'getCaptureModes' };
|
|
149
|
-
const res = await this.postJson(
|
|
164
|
+
const res = await this.postJson('/axis-cgi/capturemode.cgi', data, undefined, options);
|
|
150
165
|
const response = VapixAPI_1.maxFpsResponseSchema.parse(await res.json());
|
|
151
166
|
const channels = response.data;
|
|
152
167
|
if (channels === undefined) {
|
|
@@ -161,82 +176,97 @@ class VapixAPI {
|
|
|
161
176
|
if (captureMode === undefined) {
|
|
162
177
|
throw new errors_1.MaxFPSError('CAPTURE_MODE_NOT_FOUND');
|
|
163
178
|
}
|
|
164
|
-
if ((0,
|
|
179
|
+
if ((0, utils_1.isNullish)(captureMode.maxFPS)) {
|
|
165
180
|
throw new errors_1.MaxFPSError('FPS_NOT_SPECIFIED');
|
|
166
181
|
}
|
|
167
182
|
return captureMode.maxFPS;
|
|
168
183
|
}
|
|
169
|
-
async getTimezone(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
184
|
+
async getTimezone(options) {
|
|
185
|
+
try {
|
|
186
|
+
const agent = this.getClient(options?.proxyParams);
|
|
187
|
+
const resV2 = await agent.get({ path: '/config/rest/time/v2/timeZone', timeout: options?.timeout });
|
|
188
|
+
if (!resV2.ok) {
|
|
189
|
+
throw new Error(await (0, utils_1.responseStringify)(resV2));
|
|
190
|
+
}
|
|
191
|
+
const json = await resV2.json();
|
|
192
|
+
const data = VapixAPI_1.timeZoneSchema.parse(json);
|
|
193
|
+
if (data.status === 'error') {
|
|
194
|
+
throw new Error(data.error.message);
|
|
195
|
+
}
|
|
196
|
+
return data.data.activeTimeZone;
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : JSON.stringify(error));
|
|
200
|
+
console.warn('Falling back to deprecated time API v1');
|
|
201
|
+
}
|
|
202
|
+
const data = await this.getDateTimeInfo(options);
|
|
203
|
+
if (data.data.timeZone === undefined) {
|
|
204
|
+
throw new Error('Time zone not setup on the device');
|
|
205
|
+
}
|
|
206
|
+
return data.data.timeZone;
|
|
173
207
|
}
|
|
174
|
-
async getDateTimeInfo(
|
|
208
|
+
async getDateTimeInfo(options) {
|
|
175
209
|
const data = { apiVersion: '1.0', method: 'getDateTimeInfo' };
|
|
176
|
-
const res = await this.postJson(
|
|
210
|
+
const res = await this.postJson('/axis-cgi/time.cgi', data, undefined, options);
|
|
177
211
|
return VapixAPI_1.dateTimeinfoSchema.parse(await res.json());
|
|
178
212
|
}
|
|
179
|
-
async getDevicesSettings(
|
|
213
|
+
async getDevicesSettings(options) {
|
|
180
214
|
const data = { apiVersion: '1.0', method: 'getDevicesSettings' };
|
|
181
|
-
const res = await this.postJson(
|
|
215
|
+
const res = await this.postJson('/axis-cgi/audiodevicecontrol.cgi', data, undefined, options);
|
|
182
216
|
const result = VapixAPI_1.audioDeviceRequestSchema.parse(await res.json());
|
|
183
|
-
return result.devices.map((device) => ({
|
|
217
|
+
return result.data.devices.map((device) => ({
|
|
184
218
|
...device,
|
|
185
219
|
inputs: (device.inputs || []).sort((a, b) => a.id.localeCompare(b.id)),
|
|
186
220
|
outputs: (device.outputs || []).sort((a, b) => a.id.localeCompare(b.id)),
|
|
187
221
|
}));
|
|
188
222
|
}
|
|
189
|
-
async fetchRemoteDeviceInfo(payload,
|
|
190
|
-
const res = await this.postJson(
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
mergeAttrs: true,
|
|
194
|
-
explicitArray: false,
|
|
195
|
-
});
|
|
196
|
-
if ((0, common_1.isNullish)(result.body.data)) {
|
|
223
|
+
async fetchRemoteDeviceInfo(payload, options) {
|
|
224
|
+
const res = await this.postJson('/axis-cgi/basicdeviceinfo.cgi', payload, undefined, options);
|
|
225
|
+
const json = await res.json();
|
|
226
|
+
if ((0, utils_1.isNullish)(json.data)) {
|
|
197
227
|
throw new errors_1.NoDeviceInfoError();
|
|
198
228
|
}
|
|
199
|
-
return
|
|
229
|
+
return json.data;
|
|
200
230
|
}
|
|
201
|
-
async getHeaders(
|
|
231
|
+
async getHeaders(options) {
|
|
202
232
|
const data = { apiVersion: '1.0', method: 'list' };
|
|
203
|
-
const res = await this.postJson(
|
|
233
|
+
const res = await this.postJson('/axis-cgi/customhttpheader.cgi', data, undefined, options);
|
|
204
234
|
return zod_1.z.object({ data: zod_1.z.record(zod_1.z.string()) }).parse(await res.json()).data;
|
|
205
235
|
}
|
|
206
|
-
async setHeaders(headers,
|
|
236
|
+
async setHeaders(headers, options) {
|
|
207
237
|
const data = { apiVersion: '1.0', method: 'set', params: headers };
|
|
208
|
-
return this.postJson(
|
|
238
|
+
return this.postJson('/axis-cgi/customhttpheader.cgi', data, undefined, options);
|
|
209
239
|
}
|
|
210
|
-
async getParameter(paramNames,
|
|
211
|
-
const response = await this.
|
|
240
|
+
async getParameter(paramNames, options) {
|
|
241
|
+
const response = await this.postUrlEncoded('/axis-cgi/param.cgi', {
|
|
212
242
|
action: 'list',
|
|
213
243
|
group: (0, utils_1.arrayToUrl)(paramNames),
|
|
214
|
-
});
|
|
215
|
-
return parseParameters(await response.text());
|
|
244
|
+
}, undefined, options);
|
|
245
|
+
return VapixAPI.parseParameters(await response.text());
|
|
216
246
|
}
|
|
217
|
-
async setParameter(params,
|
|
218
|
-
const res = await this.
|
|
247
|
+
async setParameter(params, options) {
|
|
248
|
+
const res = await this.postUrlEncoded('/axis-cgi/param.cgi', {
|
|
219
249
|
...params,
|
|
220
250
|
action: 'update',
|
|
221
|
-
});
|
|
251
|
+
}, undefined, options);
|
|
222
252
|
const responseText = await res.text();
|
|
223
253
|
if (responseText.startsWith('# Error')) {
|
|
224
254
|
throw new Error(responseText);
|
|
225
255
|
}
|
|
226
256
|
return true;
|
|
227
257
|
}
|
|
228
|
-
async getGuardTourList(
|
|
258
|
+
async getGuardTourList(options) {
|
|
229
259
|
const gTourList = new Array();
|
|
230
|
-
const response = await this.getParameter('GuardTour',
|
|
260
|
+
const response = await this.getParameter('GuardTour', options);
|
|
231
261
|
for (let i = 0; i < 20; i++) {
|
|
232
262
|
const gTourBaseName = 'root.GuardTour.G' + i;
|
|
233
263
|
if (gTourBaseName + '.CamNbr' in response) {
|
|
234
264
|
const gTour = {
|
|
235
265
|
id: gTourBaseName,
|
|
236
266
|
camNbr: response[gTourBaseName + '.CamNbr'],
|
|
237
|
-
name: response[gTourBaseName + '.Name'],
|
|
267
|
+
name: response[gTourBaseName + '.Name'] ?? 'Guard Tour ' + (i + 1),
|
|
238
268
|
randomEnabled: response[gTourBaseName + '.RandomEnabled'],
|
|
239
|
-
running: response[gTourBaseName + '.Running'],
|
|
269
|
+
running: response[gTourBaseName + '.Running'] ?? 'no',
|
|
240
270
|
timeBetweenSequences: response[gTourBaseName + '.TimeBetweenSequences'],
|
|
241
271
|
tour: [],
|
|
242
272
|
};
|
|
@@ -261,16 +291,16 @@ class VapixAPI {
|
|
|
261
291
|
}
|
|
262
292
|
return gTourList;
|
|
263
293
|
}
|
|
264
|
-
setGuardTourEnabled(guardTourID, enable,
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
return this.setParameter(
|
|
294
|
+
setGuardTourEnabled(guardTourID, enable, options) {
|
|
295
|
+
const params = {};
|
|
296
|
+
params[guardTourID + '.Running'] = enable ? 'yes' : 'no';
|
|
297
|
+
return this.setParameter(params, options);
|
|
268
298
|
}
|
|
269
|
-
async getPTZPresetList(channel,
|
|
270
|
-
const res = await this.
|
|
299
|
+
async getPTZPresetList(channel, options) {
|
|
300
|
+
const res = await this.postUrlEncoded('/axis-cgi/com/ptz.cgi', {
|
|
271
301
|
query: 'presetposcam',
|
|
272
302
|
camera: channel.toString(),
|
|
273
|
-
});
|
|
303
|
+
}, undefined, options);
|
|
274
304
|
const text = await res.text();
|
|
275
305
|
const lines = text.split(/[\r\n]/);
|
|
276
306
|
const positions = [];
|
|
@@ -285,174 +315,233 @@ class VapixAPI {
|
|
|
285
315
|
}
|
|
286
316
|
return positions;
|
|
287
317
|
}
|
|
288
|
-
async listPTZ(camera,
|
|
318
|
+
async listPTZ(camera, options) {
|
|
289
319
|
const url = `/axis-cgi/com/ptz.cgi`;
|
|
290
|
-
const response = await this.
|
|
320
|
+
const response = await this.postUrlEncoded(url, {
|
|
291
321
|
camera,
|
|
292
322
|
query: 'presetposcamdata',
|
|
293
323
|
format: 'json',
|
|
294
|
-
});
|
|
295
|
-
|
|
324
|
+
}, undefined, options);
|
|
325
|
+
const text = await response.text();
|
|
326
|
+
if (text === '') {
|
|
327
|
+
throw new errors_1.PtzNotSupportedError();
|
|
328
|
+
}
|
|
329
|
+
return VapixAPI.parseCameraPtzResponse(text)[camera] ?? [];
|
|
296
330
|
}
|
|
297
|
-
async listPtzVideoSourceOverview(
|
|
298
|
-
const response = await this.
|
|
331
|
+
async listPtzVideoSourceOverview(options) {
|
|
332
|
+
const response = await this.postUrlEncoded('/axis-cgi/com/ptz.cgi', {
|
|
299
333
|
query: 'presetposall',
|
|
300
334
|
format: 'json',
|
|
301
|
-
});
|
|
302
|
-
const
|
|
335
|
+
}, undefined, options);
|
|
336
|
+
const text = await response.text();
|
|
337
|
+
if (text === '') {
|
|
338
|
+
throw new errors_1.PtzNotSupportedError();
|
|
339
|
+
}
|
|
340
|
+
const data = VapixAPI.parseCameraPtzResponse(text);
|
|
303
341
|
const res = {};
|
|
304
|
-
Object.keys(data)
|
|
305
|
-
|
|
342
|
+
Object.keys(data)
|
|
343
|
+
.map(Number)
|
|
344
|
+
.forEach((camera) => {
|
|
345
|
+
if (data[camera] !== undefined) {
|
|
346
|
+
res[camera - 1] = data[camera]?.map(({ data: itemData, ...d }) => d);
|
|
347
|
+
}
|
|
306
348
|
});
|
|
307
349
|
return res;
|
|
308
350
|
}
|
|
309
|
-
goToPreset(channel, presetName,
|
|
310
|
-
return this.
|
|
351
|
+
goToPreset(channel, presetName, options) {
|
|
352
|
+
return this.postUrlEncoded('/axis-cgi/com/ptz.cgi', {
|
|
311
353
|
camera: channel.toString(),
|
|
312
354
|
gotoserverpresetname: presetName,
|
|
313
|
-
});
|
|
355
|
+
}, undefined, options);
|
|
314
356
|
}
|
|
315
|
-
async getPtzPosition(camera,
|
|
316
|
-
const res = await this.
|
|
357
|
+
async getPtzPosition(camera, options) {
|
|
358
|
+
const res = await this.postUrlEncoded('/axis-cgi/com/ptz.cgi', {
|
|
317
359
|
query: 'position',
|
|
318
360
|
camera: camera.toString(),
|
|
319
|
-
});
|
|
320
|
-
const params = parseParameters(await res.text());
|
|
361
|
+
}, undefined, options);
|
|
362
|
+
const params = VapixAPI.parseParameters(await res.text());
|
|
321
363
|
return {
|
|
322
364
|
pan: Number(params.pan),
|
|
323
365
|
tilt: Number(params.tilt),
|
|
324
366
|
zoom: Number(params.zoom),
|
|
325
367
|
};
|
|
326
368
|
}
|
|
327
|
-
async
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
369
|
+
async getPorts(options) {
|
|
370
|
+
const res = await this.postJson('/axis-cgi/io/portmanagement.cgi', {
|
|
371
|
+
apiVersion: '1.0',
|
|
372
|
+
context: '',
|
|
373
|
+
method: 'getPorts',
|
|
374
|
+
}, undefined, options);
|
|
375
|
+
const portResponseParsed = await VapixAPI_1.getPortsResponseSchema.parse(res.json());
|
|
376
|
+
return portResponseParsed.data.items;
|
|
377
|
+
}
|
|
378
|
+
async setPorts(ports, options) {
|
|
379
|
+
await this.postJson('/axis-cgi/io/portmanagement.cgi', {
|
|
380
|
+
apiVersion: '1.0',
|
|
381
|
+
context: '',
|
|
382
|
+
method: 'setPorts',
|
|
383
|
+
params: { ports },
|
|
384
|
+
}, undefined, options);
|
|
385
|
+
}
|
|
386
|
+
async setPortStateSequence(port, sequence, options) {
|
|
387
|
+
await this.postJson('/axis-cgi/io/portmanagement.cgi', {
|
|
388
|
+
apiVersion: '1.0',
|
|
389
|
+
context: '',
|
|
390
|
+
method: 'setStateSequence',
|
|
391
|
+
params: { port, sequence },
|
|
392
|
+
}, undefined, options);
|
|
393
|
+
}
|
|
394
|
+
async getApplicationList(options) {
|
|
395
|
+
const agent = this.getClient(options?.proxyParams);
|
|
396
|
+
const res = await agent.get({ path: '/axis-cgi/applications/list.cgi', timeout: options?.timeout });
|
|
336
397
|
const xml = await res.text();
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
398
|
+
const parser = new fast_xml_parser_1.XMLParser({
|
|
399
|
+
ignoreAttributes: false,
|
|
400
|
+
attributeNamePrefix: '',
|
|
401
|
+
allowBooleanAttributes: true,
|
|
402
|
+
});
|
|
403
|
+
const result = parser.parse(xml);
|
|
404
|
+
let apps = result.reply.application ?? [];
|
|
405
|
+
if (!Array.isArray(apps)) {
|
|
406
|
+
apps = [apps];
|
|
344
407
|
}
|
|
345
|
-
return apps
|
|
408
|
+
return apps.map((app) => {
|
|
409
|
+
return {
|
|
410
|
+
...app,
|
|
411
|
+
appId: VapixAPI_1.APP_IDS.find((id) => id.toLowerCase() === app.Name.toLowerCase()) ?? null,
|
|
412
|
+
};
|
|
413
|
+
});
|
|
346
414
|
}
|
|
347
|
-
async startApplication(applicationID,
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
415
|
+
async startApplication(applicationID, options) {
|
|
416
|
+
const agent = this.getClient(options?.proxyParams);
|
|
417
|
+
const res = await agent.get({
|
|
418
|
+
path: '/axis-cgi/applications/control.cgi',
|
|
419
|
+
parameters: {
|
|
420
|
+
package: applicationID.toLowerCase(),
|
|
421
|
+
action: 'start',
|
|
422
|
+
},
|
|
423
|
+
timeout: options?.timeout,
|
|
351
424
|
});
|
|
352
425
|
const text = (await res.text()).trim().toLowerCase();
|
|
353
426
|
if (text !== 'ok' && !(text.startsWith('error:') && text.substring(7) === '6')) {
|
|
354
|
-
throw new errors_1.ApplicationAPIError('START', await (0,
|
|
427
|
+
throw new errors_1.ApplicationAPIError('START', await (0, utils_1.responseStringify)(res));
|
|
355
428
|
}
|
|
356
429
|
}
|
|
357
|
-
async restartApplication(applicationID,
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
|
|
430
|
+
async restartApplication(applicationID, options) {
|
|
431
|
+
const agent = this.getClient(options?.proxyParams);
|
|
432
|
+
const res = await agent.get({
|
|
433
|
+
path: '/axis-cgi/applications/control.cgi',
|
|
434
|
+
parameters: {
|
|
435
|
+
package: applicationID.toLowerCase(),
|
|
436
|
+
action: 'restart',
|
|
437
|
+
},
|
|
438
|
+
timeout: options?.timeout,
|
|
361
439
|
});
|
|
362
440
|
const text = (await res.text()).trim().toLowerCase();
|
|
363
441
|
if (text !== 'ok') {
|
|
364
|
-
throw new errors_1.ApplicationAPIError('RESTART', await (0,
|
|
442
|
+
throw new errors_1.ApplicationAPIError('RESTART', await (0, utils_1.responseStringify)(res));
|
|
365
443
|
}
|
|
366
444
|
}
|
|
367
|
-
async stopApplication(applicationID,
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
445
|
+
async stopApplication(applicationID, options) {
|
|
446
|
+
const agent = this.getClient(options?.proxyParams);
|
|
447
|
+
const res = await agent.get({
|
|
448
|
+
path: '/axis-cgi/applications/control.cgi',
|
|
449
|
+
parameters: {
|
|
450
|
+
package: applicationID.toLowerCase(),
|
|
451
|
+
action: 'stop',
|
|
452
|
+
},
|
|
453
|
+
timeout: options?.timeout,
|
|
371
454
|
});
|
|
372
455
|
const text = (await res.text()).trim().toLowerCase();
|
|
373
456
|
if (text !== 'ok' && !(text.startsWith('error:') && text.substring(7) === '6')) {
|
|
374
|
-
throw new errors_1.ApplicationAPIError('STOP', await (0,
|
|
457
|
+
throw new errors_1.ApplicationAPIError('STOP', await (0, utils_1.responseStringify)(res));
|
|
375
458
|
}
|
|
376
459
|
}
|
|
377
|
-
async installApplication(data, fileName) {
|
|
460
|
+
async installApplication(data, fileName, options) {
|
|
378
461
|
const formData = new FormData();
|
|
379
462
|
formData.append('packfil', data, fileName);
|
|
380
|
-
const
|
|
381
|
-
|
|
463
|
+
const agent = this.getClient(options?.proxyParams);
|
|
464
|
+
const res = await agent.post({
|
|
465
|
+
path: '/axis-cgi/applications/upload.cgi',
|
|
466
|
+
data: formData,
|
|
467
|
+
headers: {
|
|
468
|
+
contentType: 'application/octet-stream',
|
|
469
|
+
},
|
|
470
|
+
timeout: options?.timeout ?? 120000,
|
|
382
471
|
});
|
|
383
472
|
if (!res.ok) {
|
|
384
|
-
throw new Error(await (0,
|
|
473
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
385
474
|
}
|
|
386
475
|
const text = await res.text();
|
|
387
476
|
if (text.length > 5) {
|
|
388
477
|
throw new Error('installing error: ' + text);
|
|
389
478
|
}
|
|
390
479
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
params[paramName] = paramValue;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
return params;
|
|
408
|
-
};
|
|
409
|
-
const parseCameraPtzResponse = (response) => {
|
|
410
|
-
const json = JSON.parse(response);
|
|
411
|
-
const parsed = {};
|
|
412
|
-
Object.keys(json).forEach((key) => {
|
|
413
|
-
if (!key.startsWith('Camera ')) {
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
const camera = Number(key.replace('Camera ', ''));
|
|
417
|
-
if (json[key].presets !== undefined) {
|
|
418
|
-
parsed[camera] = parsePtz(json[key].presets);
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
|
-
return parsed;
|
|
422
|
-
};
|
|
423
|
-
const parsePtz = (parsed) => {
|
|
424
|
-
const res = [];
|
|
425
|
-
parsed.forEach((value) => {
|
|
426
|
-
const delimiterPos = value.indexOf('=');
|
|
427
|
-
if (delimiterPos === -1) {
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
if (!value.startsWith('presetposno')) {
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
const id = Number(value.substring(11, delimiterPos));
|
|
434
|
-
if (Number.isNaN(id)) {
|
|
435
|
-
return;
|
|
480
|
+
static parseParameters = (response) => {
|
|
481
|
+
const params = {};
|
|
482
|
+
const lines = response.split(/[\r\n]/);
|
|
483
|
+
for (const line of lines) {
|
|
484
|
+
if (line.length === 0 || line.substring(0, 7) === '# Error') {
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
const delimiterPos = line.indexOf('=');
|
|
488
|
+
if (delimiterPos !== -1) {
|
|
489
|
+
const paramName = line.substring(0, delimiterPos).replace('root.', '');
|
|
490
|
+
const paramValue = line.substring(delimiterPos + 1);
|
|
491
|
+
params[paramName] = paramValue;
|
|
492
|
+
}
|
|
436
493
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
494
|
+
return params;
|
|
495
|
+
};
|
|
496
|
+
static parseCameraPtzResponse = (response) => {
|
|
497
|
+
const json = JSON.parse(response);
|
|
498
|
+
const parsed = {};
|
|
499
|
+
Object.keys(json).forEach((key) => {
|
|
500
|
+
if (!key.startsWith('Camera ')) {
|
|
501
|
+
return;
|
|
444
502
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
503
|
+
const camera = Number(key.replace('Camera ', ''));
|
|
504
|
+
if (json[key].presets !== undefined) {
|
|
505
|
+
parsed[camera] = VapixAPI.parsePtz(json[key].presets);
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
return parsed;
|
|
509
|
+
};
|
|
510
|
+
static parsePtz = (parsed) => {
|
|
511
|
+
const res = [];
|
|
512
|
+
parsed.forEach((value) => {
|
|
513
|
+
const delimiterPos = value.indexOf('=');
|
|
514
|
+
if (delimiterPos === -1) {
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
if (!value.startsWith('presetposno')) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const id = Number(value.substring(11, delimiterPos));
|
|
521
|
+
if (Number.isNaN(id)) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
const data = value.substring(delimiterPos + 1).split(':');
|
|
525
|
+
const getValue = (valueName) => {
|
|
526
|
+
for (const d of data) {
|
|
527
|
+
const p = d.split('=');
|
|
528
|
+
if (p[0] === valueName) {
|
|
529
|
+
return Number(p[1]);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return 0;
|
|
533
|
+
};
|
|
534
|
+
res.push({
|
|
535
|
+
id,
|
|
536
|
+
name: data[0] ?? 'Preset ' + id,
|
|
537
|
+
data: {
|
|
538
|
+
pan: getValue('pan'),
|
|
539
|
+
tilt: getValue('tilt'),
|
|
540
|
+
zoom: getValue('zoom'),
|
|
541
|
+
},
|
|
542
|
+
});
|
|
455
543
|
});
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
544
|
+
return res;
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
exports.VapixAPI = VapixAPI;
|