Commit bd00a4df authored by Simon Morlat's avatar Simon Morlat

improve echo calibration user experience.

parent 057bf043
......@@ -114,8 +114,10 @@ static void ecc_deinit_filters(EcCalibrator *ecc){
static void on_tone_sent(void *data, MSFilter *f, unsigned int event_id, void *arg){
MSDtmfGenEvent *ev=(MSDtmfGenEvent*)arg;
EcCalibrator *ecc=(EcCalibrator*)data;
ecc->acc-=ev->tone_start_time;
ms_message("Sent tone at %u",(unsigned int)ev->tone_start_time);
if (ev->tone_name[0] != '\0'){
ecc->acc-=ev->tone_start_time;
ms_message("Sent tone at %u",(unsigned int)ev->tone_start_time);
}
}
static bool_t is_valid_tone(EcCalibrator *ecc, MSToneDetectorEvent *ev){
......@@ -159,21 +161,21 @@ static void ecc_play_tones(EcCalibrator *ecc){
/* configure the tones to be scanned */
strncpy(expected_tone.tone_name,"freq1",sizeof(expected_tone.tone_name));
expected_tone.frequency=2000;
expected_tone.frequency=2349.32;
expected_tone.min_duration=40;
expected_tone.min_amplitude=0.1f;
ms_filter_call_method (ecc->det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone);
strncpy(expected_tone.tone_name,"freq2",sizeof(expected_tone.tone_name));
expected_tone.frequency=2300;
expected_tone.frequency=2637.02;
expected_tone.min_duration=40;
expected_tone.min_amplitude=0.1f;
ms_filter_call_method (ecc->det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone);
strncpy(expected_tone.tone_name,"freq3",sizeof(expected_tone.tone_name));
expected_tone.frequency=2500;
expected_tone.frequency=2093;
expected_tone.min_duration=40;
expected_tone.min_amplitude=0.1f;
......@@ -191,20 +193,36 @@ static void ecc_play_tones(EcCalibrator *ecc){
ms_filter_add_notify_callback(ecc->gen,on_tone_sent,ecc,TRUE);
/* play the three tones*/
tone.frequencies[0]=2000;
strncpy(tone.tone_name, "D", sizeof(tone.tone_name));
tone.frequencies[0]=2349.32;
tone.duration=100;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
ms_usleep(300000);
tone.frequencies[0]=2300;
strncpy(tone.tone_name, "E", sizeof(tone.tone_name));
tone.frequencies[0]=2637.02;
tone.duration=100;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
ms_usleep(300000);
tone.frequencies[0]=2500;
strncpy(tone.tone_name, "C", sizeof(tone.tone_name));
tone.frequencies[0]=2093;
tone.duration=100;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
ms_usleep(300000);
/*these two next ones are for lyrism*/
tone.tone_name[0]='\0';
tone.frequencies[0]=1046.5;
tone.duration=400;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
ms_usleep(300000);
tone.tone_name[0]='\0';
tone.frequencies[0]=1567.98;
tone.duration=400;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
ms_sleep(1);
if (ecc->freq1 && ecc->freq2 && ecc->freq3) {
......
......@@ -23,14 +23,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#if _MSC_VER
#include <io.h>
#endif
static int done = 0;
static void calibration_finished(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay, void *data) {
ms_message("echo calibration finished %s.", status == LinphoneEcCalibratorDone ? "successfully" : "with faillure");
if (status == LinphoneEcCalibratorDone)
ms_message("Measured delay is %i", delay);
done = 1;
}
static char config_file[1024];
static char config_file[1024] = {0};
void parse_args(int argc, char *argv[]) {
#ifndef F_OK
#define F_OK 4
......@@ -43,20 +45,19 @@ void parse_args(int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
int count = 0;
LinphoneCoreVTable vtable = {0};
LinphoneCore *lc;
if (argc > 1)
parse_args(argc, argv);
lc = linphone_core_new(&vtable, config_file, NULL, NULL);
lc = linphone_core_new(&vtable, config_file[0] ? config_file : NULL, NULL, NULL);
linphone_core_enable_logs(NULL);
linphone_core_start_echo_calibration(lc, calibration_finished, NULL, NULL, NULL);
while (count++ < 1000) {
while (!done) {
linphone_core_iterate(lc);
ms_usleep(10000);
ms_usleep(20000);
}
linphone_core_destroy(lc);
return 0;
......
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