如何实现音频自采集?

编解码

#1

音频模块需要使用自己的音频模块,将音频模块采集到的pcm数据push到声网sdk中推流出去,目前在调用pushExternalAudioFrameRawData方法时此方法总是返回NO
和音频采集模块相关的设置内容如下:
[_rtcEngine setAudioProfile:AgoraAudioProfileMusicStandardStereo scenario:AgoraAudioScenarioChatRoomEntertainment];
[_rtcEngine enableExternalAudioSourceWithSampleRate:44100 channelsPerFrame:2];
以上方法均在joinChannelByToken方法之前调用。
音频数据的自定义推流
BOOL pushSuc = [_rtcEngine pushExternalAudioFrameRawData:data samples:samples timestamp:timestamp];
请问:有没有什么办法可以获知pushExternalAudioFrameRawData方法为什么总是返回NO吗?
补充:agora log 日志如下:
ERROR (16:41:16:882 | 50) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:16:891 | 9) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:16:901 | 10) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:16:912 | 11) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:16:924 | 12) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:16:931 | 7) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:16:941 | 10) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:16:951 | 10) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:16:961 | 10) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:16:971 | 10) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:17: 11 | 0) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:17: 21 | 10) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:17: 31 | 10) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1
ERROR (16:41:17: 41 | 10) 76567; CaptureRaw ProcessRawAudioData err2, useMode = 2 err = 1


#2

这个报错是引擎切换状态需要一定时间导致的,应该没太大影响。
你可以参考下agora的音频自采集demo:


#3

你好,此demo我已经查看了,请问引擎状态切换大概需要多少ms,有没有判断引擎状态切换已经完成的方法呢?


#4

麻烦提供下 SDK log(注意对 appid 进行加密),以及音频自采集部分的相关代码