问题
I need to stream the voice data to server, so I can't use AVAudioRecorder. Here is my approach.
set it Allow Bluetooth and activate it
NSError* e;
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryRecord
withOptions:AVAudioSessionCategoryOptionAllowBluetooth
error:nil];
[audioSession setActive:YES withOptions:0 error:&e];
I did setup the notification for AVAudioSessionRouteChangeNotification so I see the input source changed to BluetoothHFP
but seems there is no way to configure a BluetoothHFP input to AVCaptureDeviceInput.
self.captureSession = [[AVCaptureSession alloc] init];
self.captureSession.sessionPreset = AVCaptureSessionPresetLow;
AVCaptureDevice* captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
AVCaptureDeviceInput* audioInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];
if(audioInput && [self.captureSession canAddInput:audioInput]){
[self.captureSession addInput:audioInput];
}
after doing so, the input source changed to iPhone MicroPhone.
is there anyway I can get the BluetoothHFP input as AVCaptureDeviceInput??
来源:https://stackoverflow.com/questions/52324703/avcapturesession-with-bluetoothhfp-device