功能描述
QttAudio支持对SDK采集到的音视频数据进行前处理和后处理,获取想要的播放效果。
可以通过向引擎注册原始音频采集数据监听器,实现采集、修改原始音频数据功能,但不能改变数据大小。
接口描述
public interface DataObserver {
boolean onData(ByteBuffer byteBuffer, int len); }
public class ChannelEngine {
public int setRecordDataObserver(DataObserver observer, int samplerate, int channels, int bufSize);
public int setPlaybackDataObserver(DataObserver observer, int samplerate, int channels, int bufSize); }
|
示例代码
DataObserver recordObserver = new DataObserver() { @Override public boolean onData(ByteBuffer byteBuffer, int len) { byteBuffer.rewind(); byte[] data = new byte[len]; byteBuffer.get(data, 0, len); return true; } }; engine.setRecordDataObserver(recordObserver, 16000, 1, 0);
DataObserver playObserver = new DataObserver() { @Override public boolean onData(ByteBuffer byteBuffer, int len) { byteBuffer.rewind(); byte[] data = new byte[len]; byteBuffer.get(data, 0, len); return true; } }; engine.setPlaybackDataObserver(playObserver, 16000, 1, 0);
|