camstreamerlib 1.7.3 → 1.7.5
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 +41 -38
- package/CameraVapix.js +1 -1
- package/HTTPRequest.d.ts +1 -1
- package/package.json +1 -1
package/CamOverlayAPI.d.ts
CHANGED
|
@@ -15,6 +15,27 @@ export declare type Field = {
|
|
|
15
15
|
text: string;
|
|
16
16
|
color?: string;
|
|
17
17
|
};
|
|
18
|
+
export declare type Message = {
|
|
19
|
+
command: string;
|
|
20
|
+
params: any[];
|
|
21
|
+
};
|
|
22
|
+
export declare type CairoResponse = {
|
|
23
|
+
message: string;
|
|
24
|
+
call_id: number;
|
|
25
|
+
};
|
|
26
|
+
export declare type CairoCreateResponse = {
|
|
27
|
+
var: string;
|
|
28
|
+
call_id: number;
|
|
29
|
+
};
|
|
30
|
+
export declare type UploadImageResponse = {
|
|
31
|
+
var: string;
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
call_id: number;
|
|
35
|
+
};
|
|
36
|
+
export declare type Align = 'A_RIGHT' | 'A_LEFT' | 'A_CENTER';
|
|
37
|
+
export declare type TextFit = 'TFM_SCALE' | 'TFM_TRUNCATE' | 'TFM_OVERFLOW';
|
|
38
|
+
export 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
|
@@ -32,18 +32,15 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
32
32
|
}
|
|
33
33
|
connect() {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
|
|
35
|
+
try {
|
|
36
|
+
if (this.serviceID == -1) {
|
|
37
|
+
this.serviceID = yield this.createService();
|
|
38
|
+
}
|
|
36
39
|
yield this.openWebsocket();
|
|
40
|
+
this.emit('open');
|
|
37
41
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
let id = yield this.createService();
|
|
41
|
-
this.serviceID = id;
|
|
42
|
-
yield this.openWebsocket();
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
this.reportErr(err);
|
|
46
|
-
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
this.reportErr(err);
|
|
47
44
|
}
|
|
48
45
|
});
|
|
49
46
|
}
|
|
@@ -78,18 +75,13 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
77
|
if (service != null) {
|
|
81
|
-
if (service.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return service.id;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
return service.id;
|
|
89
|
-
}
|
|
78
|
+
if (service.camera == undefined || service.camera != this.camera) {
|
|
79
|
+
service.camera = this.camera;
|
|
80
|
+
yield this.updateServices(servicesJson);
|
|
81
|
+
return service.id;
|
|
90
82
|
}
|
|
91
83
|
else {
|
|
92
|
-
|
|
84
|
+
return service.id;
|
|
93
85
|
}
|
|
94
86
|
}
|
|
95
87
|
else {
|
|
@@ -174,16 +166,22 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
174
166
|
return this.sendMessage({ command: 'write_text', params: params });
|
|
175
167
|
}
|
|
176
168
|
uploadImageData(imgBuffer) {
|
|
177
|
-
return this.sendMessage({
|
|
169
|
+
return this.sendMessage({
|
|
170
|
+
command: 'upload_image_data',
|
|
171
|
+
params: [imgBuffer.toString('base64')],
|
|
172
|
+
});
|
|
178
173
|
}
|
|
179
174
|
uploadFontData(fontBuffer) {
|
|
180
|
-
return this.sendMessage({
|
|
175
|
+
return this.sendMessage({
|
|
176
|
+
command: 'upload_font_data',
|
|
177
|
+
params: [fontBuffer.toString('base64')],
|
|
178
|
+
});
|
|
181
179
|
}
|
|
182
180
|
showCairoImage(cairoImage, posX, posY) {
|
|
183
|
-
return this.sendMessage({
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
181
|
+
return this.sendMessage({
|
|
182
|
+
command: 'show_cairo_image',
|
|
183
|
+
params: [this.serviceID, cairoImage, posX, posY],
|
|
184
|
+
});
|
|
187
185
|
}
|
|
188
186
|
showCairoImageAbsolute(cairoImage, posX, posY, width, height) {
|
|
189
187
|
return this.sendMessage({
|
|
@@ -191,8 +189,11 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
191
189
|
params: [this.serviceID, cairoImage, -1.0 + (2.0 / width) * posX, -1.0 + (2.0 / height) * posY],
|
|
192
190
|
});
|
|
193
191
|
}
|
|
192
|
+
removeImage() {
|
|
193
|
+
return this.sendMessage({ command: 'remove_image', params: [this.serviceID] });
|
|
194
|
+
}
|
|
194
195
|
sendMessage(msgJson) {
|
|
195
|
-
|
|
196
|
+
return new Promise((resolve, reject) => {
|
|
196
197
|
try {
|
|
197
198
|
this.sendMessages[this.callId] = { resolve, reject };
|
|
198
199
|
msgJson['call_id'] = this.callId++;
|
|
@@ -202,7 +203,6 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
202
203
|
this.reportErr(new Error(`Send message error: ${err}`));
|
|
203
204
|
}
|
|
204
205
|
});
|
|
205
|
-
return promise;
|
|
206
206
|
}
|
|
207
207
|
reportMsg(msg) {
|
|
208
208
|
this.emit('msg', msg);
|
|
@@ -211,6 +211,7 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
211
211
|
var _a;
|
|
212
212
|
(_a = this.ws) === null || _a === void 0 ? void 0 : _a.terminate();
|
|
213
213
|
this.emit('error', err);
|
|
214
|
+
this.emit('close');
|
|
214
215
|
}
|
|
215
216
|
reportClose() {
|
|
216
217
|
this.emit('close');
|
|
@@ -266,16 +267,18 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
266
267
|
}
|
|
267
268
|
setEnabled(enabled) {
|
|
268
269
|
return __awaiter(this, void 0, void 0, function* () {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
270
|
+
if ((yield this.isEnabled()) !== enabled) {
|
|
271
|
+
const value = enabled ? 1 : 0;
|
|
272
|
+
const path = encodeURI(`/local/camoverlay/api/enabled.cgi?id_${this.serviceID}=${value}`);
|
|
273
|
+
const options = {
|
|
274
|
+
method: 'POST',
|
|
275
|
+
host: this.ip,
|
|
276
|
+
port: this.port,
|
|
277
|
+
path: path,
|
|
278
|
+
auth: this.auth,
|
|
279
|
+
};
|
|
280
|
+
yield (0, HTTPRequest_1.httpRequest)(options, '');
|
|
281
|
+
}
|
|
279
282
|
});
|
|
280
283
|
}
|
|
281
284
|
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