camera: pin macOS photo connection to .portrait (counter-intuitive)
`.landscapeRight` / `videoRotationAngle = 0` both still produced a JPEG rotated 90° CW on macOS. User verified that `.portrait` / `videoRotationAngle = 90` is the value that DOES NOT rotate the captured frame on the photo output's connection — counter to the iOS convention where `.portrait` rotates the landscape sensor frame into portrait pixels. I'd expect this to be macOS-specific photo-pipeline plumbing; the data output's connection still doesn't honor the setter (isSupported returns false or the setter no-ops), so preview + video stay unaffected. Verified empirically; not chasing the AVFoundation source for the why.
This commit is contained in:
@@ -16,14 +16,23 @@ import AVFoundation
|
||||
/// available, fall back to the deprecated one for older macOS.
|
||||
extension AVCaptureConnection {
|
||||
func applyUxCaptureOrientation(_ orientation: DeviceOrientationFlutter) {
|
||||
// macOS `AVCapturePhotoOutput`'s photo connection captures in
|
||||
// landscape natively when its rotation hint is `.portrait`
|
||||
// (90°). Counter-intuitive vs iOS where `.portrait` rotates
|
||||
// the landscape sensor to portrait, but verified empirically
|
||||
// — setting `.landscapeRight` / `videoRotationAngle = 0` left
|
||||
// the JPEG rotated 90° CW. The data output's connection on
|
||||
// macOS doesn't honor `videoOrientation` / `videoRotationAngle`
|
||||
// (or returns supported = false), so this setter is a no-op
|
||||
// there and preview + video stay correct.
|
||||
if #available(macOS 14.0, *) {
|
||||
if isVideoRotationAngleSupported(0) {
|
||||
videoRotationAngle = 0
|
||||
if isVideoRotationAngleSupported(90) {
|
||||
videoRotationAngle = 90
|
||||
return
|
||||
}
|
||||
}
|
||||
if isVideoOrientationSupported {
|
||||
videoOrientation = .landscapeRight
|
||||
videoOrientation = .portrait
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user