mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-01 10:49:26 +00:00
Custom sample rate for echo calibration.
New "echo_cancellation_rate" config file key.
This commit is contained in:
parent
27ab8107ef
commit
58dca09f9b
4 changed files with 26 additions and 6 deletions
|
|
@ -23,15 +23,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "mediastreamer2/mstonedetector.h"
|
||||
#include "mediastreamer2/dtmfgen.h"
|
||||
|
||||
|
||||
#include "lpconfig.h"
|
||||
|
||||
|
||||
|
||||
static void ecc_init_filters(EcCalibrator *ecc){
|
||||
unsigned int rate;
|
||||
ecc->ticker=ms_ticker_new();
|
||||
|
||||
ecc->sndread=ms_snd_card_create_reader(ecc->play_card);
|
||||
ms_filter_call_method(ecc->sndread,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
|
||||
ecc->det=ms_filter_new(MS_TONE_DETECTOR_ID);
|
||||
ms_filter_call_method(ecc->det,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
|
||||
ecc->rec=ms_filter_new(MS_FILE_REC_ID);
|
||||
|
||||
ms_filter_link(ecc->sndread,0,ecc->det,0);
|
||||
|
|
@ -39,14 +42,17 @@ static void ecc_init_filters(EcCalibrator *ecc){
|
|||
|
||||
ecc->play=ms_filter_new(MS_FILE_PLAYER_ID);
|
||||
ecc->gen=ms_filter_new(MS_DTMF_GEN_ID);
|
||||
ms_filter_call_method(ecc->gen,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
|
||||
ecc->resampler=ms_filter_new(MS_RESAMPLE_ID);
|
||||
ecc->sndwrite=ms_snd_card_create_writer(ecc->capt_card);
|
||||
|
||||
ms_filter_link(ecc->play,0,ecc->gen,0);
|
||||
ms_filter_link(ecc->gen,0,ecc->resampler,0);
|
||||
ms_filter_link(ecc->resampler,0,ecc->sndwrite,0);
|
||||
unsigned int rate;
|
||||
|
||||
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->resampler,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
|
||||
ms_filter_call_method(ecc->resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&rate);
|
||||
|
||||
ms_ticker_attach(ecc->ticker,ecc->play);
|
||||
|
|
@ -149,9 +155,10 @@ static void * ecc_thread(void *p){
|
|||
return NULL;
|
||||
}
|
||||
|
||||
EcCalibrator * ec_calibrator_new(MSSndCard *play_card, MSSndCard *capt_card, LinphoneEcCalibrationCallback cb, void *cb_data ){
|
||||
EcCalibrator * ec_calibrator_new(MSSndCard *play_card, MSSndCard *capt_card, unsigned int rate, LinphoneEcCalibrationCallback cb, void *cb_data ){
|
||||
EcCalibrator *ecc=ms_new0(EcCalibrator,1);
|
||||
|
||||
ecc->rate=rate;
|
||||
ecc->cb=cb;
|
||||
ecc->cb_data=cb_data;
|
||||
ecc->capt_card=capt_card;
|
||||
|
|
@ -174,6 +181,7 @@ int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibration
|
|||
ms_error("Echo calibration is still on going !");
|
||||
return -1;
|
||||
}
|
||||
lc->ecc=ec_calibrator_new(lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard,cb,cb_data);
|
||||
unsigned int 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);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -472,6 +472,7 @@ struct _EcCalibrator{
|
|||
int sent_count;
|
||||
int64_t acc;
|
||||
int delay;
|
||||
unsigned int rate;
|
||||
LinphoneEcCalibratorStatus status;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,21 @@ static void calibration_finished(LinphoneCore *lc, LinphoneEcCalibratorStatus st
|
|||
if (status==LinphoneEcCalibratorDone) ms_message("Measured delay is %i",delay);
|
||||
}
|
||||
|
||||
|
||||
static char config_file[1024];
|
||||
void parse_args(int argc, char *argv[]){
|
||||
if (argc != 3 || strncmp("-c",argv[1], 2) || access(argv[2],F_OK)!=0) {
|
||||
printf("Usage: test_ecc [-c config_file] where config_file will be written with the detected value\n");
|
||||
exit(-1);
|
||||
}
|
||||
strncpy(config_file,argv[2],1024);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
if (argc>1) parse_args(argc,argv);
|
||||
int count=0;
|
||||
LinphoneCoreVTable vtable={0};
|
||||
LinphoneCore *lc=linphone_core_new(&vtable,NULL,NULL,NULL);
|
||||
LinphoneCore *lc=linphone_core_new(&vtable,config_file,NULL,NULL);
|
||||
|
||||
linphone_core_enable_logs(NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 0781bd574fc09a43bcadcb55d8f1563d6493629c
|
||||
Subproject commit 45a3e458669ae7d3f5537665d7549d82469cf96f
|
||||
Loading…
Add table
Reference in a new issue