camstreamerlib 1.7.2 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CamOverlayAPI.d.ts +29 -8
- package/CamOverlayAPI.js +33 -28
- package/CameraVapix.js +1 -1
- package/HTTPRequest.d.ts +1 -1
- package/package.json +3 -3
package/CamOverlayAPI.d.ts
CHANGED
|
@@ -15,6 +15,27 @@ export declare type Field = {
|
|
|
15
15
|
text: string;
|
|
16
16
|
color?: string;
|
|
17
17
|
};
|
|
18
|
+
declare type Message = {
|
|
19
|
+
command: string;
|
|
20
|
+
params: any[];
|
|
21
|
+
};
|
|
22
|
+
declare type CairoResponse = {
|
|
23
|
+
message: string;
|
|
24
|
+
call_id: number;
|
|
25
|
+
};
|
|
26
|
+
declare type CairoCreateResponse = {
|
|
27
|
+
var: string;
|
|
28
|
+
call_id: number;
|
|
29
|
+
};
|
|
30
|
+
declare type UploadImageResponse = {
|
|
31
|
+
var: string;
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
call_id: number;
|
|
35
|
+
};
|
|
36
|
+
declare type Align = 'A_RIGHT' | 'A_LEFT' | 'A_CENTER';
|
|
37
|
+
declare type TextFit = 'TFM_SCALE' | 'TFM_TRUNCATE' | 'TFM_OVERFLOW';
|
|
38
|
+
declare type WriteTextParams = [string, string, number, number, number, number, Align, TextFit?];
|
|
18
39
|
declare type Service = {
|
|
19
40
|
id: number;
|
|
20
41
|
enabled: number;
|
|
@@ -42,14 +63,14 @@ export declare class CamOverlayAPI extends EventEmitter {
|
|
|
42
63
|
createService(): Promise<number>;
|
|
43
64
|
updateServices(servicesJson: ServiceJson): Promise<void>;
|
|
44
65
|
openWebsocket(digestHeader?: string): Promise<void>;
|
|
45
|
-
cairo(command: string, ...params: any[]): Promise<
|
|
46
|
-
writeText(...params:
|
|
47
|
-
uploadImageData(imgBuffer: Buffer): Promise<
|
|
48
|
-
uploadFontData(fontBuffer: Buffer): Promise<
|
|
49
|
-
showCairoImage(cairoImage:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
sendMessage(msgJson:
|
|
66
|
+
cairo(command: string, ...params: any[]): Promise<CairoResponse | CairoCreateResponse>;
|
|
67
|
+
writeText(...params: WriteTextParams): Promise<CairoResponse>;
|
|
68
|
+
uploadImageData(imgBuffer: Buffer): Promise<UploadImageResponse>;
|
|
69
|
+
uploadFontData(fontBuffer: Buffer): Promise<CairoCreateResponse>;
|
|
70
|
+
showCairoImage(cairoImage: string, posX: number, posY: number): Promise<CairoResponse>;
|
|
71
|
+
showCairoImageAbsolute(cairoImage: string, posX: number, posY: number, width: number, height: number): Promise<CairoResponse>;
|
|
72
|
+
removeImage(): Promise<CairoResponse>;
|
|
73
|
+
sendMessage(msgJson: Message): Promise<CairoResponse | CairoCreateResponse | UploadImageResponse>;
|
|
53
74
|
reportMsg(msg: string): void;
|
|
54
75
|
reportErr(err: Error): void;
|
|
55
76
|
reportClose(): void;
|
package/CamOverlayAPI.js
CHANGED
|
@@ -78,18 +78,13 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
if (service != null) {
|
|
81
|
-
if (service.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return service.id;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
return service.id;
|
|
89
|
-
}
|
|
81
|
+
if (service.camera == undefined || service.camera != this.camera) {
|
|
82
|
+
service.camera = this.camera;
|
|
83
|
+
yield this.updateServices(servicesJson);
|
|
84
|
+
return service.id;
|
|
90
85
|
}
|
|
91
86
|
else {
|
|
92
|
-
|
|
87
|
+
return service.id;
|
|
93
88
|
}
|
|
94
89
|
}
|
|
95
90
|
else {
|
|
@@ -174,16 +169,22 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
174
169
|
return this.sendMessage({ command: 'write_text', params: params });
|
|
175
170
|
}
|
|
176
171
|
uploadImageData(imgBuffer) {
|
|
177
|
-
return this.sendMessage({
|
|
172
|
+
return this.sendMessage({
|
|
173
|
+
command: 'upload_image_data',
|
|
174
|
+
params: [imgBuffer.toString('base64')],
|
|
175
|
+
});
|
|
178
176
|
}
|
|
179
177
|
uploadFontData(fontBuffer) {
|
|
180
|
-
return this.sendMessage({
|
|
178
|
+
return this.sendMessage({
|
|
179
|
+
command: 'upload_font_data',
|
|
180
|
+
params: [fontBuffer.toString('base64')],
|
|
181
|
+
});
|
|
181
182
|
}
|
|
182
183
|
showCairoImage(cairoImage, posX, posY) {
|
|
183
|
-
return this.sendMessage({
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
return this.sendMessage({
|
|
185
|
+
command: 'show_cairo_image',
|
|
186
|
+
params: [this.serviceID, cairoImage, posX, posY],
|
|
187
|
+
});
|
|
187
188
|
}
|
|
188
189
|
showCairoImageAbsolute(cairoImage, posX, posY, width, height) {
|
|
189
190
|
return this.sendMessage({
|
|
@@ -191,8 +192,11 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
191
192
|
params: [this.serviceID, cairoImage, -1.0 + (2.0 / width) * posX, -1.0 + (2.0 / height) * posY],
|
|
192
193
|
});
|
|
193
194
|
}
|
|
195
|
+
removeImage() {
|
|
196
|
+
return this.sendMessage({ command: 'remove_image', params: [this.serviceID] });
|
|
197
|
+
}
|
|
194
198
|
sendMessage(msgJson) {
|
|
195
|
-
|
|
199
|
+
return new Promise((resolve, reject) => {
|
|
196
200
|
try {
|
|
197
201
|
this.sendMessages[this.callId] = { resolve, reject };
|
|
198
202
|
msgJson['call_id'] = this.callId++;
|
|
@@ -202,7 +206,6 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
202
206
|
this.reportErr(new Error(`Send message error: ${err}`));
|
|
203
207
|
}
|
|
204
208
|
});
|
|
205
|
-
return promise;
|
|
206
209
|
}
|
|
207
210
|
reportMsg(msg) {
|
|
208
211
|
this.emit('msg', msg);
|
|
@@ -266,16 +269,18 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
266
269
|
}
|
|
267
270
|
setEnabled(enabled) {
|
|
268
271
|
return __awaiter(this, void 0, void 0, function* () {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
272
|
+
if ((yield this.isEnabled()) !== enabled) {
|
|
273
|
+
const value = enabled ? 1 : 0;
|
|
274
|
+
const path = encodeURI(`/local/camoverlay/api/enabled.cgi?id_${this.serviceID}=${value}`);
|
|
275
|
+
const options = {
|
|
276
|
+
method: 'POST',
|
|
277
|
+
host: this.ip,
|
|
278
|
+
port: this.port,
|
|
279
|
+
path: path,
|
|
280
|
+
auth: this.auth,
|
|
281
|
+
};
|
|
282
|
+
yield (0, HTTPRequest_1.httpRequest)(options, '');
|
|
283
|
+
}
|
|
279
284
|
});
|
|
280
285
|
}
|
|
281
286
|
isEnabled() {
|
package/CameraVapix.js
CHANGED
|
@@ -23,7 +23,7 @@ class CameraVapix extends eventemitter2_1.EventEmitter2 {
|
|
|
23
23
|
super();
|
|
24
24
|
this.rtsp = null;
|
|
25
25
|
this.ws = null;
|
|
26
|
-
this.protocol = (_a = options === null || options === void 0 ? void 0 : options.protocol) !== null && _a !== void 0 ? _a : '
|
|
26
|
+
this.protocol = (_a = options === null || options === void 0 ? void 0 : options.protocol) !== null && _a !== void 0 ? _a : 'http';
|
|
27
27
|
this.ip = (_b = options === null || options === void 0 ? void 0 : options.ip) !== null && _b !== void 0 ? _b : '127.0.0.1';
|
|
28
28
|
this.port = (_c = options === null || options === void 0 ? void 0 : options.port) !== null && _c !== void 0 ? _c : (this.protocol == 'http' ? 80 : 443);
|
|
29
29
|
this.auth = (_d = options === null || options === void 0 ? void 0 : options.auth) !== null && _d !== void 0 ? _d : '';
|
package/HTTPRequest.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "camstreamerlib",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.4",
|
|
4
4
|
"description": "Helper library for CamStreamer ACAP applications.",
|
|
5
5
|
"prettier": "@camstreamer/prettier-config",
|
|
6
6
|
"dependencies": {
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"eventemitter2": "^5.0.1",
|
|
9
9
|
"prettify-xml": "^1.2.0",
|
|
10
10
|
"ws": "^7.4.2",
|
|
11
|
-
"xml2js": "^0.4.19"
|
|
11
|
+
"xml2js": "^0.4.19",
|
|
12
|
+
"adm-zip": "^0.5.9"
|
|
12
13
|
},
|
|
13
14
|
"devDependencies": {
|
|
14
15
|
"@camstreamer/prettier-config": "^2.0.4",
|
|
15
16
|
"@types/jest": "^28.0.0",
|
|
16
17
|
"@types/node": "^18.0.6",
|
|
17
|
-
"adm-zip": "^0.5.9",
|
|
18
18
|
"typescript": "^4.7.4",
|
|
19
19
|
"ts-jest": "^28.0.0",
|
|
20
20
|
"ts-node": "^10.7.0",
|