mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Improve front camera fov in dual mode
This commit is contained in:
@@ -65,7 +65,7 @@ final class CameraDeviceContext {
|
||||
self.device.configureDeviceFormat(maxDimensions: self.preferredMaxDimensions, maxFramerate: self.preferredMaxFrameRate)
|
||||
self.output.configureVideoStabilization()
|
||||
|
||||
self.device.resetZoom()
|
||||
self.device.resetZoom(neutral: self.exclusive || !self.additional)
|
||||
}
|
||||
|
||||
func invalidate() {
|
||||
@@ -77,7 +77,11 @@ final class CameraDeviceContext {
|
||||
}
|
||||
|
||||
private var preferredMaxDimensions: CMVideoDimensions {
|
||||
return CMVideoDimensions(width: 1920, height: 1080)
|
||||
if self.additional {
|
||||
return CMVideoDimensions(width: 1920, height: 1440)
|
||||
} else {
|
||||
return CMVideoDimensions(width: 1920, height: 1080)
|
||||
}
|
||||
}
|
||||
|
||||
private var preferredMaxFrameRate: Double {
|
||||
|
||||
@@ -44,7 +44,14 @@ final class CameraDevice {
|
||||
selectedDevice = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInDualCamera, .builtInWideAngleCamera, .builtInTelephotoCamera], mediaType: .video, position: position).devices.first
|
||||
}
|
||||
} else {
|
||||
selectedDevice = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInDualCamera, .builtInWideAngleCamera, .builtInTelephotoCamera], mediaType: .video, position: position).devices.first
|
||||
if #available(iOS 11.1, *), dual, case .front = position {
|
||||
if let trueDepthDevice = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInTrueDepthCamera], mediaType: .video, position: position).devices.first {
|
||||
selectedDevice = trueDepthDevice
|
||||
}
|
||||
}
|
||||
if selectedDevice == nil {
|
||||
selectedDevice = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInDualCamera, .builtInWideAngleCamera, .builtInTelephotoCamera], mediaType: .video, position: position).devices.first
|
||||
}
|
||||
}
|
||||
|
||||
self.videoDevice = selectedDevice
|
||||
@@ -245,12 +252,12 @@ final class CameraDevice {
|
||||
}
|
||||
}
|
||||
|
||||
func resetZoom() {
|
||||
func resetZoom(neutral: Bool = true) {
|
||||
guard let device = self.videoDevice else {
|
||||
return
|
||||
}
|
||||
self.transaction(device) { device in
|
||||
device.videoZoomFactor = device.neutralZoomFactor
|
||||
device.videoZoomFactor = neutral ? device.neutralZoomFactor : device.minAvailableVideoZoomFactor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class CameraSimplePreviewView: UIView {
|
||||
public init(frame: CGRect, main: Bool) {
|
||||
super.init(frame: frame)
|
||||
|
||||
self.videoPreviewLayer.videoGravity = .resizeAspectFill
|
||||
self.videoPreviewLayer.videoGravity = main ? .resizeAspectFill : .resizeAspect
|
||||
|
||||
self.placeholderView.contentMode = .scaleAspectFill
|
||||
self.addSubview(self.placeholderView)
|
||||
|
||||
Reference in New Issue
Block a user