pub fn cap_recording_dims(width: u32, height: u32) -> (u32, u32)Expand description
Cap capture/encode dims to a 1080p box (1920×1080), aspect-preserving
and orientation-agnostic: the longer edge is bounded to
RECORDING_MAX_LONG_EDGE and the shorter to RECORDING_MAX_SHORT_EDGE,
both edges scaled by the same factor (never stretched — the camera
bubble stays circular) and rounded down to even (H.264 chroma
subsampling). Dims already inside the box are returned unchanged (never
upscaled), only evened. Integer arithmetic throughout.
Recording at native Retina resolution is too heavy for the live compose → GPU read-back → encode loop to sustain the configured frame rate; the encoder timestamps frames by count at that rate, so an under-delivering loop makes the recording play fast. Capping to 1080p keeps the pipeline comfortably real-time regardless of monitor, which is the deliberate tradeoff (reliable 1080p over a fast, half-lost 5K).
§Examples
use media::encode::cap_recording_dims;
assert_eq!(cap_recording_dims(5120, 2880), (1920, 1080)); // 5K 16:9 → 1080p
assert_eq!(cap_recording_dims(3840, 2160), (1920, 1080)); // 4K 16:9 → 1080p
assert_eq!(cap_recording_dims(2880, 1800), (1728, 1080)); // 16:10 → fits the box
assert_eq!(cap_recording_dims(1920, 1080), (1920, 1080)); // already 1080p
assert_eq!(cap_recording_dims(1280, 720), (1280, 720)); // smaller → unchanged
assert_eq!(cap_recording_dims(1080, 1920), (1080, 1920)); // portrait → long edge 1920