camstreamerlib 4.0.0-beta.4 → 4.0.0-beta.6

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 ADDED
@@ -0,0 +1,101 @@
1
+ # CamStreamerLib - BETA
2
+
3
+ **This is beta version of CamStreamerLib v4, dont use it on production. Is going to be changed significantly.**
4
+
5
+ **The documentation is in progress**
6
+
7
+ Node.js helper library for CamStreamer ACAP applications.
8
+
9
+ The library is primarily developed for the CamScripter ACAP application running directly in Axis cameras.
10
+ Examples of CamScripter packages can be found at https://github.com/CamStreamer/CamScripterApp_examples
11
+
12
+ ## Installation
13
+
14
+ ```
15
+ npm install camstreamerlib
16
+ ```
17
+
18
+ # Documentation for Node.js modules
19
+
20
+ - [HttpServer](doc/HttpServer.md) is a module for processing HTTP requests in your scripts. It also automatically serves up the content from html directory or you can register paths which you can process by your own (e.g. http://$CAMERA_IP/local/camscripter/proxy/$MY_PACKAGE_NAME/control.cgi).
21
+
22
+ - [VapixAPI](doc/VapixAPI.md) is a module to access Axis camera VAPIX interface.
23
+
24
+ - [CamStreamerAPI](doc/CamStreamerAPI.md) is a module for easy control of video streaming in the CamStreamer ACAP application (RTMP, HLS, SRT and MPEG-TS protocols).
25
+
26
+ - [CamOverlayAPI](doc/CamOverlayAPI.md) is a module to access CamOverlay HTTP interface.
27
+
28
+ - [CamOverlayDrawingAPI](doc/CamOverlayDrawingAPI.md) is a module for easy control of CamOverlay drawing API. For more details on supported video overlay drawing functions see https://camstreamer.com/camoverlay-api1
29
+
30
+ - [CamOverlayPainter/](doc/CamOverlayPainter.md) contains three modules which makes easier to use CamOverlayDrawingAPI.
31
+
32
+ - [CamScripterAPICameraEventsGenerator](doc/CamScripterAPICameraEventsGenerator.md) is a module which allows generating events on an Axis camera. These events can be used for triggers in the Axis camera rule engine (events/actions). It is also an easy way how to integrate events and metadata in VMS systems which support Axis camera events.
33
+
34
+ - [CamSwitcherAPI](doc/CamSwitcherAPI.md) is a module to access CamSwitcher API.
35
+
36
+ - [CamSwitcherEvents](doc/CamSwitcherEvents.md) is a module which allows receiving events from CamSwitcher ACAP application.
37
+
38
+ - [VapixEvents](doc/VapixEvents.md) is a module which allows receiving camera events from the VAPIX API.
39
+
40
+ - [GenetecAgent](doc/GenetecAgent.md) is a module which allows receiving and sending data to Genetec VMS.
41
+
42
+ ## For Developers
43
+
44
+ ### Publishing to npm repository
45
+
46
+ 1. Update version in package.json and push it
47
+ 2. Create git tag e.g. v1.2.4
48
+
49
+ - `git tag v1.2.4`
50
+ - `git push --tags`
51
+
52
+ 3. Publish new version to npm
53
+
54
+ - `npm publish ./dist`
55
+
56
+ 4. Edit GitHub release form.
57
+
58
+ ### Preparing a package to upload to CamScripter
59
+
60
+ If you want to create your own package and upload it to CamScripter App, you can use the script CreatePackage. It creates a zip file which contains all required files and directories in your package folder. The script accepts source code written either in JavaScript or TypeScript if the package has the correct structure (more information in https://github.com/CamStreamer/CamScripterApp_examples/#readme). To include this script in your package add the following lines in the file package.json:
61
+
62
+ ```json
63
+ "scripts": {
64
+ "create-package": "node node_modules/camstreamerlib/CreatePackage.js"
65
+ }
66
+ ```
67
+
68
+ By default, the zipped package does not contain node_modules directory. If you want to include it (required when uploading to CamScripter App on Axis camera), add `-includeNodeModules` or `-i` parameter.
69
+
70
+ If you need to exclude a file or directory add `-exlude=` or `-e=` parameter with comma separated list.
71
+
72
+ The zip package is created in the current directory. You can choose different location with the `-where=` or `-w=` option.
73
+
74
+ ```json
75
+ "scripts": {
76
+ "create-package": "node node_modules/camstreamerlib/CreatePackage.js -i -e=react"
77
+ }
78
+ ```
79
+
80
+ ### Breaking changes when moving from version 1.\*.\* to 2.\*.\*
81
+
82
+ - Renamed file HTTPRequest.ts to HttpRequest.ts
83
+ - Removed deprecated protocol attribute from all options objects (use tls instead).
84
+ - Removed RTSP
85
+ > Previously CameraVapix.ts supported both WebSocket and RTSP.
86
+ > Starting with version 2.0.0, it supports WebSocket only.
87
+ - ServiceID shouldn't be passed to CamOverlayAPI by the options object. Pass it as a parameter.
88
+ - Renamed CamOverlayDrawingAPI event msg to message.
89
+ - Drawing services extracted from CamOverlayAPI.ts to a separate file.
90
+ > Please read [CamOverlayAPI](doc/CamOverlayAPI.md) and [CamOverlayDrawingAPI](doc/CamOverlayDrawingAPI.md) for more information.
91
+
92
+ ### Breaking changes when moving from version 2.\*.\* to 3.\*.\*
93
+
94
+ - CamStreamerlib requiers Node.js version 18 or higher.
95
+ - CamOverlayDrawingAPI tries to reconnect when the websocket is closed. You don't have to do it manually.
96
+ > However, events `open` and `close` are still emitted in case you need to react to them.
97
+ - Files common.ts, Digest.ts, HttpRequest.ts and WsClient.ts moved to a folder internal.
98
+ - Removed function httpRequest(). Use sendRequest() instead. It uses the same interface except for the "noWaitForData" parameter.
99
+ > It returns (Response object)[https://developer.mozilla.org/en-US/docs/Web/API/Response] which doesn't contain data by default.
100
+ > If you need to wait for data, you can call for example the function `await res.text()`.
101
+ > This change affects the function `vapixGet` from (CameraVapix)[doc/CameraVapix.md] too.
package/cjs/VapixAPI.js CHANGED
@@ -336,7 +336,7 @@ class VapixAPI {
336
336
  return this.getUrlEncoded(proxy, '/axis-cgi/io/port.cgi', { action: active ? `${port}:/` : `${port}:\\` });
337
337
  }
338
338
  async getApplicationList(proxy = null) {
339
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/list.cgi');
339
+ const res = await this.client.get(proxy, '/axis-cgi/applications/list.cgi');
340
340
  const xml = await res.text();
341
341
  const result = (await (0, xml2js_1.parseStringPromise)(xml));
342
342
  const apps = [];
@@ -349,7 +349,7 @@ class VapixAPI {
349
349
  return apps;
350
350
  }
351
351
  async startApplication(applicationID, proxy = null) {
352
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/control.cgi', {
352
+ const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
353
353
  package: applicationID.toLowerCase(),
354
354
  action: 'start',
355
355
  });
@@ -359,7 +359,7 @@ class VapixAPI {
359
359
  }
360
360
  }
361
361
  async restartApplication(applicationID, proxy = null) {
362
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/control.cgi', {
362
+ const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
363
363
  package: applicationID.toLowerCase(),
364
364
  action: 'restart',
365
365
  });
@@ -369,7 +369,7 @@ class VapixAPI {
369
369
  }
370
370
  }
371
371
  async stopApplication(applicationID, proxy = null) {
372
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/control.cgi', {
372
+ const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
373
373
  package: applicationID.toLowerCase(),
374
374
  action: 'stop',
375
375
  });
@@ -403,7 +403,7 @@ const parseParameters = (response) => {
403
403
  }
404
404
  const delimiterPos = line.indexOf('=');
405
405
  if (delimiterPos !== -1) {
406
- const paramName = line.substring(0, delimiterPos);
406
+ const paramName = line.substring(0, delimiterPos).replace('root.', '');
407
407
  const paramValue = line.substring(delimiterPos + 1);
408
408
  params[paramName] = paramValue;
409
409
  }
package/esm/VapixAPI.js CHANGED
@@ -333,7 +333,7 @@ export class VapixAPI {
333
333
  return this.getUrlEncoded(proxy, '/axis-cgi/io/port.cgi', { action: active ? `${port}:/` : `${port}:\\` });
334
334
  }
335
335
  async getApplicationList(proxy = null) {
336
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/list.cgi');
336
+ const res = await this.client.get(proxy, '/axis-cgi/applications/list.cgi');
337
337
  const xml = await res.text();
338
338
  const result = (await parseStringPromise(xml));
339
339
  const apps = [];
@@ -346,7 +346,7 @@ export class VapixAPI {
346
346
  return apps;
347
347
  }
348
348
  async startApplication(applicationID, proxy = null) {
349
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/control.cgi', {
349
+ const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
350
350
  package: applicationID.toLowerCase(),
351
351
  action: 'start',
352
352
  });
@@ -356,7 +356,7 @@ export class VapixAPI {
356
356
  }
357
357
  }
358
358
  async restartApplication(applicationID, proxy = null) {
359
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/control.cgi', {
359
+ const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
360
360
  package: applicationID.toLowerCase(),
361
361
  action: 'restart',
362
362
  });
@@ -366,7 +366,7 @@ export class VapixAPI {
366
366
  }
367
367
  }
368
368
  async stopApplication(applicationID, proxy = null) {
369
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/control.cgi', {
369
+ const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
370
370
  package: applicationID.toLowerCase(),
371
371
  action: 'stop',
372
372
  });
@@ -399,7 +399,7 @@ const parseParameters = (response) => {
399
399
  }
400
400
  const delimiterPos = line.indexOf('=');
401
401
  if (delimiterPos !== -1) {
402
- const paramName = line.substring(0, delimiterPos);
402
+ const paramName = line.substring(0, delimiterPos).replace('root.', '');
403
403
  const paramValue = line.substring(delimiterPos + 1);
404
404
  params[paramName] = paramValue;
405
405
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "4.0.0-beta.4",
3
+ "version": "4.0.0-beta.6",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "dependencies": {
@@ -43,7 +43,7 @@
43
43
  "build": "npm-run-all clean build:cjs build:esm copyPackage",
44
44
  "build:cjs": "tsc --project tsconfig.cjs.json",
45
45
  "build:esm": "tsc --project tsconfig.esm.json",
46
- "copyPackage": "cp -f LICENSE dist/ && cp -f package.json dist/",
46
+ "copyPackage": "cp -f LICENSE dist/ && cp -f README.md dist/ && cp -f package.json dist/",
47
47
  "prepublish": "npm run build",
48
48
  "lint": "eslint \"src/**/*.ts\"",
49
49
  "lint:fix": "eslint \"src/**/*.ts\" --fix",