webrtc Android AECM 模块的使用

平台: Rk3399Pro_Android8.1_SDK
主要这个几个函数,

static void set_config(void *AEC_inst, unsigned options)
int webrtc_aec_destroy(void *state )
void webrtc_aec_reset(void *state )
int webrtc_aec_cancel_echo( void *state,
					    int16_t *rec_frm,
					    const int16_t *play_frm,
					    unsigned options,
					    void *reserved )
int webrtc_aec_create(unsigned clock_rate,
                                      unsigned channel_count,
                                      unsigned samples_per_frame,
                                      unsigned tail_ms,
                                      unsigned options,
                                      webrtc_ec *echo)

见源码

int webrtc_aec_test(void)
{
	webrtc_ec *echo_state;
	int ret = 0;
	short far_frame[NN_LEN];
	short near_frame[NN_LEN];
	short out_frame[NN_LEN];
	const sample * buf_ptr;

	
	echo_state = (struct webrtc_ec *)calloc(1, sizeof(struct webrtc_ec));
	if(!echo_state){
		ALOGD("webrtc_aec_create ENOMEM");
		return -ENOMEM;
	}
	
	FILE *fp_far  = fopen("/sdcard/speaker.pcm", "rb");
	FILE *fp_near = fopen("/sdcard/micin.pcm", "rb");
	FILE *fp_out  = fopen("/sdcard/out.pcm", "wb");
	if(!fp_far || !fp_near || !fp_out)
	{
		ALOGE("webrtc_aec test open file err \n");
		return -1;
	}
	ret = webrtc_aec_create(8000, 1, NN_LEN ,60, 0, echo_state);
	if(ret){
		return -1;
	}
	ALOGD("starting echo 3");
	while(1){
		if (NN_LEN == fread(far_frame, sizeof(short), NN_LEN, fp_far)){
			fread(near_frame, sizeof(short), NN_LEN, fp_near);
			webrtc_aec_cancel_echo(echo_state, near_frame , far_frame,0, NULL);
			fwrite(near_frame, sizeof(short), NN_LEN, fp_out);
		}else{
			break;
		}
	}
	webrtc_aec_destroy(echo_state);
	return 0;
}

int main(void){
	webrtc_aec_test();

	return 0;
}

adb root
adb remount
adb push webrtc_test /system/bin/
adb shell chmod 777 /system/bin/webrtc_test
./webrtc_test 运行测试

源码下载,https://download.csdn.net/download/piaozhiye/11235847
参考
参考
参考

你可能感兴趣的:(WEBRTC,android系统开发,android应用开发)