homebridge-plugin-utils 1.15.2 → 1.16.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.
Files changed (51) hide show
  1. package/README.md +4 -1
  2. package/build/eslint-rules.mjs +1 -0
  3. package/dist/featureoptions.d.ts +83 -5
  4. package/dist/featureoptions.js +65 -6
  5. package/dist/featureoptions.js.map +1 -1
  6. package/dist/ffmpeg/codecs.d.ts +172 -0
  7. package/dist/ffmpeg/codecs.js +374 -0
  8. package/dist/ffmpeg/codecs.js.map +1 -0
  9. package/dist/ffmpeg/exec.d.ts +108 -0
  10. package/dist/ffmpeg/exec.js +122 -0
  11. package/dist/ffmpeg/exec.js.map +1 -0
  12. package/dist/ffmpeg/index.d.ts +8 -0
  13. package/dist/ffmpeg/index.js +13 -0
  14. package/dist/ffmpeg/index.js.map +1 -0
  15. package/dist/ffmpeg/options.d.ts +345 -0
  16. package/dist/ffmpeg/options.js +750 -0
  17. package/dist/ffmpeg/options.js.map +1 -0
  18. package/dist/ffmpeg/process.d.ts +155 -0
  19. package/dist/ffmpeg/process.js +344 -0
  20. package/dist/ffmpeg/process.js.map +1 -0
  21. package/dist/ffmpeg/record.d.ts +230 -0
  22. package/dist/ffmpeg/record.js +504 -0
  23. package/dist/ffmpeg/record.js.map +1 -0
  24. package/dist/ffmpeg/rtp.d.ts +205 -0
  25. package/dist/ffmpeg/rtp.js +335 -0
  26. package/dist/ffmpeg/rtp.js.map +1 -0
  27. package/dist/ffmpeg/settings.d.ts +6 -0
  28. package/dist/ffmpeg/settings.js +17 -0
  29. package/dist/ffmpeg/settings.js.map +1 -0
  30. package/dist/ffmpeg/stream.d.ts +143 -0
  31. package/dist/ffmpeg/stream.js +186 -0
  32. package/dist/ffmpeg/stream.js.map +1 -0
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/mqttclient.d.ts +161 -1
  37. package/dist/mqttclient.js +161 -9
  38. package/dist/mqttclient.js.map +1 -1
  39. package/dist/service.d.ts +9 -2
  40. package/dist/service.js +6 -0
  41. package/dist/service.js.map +1 -1
  42. package/dist/ui/featureoptions.js +65 -6
  43. package/dist/ui/featureoptions.js.map +1 -1
  44. package/dist/ui/webUi-featureoptions.mjs +5 -4
  45. package/dist/util.d.ts +203 -12
  46. package/dist/util.js +95 -12
  47. package/dist/util.js.map +1 -1
  48. package/package.json +13 -9
  49. package/dist/rtp.d.ts +0 -32
  50. package/dist/rtp.js +0 -178
  51. package/dist/rtp.js.map +0 -1
@@ -0,0 +1,230 @@
1
+ import { type Nullable } from "../util.js";
2
+ import type { CameraRecordingConfiguration } from "homebridge";
3
+ import type { FfmpegOptions } from "./options.js";
4
+ import { FfmpegProcess } from "./process.js";
5
+ /**
6
+ * Options for configuring an fMP4 recording or livestream session.
7
+ *
8
+ * @property fps - The video frames per second for the session.
9
+ * @property livestream - Indicates if this is a livestream session (`true`) or a recording (`false`).
10
+ * @property probesize - Number of bytes to analyze for stream information.
11
+ * @property timeshift - Timeshift offset for event-based recording (in milliseconds).
12
+ * @property url - Source URL for livestreaming (RTSP).
13
+ */
14
+ interface Fmp4OptionsConfig {
15
+ fps: number;
16
+ livestream: boolean;
17
+ probesize: number;
18
+ timeshift: number;
19
+ url: string;
20
+ }
21
+ /**
22
+ * FFmpeg process controller for HomeKit Secure Video (HKSV) and fMP4 livestreaming and recording.
23
+ *
24
+ * This class manages the lifecycle and parsing of an FFmpeg process to support HKSV and livestreaming in fMP4 format. It handles initialization segments, media segment
25
+ * parsing, buffering, and HomeKit segment generation, and emits events for segment and initialization.
26
+ *
27
+ * @example
28
+ *
29
+ * ```ts
30
+ * // Create a new recording process for an HKSV event.
31
+ * const process = new FfmpegRecordingProcess(ffmpegOptions, recordingConfig, 30, true, 5000000, 0);
32
+ *
33
+ * // Start the process.
34
+ * process.start();
35
+ *
36
+ * // Iterate over generated segments.
37
+ * for await(const segment of process.segmentGenerator()) {
38
+ *
39
+ * // Send segment to HomeKit, etc.
40
+ * }
41
+ *
42
+ * // Stop when finished.
43
+ * process.stop();
44
+ * ```
45
+ *
46
+ * @see FfmpegOptions
47
+ * @see FfmpegProcess
48
+ * @see {@link https://ffmpeg.org/ffmpeg.html | FFmpeg Documentation}
49
+ */
50
+ declare class FfmpegFmp4Process extends FfmpegProcess {
51
+ private hasInitSegment;
52
+ private _initSegment;
53
+ private isLivestream;
54
+ private isLoggingErrors;
55
+ isTimedOut: boolean;
56
+ private recordingBuffer;
57
+ private recordingConfig;
58
+ segmentLength?: number;
59
+ /**
60
+ * Constructs a new fMP4 FFmpeg process for HKSV event recording or livestreaming.
61
+ *
62
+ * @param ffmpegOptions - FFmpeg configuration options.
63
+ * @param recordingConfig - HomeKit recording configuration for the session.
64
+ * @param isAudioActive - If `true`, enables audio stream processing.
65
+ * @param fmp4Options - Partial configuration for the fMP4 session (fps, url, etc.).
66
+ *
67
+ * @example
68
+ *
69
+ * ```ts
70
+ * const process = new FfmpegFmp4Process(ffmpegOptions, recordingConfig, true, { fps: 30 });
71
+ * ```
72
+ */
73
+ constructor(ffmpegOptions: FfmpegOptions, recordingConfig: CameraRecordingConfiguration, isAudioActive: boolean, fmp4Options?: Partial<Fmp4OptionsConfig>);
74
+ /**
75
+ * Prepares and configures the FFmpeg process for reading and parsing output fMP4 data.
76
+ *
77
+ * This method is called internally by the process lifecycle and is not typically invoked directly by consumers.
78
+ */
79
+ protected configureProcess(): void;
80
+ /**
81
+ * Retrieves the fMP4 initialization segment generated by FFmpeg.
82
+ *
83
+ * Waits until the initialization segment is available, then returns it.
84
+ *
85
+ * @returns A promise resolving to the initialization segment as a Buffer.
86
+ *
87
+ * @example
88
+ *
89
+ * ```ts
90
+ * const initSegment = await process.getInitSegment();
91
+ * ```
92
+ */
93
+ protected getInitSegment(): Promise<Buffer>;
94
+ /**
95
+ * Stops the FFmpeg process and performs cleanup, including emitting termination events for segment generators.
96
+ *
97
+ * This is called as part of the process shutdown sequence.
98
+ */
99
+ protected stopProcess(): void;
100
+ /**
101
+ * Starts the FFmpeg process, adjusting segment length for livestreams if set.
102
+ *
103
+ * @example
104
+ *
105
+ * ```ts
106
+ * process.start();
107
+ * ```
108
+ */
109
+ start(): void;
110
+ /**
111
+ * Stops the FFmpeg process and logs errors if specified.
112
+ *
113
+ * @param logErrors - If `true`, logs FFmpeg errors. Defaults to the internal process logging state.
114
+ *
115
+ * @example
116
+ *
117
+ * ```ts
118
+ * process.stop();
119
+ * ```
120
+ */
121
+ stop(logErrors?: boolean): void;
122
+ /**
123
+ * Logs errors from FFmpeg process execution, handling known benign HKSV stream errors gracefully.
124
+ *
125
+ * @param exitCode - The exit code from the FFmpeg process.
126
+ * @param signal - The signal (if any) used to terminate the process.
127
+ */
128
+ protected logFfmpegError(exitCode: number, signal: NodeJS.Signals): void;
129
+ /**
130
+ * Asynchronously generates complete segments from FFmpeg output, formatted for HomeKit Secure Video.
131
+ *
132
+ * This async generator yields fMP4 segments as Buffers, or ends on process termination or timeout.
133
+ *
134
+ * @yields A Buffer containing a complete MP4 segment suitable for HomeKit.
135
+ *
136
+ * @example
137
+ *
138
+ * ```ts
139
+ * for await(const segment of process.segmentGenerator()) {
140
+ *
141
+ * // Process each segment for HomeKit.
142
+ * }
143
+ * ```
144
+ */
145
+ segmentGenerator(): AsyncGenerator<Buffer>;
146
+ /**
147
+ * Returns the initialization segment as a Buffer, or null if not yet available.
148
+ *
149
+ * @returns The initialization segment Buffer, or `null` if not yet generated.
150
+ *
151
+ * @example
152
+ *
153
+ * ```ts
154
+ * const init = process.initSegment;
155
+ * if(init) {
156
+ *
157
+ * // Use the initialization segment.
158
+ * }
159
+ * ```
160
+ */
161
+ get initSegment(): Nullable<Buffer>;
162
+ }
163
+ /**
164
+ * Manages a HomeKit Secure Video recording FFmpeg process.
165
+ *
166
+ * @example
167
+ *
168
+ * ```ts
169
+ * const process = new FfmpegRecordingProcess(ffmpegOptions, recordingConfig, 30, true, 5000000, 0);
170
+ * process.start();
171
+ * ```
172
+ *
173
+ * @see FfmpegFmp4Process
174
+ *
175
+ * @category FFmpeg
176
+ */
177
+ export declare class FfmpegRecordingProcess extends FfmpegFmp4Process {
178
+ /**
179
+ * Constructs a new FFmpeg recording process for HKSV events.
180
+ *
181
+ * @param options - FFmpeg configuration options.
182
+ * @param recordingConfig - HomeKit recording configuration for the session.
183
+ * @param fps - Video frames per second.
184
+ * @param isAudioActive - If `true`, enables audio stream processing.
185
+ * @param probesize - Stream analysis size, in bytes.
186
+ * @param timeshift - Timeshift offset for event-based recording, in milliseconds.
187
+ */
188
+ constructor(options: FfmpegOptions, recordingConfig: CameraRecordingConfiguration, fps: number, isAudioActive: boolean, probesize: number, timeshift: number);
189
+ }
190
+ /**
191
+ * Manages a HomeKit livestream FFmpeg process for generating fMP4 segments.
192
+ *
193
+ * @example
194
+ *
195
+ * ```ts
196
+ * const process = new FfmpegLivestreamProcess(ffmpegOptions, recordingConfig, url, 30, true);
197
+ * process.start();
198
+ *
199
+ * const initSegment = await process.getInitSegment();
200
+ * ```
201
+ *
202
+ * @see FfmpegFmp4Process
203
+ *
204
+ * @category FFmpeg
205
+ */
206
+ export declare class FfmpegLivestreamProcess extends FfmpegFmp4Process {
207
+ /**
208
+ * Constructs a new FFmpeg livestream process.
209
+ *
210
+ * @param options - FFmpeg configuration options.
211
+ * @param recordingConfig - HomeKit recording configuration for the session.
212
+ * @param url - Source RTSP or livestream URL.
213
+ * @param fps - Video frames per second.
214
+ * @param isAudioActive - If `true`, enables audio stream processing.
215
+ */
216
+ constructor(options: FfmpegOptions, recordingConfig: CameraRecordingConfiguration, url: string, fps: number, isAudioActive: boolean);
217
+ /**
218
+ * Gets the fMP4 initialization segment generated by FFmpeg for the livestream.
219
+ *
220
+ * @returns A promise resolving to the initialization segment as a Buffer.
221
+ *
222
+ * @example
223
+ *
224
+ * ```ts
225
+ * const initSegment = await process.getInitSegment();
226
+ * ```
227
+ */
228
+ getInitSegment(): Promise<Buffer>;
229
+ }
230
+ export {};