camstreamerlib 4.0.31 → 4.0.32-c4420aa
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 +9 -0
- package/cjs/CamSwitcherAPI.d.ts +1 -1
- package/cjs/CamSwitcherAPI.js +8 -14
- package/cjs/browser.index.d.ts +2 -0
- package/cjs/browser.index.js +18 -0
- package/cjs/errors/errors.d.ts +3 -0
- package/cjs/errors/errors.js +8 -1
- package/esm/CamSwitcherAPI.js +9 -15
- package/esm/browser.index.js +2 -0
- package/esm/errors/errors.js +6 -0
- package/examples/README.md +43 -0
- package/examples/camstreamerlib.js +13201 -0
- package/examples/camswitcher-events.html +137 -0
- package/examples/planetracker-events.html +186 -0
- package/examples/utils/example.css +102 -0
- package/package.json +106 -103
- package/types/CamSwitcherAPI.d.ts +1 -1
- package/types/browser.index.d.ts +2 -0
- package/types/errors/errors.d.ts +3 -0
package/README.md
CHANGED
|
@@ -39,6 +39,15 @@ npm install camstreamerlib
|
|
|
39
39
|
|
|
40
40
|
</br>
|
|
41
41
|
|
|
42
|
+
# Examples
|
|
43
|
+
|
|
44
|
+
| Example | Description | Open in browser |
|
|
45
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
46
|
+
| [CamSwitcherEvents](examples/camswitcher-events.html) ([source](https://github.com/CamStreamer/CamStreamerLib/blob/master/examples/camswitcher-events.html)) | Logs every CamSwitcher event. `DeviceConnectClient` (HTTP) backs [CamSwitcherAPI](doc/CamSwitcherAPI.md) to obtain the websocket authorization token, `DeviceConnectWsClient` (websocket) backs [CamSwitcherEvents](doc/ws/CamSwitcherEvents.md), which validates and dispatches the events. Connection state is taken from the `authorization` event. | [open](https://raw.githack.com/CamStreamer/CamStreamerLib/master/examples/camswitcher-events.html) |
|
|
47
|
+
| [PlaneTrackerEvents](examples/planetracker-events.html) ([source](https://github.com/CamStreamer/CamStreamerLib/blob/master/examples/planetracker-events.html)) | Logs every PlaneTracker event. PlaneTracker needs no authorization token — [PlaneTrackerEvents](doc/ws/PlaneTrackerEvents.md) announces the connecting user (`userId` / `userName` / `userPriority`, editable in the form) as the init message instead, so only the websocket client is needed. The continuous `CAMERA_POSITION` and `FLIGHT_LIST` events only update the summary line unless the checkbox is ticked. | [open](https://raw.githack.com/CamStreamer/CamStreamerLib/master/examples/planetracker-events.html) |
|
|
48
|
+
|
|
49
|
+
</br>
|
|
50
|
+
|
|
42
51
|
# Breaking Changes
|
|
43
52
|
|
|
44
53
|
<details open>
|
package/cjs/CamSwitcherAPI.d.ts
CHANGED
|
@@ -161,7 +161,7 @@ export declare class CamSwitcherAPI<Client extends IClient<TResponse, any>> exte
|
|
|
161
161
|
bitrateVapixParams?: string | null | undefined;
|
|
162
162
|
audioSampleRate?: number | undefined;
|
|
163
163
|
audioChannelCount?: 1 | 2 | undefined;
|
|
164
|
-
}>;
|
|
164
|
+
} | undefined>;
|
|
165
165
|
getGlobalAudioSettings(options?: THttpRequestOptions): Promise<{
|
|
166
166
|
type: "source" | "fromSource";
|
|
167
167
|
source: string;
|
package/cjs/CamSwitcherAPI.js
CHANGED
|
@@ -34,15 +34,13 @@ class CamSwitcherAPI extends BasicAPI_1.BasicAPI {
|
|
|
34
34
|
return common_1.networkCameraListSchema.parse(res.data);
|
|
35
35
|
}
|
|
36
36
|
async generateSilence(sampleRate, channels, options) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
timeout: options?.timeout,
|
|
45
|
-
});
|
|
37
|
+
const res = await this._getJson(`${BASE_PATH}/generate_silence.cgi`, {
|
|
38
|
+
sample_rate: sampleRate.toString(),
|
|
39
|
+
channels,
|
|
40
|
+
}, options);
|
|
41
|
+
if (res.status !== 200) {
|
|
42
|
+
throw new errors_1.GenerateSilenceError(res.message);
|
|
43
|
+
}
|
|
46
44
|
}
|
|
47
45
|
async getMaxFps(source, options) {
|
|
48
46
|
const res = await this._getJson(`${BASE_PATH}/get_max_framerate.cgi`, {
|
|
@@ -204,11 +202,7 @@ class CamSwitcherAPI extends BasicAPI_1.BasicAPI {
|
|
|
204
202
|
async getCamSwitchOptions(options) {
|
|
205
203
|
const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS, options);
|
|
206
204
|
if ((0, utils_1.isNullish)(saveData.video)) {
|
|
207
|
-
return
|
|
208
|
-
audioSampleRate: saveData.audio?.sampleRate,
|
|
209
|
-
audioChannelCount: saveData.audio?.channelCount,
|
|
210
|
-
keyboard: saveData.keyboard,
|
|
211
|
-
});
|
|
205
|
+
return;
|
|
212
206
|
}
|
|
213
207
|
const settings = {
|
|
214
208
|
audioSampleRate: saveData.audio?.sampleRate,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./index"), exports);
|
|
18
|
+
__exportStar(require("./web/index"), exports);
|
package/cjs/errors/errors.d.ts
CHANGED
|
@@ -49,6 +49,9 @@ export declare class FetchDeviceInfoError extends Error {
|
|
|
49
49
|
export declare class AddNewClipError extends Error {
|
|
50
50
|
constructor(message: string);
|
|
51
51
|
}
|
|
52
|
+
export declare class GenerateSilenceError extends Error {
|
|
53
|
+
constructor(message: string);
|
|
54
|
+
}
|
|
52
55
|
export declare class PtzNotSupportedError extends Error {
|
|
53
56
|
constructor();
|
|
54
57
|
}
|
package/cjs/errors/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MigrationError = exports.BadRequestError = exports.ServerError = exports.InvalidAltitudeError = exports.InvalidLatLngError = exports.CannotSetCoordsInAutoModeError = exports.ImportSettingsError = exports.ResetCalibrationError = exports.TimezoneFetchError = exports.TimezoneNotSetupError = exports.UtcTimeFetchError = exports.WsAuthorizationError = exports.StorageDataFetchError = exports.PtzNotSupportedError = exports.AddNewClipError = exports.FetchDeviceInfoError = exports.NoDeviceInfoError = exports.MaxFPSError = exports.SDCardJobError = exports.SDCardActionError = exports.ApplicationAPIError = exports.SettingParameterError = exports.ParameterNotFoundError = exports.JsonParseError = exports.ParsingBlobError = exports.ServiceNotFoundError = exports.ServiceUnavailableError = exports.ErrorWithResponse = void 0;
|
|
3
|
+
exports.MigrationError = exports.BadRequestError = exports.ServerError = exports.InvalidAltitudeError = exports.InvalidLatLngError = exports.CannotSetCoordsInAutoModeError = exports.ImportSettingsError = exports.ResetCalibrationError = exports.TimezoneFetchError = exports.TimezoneNotSetupError = exports.UtcTimeFetchError = exports.WsAuthorizationError = exports.StorageDataFetchError = exports.PtzNotSupportedError = exports.GenerateSilenceError = exports.AddNewClipError = exports.FetchDeviceInfoError = exports.NoDeviceInfoError = exports.MaxFPSError = exports.SDCardJobError = exports.SDCardActionError = exports.ApplicationAPIError = exports.SettingParameterError = exports.ParameterNotFoundError = exports.JsonParseError = exports.ParsingBlobError = exports.ServiceNotFoundError = exports.ServiceUnavailableError = exports.ErrorWithResponse = void 0;
|
|
4
4
|
class ErrorWithResponse extends Error {
|
|
5
5
|
res;
|
|
6
6
|
constructor(res) {
|
|
@@ -111,6 +111,13 @@ class AddNewClipError extends Error {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
exports.AddNewClipError = AddNewClipError;
|
|
114
|
+
class GenerateSilenceError extends Error {
|
|
115
|
+
constructor(message) {
|
|
116
|
+
super('Error generating silence clip: ' + message);
|
|
117
|
+
this.name = 'GenerateSilenceError';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.GenerateSilenceError = GenerateSilenceError;
|
|
114
121
|
class PtzNotSupportedError extends Error {
|
|
115
122
|
constructor() {
|
|
116
123
|
super('Ptz not supported.');
|
package/esm/CamSwitcherAPI.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { AddNewClipError, ParameterNotFoundError } from './errors/errors';
|
|
2
|
+
import { AddNewClipError, GenerateSilenceError, ParameterNotFoundError } from './errors/errors';
|
|
3
3
|
import { parseBitrateOptionsToVapixParams, parseVapixParamsToBitrateOptions } from './internal/convertors';
|
|
4
4
|
import { isClip, isNullish } from './internal/utils';
|
|
5
5
|
import { storageInfoListSchema, outputInfoSchema, audioPushInfoSchema, clipListSchema, playlistQueueSchema, streamSaveLoadSchema, clipSaveLoadSchema, playlistSaveLoadSchema, trackerSaveLoadSchema, secondaryAudioSettingsSchema, globalAudioSettingsSchema, clipFilesListSchema, cameraOptionsSchema, } from './types/CamSwitcherAPI';
|
|
@@ -31,15 +31,13 @@ export class CamSwitcherAPI extends BasicAPI {
|
|
|
31
31
|
return networkCameraListSchema.parse(res.data);
|
|
32
32
|
}
|
|
33
33
|
async generateSilence(sampleRate, channels, options) {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
timeout: options?.timeout,
|
|
42
|
-
});
|
|
34
|
+
const res = await this._getJson(`${BASE_PATH}/generate_silence.cgi`, {
|
|
35
|
+
sample_rate: sampleRate.toString(),
|
|
36
|
+
channels,
|
|
37
|
+
}, options);
|
|
38
|
+
if (res.status !== 200) {
|
|
39
|
+
throw new GenerateSilenceError(res.message);
|
|
40
|
+
}
|
|
43
41
|
}
|
|
44
42
|
async getMaxFps(source, options) {
|
|
45
43
|
const res = await this._getJson(`${BASE_PATH}/get_max_framerate.cgi`, {
|
|
@@ -201,11 +199,7 @@ export class CamSwitcherAPI extends BasicAPI {
|
|
|
201
199
|
async getCamSwitchOptions(options) {
|
|
202
200
|
const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS, options);
|
|
203
201
|
if (isNullish(saveData.video)) {
|
|
204
|
-
return
|
|
205
|
-
audioSampleRate: saveData.audio?.sampleRate,
|
|
206
|
-
audioChannelCount: saveData.audio?.channelCount,
|
|
207
|
-
keyboard: saveData.keyboard,
|
|
208
|
-
});
|
|
202
|
+
return;
|
|
209
203
|
}
|
|
210
204
|
const settings = {
|
|
211
205
|
audioSampleRate: saveData.audio?.sampleRate,
|
package/esm/errors/errors.js
CHANGED
|
@@ -94,6 +94,12 @@ export class AddNewClipError extends Error {
|
|
|
94
94
|
this.name = 'AddNewClipError';
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
export class GenerateSilenceError extends Error {
|
|
98
|
+
constructor(message) {
|
|
99
|
+
super('Error generating silence clip: ' + message);
|
|
100
|
+
this.name = 'GenerateSilenceError';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
97
103
|
export class PtzNotSupportedError extends Error {
|
|
98
104
|
constructor() {
|
|
99
105
|
super('Ptz not supported.');
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
Standalone browser examples that use CamStreamerLib directly from a `<script type="module">`,
|
|
4
|
+
without a bundler or a framework.
|
|
5
|
+
|
|
6
|
+
## Build the browser bundle
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install
|
|
10
|
+
npm run build:browser
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Run
|
|
14
|
+
|
|
15
|
+
Modules can't be loaded over `file://`, so serve the folder over HTTP:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx serve examples
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Both pages connect to a camera through the Device Connect proxy. Fill in the device host
|
|
22
|
+
(`<MAC_ADDRESS>.device-connect.net`) and the device access token in the form, or hardcode them in the
|
|
23
|
+
`DEVICE_HOST` / `DEVICE_ACCESS_TOKEN` constants at the top of the page's script to have the form
|
|
24
|
+
prefilled. See [doc/Client.md](../doc/Client.md).
|
|
25
|
+
|
|
26
|
+
## camswitcher-events.html
|
|
27
|
+
|
|
28
|
+
Logs every CamSwitcher event. `DeviceConnectClient` (HTTP) backs `CamSwitcherAPI` to obtain the
|
|
29
|
+
websocket authorization token; `DeviceConnectWsClient` (websocket) backs `CamSwitcherEvents`, which
|
|
30
|
+
validates and dispatches the events. Connection state is taken from the `authorization` event.
|
|
31
|
+
|
|
32
|
+
See [doc/ws/CamSwitcherEvents.md](../doc/ws/CamSwitcherEvents.md).
|
|
33
|
+
|
|
34
|
+
## planetracker-events.html
|
|
35
|
+
|
|
36
|
+
Logs every PlaneTracker event. PlaneTracker needs no authorization token — `PlaneTrackerEvents`
|
|
37
|
+
announces the connecting user (`userId` / `userName` / `userPriority`, editable in the form) as the
|
|
38
|
+
init message instead, so only the websocket client is needed.
|
|
39
|
+
|
|
40
|
+
`CAMERA_POSITION` and `FLIGHT_LIST` arrive continuously, so by default they only update the summary
|
|
41
|
+
line above the log; tick the checkbox to log them as well.
|
|
42
|
+
|
|
43
|
+
See [doc/ws/PlaneTrackerEvents.md](../doc/ws/PlaneTrackerEvents.md).
|