camstreamerlib 4.0.29 → 4.0.30-44304ea

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.
@@ -144,7 +144,24 @@ export declare class CamSwitcherAPI<Client extends IClient<TResponse, any>> exte
144
144
  setSecondaryAudioSettings(settings: TSecondaryAudioSettings, options?: THttpRequestOptions): Promise<void>;
145
145
  setDefaultPlaylist(playlistId: string, options?: THttpRequestOptions): Promise<void>;
146
146
  setPermanentRtspUrlToken(token: string, options?: THttpRequestOptions): Promise<void>;
147
- getCamSwitchOptions(options?: THttpRequestOptions): Promise<any>;
147
+ getCamSwitchOptions(options?: THttpRequestOptions): Promise<{
148
+ resolution?: string | undefined;
149
+ compression?: number | undefined;
150
+ bitrateMode?: "VBR" | "MBR" | "ABR" | undefined;
151
+ maximumBitRate?: number | undefined;
152
+ retentionTime?: number | undefined;
153
+ bitRateLimit?: number | undefined;
154
+ fps?: number | undefined;
155
+ govLength?: number | undefined;
156
+ h264Profile?: "high" | "main" | "baseline" | undefined;
157
+ keyboard?: {
158
+ none: string | null;
159
+ fromSource: string | null;
160
+ } | undefined;
161
+ bitrateVapixParams?: string | null | undefined;
162
+ audioSampleRate?: number | undefined;
163
+ audioChannelCount?: 1 | 2 | undefined;
164
+ }>;
148
165
  getGlobalAudioSettings(options?: THttpRequestOptions): Promise<{
149
166
  type: "source" | "fromSource";
150
167
  source: string;
@@ -9,6 +9,7 @@ const CamSwitcherAPI_1 = require("./types/CamSwitcherAPI");
9
9
  const common_1 = require("./types/common");
10
10
  const VapixAPI_1 = require("./VapixAPI");
11
11
  const BasicAPI_1 = require("./internal/BasicAPI");
12
+ const helpers_1 = require("./helpers");
12
13
  const BASE_PATH = '/local/camswitcher/api';
13
14
  class CamSwitcherAPI extends BasicAPI_1.BasicAPI {
14
15
  CustomFormData;
@@ -203,28 +204,33 @@ class CamSwitcherAPI extends BasicAPI_1.BasicAPI {
203
204
  async getCamSwitchOptions(options) {
204
205
  const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS, options);
205
206
  if ((0, utils_1.isNullish)(saveData.video)) {
206
- return saveData;
207
+ return CamSwitcherAPI_1.cameraOptionsSchema.parse({
208
+ audioSampleRate: saveData.audio.sampleRate,
209
+ audioChannelCount: saveData.audio.channelCount,
210
+ keyboard: saveData.keyboard,
211
+ });
207
212
  }
213
+ const settings = {};
208
214
  if (!(0, utils_1.isNullish)(saveData.video?.bitrateVapixParams)) {
209
215
  const bitrateOptions = (0, convertors_1.parseVapixParamsToBitrateOptions)(saveData.video.bitrateVapixParams);
210
- saveData.video.bitrateMode = bitrateOptions.bitrateMode;
211
- saveData.video.maximumBitRate = bitrateOptions.maximumBitRate;
212
- saveData.video.retentionTime = bitrateOptions.retentionTime;
213
- saveData.video.bitRateLimit = bitrateOptions.bitRateLimit;
216
+ settings.bitrateMode = bitrateOptions.bitrateMode;
217
+ settings.maximumBitRate = bitrateOptions.maximumBitRate;
218
+ settings.retentionTime = bitrateOptions.retentionTime;
219
+ settings.bitRateLimit = bitrateOptions.bitRateLimit;
214
220
  }
215
221
  if (!(0, utils_1.isNullish)(saveData.video?.bitrateLimit)) {
216
- saveData.video.maximumBitRate = saveData.video.bitrateLimit;
217
- saveData.video.bitrateMode = 'MBR';
222
+ settings.maximumBitRate = saveData.video.bitrateLimit;
223
+ settings.bitrateMode = 'MBR';
218
224
  }
219
225
  if (!(0, utils_1.isNullish)(saveData.video?.videoClipQuality)) {
220
- saveData.video.maximumBitRate = saveData.video.videoClipQuality;
226
+ settings.maximumBitRate = saveData.video.videoClipQuality;
221
227
  }
222
- return {
223
- ...saveData.video,
228
+ return CamSwitcherAPI_1.cameraOptionsSchema.parse({
229
+ ...settings,
224
230
  audioSampleRate: saveData.audio.sampleRate,
225
231
  audioChannelCount: saveData.audio.channelCount,
226
232
  keyboard: saveData.keyboard,
227
- };
233
+ });
228
234
  }
229
235
  async getGlobalAudioSettings(options) {
230
236
  const settings = {
@@ -273,20 +279,7 @@ class CamSwitcherAPI extends BasicAPI_1.BasicAPI {
273
279
  if (data[paramName] === undefined) {
274
280
  throw new errors_1.ParameterNotFoundError(paramName);
275
281
  }
276
- if (data[paramName] === '') {
277
- return {};
278
- }
279
- try {
280
- return JSON.parse(data[paramName] + '');
281
- }
282
- catch {
283
- try {
284
- return JSON.parse(decodeURIComponent((data[paramName] + '').replaceAll('\\', '')));
285
- }
286
- catch (e) {
287
- throw new errors_1.JsonParseError(paramName, data[paramName]);
288
- }
289
- }
282
+ return (0, helpers_1.jsonParseCameraParam)(data[paramName] + '', paramName);
290
283
  }
291
284
  async getUploadedFileList(clipName, storage, options) {
292
285
  const res = await this._getJson(`${BASE_PATH}/clip_files.cgi`, { clip_name: clipName, storage }, options);
@@ -0,0 +1 @@
1
+ export declare const jsonParseCameraParam: (param: string, paramName: string) => any;
package/cjs/helpers.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jsonParseCameraParam = void 0;
4
+ const errors_1 = require("./errors/errors");
5
+ const jsonParseCameraParam = (param, paramName) => {
6
+ if (param === '') {
7
+ return {};
8
+ }
9
+ try {
10
+ return JSON.parse(param);
11
+ }
12
+ catch {
13
+ try {
14
+ return JSON.parse(decodeURIComponent(param.replaceAll('\\', '')));
15
+ }
16
+ catch (e) {
17
+ throw new errors_1.JsonParseError(paramName, param);
18
+ }
19
+ }
20
+ };
21
+ exports.jsonParseCameraParam = jsonParseCameraParam;
package/cjs/index.d.ts CHANGED
@@ -26,3 +26,4 @@ export { CamScripterAPI } from './CamScripterAPI';
26
26
  export * from './types/CamScripterAPI';
27
27
  export { VapixAPI } from './VapixAPI';
28
28
  export * from './types/VapixAPI';
29
+ export * from './helpers';
package/cjs/index.js CHANGED
@@ -53,3 +53,4 @@ __exportStar(require("./types/CamScripterAPI"), exports);
53
53
  var VapixAPI_1 = require("./VapixAPI");
54
54
  Object.defineProperty(exports, "VapixAPI", { enumerable: true, get: function () { return VapixAPI_1.VapixAPI; } });
55
55
  __exportStar(require("./types/VapixAPI"), exports);
56
+ __exportStar(require("./helpers"), exports);
@@ -1,11 +1,12 @@
1
1
  import { z } from 'zod';
2
- import { AddNewClipError, JsonParseError, ParameterNotFoundError } from './errors/errors';
2
+ import { AddNewClipError, ParameterNotFoundError } from './errors/errors';
3
3
  import { parseBitrateOptionsToVapixParams, parseVapixParamsToBitrateOptions } from './internal/convertors';
4
4
  import { isClip, isNullish } from './internal/utils';
5
- import { storageInfoListSchema, outputInfoSchema, audioPushInfoSchema, clipListSchema, playlistQueueSchema, streamSaveLoadSchema, clipSaveLoadSchema, playlistSaveLoadSchema, trackerSaveLoadSchema, secondaryAudioSettingsSchema, globalAudioSettingsSchema, clipFilesListSchema, } from './types/CamSwitcherAPI';
5
+ import { storageInfoListSchema, outputInfoSchema, audioPushInfoSchema, clipListSchema, playlistQueueSchema, streamSaveLoadSchema, clipSaveLoadSchema, playlistSaveLoadSchema, trackerSaveLoadSchema, secondaryAudioSettingsSchema, globalAudioSettingsSchema, clipFilesListSchema, cameraOptionsSchema, } from './types/CamSwitcherAPI';
6
6
  import { networkCameraListSchema, } from './types/common';
7
7
  import { VapixAPI } from './VapixAPI';
8
8
  import { BasicAPI } from './internal/BasicAPI';
9
+ import { jsonParseCameraParam } from './helpers';
9
10
  const BASE_PATH = '/local/camswitcher/api';
10
11
  export class CamSwitcherAPI extends BasicAPI {
11
12
  CustomFormData;
@@ -200,28 +201,33 @@ export class CamSwitcherAPI extends BasicAPI {
200
201
  async getCamSwitchOptions(options) {
201
202
  const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS, options);
202
203
  if (isNullish(saveData.video)) {
203
- return saveData;
204
+ return cameraOptionsSchema.parse({
205
+ audioSampleRate: saveData.audio.sampleRate,
206
+ audioChannelCount: saveData.audio.channelCount,
207
+ keyboard: saveData.keyboard,
208
+ });
204
209
  }
210
+ const settings = {};
205
211
  if (!isNullish(saveData.video?.bitrateVapixParams)) {
206
212
  const bitrateOptions = parseVapixParamsToBitrateOptions(saveData.video.bitrateVapixParams);
207
- saveData.video.bitrateMode = bitrateOptions.bitrateMode;
208
- saveData.video.maximumBitRate = bitrateOptions.maximumBitRate;
209
- saveData.video.retentionTime = bitrateOptions.retentionTime;
210
- saveData.video.bitRateLimit = bitrateOptions.bitRateLimit;
213
+ settings.bitrateMode = bitrateOptions.bitrateMode;
214
+ settings.maximumBitRate = bitrateOptions.maximumBitRate;
215
+ settings.retentionTime = bitrateOptions.retentionTime;
216
+ settings.bitRateLimit = bitrateOptions.bitRateLimit;
211
217
  }
212
218
  if (!isNullish(saveData.video?.bitrateLimit)) {
213
- saveData.video.maximumBitRate = saveData.video.bitrateLimit;
214
- saveData.video.bitrateMode = 'MBR';
219
+ settings.maximumBitRate = saveData.video.bitrateLimit;
220
+ settings.bitrateMode = 'MBR';
215
221
  }
216
222
  if (!isNullish(saveData.video?.videoClipQuality)) {
217
- saveData.video.maximumBitRate = saveData.video.videoClipQuality;
223
+ settings.maximumBitRate = saveData.video.videoClipQuality;
218
224
  }
219
- return {
220
- ...saveData.video,
225
+ return cameraOptionsSchema.parse({
226
+ ...settings,
221
227
  audioSampleRate: saveData.audio.sampleRate,
222
228
  audioChannelCount: saveData.audio.channelCount,
223
229
  keyboard: saveData.keyboard,
224
- };
230
+ });
225
231
  }
226
232
  async getGlobalAudioSettings(options) {
227
233
  const settings = {
@@ -270,20 +276,7 @@ export class CamSwitcherAPI extends BasicAPI {
270
276
  if (data[paramName] === undefined) {
271
277
  throw new ParameterNotFoundError(paramName);
272
278
  }
273
- if (data[paramName] === '') {
274
- return {};
275
- }
276
- try {
277
- return JSON.parse(data[paramName] + '');
278
- }
279
- catch {
280
- try {
281
- return JSON.parse(decodeURIComponent((data[paramName] + '').replaceAll('\\', '')));
282
- }
283
- catch (e) {
284
- throw new JsonParseError(paramName, data[paramName]);
285
- }
286
- }
279
+ return jsonParseCameraParam(data[paramName] + '', paramName);
287
280
  }
288
281
  async getUploadedFileList(clipName, storage, options) {
289
282
  const res = await this._getJson(`${BASE_PATH}/clip_files.cgi`, { clip_name: clipName, storage }, options);
package/esm/helpers.js ADDED
@@ -0,0 +1,17 @@
1
+ import { JsonParseError } from './errors/errors';
2
+ export const jsonParseCameraParam = (param, paramName) => {
3
+ if (param === '') {
4
+ return {};
5
+ }
6
+ try {
7
+ return JSON.parse(param);
8
+ }
9
+ catch {
10
+ try {
11
+ return JSON.parse(decodeURIComponent(param.replaceAll('\\', '')));
12
+ }
13
+ catch (e) {
14
+ throw new JsonParseError(paramName, param);
15
+ }
16
+ }
17
+ };
package/esm/index.js CHANGED
@@ -26,3 +26,4 @@ export { CamScripterAPI } from './CamScripterAPI';
26
26
  export * from './types/CamScripterAPI';
27
27
  export { VapixAPI } from './VapixAPI';
28
28
  export * from './types/VapixAPI';
29
+ export * from './helpers';
package/package.json CHANGED
@@ -1,110 +1,110 @@
1
1
  {
2
- "name": "camstreamerlib",
3
- "version": "4.0.29",
4
- "description": "Helper library for CamStreamer ACAP applications.",
5
- "prettier": "@camstreamer/prettier-config",
6
- "engine": {
7
- "node": ">=18.0.0"
2
+ "name": "camstreamerlib",
3
+ "version": "4.0.30-44304ea",
4
+ "description": "Helper library for CamStreamer ACAP applications.",
5
+ "prettier": "@camstreamer/prettier-config",
6
+ "engine": {
7
+ "node": ">=18.0.0"
8
+ },
9
+ "dependencies": {
10
+ "adm-zip": "^0.6.0",
11
+ "eventemitter2": "^5.0.1",
12
+ "fast-xml-parser": "^5.3.6",
13
+ "type-fest": "^4.41.0",
14
+ "undici": "^6.28.0",
15
+ "ws": "^8.18.0",
16
+ "zod": "^3.25.76"
17
+ },
18
+ "devDependencies": {
19
+ "@camstreamer/eslint-config": "^1.0.2",
20
+ "@camstreamer/prettier-config": "^2.0.4",
21
+ "@types/adm-zip": "^0.5.5",
22
+ "@types/jest": "^28.0.0",
23
+ "@types/node": "^18.19.127",
24
+ "@types/ws": "^8.5.10",
25
+ "@typescript-eslint/eslint-plugin": "^6.8.0",
26
+ "@typescript-eslint/parser": "^6.8.0",
27
+ "eslint": "^8.51.0",
28
+ "eslint-plugin-deprecation": "^2.0.0",
29
+ "eslint-plugin-unused-imports": "^3.0.0",
30
+ "jest": "^28.1.3",
31
+ "npm-run-all": "^4.1.5",
32
+ "prettier": "^2.7.1",
33
+ "ts-jest": "^28.0.0",
34
+ "ts-node": "^10.7.0",
35
+ "typescript": "5.3.3"
36
+ },
37
+ "overrides": {
38
+ "js-yaml": "^4.2.0"
39
+ },
40
+ "scripts": {
41
+ "clean": "rimraf dist/*",
42
+ "build": "npm-run-all clean build:cjs build:esm copyPackage",
43
+ "build:cjs": "tsc --project tsconfig.cjs.json",
44
+ "build:esm": "tsc --project tsconfig.esm.json",
45
+ "copyPackage": "cp -f LICENSE dist/ && cp -f README.md dist/ && cp -f package.json dist/",
46
+ "publishPackage": "./publish.sh",
47
+ "lint": "eslint \"src/**/*.ts\"",
48
+ "lint:fix": "eslint \"src/**/*.ts\" --fix",
49
+ "pretty": "prettier --write \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
50
+ "pretty:check": "prettier --check \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
51
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
52
+ "audit": "npm audit --audit-level=high"
53
+ },
54
+ "files": [
55
+ "/**/*.js",
56
+ "/**/*.ts"
57
+ ],
58
+ "main": "./cjs/index.js",
59
+ "module": "./esm/index.js",
60
+ "types": "types/index.d.ts",
61
+ "exports": {
62
+ ".": {
63
+ "import": "./esm/index.js",
64
+ "require": "./cjs/index.js",
65
+ "types": "./types/index.d.ts"
8
66
  },
9
- "dependencies": {
10
- "adm-zip": "^0.6.0",
11
- "eventemitter2": "^5.0.1",
12
- "fast-xml-parser": "^5.3.6",
13
- "type-fest": "^4.41.0",
14
- "undici": "^6.28.0",
15
- "ws": "^8.18.0",
16
- "zod": "^3.25.76"
67
+ "./web": {
68
+ "import": "./esm/web/index.js",
69
+ "require": "./cjs/web/index.js",
70
+ "types": "./types/web/index.d.ts"
17
71
  },
18
- "devDependencies": {
19
- "@camstreamer/eslint-config": "^1.0.2",
20
- "@camstreamer/prettier-config": "^2.0.4",
21
- "@types/adm-zip": "^0.5.5",
22
- "@types/jest": "^28.0.0",
23
- "@types/node": "^18.19.127",
24
- "@types/ws": "^8.5.10",
25
- "@typescript-eslint/eslint-plugin": "^6.8.0",
26
- "@typescript-eslint/parser": "^6.8.0",
27
- "eslint": "^8.51.0",
28
- "eslint-plugin-deprecation": "^2.0.0",
29
- "eslint-plugin-unused-imports": "^3.0.0",
30
- "jest": "^28.1.3",
31
- "npm-run-all": "^4.1.5",
32
- "prettier": "^2.7.1",
33
- "ts-jest": "^28.0.0",
34
- "ts-node": "^10.7.0",
35
- "typescript": "5.3.3"
72
+ "./node": {
73
+ "import": "./esm/node/index.js",
74
+ "require": "./cjs/node/index.js",
75
+ "types": "./types/node/index.d.ts"
36
76
  },
37
- "overrides": {
38
- "js-yaml": "^4.2.0"
77
+ "./cjs/index": {
78
+ "import": "./esm/index.js",
79
+ "require": "./cjs/index.js",
80
+ "types": "./types/index.d.ts"
39
81
  },
40
- "scripts": {
41
- "clean": "rimraf dist/*",
42
- "build": "npm-run-all clean build:cjs build:esm copyPackage",
43
- "build:cjs": "tsc --project tsconfig.cjs.json",
44
- "build:esm": "tsc --project tsconfig.esm.json",
45
- "copyPackage": "cp -f LICENSE dist/ && cp -f README.md dist/ && cp -f package.json dist/",
46
- "publishPackage": "./publish.sh",
47
- "lint": "eslint \"src/**/*.ts\"",
48
- "lint:fix": "eslint \"src/**/*.ts\" --fix",
49
- "pretty": "prettier --write \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
50
- "pretty:check": "prettier --check \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
51
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
52
- "audit": "npm audit --audit-level=high"
82
+ "./cjs/node": {
83
+ "import": "./esm/node/index.js",
84
+ "require": "./cjs/node/index.js",
85
+ "types": "./types/node/index.js"
53
86
  },
54
- "files": [
55
- "/**/*.js",
56
- "/**/*.ts"
57
- ],
58
- "main": "./cjs/index.js",
59
- "module": "./esm/index.js",
60
- "types": "types/index.d.ts",
61
- "exports": {
62
- ".": {
63
- "import": "./esm/index.js",
64
- "require": "./cjs/index.js",
65
- "types": "./types/index.d.ts"
66
- },
67
- "./web": {
68
- "import": "./esm/web/index.js",
69
- "require": "./cjs/web/index.js",
70
- "types": "./types/web/index.d.ts"
71
- },
72
- "./node": {
73
- "import": "./esm/node/index.js",
74
- "require": "./cjs/node/index.js",
75
- "types": "./types/node/index.d.ts"
76
- },
77
- "./cjs/index": {
78
- "import": "./esm/index.js",
79
- "require": "./cjs/index.js",
80
- "types": "./types/index.d.ts"
81
- },
82
- "./cjs/node": {
83
- "import": "./esm/node/index.js",
84
- "require": "./cjs/node/index.js",
85
- "types": "./types/node/index.js"
86
- },
87
- "./cjs/node/index": {
88
- "import": "./esm/node/index.js",
89
- "require": "./cjs/node/index.js",
90
- "types": "./types/node/index.js"
91
- }
92
- },
93
- "repository": {
94
- "type": "git",
95
- "url": "git+https://github.com/CamStreamer/CamStreamerLib.git"
96
- },
97
- "keywords": [
98
- "CamStreamer",
99
- "CamOverlay",
100
- "CamScripter",
101
- "Camera",
102
- "Axis"
103
- ],
104
- "author": "CamStreamer s.r.o",
105
- "license": "ISC",
106
- "bugs": {
107
- "url": "https://github.com/CamStreamer/CamStreamerLib/issues"
108
- },
109
- "homepage": "https://github.com/CamStreamer/CamStreamerLib#readme"
87
+ "./cjs/node/index": {
88
+ "import": "./esm/node/index.js",
89
+ "require": "./cjs/node/index.js",
90
+ "types": "./types/node/index.js"
91
+ }
92
+ },
93
+ "repository": {
94
+ "type": "git",
95
+ "url": "git+https://github.com/CamStreamer/CamStreamerLib.git"
96
+ },
97
+ "keywords": [
98
+ "CamStreamer",
99
+ "CamOverlay",
100
+ "CamScripter",
101
+ "Camera",
102
+ "Axis"
103
+ ],
104
+ "author": "CamStreamer s.r.o",
105
+ "license": "ISC",
106
+ "bugs": {
107
+ "url": "https://github.com/CamStreamer/CamStreamerLib/issues"
108
+ },
109
+ "homepage": "https://github.com/CamStreamer/CamStreamerLib#readme"
110
110
  }
@@ -144,7 +144,24 @@ export declare class CamSwitcherAPI<Client extends IClient<TResponse, any>> exte
144
144
  setSecondaryAudioSettings(settings: TSecondaryAudioSettings, options?: THttpRequestOptions): Promise<void>;
145
145
  setDefaultPlaylist(playlistId: string, options?: THttpRequestOptions): Promise<void>;
146
146
  setPermanentRtspUrlToken(token: string, options?: THttpRequestOptions): Promise<void>;
147
- getCamSwitchOptions(options?: THttpRequestOptions): Promise<any>;
147
+ getCamSwitchOptions(options?: THttpRequestOptions): Promise<{
148
+ resolution?: string | undefined;
149
+ compression?: number | undefined;
150
+ bitrateMode?: "VBR" | "MBR" | "ABR" | undefined;
151
+ maximumBitRate?: number | undefined;
152
+ retentionTime?: number | undefined;
153
+ bitRateLimit?: number | undefined;
154
+ fps?: number | undefined;
155
+ govLength?: number | undefined;
156
+ h264Profile?: "high" | "main" | "baseline" | undefined;
157
+ keyboard?: {
158
+ none: string | null;
159
+ fromSource: string | null;
160
+ } | undefined;
161
+ bitrateVapixParams?: string | null | undefined;
162
+ audioSampleRate?: number | undefined;
163
+ audioChannelCount?: 1 | 2 | undefined;
164
+ }>;
148
165
  getGlobalAudioSettings(options?: THttpRequestOptions): Promise<{
149
166
  type: "source" | "fromSource";
150
167
  source: string;
@@ -0,0 +1 @@
1
+ export declare const jsonParseCameraParam: (param: string, paramName: string) => any;
package/types/index.d.ts CHANGED
@@ -26,3 +26,4 @@ export { CamScripterAPI } from './CamScripterAPI';
26
26
  export * from './types/CamScripterAPI';
27
27
  export { VapixAPI } from './VapixAPI';
28
28
  export * from './types/VapixAPI';
29
+ export * from './helpers';