homebridge-nest-accfactory 0.0.4-a → 0.0.5
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/CHANGELOG.md +8 -1
- package/README.md +7 -7
- package/dist/HomeKitDevice.js +21 -10
- package/dist/HomeKitHistory.js +2 -24
- package/dist/camera.js +224 -236
- package/dist/doorbell.js +4 -4
- package/dist/floodlight.js +97 -0
- package/dist/index.js +7 -7
- package/dist/nexustalk.js +219 -418
- package/dist/protect.js +8 -9
- package/dist/protobuf/google/trait/product/camera.proto +1 -0
- package/dist/protobuf/googlehome/foyer.proto +11 -3
- package/dist/protobuf/nest/nexustalk.proto +181 -0
- package/dist/protobuf/nestlabs/eventingapi/v1.proto +6 -2
- package/dist/protobuf/nestlabs/gateway/v1.proto +29 -23
- package/dist/protobuf/nestlabs/gateway/v2.proto +16 -8
- package/dist/protobuf/root.proto +2 -27
- package/dist/protobuf/weave/trait/actuator.proto +13 -0
- package/dist/streamer.js +33 -30
- package/dist/system.js +1105 -1095
- package/dist/thermostat.js +5 -6
- package/package.json +7 -6
- package/dist/protobuf/nest/messages.proto +0 -8
- package/dist/webrtc.js +0 -55
package/dist/streamer.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// streamer.talkingAudio(talkingData)
|
|
14
14
|
// streamer.update(deviceData) <- call super after
|
|
15
15
|
//
|
|
16
|
-
// Code version
|
|
16
|
+
// Code version 11/9/2024
|
|
17
17
|
// Mark Hulskamp
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
@@ -35,17 +35,18 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Make a define
|
|
|
35
35
|
|
|
36
36
|
// Streamer object
|
|
37
37
|
export default class Streamer {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
audioEnabled = undefined;
|
|
42
|
-
online = undefined;
|
|
38
|
+
videoEnabled = undefined; // Video stream on camera enabled or not
|
|
39
|
+
audioEnabled = undefined; // Audio from camera enabled or not
|
|
40
|
+
online = undefined; // Camera online or not
|
|
43
41
|
host = ''; // Host to connect to or connected too
|
|
44
|
-
|
|
42
|
+
uuid = undefined; // UUID of the device connecting
|
|
43
|
+
connected = false; // Streamer connected to endpoint
|
|
45
44
|
|
|
46
45
|
// Internal data only for this class
|
|
47
46
|
#outputTimer = undefined; // Timer for non-blocking loop to stream output data
|
|
48
47
|
#outputs = {}; // Output streams ie: buffer, live, record
|
|
48
|
+
#cameraOfflineFrame = undefined; // Camera offline video frame
|
|
49
|
+
#cameraVideoOffFrame = undefined; // Video turned off on camera video frame
|
|
49
50
|
|
|
50
51
|
constructor(deviceData, options) {
|
|
51
52
|
// Setup logger object if passed as option
|
|
@@ -63,6 +64,7 @@ export default class Streamer {
|
|
|
63
64
|
this.online = deviceData?.online === true;
|
|
64
65
|
this.videoEnabled = deviceData?.streaming_enabled === true;
|
|
65
66
|
this.audioEnabled = deviceData?.audio_enabled === true;
|
|
67
|
+
this.uuid = deviceData?.uuid;
|
|
66
68
|
|
|
67
69
|
// Setup location for *.h264 frame files. This can be overriden by a passed in option
|
|
68
70
|
let resourcePath = path.resolve(__dirname + '/res'); // Default location for *.h264 files
|
|
@@ -76,19 +78,19 @@ export default class Streamer {
|
|
|
76
78
|
|
|
77
79
|
// load buffer for camera offline image in .h264 frame
|
|
78
80
|
if (fs.existsSync(path.resolve(resourcePath + '/' + CAMERAOFFLINEH264FILE)) === true) {
|
|
79
|
-
this
|
|
81
|
+
this.#cameraOfflineFrame = fs.readFileSync(path.resolve(resourcePath + '/' + CAMERAOFFLINEH264FILE));
|
|
80
82
|
// remove any H264 NALU from beginning of any video data. We do this as they are added later when output by our ffmpeg router
|
|
81
|
-
if (this
|
|
82
|
-
this
|
|
83
|
+
if (this.#cameraOfflineFrame.indexOf(H264NALStartcode) === 0) {
|
|
84
|
+
this.#cameraOfflineFrame = this.#cameraOfflineFrame.subarray(H264NALStartcode.length);
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
// load buffer for camera stream off image in .h264 frame
|
|
87
89
|
if (fs.existsSync(path.resolve(resourcePath + '/' + CAMERAOFFH264FILE)) === true) {
|
|
88
|
-
this
|
|
90
|
+
this.#cameraVideoOffFrame = fs.readFileSync(path.resolve(resourcePath + '/' + CAMERAOFFH264FILE));
|
|
89
91
|
// remove any H264 NALU from beginning of any video data. We do this as they are added later when output by our ffmpeg router
|
|
90
|
-
if (this
|
|
91
|
-
this
|
|
92
|
+
if (this.#cameraVideoOffFrame.indexOf(H264NALStartcode) === 0) {
|
|
93
|
+
this.#cameraVideoOffFrame = this.#cameraVideoOffFrame.subarray(H264NALStartcode.length);
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
|
|
@@ -103,15 +105,15 @@ export default class Streamer {
|
|
|
103
105
|
Object.values(this.#outputs).forEach((output) => {
|
|
104
106
|
// Monitor for camera going offline and/or video enabled/disabled
|
|
105
107
|
// We'll insert the appropriate video frame into the stream
|
|
106
|
-
if (this.online === false && this
|
|
108
|
+
if (this.online === false && this.#cameraOfflineFrame !== undefined && outputVideoFrame === true) {
|
|
107
109
|
// Camera is offline so feed in our custom h264 frame and AAC silence
|
|
108
|
-
output.buffer.push({ type: 'video', time: dateNow, data: this
|
|
110
|
+
output.buffer.push({ type: 'video', time: dateNow, data: this.#cameraOfflineFrame });
|
|
109
111
|
output.buffer.push({ type: 'audio', time: dateNow, data: AACAudioSilence });
|
|
110
112
|
lastTimeVideo = dateNow;
|
|
111
113
|
}
|
|
112
|
-
if (this.online === true && this.videoEnabled === false && this
|
|
114
|
+
if (this.online === true && this.videoEnabled === false && this.#cameraVideoOffFrame !== undefined && outputVideoFrame === true) {
|
|
113
115
|
// Camera video is turned off so feed in our custom h264 frame and AAC silence
|
|
114
|
-
output.buffer.push({ type: 'video', time: dateNow, data: this
|
|
116
|
+
output.buffer.push({ type: 'video', time: dateNow, data: this.#cameraVideoOffFrame });
|
|
115
117
|
output.buffer.push({ type: 'audio', time: dateNow, data: AACAudioSilence });
|
|
116
118
|
lastTimeVideo = dateNow;
|
|
117
119
|
}
|
|
@@ -150,10 +152,10 @@ export default class Streamer {
|
|
|
150
152
|
startBuffering() {
|
|
151
153
|
if (this.#outputs?.buffer === undefined) {
|
|
152
154
|
// No active buffer session, start connection to streamer
|
|
153
|
-
if (this.
|
|
155
|
+
if (this.connected === false && typeof this.host === 'string' && this.host !== '') {
|
|
154
156
|
if (typeof this.connect === 'function') {
|
|
155
|
-
this.connect(this.host);
|
|
156
157
|
this?.log?.debug && this.log.debug('Started buffering from "%s"', this.host);
|
|
158
|
+
this.connect(this.host);
|
|
157
159
|
}
|
|
158
160
|
}
|
|
159
161
|
|
|
@@ -199,7 +201,7 @@ export default class Streamer {
|
|
|
199
201
|
});
|
|
200
202
|
}
|
|
201
203
|
|
|
202
|
-
if (this.
|
|
204
|
+
if (this.connected === false && typeof this.host === 'string' && this.host !== '') {
|
|
203
205
|
// We do not have an active socket connection, so startup connection to host
|
|
204
206
|
if (typeof this.connect === 'function') {
|
|
205
207
|
this.connect(this.host);
|
|
@@ -218,9 +220,9 @@ export default class Streamer {
|
|
|
218
220
|
// finally, we've started live stream
|
|
219
221
|
this?.log?.debug &&
|
|
220
222
|
this.log.debug(
|
|
221
|
-
'Started live stream from "%s" %s
|
|
223
|
+
'Started live stream from "%s" %s "%s"',
|
|
222
224
|
this.host,
|
|
223
|
-
talkbackStream !== null && typeof talkbackStream === 'object' ? 'with two-way audio' : '',
|
|
225
|
+
talkbackStream !== null && typeof talkbackStream === 'object' ? 'with two-way audio and sesssion id of' : 'and sesssion id of',
|
|
224
226
|
sessionID,
|
|
225
227
|
);
|
|
226
228
|
}
|
|
@@ -239,7 +241,7 @@ export default class Streamer {
|
|
|
239
241
|
});
|
|
240
242
|
}
|
|
241
243
|
|
|
242
|
-
if (this.
|
|
244
|
+
if (this.connected === false && typeof this.host === 'string' && this.host !== '') {
|
|
243
245
|
// We do not have an active socket connection, so startup connection to host
|
|
244
246
|
if (typeof this.connect === 'function') {
|
|
245
247
|
this.connect(this.host);
|
|
@@ -302,20 +304,21 @@ export default class Streamer {
|
|
|
302
304
|
return;
|
|
303
305
|
}
|
|
304
306
|
|
|
305
|
-
this.online = deviceData?.online === true;
|
|
306
|
-
this.videoEnabled = deviceData?.streaming_enabled === true;
|
|
307
|
-
this.audioEnabled = deviceData?.audio_enabled === true;
|
|
308
|
-
|
|
309
307
|
if (this.host !== deviceData.streaming_host) {
|
|
310
308
|
this.host = deviceData.streaming_host;
|
|
311
|
-
this?.log?.debug && this.log.debug('New streaming host has requested
|
|
309
|
+
this?.log?.debug && this.log.debug('New streaming host has been requested for connection. Host requested is "%s"', this.host);
|
|
312
310
|
}
|
|
313
311
|
|
|
314
|
-
if (
|
|
312
|
+
if (
|
|
313
|
+
this.online !== deviceData.online ||
|
|
314
|
+
this.videoEnabled !== deviceData.streaming_enabled ||
|
|
315
|
+
this.audioEnabled !== deviceData?.audio_enabled
|
|
316
|
+
) {
|
|
315
317
|
// Online status or streaming status has changed has changed
|
|
316
318
|
this.online = deviceData?.online === true;
|
|
317
319
|
this.videoEnabled = deviceData?.streaming_enabled === true;
|
|
318
|
-
|
|
320
|
+
this.audioEnabled = deviceData?.audio_enabled === true;
|
|
321
|
+
if ((this.online === false || this.videoEnabled === false || this.audioEnabled === false) && typeof this.close === 'function') {
|
|
319
322
|
this.close(true); // as offline or streaming not enabled, close socket
|
|
320
323
|
}
|
|
321
324
|
if (this.online === true && this.videoEnabled === true && typeof this.connect === 'function') {
|