AVCaptureSession with BluetoothHFP device

随声附和 提交于 2019-12-24 11:13:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!