hap-nodejs 1.0.0-beta.8 → 1.0.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 +7 -3
- package/dist/accessories/AirConditioner_accessory.js +24 -24
- package/dist/accessories/AirConditioner_accessory.js.map +1 -1
- package/dist/accessories/AppleTVRemote_accessory.js +23 -23
- package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
- package/dist/accessories/Camera_accessory.js +295 -380
- package/dist/accessories/Camera_accessory.js.map +1 -1
- package/dist/accessories/Fan_accessory.js +15 -21
- package/dist/accessories/Fan_accessory.js.map +1 -1
- package/dist/accessories/GarageDoorOpener_accessory.js +12 -12
- package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
- package/dist/accessories/Light-AdaptiveLighting_accessory.js +31 -21
- package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
- package/dist/accessories/Light_accessory.js +45 -48
- package/dist/accessories/Light_accessory.js.map +1 -1
- package/dist/accessories/Lock_accessory.js +11 -11
- package/dist/accessories/Lock_accessory.js.map +1 -1
- package/dist/accessories/MotionSensor_accessory.js +8 -8
- package/dist/accessories/MotionSensor_accessory.js.map +1 -1
- package/dist/accessories/Outlet_accessory.js +10 -10
- package/dist/accessories/Outlet_accessory.js.map +1 -1
- package/dist/accessories/SmartSpeaker_accessory.js +11 -11
- package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
- package/dist/accessories/Sprinkler_accessory.js +19 -19
- package/dist/accessories/Sprinkler_accessory.js.map +1 -1
- package/dist/accessories/TV_accessory.js +17 -17
- package/dist/accessories/TV_accessory.js.map +1 -1
- package/dist/accessories/TemperatureSensor_accessory.js +6 -6
- package/dist/accessories/TemperatureSensor_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.js +3 -3
- package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.js +4 -4
- package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -1
- package/dist/accessories/gstreamer-audioProducer.js +45 -55
- package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
- package/dist/accessories/types.js +2 -2
- package/dist/accessories/types.js.map +1 -1
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -31
- package/dist/index.js.map +1 -1
- package/dist/internal-types.d.ts +4 -4
- package/dist/internal-types.d.ts.map +1 -1
- package/dist/internal-types.js +10 -6
- package/dist/internal-types.js.map +1 -1
- package/dist/lib/Accessory.d.ts +19 -74
- package/dist/lib/Accessory.d.ts.map +1 -1
- package/dist/lib/Accessory.js +775 -1155
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/Advertiser.d.ts +5 -6
- package/dist/lib/Advertiser.d.ts.map +1 -1
- package/dist/lib/Advertiser.js +402 -521
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Bridge.js +6 -10
- package/dist/lib/Bridge.js.map +1 -1
- package/dist/lib/Characteristic.d.ts +31 -93
- package/dist/lib/Characteristic.d.ts.map +1 -1
- package/dist/lib/Characteristic.js +1474 -668
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.d.ts +10 -22
- package/dist/lib/HAPServer.d.ts.map +1 -1
- package/dist/lib/HAPServer.js +224 -286
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts +9 -27
- package/dist/lib/Service.d.ts.map +1 -1
- package/dist/lib/Service.js +476 -314
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/RTPProxy.d.ts +0 -2
- package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
- package/dist/lib/camera/RTPProxy.js +112 -104
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts +2 -67
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.js +272 -292
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/RecordingManagement.d.ts +0 -1
- package/dist/lib/camera/RecordingManagement.d.ts.map +1 -1
- package/dist/lib/camera/RecordingManagement.js +325 -392
- package/dist/lib/camera/RecordingManagement.js.map +1 -1
- package/dist/lib/camera/index.d.ts +0 -1
- package/dist/lib/camera/index.d.ts.map +1 -1
- package/dist/lib/camera/index.js +1 -2
- package/dist/lib/camera/index.js.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts +19 -4
- package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.js +220 -221
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.d.ts +0 -6
- package/dist/lib/controller/CameraController.d.ts.map +1 -1
- package/dist/lib/controller/CameraController.js +192 -258
- 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 +3 -3
- package/dist/lib/controller/Controller.js.map +1 -1
- package/dist/lib/controller/DoorbellController.js +38 -39
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.d.ts +4 -20
- package/dist/lib/controller/RemoteController.d.ts.map +1 -1
- package/dist/lib/controller/RemoteController.js +351 -424
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/controller/index.js +1 -1
- package/dist/lib/datastream/DataStreamManagement.js +57 -58
- package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.d.ts +0 -1
- package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamParser.js +261 -306
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.d.ts +0 -8
- package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamServer.js +262 -275
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/datastream/index.js +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts +50 -40
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +2059 -2754
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts +14 -8
- package/dist/lib/definitions/ServiceDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.js +834 -1053
- package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
- package/dist/lib/definitions/generate-definitions.js +383 -679
- package/dist/lib/definitions/generate-definitions.js.map +1 -1
- package/dist/lib/definitions/generator-configuration.d.ts.map +1 -1
- package/dist/lib/definitions/generator-configuration.js +163 -35
- package/dist/lib/definitions/generator-configuration.js.map +1 -1
- package/dist/lib/definitions/index.js +1 -1
- package/dist/lib/model/AccessoryInfo.d.ts +0 -1
- package/dist/lib/model/AccessoryInfo.d.ts.map +1 -1
- package/dist/lib/model/AccessoryInfo.js +102 -137
- package/dist/lib/model/AccessoryInfo.js.map +1 -1
- package/dist/lib/model/ControllerStorage.js +86 -89
- package/dist/lib/model/ControllerStorage.js.map +1 -1
- package/dist/lib/model/HAPStorage.js +15 -16
- package/dist/lib/model/HAPStorage.js.map +1 -1
- package/dist/lib/model/IdentifierCache.js +49 -49
- package/dist/lib/model/IdentifierCache.js.map +1 -1
- package/dist/lib/tv/AccessControlManagement.d.ts +0 -1
- package/dist/lib/tv/AccessControlManagement.d.ts.map +1 -1
- package/dist/lib/tv/AccessControlManagement.js +43 -46
- package/dist/lib/tv/AccessControlManagement.js.map +1 -1
- package/dist/lib/util/checkName.d.ts +8 -0
- package/dist/lib/util/checkName.d.ts.map +1 -0
- package/dist/lib/util/checkName.js +17 -0
- package/dist/lib/util/checkName.js.map +1 -0
- package/dist/lib/util/clone.js +6 -29
- package/dist/lib/util/clone.js.map +1 -1
- package/dist/lib/util/color-utils.js +8 -12
- package/dist/lib/util/color-utils.js.map +1 -1
- package/dist/lib/util/eventedhttp.d.ts +5 -9
- package/dist/lib/util/eventedhttp.d.ts.map +1 -1
- package/dist/lib/util/eventedhttp.js +306 -405
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.d.ts +0 -1
- package/dist/lib/util/hapCrypto.d.ts.map +1 -1
- package/dist/lib/util/hapCrypto.js +39 -41
- package/dist/lib/util/hapCrypto.js.map +1 -1
- package/dist/lib/util/hapStatusError.js +9 -12
- package/dist/lib/util/hapStatusError.js.map +1 -1
- package/dist/lib/util/net-utils.d.ts.map +1 -1
- package/dist/lib/util/net-utils.js +34 -54
- package/dist/lib/util/net-utils.js.map +1 -1
- package/dist/lib/util/once.js +4 -10
- package/dist/lib/util/once.js.map +1 -1
- package/dist/lib/util/promise-utils.d.ts +0 -1
- package/dist/lib/util/promise-utils.d.ts.map +1 -1
- package/dist/lib/util/promise-utils.js +10 -16
- package/dist/lib/util/promise-utils.js.map +1 -1
- package/dist/lib/util/request-util.js +8 -10
- package/dist/lib/util/request-util.js.map +1 -1
- package/dist/lib/util/time.d.ts +0 -1
- package/dist/lib/util/time.d.ts.map +1 -1
- package/dist/lib/util/time.js +7 -8
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/tlv.d.ts +0 -28
- package/dist/lib/util/tlv.d.ts.map +1 -1
- package/dist/lib/util/tlv.js +83 -126
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.d.ts +0 -10
- package/dist/lib/util/uuid.d.ts.map +1 -1
- package/dist/lib/util/uuid.js +22 -40
- package/dist/lib/util/uuid.js.map +1 -1
- package/dist/types.d.ts +0 -35
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +29 -28
- package/dist/lib/AccessoryLoader.d.ts +0 -28
- package/dist/lib/AccessoryLoader.d.ts.map +0 -1
- package/dist/lib/AccessoryLoader.js +0 -167
- package/dist/lib/AccessoryLoader.js.map +0 -1
- package/dist/lib/camera/Camera.d.ts +0 -44
- package/dist/lib/camera/Camera.d.ts.map +0 -1
- package/dist/lib/camera/Camera.js +0 -36
- package/dist/lib/camera/Camera.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CameraController = exports.CameraControllerEvents = exports.ResourceRequestReason = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
6
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
7
|
+
const events_1 = require("events");
|
|
8
|
+
const camera_1 = require("../camera");
|
|
9
|
+
const Characteristic_1 = require("../Characteristic");
|
|
10
|
+
const datastream_1 = require("../datastream");
|
|
11
|
+
const Service_1 = require("../Service");
|
|
12
|
+
const hapStatusError_1 = require("../util/hapStatusError");
|
|
13
|
+
const debug = (0, debug_1.default)("HAP-NodeJS:Camera:Controller");
|
|
14
14
|
/**
|
|
15
15
|
* @group Camera
|
|
16
16
|
*/
|
|
@@ -26,7 +26,7 @@ var ResourceRequestReason;
|
|
|
26
26
|
* In the example of camera image snapshots, requests are made due to e.g. a motion event or similar.
|
|
27
27
|
*/
|
|
28
28
|
ResourceRequestReason[ResourceRequestReason["EVENT"] = 1] = "EVENT";
|
|
29
|
-
})(ResourceRequestReason
|
|
29
|
+
})(ResourceRequestReason || (exports.ResourceRequestReason = ResourceRequestReason = {}));
|
|
30
30
|
/**
|
|
31
31
|
* @group Camera
|
|
32
32
|
*/
|
|
@@ -43,42 +43,64 @@ var CameraControllerEvents;
|
|
|
43
43
|
* except the mute state. When you unmute the device microphone it will reset the mute state if it was set previously.
|
|
44
44
|
*/
|
|
45
45
|
CameraControllerEvents["SPEAKER_PROPERTIES_CHANGED"] = "speaker-change";
|
|
46
|
-
})(CameraControllerEvents
|
|
46
|
+
})(CameraControllerEvents || (exports.CameraControllerEvents = CameraControllerEvents = {}));
|
|
47
47
|
/**
|
|
48
48
|
* Everything needed to expose a HomeKit Camera.
|
|
49
49
|
*
|
|
50
50
|
* @group Camera
|
|
51
51
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
53
|
+
class CameraController extends events_1.EventEmitter {
|
|
54
|
+
static STREAM_MANAGEMENT = "streamManagement"; // key to index all RTPStreamManagement services
|
|
55
|
+
stateChangeDelegate;
|
|
56
|
+
streamCount;
|
|
57
|
+
delegate;
|
|
58
|
+
streamingOptions;
|
|
59
|
+
/**
|
|
60
|
+
* **Temporary** storage for {@link CameraRecordingOptions} and {@link CameraRecordingDelegate}.
|
|
61
|
+
* This property is reset to `undefined` after the CameraController was fully initialized.
|
|
62
|
+
* You can still access those values via the {@link CameraController.recordingManagement}.
|
|
63
|
+
*/
|
|
64
|
+
recording;
|
|
65
|
+
/**
|
|
66
|
+
* Temporary storage for the sensor option.
|
|
67
|
+
*/
|
|
68
|
+
sensorOptions;
|
|
69
|
+
legacyMode = false;
|
|
70
|
+
/**
|
|
71
|
+
* @private
|
|
72
|
+
*/
|
|
73
|
+
streamManagements = [];
|
|
74
|
+
/**
|
|
75
|
+
* The {@link RecordingManagement} which is responsible for handling HomeKit Secure Video.
|
|
76
|
+
* This property is only present if recording was configured.
|
|
77
|
+
*/
|
|
78
|
+
recordingManagement;
|
|
79
|
+
microphoneService;
|
|
80
|
+
speakerService;
|
|
81
|
+
microphoneMuted = false;
|
|
82
|
+
microphoneVolume = 100;
|
|
83
|
+
speakerMuted = false;
|
|
84
|
+
speakerVolume = 100;
|
|
85
|
+
motionService;
|
|
86
|
+
motionServiceExternallySupplied = false;
|
|
87
|
+
occupancyService;
|
|
88
|
+
occupancyServiceExternallySupplied = false;
|
|
89
|
+
constructor(options, legacyMode = false) {
|
|
90
|
+
super();
|
|
91
|
+
this.streamCount = Math.max(1, options.cameraStreamCount || 1);
|
|
92
|
+
this.delegate = options.delegate;
|
|
93
|
+
this.streamingOptions = options.streamingOptions;
|
|
94
|
+
this.recording = options.recording;
|
|
95
|
+
this.sensorOptions = options.sensors;
|
|
96
|
+
this.legacyMode = legacyMode; // legacy mode will prevent from Microphone and Speaker services to get created to avoid collisions
|
|
75
97
|
}
|
|
76
98
|
/**
|
|
77
99
|
* @private
|
|
78
100
|
*/
|
|
79
|
-
|
|
101
|
+
controllerId() {
|
|
80
102
|
return "camera" /* DefaultControllerType.CAMERA */;
|
|
81
|
-
}
|
|
103
|
+
}
|
|
82
104
|
// ----------------------------------- STREAM API ------------------------------------
|
|
83
105
|
/**
|
|
84
106
|
* Call this method if you want to forcefully suspend an ongoing streaming session.
|
|
@@ -86,63 +108,60 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
86
108
|
*
|
|
87
109
|
* @param sessionId - id of the current ongoing streaming session
|
|
88
110
|
*/
|
|
89
|
-
|
|
90
|
-
this.streamManagements.forEach(
|
|
111
|
+
forceStopStreamingSession(sessionId) {
|
|
112
|
+
this.streamManagements.forEach(management => {
|
|
91
113
|
if (management.sessionIdentifier === sessionId) {
|
|
92
114
|
management.forceStop();
|
|
93
115
|
}
|
|
94
116
|
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
117
|
+
}
|
|
118
|
+
static generateSynchronisationSource() {
|
|
119
|
+
const ssrc = crypto_1.default.randomBytes(4); // range [-2.14748e+09 - 2.14748e+09]
|
|
98
120
|
ssrc[0] = 0;
|
|
99
121
|
return ssrc.readInt32BE(0);
|
|
100
|
-
}
|
|
122
|
+
}
|
|
101
123
|
// ----------------------------- MICROPHONE/SPEAKER API ------------------------------
|
|
102
|
-
|
|
103
|
-
if (muted === void 0) { muted = true; }
|
|
124
|
+
setMicrophoneMuted(muted = true) {
|
|
104
125
|
if (!this.microphoneService) {
|
|
105
126
|
return;
|
|
106
127
|
}
|
|
107
128
|
this.microphoneMuted = muted;
|
|
108
129
|
this.microphoneService.updateCharacteristic(Characteristic_1.Characteristic.Mute, muted);
|
|
109
|
-
}
|
|
110
|
-
|
|
130
|
+
}
|
|
131
|
+
setMicrophoneVolume(volume) {
|
|
111
132
|
if (!this.microphoneService) {
|
|
112
133
|
return;
|
|
113
134
|
}
|
|
114
135
|
this.microphoneVolume = volume;
|
|
115
136
|
this.microphoneService.updateCharacteristic(Characteristic_1.Characteristic.Volume, volume);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (muted === void 0) { muted = true; }
|
|
137
|
+
}
|
|
138
|
+
setSpeakerMuted(muted = true) {
|
|
119
139
|
if (!this.speakerService) {
|
|
120
140
|
return;
|
|
121
141
|
}
|
|
122
142
|
this.speakerMuted = muted;
|
|
123
143
|
this.speakerService.updateCharacteristic(Characteristic_1.Characteristic.Mute, muted);
|
|
124
|
-
}
|
|
125
|
-
|
|
144
|
+
}
|
|
145
|
+
setSpeakerVolume(volume) {
|
|
126
146
|
if (!this.speakerService) {
|
|
127
147
|
return;
|
|
128
148
|
}
|
|
129
149
|
this.speakerVolume = volume;
|
|
130
150
|
this.speakerService.updateCharacteristic(Characteristic_1.Characteristic.Volume, volume);
|
|
131
|
-
}
|
|
132
|
-
|
|
151
|
+
}
|
|
152
|
+
emitMicrophoneChange() {
|
|
133
153
|
this.emit("microphone-change" /* CameraControllerEvents.MICROPHONE_PROPERTIES_CHANGED */, this.microphoneMuted, this.microphoneVolume);
|
|
134
|
-
}
|
|
135
|
-
|
|
154
|
+
}
|
|
155
|
+
emitSpeakerChange() {
|
|
136
156
|
this.emit("speaker-change" /* CameraControllerEvents.SPEAKER_PROPERTIES_CHANGED */, this.speakerMuted, this.speakerVolume);
|
|
137
|
-
}
|
|
157
|
+
}
|
|
138
158
|
// -----------------------------------------------------------------------------------
|
|
139
159
|
/**
|
|
140
160
|
* @private
|
|
141
161
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
var rtp = new camera_1.RTPStreamManagement(i, this.streamingOptions, this.delegate, undefined, this.rtpStreamManagementDisabledThroughOperatingMode.bind(this));
|
|
162
|
+
constructServices() {
|
|
163
|
+
for (let i = 0; i < this.streamCount; i++) {
|
|
164
|
+
const rtp = new camera_1.RTPStreamManagement(i, this.streamingOptions, this.delegate, undefined, this.rtpStreamManagementDisabledThroughOperatingMode.bind(this));
|
|
146
165
|
this.streamManagements.push(rtp);
|
|
147
166
|
}
|
|
148
167
|
if (!this.legacyMode && this.streamingOptions.audio) {
|
|
@@ -158,7 +177,7 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
158
177
|
if (this.recording) {
|
|
159
178
|
this.recordingManagement = new camera_1.RecordingManagement(this.recording.options, this.recording.delegate, this.retrieveEventTriggerOptions());
|
|
160
179
|
}
|
|
161
|
-
if (
|
|
180
|
+
if (this.sensorOptions?.motion) {
|
|
162
181
|
if (typeof this.sensorOptions.motion === "boolean") {
|
|
163
182
|
this.motionService = new Service_1.Service.MotionSensor("", "");
|
|
164
183
|
}
|
|
@@ -167,9 +186,9 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
167
186
|
this.motionServiceExternallySupplied = true;
|
|
168
187
|
}
|
|
169
188
|
this.motionService.setCharacteristic(Characteristic_1.Characteristic.StatusActive, true);
|
|
170
|
-
|
|
189
|
+
this.recordingManagement?.recordingManagementService.addLinkedService(this.motionService);
|
|
171
190
|
}
|
|
172
|
-
if (
|
|
191
|
+
if (this.sensorOptions?.occupancy) {
|
|
173
192
|
if (typeof this.sensorOptions.occupancy === "boolean") {
|
|
174
193
|
this.occupancyService = new Service_1.Service.OccupancySensor("", "");
|
|
175
194
|
}
|
|
@@ -178,9 +197,9 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
178
197
|
this.occupancyServiceExternallySupplied = true;
|
|
179
198
|
}
|
|
180
199
|
this.occupancyService.setCharacteristic(Characteristic_1.Characteristic.StatusActive, true);
|
|
181
|
-
|
|
200
|
+
this.recordingManagement?.recordingManagementService.addLinkedService(this.occupancyService);
|
|
182
201
|
}
|
|
183
|
-
|
|
202
|
+
const serviceMap = {
|
|
184
203
|
microphone: this.microphoneService,
|
|
185
204
|
speaker: this.speakerService,
|
|
186
205
|
motionService: !this.motionServiceExternallySupplied ? this.motionService : undefined,
|
|
@@ -191,35 +210,34 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
191
210
|
serviceMap.cameraOperatingMode = this.recordingManagement.operatingModeService;
|
|
192
211
|
serviceMap.dataStreamTransportManagement = this.recordingManagement.dataStreamManagement.getService();
|
|
193
212
|
}
|
|
194
|
-
this.streamManagements.forEach(
|
|
213
|
+
this.streamManagements.forEach((management, index) => {
|
|
195
214
|
serviceMap[CameraController.STREAM_MANAGEMENT + index] = management.getService();
|
|
196
215
|
});
|
|
197
216
|
this.recording = undefined;
|
|
198
217
|
this.sensorOptions = undefined;
|
|
199
218
|
return serviceMap;
|
|
200
|
-
}
|
|
219
|
+
}
|
|
201
220
|
/**
|
|
202
221
|
* @private
|
|
203
222
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
223
|
+
initWithServices(serviceMap) {
|
|
224
|
+
const result = this._initWithServices(serviceMap);
|
|
206
225
|
if (result.updated) { // serviceMap must only be returned if anything actually changed
|
|
207
226
|
return result.serviceMap;
|
|
208
227
|
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
var modifiedServiceMap = false;
|
|
228
|
+
}
|
|
229
|
+
_initWithServices(serviceMap) {
|
|
230
|
+
let modifiedServiceMap = false;
|
|
213
231
|
// eslint-disable-next-line no-constant-condition
|
|
214
|
-
for (
|
|
215
|
-
|
|
232
|
+
for (let i = 0; true; i++) {
|
|
233
|
+
const streamManagementService = serviceMap[CameraController.STREAM_MANAGEMENT + i];
|
|
216
234
|
if (i < this.streamCount) {
|
|
217
|
-
|
|
235
|
+
const operatingModeClosure = this.rtpStreamManagementDisabledThroughOperatingMode.bind(this);
|
|
218
236
|
if (streamManagementService) { // normal init
|
|
219
237
|
this.streamManagements.push(new camera_1.RTPStreamManagement(i, this.streamingOptions, this.delegate, streamManagementService, operatingModeClosure));
|
|
220
238
|
}
|
|
221
239
|
else { // stream count got bigger, we need to create a new service
|
|
222
|
-
|
|
240
|
+
const management = new camera_1.RTPStreamManagement(i, this.streamingOptions, this.delegate, undefined, operatingModeClosure);
|
|
223
241
|
this.streamManagements.push(management);
|
|
224
242
|
serviceMap[CameraController.STREAM_MANAGEMENT + i] = management.getService();
|
|
225
243
|
modifiedServiceMap = true;
|
|
@@ -254,7 +272,7 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
254
272
|
modifiedServiceMap = true;
|
|
255
273
|
}
|
|
256
274
|
// SPEAKER
|
|
257
|
-
if (!this.legacyMode &&
|
|
275
|
+
if (!this.legacyMode && this.streamingOptions.audio?.twoWayAudio) { // speaker should be present
|
|
258
276
|
if (serviceMap.speaker) {
|
|
259
277
|
this.speakerService = serviceMap.speaker;
|
|
260
278
|
}
|
|
@@ -273,7 +291,7 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
273
291
|
}
|
|
274
292
|
// RECORDING
|
|
275
293
|
if (this.recording) {
|
|
276
|
-
|
|
294
|
+
const eventTriggers = this.retrieveEventTriggerOptions();
|
|
277
295
|
// RECORDING MANAGEMENT
|
|
278
296
|
if (serviceMap.cameraEventRecordingManagement && serviceMap.cameraOperatingMode && serviceMap.dataStreamTransportManagement) {
|
|
279
297
|
this.recordingManagement = new camera_1.RecordingManagement(this.recording.options, this.recording.delegate, eventTriggers, {
|
|
@@ -305,7 +323,7 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
305
323
|
}
|
|
306
324
|
}
|
|
307
325
|
// MOTION SENSOR
|
|
308
|
-
if (
|
|
326
|
+
if (this.sensorOptions?.motion) {
|
|
309
327
|
if (typeof this.sensorOptions.motion === "boolean") {
|
|
310
328
|
if (serviceMap.motionService) {
|
|
311
329
|
this.motionService = serviceMap.motionService;
|
|
@@ -320,23 +338,23 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
320
338
|
this.motionService = this.sensorOptions.motion;
|
|
321
339
|
this.motionServiceExternallySupplied = true;
|
|
322
340
|
if (serviceMap.motionService) { // motion service previously supplied as bool option
|
|
323
|
-
|
|
341
|
+
this.recordingManagement?.recordingManagementService.removeLinkedService(serviceMap.motionService);
|
|
324
342
|
delete serviceMap.motionService;
|
|
325
343
|
modifiedServiceMap = true;
|
|
326
344
|
}
|
|
327
345
|
}
|
|
328
346
|
this.motionService.setCharacteristic(Characteristic_1.Characteristic.StatusActive, true);
|
|
329
|
-
|
|
347
|
+
this.recordingManagement?.recordingManagementService.addLinkedService(this.motionService);
|
|
330
348
|
}
|
|
331
349
|
else {
|
|
332
350
|
if (serviceMap.motionService) {
|
|
333
|
-
|
|
351
|
+
this.recordingManagement?.recordingManagementService.removeLinkedService(serviceMap.motionService);
|
|
334
352
|
delete serviceMap.motionService;
|
|
335
353
|
modifiedServiceMap = true;
|
|
336
354
|
}
|
|
337
355
|
}
|
|
338
356
|
// OCCUPANCY SENSOR
|
|
339
|
-
if (
|
|
357
|
+
if (this.sensorOptions?.occupancy) {
|
|
340
358
|
if (typeof this.sensorOptions.occupancy === "boolean") {
|
|
341
359
|
if (serviceMap.occupancyService) {
|
|
342
360
|
this.occupancyService = serviceMap.occupancyService;
|
|
@@ -351,17 +369,17 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
351
369
|
this.occupancyService = this.sensorOptions.occupancy;
|
|
352
370
|
this.occupancyServiceExternallySupplied = true;
|
|
353
371
|
if (serviceMap.occupancyService) { // occupancy service previously supplied as bool option
|
|
354
|
-
|
|
372
|
+
this.recordingManagement?.recordingManagementService.removeLinkedService(serviceMap.occupancyService);
|
|
355
373
|
delete serviceMap.occupancyService;
|
|
356
374
|
modifiedServiceMap = true;
|
|
357
375
|
}
|
|
358
376
|
}
|
|
359
377
|
this.occupancyService.setCharacteristic(Characteristic_1.Characteristic.StatusActive, true);
|
|
360
|
-
|
|
378
|
+
this.recordingManagement?.recordingManagementService.addLinkedService(this.occupancyService);
|
|
361
379
|
}
|
|
362
380
|
else {
|
|
363
381
|
if (serviceMap.occupancyService) {
|
|
364
|
-
|
|
382
|
+
this.recordingManagement?.recordingManagementService.removeLinkedService(serviceMap.occupancyService);
|
|
365
383
|
delete serviceMap.occupancyService;
|
|
366
384
|
modifiedServiceMap = true;
|
|
367
385
|
}
|
|
@@ -375,256 +393,182 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
375
393
|
serviceMap: serviceMap,
|
|
376
394
|
updated: modifiedServiceMap,
|
|
377
395
|
};
|
|
378
|
-
}
|
|
396
|
+
}
|
|
379
397
|
// overwritten in DoorbellController (to avoid cyclic dependencies, I hate typescript for that)
|
|
380
|
-
|
|
398
|
+
migrateFromDoorbell(serviceMap) {
|
|
381
399
|
if (serviceMap.doorbell) { // See NOTICE in DoorbellController
|
|
382
400
|
delete serviceMap.doorbell;
|
|
383
401
|
return true;
|
|
384
402
|
}
|
|
385
403
|
return false;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
var e_1, _a;
|
|
389
|
-
var _b;
|
|
404
|
+
}
|
|
405
|
+
retrieveEventTriggerOptions() {
|
|
390
406
|
if (!this.recording) {
|
|
391
407
|
return new Set();
|
|
392
408
|
}
|
|
393
|
-
|
|
409
|
+
const triggerOptions = new Set();
|
|
394
410
|
if (this.recording.options.overrideEventTriggerOptions) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
var option = _d.value;
|
|
398
|
-
triggerOptions.add(option);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
402
|
-
finally {
|
|
403
|
-
try {
|
|
404
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
405
|
-
}
|
|
406
|
-
finally { if (e_1) throw e_1.error; }
|
|
411
|
+
for (const option of this.recording.options.overrideEventTriggerOptions) {
|
|
412
|
+
triggerOptions.add(option);
|
|
407
413
|
}
|
|
408
414
|
}
|
|
409
|
-
if (
|
|
415
|
+
if (this.sensorOptions?.motion) {
|
|
410
416
|
triggerOptions.add(1 /* EventTriggerOption.MOTION */);
|
|
411
417
|
}
|
|
412
418
|
// this method is overwritten by the `DoorbellController` to automatically configure EventTriggerOption.DOORBELL
|
|
413
419
|
return triggerOptions;
|
|
414
|
-
}
|
|
420
|
+
}
|
|
415
421
|
/**
|
|
416
422
|
* @private
|
|
417
423
|
*/
|
|
418
|
-
|
|
419
|
-
var _this = this;
|
|
420
|
-
var _a, _b;
|
|
424
|
+
configureServices() {
|
|
421
425
|
if (this.microphoneService) {
|
|
422
426
|
this.microphoneService.getCharacteristic(Characteristic_1.Characteristic.Mute)
|
|
423
|
-
.on("get" /* CharacteristicEventTypes.GET */,
|
|
424
|
-
callback(undefined,
|
|
427
|
+
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
428
|
+
callback(undefined, this.microphoneMuted);
|
|
425
429
|
})
|
|
426
|
-
.on("set" /* CharacteristicEventTypes.SET */,
|
|
427
|
-
|
|
430
|
+
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
431
|
+
this.microphoneMuted = value;
|
|
428
432
|
callback();
|
|
429
|
-
|
|
433
|
+
this.emitMicrophoneChange();
|
|
430
434
|
});
|
|
431
435
|
this.microphoneService.getCharacteristic(Characteristic_1.Characteristic.Volume)
|
|
432
|
-
.on("get" /* CharacteristicEventTypes.GET */,
|
|
433
|
-
callback(undefined,
|
|
436
|
+
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
437
|
+
callback(undefined, this.microphoneVolume);
|
|
434
438
|
})
|
|
435
|
-
.on("set" /* CharacteristicEventTypes.SET */,
|
|
436
|
-
|
|
439
|
+
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
440
|
+
this.microphoneVolume = value;
|
|
437
441
|
callback();
|
|
438
|
-
|
|
442
|
+
this.emitMicrophoneChange();
|
|
439
443
|
});
|
|
440
444
|
}
|
|
441
445
|
if (this.speakerService) {
|
|
442
446
|
this.speakerService.getCharacteristic(Characteristic_1.Characteristic.Mute)
|
|
443
|
-
.on("get" /* CharacteristicEventTypes.GET */,
|
|
444
|
-
callback(undefined,
|
|
447
|
+
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
448
|
+
callback(undefined, this.speakerMuted);
|
|
445
449
|
})
|
|
446
|
-
.on("set" /* CharacteristicEventTypes.SET */,
|
|
447
|
-
|
|
450
|
+
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
451
|
+
this.speakerMuted = value;
|
|
448
452
|
callback();
|
|
449
|
-
|
|
453
|
+
this.emitSpeakerChange();
|
|
450
454
|
});
|
|
451
455
|
this.speakerService.getCharacteristic(Characteristic_1.Characteristic.Volume)
|
|
452
|
-
.on("get" /* CharacteristicEventTypes.GET */,
|
|
453
|
-
callback(undefined,
|
|
456
|
+
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
457
|
+
callback(undefined, this.speakerVolume);
|
|
454
458
|
})
|
|
455
|
-
.on("set" /* CharacteristicEventTypes.SET */,
|
|
456
|
-
|
|
459
|
+
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
460
|
+
this.speakerVolume = value;
|
|
457
461
|
callback();
|
|
458
|
-
|
|
462
|
+
this.emitSpeakerChange();
|
|
459
463
|
});
|
|
460
464
|
}
|
|
461
465
|
// make the sensor services available to the RecordingManagement.
|
|
462
466
|
if (this.motionService) {
|
|
463
|
-
|
|
467
|
+
this.recordingManagement?.sensorServices.push(this.motionService);
|
|
464
468
|
}
|
|
465
469
|
if (this.occupancyService) {
|
|
466
|
-
|
|
470
|
+
this.recordingManagement?.sensorServices.push(this.occupancyService);
|
|
467
471
|
}
|
|
468
|
-
}
|
|
469
|
-
|
|
472
|
+
}
|
|
473
|
+
rtpStreamManagementDisabledThroughOperatingMode() {
|
|
470
474
|
return this.recordingManagement
|
|
471
475
|
? !this.recordingManagement.operatingModeService.getCharacteristic(Characteristic_1.Characteristic.HomeKitCameraActive).value
|
|
472
476
|
: false;
|
|
473
|
-
}
|
|
477
|
+
}
|
|
474
478
|
/**
|
|
475
479
|
* @private
|
|
476
480
|
*/
|
|
477
|
-
|
|
478
|
-
var e_2, _a;
|
|
479
|
-
var _b;
|
|
481
|
+
handleControllerRemoved() {
|
|
480
482
|
this.handleFactoryReset();
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
var management = _d.value;
|
|
484
|
-
management.destroy();
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
488
|
-
finally {
|
|
489
|
-
try {
|
|
490
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
491
|
-
}
|
|
492
|
-
finally { if (e_2) throw e_2.error; }
|
|
483
|
+
for (const management of this.streamManagements) {
|
|
484
|
+
management.destroy();
|
|
493
485
|
}
|
|
494
486
|
this.streamManagements.splice(0, this.streamManagements.length);
|
|
495
487
|
this.microphoneService = undefined;
|
|
496
488
|
this.speakerService = undefined;
|
|
497
|
-
|
|
489
|
+
this.recordingManagement?.destroy();
|
|
498
490
|
this.recordingManagement = undefined;
|
|
499
491
|
this.removeAllListeners();
|
|
500
|
-
}
|
|
492
|
+
}
|
|
501
493
|
/**
|
|
502
494
|
* @private
|
|
503
495
|
*/
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
this.
|
|
507
|
-
(_a = this.recordingManagement) === null || _a === void 0 ? void 0 : _a.handleFactoryReset();
|
|
496
|
+
handleFactoryReset() {
|
|
497
|
+
this.streamManagements.forEach(management => management.handleFactoryReset());
|
|
498
|
+
this.recordingManagement?.handleFactoryReset();
|
|
508
499
|
this.microphoneMuted = false;
|
|
509
500
|
this.microphoneVolume = 100;
|
|
510
501
|
this.speakerMuted = false;
|
|
511
502
|
this.speakerVolume = 100;
|
|
512
|
-
}
|
|
503
|
+
}
|
|
513
504
|
/**
|
|
514
505
|
* @private
|
|
515
506
|
*/
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
var management = _d.value;
|
|
523
|
-
var serializedState = management.serialize();
|
|
524
|
-
if (serializedState) {
|
|
525
|
-
streamManagementStates.push(serializedState);
|
|
526
|
-
}
|
|
507
|
+
serialize() {
|
|
508
|
+
const streamManagementStates = [];
|
|
509
|
+
for (const management of this.streamManagements) {
|
|
510
|
+
const serializedState = management.serialize();
|
|
511
|
+
if (serializedState) {
|
|
512
|
+
streamManagementStates.push(serializedState);
|
|
527
513
|
}
|
|
528
514
|
}
|
|
529
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
530
|
-
finally {
|
|
531
|
-
try {
|
|
532
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
533
|
-
}
|
|
534
|
-
finally { if (e_3) throw e_3.error; }
|
|
535
|
-
}
|
|
536
515
|
return {
|
|
537
516
|
streamManagements: streamManagementStates,
|
|
538
|
-
recordingManagement:
|
|
517
|
+
recordingManagement: this.recordingManagement?.serialize(),
|
|
539
518
|
};
|
|
540
|
-
}
|
|
519
|
+
}
|
|
541
520
|
/**
|
|
542
521
|
* @private
|
|
543
522
|
*/
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
var streamManagementState = _e.value;
|
|
550
|
-
var streamManagement = this.streamManagements[streamManagementState.id];
|
|
551
|
-
if (streamManagement) {
|
|
552
|
-
streamManagement.deserialize(streamManagementState);
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
557
|
-
finally {
|
|
558
|
-
try {
|
|
559
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
523
|
+
deserialize(serialized) {
|
|
524
|
+
for (const streamManagementState of serialized.streamManagements) {
|
|
525
|
+
const streamManagement = this.streamManagements[streamManagementState.id];
|
|
526
|
+
if (streamManagement) {
|
|
527
|
+
streamManagement.deserialize(streamManagementState);
|
|
560
528
|
}
|
|
561
|
-
finally { if (e_4) throw e_4.error; }
|
|
562
529
|
}
|
|
563
530
|
if (serialized.recordingManagement) {
|
|
564
531
|
if (this.recordingManagement) {
|
|
565
532
|
this.recordingManagement.deserialize(serialized.recordingManagement);
|
|
566
533
|
}
|
|
567
534
|
else {
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
var streamManagement = _g.value;
|
|
572
|
-
streamManagement.service.updateCharacteristic(Characteristic_1.Characteristic.Active, true);
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
576
|
-
finally {
|
|
577
|
-
try {
|
|
578
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
579
|
-
}
|
|
580
|
-
finally { if (e_5) throw e_5.error; }
|
|
535
|
+
// Active characteristic cannot be controlled if removing HSV, ensure they are all active!
|
|
536
|
+
for (const streamManagement of this.streamManagements) {
|
|
537
|
+
streamManagement.service.updateCharacteristic(Characteristic_1.Characteristic.Active, true);
|
|
581
538
|
}
|
|
582
|
-
|
|
539
|
+
this.stateChangeDelegate?.();
|
|
583
540
|
}
|
|
584
541
|
}
|
|
585
|
-
}
|
|
542
|
+
}
|
|
586
543
|
/**
|
|
587
544
|
* @private
|
|
588
545
|
*/
|
|
589
|
-
|
|
590
|
-
var e_6, _a;
|
|
591
|
-
var _b;
|
|
546
|
+
setupStateChangeDelegate(delegate) {
|
|
592
547
|
this.stateChangeDelegate = delegate;
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
var streamManagement = _d.value;
|
|
596
|
-
streamManagement.setupStateChangeDelegate(delegate);
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
600
|
-
finally {
|
|
601
|
-
try {
|
|
602
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
603
|
-
}
|
|
604
|
-
finally { if (e_6) throw e_6.error; }
|
|
548
|
+
for (const streamManagement of this.streamManagements) {
|
|
549
|
+
streamManagement.setupStateChangeDelegate(delegate);
|
|
605
550
|
}
|
|
606
|
-
|
|
607
|
-
}
|
|
551
|
+
this.recordingManagement?.setupStateChangeDelegate(delegate);
|
|
552
|
+
}
|
|
608
553
|
/**
|
|
609
554
|
* @private
|
|
610
555
|
*/
|
|
611
|
-
|
|
612
|
-
var _this = this;
|
|
556
|
+
handleSnapshotRequest(height, width, accessoryName, reason) {
|
|
613
557
|
// first step is to verify that the reason is applicable to our current policy
|
|
614
|
-
|
|
615
|
-
.map(
|
|
616
|
-
.reduce(
|
|
558
|
+
const streamingDisabled = this.streamManagements
|
|
559
|
+
.map(management => !management.getService().getCharacteristic(Characteristic_1.Characteristic.Active).value)
|
|
560
|
+
.reduce((previousValue, currentValue) => previousValue && currentValue);
|
|
617
561
|
if (streamingDisabled) {
|
|
618
562
|
debug("[%s] Rejecting snapshot as streaming is disabled.", accessoryName);
|
|
619
563
|
return Promise.reject(-70412 /* HAPStatus.NOT_ALLOWED_IN_CURRENT_STATE */);
|
|
620
564
|
}
|
|
621
565
|
if (this.recordingManagement) {
|
|
622
|
-
|
|
566
|
+
const operatingModeService = this.recordingManagement.operatingModeService;
|
|
623
567
|
if (!operatingModeService.getCharacteristic(Characteristic_1.Characteristic.HomeKitCameraActive).value) {
|
|
624
568
|
debug("[%s] Rejecting snapshot as HomeKit camera is disabled.", accessoryName);
|
|
625
569
|
return Promise.reject(-70412 /* HAPStatus.NOT_ALLOWED_IN_CURRENT_STATE */);
|
|
626
570
|
}
|
|
627
|
-
|
|
571
|
+
const eventSnapshotsActive = operatingModeService
|
|
628
572
|
.getCharacteristic(Characteristic_1.Characteristic.EventSnapshotsActive)
|
|
629
573
|
.value;
|
|
630
574
|
if (!eventSnapshotsActive) {
|
|
@@ -637,7 +581,7 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
637
581
|
return Promise.reject(-70412 /* HAPStatus.NOT_ALLOWED_IN_CURRENT_STATE */);
|
|
638
582
|
}
|
|
639
583
|
}
|
|
640
|
-
|
|
584
|
+
const periodicSnapshotsActive = operatingModeService
|
|
641
585
|
.getCharacteristic(Characteristic_1.Characteristic.PeriodicSnapshotsActive)
|
|
642
586
|
.value;
|
|
643
587
|
if (!periodicSnapshotsActive) {
|
|
@@ -652,24 +596,24 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
652
596
|
}
|
|
653
597
|
}
|
|
654
598
|
// now do the actual snapshot request.
|
|
655
|
-
return new Promise(
|
|
599
|
+
return new Promise((resolve, reject) => {
|
|
656
600
|
// TODO test and make timeouts configurable!
|
|
657
|
-
|
|
658
|
-
console.warn(
|
|
659
|
-
timeout = setTimeout(
|
|
601
|
+
let timeout = setTimeout(() => {
|
|
602
|
+
console.warn(`[${accessoryName}] The image snapshot handler for the given accessory is slow to respond! See https://homebridge.io/w/JtMGR for more info.`);
|
|
603
|
+
timeout = setTimeout(() => {
|
|
660
604
|
timeout = undefined;
|
|
661
|
-
console.warn(
|
|
605
|
+
console.warn(`[${accessoryName}] The image snapshot handler for the given accessory didn't respond at all! See https://homebridge.io/w/JtMGR for more info.`);
|
|
662
606
|
reject(-70408 /* HAPStatus.OPERATION_TIMED_OUT */);
|
|
663
607
|
}, 17000);
|
|
664
608
|
timeout.unref();
|
|
665
|
-
},
|
|
609
|
+
}, 8000);
|
|
666
610
|
timeout.unref();
|
|
667
611
|
try {
|
|
668
|
-
|
|
612
|
+
this.delegate.handleSnapshotRequest({
|
|
669
613
|
height: height,
|
|
670
614
|
width: width,
|
|
671
615
|
reason: reason,
|
|
672
|
-
},
|
|
616
|
+
}, (error, buffer) => {
|
|
673
617
|
if (!timeout) {
|
|
674
618
|
return;
|
|
675
619
|
}
|
|
@@ -688,7 +632,7 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
688
632
|
return;
|
|
689
633
|
}
|
|
690
634
|
if (!buffer || buffer.length === 0) {
|
|
691
|
-
console.warn(
|
|
635
|
+
console.warn(`[${accessoryName}] Snapshot request handler provided empty image buffer!`);
|
|
692
636
|
reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
693
637
|
}
|
|
694
638
|
else {
|
|
@@ -704,21 +648,11 @@ var CameraController = /** @class */ (function (_super) {
|
|
|
704
648
|
clearTimeout(timeout);
|
|
705
649
|
timeout = undefined;
|
|
706
650
|
}
|
|
707
|
-
console.warn(
|
|
651
|
+
console.warn(`[${accessoryName}] Unhandled error thrown inside snapshot request handler: ${error.stack}`);
|
|
708
652
|
reject(error instanceof hapStatusError_1.HapStatusError ? error.hapStatus : -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
709
653
|
}
|
|
710
654
|
});
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
* @private
|
|
714
|
-
*/
|
|
715
|
-
CameraController.prototype.handleCloseConnection = function (sessionID) {
|
|
716
|
-
if (this.delegate instanceof camera_1.LegacyCameraSourceAdapter) {
|
|
717
|
-
this.delegate.forwardCloseConnection(sessionID);
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
CameraController.STREAM_MANAGEMENT = "streamManagement"; // key to index all RTPStreamManagement services
|
|
721
|
-
return CameraController;
|
|
722
|
-
}(events_1.EventEmitter));
|
|
655
|
+
}
|
|
656
|
+
}
|
|
723
657
|
exports.CameraController = CameraController;
|
|
724
658
|
//# sourceMappingURL=CameraController.js.map
|