JNIEXPORT jint JNICALL Java_com_jabber_audio_encoder_AudioWebrtcAecm_yy_1webrtc_1aecm_1initiate
  (JNIEnv *env, jobject obj, jint samp_freq){

	__android_log_print(ANDROID_LOG_ERROR ,TAG ,"in audioWebrtcAecm initiate function ");
	int ret ;
	void* AECM_instance;

	if ((ret = WebRtcAecm_Create(&AECM_instance) )) {
		__android_log_print(ANDROID_LOG_ERROR ,TAG ,"WebRtcAecm_Create failed with error code = %d", ret);
		return ret;
	}

	if ((ret = WebRtcAecm_Init(AECM_instance, samp_freq) )) {
		__android_log_print(ANDROID_LOG_ERROR ,TAG ,"WebRtcAecm_Init failed with error code = %d", ret);
		return ret;
	}

#if 0	//config
	AecmConfig aecm_config;
	aecm_config.cngMode = AECM_TRUE;
	aecm_config.echoMode = 3;

	if(( ret = WebRtcAecm_set_config(AECM_instance, aecm_config) )){
		__android_log_print(ANDROID_LOG_ERROR ,TAG ,"WebRtcAecm_set_config failed with error code = %d", ret);
		return ret;
	}
#endif

	return (jint)((int *)AECM_instance );
}
Exemplo n.º 2
0
static void webrtc_aec_preprocess(MSFilter *f)
{
	WebRTCAECState *s = (WebRTCAECState *) f->data;
	AecmConfig config;
	int delay_samples = 0;
	mblk_t *m;
	int error_code;

	s->echostarted = FALSE;
	delay_samples = s->delay_ms * s->samplerate / 1000;
	s->framesize=(framesize*s->samplerate)/8000;
	ms_message("Initializing WebRTC echo canceler with framesize=%i, delay_ms=%i, delay_samples=%i", s->framesize, s->delay_ms, delay_samples);

	if ((s->aecmInst = WebRtcAecm_Create()) == NULL) {
		s->bypass_mode = TRUE;
		ms_error("WebRtcAecm_Create(): error, entering bypass mode");
		return;
	}
	if ((error_code = WebRtcAecm_Init(s->aecmInst, s->samplerate)) < 0) {
		if (error_code == AECM_BAD_PARAMETER_ERROR) {
			ms_error("WebRtcAecm_Init(): WebRTC echo canceller does not support %d samplerate", s->samplerate);
		}
		s->bypass_mode = TRUE;
		ms_error("Entering bypass mode");
		return;
	}
	config.cngMode = TRUE;
	config.echoMode = 3;
	if (WebRtcAecm_set_config(s->aecmInst, config)!=0){
		ms_error("WebRtcAecm_set_config(): failed.");
	}

	/* fill with zeroes for the time of the delay*/
	m = allocb(delay_samples * 2, 0);
	m->b_wptr += delay_samples * 2;
	ms_bufferizer_put(&s->delayed_ref, m);
	s->min_ref_samples = -1;
	s->nominal_ref_samples = delay_samples;
	ms_audio_flow_controller_init(&s->afc);
	s->flow_control_time = f->ticker->time;
}