import { t as Camera } from "../Camera-BKZMXwCV.js"; import { t as INTERNAL_ACCESS } from "../privateAccess-DLrOMEAu.js"; import "../DataCaptureContext-CAmigtb7.js"; //#region src/main/private/CameraPool.d.ts /** * Manages a pool of Camera instances to ensure efficient reuse and proper lifecycle management. * * The CameraPool class serves as a central registry for Camera objects, preventing duplicate * camera instances and maintaining consistency between application-created cameras and * device-detected cameras. It handles the complex reconciliation process when new cameras * are detected from the device, ensuring that existing Camera object references remain valid. * * This approach ensures that camera references remain stable across device enumerations * while keeping the pool synchronized with the actual hardware state. * * Because of this central management of Camera instances, references to Camera object will work. For example, * if you switch cameras using the CameraSwitchControl and cycle through all cameras until the initial one, * executing "initialCamera === context.frameSource" will return true (initialCamera being the camera instance that * you passed to "context.setFrameSource()") */ declare class CameraPool { private cameraPool; /** * Track if the cameras of the device have been gathered. This means we have their ids, labels and positions. */ private deviceCamerasDiscovered; /** * Creates a new camera if the pool does not contain a similar-enough instance. */ getOrCreate(newCamera: Camera): Camera; /** * Reconciles the pool with the cameras reported by the device so that, after this call, the pool * holds exactly one Camera instance per device camera (keyed by deviceId) while preserving * existing Camera object references whenever possible. * * The algorithm has four steps: * 1. **Match by deviceId** — every incoming camera with a deviceId tries to find a pool camera * with the same deviceId. Matches update label and position in place. * 2. **Merge best-guesses by position** — any remaining incoming camera tries to merge into a * pool camera that has NO deviceId and shares its position. Pool cameras that already have a * deviceId are never touched by this step. * 3. **Force-merge remaining best-guesses** — any pool camera that still has no deviceId is * force-merged with the next unmatched incoming camera regardless of position. The initial * position is a "wish": we preserve the Camera object reference by snapping it to a real * device camera even if no position match was possible. * 4. **Reconcile leftovers** — incoming cameras with a deviceId that matched nothing are added * as new pool entries. Incoming cameras without a deviceId are dropped with a debug log * (should not happen in practice). Pool cameras that matched nothing (i.e. had a deviceId * absent from the device list) are marked as unmapped and removed, with a warning. * * @param newCameras Camera objects detected from the current device enumeration */ integrateIncomingVideoDevices(newCameras: Camera[]): void; private matchByDeviceId; /** * Second pass: merge leftover incoming cameras into best-guess pool cameras (those without a * deviceId) that share a position. Pool cameras that already have a deviceId are immutable here — * this is the only legitimate use of position-based matching. */ private mergeBestGuesses; /** * Third pass: any pool camera that still has no deviceId is snapped onto the next unmatched * incoming camera regardless of position. The initial position was a best-effort wish — when no * device camera satisfies it, preserving the Camera object reference beats honouring the wish. */ private forceMergeBestGuesses; private pushOrDropLeftovers; private removeOrphans; /** * Re-binds a pool camera to a different deviceId after the CameraManager has ended up opening a * different stream than the one the camera was merged with during integration. * * Used by best-guess resolution: the bestGuess Camera is merged with *some* device camera during * integration (first match by position), but CameraManager may ultimately open a different camera * (the "main" one for iOS, typically). In that case the user's Camera reference must still reflect * what was actually opened, without breaking the pool invariant that each deviceId appears at most * once. * * When another pool camera already holds `target.deviceId`, their identities are swapped: `camera` * adopts the target identity, the existing holder adopts `camera`'s previous identity. Both device * cameras remain represented in the pool; only the Camera object references are reshuffled. */ rebindToDeviceId(camera: Camera, target: Pick): void; get(): Camera[]; clear(): void; private push; private debugLog; private logPool; private dumpAsSimpleObjects; } declare const internal: { [INTERNAL_ACCESS]: { CameraPool: typeof CameraPool; }; }; declare const cameraPool: CameraPool; //#endregion export { cameraPool, internal };