Callback when phone call ends? (to resume AVCaptureSession)
<p>I have a video camera app and I would like it to allow users to capture content while on the phone. </p>

<p>I can do this by disconnecting the audio capture when the phone call is received and the session is interrupted, but because the session is no longer interrupted, I now have no way of knowing when the phone call ends and it is ok to reconnect the audio device.</p>

<p>If I use this callbacks for <code>AVCaptureSessionWasInterruptedNotification</code> and <code>AVCaptureSessionInterruptionEndedNotification</code>:</p>

<pre><code>- (void)sessionWasInterrupted:(NSNotification *)notification {
    NSLog(@"session was interrupted");

    // disconnect the audio device when a call is started

    AVCaptureDevice *device = [[self audioInput] device];
    if ([device hasMediaType:AVMediaTypeAudio]) {
      [[self session] removeInput:[self audioInput]];
      [self setAudioInput:nil];
    }
}

- (void)sessionInterruptionEnded:(NSNotification *)notification {
    NSLog(@"session interuption ended");

    // reconnect the audio device when the call ends
    // PROBLEM: disconnecting the audio device triggers this callback before the phone call ends...

    AVCaptureDevice *device = [[self audioInput] device];
    if ([device hasMediaType:AVMediaTypeAudio]) {
        if ([[self session] canAddInput:[self audioInput]])
            [[self session] addInput:[self audioInput]];
    }
}
</code></pre>

<p>I get an infinite loop of both of them being called one after another for the entire duration of the phone call and the camera is frozen. If I don't reconnect the device in the second function, the camera keeps working, but <code>sessionInterruptionEnded</code> is not called again when the phone call ends.</p>

<p>Is there a callback for when the phone call ends?</p>