Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NativeCamera - Use the main camera on iOS rather than virtual camera #1136

Merged
merged 2 commits into from
Sep 16, 2022
Merged
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
45 changes: 23 additions & 22 deletions Plugins/NativeCamera/Source/Apple/NativeCameraImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -202,29 +202,30 @@ fragment float4 fragmentShader(RasterizerData in [[stage_in]],
uint32_t bestPixelCount{0};
uint32_t devicePixelFormat{0};
uint32_t bestDimDiff{0};
NSArray* deviceTypes{nullptr};
NSArray* deviceTypes{@[
// Use the main camera on the device which is best for general use and will typically be 1x optical zoom and the highest resolution.
// https://developer.apple.com/documentation/avfoundation/avcapturedevice/devicetype/2361449-builtinwideanglecamera
AVCaptureDeviceTypeBuiltInWideAngleCamera
]};
bool foundExactMatch{false};
if (@available(iOS 13.0, *))
{
// Ordered list of cameras by general usage quality.
deviceTypes = @[
AVCaptureDeviceTypeBuiltInTripleCamera,
AVCaptureDeviceTypeBuiltInDualCamera,
AVCaptureDeviceTypeBuiltInDualWideCamera,
AVCaptureDeviceTypeBuiltInWideAngleCamera,
AVCaptureDeviceTypeBuiltInUltraWideCamera,
AVCaptureDeviceTypeBuiltInTelephotoCamera,
AVCaptureDeviceTypeBuiltInTrueDepthCamera
];
}
else
{
// Only these camera types are available for all devices
deviceTypes = @[
AVCaptureDeviceTypeBuiltInDualCamera,
AVCaptureDeviceTypeBuiltInWideAngleCamera
];
}

// The below code would allow us to choose virtual cameras which dynamically switch between the different physical
// camera sensors based on different zoom levels. Until we support letting the consumer modify the camera's zoom
// it would result in often being stuck on the most zoomed out camera on the device which is often not desired.

// if (@available(iOS 13.0, *))
// {
// // Ordered list of cameras by general usage quality.
// deviceTypes = @[
// AVCaptureDeviceTypeBuiltInTripleCamera,
// AVCaptureDeviceTypeBuiltInDualCamera,
// AVCaptureDeviceTypeBuiltInDualWideCamera,
// AVCaptureDeviceTypeBuiltInWideAngleCamera,
// AVCaptureDeviceTypeBuiltInUltraWideCamera,
// AVCaptureDeviceTypeBuiltInTelephotoCamera,
// AVCaptureDeviceTypeBuiltInTrueDepthCamera
// ];
// }

AVCaptureDeviceDiscoverySession* discoverySession{[AVCaptureDeviceDiscoverySession
discoverySessionWithDeviceTypes:deviceTypes
Expand Down