import type { Logger } from '../types'; /** * Diagnostic instrumentation for debugging slow camera loads. * * Collects per-camera timeline data from connect() through first playing frame. * Exposes `window.__webrtcDiag` for console inspection: * * __webrtcDiag.summary() — table of all cameras with phase timings * __webrtcDiag.slow() — only cameras that took > 5s to first frame * __webrtcDiag.detail(cameraKey) — full timeline for one camera * __webrtcDiag.reset() — clear all data * __webrtcDiag.active() — cameras still waiting for first frame * __webrtcDiag.raw — raw data map */ export interface DiagPhase { label: string; startMs: number; endMs?: number; durationMs?: number; meta?: Record; } export interface DiagCameraTimeline { connectionKey: string; cameraName?: string; connectStartMs: number; phases: DiagPhase[]; ticketFetchStartMs?: number; ticketFetchEndMs?: number; wsOpenMs?: number; sdpOfferMs?: number; sdpAnswerMs?: number; iceConnectedMs?: number; firstTrackMs?: number; firstFrameMs?: number; baseRetryAttempts: number; upgradeRetryAttempts: number; mseFallback: boolean; initialStream: string; upgradeStream?: string; deliveryMethod: string; finalState?: string; errors: string[]; disposed: boolean; } declare class DiagTracker { private timelines; /** Start tracking a new camera connection. */ startCamera(connectionKey: string, meta?: Partial): DiagCameraTimeline; /** Get the timeline for a camera (or null). */ get(connectionKey: string): DiagCameraTimeline | null; /** Record a phase start. */ phaseStart(connectionKey: string, label: string, meta?: Record): void; /** Record a phase end (finds the most recent phase with the same label). */ phaseEnd(connectionKey: string, label: string, meta?: Record): void; /** Record a milestone timestamp. Only records the first value (base connection wins). */ milestone(connectionKey: string, key: keyof DiagCameraTimeline, meta?: Record): void; /** Record first frame and log summary via the optional logger. */ recordFirstFrame(connectionKey: string, logger?: Logger): void; /** Compute a phase summary object for a timeline. */ private computePhaseSummary; /** Table summary of all cameras. */ summary(): void; /** Show only cameras that took > threshold ms to first frame. */ slow(thresholdMs?: number): void; /** Full timeline for one camera. */ detail(connectionKey: string): void; /** Cameras still waiting for first frame. */ active(): void; /** Clear all tracking data. */ reset(): void; /** Raw data map for programmatic access. */ get raw(): Map; } export declare const diagTracker: DiagTracker; export {}; //# sourceMappingURL=diag-tracker.d.ts.map