]> sjero.net Git - linphone/commitdiff
echo calibrator ready
authorSimon Morlat <simon.morlat@linphone.org>
Mon, 24 Jan 2011 14:58:24 +0000 (15:58 +0100)
committerSimon Morlat <simon.morlat@linphone.org>
Mon, 24 Jan 2011 14:58:24 +0000 (15:58 +0100)
coreapi/Makefile.am
coreapi/linphonecore.c
coreapi/linphonecore_utils.h
coreapi/private.h
mediastreamer2
oRTP

index 4835dc74cc30391fc2b9ae104aa97be6f361d243..8f88045f568a2c3993ffa01b6b705e5f03c1d3b8 100644 (file)
@@ -35,7 +35,8 @@ liblinphone_la_SOURCES=\
        linphonecall.c \
        sipsetup.c sipsetup.h \
        siplogin.c \
-       lsd.c linphonecore_utils.h
+       lsd.c linphonecore_utils.h \
+       ec-calibrator.c
 
 
 liblinphone_la_LDFLAGS= -version-info $(LIBLINPHONE_SO_VERSION) -no-undefined
@@ -49,7 +50,7 @@ if BUILD_WIN32
 liblinphone_la_LIBADD+=$(top_builddir)/oRTP/src/libortp.la
 endif
 
-noinst_PROGRAMS=test_lsd
+noinst_PROGRAMS=test_lsd test_ecc
 
 test_lsd_SOURCES=test_lsd.c
 
@@ -57,6 +58,14 @@ test_lsd_LDADD=liblinphone.la \
                                                        $(MEDIASTREAMER_LIBS) \
                                                        $(ORTP_LIBS)
 
+test_ecc_SOURCES=test_ecc.c
+
+test_ecc_LDADD=liblinphone.la \
+                                                       $(MEDIASTREAMER_LIBS) \
+                                                       $(ORTP_LIBS)
+
+
+
 AM_CFLAGS=$(STRICT_OPTIONS)  -DIN_LINPHONE \
        $(ORTP_CFLAGS) \
        $(OSIP_CFLAGS) \
index ef145c2fd35af1d304afcc5129104ed87b810f73..f10214178fd7668357beb39998dec6ee40f5fea3 100644 (file)
@@ -1635,6 +1635,19 @@ void linphone_core_iterate(LinphoneCore *lc){
                one_second_elapsed=TRUE;
        }
 
+       if (lc->ecc!=NULL){
+               LinphoneEcCalibratorStatus ecs=ec_calibrator_get_status(lc->ecc);
+               if (ecs!=LinphoneEcCalibratorInProgress){
+                       if (lc->ecc->cb)
+                               lc->ecc->cb(lc,ecs,lc->ecc->delay,lc->ecc->cb_data);
+                       if (ecs==LinphoneEcCalibratorDone){
+                               lp_config_set_int(lc->config, "sound", "ec_delay",lc->ecc->delay);
+                       }
+                       ec_calibrator_destroy(lc->ecc);
+                       lc->ecc=NULL;
+               }
+       }
+
        if (lc->preview_finished){
                lc->preview_finished=0;
                ring_stop(lc->ringstream);
index 8c29ef1afe5883f7c7d6e434d6cda5e63ed43d88..b2ede96496cbd0186cc660ca4f0be41e8935caec 100644 (file)
@@ -49,4 +49,21 @@ void linphone_sound_daemon_release_all_players(LinphoneSoundDaemon *obj);
 void linphone_core_use_sound_daemon(LinphoneCore *lc, LinphoneSoundDaemon *lsd);
 void linphone_sound_daemon_destroy(LinphoneSoundDaemon *obj);
 
+/**
+ * Enum describing the result of the echo canceller calibration process.
+**/
+typedef enum {
+       LinphoneEcCalibratorInProgress,
+       LinphoneEcCalibratorDone,
+       LinphoneEcCalibratorFailed
+}LinphoneEcCalibratorStatus;
+
+
+typedef void (*LinphoneEcCalibrationCallback)(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data);
+
+/**
+ * Start an echo calibration of the sound devices, in order to find adequate settings for the echo canceller automatically.
+**/
+int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibrationCallback cb, void *cb_data);
+
 #endif
index 5759bbc19a67778a2e65a94516965f06a8ffec35..a960acbd8130adb94a28cb811fd5734d7a82a2d1 100644 (file)
@@ -26,6 +26,7 @@
 #define _PRIVATE_H
 
 #include "linphonecore.h"
+#include "linphonecore_utils.h"
 #include "sal.h"
 
 #ifdef HAVE_CONFIG_H
@@ -424,6 +425,7 @@ struct _LinphoneCore
        unsigned long video_window_id;
        unsigned long preview_window_id;
        time_t netup_time; /*time when network went reachable */
+       struct _EcCalibrator *ecc;
        bool_t use_files;
        bool_t apply_nat_settings;
        bool_t initial_subscribes_sent;
@@ -451,6 +453,27 @@ bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, Payl
 #define linphone_core_ready(lc) ((lc)->state!=LinphoneGlobalStartup)
 void _linphone_core_configure_resolver();
 
+struct _EcCalibrator{
+       ms_thread_t thread;
+       MSSndCard *play_card,*capt_card;
+       MSFilter *sndread,*det,*rec;
+       MSFilter *play, *gen, *sndwrite;
+       MSTicker *ticker;
+       LinphoneEcCalibrationCallback cb;
+       void *cb_data;
+       int recv_count;
+       int sent_count;
+       int64_t acc;
+       int delay;
+       LinphoneEcCalibratorStatus status;
+};
+
+typedef struct _EcCalibrator EcCalibrator;
+
+LinphoneEcCalibratorStatus ec_calibrator_get_status(EcCalibrator *ecc);
+
+void ec_calibrator_destroy(EcCalibrator *ecc);
+
 #define HOLD_OFF       (0)
 #define HOLD_ON                (1)
 
index dce5ac7d4dc8e298cdedd5dcef55c60d7485206e..c5959fa4520005013cd14d2f773116f24f2eb7b7 160000 (submodule)
@@ -1 +1 @@
-Subproject commit dce5ac7d4dc8e298cdedd5dcef55c60d7485206e
+Subproject commit c5959fa4520005013cd14d2f773116f24f2eb7b7
diff --git a/oRTP b/oRTP
index c8b487f32fe225f8b1961754db9140eb282a0d28..37c60a638fd108404ca437e2bbef78f227178450 160000 (submodule)
--- a/oRTP
+++ b/oRTP
@@ -1 +1 @@
-Subproject commit c8b487f32fe225f8b1961754db9140eb282a0d28
+Subproject commit 37c60a638fd108404ca437e2bbef78f227178450