openFrameworks
openFrameworks copied to clipboard
alternating deprecated devicesWithMediaType with AVCaptureDeviceDiscoverySession
This PR closes https://github.com/openframeworks/openFrameworks/issues/6925
Thanks @dimitre going to ask @danoli3 and @2bbb to take a quick look at this one. Just want to make sure we aren't missing anything with the change.
AVCaptureDeviceDiscoverySession
is from 10.15.
Will we remove target before 10.15?
isn't currently deployment target 10.9?
If we support old macos (< 10.15), I recommend to use available macro like:
NSArray<AVCaptureDevice *> *devices;
if (@available(macOS 10.15, *)) {
AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[
AVCaptureDeviceTypeBuiltInWideAngleCamera,
AVCaptureDeviceTypeExternalUnknown,
] mediaType:nil position:AVCaptureDevicePositionUnspecified];
devices = [session devices];
} else {
devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
}
@available
macro is from Xcode9, if we need to support more older Xcode, then we use other macro with Availability.h
maybe...
thank you @2bbb great idea! we can make it to a function like getDevices or something.
Thanks @2bbb Def don't need to support Xcode < 9 - so an Xcode 9 onwards solution would be fine! :)
Good to merge @dimitre ?
Even with @available it still generates the warnings. It can be merged as it is or if you prefer I can investigate a bit more if we have some kind of preprocessor checks of macOs version
Ahh cool!. Well feel free to squash and merge when you are ready.
I am also seeing a bunch of weird print outs when opening the camera on macOS 12.3.1
CMIO_Graph_Helpers_Analytics.mm:36:sendAnalytics Missing key usesFileOutputDelegate
CMIO_Graph_Helpers_Analytics.mm:36:sendAnalytics Missing key usesVideoFieldMode
etc