From ad99d290de64a7bc9068687f5e0c6707e1e02233 Mon Sep 17 00:00:00 2001 From: Brandon McFarlin <6525520+Brandawg93@users.noreply.github.com> Date: Wed, 3 Mar 2021 13:18:59 -0500 Subject: [PATCH] fix stream callback --- src/accessory.ts | 6 +++--- src/ffmpeg.ts | 4 ++-- src/streaming-delegate.ts | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/accessory.ts b/src/accessory.ts index 5611ca3e..19835ca2 100644 --- a/src/accessory.ts +++ b/src/accessory.ts @@ -109,19 +109,19 @@ export class NestAccessory { name: string, serviceType: ServiceType, _key: keyof Properties, - cb: (value: CharacteristicValue) => void, + cb: (value: CharacteristicValue) => Promise, ): void { const service = this.createService(serviceType, name); this.log.debug(`Creating switch for ${this.accessory.displayName} ${name}.`); service .setCharacteristic(this.hap.Characteristic.On, this.camera.info.properties[_key]) .getCharacteristic(this.hap.Characteristic.On) - .on(CharacteristicEventTypes.SET, async (value: CharacteristicValue, callback: CharacteristicSetCallback) => { + .on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => { cb(value); this.log.info(`Setting ${this.accessory.displayName} ${name} to ${value ? 'on' : 'off'}`); callback(); }) - .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => { + .on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => { callback(undefined, this.camera.info.properties[_key]); }); } diff --git a/src/ffmpeg.ts b/src/ffmpeg.ts index 5079bdaf..d0dc82c6 100644 --- a/src/ffmpeg.ts +++ b/src/ffmpeg.ts @@ -1,5 +1,5 @@ import execa from 'execa'; -import { Logging, StreamRequestCallback } from 'homebridge'; +import { Logging } from 'homebridge'; import { StreamingDelegate } from './streaming-delegate'; import { Readable, Writable } from 'stream'; import pathToFfmpeg from 'ffmpeg-for-homebridge'; @@ -47,11 +47,11 @@ export class FfmpegProcess { title: string, command: Array, log: Logging, - callback: StreamRequestCallback | undefined, delegate: StreamingDelegate, sessionId: string, ffmpegDebugOutput: boolean, customFfmpeg?: string, + callback?: (error?: Error | undefined) => void, ) { let started = false; const controller = delegate.controller; diff --git a/src/streaming-delegate.ts b/src/streaming-delegate.ts index 079461a8..3853ccf9 100644 --- a/src/streaming-delegate.ts +++ b/src/streaming-delegate.ts @@ -367,11 +367,13 @@ export class StreamingDelegate implements CameraStreamingDelegate { 'VIDEO', videoffmpegCommand, this.log, - callback, this, sessionId, false, this.customFfmpeg, + (error) => { + callback(error); + }, ); let ffmpegAudio: FfmpegProcess | undefined; @@ -384,7 +386,6 @@ export class StreamingDelegate implements CameraStreamingDelegate { 'AUDIO', audioffmpegCommand, this.log, - undefined, this, sessionId, false, @@ -399,7 +400,6 @@ export class StreamingDelegate implements CameraStreamingDelegate { 'RETURN AUDIO', returnAudioffmpegCommand, this.log, - undefined, this, sessionId, false,