camstreamerlib 4.0.0-beta.161 → 4.0.0-beta.163

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 CHANGED
@@ -1,13 +1,8 @@
1
1
  # CamStreamerLib - BETA
2
2
 
3
- **This is beta version of CamStreamerLib v4, dont use it on production. Is going to be changed significantly.**
3
+ Web and Node.js helper library for CamStreamer ACAP applications.
4
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
5
+ The library is primarily developed for ACAP applications running directly in Axis cameras.
11
6
 
12
7
  ## Installation
13
8
 
@@ -26,7 +21,7 @@ npm install camstreamerlib
26
21
  | [CamSwitcherAPI](doc/CamSwitcherAPI.md) | Module to access CamSwitcher API. |
27
22
  | [PlaneTrackerAPI](doc/PlaneTrackerAPI.md) | Module to access PlaneTracker API. |
28
23
  | [CamStreamerEvents](doc/ws/CamStreamerEvents.md) | Module which allows receiving events from CamStreamer ACAP application. |
29
- | [OverlayEvents](doc/ws/OverlayEvents.md) | Module which allows receiving events from Overlay ACAP application. |
24
+ | [CamOverlayEvents](doc/ws/CamOverlayEvents.md) | Module which allows receiving events from CamOverlay ACAP application. |
30
25
  | [CamSwitcherEvents](doc/ws/CamSwitcherEvents.md) | Module which allows receiving events from CamSwitcher ACAP application. |
31
26
  | [PlaneTrackerEvents](doc/ws/PlaneTrackerEvents.md) | Module which allows receiving events from PlaneTracker ACAP application. |
32
27
 
@@ -56,11 +51,11 @@ npm install camstreamerlib
56
51
 
57
52
  ### ACAP API Class Constructors Updated
58
53
 
59
- All ACAP API classes now **require a client instance to be passed into their constructors** instead of options object.
54
+ All ACAP API classes now **require a client instance to be passed into their constructors** instead of `options` object.
60
55
 
61
56
  - This change improves flexibility by allowing you to use either the Node or Web client, depending on your environment.
62
57
 
63
- Example (before → now):
58
+ **Example (before → now)**:
64
59
 
65
60
  ```typescript
66
61
  // Before
@@ -78,6 +73,12 @@ const coApi = new CamOverlayAPI({
78
73
  import { DefaultClient } from 'camstreamerlib/web';
79
74
  import { CamOverlayAPI } from 'camstreamerlib';
80
75
 
76
+ // Use DefaultClient in constructor
77
+ const coApi = new CamOverlayAPI(
78
+ new DefaultClient()
79
+ );
80
+
81
+ // Or adjust DefaultClient default values with your own
81
82
  const coApi = new CamOverlayAPI(
82
83
  new DefaultClient({
83
84
  tls: false,
@@ -109,17 +110,43 @@ import { Painter } from 'camstreamerlib/node';
109
110
  import { DefaultClient } from 'camstreamerlib/web';
110
111
  ```
111
112
 
112
- > Note: To ensure compatibility, set the module resolution in your projects tsconfig.json to `"moduleResolution": "bundler"`.
113
+ > :information_source: Note: To ensure compatibility, set the module resolution in your web projects tsconfig.json to `"moduleResolution": "bundler"`.
113
114
 
114
- ### Class and Method Refactored
115
+ ### Classes and Methods Refactored
115
116
 
116
117
  - **CameraVapix API** has been renamed to [**VapixAPI**](doc/VapixAPI.md).
117
118
  - **DefaultAgent** has been refactored into two separate classes - one for node, one for web as [**DefaultClient**](doc/Client.md)
118
119
  - Several method names and parameter names across the library have been updated for consistency and clarity.
120
+ - New API modules and endpoints have been introduced, providing extended functionality and better coverage of the underlying service.
119
121
 
120
- > Please refer to [the documentation](#documentation-for-acap-and-camera-api).
122
+ ### Stream List Migration
121
123
 
122
- - New API modules and endpoints have been introduced, providing extended functionality and better coverage of the underlying service.
124
+ - `CamStreamerAPI.getStreamList()` and `getStream()` now throw a **`MigrationError`** when old-format (v3) stream data is detected on the camera.
125
+ - `MigrationError` provides four arrays to help you handle the transition: `.valid`, `.old`, `.invalid`, and `.unknown`.
126
+
127
+ ```typescript
128
+ import { MigrationError } from 'camstreamerlib';
129
+
130
+ try {
131
+ const streams = await csApi.getStreamList();
132
+ } catch (e) {
133
+ if (e instanceof MigrationError) {
134
+ console.log('Valid streams:', e.valid);
135
+ console.log('Old-format streams needing migration:', e.old);
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### CreatePackage Script Path Changed
141
+
142
+ - The path to the `CreatePackage` script changed from `camstreamerlib/CreatePackage.js` to `camstreamerlib/bin/CreatePackage.js`.
143
+ - Update any `package.json` scripts accordingly:
144
+
145
+ ```json
146
+ "scripts": {
147
+ "create-package": "node node_modules/camstreamerlib/bin/CreatePackage.js"
148
+ }
149
+ ```
123
150
 
124
151
  <hr/>
125
152
  </details>
@@ -204,3 +231,5 @@ The zip package is created in the current directory. You can choose different lo
204
231
  "create-package": "node node_modules/camstreamerlib/bin/CreatePackage.js -i -e=react"
205
232
  }
206
233
  ```
234
+
235
+ > :warning: Path to `CreatePackage` script has changed from `camstreamerlib/CreatePackage.js` to `camstreamerlib/bin/CreatePackage.js` (from v.4.0.0)
@@ -81,6 +81,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
81
81
  internalVapixParameters: string;
82
82
  } | {
83
83
  type: "CSw";
84
+ internalVapixParameters: string;
84
85
  } | {
85
86
  type: "CRS";
86
87
  internalVapixParameters: string;
@@ -169,6 +170,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
169
170
  internalVapixParameters: string;
170
171
  } | {
171
172
  type: "CSw";
173
+ internalVapixParameters: string;
172
174
  } | {
173
175
  type: "CRS";
174
176
  internalVapixParameters: string;
@@ -203,6 +205,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
203
205
  direction: "N" | "NE" | "E" | "SE" | "S" | "SW" | "W" | "NW" | null;
204
206
  position: "fix" | "rotating" | "controllable";
205
207
  webPageUrl: string;
208
+ mediaServerUrl: string | null;
206
209
  } | {
207
210
  status: {
208
211
  led: boolean;
@@ -262,6 +265,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
262
265
  internalVapixParameters: string;
263
266
  } | {
264
267
  type: "CSw";
268
+ internalVapixParameters: string;
265
269
  } | {
266
270
  type: "CRS";
267
271
  internalVapixParameters: string;
@@ -358,6 +362,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
358
362
  internalVapixParameters: string;
359
363
  } | {
360
364
  type: "CSw";
365
+ internalVapixParameters: string;
361
366
  } | {
362
367
  type: "CRS";
363
368
  internalVapixParameters: string;
@@ -443,6 +448,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
443
448
  internalVapixParameters: string;
444
449
  } | {
445
450
  type: "CSw";
451
+ internalVapixParameters: string;
446
452
  } | {
447
453
  type: "CRS";
448
454
  internalVapixParameters: string;
@@ -528,6 +534,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
528
534
  internalVapixParameters: string;
529
535
  } | {
530
536
  type: "CSw";
537
+ internalVapixParameters: string;
531
538
  } | {
532
539
  type: "CRS";
533
540
  internalVapixParameters: string;
@@ -613,6 +620,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
613
620
  internalVapixParameters: string;
614
621
  } | {
615
622
  type: "CSw";
623
+ internalVapixParameters: string;
616
624
  } | {
617
625
  type: "CRS";
618
626
  internalVapixParameters: string;
@@ -698,6 +706,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
698
706
  internalVapixParameters: string;
699
707
  } | {
700
708
  type: "CSw";
709
+ internalVapixParameters: string;
701
710
  } | {
702
711
  type: "CRS";
703
712
  internalVapixParameters: string;
@@ -783,6 +792,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
783
792
  internalVapixParameters: string;
784
793
  } | {
785
794
  type: "CSw";
795
+ internalVapixParameters: string;
786
796
  } | {
787
797
  type: "CRS";
788
798
  internalVapixParameters: string;
@@ -868,6 +878,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
868
878
  internalVapixParameters: string;
869
879
  } | {
870
880
  type: "CSw";
881
+ internalVapixParameters: string;
871
882
  } | {
872
883
  type: "CRS";
873
884
  internalVapixParameters: string;
@@ -953,6 +964,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
953
964
  internalVapixParameters: string;
954
965
  } | {
955
966
  type: "CSw";
967
+ internalVapixParameters: string;
956
968
  } | {
957
969
  type: "CRS";
958
970
  internalVapixParameters: string;
@@ -1038,6 +1050,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1038
1050
  internalVapixParameters: string;
1039
1051
  } | {
1040
1052
  type: "CSw";
1053
+ internalVapixParameters: string;
1041
1054
  } | {
1042
1055
  type: "CRS";
1043
1056
  internalVapixParameters: string;
@@ -1123,6 +1136,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1123
1136
  internalVapixParameters: string;
1124
1137
  } | {
1125
1138
  type: "CSw";
1139
+ internalVapixParameters: string;
1126
1140
  } | {
1127
1141
  type: "CRS";
1128
1142
  internalVapixParameters: string;
@@ -1208,6 +1222,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1208
1222
  internalVapixParameters: string;
1209
1223
  } | {
1210
1224
  type: "CSw";
1225
+ internalVapixParameters: string;
1211
1226
  } | {
1212
1227
  type: "CRS";
1213
1228
  internalVapixParameters: string;
@@ -1293,6 +1308,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1293
1308
  internalVapixParameters: string;
1294
1309
  } | {
1295
1310
  type: "CSw";
1311
+ internalVapixParameters: string;
1296
1312
  } | {
1297
1313
  type: "CRS";
1298
1314
  internalVapixParameters: string;
@@ -1378,6 +1394,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1378
1394
  internalVapixParameters: string;
1379
1395
  } | {
1380
1396
  type: "CSw";
1397
+ internalVapixParameters: string;
1381
1398
  } | {
1382
1399
  type: "CRS";
1383
1400
  internalVapixParameters: string;
@@ -1463,6 +1480,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1463
1480
  internalVapixParameters: string;
1464
1481
  } | {
1465
1482
  type: "CSw";
1483
+ internalVapixParameters: string;
1466
1484
  } | {
1467
1485
  type: "CRS";
1468
1486
  internalVapixParameters: string;
@@ -1548,6 +1566,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1548
1566
  internalVapixParameters: string;
1549
1567
  } | {
1550
1568
  type: "CSw";
1569
+ internalVapixParameters: string;
1551
1570
  } | {
1552
1571
  type: "CRS";
1553
1572
  internalVapixParameters: string;
@@ -1633,6 +1652,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1633
1652
  internalVapixParameters: string;
1634
1653
  } | {
1635
1654
  type: "CSw";
1655
+ internalVapixParameters: string;
1636
1656
  } | {
1637
1657
  type: "CRS";
1638
1658
  internalVapixParameters: string;
@@ -1718,6 +1738,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1718
1738
  internalVapixParameters: string;
1719
1739
  } | {
1720
1740
  type: "CSw";
1741
+ internalVapixParameters: string;
1721
1742
  } | {
1722
1743
  type: "CRS";
1723
1744
  internalVapixParameters: string;
@@ -1814,6 +1835,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1814
1835
  internalVapixParameters: string;
1815
1836
  } | {
1816
1837
  type: "CSw";
1838
+ internalVapixParameters: string;
1817
1839
  } | {
1818
1840
  type: "CRS";
1819
1841
  internalVapixParameters: string;
@@ -1902,6 +1924,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1902
1924
  internalVapixParameters: string;
1903
1925
  } | {
1904
1926
  type: "CSw";
1927
+ internalVapixParameters: string;
1905
1928
  } | {
1906
1929
  type: "CRS";
1907
1930
  internalVapixParameters: string;
@@ -1936,6 +1959,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1936
1959
  direction: "N" | "NE" | "E" | "SE" | "S" | "SW" | "W" | "NW" | null;
1937
1960
  position: "fix" | "rotating" | "controllable";
1938
1961
  webPageUrl: string;
1962
+ mediaServerUrl: string | null;
1939
1963
  } | {
1940
1964
  status: {
1941
1965
  led: boolean;
@@ -1995,6 +2019,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1995
2019
  internalVapixParameters: string;
1996
2020
  } | {
1997
2021
  type: "CSw";
2022
+ internalVapixParameters: string;
1998
2023
  } | {
1999
2024
  type: "CRS";
2000
2025
  internalVapixParameters: string;
@@ -2091,6 +2116,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2091
2116
  internalVapixParameters: string;
2092
2117
  } | {
2093
2118
  type: "CSw";
2119
+ internalVapixParameters: string;
2094
2120
  } | {
2095
2121
  type: "CRS";
2096
2122
  internalVapixParameters: string;
@@ -2176,6 +2202,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2176
2202
  internalVapixParameters: string;
2177
2203
  } | {
2178
2204
  type: "CSw";
2205
+ internalVapixParameters: string;
2179
2206
  } | {
2180
2207
  type: "CRS";
2181
2208
  internalVapixParameters: string;
@@ -2261,6 +2288,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2261
2288
  internalVapixParameters: string;
2262
2289
  } | {
2263
2290
  type: "CSw";
2291
+ internalVapixParameters: string;
2264
2292
  } | {
2265
2293
  type: "CRS";
2266
2294
  internalVapixParameters: string;
@@ -2346,6 +2374,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2346
2374
  internalVapixParameters: string;
2347
2375
  } | {
2348
2376
  type: "CSw";
2377
+ internalVapixParameters: string;
2349
2378
  } | {
2350
2379
  type: "CRS";
2351
2380
  internalVapixParameters: string;
@@ -2431,6 +2460,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2431
2460
  internalVapixParameters: string;
2432
2461
  } | {
2433
2462
  type: "CSw";
2463
+ internalVapixParameters: string;
2434
2464
  } | {
2435
2465
  type: "CRS";
2436
2466
  internalVapixParameters: string;
@@ -2516,6 +2546,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2516
2546
  internalVapixParameters: string;
2517
2547
  } | {
2518
2548
  type: "CSw";
2549
+ internalVapixParameters: string;
2519
2550
  } | {
2520
2551
  type: "CRS";
2521
2552
  internalVapixParameters: string;
@@ -2601,6 +2632,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2601
2632
  internalVapixParameters: string;
2602
2633
  } | {
2603
2634
  type: "CSw";
2635
+ internalVapixParameters: string;
2604
2636
  } | {
2605
2637
  type: "CRS";
2606
2638
  internalVapixParameters: string;
@@ -2686,6 +2718,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2686
2718
  internalVapixParameters: string;
2687
2719
  } | {
2688
2720
  type: "CSw";
2721
+ internalVapixParameters: string;
2689
2722
  } | {
2690
2723
  type: "CRS";
2691
2724
  internalVapixParameters: string;
@@ -2771,6 +2804,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2771
2804
  internalVapixParameters: string;
2772
2805
  } | {
2773
2806
  type: "CSw";
2807
+ internalVapixParameters: string;
2774
2808
  } | {
2775
2809
  type: "CRS";
2776
2810
  internalVapixParameters: string;
@@ -2856,6 +2890,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2856
2890
  internalVapixParameters: string;
2857
2891
  } | {
2858
2892
  type: "CSw";
2893
+ internalVapixParameters: string;
2859
2894
  } | {
2860
2895
  type: "CRS";
2861
2896
  internalVapixParameters: string;
@@ -2941,6 +2976,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2941
2976
  internalVapixParameters: string;
2942
2977
  } | {
2943
2978
  type: "CSw";
2979
+ internalVapixParameters: string;
2944
2980
  } | {
2945
2981
  type: "CRS";
2946
2982
  internalVapixParameters: string;
@@ -3026,6 +3062,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
3026
3062
  internalVapixParameters: string;
3027
3063
  } | {
3028
3064
  type: "CSw";
3065
+ internalVapixParameters: string;
3029
3066
  } | {
3030
3067
  type: "CRS";
3031
3068
  internalVapixParameters: string;
@@ -3111,6 +3148,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
3111
3148
  internalVapixParameters: string;
3112
3149
  } | {
3113
3150
  type: "CSw";
3151
+ internalVapixParameters: string;
3114
3152
  } | {
3115
3153
  type: "CRS";
3116
3154
  internalVapixParameters: string;
@@ -3196,6 +3234,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
3196
3234
  internalVapixParameters: string;
3197
3235
  } | {
3198
3236
  type: "CSw";
3237
+ internalVapixParameters: string;
3199
3238
  } | {
3200
3239
  type: "CRS";
3201
3240
  internalVapixParameters: string;
@@ -3281,6 +3320,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
3281
3320
  internalVapixParameters: string;
3282
3321
  } | {
3283
3322
  type: "CSw";
3323
+ internalVapixParameters: string;
3284
3324
  } | {
3285
3325
  type: "CRS";
3286
3326
  internalVapixParameters: string;
@@ -3366,6 +3406,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
3366
3406
  internalVapixParameters: string;
3367
3407
  } | {
3368
3408
  type: "CSw";
3409
+ internalVapixParameters: string;
3369
3410
  } | {
3370
3411
  type: "CRS";
3371
3412
  internalVapixParameters: string;
@@ -3451,6 +3492,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
3451
3492
  internalVapixParameters: string;
3452
3493
  } | {
3453
3494
  type: "CSw";
3495
+ internalVapixParameters: string;
3454
3496
  } | {
3455
3497
  type: "CRS";
3456
3498
  internalVapixParameters: string;
package/cjs/VapixAPI.d.ts CHANGED
@@ -17,15 +17,6 @@ export declare class VapixAPI<Client extends IClient<TResponse, any>> extends Ba
17
17
  bitRates: number[];
18
18
  }[]>;
19
19
  performAutofocus(options?: THttpRequestOptions): Promise<void>;
20
- checkSDCard(options?: THttpRequestOptions): Promise<{
21
- status: "OK" | "connected" | "disconnected";
22
- totalSize: number;
23
- freeSize: number;
24
- }>;
25
- mountSDCard(options?: THttpRequestOptions): Promise<number>;
26
- unmountSDCard(options?: THttpRequestOptions): Promise<number>;
27
- private _doSDCardMountAction;
28
- fetchSDCardJobProgress(jobId: number, options?: THttpRequestOptions): Promise<number>;
29
20
  downloadCameraReport(options?: THttpRequestOptions): Promise<string>;
30
21
  getSystemLog(options?: THttpRequestOptions): Promise<string>;
31
22
  getMaxFps(channel: number, options?: THttpRequestOptions): Promise<number>;
@@ -43,6 +34,15 @@ export declare class VapixAPI<Client extends IClient<TResponse, any>> extends Ba
43
34
  fetchRemoteDeviceInfo<T extends Record<string, any>>(payload: T, options?: THttpRequestOptions): Promise<any>;
44
35
  getHeaders(options?: THttpRequestOptions): Promise<Record<string, string>>;
45
36
  setHeaders(headers: Record<string, string>, options?: THttpRequestOptions): Promise<void>;
37
+ checkSDCard(options?: THttpRequestOptions): Promise<{
38
+ status: "OK" | "connected" | "disconnected";
39
+ totalSize: number;
40
+ freeSize: number;
41
+ }>;
42
+ mountSDCard(options?: THttpRequestOptions): Promise<number>;
43
+ unmountSDCard(options?: THttpRequestOptions): Promise<number>;
44
+ private _doSDCardMountAction;
45
+ fetchSDCardJobProgress(jobId: number, options?: THttpRequestOptions): Promise<number>;
46
46
  getParameter(paramNames: string | string[], options?: THttpRequestOptions): Promise<Record<string, string>>;
47
47
  setParameter(params: Record<string, string | number | boolean>, options?: THttpRequestOptions): Promise<void>;
48
48
  getGuardTourList(options?: THttpRequestOptions): Promise<{
package/cjs/VapixAPI.js CHANGED
@@ -98,65 +98,6 @@ class VapixAPI extends BasicAPI_1.BasicAPI {
98
98
  }, options);
99
99
  }
100
100
  }
101
- async checkSDCard(options) {
102
- const res = await this._postUrlEncoded('/axis-cgi/disks/list.cgi', {
103
- diskid: 'SD_DISK',
104
- }, options);
105
- const xmlText = await res.text();
106
- const parser = new fast_xml_parser_1.XMLParser({
107
- ignoreAttributes: false,
108
- attributeNamePrefix: '',
109
- allowBooleanAttributes: true,
110
- });
111
- const result = parser.parse(xmlText);
112
- const data = result.root.disks.disk;
113
- return VapixAPI_1.sdCardInfoSchema.parse({
114
- totalSize: parseInt(data.totalsize),
115
- freeSize: parseInt(data.freesize),
116
- status: VapixAPI_1.sdCardWatchedStatuses.includes(data.status) ? data.status : 'disconnected',
117
- });
118
- }
119
- mountSDCard(options) {
120
- return this._doSDCardMountAction('MOUNT', options);
121
- }
122
- unmountSDCard(options) {
123
- return this._doSDCardMountAction('UNMOUNT', options);
124
- }
125
- async _doSDCardMountAction(action, options) {
126
- const res = await this._postUrlEncoded('/axis-cgi/disks/mount.cgi', {
127
- action: action,
128
- diskid: 'SD_DISK',
129
- }, options);
130
- const textXml = await res.text();
131
- const parser = new fast_xml_parser_1.XMLParser({
132
- ignoreAttributes: false,
133
- attributeNamePrefix: '',
134
- allowBooleanAttributes: true,
135
- });
136
- const result = parser.parse(textXml);
137
- const job = result.root.job;
138
- if (job.result !== 'OK') {
139
- throw new errors_1.SDCardActionError(action, job.description);
140
- }
141
- return Number(job.jobid);
142
- }
143
- async fetchSDCardJobProgress(jobId, options) {
144
- const res = await this._postUrlEncoded('/axis-cgi/disks/job.cgi', {
145
- jobid: String(jobId),
146
- diskid: 'SD_DISK',
147
- }, options);
148
- const textXml = await res.text();
149
- const parser = new fast_xml_parser_1.XMLParser({
150
- ignoreAttributes: false,
151
- attributeNamePrefix: '',
152
- allowBooleanAttributes: true,
153
- });
154
- const job = parser.parse(textXml).root.job;
155
- if (job.result !== 'OK') {
156
- throw new errors_1.SDCardJobError(job.description);
157
- }
158
- return Number(job.progress);
159
- }
160
101
  downloadCameraReport(options) {
161
102
  return this._getText('/axis-cgi/serverreport.cgi', { mode: 'text' }, options);
162
103
  }
@@ -242,6 +183,65 @@ class VapixAPI extends BasicAPI_1.BasicAPI {
242
183
  const data = { apiVersion: '1.0', method: 'set', params: headers };
243
184
  await this._postJsonEncoded('/axis-cgi/customhttpheader.cgi', data, undefined, options);
244
185
  }
186
+ async checkSDCard(options) {
187
+ const res = await this._postUrlEncoded('/axis-cgi/disks/list.cgi', {
188
+ diskid: 'SD_DISK',
189
+ }, options);
190
+ const xmlText = await res.text();
191
+ const parser = new fast_xml_parser_1.XMLParser({
192
+ ignoreAttributes: false,
193
+ attributeNamePrefix: '',
194
+ allowBooleanAttributes: true,
195
+ });
196
+ const result = parser.parse(xmlText);
197
+ const data = result.root.disks.disk;
198
+ return VapixAPI_1.sdCardInfoSchema.parse({
199
+ totalSize: parseInt(data.totalsize),
200
+ freeSize: parseInt(data.freesize),
201
+ status: VapixAPI_1.sdCardWatchedStatuses.includes(data.status) ? data.status : 'disconnected',
202
+ });
203
+ }
204
+ mountSDCard(options) {
205
+ return this._doSDCardMountAction('MOUNT', options);
206
+ }
207
+ unmountSDCard(options) {
208
+ return this._doSDCardMountAction('UNMOUNT', options);
209
+ }
210
+ async _doSDCardMountAction(action, options) {
211
+ const res = await this._postUrlEncoded('/axis-cgi/disks/mount.cgi', {
212
+ action: action,
213
+ diskid: 'SD_DISK',
214
+ }, options);
215
+ const textXml = await res.text();
216
+ const parser = new fast_xml_parser_1.XMLParser({
217
+ ignoreAttributes: false,
218
+ attributeNamePrefix: '',
219
+ allowBooleanAttributes: true,
220
+ });
221
+ const result = parser.parse(textXml);
222
+ const job = result.root.job;
223
+ if (job.result !== 'OK') {
224
+ throw new errors_1.SDCardActionError(action, job.description);
225
+ }
226
+ return Number(job.jobid);
227
+ }
228
+ async fetchSDCardJobProgress(jobId, options) {
229
+ const res = await this._postUrlEncoded('/disks/job.cgi', {
230
+ jobid: String(jobId),
231
+ diskid: 'SD_DISK',
232
+ }, options);
233
+ const textXml = await res.text();
234
+ const parser = new fast_xml_parser_1.XMLParser({
235
+ ignoreAttributes: false,
236
+ attributeNamePrefix: '',
237
+ allowBooleanAttributes: true,
238
+ });
239
+ const job = parser.parse(textXml).root.job;
240
+ if (job.result !== 'OK') {
241
+ throw new errors_1.SDCardJobError(job.description);
242
+ }
243
+ return Number(job.progress);
244
+ }
245
245
  async getParameter(paramNames, options) {
246
246
  const response = await this._postUrlEncoded('/axis-cgi/param.cgi', {
247
247
  action: 'list',
@@ -74,7 +74,7 @@ const parseVideoOptionsToVapixParams = (firmWareVersion, video) => {
74
74
  if ((0, versionCompare_1.isFirmwareVersionAtLeast)(firmWareVersion, constants_1.FIRMWARE_WITH_OVERLAYS_SUPPORT) && video.overlays !== undefined) {
75
75
  overlaysParams = `&overlays=${video.overlays}`;
76
76
  }
77
- const nbrOfChannels = video.audio === 1 ? `&nbrOfChannels=${video.nbrOfChannels}` : '';
77
+ const nbrOfChannels = video.nbrOfChannels ? (video.audio === 1 ? `&nbrOfChannels=${video.nbrOfChannels}` : '') : '';
78
78
  const audioParams = `audio=${video.audio}${nbrOfChannels}`;
79
79
  const videoCodecParams = video.videoCodec === 'h264'
80
80
  ? `videoCodec=${video.videoCodec}&h264Profile=${video.h264Profile}`