I want to be able to detect if microphone is available for recording a video, and if the user is on a phone call microphone isn't available. What is the best way to detect microphone availability taking into account phone calls. This is the code I have for adding microphone and it doesn't detect that a microphone is unavailable during phone call
self.session = [[AVCaptureSession alloc] init];
audioDevice = [[AVCaptureDevice devicesWithMediaType:AVMediaTypeAudio] firstObject];
audioDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:&error];
if ([self.session canAddInput:audioDeviceInput])
{
[self.session addInput:audioDeviceInput];
}