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