homebridge-eufy-security-mikebcbc
Version:
Control Eufy Security from homebridge.
90 lines • 4.44 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import { CameraController, CameraStreamingDelegate, PrepareStreamCallback, PrepareStreamRequest, SnapshotRequest, SnapshotRequestCallback, SRTPCryptoSuites, StreamingRequest, StreamRequestCallback } from 'homebridge';
import { CameraConfig } from '../utils/configTypes';
import { FFmpeg } from '../utils/ffmpeg';
import { Camera } from 'eufy-security-client';
import { EufySecurityPlatform } from '../platform';
import { TalkbackStream } from '../utils/Talkback';
import { CameraAccessory } from '../accessories/CameraAccessory';
import { LocalLivestreamManager } from './LocalLivestreamManager';
export type SessionInfo = {
address: string;
ipv6: boolean;
videoPort: number;
videoReturnPort: number;
videoCryptoSuite: SRTPCryptoSuites;
videoSRTP: Buffer;
videoSSRC: number;
audioPort: number;
audioReturnPort: number;
audioCryptoSuite: SRTPCryptoSuites;
audioSRTP: Buffer;
audioSSRC: number;
};
type ActiveSession = {
videoProcess?: FFmpeg;
audioProcess?: FFmpeg;
returnProcess?: FFmpeg;
talkbackStream?: TalkbackStream;
};
export declare class StreamingDelegate implements CameraStreamingDelegate {
readonly camera: CameraAccessory;
readonly platform: EufySecurityPlatform;
readonly device: Camera;
readonly cameraConfig: CameraConfig;
private readonly hap;
private readonly api;
private readonly log;
readonly cameraName: string;
private readonly videoConfig;
private controller?;
readonly localLivestreamManager: LocalLivestreamManager;
private snapshotManager;
pendingSessions: Map<string, SessionInfo>;
ongoingSessions: Map<string, ActiveSession>;
timeouts: Map<string, NodeJS.Timeout>;
constructor(camera: CameraAccessory);
setController(controller: CameraController): void;
getLivestreamManager(): LocalLivestreamManager;
handleSnapshotRequest(request: SnapshotRequest, callback: SnapshotRequestCallback): Promise<void>;
prepareStream(request: PrepareStreamRequest, callback: PrepareStreamCallback): Promise<void>;
private startStream;
/**
* Handles various types of streaming requests.
*
* This method delegates different types of streaming requests (like starting, reconfiguring, or stopping a stream)
* to their respective handlers. It enhances code organization by segregating different request handling logics into
* separate methods. This makes the code easier to read and maintain.
*
* @param {StreamingRequest} request - The streaming request to be handled.
* @param {StreamRequestCallback} callback - The callback to be invoked after handling the request.
*/
handleStreamRequest(request: StreamingRequest, callback: StreamRequestCallback): void;
/**
* Safely stops a specific resource associated with the streaming session.
*
* This method attempts to stop or clean up a given resource (like a stream or a socket) and handles any errors that
* may occur in the process. It's a general-purpose utility method to ensure that all resources are closed properly
* without causing unhandled exceptions. This improves the robustness of the resource management in streaming sessions.
*
* @param {string} resourceName - A descriptive name of the resource for logging purposes.
* @param {() => void} stopAction - A function encapsulating the logic to stop or clean up the resource.
*/
private safelyStopResource;
/**
* Stops an ongoing streaming session.
*
* This method is responsible for stopping all processes and resources associated with a given streaming session.
* It first checks for any pending sessions with the provided session ID and removes them if found.
* Then, it proceeds to stop all active processes (video, audio, return processes) and resources (talkback stream, socket)
* associated with the ongoing session. Each resource is stopped safely using the `safelyStopResource` method, which handles
* any errors that may occur during the stopping process. If no session is found with the given ID, it logs that no session
* needs to be stopped.
*
* @param {string} sessionId - The unique identifier of the streaming session to be stopped.
*/
stopStream(sessionId: string): void;
}
export {};
//# sourceMappingURL=streamingDelegate.d.ts.map