Commit a5a49f8f authored by Ghislain MARY's avatar Ghislain MARY

Merge branch 'master' of git.linphone.org:linphone into belle-sip

parents 39255e81 18cdaef2
......@@ -29,6 +29,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void ecc_init_filters(EcCalibrator *ecc){
unsigned int rate;
int channels = 1;
int ecc_channels = 1;
MSTickerParams params={0};
params.name="Echo calibrator";
params.prio=MS_TICKER_PRIO_HIGH;
......@@ -37,9 +39,13 @@ static void ecc_init_filters(EcCalibrator *ecc){
ecc->sndread=ms_snd_card_create_reader(ecc->play_card);
ms_filter_call_method(ecc->sndread,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ms_filter_call_method(ecc->sndread,MS_FILTER_GET_SAMPLE_RATE,&rate);
ms_filter_call_method(ecc->sndread,MS_FILTER_SET_NCHANNELS,&ecc_channels);
ms_filter_call_method(ecc->sndread,MS_FILTER_GET_NCHANNELS,&channels);
ecc->read_resampler=ms_filter_new(MS_RESAMPLE_ID);
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_SAMPLE_RATE,&rate);
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&ecc->rate);
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_NCHANNELS,&ecc_channels);
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_OUTPUT_NCHANNELS,&channels);
ecc->det=ms_filter_new(MS_TONE_DETECTOR_ID);
......@@ -50,7 +56,7 @@ static void ecc_init_filters(EcCalibrator *ecc){
ms_filter_link(ecc->read_resampler,0,ecc->det,0);
ms_filter_link(ecc->det,0,ecc->rec,0);
ecc->play=ms_filter_new(MS_FILE_PLAYER_ID);
ecc->play=ms_filter_new(MS_VOID_SOURCE_ID);
ecc->gen=ms_filter_new(MS_DTMF_GEN_ID);
ms_filter_call_method(ecc->gen,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ecc->write_resampler=ms_filter_new(MS_RESAMPLE_ID);
......@@ -58,8 +64,12 @@ static void ecc_init_filters(EcCalibrator *ecc){
ms_filter_call_method(ecc->sndwrite,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ms_filter_call_method(ecc->sndwrite,MS_FILTER_GET_SAMPLE_RATE,&rate);
ms_filter_call_method(ecc->sndwrite,MS_FILTER_SET_NCHANNELS,&ecc_channels);
ms_filter_call_method(ecc->sndwrite,MS_FILTER_GET_NCHANNELS,&channels);
ms_filter_call_method(ecc->write_resampler,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ms_filter_call_method(ecc->write_resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&rate);
ms_filter_call_method(ecc->write_resampler,MS_FILTER_SET_NCHANNELS,&ecc_channels);
ms_filter_call_method(ecc->write_resampler,MS_FILTER_SET_OUTPUT_NCHANNELS,&channels);
ms_filter_link(ecc->play,0,ecc->gen,0);
ms_filter_link(ecc->gen,0,ecc->write_resampler,0);
......@@ -67,10 +77,17 @@ static void ecc_init_filters(EcCalibrator *ecc){
ms_ticker_attach(ecc->ticker,ecc->sndread);
ms_ticker_attach(ecc->ticker,ecc->play);
if (ecc->audio_init_cb != NULL) {
(*ecc->audio_init_cb)(ecc->cb_data);
}
}
static void ecc_deinit_filters(EcCalibrator *ecc){
if (ecc->audio_uninit_cb != NULL) {
(*ecc->audio_uninit_cb)(ecc->cb_data);
}
ms_ticker_detach(ecc->ticker,ecc->sndread);
ms_ticker_detach(ecc->ticker,ecc->play);
......@@ -222,12 +239,15 @@ static void * ecc_thread(void *p){
return NULL;
}
EcCalibrator * ec_calibrator_new(MSSndCard *play_card, MSSndCard *capt_card, unsigned int rate, LinphoneEcCalibrationCallback cb, void *cb_data ){
EcCalibrator * ec_calibrator_new(MSSndCard *play_card, MSSndCard *capt_card, unsigned int rate, LinphoneEcCalibrationCallback cb,
LinphoneEcCalibrationAudioInit audio_init_cb, LinphoneEcCalibrationAudioUninit audio_uninit_cb, void *cb_data){
EcCalibrator *ecc=ms_new0(EcCalibrator,1);
ecc->rate=rate;
ecc->cb=cb;
ecc->cb_data=cb_data;
ecc->audio_init_cb=audio_init_cb;
ecc->audio_uninit_cb=audio_uninit_cb;
ecc->capt_card=capt_card;
ecc->play_card=play_card;
ms_thread_create(&ecc->thread,NULL,ecc_thread,ecc);
......@@ -243,7 +263,8 @@ void ec_calibrator_destroy(EcCalibrator *ecc){
ms_free(ecc);
}
int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibrationCallback cb, void *cb_data){
int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibrationCallback cb,
LinphoneEcCalibrationAudioInit audio_init_cb, LinphoneEcCalibrationAudioUninit audio_uninit_cb, void *cb_data){
unsigned int rate;
if (lc->ecc!=NULL){
......@@ -251,7 +272,7 @@ int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibration
return -1;
}
rate = lp_config_get_int(lc->config,"sound","echo_cancellation_rate",8000);
lc->ecc=ec_calibrator_new(lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard,rate,cb,cb_data);
lc->ecc=ec_calibrator_new(lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard,rate,cb,audio_init_cb,audio_uninit_cb,cb_data);
return 0;
}
......@@ -996,6 +996,8 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNI
,jobject data) {
return (jint)linphone_core_start_echo_calibration((LinphoneCore*)lc
, LinphoneCoreData::ecCalibrationStatus
, NULL
, NULL
, data?env->NewGlobalRef(data):NULL);
}
......
......@@ -64,12 +64,15 @@ typedef enum {
typedef void (*LinphoneEcCalibrationCallback)(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data);
typedef void (*LinphoneEcCalibrationAudioInit)(void *data);
typedef void (*LinphoneEcCalibrationAudioUninit)(void *data);
/**
*
* Start an echo calibration of the sound devices, in order to find adequate settings for the echo canceller automatically.
**/
LINPHONE_PUBLIC int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibrationCallback cb, void *cb_data);
LINPHONE_PUBLIC int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibrationCallback cb,
LinphoneEcCalibrationAudioInit audio_init_cb, LinphoneEcCalibrationAudioUninit audio_uninit_cb, void *cb_data);
/**
* @ingroup IOS
* Special function to warm up dtmf feeback stream. #linphone_core_stop_dtmf_stream must() be called before entering FG mode
......
......@@ -671,6 +671,8 @@ struct _EcCalibrator{
MSTicker *ticker;
LinphoneEcCalibrationCallback cb;
void *cb_data;
LinphoneEcCalibrationAudioInit audio_init_cb;
LinphoneEcCalibrationAudioUninit audio_uninit_cb;
int64_t acc;
int delay;
unsigned int rate;
......
......@@ -52,7 +52,7 @@ int main(int argc, char *argv[]){
linphone_core_enable_logs(NULL);
linphone_core_start_echo_calibration(lc,calibration_finished,NULL);
linphone_core_start_echo_calibration(lc,calibration_finished,NULL,NULL,NULL);
while(count++<1000){
linphone_core_iterate(lc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment