MSDtmfGenCustomTone tone;
MSToneDetectorDef expected_tone;
-
ms_filter_set_notify_callback(ecc->det,on_tone_received,ecc);
expected_tone.frequency=2000;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
ms_sleep(1);
- if (ecc->sent_count==3 && ecc->recv_count==3){
- int delay=ecc->acc/3;
- if (delay<0){
- ms_error("Quite surprising calibration result, delay=%i",delay);
- ecc->status=LinphoneEcCalibratorFailed;
- }else{ms_message("Echo calibration estimated delay to be %i ms",delay);
- ecc->delay=delay;
- ecc->status=LinphoneEcCalibratorDone;
+ if (ecc->sent_count==3) {
+ if (ecc->recv_count==3){
+ int delay=ecc->acc/3;
+ if (delay<0){
+ ms_error("Quite surprising calibration result, delay=%i",delay);
+ ecc->status=LinphoneEcCalibratorFailed;
+ }else{
+ ms_message("Echo calibration estimated delay to be %i ms",delay);
+ ecc->delay=delay;
+ ecc->status=LinphoneEcCalibratorDone;
+ }
+ } else if (ecc->recv_count == 0) {
+ ms_message("Echo calibration succeeded, no echo has been detected");
+ ecc->status = LinphoneEcCalibratorDoneNoEcho;
+ } else {
+ ecc->status = LinphoneEcCalibratorFailed;
}
}else{
- ms_error("Echo calibration failed, tones received = %i",ecc->recv_count);
ecc->status=LinphoneEcCalibratorFailed;
}
-
+ if (ecc->status == LinphoneEcCalibratorFailed) {
+ ms_error("Echo calibration failed, tones received = %i",ecc->recv_count);
+ }
}
static void * ecc_thread(void *p){
* Enum describing the result of the echo canceller calibration process.
**/
typedef enum {
- LinphoneEcCalibratorInProgress,
- LinphoneEcCalibratorDone,
- LinphoneEcCalibratorFailed
+ LinphoneEcCalibratorInProgress, /**< The echo canceller calibration process is on going. */
+ LinphoneEcCalibratorDone, /**< The echo canceller calibration has been performed and produced an echo delay measure. */
+ LinphoneEcCalibratorFailed, /**< The echo canceller calibration process has failed. */
+ LinphoneEcCalibratorDoneNoEcho /**< The echo canceller calibration has been performed and no echo has been detected. */
}LinphoneEcCalibratorStatus;
public static final int IN_PROGRESS_STATUS=0;
public static final int DONE_STATUS=1;
public static final int FAILED_STATUS=2;
+ public static final int DONE_NO_ECHO_STATUS=3;
/**
* Calibration in progress
*/
- static public EcCalibratorStatus InProgress = new EcCalibratorStatus(IN_PROGRESS_STATUS,"InProgress");
+ static public EcCalibratorStatus InProgress = new EcCalibratorStatus(IN_PROGRESS_STATUS,"InProgress");
/**
- * Calibration done
+ * Calibration done that produced an echo delay measure
*/
- static public EcCalibratorStatus Done = new EcCalibratorStatus(DONE_STATUS,"Done");
+ static public EcCalibratorStatus Done = new EcCalibratorStatus(DONE_STATUS,"Done");
/**
- * Calibration in progress
+ * Calibration failed
*/
static public EcCalibratorStatus Failed = new EcCalibratorStatus(FAILED_STATUS,"Failed");
+ /**
+ * Calibration done with no echo detected
+ */
+ static public EcCalibratorStatus DoneNoEcho = new EcCalibratorStatus(DONE_NO_ECHO_STATUS, "DoneNoEcho");
private final int mValue;
private final String mStringValue;