title: iOS - How to record a video using a bluetooth headset as audio input?
body: <p>I'm trying to record a video using <a href="https://github.com/thisandagain/cam" rel="nofollow">DIYCam</a> and setting the audio route for a bluetooth headset as audio input, but seems like the routing isn't working. As I understand, I just need to route the audio input to my bluetooth headset, and I don't need to change anything about DIYCam, am I right? Here is my code:</p>
  
  <p>When the view is loading I create the DIYCam instance:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view from its nib.
  
      [self.navigationController setNavigationBarHidden:YES];
  
      self.camera = [[DIYCam alloc] initWithFrame:self.view.bounds];
      self.camera.delegate = self;
      [self.camera setupWithOptions:nil]; // Check DIYAV.h for options
      [self.camera setCamMode:DIYAVModeVideo];
      [self.view addSubview:self.camera];
      [self.view sendSubviewToBack:self.camera];
  
      if( self.bluetoothInput ) {
          [self setBluetoothAudioInput];
      }
  }
  </code></pre>
  
  <p>This is my bluetooth routing function:</p>
  
  <pre><code>- (void)setBluetoothAudioInput
  {
      // create and set up the audio session
      AVAudioSession* audioSession = [AVAudioSession sharedInstance];
      [audioSession setDelegate:self];
      [audioSession setCategory:AVAudioSessionCategoryRecord error:nil];
      [audioSession setActive:YES error:nil];
  
      // set up for bluetooth microphone input
      UInt32 allowBluetoothInput = 1;
      OSStatus stat = AudioSessionSetProperty (
                                               kAudioSessionProperty_OverrideCategoryEnableBluetoothInput,
                                               sizeof (allowBluetoothInput),
                                               &amp;allowBluetoothInput
                                               );
  }
  </code></pre>
  
  <p>And these are the IBActions for starting and stoping:</p>
  
  <pre><code>- (IBAction)startRecording:(id)sender
  {
      [self.camera startSession];
      [self.camera captureVideoStart];
  }
  
  - (IBAction)stopRecording:(id)sender
  {
      [self.camera captureVideoStop];
      [self.camera stopSession];
  }
  </code></pre>