UNPKG

@viguza/homebridge-ezviz

Version:

A short description about what your plugin does.

79 lines 3.56 kB
import { StreamingDelegate } from '../utils/streaming-delegate.js'; /** * IP Camera accessory for EZVIZ devices * Handles video streaming and camera functionality */ export class IPCamera { platform; accessory; api; deviceSerial; constructor(api, platform, accessory) { this.platform = platform; this.accessory = accessory; this.api = api; this.deviceSerial = accessory.context.device.DeviceInfo.deviceSerial; // Set accessory information this.accessory.getService(this.platform.Service.AccessoryInformation) .setCharacteristic(this.platform.Characteristic.Manufacturer, 'EZVIZ') .setCharacteristic(this.platform.Characteristic.Model, accessory.context.device.DeviceInfo.deviceSubCategory) .setCharacteristic(this.platform.Characteristic.SerialNumber, this.deviceSerial); // Create streaming delegate const streamingDelegate = new StreamingDelegate(this.platform.api.hap, accessory.context.device, this.platform.log); // Configure camera controller options const options = { cameraStreamCount: 2, // HomeKit requires at least 2 streams, but 1 is also just fine delegate: streamingDelegate, streamingOptions: { supportedCryptoSuites: [0 /* this.platform.api.hap.SRTPCryptoSuites.AES_CM_128_HMAC_SHA1_80 */], video: { resolutions: [ [320, 180, 30], [320, 240, 15], // Apple Watch requires this configuration [320, 240, 30], [480, 270, 30], [480, 360, 30], [640, 360, 30], [640, 480, 30], [1280, 720, 30], [1280, 960, 30], [1920, 1080, 30], [1600, 1200, 30], ], codec: { profiles: [0 /* this.platform.api.hap.H264Profile.BASELINE */, 1 /* this.platform.api.hap.H264Profile.MAIN */, 2 /* this.platform.api.hap.H264Profile.HIGH */], levels: [0 /* this.platform.api.hap.H264Level.LEVEL3_1 */, 1 /* this.platform.api.hap.H264Level.LEVEL3_2 */, 2 /* this.platform.api.hap.H264Level.LEVEL4_0 */], }, }, audio: { twoWayAudio: false, codecs: [ { type: "AAC-eld" /* AudioStreamingCodecType.AAC_ELD */, samplerate: 16 /* AudioStreamingSamplerate.KHZ_16 */, }, ], }, }, }; try { // Create and configure camera controller const cameraController = new this.platform.api.hap.CameraController(options); streamingDelegate.controller = cameraController; accessory.configureController(streamingDelegate.controller); this.platform.log.debug(`Successfully configured camera: ${accessory.context.device.Name}`); } catch (error) { this.platform.log.error(`Error configuring camera ${accessory.context.device.Name}:`, error); throw error; } } /** * Gets the accessory instance * @returns The platform accessory */ getAccessory() { return this.accessory; } } //# sourceMappingURL=ip-camera.js.map