Setting activeFormat on camera before acquisition in macOS

I am building an application, where I use AVFoundation library to access the camera (FaceTime HD Camera) on a MacBook. My aim is to access different formats supported by the camera from AVFoundation library and allow users to set the format, before acquiring an image.


Documentation:

https://developer.apple.com/documentation/avfoundation/avcapturedevice/1389221-activeformat


Sample code:


NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType : AVMediaTypeVideo];

_session = [[AVCaptureSession alloc] init];

// for each _device, find out information about its formats
for (AVCaptureDevice* device in videoDevices)
{
    NSArray* formats = [device formats];
   // Enumerate through each format
    for (AVCaptureDeviceFormat* format in formats){

        [device lockForConfiguration:nil];
        device.activeFormat = format; 
           
        // add session input
        // add session output
        // start capture session, [_session startRunning];

        // wait for the image to capture to a buffer (CVImageBufferRef imageBuffer) and get the latest image buffer

        // remove input, output
        // stop capture session, [_session stopRunning];
        
        [device unlockForConfiguration];

        CVPixelBufferRef pixelBuf = imageBuffer;

        OSType formatType = CVPixelBufferGetPixelFormatType(pixelBuf);
        // The 'formatType' here does not reflect a value that is expected (based on the active format that is set in the code above).

    }
}


By setting the device activeformat to a format from the array, I can see from debugging that the device honors my format setting. However, I noticed that the session preset takes precedence over the active format during acquisition. So the acquired image is always of the same format irrespective of what the active format is set to (as the session presets work on default format settings).


Is it possible to set activeformat and acquire images with that format in macOS?


I see that there is a way to do the same in iOS by setting the session preset to sessionpresetinputpriority. Since input priority is not supported for macOS, how can a user make sure that activeformat takes priority over session preset when using macOS. If this is done by default in mac, is there something wrong in my workflow above?


Doc Links:

https://developer.apple.com/documentation/avfoundation/avcapturedevice/1389221-activeformat?language=objc

https://developer.apple.com/documentation/avfoundation/avcapturesessionpresetinputpriority?language=objc


Appreciate any help!

Thanks