@camera.ui/camera-ui-homekit 0.0.28 → 0.0.29

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 (59) hide show
  1. package/bundle.zip +0 -0
  2. package/package.json +17 -34
  3. package/CHANGELOG.md +0 -8
  4. package/CONTRIBUTING.md +0 -1
  5. package/LICENSE.md +0 -22
  6. package/README.md +0 -1
  7. package/dist/camera/accessory.d.ts +0 -28
  8. package/dist/camera/accessory.js +0 -380
  9. package/dist/camera/accessory.js.map +0 -1
  10. package/dist/camera/recordingDelegate.d.ts +0 -27
  11. package/dist/camera/recordingDelegate.js +0 -264
  12. package/dist/camera/recordingDelegate.js.map +0 -1
  13. package/dist/camera/services.d.ts +0 -28
  14. package/dist/camera/services.js +0 -202
  15. package/dist/camera/services.js.map +0 -1
  16. package/dist/camera/sessionWrapper.d.ts +0 -40
  17. package/dist/camera/sessionWrapper.js +0 -517
  18. package/dist/camera/sessionWrapper.js.map +0 -1
  19. package/dist/camera/streamingDelegate.d.ts +0 -14
  20. package/dist/camera/streamingDelegate.js +0 -100
  21. package/dist/camera/streamingDelegate.js.map +0 -1
  22. package/dist/camera/streamingServer.d.ts +0 -26
  23. package/dist/camera/streamingServer.js +0 -145
  24. package/dist/camera/streamingServer.js.map +0 -1
  25. package/dist/constants.d.ts +0 -1
  26. package/dist/constants.js +0 -7
  27. package/dist/constants.js.map +0 -1
  28. package/dist/crypto.d.ts +0 -1
  29. package/dist/crypto.js +0 -34
  30. package/dist/crypto.js.map +0 -1
  31. package/dist/index.d.ts +0 -16
  32. package/dist/index.js +0 -53
  33. package/dist/index.js.map +0 -1
  34. package/dist/types.d.ts +0 -16
  35. package/dist/types.js +0 -2
  36. package/dist/types.js.map +0 -1
  37. package/dist/utils/mac.d.ts +0 -4
  38. package/dist/utils/mac.js +0 -19
  39. package/dist/utils/mac.js.map +0 -1
  40. package/dist/utils/opus-repacketizer.d.ts +0 -7
  41. package/dist/utils/opus-repacketizer.js +0 -163
  42. package/dist/utils/opus-repacketizer.js.map +0 -1
  43. package/dist/utils/processor.d.ts +0 -85
  44. package/dist/utils/processor.js +0 -475
  45. package/dist/utils/processor.js.map +0 -1
  46. package/dist/utils/return-audio-transcoder.d.ts +0 -39
  47. package/dist/utils/return-audio-transcoder.js +0 -82
  48. package/dist/utils/return-audio-transcoder.js.map +0 -1
  49. package/dist/utils/srtp.d.ts +0 -8
  50. package/dist/utils/srtp.js +0 -22
  51. package/dist/utils/srtp.js.map +0 -1
  52. package/dist/utils/utils.d.ts +0 -10
  53. package/dist/utils/utils.js +0 -38
  54. package/dist/utils/utils.js.map +0 -1
  55. package/media/cameraOffline.png +0 -0
  56. package/media/maxStreams.png +0 -0
  57. package/media/noSnapshot.png +0 -0
  58. package/media/privacyMode.png +0 -0
  59. package/scripts/install-optional-deps.js +0 -17
@@ -1,264 +0,0 @@
1
- import { checkMp4StartsWithKeyFrame } from '@camera.ui/common/cameraUtils';
2
- import { Characteristic, Service } from 'hap-nodejs';
3
- import { MP4StreamingServer } from './streamingServer.js';
4
- export class RecordingDelegate {
5
- cameraAccessory;
6
- accessory;
7
- cameraDevice;
8
- cameraLogger;
9
- isRecording = false;
10
- handlingRecordingRequest = false;
11
- maxVideoDuration = 3 * 60 * 1000;
12
- recordingTimeout;
13
- server;
14
- configuration;
15
- constructor(cameraAccessory, accessory, cameraDevice) {
16
- this.cameraAccessory = cameraAccessory;
17
- this.accessory = accessory;
18
- this.cameraDevice = cameraDevice;
19
- this.cameraLogger = cameraDevice.logger;
20
- }
21
- async updateRecordingActive(active) {
22
- this.cameraLogger.debug(`Recording active: ${active}`);
23
- if (!active) {
24
- this.accessory.getService(Service.MotionSensor)?.getCharacteristic(Characteristic.MotionDetected).updateValue(false);
25
- }
26
- this.isRecording = active;
27
- }
28
- updateRecordingConfiguration(configuration) {
29
- this.cameraLogger.debug('Recording configuration updated:', JSON.stringify(configuration));
30
- this.configuration = configuration;
31
- }
32
- async *handleRecordingStreamRequest(streamId) {
33
- if (!this.configuration) {
34
- this.cameraLogger.warn('Recording configuration is not set, cannot start recording stream!');
35
- return;
36
- }
37
- if (this.handlingRecordingRequest) {
38
- this.cameraLogger.warn('Already handling a recording stream request, cannot start another one!');
39
- return;
40
- }
41
- this.cameraLogger.log(`Starting motion recording stream for stream ID "${streamId}"`);
42
- this.handlingRecordingRequest = true;
43
- this.server = new MP4StreamingServer(this.accessory, this.cameraAccessory, this.cameraDevice);
44
- const ffmpegPath = await this.cameraAccessory.api.coreManager.getFFmpegPath();
45
- const mpegtsPrebufferingState = await this.cameraDevice.streamSource.getPrebufferingState('mpegts');
46
- const mp4PrebufferingState = await this.cameraDevice.streamSource.getPrebufferingState('mp4');
47
- const isMP4Server = mp4PrebufferingState?.url;
48
- if (!mp4PrebufferingState?.url && !this.cameraDevice.isCloud) {
49
- this.cameraLogger.attention('Prebuffering is not enabled! Please install and enable the prebuffering plugin.');
50
- }
51
- if (isMP4Server) {
52
- await this.server.connectToServer(mp4PrebufferingState.url);
53
- }
54
- else {
55
- const streamInfo = await this.cameraDevice.streamSource.probeStream(true);
56
- const cameraAudioEnabled = streamInfo && streamInfo.audio.filter((a) => a.direction === 'sendonly').length > 0;
57
- const recordingAudioEnabled = this.cameraAccessory.controller?.recordingManagement?.recordingManagementService.getCharacteristic(Characteristic.RecordingAudioActive).value === 1;
58
- const audioEnabled = cameraAudioEnabled && recordingAudioEnabled;
59
- const isAAC = streamInfo && streamInfo.audio.find((a) => a.direction === 'sendonly')?.codec === 'MPEG4-GENERIC';
60
- const transcodeRecording = this.cameraAccessory.cameraStorage.values.transcodeRecording;
61
- const request = {
62
- audio: {
63
- codec: this.configuration.audioCodec.type === 0 /* AudioRecordingCodecType.AAC_LC */ ? 'aac' : 'libfdk_aac',
64
- sampleRate: this.getSampleRate(this.configuration.audioCodec.samplerate),
65
- channels: this.configuration.audioCodec.audioChannels,
66
- bitrate: this.configuration.audioCodec.bitrate,
67
- },
68
- video: {
69
- width: this.configuration.videoCodec.resolution[0],
70
- height: this.configuration.videoCodec.resolution[1],
71
- fps: this.configuration.videoCodec.resolution[2],
72
- bitrate: this.configuration.videoCodec.parameters.bitRate,
73
- iFrameInterval: this.configuration.videoCodec.parameters.iFrameInterval / 1000,
74
- profile: this.getProfile(this.configuration.videoCodec.parameters.profile),
75
- level: this.getLevel(this.configuration.videoCodec.parameters.level),
76
- },
77
- };
78
- const ffmpegInput = ['-hide_banner', '-v', 'error', '-fflags', '+nobuffer', '-flags', 'low_delay', '-timeout', '5000000', '-fflags', '+genpts'];
79
- if (mpegtsPrebufferingState?.url) {
80
- ffmpegInput.push('-f', 'mpegts', '-re', '-i', mpegtsPrebufferingState.url);
81
- }
82
- else {
83
- const aacSource = this.cameraDevice.internalSources.find((s) => s.internal && s.type === 'aac');
84
- ffmpegInput.push('-rtsp_transport', 'tcp', '-i', aacSource.urls.rtsp.default);
85
- }
86
- const videoArgs = [];
87
- const audioArgs = [];
88
- if (transcodeRecording) {
89
- videoArgs.push(
90
- // '-an',
91
- '-sn', '-dn', '-codec:v', 'libx264', '-pix_fmt', 'yuv420p', '-profile:v', request.video.profile, '-level:v', request.video.level, '-preset', 'ultrafast', '-bf', '0', '-filter_complex', `scale=w='min(${request.video.width},iw)':h=-2`, '-b:v', `${request.video.bitrate}k`, '-bufsize', `${2 * request.video.bitrate}k`, '-maxrate', `${request.video.bitrate}k`,
92
- // '-force_key_frames', `expr:gte(t,n_forced*${request.video.iFrameInterval})`,
93
- '-g', `${request.video.iFrameInterval * request.video.fps}`, '-r', `${request.video.fps}`);
94
- }
95
- else {
96
- videoArgs.push('-vcodec', 'copy');
97
- }
98
- if (audioEnabled) {
99
- if (!isAAC) {
100
- this.cameraLogger.warn('Recording audio is not explicitly AAC, forcing transcoding. Setting audio output to AAC is recommended.');
101
- audioArgs.push(...(request.audio.codec === 'aac' ? ['-acodec', request.audio.codec, '-profile:a', 'aac_low'] : ['-acodec', request.audio.codec, '-profile:a', 'aac_eld']), '-ar', `${request.audio.sampleRate}k`, '-b:a', `${request.audio.bitrate}k`, '-ac', `${request.audio.channels}`);
102
- }
103
- else {
104
- audioArgs.push('-acodec', 'copy', '-bsf:a', 'aac_adtstoasc');
105
- }
106
- }
107
- await this.server.createServer(ffmpegPath, ffmpegInput, videoArgs, audioArgs);
108
- }
109
- if (!this.server || this.server.destroyed) {
110
- this.cameraLogger.warn('Server was destroyed, cannot start recording stream!');
111
- await this.cleanupRecording();
112
- return;
113
- }
114
- let segment = 0;
115
- let isLastSegment = false;
116
- // let headerData: Buffer[] | undefined;
117
- this.recordingTimeout = setTimeout(() => {
118
- this.cameraLogger.warn('Max recording duration reached!');
119
- isLastSegment = true;
120
- }, this.maxVideoDuration);
121
- try {
122
- let checkMp4 = !isMP4Server;
123
- let needSkip = true;
124
- let pending = [];
125
- let ftyp;
126
- let moov;
127
- for await (const box of this.server.generator()) {
128
- const { header, type, data } = box;
129
- if (checkMp4 && !ftyp && type === 'ftyp') {
130
- ftyp = [header, data];
131
- }
132
- if (checkMp4 && !moov && type === 'moov') {
133
- moov = [header, data];
134
- }
135
- if (type === 'mdat' && checkMp4) {
136
- checkMp4 = false;
137
- try {
138
- const mp4Buffer = Buffer.concat([...ftyp, ...moov, ...pending, header, data]);
139
- const mp4StartsWithKeyFrame = await checkMp4StartsWithKeyFrame(mp4Buffer, ffmpegPath);
140
- if (!mp4StartsWithKeyFrame) {
141
- this.cameraLogger.debug('MP4 fragment does not start with keyframe, skipping...');
142
- needSkip = false;
143
- pending = [];
144
- continue;
145
- }
146
- }
147
- finally {
148
- ftyp = undefined;
149
- moov = undefined;
150
- }
151
- }
152
- pending.push(header, data);
153
- if (type === 'moov' || type === 'mdat') {
154
- if (type === 'mdat' && needSkip) {
155
- pending = [];
156
- needSkip = false;
157
- continue;
158
- }
159
- const fragment = Buffer.concat(pending);
160
- pending = [];
161
- this.cameraLogger.debug(`Motion fragment #${++segment} sent. Size:`, fragment.length);
162
- yield {
163
- data: fragment,
164
- isLast: isLastSegment,
165
- };
166
- if (isLastSegment) {
167
- break;
168
- }
169
- }
170
- }
171
- }
172
- catch (error) {
173
- if (!error.message.startsWith('FFMPEG')) {
174
- this.cameraLogger.error('Encountered unexpected error on generator. Error:', error.message);
175
- }
176
- else {
177
- this.cameraLogger.debug(`Recording completed ${error}`);
178
- }
179
- }
180
- finally {
181
- await this.cleanupRecording();
182
- }
183
- }
184
- async closeRecordingStream(streamId, reason) {
185
- this.cameraLogger.log(`Closing recording stream with ID "${streamId}". Reason: ${this.getHdsReason(reason)}`);
186
- await this.cleanupRecording();
187
- }
188
- async acknowledgeStream(streamId) {
189
- this.cameraLogger.log(`Last packet of stream with ID "${streamId}" acknowledged`);
190
- await this.closeRecordingStream(streamId, 0 /* HDSProtocolSpecificErrorReason.NORMAL */);
191
- }
192
- async cleanupRecording() {
193
- clearTimeout(this.recordingTimeout);
194
- this.recordingTimeout = undefined;
195
- await this.server?.destroy();
196
- this.server = undefined;
197
- this.handlingRecordingRequest = false;
198
- }
199
- getSampleRate(samplerate) {
200
- switch (samplerate) {
201
- case 0 /* AudioRecordingSamplerate.KHZ_8 */:
202
- return '8';
203
- case 1 /* AudioRecordingSamplerate.KHZ_16 */:
204
- return '16';
205
- case 2 /* AudioRecordingSamplerate.KHZ_24 */:
206
- return '24';
207
- case 3 /* AudioRecordingSamplerate.KHZ_32 */:
208
- return '32';
209
- case 4 /* AudioRecordingSamplerate.KHZ_44_1 */:
210
- return '44.1';
211
- case 5 /* AudioRecordingSamplerate.KHZ_48 */:
212
- return '48';
213
- default:
214
- throw new Error('Unsupported audio samplerate: ' + samplerate);
215
- }
216
- }
217
- getProfile(profile) {
218
- switch (profile) {
219
- case 0 /* H264Profile.BASELINE */:
220
- return 'baseline';
221
- case 1 /* H264Profile.MAIN */:
222
- return 'main';
223
- case 2 /* H264Profile.HIGH */:
224
- return 'high';
225
- }
226
- }
227
- getLevel(level) {
228
- switch (level) {
229
- case 0 /* H264Level.LEVEL3_1 */:
230
- return '3.1';
231
- case 1 /* H264Level.LEVEL3_2 */:
232
- return '3.2';
233
- case 2 /* H264Level.LEVEL4_0 */:
234
- return '4.0';
235
- }
236
- }
237
- getHdsReason(reason) {
238
- switch (reason) {
239
- case 7 /* HDSProtocolSpecificErrorReason.BAD_DATA */:
240
- return 'Bad Data';
241
- case 2 /* HDSProtocolSpecificErrorReason.BUSY */:
242
- return 'Busy';
243
- case 3 /* HDSProtocolSpecificErrorReason.CANCELLED */:
244
- return 'Cancelled';
245
- case 9 /* HDSProtocolSpecificErrorReason.INVALID_CONFIGURATION */:
246
- return 'Invalid Configuration';
247
- case 0 /* HDSProtocolSpecificErrorReason.NORMAL */:
248
- return 'Normal';
249
- case 1 /* HDSProtocolSpecificErrorReason.NOT_ALLOWED */:
250
- return 'Not Allowed';
251
- case 8 /* HDSProtocolSpecificErrorReason.PROTOCOL_ERROR */:
252
- return 'Protocol Error';
253
- case 6 /* HDSProtocolSpecificErrorReason.TIMEOUT */:
254
- return 'Timeout';
255
- case 5 /* HDSProtocolSpecificErrorReason.UNEXPECTED_FAILURE */:
256
- return 'Unexpected Failure';
257
- case 4 /* HDSProtocolSpecificErrorReason.UNSUPPORTED */:
258
- return 'Unsupported';
259
- default:
260
- return 'Unknown';
261
- }
262
- }
263
- }
264
- //# sourceMappingURL=recordingDelegate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recordingDelegate.js","sourceRoot":"","sources":["../../src/camera/recordingDelegate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAqD,cAAc,EAA0D,OAAO,EAAE,MAAM,YAAY,CAAC;AAEhK,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAM1D,MAAM,OAAO,iBAAiB;IACpB,eAAe,CAAkB;IACjC,SAAS,CAAY;IACrB,YAAY,CAAe;IAC3B,YAAY,CAAgB;IAE5B,WAAW,GAAG,KAAK,CAAC;IACpB,wBAAwB,GAAG,KAAK,C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oC;QACxD,QAAQ,UAAU,EAAE,CAAC;YACnB;gBACE,OAAO,GAAG,CAAC;YACb;gBACE,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,MAAM,CAAC;YAChB;gBACE,OAAO,IAAI,CAAC;YACd;gBACE,MAAM,IAAI,KAAK,CAAC,gCAAgC,GAAG,UAAU,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,OAAoB;QACrC,QAAQ,OAAO,EAAE,CAAC;YAChB;gBACE,OAAO,UAAU,CAAC;YACpB;gBACE,OAAO,MAAM,CAAC;YAChB;gBACE,OAAO,MAAM,CAAC;QAClB,CAAC;IACH,CAAC;IAEO,QAAQ,CAAC,KAAgB;QAC/B,QAAQ,KAAK,EAAE,CAAC;YACd;gBACE,OAAO,KAAK,CAAC;YACf;gBACE,OAAO,KAAK,CAAC;YACf;gBACE,OAAO,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,MAAuC;QAC1D,QAAQ,MAAM,EAAE,CAAC;YACf;gBACE,OAAO,UAAU,CAAC;YACpB;gBACE,OAAO,MAAM,CAAC;YAChB;gBACE,OAAO,WAAW,CAAC;YACrB;gBACE,OAAO,uBAAuB,CAAC;YACjC;gBACE,OAAO,QAAQ,CAAC;YAClB;gBACE,OAAO,aAAa,CAAC;YACvB;gBACE,OAAO,gBAAgB,CAAC;YAC1B;gBACE,OAAO,SAAS,CAAC;YACnB;gBACE,OAAO,oBAAoB,CAAC;YAC9B;gBACE,OAAO,aAAa,CAAC;YACvB;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC;CACF"}
@@ -1,28 +0,0 @@
1
- import { Service } from 'hap-nodejs';
2
- import type { CameraDevice } from '@camera.ui/types';
3
- import type { Accessory } from 'hap-nodejs';
4
- import type { CameraAccessory } from './accessory.js';
5
- export declare class CameraServices {
6
- services: Service[];
7
- private accessory;
8
- private cameraAccessory;
9
- private cameraDevice;
10
- private cameraLogger;
11
- private onMotionDetected?;
12
- private onDoorbellPressed?;
13
- private onLightSwitched?;
14
- private onBatteryChanged?;
15
- private motionTimeout?;
16
- private maxMotionTimeout?;
17
- private maxMotionTime;
18
- private motionTimeoutDuration;
19
- constructor(accessory: Accessory, cameraAccessory: CameraAccessory, cameraDevice: CameraDevice);
20
- addServices(): void;
21
- private addBatteryService;
22
- private removeBatteryService;
23
- private addMotionService;
24
- private addDoorbellService;
25
- private removeDoorbellService;
26
- private addLightService;
27
- private removeLightService;
28
- }
@@ -1,202 +0,0 @@
1
- import { Characteristic, Service } from 'hap-nodejs';
2
- export class CameraServices {
3
- services = [];
4
- accessory;
5
- cameraAccessory;
6
- cameraDevice;
7
- cameraLogger;
8
- onMotionDetected;
9
- onDoorbellPressed;
10
- onLightSwitched;
11
- onBatteryChanged;
12
- motionTimeout;
13
- maxMotionTimeout;
14
- maxMotionTime = 2 * 60 * 1000;
15
- motionTimeoutDuration = 30000;
16
- constructor(accessory, cameraAccessory, cameraDevice) {
17
- this.accessory = accessory;
18
- this.cameraAccessory = cameraAccessory;
19
- this.cameraDevice = cameraDevice;
20
- this.cameraLogger = cameraDevice.logger;
21
- // this.cameraDevice.onPropertyChange('hasMotionDetector').subscribe(({ newData }) => {
22
- // if (newData) {
23
- // this.addMotionService();
24
- // } else {
25
- // this.removeMotionService();
26
- // }
27
- // });
28
- this.cameraDevice.onPropertyChange('hasLight').subscribe(({ newData }) => {
29
- if (newData) {
30
- this.addLightService();
31
- }
32
- else {
33
- this.removeLightService();
34
- }
35
- });
36
- this.cameraDevice.onPropertyChange('hasBinarySensor').subscribe(({ newData }) => {
37
- if (newData) {
38
- this.addDoorbellService();
39
- }
40
- else {
41
- this.removeDoorbellService();
42
- }
43
- });
44
- this.cameraDevice.onPropertyChange('hasBattery').subscribe(({ newData }) => {
45
- if (newData) {
46
- this.addBatteryService();
47
- }
48
- else {
49
- this.removeBatteryService();
50
- }
51
- });
52
- this.addServices();
53
- }
54
- addServices() {
55
- this.cameraLogger.debug('Adding services');
56
- this.addMotionService();
57
- this.addDoorbellService();
58
- this.addLightService();
59
- this.addBatteryService();
60
- }
61
- addBatteryService() {
62
- let batteryService = this.accessory.getService(Service.Battery);
63
- if (!batteryService && this.cameraDevice.hasBattery) {
64
- this.cameraLogger.debug('Adding battery service');
65
- batteryService = this.accessory.addService(Service.Battery, 'Battery');
66
- if (!batteryService.testCharacteristic(Characteristic.BatteryLevel)) {
67
- batteryService.addCharacteristic(Characteristic.BatteryLevel);
68
- }
69
- if (!batteryService.testCharacteristic(Characteristic.ChargingState)) {
70
- batteryService.addCharacteristic(Characteristic.ChargingState);
71
- }
72
- batteryService.getCharacteristic(Characteristic.BatteryLevel).on('change', (change) => {
73
- if (change.oldValue !== change.newValue) {
74
- this.cameraLogger.debug('Battery level changed to', change.newValue);
75
- }
76
- });
77
- batteryService.getCharacteristic(Characteristic.StatusLowBattery).on('change', (change) => {
78
- if (change.oldValue !== change.newValue) {
79
- this.cameraLogger.debug('Battery state changed to', change.newValue);
80
- }
81
- });
82
- batteryService.getCharacteristic(Characteristic.ChargingState).on('change', (change) => {
83
- if (change.oldValue !== change.newValue) {
84
- this.cameraLogger.debug('Battery charging state changed to', change.newValue);
85
- }
86
- });
87
- this.onBatteryChanged = this.cameraDevice.onBatteryChanged.subscribe(({ level, lowBattery, charging }) => {
88
- const low = lowBattery || level <= 10 ? Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
89
- const charg = charging === true ? Characteristic.ChargingState.CHARGING : Characteristic.ChargingState.NOT_CHARGING;
90
- batteryService?.getCharacteristic(Characteristic.BatteryLevel).updateValue(level);
91
- batteryService?.getCharacteristic(Characteristic.StatusLowBattery).updateValue(low);
92
- batteryService?.getCharacteristic(Characteristic.ChargingState).updateValue(charg);
93
- });
94
- this.services.push(batteryService);
95
- }
96
- }
97
- removeBatteryService() {
98
- const batteryService = this.accessory.getService(Service.Battery);
99
- if (batteryService) {
100
- this.cameraLogger.debug('Removing battery service');
101
- this.onBatteryChanged?.unsubscribe();
102
- this.accessory.removeService(batteryService);
103
- this.services = this.services.filter((service) => service.UUID !== batteryService.UUID);
104
- }
105
- }
106
- addMotionService() {
107
- let motionService = this.accessory.getService(Service.MotionSensor);
108
- if (!motionService) {
109
- this.cameraLogger.debug('Adding motion service');
110
- motionService = this.accessory.addService(Service.MotionSensor, 'Motion Sensor');
111
- motionService.getCharacteristic(Characteristic.MotionDetected).on('change', (change) => {
112
- if (change.oldValue !== change.newValue) {
113
- clearTimeout(this.maxMotionTimeout);
114
- this.cameraLogger.debug('Motion state changed to', change.newValue);
115
- if (change.newValue) {
116
- this.maxMotionTimeout = setTimeout(() => {
117
- clearTimeout(this.motionTimeout);
118
- this.cameraLogger.debug('Resetting motion state');
119
- motionService?.getCharacteristic(Characteristic.MotionDetected).updateValue(false);
120
- }, this.maxMotionTime);
121
- }
122
- }
123
- });
124
- this.onMotionDetected = this.cameraDevice.onMotionDetected.subscribe(({ state, detections }) => {
125
- clearTimeout(this.motionTimeout);
126
- const detected = state || detections.length > 0;
127
- if (detected) {
128
- motionService?.getCharacteristic(Characteristic.MotionDetected).updateValue(true);
129
- }
130
- else {
131
- this.motionTimeout = setTimeout(() => {
132
- clearTimeout(this.maxMotionTime);
133
- motionService?.getCharacteristic(Characteristic.MotionDetected).updateValue(false);
134
- }, this.motionTimeoutDuration);
135
- }
136
- });
137
- this.services.push(motionService);
138
- }
139
- }
140
- // private removeMotionService(): void {
141
- // const motionService = this.accessory.getService(Service.MotionSensor);
142
- // if (motionService) {
143
- // this.cameraLogger.debug('Removing motion service');
144
- // this.onMotionDetected?.unsubscribe();
145
- // this.accessory.removeService(motionService);
146
- // this.services = this.services.filter((service) => service.UUID !== motionService.UUID);
147
- // }
148
- // }
149
- addDoorbellService() {
150
- let doorbellService = this.accessory.getService(Service.Doorbell);
151
- if (!doorbellService && this.cameraDevice.hasBinarySensor) {
152
- this.cameraLogger.debug('Adding doorbell service');
153
- doorbellService = this.accessory.addService(Service.Doorbell, 'Doorbell');
154
- doorbellService.getCharacteristic(Characteristic.ProgrammableSwitchEvent).on('change', (change) => {
155
- if (change.oldValue !== change.newValue) {
156
- this.cameraLogger.debug('Doorbell state changed to', change.newValue);
157
- }
158
- });
159
- this.onDoorbellPressed = this.cameraDevice.onDoorbellPressed.subscribe(({ state }) => {
160
- if (state) {
161
- doorbellService?.getCharacteristic(Characteristic.ProgrammableSwitchEvent).updateValue(Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
162
- }
163
- });
164
- this.services.push(doorbellService);
165
- }
166
- }
167
- removeDoorbellService() {
168
- const doorbellService = this.accessory.getService(Service.Doorbell);
169
- if (doorbellService) {
170
- this.cameraLogger.debug('Removing doorbell service');
171
- this.onDoorbellPressed?.unsubscribe();
172
- this.accessory.removeService(doorbellService);
173
- this.services = this.services.filter((service) => service.UUID !== doorbellService.UUID);
174
- }
175
- }
176
- addLightService() {
177
- let lightService = this.accessory.getService(Service.Lightbulb);
178
- if (!lightService && this.cameraDevice.hasLight) {
179
- this.cameraLogger.debug('Adding light service');
180
- lightService = this.accessory.addService(Service.Lightbulb, 'Light');
181
- lightService.getCharacteristic(Characteristic.On).on('change', (change) => {
182
- if (change.oldValue !== change.newValue) {
183
- this.cameraLogger.debug('Light state changed to', change.newValue);
184
- }
185
- });
186
- this.onLightSwitched = this.cameraDevice.onLightSwitched.subscribe(({ state }) => {
187
- lightService?.getCharacteristic(Characteristic.On).updateValue(state);
188
- });
189
- this.services.push(lightService);
190
- }
191
- }
192
- removeLightService() {
193
- const lightService = this.accessory.getService(Service.Lightbulb);
194
- if (lightService) {
195
- this.cameraLogger.debug('Removing light service');
196
- this.onLightSwitched?.unsubscribe();
197
- this.accessory.removeService(lightService);
198
- this.services = this.services.filter((service) => service.UUID !== lightService.UUID);
199
- }
200
- }
201
- }
202
- //# sourceMappingURL=services.js.map
@@ -1 +0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raDevice } from '@camera.ui/types';
3
- import type { PrepareStreamRequest, StartStreamRequest } from 'hap-nodejs';
4
- import type { CameraAccessory } from './accessory.js';
5
- export declare class StreamingSessionWrapper {
6
- start: number;
7
- audioSsrc: number;
8
- videoSsrc: number;
9
- audioSrtp: import("../utils/srtp.js").SrtpOptions;
10
- videoSrtp: import("../utils/srtp.js").SrtpOptions;
11
- audioSplitter: RtpSplitter;
12
- videoSplitter: RtpSplitter;
13
- private cameraAccessory;
14
- private cameraDevice;
15
- private streamingSession;
16
- private prepareStreamRequest;
17
- private ffmpegProcess?;
18
- private cameraLogger;
19
- private repacketizeAudioSplitter;
20
- private packetReceivedSubject;
21
- private ffmpegHardware;
22
- constructor(cameraAccessory: CameraAccessory, cameraDevice: CameraDevice, prepareStreamRequest: PrepareStreamRequest, start: number, ffmpegHardware: FFMpegHardware);
23
- prepare(): Promise<void>;
24
- activate(startStreamRequest: StartStreamRequest): Promise<void>;
25
- stop(): void;
26
- private preCheck;
27
- private run;
28
- private startAudioSession;
29
- private startRtspSession;
30
- private createTwoWayAudioTranscoder;
31
- private listenForVideoPackets;
32
- private listenForAudioPackets;
33
- private setupAddress;
34
- private opusTranscodeArgs;
35
- private aacTranscodeArgs;
36
- private getH264Level;
37
- private getH264Profile;
38
- private isLowBandwidth;
39
- private getDurationSeconds;
40
- }