Skip to main content

classify_camera_line

Function classify_camera_line 

Source
pub(crate) fn classify_camera_line(line: &str) -> Option<bool>
Expand description

Classify one line of macOS log stream output: Some(true) when the camera turned on, Some(false) when it turned off, None for an unrelated line. Start wins if a single line somehow carries both markers, matching the original if/else if ordering. Kept un-gated so the start/stop contract is unit-tested on every OS — only the macOS log-stream reader calls it in non-test builds.

Two signals are recognised:

  • Legacy (pre-macOS 26) AppleCameraAssistant posts kCameraStreamStart/kCameraStreamStop events.
  • macOS 26+ stopped posting those on Apple Silicon (#113). Control Center instead publishes the full set of in-use cameras as Frame publisher cameras changed to [...]. The payload is keyed by client, e.g. [us.zoom.xos: ["0x…"]]; “every camera released” is an empty collection — [] on earlier macOS, [:] (an empty dictionary) on macOS 26 (#158). A non-empty payload means at least one camera is live. This aggregate is more robust than the old per-stream events.