macOS preview was stretching (aspect wrong) and macOS photo capture
was rotating the landscape sensor 90° because the shared
PhotoOutput / CameraInstance code was setting
`AVCaptureConnection.videoOrientation` from the orientation snapshot
unconditionally. iOS needs that to rotate sample buffers to portrait;
macOS desktop cams are physically landscape and any rotation just
skews the result.
Moved the rotation call behind a per-platform extension on
`AVCaptureConnection`:
- `ios/Classes/Camera/AVCaptureConnection+iOS.swift` applies the
snapshot orientation (current behavior).
- `macos/Classes/Camera/AVCaptureConnection+macOS.swift` is a
no-op. macOS-flavoured photos / preview frames now flow at
native landscape orientation.
`CaptureDevice` reports sensorOrientation=0 on macOS (was hardcoded
90 for iOS); on macOS the page's `normalizeCameraCapture` math then
collapses to identity and the saved JPEG stays the landscape the
sensor produced. iOS keeps sensorOrientation=90 (matches
camera_avfoundation's reported value and the existing capture-
transform math).
Photo and video paths now both produce upright content on macOS
(video already worked because VideoRecorder's transform table maps
the always-portraitUp macOS snapshot to `.identity`).
18 lines
733 B
Swift
18 lines
733 B
Swift
import AVFoundation
|
|
|
|
/// macOS counterpart of `AVCaptureConnection+iOS.swift`.
|
|
///
|
|
/// macOS desktop cameras are physically fixed landscape — applying any
|
|
/// `AVCaptureVideoOrientation` would skew the captured photo (and on
|
|
/// some macOS versions the preview's data-output buffers) by 90°.
|
|
/// The orientation snapshot from Flutter (always `portraitUp` on
|
|
/// macOS — desktops don't rotate) is therefore ignored at the
|
|
/// connection layer; the recorded video's track transform is still
|
|
/// `.identity` from VideoRecorder's existing mapping, so video stays
|
|
/// landscape too.
|
|
extension AVCaptureConnection {
|
|
func applyUxCaptureOrientation(_ orientation: DeviceOrientationFlutter) {
|
|
// Intentionally empty.
|
|
}
|
|
}
|