mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-20 09:48:28 +00:00
improve echo calibration user experience.
This commit is contained in:
parent
057bf0430a
commit
bd00a4df59
2 changed files with 33 additions and 14 deletions
|
|
@ -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){
|
static void on_tone_sent(void *data, MSFilter *f, unsigned int event_id, void *arg){
|
||||||
MSDtmfGenEvent *ev=(MSDtmfGenEvent*)arg;
|
MSDtmfGenEvent *ev=(MSDtmfGenEvent*)arg;
|
||||||
EcCalibrator *ecc=(EcCalibrator*)data;
|
EcCalibrator *ecc=(EcCalibrator*)data;
|
||||||
|
if (ev->tone_name[0] != '\0'){
|
||||||
ecc->acc-=ev->tone_start_time;
|
ecc->acc-=ev->tone_start_time;
|
||||||
ms_message("Sent tone at %u",(unsigned int)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){
|
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 */
|
/* configure the tones to be scanned */
|
||||||
|
|
||||||
strncpy(expected_tone.tone_name,"freq1",sizeof(expected_tone.tone_name));
|
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_duration=40;
|
||||||
expected_tone.min_amplitude=0.1f;
|
expected_tone.min_amplitude=0.1f;
|
||||||
|
|
||||||
ms_filter_call_method (ecc->det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone);
|
ms_filter_call_method (ecc->det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone);
|
||||||
|
|
||||||
strncpy(expected_tone.tone_name,"freq2",sizeof(expected_tone.tone_name));
|
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_duration=40;
|
||||||
expected_tone.min_amplitude=0.1f;
|
expected_tone.min_amplitude=0.1f;
|
||||||
|
|
||||||
ms_filter_call_method (ecc->det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone);
|
ms_filter_call_method (ecc->det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone);
|
||||||
|
|
||||||
strncpy(expected_tone.tone_name,"freq3",sizeof(expected_tone.tone_name));
|
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_duration=40;
|
||||||
expected_tone.min_amplitude=0.1f;
|
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);
|
ms_filter_add_notify_callback(ecc->gen,on_tone_sent,ecc,TRUE);
|
||||||
|
|
||||||
/* play the three tones*/
|
/* play the three tones*/
|
||||||
|
strncpy(tone.tone_name, "D", sizeof(tone.tone_name));
|
||||||
tone.frequencies[0]=2000;
|
tone.frequencies[0]=2349.32;
|
||||||
tone.duration=100;
|
tone.duration=100;
|
||||||
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
|
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
|
||||||
ms_usleep(300000);
|
ms_usleep(300000);
|
||||||
|
|
||||||
tone.frequencies[0]=2300;
|
strncpy(tone.tone_name, "E", sizeof(tone.tone_name));
|
||||||
|
tone.frequencies[0]=2637.02;
|
||||||
tone.duration=100;
|
tone.duration=100;
|
||||||
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
|
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
|
||||||
ms_usleep(300000);
|
ms_usleep(300000);
|
||||||
|
|
||||||
tone.frequencies[0]=2500;
|
strncpy(tone.tone_name, "C", sizeof(tone.tone_name));
|
||||||
|
tone.frequencies[0]=2093;
|
||||||
tone.duration=100;
|
tone.duration=100;
|
||||||
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
|
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);
|
ms_sleep(1);
|
||||||
|
|
||||||
if (ecc->freq1 && ecc->freq2 && ecc->freq3) {
|
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
|
#if _MSC_VER
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
static int done = 0;
|
||||||
|
|
||||||
static void calibration_finished(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay, void *data) {
|
static void calibration_finished(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay, void *data) {
|
||||||
ms_message("echo calibration finished %s.", status == LinphoneEcCalibratorDone ? "successfully" : "with faillure");
|
ms_message("echo calibration finished %s.", status == LinphoneEcCalibratorDone ? "successfully" : "with faillure");
|
||||||
if (status == LinphoneEcCalibratorDone)
|
if (status == LinphoneEcCalibratorDone)
|
||||||
ms_message("Measured delay is %i", delay);
|
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[]) {
|
void parse_args(int argc, char *argv[]) {
|
||||||
#ifndef F_OK
|
#ifndef F_OK
|
||||||
#define F_OK 4
|
#define F_OK 4
|
||||||
|
|
@ -43,20 +45,19 @@ void parse_args(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
int count = 0;
|
|
||||||
LinphoneCoreVTable vtable = {0};
|
LinphoneCoreVTable vtable = {0};
|
||||||
LinphoneCore *lc;
|
LinphoneCore *lc;
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
parse_args(argc, argv);
|
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_enable_logs(NULL);
|
||||||
|
|
||||||
linphone_core_start_echo_calibration(lc, calibration_finished, NULL, NULL, NULL);
|
linphone_core_start_echo_calibration(lc, calibration_finished, NULL, NULL, NULL);
|
||||||
|
|
||||||
while (count++ < 1000) {
|
while (!done) {
|
||||||
linphone_core_iterate(lc);
|
linphone_core_iterate(lc);
|
||||||
ms_usleep(10000);
|
ms_usleep(20000);
|
||||||
}
|
}
|
||||||
linphone_core_destroy(lc);
|
linphone_core_destroy(lc);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue