camstreamerlib 4.0.0-beta.29 → 4.0.0-beta.30
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 +6 -2
- package/cjs/CamOverlayAPI.d.ts +38 -615
- package/cjs/CamOverlayAPI.js +128 -104
- package/cjs/CamOverlayDrawingAPI.d.ts +2 -47
- package/cjs/CamOverlayPainter/Frame.d.ts +8 -37
- package/cjs/CamOverlayPainter/Frame.js +33 -0
- package/cjs/CamOverlayPainter/Painter.d.ts +5 -10
- package/cjs/CamOverlayPainter/Painter.js +2 -4
- package/cjs/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/cjs/CamOverlayPainter/ResourceManager.js +2 -1
- package/cjs/CamScripterAPI.d.ts +12 -12
- package/cjs/CamScripterAPI.js +33 -27
- package/cjs/CamStreamerAPI.d.ts +11 -9
- package/cjs/CamStreamerAPI.js +28 -22
- package/cjs/CamSwitcherAPI.d.ts +35 -34
- package/cjs/CamSwitcherAPI.js +94 -82
- package/cjs/PlaneTrackerAPI.d.ts +30 -36
- package/cjs/PlaneTrackerAPI.js +132 -71
- package/cjs/VapixAPI.d.ts +43 -40
- package/cjs/VapixAPI.js +205 -183
- package/cjs/events/AxisCameraStationEvents.d.ts +5 -5
- package/cjs/events/AxisCameraStationEvents.js +17 -12
- package/cjs/events/GenetecAgent.d.ts +2 -0
- package/cjs/events/GenetecAgent.js +15 -4
- package/cjs/index.d.ts +7 -1
- package/cjs/index.js +12 -2
- package/cjs/internal/ProxyClient.d.ts +7 -8
- package/cjs/internal/ProxyClient.js +25 -31
- package/cjs/internal/types.d.ts +16 -9
- package/cjs/internal/utils.d.ts +1 -2
- package/cjs/internal/utils.js +1 -5
- package/cjs/node/DefaultClient.d.ts +3 -5
- package/cjs/node/DefaultClient.js +10 -14
- package/cjs/node/HttpRequestSender.d.ts +1 -0
- package/cjs/node/HttpRequestSender.js +13 -3
- package/cjs/node/WsClient.d.ts +1 -0
- package/cjs/node/index.d.ts +2 -0
- package/cjs/node/index.js +18 -1
- package/cjs/{models/CamOverlayAPI/widgetsSchema.d.ts → types/CamOverlayAPI/CamOverlayAPI.d.ts} +625 -375
- package/cjs/{models/CamOverlayAPI/widgetCommonSchema.js → types/CamOverlayAPI/CamOverlayAPI.js} +65 -14
- package/cjs/{models → types}/CamOverlayAPI/accuweatherSchema.d.ts +40 -10
- package/cjs/{models → types}/CamOverlayAPI/accuweatherSchema.js +11 -9
- package/cjs/{models → types}/CamOverlayAPI/customGraphicsSchema.d.ts +89 -5
- package/cjs/{models → types}/CamOverlayAPI/customGraphicsSchema.js +9 -7
- package/{esm/models → cjs/types}/CamOverlayAPI/imagesSchema.d.ts +40 -13
- package/cjs/types/CamOverlayAPI/imagesSchema.js +12 -0
- package/cjs/{models → types}/CamOverlayAPI/index.d.ts +0 -4
- package/cjs/{models → types}/CamOverlayAPI/index.js +0 -4
- package/{esm/models → cjs/types}/CamOverlayAPI/infotickerSchema.d.ts +43 -9
- package/cjs/{models → types}/CamOverlayAPI/infotickerSchema.js +10 -8
- package/{esm/models → cjs/types}/CamOverlayAPI/pipSchema.d.ts +48 -7
- package/cjs/{models → types}/CamOverlayAPI/pipSchema.js +8 -6
- package/{esm/models → cjs/types}/CamOverlayAPI/ptzCompassSchema.d.ts +40 -7
- package/cjs/{models → types}/CamOverlayAPI/ptzCompassSchema.js +8 -6
- package/cjs/{models → types}/CamOverlayAPI/ptzSchema.d.ts +42 -14
- package/cjs/types/CamOverlayAPI/ptzSchema.js +15 -0
- package/{esm/models → cjs/types}/CamOverlayAPI/screenSharingSchema.d.ts +26 -5
- package/cjs/types/CamOverlayAPI/screenSharingSchema.js +11 -0
- package/cjs/{models → types}/CamOverlayAPI/webCameraSharingSchema.d.ts +26 -5
- 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/CamStreamerAPI.d.ts +4 -4
- package/cjs/types/PlaneTrackerAPI.d.ts +6 -0
- package/cjs/types/common.d.ts +12 -3
- package/cjs/web/DefaultClient.d.ts +4 -4
- package/cjs/web/DefaultClient.js +21 -11
- package/esm/CamOverlayAPI.d.ts +38 -615
- package/esm/CamOverlayAPI.js +127 -103
- package/esm/CamOverlayDrawingAPI.d.ts +2 -47
- package/esm/CamOverlayPainter/Frame.d.ts +8 -37
- package/esm/CamOverlayPainter/Frame.js +33 -0
- package/esm/CamOverlayPainter/Painter.d.ts +5 -10
- package/esm/CamOverlayPainter/Painter.js +1 -2
- package/esm/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/esm/CamOverlayPainter/ResourceManager.js +1 -1
- package/esm/CamScripterAPI.d.ts +12 -12
- package/esm/CamScripterAPI.js +32 -26
- package/esm/CamStreamerAPI.d.ts +11 -9
- package/esm/CamStreamerAPI.js +28 -22
- package/esm/CamSwitcherAPI.d.ts +35 -34
- package/esm/CamSwitcherAPI.js +95 -83
- package/esm/PlaneTrackerAPI.d.ts +30 -36
- package/esm/PlaneTrackerAPI.js +131 -70
- package/esm/VapixAPI.d.ts +43 -40
- package/esm/VapixAPI.js +204 -182
- package/esm/events/AxisCameraStationEvents.d.ts +5 -5
- package/esm/events/AxisCameraStationEvents.js +18 -13
- package/esm/events/GenetecAgent.d.ts +2 -0
- package/esm/events/GenetecAgent.js +15 -4
- package/esm/index.d.ts +7 -1
- package/esm/index.js +7 -1
- package/esm/internal/ProxyClient.d.ts +7 -8
- package/esm/internal/ProxyClient.js +25 -31
- package/esm/internal/types.d.ts +16 -9
- package/esm/internal/utils.d.ts +1 -2
- package/esm/internal/utils.js +0 -3
- package/esm/node/DefaultClient.d.ts +3 -5
- package/esm/node/DefaultClient.js +10 -14
- package/esm/node/HttpRequestSender.d.ts +1 -0
- package/esm/node/HttpRequestSender.js +13 -3
- package/esm/node/WsClient.d.ts +1 -0
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/{models/CamOverlayAPI/widgetsSchema.d.ts → types/CamOverlayAPI/CamOverlayAPI.d.ts} +625 -375
- package/esm/{models/CamOverlayAPI/widgetCommonSchema.js → types/CamOverlayAPI/CamOverlayAPI.js} +64 -13
- package/esm/{models → types}/CamOverlayAPI/accuweatherSchema.d.ts +40 -10
- package/esm/{models → types}/CamOverlayAPI/accuweatherSchema.js +3 -2
- package/esm/{models → types}/CamOverlayAPI/customGraphicsSchema.d.ts +89 -5
- package/esm/{models → types}/CamOverlayAPI/customGraphicsSchema.js +3 -2
- package/{cjs/models → esm/types}/CamOverlayAPI/imagesSchema.d.ts +40 -13
- package/esm/types/CamOverlayAPI/imagesSchema.js +8 -0
- package/esm/{models → types}/CamOverlayAPI/index.d.ts +0 -4
- package/esm/{models → types}/CamOverlayAPI/index.js +0 -4
- package/{cjs/models → esm/types}/CamOverlayAPI/infotickerSchema.d.ts +43 -9
- package/esm/{models → types}/CamOverlayAPI/infotickerSchema.js +3 -2
- package/{cjs/models → esm/types}/CamOverlayAPI/pipSchema.d.ts +48 -7
- package/esm/{models → types}/CamOverlayAPI/pipSchema.js +3 -2
- package/{cjs/models → esm/types}/CamOverlayAPI/ptzCompassSchema.d.ts +40 -7
- package/esm/{models → types}/CamOverlayAPI/ptzCompassSchema.js +3 -2
- package/esm/{models → types}/CamOverlayAPI/ptzSchema.d.ts +42 -14
- package/esm/{models → types}/CamOverlayAPI/ptzSchema.js +3 -2
- package/{cjs/models → esm/types}/CamOverlayAPI/screenSharingSchema.d.ts +26 -5
- package/esm/types/CamOverlayAPI/screenSharingSchema.js +7 -0
- package/esm/{models → types}/CamOverlayAPI/webCameraSharingSchema.d.ts +26 -5
- 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/CamStreamerAPI.d.ts +4 -4
- package/esm/types/PlaneTrackerAPI.d.ts +6 -0
- package/esm/types/common.d.ts +12 -3
- package/esm/web/DefaultClient.d.ts +4 -4
- package/esm/web/DefaultClient.js +21 -11
- package/package.json +2 -2
- package/cjs/models/CamOverlayAPI/constants.d.ts +0 -11
- package/cjs/models/CamOverlayAPI/constants.js +0 -14
- package/cjs/models/CamOverlayAPI/fileSchema.d.ts +0 -28
- package/cjs/models/CamOverlayAPI/fileSchema.js +0 -17
- package/cjs/models/CamOverlayAPI/imagesSchema.js +0 -10
- package/cjs/models/CamOverlayAPI/ptzSchema.js +0 -13
- package/cjs/models/CamOverlayAPI/screenSharingSchema.js +0 -9
- package/cjs/models/CamOverlayAPI/webCameraSharingSchema.js +0 -9
- package/cjs/models/CamOverlayAPI/widgetCommonSchema.d.ts +0 -126
- package/cjs/models/CamOverlayAPI/widgetsSchema.js +0 -27
- package/cjs/types/CamOverlayAPI.d.ts +0 -328
- package/cjs/types/CamOverlayAPI.js +0 -26
- package/esm/models/CamOverlayAPI/constants.d.ts +0 -11
- package/esm/models/CamOverlayAPI/constants.js +0 -11
- package/esm/models/CamOverlayAPI/fileSchema.d.ts +0 -28
- package/esm/models/CamOverlayAPI/fileSchema.js +0 -14
- package/esm/models/CamOverlayAPI/imagesSchema.js +0 -7
- package/esm/models/CamOverlayAPI/screenSharingSchema.js +0 -6
- package/esm/models/CamOverlayAPI/webCameraSharingSchema.js +0 -6
- package/esm/models/CamOverlayAPI/widgetCommonSchema.d.ts +0 -126
- package/esm/models/CamOverlayAPI/widgetsSchema.js +0 -24
- package/esm/types/CamOverlayAPI.d.ts +0 -328
- package/esm/types/CamOverlayAPI.js +0 -14
package/cjs/CamScripterAPI.js
CHANGED
|
@@ -1,58 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CamScripterAPI =
|
|
3
|
+
exports.CamScripterAPI = void 0;
|
|
4
|
+
const ProxyClient_1 = require("./internal/ProxyClient");
|
|
4
5
|
const utils_1 = require("./internal/utils");
|
|
5
6
|
const CamScripterAPI_1 = require("./types/CamScripterAPI");
|
|
6
7
|
const common_1 = require("./types/common");
|
|
7
|
-
|
|
8
|
+
const BASE_PATH = '/local/camscripter';
|
|
8
9
|
class CamScripterAPI {
|
|
9
10
|
client;
|
|
10
11
|
constructor(client) {
|
|
11
12
|
this.client = client;
|
|
12
13
|
}
|
|
13
|
-
static getProxyUrlPath = () => `${
|
|
14
|
-
async checkCameraTime() {
|
|
15
|
-
const data = await this.get(`${
|
|
14
|
+
static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
15
|
+
async checkCameraTime(options) {
|
|
16
|
+
const data = await this.get(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
16
17
|
return CamScripterAPI_1.cameraTimeResponseSchema.parse(data).state;
|
|
17
18
|
}
|
|
18
|
-
async getNetworkCameraList() {
|
|
19
|
-
const data = await this.get(`${
|
|
19
|
+
async getNetworkCameraList(options) {
|
|
20
|
+
const data = await this.get(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
|
|
20
21
|
return common_1.networkCameraListSchema.parse(data.camera_list);
|
|
21
22
|
}
|
|
22
|
-
async getStorageInfo() {
|
|
23
|
-
const data = await this.get(`${
|
|
23
|
+
async getStorageInfo(options) {
|
|
24
|
+
const data = await this.get(`${BASE_PATH}/package/get_storage.cgi`, undefined, options);
|
|
24
25
|
return CamScripterAPI_1.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 CamScripterAPI_1.packageInfoListSchema.parse(data);
|
|
29
30
|
}
|
|
30
|
-
async installPackages(formData, storage) {
|
|
31
|
-
const data = 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);
|
|
32
33
|
return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
|
|
33
34
|
}
|
|
34
|
-
async uninstallPackage(packageId) {
|
|
35
|
-
const data = await this.get(`${
|
|
35
|
+
async uninstallPackage(packageId, options) {
|
|
36
|
+
const data = await this.get(`${BASE_PATH}/package/remove.cgi?package_name=${packageId}`, undefined, options);
|
|
36
37
|
return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
|
|
37
38
|
}
|
|
38
|
-
async importSettings(packageId, formData) {
|
|
39
|
-
const data = 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);
|
|
40
41
|
return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
|
|
41
42
|
}
|
|
42
|
-
async exportSettings(packageId, formData) {
|
|
43
|
-
const data = 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);
|
|
44
45
|
return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
|
|
45
46
|
}
|
|
46
|
-
async getNodejsStatus() {
|
|
47
|
-
const data = await this.get(`${
|
|
47
|
+
async getNodejsStatus(options) {
|
|
48
|
+
const data = await this.get(`${BASE_PATH}/diagnostics.cgi`, undefined, options);
|
|
48
49
|
return CamScripterAPI_1.nodeStateSchema.parse(data);
|
|
49
50
|
}
|
|
50
|
-
async installNodejs(storage) {
|
|
51
|
-
const data = await this.get(`${
|
|
51
|
+
async installNodejs(storage, options) {
|
|
52
|
+
const data = await this.get(`${BASE_PATH}/node_update.cgi?storage=${storage}`, undefined, options);
|
|
52
53
|
return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
|
|
53
54
|
}
|
|
54
|
-
async get(path,
|
|
55
|
-
const
|
|
55
|
+
async get(path, parameters, options) {
|
|
56
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
57
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
56
58
|
if (res.ok) {
|
|
57
59
|
return await res.json();
|
|
58
60
|
}
|
|
@@ -60,8 +62,9 @@ class CamScripterAPI {
|
|
|
60
62
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
|
-
async post(path, data,
|
|
64
|
-
const
|
|
65
|
+
async post(path, data, parameters, options) {
|
|
66
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
67
|
+
const res = await agent.post({ path, data, parameters, timeout: options?.timeout });
|
|
65
68
|
if (res.ok) {
|
|
66
69
|
return await res.json();
|
|
67
70
|
}
|
|
@@ -69,5 +72,8 @@ class CamScripterAPI {
|
|
|
69
72
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
70
73
|
}
|
|
71
74
|
}
|
|
75
|
+
getAgent(proxyParams) {
|
|
76
|
+
return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
|
|
77
|
+
}
|
|
72
78
|
}
|
|
73
79
|
exports.CamScripterAPI = CamScripterAPI;
|
package/cjs/CamStreamerAPI.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { IClient, TResponse } from './internal/types';
|
|
2
2
|
import { TStreamAttributes, TStreamList } from './types/CamStreamerAPI';
|
|
3
|
+
import { THttpRequestOptions } from './types/common';
|
|
3
4
|
export declare class CamStreamerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
4
5
|
client: Client;
|
|
5
6
|
constructor(client: Client);
|
|
6
|
-
getStreamList(): Promise<TStreamList>;
|
|
7
|
-
getStream(
|
|
8
|
-
getStreamParameter(
|
|
9
|
-
setStream(
|
|
10
|
-
setStreamParameter(
|
|
11
|
-
isStreaming(
|
|
12
|
-
deleteStream(
|
|
13
|
-
|
|
14
|
-
getUtcTime(): Promise<number>;
|
|
7
|
+
getStreamList(options?: THttpRequestOptions): Promise<TStreamList>;
|
|
8
|
+
getStream(streamId: string, options?: THttpRequestOptions): Promise<TStreamAttributes>;
|
|
9
|
+
getStreamParameter(streamId: string, paramName: string, options?: THttpRequestOptions): Promise<string>;
|
|
10
|
+
setStream(streamId: string, params: Partial<TStreamAttributes>, options?: THttpRequestOptions): Promise<void>;
|
|
11
|
+
setStreamParameter(streamId: string, paramName: string, value: string, options?: THttpRequestOptions): Promise<void>;
|
|
12
|
+
isStreaming(streamId: string, options?: THttpRequestOptions): Promise<boolean>;
|
|
13
|
+
deleteStream(streamId: string, options?: THttpRequestOptions): Promise<void>;
|
|
14
|
+
wsAuthorization(options?: THttpRequestOptions): Promise<string>;
|
|
15
|
+
getUtcTime(options?: THttpRequestOptions): Promise<number>;
|
|
15
16
|
private get;
|
|
17
|
+
private getAgent;
|
|
16
18
|
}
|
package/cjs/CamStreamerAPI.js
CHANGED
|
@@ -1,53 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CamStreamerAPI = void 0;
|
|
4
|
+
const ProxyClient_1 = require("./internal/ProxyClient");
|
|
4
5
|
const utils_1 = require("./internal/utils");
|
|
5
6
|
const CamStreamerAPI_1 = require("./types/CamStreamerAPI");
|
|
7
|
+
const BASE_PATH = '/local/camstreamer';
|
|
6
8
|
class CamStreamerAPI {
|
|
7
9
|
client;
|
|
8
10
|
constructor(client) {
|
|
9
11
|
this.client = client;
|
|
10
12
|
}
|
|
11
|
-
async getStreamList() {
|
|
12
|
-
const streamListRes = await this.get(
|
|
13
|
+
async getStreamList(options) {
|
|
14
|
+
const streamListRes = await this.get(`${BASE_PATH}/stream/list.cgi`, undefined, options);
|
|
13
15
|
return CamStreamerAPI_1.streamListSchema.parse(streamListRes.data);
|
|
14
16
|
}
|
|
15
|
-
async getStream(
|
|
16
|
-
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);
|
|
17
19
|
return CamStreamerAPI_1.streamAttributesSchema.parse(stream.data);
|
|
18
20
|
}
|
|
19
|
-
async getStreamParameter(
|
|
20
|
-
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);
|
|
21
23
|
return stream.data[paramName];
|
|
22
24
|
}
|
|
23
|
-
async setStream(
|
|
25
|
+
async setStream(streamId, params, options) {
|
|
24
26
|
const { streamDelay, startTime, stopTime, ...rest } = params;
|
|
25
|
-
await this.get(
|
|
26
|
-
stream_id:
|
|
27
|
+
await this.get(`${BASE_PATH}/stream/set.cgi`, {
|
|
28
|
+
stream_id: streamId,
|
|
27
29
|
streamDelay: streamDelay ?? '',
|
|
28
30
|
startTime: startTime ?? 'null',
|
|
29
31
|
stopTime: stopTime ?? 'null',
|
|
30
32
|
...rest,
|
|
31
|
-
});
|
|
33
|
+
}, options);
|
|
32
34
|
}
|
|
33
|
-
async setStreamParameter(
|
|
34
|
-
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);
|
|
35
37
|
}
|
|
36
|
-
async isStreaming(
|
|
37
|
-
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);
|
|
38
40
|
return response.data.is_streaming === 1;
|
|
39
41
|
}
|
|
40
|
-
async deleteStream(
|
|
41
|
-
await this.get(
|
|
42
|
+
async deleteStream(streamId, options) {
|
|
43
|
+
await this.get(`${BASE_PATH}/stream/remove.cgi`, { stream_id: streamId }, options);
|
|
42
44
|
}
|
|
43
|
-
|
|
44
|
-
return this.get(
|
|
45
|
+
wsAuthorization(options) {
|
|
46
|
+
return this.get(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
|
|
45
47
|
}
|
|
46
|
-
async getUtcTime() {
|
|
47
|
-
return await this.get(
|
|
48
|
+
async getUtcTime(options) {
|
|
49
|
+
return await this.get(`${BASE_PATH}/get_utc_time.cgi`, undefined, options);
|
|
48
50
|
}
|
|
49
|
-
async get(path, parameters) {
|
|
50
|
-
const
|
|
51
|
+
async get(path, parameters, options) {
|
|
52
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
53
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
51
54
|
if (res.ok) {
|
|
52
55
|
return await res.json();
|
|
53
56
|
}
|
|
@@ -55,5 +58,8 @@ class CamStreamerAPI {
|
|
|
55
58
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
56
59
|
}
|
|
57
60
|
}
|
|
61
|
+
getAgent(proxyParams) {
|
|
62
|
+
return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
|
|
63
|
+
}
|
|
58
64
|
}
|
|
59
65
|
exports.CamStreamerAPI = CamStreamerAPI;
|
package/cjs/CamSwitcherAPI.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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';
|
|
3
|
+
import { TAudioChannel, THttpRequestOptions, TNetworkCamera, TStorageType } from './types/common';
|
|
4
4
|
export declare class CamSwitcherAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
5
5
|
client: Client;
|
|
6
6
|
private CustomFormData;
|
|
@@ -12,41 +12,42 @@ export declare class CamSwitcherAPI<Client extends IClient<TResponse> = IClient<
|
|
|
12
12
|
static getProxyUrlPath: () => string;
|
|
13
13
|
static getWsEventsUrlPath: () => string;
|
|
14
14
|
static getClipPreviewUrlPath: (id: string, storage: TStorageType) => string;
|
|
15
|
-
generateSilence(sampleRate: number, channels: TAudioChannel): Promise<void>;
|
|
16
|
-
checkCameraTime(): Promise<boolean>;
|
|
17
|
-
|
|
18
|
-
getMaxFps(source: number): Promise<number>;
|
|
19
|
-
getStorageInfo(): Promise<TStorageInfo[]>;
|
|
20
|
-
wsAuthorization(): Promise<string>;
|
|
21
|
-
getOutputInfo(): Promise<TOutputInfo>;
|
|
22
|
-
getAudioPushInfo(): Promise<TAudioPushInfo>;
|
|
23
|
-
getStreamSaveList(): Promise<TStreamSaveLoadList>;
|
|
24
|
-
getClipSaveList(): Promise<TClipSaveLoadList>;
|
|
25
|
-
getPlaylistSaveList(): Promise<TPlaylistSaveLoadList>;
|
|
26
|
-
getTrackerSaveList(): Promise<TrackerSaveLoadList>;
|
|
27
|
-
setStreamSaveList(data: TStreamSaveList): Promise<boolean>;
|
|
28
|
-
setClipSaveList(data: TClipSaveList): Promise<boolean>;
|
|
29
|
-
setPlaylistSaveList(data: TPlaylistSaveList): Promise<boolean>;
|
|
30
|
-
setTrackerSaveList(data: TTrackerSaveList): Promise<boolean>;
|
|
31
|
-
playlistSwitch(playlistName: string): Promise<void>;
|
|
32
|
-
playlistQueuePush(playlistName: string): Promise<void>;
|
|
33
|
-
playlistQueueClear(): Promise<void>;
|
|
34
|
-
playlistQueueList(): Promise<string[]>;
|
|
35
|
-
playlistQueuePlayNext(): Promise<void>;
|
|
36
|
-
addNewClip(file: any, clipType: 'video' | 'audio', storage: TStorageType, id: string, fileName?: string): Promise<void>;
|
|
37
|
-
removeClip(id: string, storage: TStorageType): Promise<any>;
|
|
38
|
-
getClipList(): Promise<TClipList>;
|
|
39
|
-
setCamSwitchOptions(data: TCameraOptions, cameraFWVersion: string): Promise<boolean>;
|
|
40
|
-
setGlobalAudioSettings(settings: TGlobalAudioSettings): Promise<boolean>;
|
|
41
|
-
setSecondaryAudioSettings(settings: TSecondaryAudioSettings): Promise<boolean>;
|
|
42
|
-
setDefaultPlaylist(id: string): Promise<boolean>;
|
|
43
|
-
setPermanentRtspUrlToken(token: string): Promise<boolean>;
|
|
44
|
-
getCamSwitchOptions(): Promise<Partial<TCameraOptions>>;
|
|
45
|
-
getGlobalAudioSettings(): Promise<TGlobalAudioSettings>;
|
|
46
|
-
getSecondaryAudioSettings(): Promise<TSecondaryAudioSettings>;
|
|
47
|
-
getPermanentRtspUrlToken(): Promise<string>;
|
|
15
|
+
generateSilence(sampleRate: number, channels: TAudioChannel, options?: THttpRequestOptions): Promise<void>;
|
|
16
|
+
checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
|
|
17
|
+
getNetworkCameraList(options?: THttpRequestOptions): Promise<TNetworkCamera[]>;
|
|
18
|
+
getMaxFps(source: number, options?: THttpRequestOptions): Promise<number>;
|
|
19
|
+
getStorageInfo(options?: THttpRequestOptions): Promise<TStorageInfo[]>;
|
|
20
|
+
wsAuthorization(options?: THttpRequestOptions): Promise<string>;
|
|
21
|
+
getOutputInfo(options?: THttpRequestOptions): Promise<TOutputInfo>;
|
|
22
|
+
getAudioPushInfo(options?: THttpRequestOptions): Promise<TAudioPushInfo>;
|
|
23
|
+
getStreamSaveList(options?: THttpRequestOptions): Promise<TStreamSaveLoadList>;
|
|
24
|
+
getClipSaveList(options?: THttpRequestOptions): Promise<TClipSaveLoadList>;
|
|
25
|
+
getPlaylistSaveList(options?: THttpRequestOptions): Promise<TPlaylistSaveLoadList>;
|
|
26
|
+
getTrackerSaveList(options?: THttpRequestOptions): Promise<TrackerSaveLoadList>;
|
|
27
|
+
setStreamSaveList(data: TStreamSaveList, options?: THttpRequestOptions): Promise<boolean>;
|
|
28
|
+
setClipSaveList(data: TClipSaveList, options?: THttpRequestOptions): Promise<boolean>;
|
|
29
|
+
setPlaylistSaveList(data: TPlaylistSaveList, options?: THttpRequestOptions): Promise<boolean>;
|
|
30
|
+
setTrackerSaveList(data: TTrackerSaveList, options?: THttpRequestOptions): Promise<boolean>;
|
|
31
|
+
playlistSwitch(playlistName: string, options?: THttpRequestOptions): Promise<void>;
|
|
32
|
+
playlistQueuePush(playlistName: string, options?: THttpRequestOptions): Promise<void>;
|
|
33
|
+
playlistQueueClear(options?: THttpRequestOptions): Promise<void>;
|
|
34
|
+
playlistQueueList(options?: THttpRequestOptions): Promise<string[]>;
|
|
35
|
+
playlistQueuePlayNext(options?: THttpRequestOptions): Promise<void>;
|
|
36
|
+
addNewClip(file: any, clipType: 'video' | 'audio', storage: TStorageType, id: string, fileName?: string, options?: THttpRequestOptions): Promise<void>;
|
|
37
|
+
removeClip(id: string, storage: TStorageType, options?: THttpRequestOptions): Promise<any>;
|
|
38
|
+
getClipList(options?: THttpRequestOptions): Promise<TClipList>;
|
|
39
|
+
setCamSwitchOptions(data: TCameraOptions, cameraFWVersion: string, options?: THttpRequestOptions): Promise<boolean>;
|
|
40
|
+
setGlobalAudioSettings(settings: TGlobalAudioSettings, options?: THttpRequestOptions): Promise<boolean>;
|
|
41
|
+
setSecondaryAudioSettings(settings: TSecondaryAudioSettings, options?: THttpRequestOptions): Promise<boolean>;
|
|
42
|
+
setDefaultPlaylist(id: string, options?: THttpRequestOptions): Promise<boolean>;
|
|
43
|
+
setPermanentRtspUrlToken(token: string, options?: THttpRequestOptions): Promise<boolean>;
|
|
44
|
+
getCamSwitchOptions(options?: THttpRequestOptions): Promise<Partial<TCameraOptions>>;
|
|
45
|
+
getGlobalAudioSettings(options?: THttpRequestOptions): Promise<TGlobalAudioSettings>;
|
|
46
|
+
getSecondaryAudioSettings(options?: THttpRequestOptions): Promise<TSecondaryAudioSettings>;
|
|
47
|
+
getPermanentRtspUrlToken(options?: THttpRequestOptions): Promise<string>;
|
|
48
48
|
private get;
|
|
49
49
|
private set;
|
|
50
50
|
private setParamFromCameraJSON;
|
|
51
51
|
private getParamFromCameraAndJSONParse;
|
|
52
|
+
private getAgent;
|
|
52
53
|
}
|
package/cjs/CamSwitcherAPI.js
CHANGED
|
@@ -9,7 +9,8 @@ const common_1 = require("./types/common");
|
|
|
9
9
|
const VapixAPI_1 = require("./VapixAPI");
|
|
10
10
|
const versionCompare_1 = require("./internal/versionCompare");
|
|
11
11
|
const constants_1 = require("./internal/constants");
|
|
12
|
-
const
|
|
12
|
+
const ProxyClient_1 = require("./internal/ProxyClient");
|
|
13
|
+
const BASE_PATH = '/local/camswitcher/api';
|
|
13
14
|
class CamSwitcherAPI {
|
|
14
15
|
client;
|
|
15
16
|
CustomFormData;
|
|
@@ -17,111 +18,117 @@ class CamSwitcherAPI {
|
|
|
17
18
|
constructor(client, CustomFormData = FormData) {
|
|
18
19
|
this.client = client;
|
|
19
20
|
this.CustomFormData = CustomFormData;
|
|
20
|
-
this.vapixAgent = new VapixAPI_1.VapixAPI(client
|
|
21
|
+
this.vapixAgent = new VapixAPI_1.VapixAPI(client);
|
|
21
22
|
}
|
|
22
|
-
static getProxyUrlPath = () => `${
|
|
23
|
+
static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
23
24
|
static getWsEventsUrlPath = () => `/local/camswitcher/events`;
|
|
24
|
-
static getClipPreviewUrlPath = (id, storage) => `${
|
|
25
|
-
async generateSilence(sampleRate, channels) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
static getClipPreviewUrlPath = (id, storage) => `${BASE_PATH}/clip_preview.cgi?clip_name=${id}&storage=${storage}`;
|
|
26
|
+
async generateSilence(sampleRate, channels, options) {
|
|
27
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
28
|
+
await agent.get({
|
|
29
|
+
path: `${BASE_PATH}/generate_silence.cgi`,
|
|
30
|
+
parameters: {
|
|
31
|
+
sample_rate: sampleRate.toString(),
|
|
32
|
+
channels,
|
|
33
|
+
},
|
|
34
|
+
timeout: options?.timeout,
|
|
29
35
|
});
|
|
30
36
|
}
|
|
31
|
-
async checkCameraTime() {
|
|
32
|
-
const data = await this.get(`${
|
|
37
|
+
async checkCameraTime(options) {
|
|
38
|
+
const data = await this.get(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
33
39
|
return zod_1.z.boolean().parse(data);
|
|
34
40
|
}
|
|
35
|
-
async
|
|
36
|
-
const data = await this.get(`${
|
|
41
|
+
async getNetworkCameraList(options) {
|
|
42
|
+
const data = await this.get(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
|
|
37
43
|
return common_1.networkCameraListSchema.parse(data);
|
|
38
44
|
}
|
|
39
|
-
async getMaxFps(source) {
|
|
40
|
-
const data = await this.get(`${
|
|
45
|
+
async getMaxFps(source, options) {
|
|
46
|
+
const data = await this.get(`${BASE_PATH}/get_max_framerate.cgi`, {
|
|
41
47
|
video_source: source.toString(),
|
|
42
|
-
});
|
|
48
|
+
}, options);
|
|
43
49
|
return zod_1.z.number().parse(data);
|
|
44
50
|
}
|
|
45
|
-
async getStorageInfo() {
|
|
46
|
-
const data = await this.get(`${
|
|
51
|
+
async getStorageInfo(options) {
|
|
52
|
+
const data = await this.get(`${BASE_PATH}/get_storage.cgi`, undefined, options);
|
|
47
53
|
return CamSwitcherAPI_1.storageInfoListSchema.parse(data);
|
|
48
54
|
}
|
|
49
|
-
async wsAuthorization() {
|
|
50
|
-
const data = await this.get(`${
|
|
55
|
+
async wsAuthorization(options) {
|
|
56
|
+
const data = await this.get(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
|
|
51
57
|
return zod_1.z.string().parse(data);
|
|
52
58
|
}
|
|
53
|
-
async getOutputInfo() {
|
|
54
|
-
const data = await this.get(`${
|
|
59
|
+
async getOutputInfo(options) {
|
|
60
|
+
const data = await this.get(`${BASE_PATH}/output_info.cgi`, undefined, options);
|
|
55
61
|
return CamSwitcherAPI_1.outputInfoSchema.parse(data);
|
|
56
62
|
}
|
|
57
|
-
async getAudioPushInfo() {
|
|
58
|
-
const data = await this.get(`${
|
|
63
|
+
async getAudioPushInfo(options) {
|
|
64
|
+
const data = await this.get(`${BASE_PATH}/audio_push_info.cgi`, undefined, options);
|
|
59
65
|
return CamSwitcherAPI_1.audioPushInfoSchema.parse(data);
|
|
60
66
|
}
|
|
61
|
-
async getStreamSaveList() {
|
|
62
|
-
const data = await this.get(`${
|
|
67
|
+
async getStreamSaveList(options) {
|
|
68
|
+
const data = await this.get(`${BASE_PATH}/streams.cgi`, { action: 'get' }, options);
|
|
63
69
|
return CamSwitcherAPI_1.streamSaveLoadSchema.parse(data);
|
|
64
70
|
}
|
|
65
|
-
async getClipSaveList() {
|
|
66
|
-
const data = await this.get(`${
|
|
71
|
+
async getClipSaveList(options) {
|
|
72
|
+
const data = await this.get(`${BASE_PATH}/clips.cgi`, { action: 'get' }, options);
|
|
67
73
|
return CamSwitcherAPI_1.clipSaveLoadSchema.parse(data);
|
|
68
74
|
}
|
|
69
|
-
async getPlaylistSaveList() {
|
|
70
|
-
const data = await this.get(`${
|
|
75
|
+
async getPlaylistSaveList(options) {
|
|
76
|
+
const data = await this.get(`${BASE_PATH}/playlists.cgi`, { action: 'get' }, options);
|
|
71
77
|
return CamSwitcherAPI_1.playlistSaveLoadSchema.parse(data);
|
|
72
78
|
}
|
|
73
|
-
async getTrackerSaveList() {
|
|
74
|
-
const data = await this.get(`${
|
|
79
|
+
async getTrackerSaveList(options) {
|
|
80
|
+
const data = await this.get(`${BASE_PATH}/trackers.cgi`, { action: 'get' }, options);
|
|
75
81
|
return CamSwitcherAPI_1.trackerSaveLoadSchema.parse(data);
|
|
76
82
|
}
|
|
77
|
-
async setStreamSaveList(data) {
|
|
78
|
-
return await this.set(`${
|
|
83
|
+
async setStreamSaveList(data, options) {
|
|
84
|
+
return await this.set(`${BASE_PATH}/streams.cgi`, data, { action: 'set' }, options);
|
|
79
85
|
}
|
|
80
|
-
async setClipSaveList(data) {
|
|
81
|
-
return await this.set(`${
|
|
86
|
+
async setClipSaveList(data, options) {
|
|
87
|
+
return await this.set(`${BASE_PATH}/clips.cgi`, data, { action: 'set' }, options);
|
|
82
88
|
}
|
|
83
|
-
async setPlaylistSaveList(data) {
|
|
84
|
-
return await this.set(`${
|
|
89
|
+
async setPlaylistSaveList(data, options) {
|
|
90
|
+
return await this.set(`${BASE_PATH}/playlists.cgi`, data, { action: 'set' }, options);
|
|
85
91
|
}
|
|
86
|
-
async setTrackerSaveList(data) {
|
|
87
|
-
return await this.set(`${
|
|
92
|
+
async setTrackerSaveList(data, options) {
|
|
93
|
+
return await this.set(`${BASE_PATH}/trackers.cgi`, data, { action: 'set' }, options);
|
|
88
94
|
}
|
|
89
|
-
async playlistSwitch(playlistName) {
|
|
90
|
-
await this.get(`${
|
|
95
|
+
async playlistSwitch(playlistName, options) {
|
|
96
|
+
await this.get(`${BASE_PATH}/playlist_switch.cgi`, { playlist_name: playlistName }, options);
|
|
91
97
|
}
|
|
92
|
-
async playlistQueuePush(playlistName) {
|
|
93
|
-
await this.get(`${
|
|
98
|
+
async playlistQueuePush(playlistName, options) {
|
|
99
|
+
await this.get(`${BASE_PATH}/playlist_queue_push.cgi`, { playlist_name: playlistName }, options);
|
|
94
100
|
}
|
|
95
|
-
async playlistQueueClear() {
|
|
96
|
-
await this.get(`${
|
|
101
|
+
async playlistQueueClear(options) {
|
|
102
|
+
await this.get(`${BASE_PATH}/playlist_queue_clear.cgi`, undefined, options);
|
|
97
103
|
}
|
|
98
|
-
async playlistQueueList() {
|
|
99
|
-
const data = await this.get(`${
|
|
104
|
+
async playlistQueueList(options) {
|
|
105
|
+
const data = await this.get(`${BASE_PATH}/playlist_queue_list.cgi`, undefined, options);
|
|
100
106
|
return CamSwitcherAPI_1.playlistQueueSchema.parse(data).playlistQueueList;
|
|
101
107
|
}
|
|
102
|
-
async playlistQueuePlayNext() {
|
|
103
|
-
await this.get(`${
|
|
108
|
+
async playlistQueuePlayNext(options) {
|
|
109
|
+
await this.get(`${BASE_PATH}/playlist_queue_play_next.cgi`, undefined, options);
|
|
104
110
|
}
|
|
105
|
-
async addNewClip(file, clipType, storage, id, fileName) {
|
|
111
|
+
async addNewClip(file, clipType, storage, id, fileName, options) {
|
|
112
|
+
const path = `${BASE_PATH}/clip_upload.cgi?storage=${storage}`;
|
|
106
113
|
const formData = new this.CustomFormData();
|
|
107
114
|
formData.append('clip_name', id);
|
|
108
115
|
formData.append('clip_type', clipType);
|
|
109
116
|
formData.append('file', file, fileName);
|
|
110
|
-
const
|
|
111
|
-
const res = await
|
|
117
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
118
|
+
const res = await agent.post({ path, data: formData, timeout: options?.timeout });
|
|
112
119
|
const output = (await res.json());
|
|
113
120
|
if (output.status !== 200) {
|
|
114
121
|
throw new errors_1.AddNewClipError(output.message);
|
|
115
122
|
}
|
|
116
123
|
}
|
|
117
|
-
removeClip(id, storage) {
|
|
118
|
-
return this.get(`${
|
|
124
|
+
removeClip(id, storage, options) {
|
|
125
|
+
return this.get(`${BASE_PATH}/clip_remove.cgi`, { clip_name: id, storage }, options);
|
|
119
126
|
}
|
|
120
|
-
async getClipList() {
|
|
121
|
-
const data = await this.get(`${
|
|
127
|
+
async getClipList(options) {
|
|
128
|
+
const data = await this.get(`${BASE_PATH}/clip_list.cgi`, undefined, options);
|
|
122
129
|
return CamSwitcherAPI_1.clipListSchema.parse(data).clip_list;
|
|
123
130
|
}
|
|
124
|
-
setCamSwitchOptions(data, cameraFWVersion) {
|
|
131
|
+
setCamSwitchOptions(data, cameraFWVersion, options) {
|
|
125
132
|
const bitrateVapixParams = parseBitrateOptionsToBitrateVapixParams(cameraFWVersion, data.bitrateMode, data);
|
|
126
133
|
const saveData = {
|
|
127
134
|
video: {
|
|
@@ -139,9 +146,9 @@ class CamSwitcherAPI {
|
|
|
139
146
|
},
|
|
140
147
|
keyboard: data.keyboard,
|
|
141
148
|
};
|
|
142
|
-
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SETTINGS, saveData);
|
|
149
|
+
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SETTINGS, saveData, options);
|
|
143
150
|
}
|
|
144
|
-
setGlobalAudioSettings(settings) {
|
|
151
|
+
setGlobalAudioSettings(settings, options) {
|
|
145
152
|
let acceptedType = 'NONE';
|
|
146
153
|
if (settings.type === 'source' && settings.source) {
|
|
147
154
|
if ((0, utils_1.isClip)(settings.source)) {
|
|
@@ -157,9 +164,9 @@ class CamSwitcherAPI {
|
|
|
157
164
|
clip_name: settings.source,
|
|
158
165
|
storage: settings.storage,
|
|
159
166
|
};
|
|
160
|
-
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.MASTER_AUDIO, data);
|
|
167
|
+
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.MASTER_AUDIO, data, options);
|
|
161
168
|
}
|
|
162
|
-
setSecondaryAudioSettings(settings) {
|
|
169
|
+
setSecondaryAudioSettings(settings, options) {
|
|
163
170
|
const data = {
|
|
164
171
|
type: settings.type,
|
|
165
172
|
stream_name: settings.streamName ?? '',
|
|
@@ -168,19 +175,19 @@ class CamSwitcherAPI {
|
|
|
168
175
|
secondary_audio_level: settings.secondaryAudioLevel,
|
|
169
176
|
master_audio_level: settings.masterAudioLevel,
|
|
170
177
|
};
|
|
171
|
-
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SECONDARY_AUDIO, data);
|
|
178
|
+
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SECONDARY_AUDIO, data, options);
|
|
172
179
|
}
|
|
173
|
-
setDefaultPlaylist(id) {
|
|
180
|
+
setDefaultPlaylist(id, options) {
|
|
174
181
|
const value = JSON.stringify({ default_playlist_id: id });
|
|
175
182
|
return this.vapixAgent.setParameter({
|
|
176
183
|
[CSW_PARAM_NAMES.DEFAULT_PLAYLIST]: value,
|
|
177
|
-
},
|
|
184
|
+
}, options);
|
|
178
185
|
}
|
|
179
|
-
setPermanentRtspUrlToken(token) {
|
|
180
|
-
return this.vapixAgent.setParameter({ [CSW_PARAM_NAMES.RTSP_TOKEN]: token },
|
|
186
|
+
setPermanentRtspUrlToken(token, options) {
|
|
187
|
+
return this.vapixAgent.setParameter({ [CSW_PARAM_NAMES.RTSP_TOKEN]: token }, options);
|
|
181
188
|
}
|
|
182
|
-
async getCamSwitchOptions() {
|
|
183
|
-
const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS);
|
|
189
|
+
async getCamSwitchOptions(options) {
|
|
190
|
+
const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS, options);
|
|
184
191
|
if ((0, utils_1.isNullish)(saveData.video)) {
|
|
185
192
|
return saveData;
|
|
186
193
|
}
|
|
@@ -205,12 +212,12 @@ class CamSwitcherAPI {
|
|
|
205
212
|
keyboard: saveData.keyboard,
|
|
206
213
|
};
|
|
207
214
|
}
|
|
208
|
-
async getGlobalAudioSettings() {
|
|
215
|
+
async getGlobalAudioSettings(options) {
|
|
209
216
|
const settings = {
|
|
210
217
|
type: 'fromSource',
|
|
211
218
|
source: 'fromSource',
|
|
212
219
|
};
|
|
213
|
-
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.MASTER_AUDIO);
|
|
220
|
+
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.MASTER_AUDIO, options);
|
|
214
221
|
if (res.type === 'STREAM') {
|
|
215
222
|
settings.type = 'source';
|
|
216
223
|
settings.source = res.stream_name;
|
|
@@ -222,8 +229,8 @@ class CamSwitcherAPI {
|
|
|
222
229
|
}
|
|
223
230
|
return settings;
|
|
224
231
|
}
|
|
225
|
-
async getSecondaryAudioSettings() {
|
|
226
|
-
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SECONDARY_AUDIO);
|
|
232
|
+
async getSecondaryAudioSettings(options) {
|
|
233
|
+
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SECONDARY_AUDIO, options);
|
|
227
234
|
const settings = {
|
|
228
235
|
type: res.type ?? 'NONE',
|
|
229
236
|
streamName: res.stream_name,
|
|
@@ -234,13 +241,14 @@ class CamSwitcherAPI {
|
|
|
234
241
|
};
|
|
235
242
|
return settings;
|
|
236
243
|
}
|
|
237
|
-
async getPermanentRtspUrlToken() {
|
|
244
|
+
async getPermanentRtspUrlToken(options) {
|
|
238
245
|
const paramName = CSW_PARAM_NAMES.RTSP_TOKEN;
|
|
239
|
-
const res = await this.vapixAgent.getParameter([paramName],
|
|
246
|
+
const res = await this.vapixAgent.getParameter([paramName], options);
|
|
240
247
|
return res[paramName] ?? '';
|
|
241
248
|
}
|
|
242
|
-
async get(path, parameters
|
|
243
|
-
const
|
|
249
|
+
async get(path, parameters, options) {
|
|
250
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
251
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
244
252
|
if (res.ok) {
|
|
245
253
|
const d = (await res.json());
|
|
246
254
|
return d.data;
|
|
@@ -249,8 +257,9 @@ class CamSwitcherAPI {
|
|
|
249
257
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
250
258
|
}
|
|
251
259
|
}
|
|
252
|
-
async set(path, data, parameters
|
|
253
|
-
const
|
|
260
|
+
async set(path, data, parameters, options) {
|
|
261
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
262
|
+
const res = await agent.post({ path, data: JSON.stringify(data), parameters, timeout: options?.timeout });
|
|
254
263
|
if (res.ok) {
|
|
255
264
|
const parsed = await res.json();
|
|
256
265
|
return parsed.message === 'OK';
|
|
@@ -259,13 +268,13 @@ class CamSwitcherAPI {
|
|
|
259
268
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
260
269
|
}
|
|
261
270
|
}
|
|
262
|
-
setParamFromCameraJSON(paramName, data) {
|
|
271
|
+
setParamFromCameraJSON(paramName, data, options) {
|
|
263
272
|
const params = {};
|
|
264
273
|
params[paramName] = JSON.stringify(data);
|
|
265
|
-
return this.vapixAgent.setParameter(params,
|
|
274
|
+
return this.vapixAgent.setParameter(params, options);
|
|
266
275
|
}
|
|
267
|
-
async getParamFromCameraAndJSONParse(paramName) {
|
|
268
|
-
const data = await this.vapixAgent.getParameter([paramName],
|
|
276
|
+
async getParamFromCameraAndJSONParse(paramName, options) {
|
|
277
|
+
const data = await this.vapixAgent.getParameter([paramName], options);
|
|
269
278
|
if (data[paramName] !== undefined) {
|
|
270
279
|
try {
|
|
271
280
|
if (data[paramName] === '') {
|
|
@@ -281,6 +290,9 @@ class CamSwitcherAPI {
|
|
|
281
290
|
}
|
|
282
291
|
throw new Error("Error: no parametr '" + paramName + "' was found");
|
|
283
292
|
}
|
|
293
|
+
getAgent(proxyParams) {
|
|
294
|
+
return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
|
|
295
|
+
}
|
|
284
296
|
}
|
|
285
297
|
exports.CamSwitcherAPI = CamSwitcherAPI;
|
|
286
298
|
const CSW_PARAM_NAMES = {
|