首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用linphone sdk录音失败

使用linphone sdk录音失败
EN

Stack Overflow用户
提问于 2015-04-24 23:10:18
回答 1查看 474关注 0票数 0

我正在使用linphone在IOS上开发VOIP应用程序。

我使用了[LinphoneManager instance startLibLinphone]函数来初始化linphone sdk。

然后我使用下面的代码进行音频录制。

但是我得到了记录失败的错误。

如何使用linphone sdk录制音频?

谢谢。

代码语言:javascript
复制
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;
}
EN

回答 1

Stack Overflow用户

发布于 2015-04-24 23:54:05

我解决了这个问题。

我添加了下面的代码。

代码语言:javascript
复制
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];

所以它工作得很好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29851110

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档