Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Signal/src/ViewControllers/Photos/CameraCaptureSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,15 @@ class CameraCaptureSession: NSObject {
}

private var motionManager: CMMotionManager?

// Allows external callers to update capture orientation on the session queue.
// Useful for iPads deriving orientation from interface, especially before accelerometer data is available.
func setCaptureOrientation(_ orientation: AVCaptureVideoOrientation) {
sessionQueue.async { [weak self] in
self?.captureOrientation = orientation
self?.updateVideoCaptureOrientation()
}
}

func updateVideoPreviewConnection(toOrientation orientation: AVCaptureVideoOrientation) {
guard let videoConnection = previewView.previewLayer.connection else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ class PhotoCaptureViewController: OWSViewController, OWSNavigationChildControlle
previewOrientation = .portrait
}
UIViewController.attemptRotationToDeviceOrientation()

// Updates preview layer and capture orientation for correct media encoding.
// Crucial on iPad where interface orientation may differ from default portrait.
cameraCaptureSession.updateVideoPreviewConnection(toOrientation: previewOrientation)
cameraCaptureSession.setCaptureOrientation(previewOrientation)
updateIconOrientations(isAnimated: false, captureOrientation: previewOrientation)

NotificationCenter.default.addObserver(
Expand Down