openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

alternating deprecated devicesWithMediaType with AVCaptureDeviceDiscoverySession

Open dimitre opened this issue 2 years ago • 4 comments

This PR closes https://github.com/openframeworks/openFrameworks/issues/6925

dimitre avatar Apr 12 '22 13:04 dimitre

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.

ofTheo avatar Apr 12 '22 22:04 ofTheo

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...

2bbb avatar Apr 12 '22 22:04 2bbb

thank you @2bbb great idea! we can make it to a function like getDevices or something.

dimitre avatar Apr 12 '22 23:04 dimitre

Thanks @2bbb Def don't need to support Xcode < 9 - so an Xcode 9 onwards solution would be fine! :)

ofTheo avatar May 17 '22 15:05 ofTheo

Good to merge @dimitre ?

ofTheo avatar Sep 28 '22 16:09 ofTheo

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

dimitre avatar Sep 28 '22 16:09 dimitre

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

ofTheo avatar Sep 28 '22 16:09 ofTheo