@homebridge/hap-nodejs 2.2.4-beta.7 → 2.3.0-beta.0
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 +14 -17
- package/dist/accessories/AirConditioner_accessory.js +27 -29
- package/dist/accessories/AirConditioner_accessory.js.map +1 -1
- package/dist/accessories/AppleTVRemote_accessory.js +61 -71
- package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
- package/dist/accessories/Camera_accessory.js +151 -134
- package/dist/accessories/Camera_accessory.js.map +1 -1
- package/dist/accessories/Fan_accessory.js +18 -21
- package/dist/accessories/Fan_accessory.js.map +1 -1
- package/dist/accessories/GarageDoorOpener_accessory.js +33 -35
- package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
- package/dist/accessories/Light-AdaptiveLighting_accessory.js +41 -44
- package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
- package/dist/accessories/Light_accessory.js +32 -34
- package/dist/accessories/Light_accessory.js.map +1 -1
- package/dist/accessories/Lock_accessory.js +24 -26
- package/dist/accessories/Lock_accessory.js.map +1 -1
- package/dist/accessories/MotionSensor_accessory.js +13 -15
- package/dist/accessories/MotionSensor_accessory.js.map +1 -1
- package/dist/accessories/Outlet_accessory.js +20 -22
- package/dist/accessories/Outlet_accessory.js.map +1 -1
- package/dist/accessories/SmartSpeaker_accessory.js +18 -20
- package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
- package/dist/accessories/Sprinkler_accessory.js +36 -38
- package/dist/accessories/Sprinkler_accessory.js.map +1 -1
- package/dist/accessories/TV_accessory.js +43 -45
- package/dist/accessories/TV_accessory.js.map +1 -1
- package/dist/accessories/TemperatureSensor_accessory.js +12 -14
- package/dist/accessories/TemperatureSensor_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.d.ts +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.js +9 -12
- package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.js +11 -14
- package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -1
- package/dist/accessories/gstreamer-audioProducer.d.ts +3 -3
- package/dist/accessories/gstreamer-audioProducer.d.ts.map +1 -1
- package/dist/accessories/gstreamer-audioProducer.js +35 -36
- package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
- package/dist/accessories/types.d.ts +63 -63
- package/dist/accessories/types.d.ts.map +1 -1
- package/dist/accessories/types.js +83 -87
- package/dist/accessories/types.js.map +1 -1
- package/dist/hap.d.ts +50 -0
- package/dist/hap.d.ts.map +1 -0
- package/dist/hap.js +49 -0
- package/dist/hap.js.map +1 -0
- package/dist/index.d.ts +3 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -53
- package/dist/index.js.map +1 -1
- package/dist/internal-types.d.ts +1 -1
- package/dist/internal-types.d.ts.map +1 -1
- package/dist/internal-types.js +19 -19
- package/dist/internal-types.js.map +1 -1
- package/dist/lib/Accessory.d.ts +37 -37
- package/dist/lib/Accessory.d.ts.map +1 -1
- package/dist/lib/Accessory.js +265 -257
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/Advertiser.d.ts +6 -6
- package/dist/lib/Advertiser.d.ts.map +1 -1
- package/dist/lib/Advertiser.js +143 -139
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Bridge.d.ts +1 -1
- package/dist/lib/Bridge.d.ts.map +1 -1
- package/dist/lib/Bridge.js +2 -6
- package/dist/lib/Bridge.js.map +1 -1
- package/dist/lib/Characteristic.d.ts +40 -41
- package/dist/lib/Characteristic.d.ts.map +1 -1
- package/dist/lib/Characteristic.js +265 -216
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.d.ts +30 -29
- package/dist/lib/HAPServer.d.ts.map +1 -1
- package/dist/lib/HAPServer.js +223 -224
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts +21 -22
- package/dist/lib/Service.d.ts.map +1 -1
- package/dist/lib/Service.js +60 -68
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/RTPProxy.d.ts +2 -1
- package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
- package/dist/lib/camera/RTPProxy.js +35 -37
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts +34 -33
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.js +178 -132
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/RecordingManagement.d.ts +18 -17
- package/dist/lib/camera/RecordingManagement.d.ts.map +1 -1
- package/dist/lib/camera/RecordingManagement.js +182 -154
- package/dist/lib/camera/RecordingManagement.js.map +1 -1
- package/dist/lib/camera/index.d.ts +3 -3
- package/dist/lib/camera/index.d.ts.map +1 -1
- package/dist/lib/camera/index.js +3 -6
- package/dist/lib/camera/index.js.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts +8 -8
- package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.js +111 -99
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.d.ts +21 -20
- package/dist/lib/controller/CameraController.d.ts.map +1 -1
- package/dist/lib/controller/CameraController.js +82 -80
- package/dist/lib/controller/CameraController.js.map +1 -1
- package/dist/lib/controller/Controller.d.ts +1 -1
- package/dist/lib/controller/Controller.d.ts.map +1 -1
- package/dist/lib/controller/Controller.js +5 -8
- package/dist/lib/controller/Controller.js.map +1 -1
- package/dist/lib/controller/DoorbellController.d.ts +4 -4
- package/dist/lib/controller/DoorbellController.d.ts.map +1 -1
- package/dist/lib/controller/DoorbellController.js +9 -13
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.d.ts +38 -37
- package/dist/lib/controller/RemoteController.d.ts.map +1 -1
- package/dist/lib/controller/RemoteController.js +188 -158
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/controller/index.d.ts +5 -5
- package/dist/lib/controller/index.d.ts.map +1 -1
- package/dist/lib/controller/index.js +5 -8
- package/dist/lib/controller/index.js.map +1 -1
- package/dist/lib/datastream/DataStreamManagement.d.ts +2 -2
- package/dist/lib/datastream/DataStreamManagement.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamManagement.js +32 -32
- package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.d.ts +1 -0
- package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamParser.js +53 -69
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.d.ts +23 -22
- package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamServer.js +152 -154
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/datastream/index.d.ts +3 -3
- package/dist/lib/datastream/index.d.ts.map +1 -1
- package/dist/lib/datastream/index.js +3 -6
- package/dist/lib/datastream/index.js.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +1103 -1288
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.js +644 -722
- package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
- package/dist/lib/definitions/generate-definitions.d.ts +2 -2
- package/dist/lib/definitions/generate-definitions.d.ts.map +1 -1
- package/dist/lib/definitions/generate-definitions.js +241 -241
- package/dist/lib/definitions/generate-definitions.js.map +1 -1
- package/dist/lib/definitions/generator-configuration.d.ts +1 -1
- package/dist/lib/definitions/generator-configuration.d.ts.map +1 -1
- package/dist/lib/definitions/generator-configuration.js +572 -309
- package/dist/lib/definitions/generator-configuration.js.map +1 -1
- package/dist/lib/definitions/index.d.ts +2 -2
- package/dist/lib/definitions/index.d.ts.map +1 -1
- package/dist/lib/definitions/index.js +2 -5
- package/dist/lib/definitions/index.js.map +1 -1
- package/dist/lib/gen/HomeKit.js +1 -2
- package/dist/lib/gen/HomeKit.js.map +1 -1
- package/dist/lib/model/AccessoryInfo.d.ts +4 -3
- package/dist/lib/model/AccessoryInfo.d.ts.map +1 -1
- package/dist/lib/model/AccessoryInfo.js +53 -56
- package/dist/lib/model/AccessoryInfo.js.map +1 -1
- package/dist/lib/model/ControllerStorage.d.ts +3 -3
- package/dist/lib/model/ControllerStorage.d.ts.map +1 -1
- package/dist/lib/model/ControllerStorage.js +31 -30
- package/dist/lib/model/ControllerStorage.js.map +1 -1
- package/dist/lib/model/HAPFileStorage.d.ts.map +1 -1
- package/dist/lib/model/HAPFileStorage.js +71 -50
- package/dist/lib/model/HAPFileStorage.js.map +1 -1
- package/dist/lib/model/HAPStorage.d.ts +1 -1
- package/dist/lib/model/HAPStorage.d.ts.map +1 -1
- package/dist/lib/model/HAPStorage.js +11 -14
- package/dist/lib/model/HAPStorage.js.map +1 -1
- package/dist/lib/model/IdentifierCache.d.ts +1 -1
- package/dist/lib/model/IdentifierCache.d.ts.map +1 -1
- package/dist/lib/model/IdentifierCache.js +23 -27
- package/dist/lib/model/IdentifierCache.js.map +1 -1
- package/dist/lib/tv/AccessControlManagement.d.ts +6 -6
- package/dist/lib/tv/AccessControlManagement.d.ts.map +1 -1
- package/dist/lib/tv/AccessControlManagement.js +23 -24
- package/dist/lib/tv/AccessControlManagement.js.map +1 -1
- package/dist/lib/util/checkName.d.ts +2 -2
- package/dist/lib/util/checkName.d.ts.map +1 -1
- package/dist/lib/util/checkName.js +8 -14
- package/dist/lib/util/checkName.js.map +1 -1
- package/dist/lib/util/clone.d.ts.map +1 -1
- package/dist/lib/util/clone.js +1 -5
- package/dist/lib/util/clone.js.map +1 -1
- package/dist/lib/util/color-utils.d.ts +1 -1
- package/dist/lib/util/color-utils.d.ts.map +1 -1
- package/dist/lib/util/color-utils.js +1608 -410
- package/dist/lib/util/color-utils.js.map +1 -1
- package/dist/lib/util/eventedhttp.d.ts +23 -22
- package/dist/lib/util/eventedhttp.d.ts.map +1 -1
- package/dist/lib/util/eventedhttp.js +127 -122
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.d.ts +2 -1
- package/dist/lib/util/hapCrypto.d.ts.map +1 -1
- package/dist/lib/util/hapCrypto.js +72 -59
- package/dist/lib/util/hapCrypto.js.map +1 -1
- package/dist/lib/util/hapStatusError.d.ts +1 -1
- package/dist/lib/util/hapStatusError.d.ts.map +1 -1
- package/dist/lib/util/hapStatusError.js +4 -8
- package/dist/lib/util/hapStatusError.js.map +1 -1
- package/dist/lib/util/net-utils.js +13 -19
- package/dist/lib/util/net-utils.js.map +1 -1
- package/dist/lib/util/once.js +3 -6
- package/dist/lib/util/once.js.map +1 -1
- package/dist/lib/util/promise-utils.d.ts +1 -1
- package/dist/lib/util/promise-utils.d.ts.map +1 -1
- package/dist/lib/util/promise-utils.js +9 -11
- package/dist/lib/util/promise-utils.js.map +1 -1
- package/dist/lib/util/request-util.d.ts +3 -3
- package/dist/lib/util/request-util.d.ts.map +1 -1
- package/dist/lib/util/request-util.js +13 -22
- package/dist/lib/util/request-util.js.map +1 -1
- package/dist/lib/util/time.d.ts +1 -0
- package/dist/lib/util/time.d.ts.map +1 -1
- package/dist/lib/util/time.js +6 -11
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/tlv.d.ts +1 -0
- package/dist/lib/util/tlv.d.ts.map +1 -1
- package/dist/lib/util/tlv.js +38 -44
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.d.ts +1 -0
- package/dist/lib/util/uuid.d.ts.map +1 -1
- package/dist/lib/util/uuid.js +26 -38
- package/dist/lib/util/uuid.js.map +1 -1
- package/dist/types.d.ts +24 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -5
- package/dist/types.js.map +1 -1
- package/package.json +49 -42
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const debug = (0, debug_1.default)("HAP-NodeJS:Camera:RecordingManagement");
|
|
14
|
-
const hksvDebug = (0, debug_1.default)("HAP-NodeJS:HKSV");
|
|
1
|
+
/* global NodeJS */
|
|
2
|
+
import { Buffer } from 'node:buffer';
|
|
3
|
+
import crypto from 'node:crypto';
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
import createDebug from 'debug';
|
|
6
|
+
import { Characteristic } from '../Characteristic.js';
|
|
7
|
+
import { DataStreamManagement, HDSConnectionError, HDSProtocolError, HDSStatus, } from '../datastream/index.js';
|
|
8
|
+
import { Service } from '../Service.js';
|
|
9
|
+
import { HapStatusError } from '../util/hapStatusError.js';
|
|
10
|
+
import * as tlv from '../util/tlv.js';
|
|
11
|
+
const debug = createDebug('HAP-NodeJS:Camera:RecordingManagement');
|
|
12
|
+
const hksvDebug = createDebug('HAP-NodeJS:HKSV');
|
|
15
13
|
/**
|
|
16
14
|
* Describes the Event trigger.
|
|
17
15
|
*
|
|
18
16
|
* @group Camera
|
|
19
17
|
*/
|
|
20
|
-
|
|
18
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
19
|
+
export var EventTriggerOption;
|
|
21
20
|
(function (EventTriggerOption) {
|
|
22
21
|
/**
|
|
23
22
|
* The Motion trigger. If enabled motion should trigger the start of a recording.
|
|
@@ -32,20 +31,23 @@ var EventTriggerOption;
|
|
|
32
31
|
* See https://github.com/homebridge/HAP-NodeJS/issues/976#issuecomment-1280301989.
|
|
33
32
|
*/
|
|
34
33
|
EventTriggerOption[EventTriggerOption["DOORBELL"] = 2] = "DOORBELL";
|
|
35
|
-
})(EventTriggerOption || (
|
|
34
|
+
})(EventTriggerOption || (EventTriggerOption = {}));
|
|
36
35
|
/**
|
|
37
36
|
* @group Camera
|
|
38
37
|
*/
|
|
39
|
-
|
|
38
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
39
|
+
export var MediaContainerType;
|
|
40
40
|
(function (MediaContainerType) {
|
|
41
41
|
MediaContainerType[MediaContainerType["FRAGMENTED_MP4"] = 0] = "FRAGMENTED_MP4";
|
|
42
|
-
})(MediaContainerType || (
|
|
42
|
+
})(MediaContainerType || (MediaContainerType = {}));
|
|
43
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
43
44
|
var VideoCodecConfigurationTypes;
|
|
44
45
|
(function (VideoCodecConfigurationTypes) {
|
|
45
46
|
VideoCodecConfigurationTypes[VideoCodecConfigurationTypes["CODEC_TYPE"] = 1] = "CODEC_TYPE";
|
|
46
47
|
VideoCodecConfigurationTypes[VideoCodecConfigurationTypes["CODEC_PARAMETERS"] = 2] = "CODEC_PARAMETERS";
|
|
47
48
|
VideoCodecConfigurationTypes[VideoCodecConfigurationTypes["ATTRIBUTES"] = 3] = "ATTRIBUTES";
|
|
48
49
|
})(VideoCodecConfigurationTypes || (VideoCodecConfigurationTypes = {}));
|
|
50
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
49
51
|
var VideoCodecParametersTypes;
|
|
50
52
|
(function (VideoCodecParametersTypes) {
|
|
51
53
|
VideoCodecParametersTypes[VideoCodecParametersTypes["PROFILE_ID"] = 1] = "PROFILE_ID";
|
|
@@ -53,12 +55,14 @@ var VideoCodecParametersTypes;
|
|
|
53
55
|
VideoCodecParametersTypes[VideoCodecParametersTypes["BITRATE"] = 3] = "BITRATE";
|
|
54
56
|
VideoCodecParametersTypes[VideoCodecParametersTypes["IFRAME_INTERVAL"] = 4] = "IFRAME_INTERVAL";
|
|
55
57
|
})(VideoCodecParametersTypes || (VideoCodecParametersTypes = {}));
|
|
58
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
56
59
|
var VideoAttributesTypes;
|
|
57
60
|
(function (VideoAttributesTypes) {
|
|
58
61
|
VideoAttributesTypes[VideoAttributesTypes["IMAGE_WIDTH"] = 1] = "IMAGE_WIDTH";
|
|
59
62
|
VideoAttributesTypes[VideoAttributesTypes["IMAGE_HEIGHT"] = 2] = "IMAGE_HEIGHT";
|
|
60
63
|
VideoAttributesTypes[VideoAttributesTypes["FRAME_RATE"] = 3] = "FRAME_RATE";
|
|
61
64
|
})(VideoAttributesTypes || (VideoAttributesTypes = {}));
|
|
65
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
62
66
|
var SelectedCameraRecordingConfigurationTypes;
|
|
63
67
|
(function (SelectedCameraRecordingConfigurationTypes) {
|
|
64
68
|
SelectedCameraRecordingConfigurationTypes[SelectedCameraRecordingConfigurationTypes["SELECTED_RECORDING_CONFIGURATION"] = 1] = "SELECTED_RECORDING_CONFIGURATION";
|
|
@@ -68,15 +72,17 @@ var SelectedCameraRecordingConfigurationTypes;
|
|
|
68
72
|
/**
|
|
69
73
|
* @group Camera
|
|
70
74
|
*/
|
|
71
|
-
|
|
75
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
76
|
+
export var AudioRecordingCodecType;
|
|
72
77
|
(function (AudioRecordingCodecType) {
|
|
73
78
|
AudioRecordingCodecType[AudioRecordingCodecType["AAC_LC"] = 0] = "AAC_LC";
|
|
74
79
|
AudioRecordingCodecType[AudioRecordingCodecType["AAC_ELD"] = 1] = "AAC_ELD";
|
|
75
|
-
})(AudioRecordingCodecType || (
|
|
80
|
+
})(AudioRecordingCodecType || (AudioRecordingCodecType = {}));
|
|
76
81
|
/**
|
|
77
82
|
* @group Camera
|
|
78
83
|
*/
|
|
79
|
-
|
|
84
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
85
|
+
export var AudioRecordingSamplerate;
|
|
80
86
|
(function (AudioRecordingSamplerate) {
|
|
81
87
|
AudioRecordingSamplerate[AudioRecordingSamplerate["KHZ_8"] = 0] = "KHZ_8";
|
|
82
88
|
AudioRecordingSamplerate[AudioRecordingSamplerate["KHZ_16"] = 1] = "KHZ_16";
|
|
@@ -84,38 +90,45 @@ var AudioRecordingSamplerate;
|
|
|
84
90
|
AudioRecordingSamplerate[AudioRecordingSamplerate["KHZ_32"] = 3] = "KHZ_32";
|
|
85
91
|
AudioRecordingSamplerate[AudioRecordingSamplerate["KHZ_44_1"] = 4] = "KHZ_44_1";
|
|
86
92
|
AudioRecordingSamplerate[AudioRecordingSamplerate["KHZ_48"] = 5] = "KHZ_48";
|
|
87
|
-
})(AudioRecordingSamplerate || (
|
|
93
|
+
})(AudioRecordingSamplerate || (AudioRecordingSamplerate = {}));
|
|
94
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
88
95
|
var SupportedVideoRecordingConfigurationTypes;
|
|
89
96
|
(function (SupportedVideoRecordingConfigurationTypes) {
|
|
90
97
|
SupportedVideoRecordingConfigurationTypes[SupportedVideoRecordingConfigurationTypes["VIDEO_CODEC_CONFIGURATION"] = 1] = "VIDEO_CODEC_CONFIGURATION";
|
|
91
98
|
})(SupportedVideoRecordingConfigurationTypes || (SupportedVideoRecordingConfigurationTypes = {}));
|
|
99
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
92
100
|
var SupportedCameraRecordingConfigurationTypes;
|
|
93
101
|
(function (SupportedCameraRecordingConfigurationTypes) {
|
|
94
102
|
SupportedCameraRecordingConfigurationTypes[SupportedCameraRecordingConfigurationTypes["PREBUFFER_LENGTH"] = 1] = "PREBUFFER_LENGTH";
|
|
95
103
|
SupportedCameraRecordingConfigurationTypes[SupportedCameraRecordingConfigurationTypes["EVENT_TRIGGER_OPTIONS"] = 2] = "EVENT_TRIGGER_OPTIONS";
|
|
96
104
|
SupportedCameraRecordingConfigurationTypes[SupportedCameraRecordingConfigurationTypes["MEDIA_CONTAINER_CONFIGURATIONS"] = 3] = "MEDIA_CONTAINER_CONFIGURATIONS";
|
|
97
105
|
})(SupportedCameraRecordingConfigurationTypes || (SupportedCameraRecordingConfigurationTypes = {}));
|
|
106
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
98
107
|
var MediaContainerConfigurationTypes;
|
|
99
108
|
(function (MediaContainerConfigurationTypes) {
|
|
100
109
|
MediaContainerConfigurationTypes[MediaContainerConfigurationTypes["MEDIA_CONTAINER_TYPE"] = 1] = "MEDIA_CONTAINER_TYPE";
|
|
101
110
|
MediaContainerConfigurationTypes[MediaContainerConfigurationTypes["MEDIA_CONTAINER_PARAMETERS"] = 2] = "MEDIA_CONTAINER_PARAMETERS";
|
|
102
111
|
})(MediaContainerConfigurationTypes || (MediaContainerConfigurationTypes = {}));
|
|
112
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
103
113
|
var MediaContainerParameterTypes;
|
|
104
114
|
(function (MediaContainerParameterTypes) {
|
|
105
115
|
MediaContainerParameterTypes[MediaContainerParameterTypes["FRAGMENT_LENGTH"] = 1] = "FRAGMENT_LENGTH";
|
|
106
116
|
})(MediaContainerParameterTypes || (MediaContainerParameterTypes = {}));
|
|
117
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
107
118
|
var AudioCodecParametersTypes;
|
|
108
119
|
(function (AudioCodecParametersTypes) {
|
|
109
120
|
AudioCodecParametersTypes[AudioCodecParametersTypes["CHANNEL"] = 1] = "CHANNEL";
|
|
110
121
|
AudioCodecParametersTypes[AudioCodecParametersTypes["BIT_RATE"] = 2] = "BIT_RATE";
|
|
111
122
|
AudioCodecParametersTypes[AudioCodecParametersTypes["SAMPLE_RATE"] = 3] = "SAMPLE_RATE";
|
|
112
|
-
AudioCodecParametersTypes[AudioCodecParametersTypes["MAX_AUDIO_BITRATE"] = 4] = "MAX_AUDIO_BITRATE";
|
|
123
|
+
AudioCodecParametersTypes[AudioCodecParametersTypes["MAX_AUDIO_BITRATE"] = 4] = "MAX_AUDIO_BITRATE";
|
|
113
124
|
})(AudioCodecParametersTypes || (AudioCodecParametersTypes = {}));
|
|
125
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
114
126
|
var AudioCodecConfigurationTypes;
|
|
115
127
|
(function (AudioCodecConfigurationTypes) {
|
|
116
128
|
AudioCodecConfigurationTypes[AudioCodecConfigurationTypes["CODEC_TYPE"] = 1] = "CODEC_TYPE";
|
|
117
129
|
AudioCodecConfigurationTypes[AudioCodecConfigurationTypes["CODEC_PARAMETERS"] = 2] = "CODEC_PARAMETERS";
|
|
118
130
|
})(AudioCodecConfigurationTypes || (AudioCodecConfigurationTypes = {}));
|
|
131
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
119
132
|
var SupportedAudioRecordingConfigurationTypes;
|
|
120
133
|
(function (SupportedAudioRecordingConfigurationTypes) {
|
|
121
134
|
SupportedAudioRecordingConfigurationTypes[SupportedAudioRecordingConfigurationTypes["AUDIO_CODEC_CONFIGURATION"] = 1] = "AUDIO_CODEC_CONFIGURATION";
|
|
@@ -123,7 +136,8 @@ var SupportedAudioRecordingConfigurationTypes;
|
|
|
123
136
|
/**
|
|
124
137
|
* @group Camera
|
|
125
138
|
*/
|
|
126
|
-
|
|
139
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
140
|
+
export var PacketDataType;
|
|
127
141
|
(function (PacketDataType) {
|
|
128
142
|
/**
|
|
129
143
|
* mp4 moov box
|
|
@@ -133,11 +147,11 @@ var PacketDataType;
|
|
|
133
147
|
* mp4 moof + mdat boxes
|
|
134
148
|
*/
|
|
135
149
|
PacketDataType["MEDIA_FRAGMENT"] = "mediaFragment";
|
|
136
|
-
})(PacketDataType || (
|
|
150
|
+
})(PacketDataType || (PacketDataType = {}));
|
|
137
151
|
/**
|
|
138
152
|
* @group Camera
|
|
139
153
|
*/
|
|
140
|
-
class RecordingManagement {
|
|
154
|
+
export class RecordingManagement {
|
|
141
155
|
options;
|
|
142
156
|
delegate;
|
|
143
157
|
stateChangeDelegate;
|
|
@@ -183,129 +197,139 @@ class RecordingManagement {
|
|
|
183
197
|
this.supportedVideoRecordingConfiguration = this._supportedVideoRecordingConfiguration(options.video);
|
|
184
198
|
this.supportedAudioRecordingConfiguration = this._supportedAudioStreamConfiguration(options.audio);
|
|
185
199
|
this.setupServiceHandlers();
|
|
186
|
-
hksvDebug(
|
|
200
|
+
hksvDebug('RecordingManagement created (eventTriggers=0x%s)', this.eventTriggerOptions.toString(16));
|
|
187
201
|
}
|
|
188
202
|
constructService() {
|
|
189
|
-
const recordingManagement = new
|
|
190
|
-
recordingManagement.setCharacteristic(
|
|
191
|
-
recordingManagement.setCharacteristic(
|
|
192
|
-
const operatingMode = new
|
|
193
|
-
operatingMode.setCharacteristic(
|
|
194
|
-
operatingMode.setCharacteristic(
|
|
195
|
-
operatingMode.setCharacteristic(
|
|
196
|
-
const dataStreamManagement = new
|
|
203
|
+
const recordingManagement = new Service.CameraRecordingManagement('', '');
|
|
204
|
+
recordingManagement.setCharacteristic(Characteristic.Active, false);
|
|
205
|
+
recordingManagement.setCharacteristic(Characteristic.RecordingAudioActive, false);
|
|
206
|
+
const operatingMode = new Service.CameraOperatingMode('', '');
|
|
207
|
+
operatingMode.setCharacteristic(Characteristic.EventSnapshotsActive, true);
|
|
208
|
+
operatingMode.setCharacteristic(Characteristic.HomeKitCameraActive, true);
|
|
209
|
+
operatingMode.setCharacteristic(Characteristic.PeriodicSnapshotsActive, true);
|
|
210
|
+
const dataStreamManagement = new DataStreamManagement();
|
|
197
211
|
recordingManagement.addLinkedService(dataStreamManagement.getService());
|
|
198
212
|
return {
|
|
199
|
-
recordingManagement
|
|
200
|
-
operatingMode
|
|
201
|
-
dataStreamManagement
|
|
213
|
+
recordingManagement,
|
|
214
|
+
operatingMode,
|
|
215
|
+
dataStreamManagement,
|
|
202
216
|
};
|
|
203
217
|
}
|
|
204
218
|
setupServiceHandlers() {
|
|
205
219
|
// update the current configuration values to the current state.
|
|
206
|
-
this.recordingManagementService.setCharacteristic(
|
|
207
|
-
this.recordingManagementService.setCharacteristic(
|
|
208
|
-
this.recordingManagementService.setCharacteristic(
|
|
209
|
-
this.recordingManagementService.getCharacteristic(
|
|
220
|
+
this.recordingManagementService.setCharacteristic(Characteristic.SupportedCameraRecordingConfiguration, this.supportedCameraRecordingConfiguration);
|
|
221
|
+
this.recordingManagementService.setCharacteristic(Characteristic.SupportedVideoRecordingConfiguration, this.supportedVideoRecordingConfiguration);
|
|
222
|
+
this.recordingManagementService.setCharacteristic(Characteristic.SupportedAudioRecordingConfiguration, this.supportedAudioRecordingConfiguration);
|
|
223
|
+
this.recordingManagementService.getCharacteristic(Characteristic.SelectedCameraRecordingConfiguration)
|
|
210
224
|
.onGet(this.handleSelectedCameraRecordingConfigurationRead.bind(this))
|
|
211
225
|
.onSet(this.handleSelectedCameraRecordingConfigurationWrite.bind(this))
|
|
212
|
-
.setProps({
|
|
213
|
-
|
|
214
|
-
|
|
226
|
+
.setProps({
|
|
227
|
+
adminOnlyAccess: [1 /* Access.WRITE */],
|
|
228
|
+
});
|
|
229
|
+
this.recordingManagementService.getCharacteristic(Characteristic.Active)
|
|
230
|
+
.onSet((value) => {
|
|
215
231
|
if (!!value === this.recordingActive) {
|
|
216
232
|
return; // skip delegate call if state didn't change!
|
|
217
233
|
}
|
|
218
234
|
this.recordingActive = !!value;
|
|
219
|
-
hksvDebug(
|
|
235
|
+
hksvDebug('Active onSet: recordingActive -> %s', this.recordingActive);
|
|
220
236
|
this.delegate.updateRecordingActive(this.recordingActive);
|
|
221
237
|
})
|
|
222
238
|
.on("change" /* CharacteristicEventTypes.CHANGE */, () => this.stateChangeDelegate?.())
|
|
223
|
-
.setProps({
|
|
224
|
-
|
|
239
|
+
.setProps({
|
|
240
|
+
adminOnlyAccess: [1 /* Access.WRITE */],
|
|
241
|
+
});
|
|
242
|
+
this.recordingManagementService.getCharacteristic(Characteristic.RecordingAudioActive)
|
|
225
243
|
.on("change" /* CharacteristicEventTypes.CHANGE */, () => this.stateChangeDelegate?.());
|
|
226
|
-
this.operatingModeService.getCharacteristic(
|
|
227
|
-
.on("change" /* CharacteristicEventTypes.CHANGE */, change => {
|
|
244
|
+
this.operatingModeService.getCharacteristic(Characteristic.HomeKitCameraActive)
|
|
245
|
+
.on("change" /* CharacteristicEventTypes.CHANGE */, (change) => {
|
|
228
246
|
for (const service of this.sensorServices) {
|
|
229
|
-
service.setCharacteristic(
|
|
247
|
+
service.setCharacteristic(Characteristic.StatusActive, !!change.newValue);
|
|
230
248
|
}
|
|
231
249
|
if (!change.newValue && this.recordingStream) {
|
|
232
250
|
this.recordingStream.close(1 /* HDSProtocolSpecificErrorReason.NOT_ALLOWED */);
|
|
233
251
|
}
|
|
234
252
|
this.stateChangeDelegate?.();
|
|
235
253
|
})
|
|
236
|
-
.setProps({
|
|
237
|
-
|
|
254
|
+
.setProps({
|
|
255
|
+
adminOnlyAccess: [1 /* Access.WRITE */],
|
|
256
|
+
});
|
|
257
|
+
this.operatingModeService.getCharacteristic(Characteristic.EventSnapshotsActive)
|
|
238
258
|
.on("change" /* CharacteristicEventTypes.CHANGE */, () => this.stateChangeDelegate?.())
|
|
239
|
-
.setProps({
|
|
240
|
-
|
|
259
|
+
.setProps({
|
|
260
|
+
adminOnlyAccess: [1 /* Access.WRITE */],
|
|
261
|
+
});
|
|
262
|
+
this.operatingModeService.getCharacteristic(Characteristic.PeriodicSnapshotsActive)
|
|
241
263
|
.on("change" /* CharacteristicEventTypes.CHANGE */, () => this.stateChangeDelegate?.())
|
|
242
|
-
.setProps({
|
|
264
|
+
.setProps({
|
|
265
|
+
adminOnlyAccess: [1 /* Access.WRITE */],
|
|
266
|
+
});
|
|
243
267
|
this.dataStreamManagement
|
|
244
268
|
.onRequestMessage("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, this.handleDataSendOpen.bind(this));
|
|
245
269
|
}
|
|
246
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
247
270
|
handleDataSendOpen(connection, id, message) {
|
|
248
271
|
// for message fields see https://github.com/Supereg/secure-video-specification#41-start
|
|
249
272
|
const streamId = message.streamId;
|
|
250
273
|
const type = message.type;
|
|
251
274
|
const target = message.target;
|
|
252
275
|
const reason = message.reason;
|
|
253
|
-
if (target !==
|
|
254
|
-
debug(
|
|
255
|
-
connection.sendResponse("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, id,
|
|
276
|
+
if (target !== 'controller' || type !== 'ipcamera.recording') {
|
|
277
|
+
debug('[HDS %s] Received data send with unexpected target: %s or type: %d. Rejecting...', connection.remoteAddress, target, type);
|
|
278
|
+
connection.sendResponse("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, id, HDSStatus.PROTOCOL_SPECIFIC_ERROR, {
|
|
256
279
|
status: 5 /* HDSProtocolSpecificErrorReason.UNEXPECTED_FAILURE */,
|
|
257
280
|
});
|
|
258
281
|
return;
|
|
259
282
|
}
|
|
260
283
|
if (!this.recordingActive) {
|
|
261
|
-
hksvDebug(
|
|
262
|
-
connection.sendResponse("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, id,
|
|
284
|
+
hksvDebug('[HDS %s] rejecting DATA_SEND OPEN: recordingActive=false', connection.remoteAddress);
|
|
285
|
+
connection.sendResponse("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, id, HDSStatus.PROTOCOL_SPECIFIC_ERROR, {
|
|
263
286
|
status: 1 /* HDSProtocolSpecificErrorReason.NOT_ALLOWED */,
|
|
264
287
|
});
|
|
265
288
|
return;
|
|
266
289
|
}
|
|
267
|
-
if (!this.operatingModeService.getCharacteristic(
|
|
268
|
-
hksvDebug(
|
|
269
|
-
connection.sendResponse("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, id,
|
|
290
|
+
if (!this.operatingModeService.getCharacteristic(Characteristic.HomeKitCameraActive).value) {
|
|
291
|
+
hksvDebug('[HDS %s] rejecting DATA_SEND OPEN: HomeKitCameraActive=false', connection.remoteAddress);
|
|
292
|
+
connection.sendResponse("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, id, HDSStatus.PROTOCOL_SPECIFIC_ERROR, {
|
|
270
293
|
status: 1 /* HDSProtocolSpecificErrorReason.NOT_ALLOWED */,
|
|
271
294
|
});
|
|
272
295
|
return;
|
|
273
296
|
}
|
|
274
297
|
if (this.recordingStream) {
|
|
275
|
-
debug(
|
|
298
|
+
debug('[HDS %s] Rejecting DATA_SEND OPEN as another stream (%s) is already recording with streamId %d!', connection.remoteAddress, this.recordingStream.connection.remoteAddress, this.recordingStream.streamId);
|
|
276
299
|
// there is already a recording stream running.
|
|
277
|
-
connection.sendResponse("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, id,
|
|
300
|
+
connection.sendResponse("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, id, HDSStatus.PROTOCOL_SPECIFIC_ERROR, {
|
|
278
301
|
status: 2 /* HDSProtocolSpecificErrorReason.BUSY */,
|
|
279
302
|
});
|
|
280
303
|
return;
|
|
281
304
|
}
|
|
282
305
|
if (!this.selectedConfiguration) {
|
|
283
|
-
hksvDebug(
|
|
284
|
-
connection.sendResponse("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, id,
|
|
306
|
+
hksvDebug('[HDS %s] rejecting DATA_SEND OPEN: no selectedConfiguration (homebridge#3928)', connection.remoteAddress);
|
|
307
|
+
connection.sendResponse("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, id, HDSStatus.PROTOCOL_SPECIFIC_ERROR, {
|
|
285
308
|
status: 9 /* HDSProtocolSpecificErrorReason.INVALID_CONFIGURATION */,
|
|
286
309
|
});
|
|
287
310
|
return;
|
|
288
311
|
}
|
|
289
|
-
debug(
|
|
290
|
-
// eslint-disable-next-line
|
|
312
|
+
debug('[HDS %s] HDS DATA_SEND Open with reason \'%s\'.', connection.remoteAddress, reason);
|
|
313
|
+
// eslint-disable-next-line ts/no-use-before-define
|
|
291
314
|
this.recordingStream = new CameraRecordingStream(connection, this.delegate, id, streamId);
|
|
292
315
|
this.recordingStream.on("closed" /* CameraRecordingStreamEvents.CLOSED */, () => {
|
|
293
|
-
debug(
|
|
316
|
+
debug('[HDS %s] Removing active recoding session from recording management!', connection.remoteAddress);
|
|
294
317
|
this.recordingStream = undefined;
|
|
295
318
|
});
|
|
296
319
|
this.recordingStream.startStreaming();
|
|
297
320
|
}
|
|
298
321
|
handleSelectedCameraRecordingConfigurationRead() {
|
|
299
322
|
if (!this.selectedConfiguration) {
|
|
300
|
-
throw new
|
|
323
|
+
throw new HapStatusError(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
301
324
|
}
|
|
302
325
|
return this.selectedConfiguration.base64;
|
|
303
326
|
}
|
|
304
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
305
327
|
handleSelectedCameraRecordingConfigurationWrite(value) {
|
|
306
328
|
const configuration = this.parseSelectedConfiguration(value);
|
|
307
329
|
const changed = this.selectedConfiguration?.base64 !== value;
|
|
308
|
-
hksvDebug(
|
|
330
|
+
hksvDebug('SelectedRecordingConfiguration write: changed=%s hasStateChangeDelegate=%s base64Len=%d', changed, !!this.stateChangeDelegate, typeof value === 'string'
|
|
331
|
+
? value.length
|
|
332
|
+
: -1);
|
|
309
333
|
this.selectedConfiguration = {
|
|
310
334
|
parsed: configuration,
|
|
311
335
|
base64: value,
|
|
@@ -317,7 +341,7 @@ class RecordingManagement {
|
|
|
317
341
|
}
|
|
318
342
|
}
|
|
319
343
|
parseSelectedConfiguration(value) {
|
|
320
|
-
const decoded = tlv.decode(Buffer.from(value,
|
|
344
|
+
const decoded = tlv.decode(Buffer.from(value, 'base64'));
|
|
321
345
|
const recording = tlv.decode(decoded[1 /* SelectedCameraRecordingConfigurationTypes.SELECTED_RECORDING_CONFIGURATION */]);
|
|
322
346
|
const video = tlv.decode(decoded[2 /* SelectedCameraRecordingConfigurationTypes.SELECTED_VIDEO_CONFIGURATION */]);
|
|
323
347
|
const audio = tlv.decode(decoded[3 /* SelectedCameraRecordingConfigurationTypes.SELECTED_AUDIO_CONFIGURATION */]);
|
|
@@ -353,7 +377,7 @@ class RecordingManagement {
|
|
|
353
377
|
bit_index += 1; // count our current bit index
|
|
354
378
|
}
|
|
355
379
|
return {
|
|
356
|
-
prebufferLength
|
|
380
|
+
prebufferLength,
|
|
357
381
|
eventTriggerTypes: typedEventTriggers,
|
|
358
382
|
mediaContainerConfiguration: {
|
|
359
383
|
type: containerType,
|
|
@@ -362,10 +386,10 @@ class RecordingManagement {
|
|
|
362
386
|
videoCodec: {
|
|
363
387
|
type: videoCodec,
|
|
364
388
|
parameters: {
|
|
365
|
-
profile
|
|
366
|
-
level
|
|
389
|
+
profile,
|
|
390
|
+
level,
|
|
367
391
|
bitRate: videoBitrate,
|
|
368
|
-
iFrameInterval
|
|
392
|
+
iFrameInterval,
|
|
369
393
|
},
|
|
370
394
|
resolution: [width, height, framerate],
|
|
371
395
|
},
|
|
@@ -386,23 +410,23 @@ class RecordingManagement {
|
|
|
386
410
|
const eventTriggerOptions = Buffer.alloc(8);
|
|
387
411
|
prebufferLength.writeInt32LE(options.prebufferLength, 0);
|
|
388
412
|
eventTriggerOptions.writeInt32LE(this.eventTriggerOptions, 0);
|
|
389
|
-
return tlv.encode(1 /* SupportedCameraRecordingConfigurationTypes.PREBUFFER_LENGTH */, prebufferLength, 2 /* SupportedCameraRecordingConfigurationTypes.EVENT_TRIGGER_OPTIONS */, eventTriggerOptions, 3 /* SupportedCameraRecordingConfigurationTypes.MEDIA_CONTAINER_CONFIGURATIONS */, mediaContainers.map(config => {
|
|
413
|
+
return tlv.encode(1 /* SupportedCameraRecordingConfigurationTypes.PREBUFFER_LENGTH */, prebufferLength, 2 /* SupportedCameraRecordingConfigurationTypes.EVENT_TRIGGER_OPTIONS */, eventTriggerOptions, 3 /* SupportedCameraRecordingConfigurationTypes.MEDIA_CONTAINER_CONFIGURATIONS */, mediaContainers.map((config) => {
|
|
390
414
|
const fragmentLength = Buffer.alloc(4);
|
|
391
415
|
fragmentLength.writeInt32LE(config.fragmentLength, 0);
|
|
392
416
|
return tlv.encode(1 /* MediaContainerConfigurationTypes.MEDIA_CONTAINER_TYPE */, config.type, 2 /* MediaContainerConfigurationTypes.MEDIA_CONTAINER_PARAMETERS */, tlv.encode(1 /* MediaContainerParameterTypes.FRAGMENT_LENGTH */, fragmentLength));
|
|
393
|
-
})).toString(
|
|
417
|
+
})).toString('base64');
|
|
394
418
|
}
|
|
395
419
|
_supportedVideoRecordingConfiguration(videoOptions) {
|
|
396
420
|
if (!videoOptions.parameters) {
|
|
397
|
-
throw new Error(
|
|
421
|
+
throw new Error('Video parameters cannot be undefined');
|
|
398
422
|
}
|
|
399
423
|
if (!videoOptions.resolutions) {
|
|
400
|
-
throw new Error(
|
|
424
|
+
throw new Error('Video resolutions cannot be undefined');
|
|
401
425
|
}
|
|
402
426
|
const codecParameters = tlv.encode(1 /* VideoCodecParametersTypes.PROFILE_ID */, videoOptions.parameters.profiles, 2 /* VideoCodecParametersTypes.LEVEL */, videoOptions.parameters.levels);
|
|
403
|
-
const videoStreamConfiguration = tlv.encode(1 /* VideoCodecConfigurationTypes.CODEC_TYPE */, videoOptions.type, 2 /* VideoCodecConfigurationTypes.CODEC_PARAMETERS */, codecParameters, 3 /* VideoCodecConfigurationTypes.ATTRIBUTES */, videoOptions.resolutions.map(resolution => {
|
|
427
|
+
const videoStreamConfiguration = tlv.encode(1 /* VideoCodecConfigurationTypes.CODEC_TYPE */, videoOptions.type, 2 /* VideoCodecConfigurationTypes.CODEC_PARAMETERS */, codecParameters, 3 /* VideoCodecConfigurationTypes.ATTRIBUTES */, videoOptions.resolutions.map((resolution) => {
|
|
404
428
|
if (resolution.length !== 3) {
|
|
405
|
-
throw new Error(
|
|
429
|
+
throw new Error('Unexpected video resolution');
|
|
406
430
|
}
|
|
407
431
|
const width = Buffer.alloc(2);
|
|
408
432
|
const height = Buffer.alloc(2);
|
|
@@ -412,33 +436,33 @@ class RecordingManagement {
|
|
|
412
436
|
frameRate.writeUInt8(resolution[2], 0);
|
|
413
437
|
return tlv.encode(1 /* VideoAttributesTypes.IMAGE_WIDTH */, width, 2 /* VideoAttributesTypes.IMAGE_HEIGHT */, height, 3 /* VideoAttributesTypes.FRAME_RATE */, frameRate);
|
|
414
438
|
}));
|
|
415
|
-
return tlv.encode(1 /* SupportedVideoRecordingConfigurationTypes.VIDEO_CODEC_CONFIGURATION */, videoStreamConfiguration).toString(
|
|
439
|
+
return tlv.encode(1 /* SupportedVideoRecordingConfigurationTypes.VIDEO_CODEC_CONFIGURATION */, videoStreamConfiguration).toString('base64');
|
|
416
440
|
}
|
|
417
441
|
_supportedAudioStreamConfiguration(audioOptions) {
|
|
418
442
|
const audioCodecs = Array.isArray(audioOptions.codecs)
|
|
419
443
|
? audioOptions.codecs
|
|
420
444
|
: [audioOptions.codecs];
|
|
421
445
|
if (audioCodecs.length === 0) {
|
|
422
|
-
throw Error(
|
|
446
|
+
throw new Error('CameraRecordingOptions.audio: At least one audio codec configuration must be specified!');
|
|
423
447
|
}
|
|
424
|
-
const codecConfigurations = audioCodecs.map(codec => {
|
|
448
|
+
const codecConfigurations = audioCodecs.map((codec) => {
|
|
425
449
|
const providedSamplerates = Array.isArray(codec.samplerate)
|
|
426
450
|
? codec.samplerate
|
|
427
451
|
: [codec.samplerate];
|
|
428
452
|
if (providedSamplerates.length === 0) {
|
|
429
|
-
throw new Error(
|
|
453
|
+
throw new Error('CameraRecordingOptions.audio.codecs: Audio samplerate cannot be empty!');
|
|
430
454
|
}
|
|
431
455
|
const audioParameters = tlv.encode(1 /* AudioCodecParametersTypes.CHANNEL */, Math.max(1, codec.audioChannels || 1), 2 /* AudioCodecParametersTypes.BIT_RATE */, codec.bitrateMode || 0 /* AudioBitrate.VARIABLE */, 3 /* AudioCodecParametersTypes.SAMPLE_RATE */, providedSamplerates);
|
|
432
456
|
return tlv.encode(1 /* AudioCodecConfigurationTypes.CODEC_TYPE */, codec.type, 2 /* AudioCodecConfigurationTypes.CODEC_PARAMETERS */, audioParameters);
|
|
433
457
|
});
|
|
434
|
-
return tlv.encode(1 /* SupportedAudioRecordingConfigurationTypes.AUDIO_CODEC_CONFIGURATION */, codecConfigurations).toString(
|
|
458
|
+
return tlv.encode(1 /* SupportedAudioRecordingConfigurationTypes.AUDIO_CODEC_CONFIGURATION */, codecConfigurations).toString('base64');
|
|
435
459
|
}
|
|
436
|
-
computeConfigurationHash(algorithm =
|
|
437
|
-
const configurationHash =
|
|
460
|
+
computeConfigurationHash(algorithm = 'sha256') {
|
|
461
|
+
const configurationHash = crypto.createHash(algorithm);
|
|
438
462
|
configurationHash.update(this.supportedCameraRecordingConfiguration);
|
|
439
463
|
configurationHash.update(this.supportedVideoRecordingConfiguration);
|
|
440
464
|
configurationHash.update(this.supportedAudioRecordingConfiguration);
|
|
441
|
-
return configurationHash.digest().toString(
|
|
465
|
+
return configurationHash.digest().toString('hex');
|
|
442
466
|
}
|
|
443
467
|
/**
|
|
444
468
|
* @private
|
|
@@ -446,15 +470,15 @@ class RecordingManagement {
|
|
|
446
470
|
serialize() {
|
|
447
471
|
return {
|
|
448
472
|
configurationHash: {
|
|
449
|
-
algorithm:
|
|
450
|
-
hash: this.computeConfigurationHash(
|
|
473
|
+
algorithm: 'sha256',
|
|
474
|
+
hash: this.computeConfigurationHash('sha256'),
|
|
451
475
|
},
|
|
452
476
|
selectedConfiguration: this.selectedConfiguration?.base64,
|
|
453
477
|
recordingActive: this.recordingActive,
|
|
454
|
-
recordingAudioActive: !!this.recordingManagementService.getCharacteristic(
|
|
455
|
-
eventSnapshotsActive: !!this.operatingModeService.getCharacteristic(
|
|
456
|
-
homeKitCameraActive: !!this.operatingModeService.getCharacteristic(
|
|
457
|
-
periodicSnapshotsActive: !!this.operatingModeService.getCharacteristic(
|
|
478
|
+
recordingAudioActive: !!this.recordingManagementService.getCharacteristic(Characteristic.RecordingAudioActive).value,
|
|
479
|
+
eventSnapshotsActive: !!this.operatingModeService.getCharacteristic(Characteristic.EventSnapshotsActive).value,
|
|
480
|
+
homeKitCameraActive: !!this.operatingModeService.getCharacteristic(Characteristic.HomeKitCameraActive).value,
|
|
481
|
+
periodicSnapshotsActive: !!this.operatingModeService.getCharacteristic(Characteristic.PeriodicSnapshotsActive).value,
|
|
458
482
|
};
|
|
459
483
|
}
|
|
460
484
|
/**
|
|
@@ -464,7 +488,7 @@ class RecordingManagement {
|
|
|
464
488
|
let changedState = false;
|
|
465
489
|
// we only restore the `selectedConfiguration` if our supported configuration hasn't changed.
|
|
466
490
|
const currentConfigurationHash = this.computeConfigurationHash(serialized.configurationHash.algorithm);
|
|
467
|
-
hksvDebug(
|
|
491
|
+
hksvDebug('deserialize: hasSavedSelectedConfig=%s savedHash=%s currentHash=%s hashMatch=%s recordingActive=%s', !!serialized.selectedConfiguration, serialized.configurationHash?.hash?.slice(0, 12), currentConfigurationHash.slice(0, 12), currentConfigurationHash === serialized.configurationHash?.hash, serialized.recordingActive);
|
|
468
492
|
if (serialized.selectedConfiguration) {
|
|
469
493
|
if (currentConfigurationHash === serialized.configurationHash.hash) {
|
|
470
494
|
this.selectedConfiguration = {
|
|
@@ -473,33 +497,33 @@ class RecordingManagement {
|
|
|
473
497
|
};
|
|
474
498
|
}
|
|
475
499
|
else {
|
|
476
|
-
hksvDebug(
|
|
500
|
+
hksvDebug('deserialize: discarding saved selectedConfiguration — supportedConfiguration hash changed since last run');
|
|
477
501
|
changedState = true;
|
|
478
502
|
}
|
|
479
503
|
}
|
|
480
504
|
this.recordingActive = serialized.recordingActive;
|
|
481
|
-
this.recordingManagementService.updateCharacteristic(
|
|
482
|
-
this.recordingManagementService.updateCharacteristic(
|
|
483
|
-
this.operatingModeService.updateCharacteristic(
|
|
484
|
-
this.operatingModeService.updateCharacteristic(
|
|
485
|
-
this.operatingModeService.updateCharacteristic(
|
|
505
|
+
this.recordingManagementService.updateCharacteristic(Characteristic.Active, serialized.recordingActive);
|
|
506
|
+
this.recordingManagementService.updateCharacteristic(Characteristic.RecordingAudioActive, serialized.recordingAudioActive);
|
|
507
|
+
this.operatingModeService.updateCharacteristic(Characteristic.EventSnapshotsActive, serialized.eventSnapshotsActive);
|
|
508
|
+
this.operatingModeService.updateCharacteristic(Characteristic.PeriodicSnapshotsActive, serialized.periodicSnapshotsActive);
|
|
509
|
+
this.operatingModeService.updateCharacteristic(Characteristic.HomeKitCameraActive, serialized.homeKitCameraActive);
|
|
486
510
|
for (const service of this.sensorServices) {
|
|
487
|
-
service.setCharacteristic(
|
|
511
|
+
service.setCharacteristic(Characteristic.StatusActive, serialized.homeKitCameraActive);
|
|
488
512
|
}
|
|
489
513
|
try {
|
|
490
514
|
if (this.selectedConfiguration) {
|
|
491
|
-
hksvDebug(
|
|
515
|
+
hksvDebug('deserialize: replaying updateRecordingConfiguration to delegate');
|
|
492
516
|
this.delegate.updateRecordingConfiguration(this.selectedConfiguration.parsed);
|
|
493
517
|
}
|
|
494
518
|
else {
|
|
495
|
-
hksvDebug(
|
|
519
|
+
hksvDebug('deserialize: no selectedConfiguration to restore');
|
|
496
520
|
}
|
|
497
521
|
if (serialized.recordingActive) {
|
|
498
522
|
this.delegate.updateRecordingActive(serialized.recordingActive);
|
|
499
523
|
}
|
|
500
524
|
}
|
|
501
525
|
catch (error) {
|
|
502
|
-
console.error(
|
|
526
|
+
console.error(`Failed to properly initialize CameraRecordingDelegate from persistent storage: ${error.stack}`);
|
|
503
527
|
}
|
|
504
528
|
if (changedState) {
|
|
505
529
|
this.stateChangeDelegate?.();
|
|
@@ -515,15 +539,15 @@ class RecordingManagement {
|
|
|
515
539
|
this.dataStreamManagement.destroy();
|
|
516
540
|
}
|
|
517
541
|
handleFactoryReset() {
|
|
518
|
-
hksvDebug(
|
|
542
|
+
hksvDebug('handleFactoryReset: clearing selectedConfiguration and resetting recording state');
|
|
519
543
|
this.selectedConfiguration = undefined;
|
|
520
|
-
this.recordingManagementService.updateCharacteristic(
|
|
521
|
-
this.recordingManagementService.updateCharacteristic(
|
|
522
|
-
this.operatingModeService.updateCharacteristic(
|
|
523
|
-
this.operatingModeService.updateCharacteristic(
|
|
524
|
-
this.operatingModeService.updateCharacteristic(
|
|
544
|
+
this.recordingManagementService.updateCharacteristic(Characteristic.Active, false);
|
|
545
|
+
this.recordingManagementService.updateCharacteristic(Characteristic.RecordingAudioActive, false);
|
|
546
|
+
this.operatingModeService.updateCharacteristic(Characteristic.EventSnapshotsActive, true);
|
|
547
|
+
this.operatingModeService.updateCharacteristic(Characteristic.PeriodicSnapshotsActive, true);
|
|
548
|
+
this.operatingModeService.updateCharacteristic(Characteristic.HomeKitCameraActive, true);
|
|
525
549
|
for (const service of this.sensorServices) {
|
|
526
|
-
service.setCharacteristic(
|
|
550
|
+
service.setCharacteristic(Characteristic.StatusActive, true);
|
|
527
551
|
}
|
|
528
552
|
try {
|
|
529
553
|
// notifying the delegate about the updated state
|
|
@@ -531,14 +555,14 @@ class RecordingManagement {
|
|
|
531
555
|
this.delegate.updateRecordingConfiguration(undefined);
|
|
532
556
|
}
|
|
533
557
|
catch (error) {
|
|
534
|
-
console.error(
|
|
558
|
+
console.error(`CameraRecordingDelegate failed to update state after handleFactoryReset: ${error.stack}`);
|
|
535
559
|
}
|
|
536
560
|
}
|
|
537
561
|
}
|
|
538
|
-
exports.RecordingManagement = RecordingManagement;
|
|
539
562
|
/**
|
|
540
563
|
* @group Camera
|
|
541
564
|
*/
|
|
565
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
542
566
|
var CameraRecordingStreamEvents;
|
|
543
567
|
(function (CameraRecordingStreamEvents) {
|
|
544
568
|
/**
|
|
@@ -554,8 +578,8 @@ var CameraRecordingStreamEvents;
|
|
|
554
578
|
*
|
|
555
579
|
* @group Camera
|
|
556
580
|
*/
|
|
557
|
-
// eslint-disable-next-line
|
|
558
|
-
class CameraRecordingStream extends
|
|
581
|
+
// eslint-disable-next-line ts/no-unsafe-declaration-merging
|
|
582
|
+
class CameraRecordingStream extends EventEmitter {
|
|
559
583
|
connection;
|
|
560
584
|
delegate;
|
|
561
585
|
hdsRequestId;
|
|
@@ -594,9 +618,9 @@ class CameraRecordingStream extends events_1.EventEmitter {
|
|
|
594
618
|
this._startStreaming();
|
|
595
619
|
}
|
|
596
620
|
async _startStreaming() {
|
|
597
|
-
debug(
|
|
598
|
-
this.connection.sendResponse("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, this.hdsRequestId,
|
|
599
|
-
status:
|
|
621
|
+
debug('[HDS %s] Sending DATA_SEND OPEN response for streamId %d', this.connection.remoteAddress, this.streamId);
|
|
622
|
+
this.connection.sendResponse("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, this.hdsRequestId, HDSStatus.SUCCESS, {
|
|
623
|
+
status: HDSStatus.SUCCESS,
|
|
600
624
|
});
|
|
601
625
|
// 256 KiB (1KiB to 900 KiB)
|
|
602
626
|
const maxChunk = 0x40000;
|
|
@@ -610,7 +634,7 @@ class CameraRecordingStream extends events_1.EventEmitter {
|
|
|
610
634
|
this.generator = this.delegate.handleRecordingStreamRequest(this.streamId, this.abortController.signal);
|
|
611
635
|
for await (const packet of this.generator) {
|
|
612
636
|
if (this.closed) {
|
|
613
|
-
debug(
|
|
637
|
+
debug('[HDS %s] Delegate yielded fragment after stream %d was already closed.', this.connection.remoteAddress, this.streamId);
|
|
614
638
|
break;
|
|
615
639
|
}
|
|
616
640
|
if (lastFragmentWasMarkedLast) {
|
|
@@ -629,19 +653,25 @@ class CameraRecordingStream extends events_1.EventEmitter {
|
|
|
629
653
|
// see https://github.com/Supereg/secure-video-specification#42-binary-data
|
|
630
654
|
const event = {
|
|
631
655
|
streamId: this.streamId,
|
|
632
|
-
packets: [
|
|
633
|
-
|
|
656
|
+
packets: [
|
|
657
|
+
{
|
|
658
|
+
data,
|
|
634
659
|
metadata: {
|
|
635
660
|
dataType: initialization ? "mediaInitialization" /* PacketDataType.MEDIA_INITIALIZATION */ : "mediaFragment" /* PacketDataType.MEDIA_FRAGMENT */,
|
|
636
|
-
dataSequenceNumber
|
|
637
|
-
dataChunkSequenceNumber
|
|
661
|
+
dataSequenceNumber,
|
|
662
|
+
dataChunkSequenceNumber,
|
|
638
663
|
isLastDataChunk: offset >= fragment.length,
|
|
639
|
-
dataTotalSize: dataChunkSequenceNumber === 1
|
|
664
|
+
dataTotalSize: dataChunkSequenceNumber === 1
|
|
665
|
+
? fragment.length
|
|
666
|
+
: undefined,
|
|
640
667
|
},
|
|
641
|
-
}
|
|
642
|
-
|
|
668
|
+
},
|
|
669
|
+
],
|
|
670
|
+
endOfStream: offset >= fragment.length
|
|
671
|
+
? Boolean(packet.isLast).valueOf()
|
|
672
|
+
: undefined,
|
|
643
673
|
};
|
|
644
|
-
debug(
|
|
674
|
+
debug('[HDS %s] Sending DATA_SEND DATA for stream %d with metadata: %o and length %d; EoS: %s', this.connection.remoteAddress, this.streamId, event.packets[0].metadata, data.length, event.endOfStream);
|
|
645
675
|
this.connection.sendEvent("dataSend" /* Protocols.DATA_SEND */, "data" /* Topics.DATA */, event);
|
|
646
676
|
dataChunkSequenceNumber++;
|
|
647
677
|
initialization = false;
|
|
@@ -654,8 +684,8 @@ class CameraRecordingStream extends events_1.EventEmitter {
|
|
|
654
684
|
}
|
|
655
685
|
if (!lastFragmentWasMarkedLast && !this.closed) {
|
|
656
686
|
// Delegate violates the contract. Exited normally on a non-closed stream without properly setting `isLast`.
|
|
657
|
-
console.warn(`[HDS ${this.connection.remoteAddress}] Delegate finished streaming for ${this.streamId} without setting RecordingPacket.isLast. `
|
|
658
|
-
|
|
687
|
+
console.warn(`[HDS ${this.connection.remoteAddress}] Delegate finished streaming for ${this.streamId} without setting RecordingPacket.isLast. `
|
|
688
|
+
+ 'Can\'t notify Controller about endOfStream!');
|
|
659
689
|
}
|
|
660
690
|
}
|
|
661
691
|
catch (error) {
|
|
@@ -664,13 +694,13 @@ class CameraRecordingStream extends events_1.EventEmitter {
|
|
|
664
694
|
}
|
|
665
695
|
else {
|
|
666
696
|
let closeReason = 5 /* HDSProtocolSpecificErrorReason.UNEXPECTED_FAILURE */;
|
|
667
|
-
if (error instanceof
|
|
697
|
+
if (error instanceof HDSProtocolError) {
|
|
668
698
|
closeReason = error.reason;
|
|
669
|
-
debug(
|
|
699
|
+
debug('[HDS %s] Delegate signaled to close the recording stream %d.', this.connection.remoteAddress, this.streamId);
|
|
670
700
|
}
|
|
671
|
-
else if (error instanceof
|
|
701
|
+
else if (error instanceof HDSConnectionError && error.type === 2 /* HDSConnectionErrorType.CLOSED_SOCKET */) {
|
|
672
702
|
// we are probably on a shutdown or just late. Connection is dead. End the stream!
|
|
673
|
-
debug(
|
|
703
|
+
debug('[HDS %s] Exited recording stream due to closed HDS socket: stream id %d.', this.connection.remoteAddress, this.streamId);
|
|
674
704
|
return; // execute finally and then exit (we want to skip the `sendEvent` below)
|
|
675
705
|
}
|
|
676
706
|
else {
|
|
@@ -694,19 +724,17 @@ class CameraRecordingStream extends events_1.EventEmitter {
|
|
|
694
724
|
this.kickOffCloseTimeout();
|
|
695
725
|
}
|
|
696
726
|
}
|
|
697
|
-
debug(
|
|
727
|
+
debug('[HDS %s] Finished DATA_SEND transmission for stream %d!', this.connection.remoteAddress, this.streamId);
|
|
698
728
|
}
|
|
699
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
700
729
|
handleDataSendAck(message) {
|
|
701
730
|
const streamId = message.streamId;
|
|
702
731
|
const endOfStream = message.endOfStream;
|
|
703
732
|
// The HomeKit Controller will send a DATA_SEND ACK if we set the `endOfStream` flag in the last packet
|
|
704
733
|
// of our DATA_SEND DATA packet.
|
|
705
734
|
// To my testing the session is then considered complete and the HomeKit controller will close the HDS Connection after 5 seconds.
|
|
706
|
-
debug(
|
|
735
|
+
debug('[HDS %s] Received DATA_SEND ACK packet for streamId %s. Acknowledged %s.', this.connection.remoteAddress, streamId, endOfStream);
|
|
707
736
|
this.handleClosed(() => this.delegate.acknowledgeStream?.(this.streamId));
|
|
708
737
|
}
|
|
709
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
710
738
|
handleDataSendClose(message) {
|
|
711
739
|
// see https://github.com/Supereg/secure-video-specification#43-close
|
|
712
740
|
const streamId = message.streamId;
|
|
@@ -714,13 +742,13 @@ class CameraRecordingStream extends events_1.EventEmitter {
|
|
|
714
742
|
if (streamId !== this.streamId) {
|
|
715
743
|
return;
|
|
716
744
|
}
|
|
717
|
-
debug(
|
|
745
|
+
debug('[HDS %s] Received DATA_SEND CLOSE for streamId %d with reason %s',
|
|
718
746
|
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
719
|
-
this.connection.remoteAddress, streamId,
|
|
747
|
+
this.connection.remoteAddress, streamId, HDSProtocolSpecificErrorReason[reason]);
|
|
720
748
|
this.handleClosed(() => this.delegate.closeRecordingStream(streamId, reason));
|
|
721
749
|
}
|
|
722
750
|
handleDataStreamConnectionClosed() {
|
|
723
|
-
debug(
|
|
751
|
+
debug('[HDS %s] The HDS connection of the stream %d closed.', this.connection.remoteAddress, this.streamId);
|
|
724
752
|
this.handleClosed(() => this.delegate.closeRecordingStream(this.streamId, undefined));
|
|
725
753
|
}
|
|
726
754
|
handleClosed(closure) {
|
|
@@ -743,12 +771,12 @@ class CameraRecordingStream extends events_1.EventEmitter {
|
|
|
743
771
|
// generator terminates promptly even if the delegate doesn't check the signal. We catch rejections
|
|
744
772
|
// to prevent unhandled promise warnings if the generator's cleanup throws.
|
|
745
773
|
// @ts-expect-error: AsyncGenerator.return() requires a value parameter, but we're signaling termination.
|
|
746
|
-
void this.generator.return().catch((error) => debug(
|
|
774
|
+
void this.generator.return().catch((error) => debug('[HDS %s] Error while closing recording generator for stream %d: %s', this.connection.remoteAddress, this.streamId, error.stack ?? String(error)));
|
|
747
775
|
// when this variable is defined, the generator hasn't returned yet.
|
|
748
776
|
// we start a timeout to uncover potential programming mistakes where we await forever and can't free resources.
|
|
749
777
|
this.generatorTimeout = setTimeout(() => {
|
|
750
|
-
console.error(
|
|
751
|
-
|
|
778
|
+
console.error('[HDS %s] Recording download stream %d is still awaiting generator although stream was closed 10s ago! '
|
|
779
|
+
+ 'This is a programming mistake by the camera implementation which prevents freeing up resources.', this.connection.remoteAddress, this.streamId);
|
|
752
780
|
}, 10000);
|
|
753
781
|
}
|
|
754
782
|
try {
|
|
@@ -767,14 +795,14 @@ class CameraRecordingStream extends events_1.EventEmitter {
|
|
|
767
795
|
if (this.closed) {
|
|
768
796
|
return;
|
|
769
797
|
}
|
|
770
|
-
debug(
|
|
798
|
+
debug('[HDS %s] Recording stream %d was closed manually with reason %s.',
|
|
771
799
|
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
772
|
-
this.connection.remoteAddress, this.streamId, reason ?
|
|
800
|
+
this.connection.remoteAddress, this.streamId, reason ? HDSProtocolSpecificErrorReason[reason] : 'CLOSED');
|
|
773
801
|
// the `isConsideredClosed` check just ensures that the won't ever throw here and that `handledClosed` is always executed.
|
|
774
802
|
if (!this.connection.isConsideredClosed()) {
|
|
775
803
|
this.connection.sendEvent("dataSend" /* Protocols.DATA_SEND */, "close" /* Topics.CLOSE */, {
|
|
776
804
|
streamId: this.streamId,
|
|
777
|
-
reason
|
|
805
|
+
reason,
|
|
778
806
|
});
|
|
779
807
|
}
|
|
780
808
|
this.handleClosed(() => this.delegate.closeRecordingStream(this.streamId, reason));
|
|
@@ -787,7 +815,7 @@ class CameraRecordingStream extends events_1.EventEmitter {
|
|
|
787
815
|
if (this.closed) {
|
|
788
816
|
return;
|
|
789
817
|
}
|
|
790
|
-
debug(
|
|
818
|
+
debug('[HDS %s] Recording stream %d took longer than expected to fully close. Force closing now!', this.connection.remoteAddress, this.streamId);
|
|
791
819
|
this.close(3 /* HDSProtocolSpecificErrorReason.CANCELLED */);
|
|
792
820
|
}, 12000);
|
|
793
821
|
}
|