我正在使用linphone在IOS上开发VOIP应用程序。
我使用了[LinphoneManager instance startLibLinphone]函数来初始化linphone sdk。
然后我使用下面的代码进行音频录制。
但是我得到了记录失败的错误。
如何使用linphone sdk录制音频?
谢谢。
NSError *error;
// Recording settings
NSDictionary *settings = @{AVEncoderAudioQualityKey: @(AVAudioQualityMedium),
AVFormatIDKey: @(kAudioFormatMPEG4AAC),
AVEncoderBitRateKey: @(128000),
AVNumberOfChannelsKey: @(1),
AVSampleRateKey: @(44100),
AVLinearPCMBitDepthKey:@(8)};
// File URL
NSURL *url = [NSURL fileURLWithPath:pathToSave];//FILEPATH];
// Create recorder
recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];
if (!recorder)
{
NSLog(@"Error establishing recorder: %@", error.localizedFailureReason);
return NO;
}
recorder.delegate = delegate;
recorder.meteringEnabled = YES;
if (![recorder prepareToRecord])
{
NSLog(@"Error: Prepare to record failed");
return NO;
}
if (![recorder record])
{
NSLog(@"Error: Record failed");
return NO;
}发布于 2015-04-24 23:54:05
我解决了这个问题。
我添加了下面的代码。
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *err = nil;
[audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&err];
if(err){
NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
return;
}
[audioSession setActive:YES error:&err];所以它工作得很好。
https://stackoverflow.com/questions/29851110
复制相似问题