]> sjero.net Git - linphone/commitdiff
add EC bypass mode
authorJehan Monnier <jehan.monnier@linphone.org>
Mon, 24 Jan 2011 09:35:23 +0000 (10:35 +0100)
committerJehan Monnier <jehan.monnier@linphone.org>
Mon, 24 Jan 2011 09:35:23 +0000 (10:35 +0100)
coreapi/linphonecall.c
coreapi/linphonecore.c
coreapi/linphonecore.h
coreapi/linphonecore_jni.cc
java/common/org/linphone/core/LinphoneCall.java
mediastreamer2

index db5c45096f3116ad895e0810cdf62a96d68755f8..7254e94ac47b3575720eee1a22be3f2380929be7 100644 (file)
@@ -572,6 +572,7 @@ static void rendercb(void *data, const MSPicture *local, const MSPicture *remote
 }
 #endif
 
+
 void linphone_call_init_media_streams(LinphoneCall *call){
        LinphoneCore *lc=call->core;
        SalMediaDescription *md=call->localdesc;
@@ -672,30 +673,24 @@ static void post_configure_audio_streams(LinphoneCall*call){
        }
        if (st->volsend){
                ms_filter_call_method(st->volsend,MS_VOLUME_REMOVE_DC,&dc_removal);
-       }
-       if (linphone_core_echo_limiter_enabled(lc)){
                float speed=lp_config_get_float(lc->config,"sound","el_speed",-1);
                thres=lp_config_get_float(lc->config,"sound","el_thres",-1);
                float force=lp_config_get_float(lc->config,"sound","el_force",-1);
                int sustain=lp_config_get_int(lc->config,"sound","el_sustain",-1);
                float transmit_thres=lp_config_get_float(lc->config,"sound","el_transmit_thres",-1);
                MSFilter *f=NULL;
-               if (st->el_type!=ELInactive){
-                       f=st->volsend;
-                       if (speed==-1) speed=0.03;
-                       if (force==-1) force=25;
-                       ms_filter_call_method(f,MS_VOLUME_SET_EA_SPEED,&speed);
-                       ms_filter_call_method(f,MS_VOLUME_SET_EA_FORCE,&force);
-                       if (thres!=-1)
-                               ms_filter_call_method(f,MS_VOLUME_SET_EA_THRESHOLD,&thres);
-                       if (sustain!=-1)
-                               ms_filter_call_method(f,MS_VOLUME_SET_EA_SUSTAIN,&sustain);
-                       if (transmit_thres!=-1)
+               f=st->volsend;
+               if (speed==-1) speed=0.03;
+               if (force==-1) force=25;
+               ms_filter_call_method(f,MS_VOLUME_SET_EA_SPEED,&speed);
+               ms_filter_call_method(f,MS_VOLUME_SET_EA_FORCE,&force);
+               if (thres!=-1)
+                       ms_filter_call_method(f,MS_VOLUME_SET_EA_THRESHOLD,&thres);
+               if (sustain!=-1)
+                       ms_filter_call_method(f,MS_VOLUME_SET_EA_SUSTAIN,&sustain);
+               if (transmit_thres!=-1)
                                ms_filter_call_method(f,MS_VOLUME_SET_EA_TRANSMIT_THRESHOLD,&transmit_thres);
-               }
-       }
-               
-       if (st->volsend){
+
                ms_filter_call_method(st->volsend,MS_VOLUME_SET_NOISE_GATE_THRESHOLD,&ng_thres);
                ms_filter_call_method(st->volsend,MS_VOLUME_SET_NOISE_GATE_FLOORGAIN,&ng_floorgain);
        }
@@ -982,3 +977,42 @@ void linphone_call_send_vfu_request(LinphoneCall *call)
        sal_call_send_vfu_request(call->op);
 }
 #endif
+
+void linphone_call_enable_echo_cancellation(LinphoneCall *call, bool_t enable) {
+       if (call!=NULL && call->audiostream!=NULL && call->audiostream->ec){
+               bool_t bypass_mode = !enable;
+               ms_filter_call_method(call->audiostream->ec,MS_ECHO_CANCELLER_SET_BYPASS_MODE,&bypass_mode);
+       }
+}
+bool_t linphone_call_echo_cancellation_enabled(LinphoneCall *call) {
+       if (call!=NULL && call->audiostream!=NULL && call->audiostream->ec){
+               bool_t val;
+               ms_filter_call_method(call->audiostream->ec,MS_ECHO_CANCELLER_GET_BYPASS_MODE,&val);
+               return !val;
+       } else {
+               return linphone_core_echo_cancellation_enabled(call->core);
+       }
+}
+
+void linphone_call_enable_echo_limiter(LinphoneCall *call, bool_t val){
+       if (call!=NULL && call->audiostream!=NULL ) {
+               if (val) {
+               const char *type=lp_config_get_string(call->core->config,"sound","el_type","mic");
+               if (strcasecmp(type,"mic")==0)
+                       audio_stream_enable_echo_limiter(call->audiostream,ELControlMic);
+               else if (strcasecmp(type,"full")==0)
+                       audio_stream_enable_echo_limiter(call->audiostream,ELControlFull);
+               } else {
+                       audio_stream_enable_echo_limiter(call->audiostream,ELInactive);
+               }
+       }
+}
+
+bool_t linphone_call_echo_limiter_enabled(const LinphoneCall *call){
+       if (call!=NULL && call->audiostream!=NULL ){
+               return call->audiostream->el_type !=ELInactive ;
+       } else {
+               return linphone_core_echo_limiter_enabled(call->core);
+       }
+}
+
index 40d4257b0c98e71430d9dbf043eb801c16b15cf8..9e0c56b1d7e33badb86ee41f642750f370a8a0d2 100644 (file)
@@ -2894,7 +2894,7 @@ const char * linphone_core_get_ringback(const LinphoneCore *lc){
 }
 
 /**
- * Enables or disable echo cancellation.
+ * Enables or disable echo cancellation. Value is saved an used for subsequent calls
  *
  * @ingroup media_parameters
 **/
@@ -2904,6 +2904,7 @@ void linphone_core_enable_echo_cancellation(LinphoneCore *lc, bool_t val){
                lp_config_set_int(lc->config,"sound","echocancellation",val);
 }
 
+
 /**
  * Returns TRUE if echo cancellation is enabled.
  *
index 8cea2d5eb59dee5064ffbcdcb3bc42b54e574bea..0b9823f3c0eeeafb15deb97bbbf11ef3800203a8 100644 (file)
@@ -247,8 +247,34 @@ LinphoneReason linphone_call_get_reason(const LinphoneCall *call);
 const char *linphone_call_get_remote_user_agent(LinphoneCall *call);
 void *linphone_call_get_user_pointer(LinphoneCall *call);
 void linphone_call_set_user_pointer(LinphoneCall *call, void *user_pointer);
-
-
+/**
+ * Enables or disable echo cancellation for this call
+ * @param call
+ * @param val
+ *
+ * @ingroup media_parameters
+**/
+void linphone_call_enable_echo_cancellation(LinphoneCall *call, bool_t val) ;
+/**
+ * Returns TRUE if echo cancellation is enabled.
+ *
+ * @ingroup media_parameters
+**/
+bool_t linphone_call_echo_cancellation_enabled(LinphoneCall *lc);
+/**
+ * Enables or disable echo limiter for this call
+ * @param call
+ * @param val
+ *
+ * @ingroup media_parameters
+**/
+void linphone_call_enable_echo_limiter(LinphoneCall *call, bool_t val);
+/**
+ * Returns TRUE if echo limiter is enabled.
+ *
+ * @ingroup media_parameters
+**/
+bool_t linphone_call_echo_limiter_enabled(const LinphoneCall *call);
 /**
  * @addtogroup proxies
  * @{
index dc3969b8d3c28c3b949469c6fdb5f36145e23f96..fbd8f01eab4f534d297958f7be18d312b7f46a13 100644 (file)
@@ -857,6 +857,7 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv
        return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
 }
 
+/*payloadType*/
 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv*  env,jobject  thiz,jlong ptr) {
        PayloadType* pt = (PayloadType*)ptr;
        char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
@@ -913,6 +914,30 @@ extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState(  JNIEnv*  env
                                                                                                                                                ,jlong ptr) {
        return (jint)linphone_call_get_state((LinphoneCall*)ptr);
 }
+extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation(        JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr
+                                                                                                                                               ,jboolean value) {
+       linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
+}
+extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr) {
+       return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
+}
+
+extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter(     JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr
+                                                                                                                                               ,jboolean value) {
+       linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
+}
+extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled(      JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr) {
+       return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
+}
+
 
 //LinphoneFriend
 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv*  env
index cddcd7be6996a38e06a414c57e779741eca2c6e8..66418a930e7bd15bf202e07e74d70d83cabcb718 100644 (file)
@@ -21,7 +21,7 @@ package org.linphone.core;
 import java.util.Vector;
 
 /**
- * Object representing a Call. calls are created using {@link LinphoneCore#invite(LinphoneAddress)} or paased to the application by listener {@link LinphoneCoreListener#callState(LinphoneCore, LinphoneCall, State, String)}
+ * Object representing a Call. calls are created using {@link LinphoneCore#invite(LinphoneAddress)} or passed to the application by listener {@link LinphoneCoreListener#callState(LinphoneCore, LinphoneCall, State, String)}
  * 
  */
 @SuppressWarnings("unchecked")
@@ -154,5 +154,25 @@ public interface LinphoneCall {
        public LinphoneCallParams getCurrentParamsCopy();
        
        public void enableCamera(boolean enabled);
+       /**
+        * Enables or disable echo cancellation.
+        * @param enable
+        */
+       public void enableEchoCancellation(boolean enable);
+       /**
+        * get EC status 
+        * @return true if echo cancellation is enabled.
+        */
+       public boolean isEchoCancellationEnabled();
+       /**
+        * Enables or disable echo limiter cancellation.
+        * @param enable
+        */
+       public void enableEchoLimiter(boolean enable);
+       /**
+        * get EL status 
+        * @return true if echo limiter is enabled.
+        */
+       public boolean isEchoLimiterEnabled();
 
 }
index 11a2eced2d238322c32fc775a6583387a9d43fc4..d48296689764e1f5f27f16c881ee4c5dcb8445dd 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 11a2eced2d238322c32fc775a6583387a9d43fc4
+Subproject commit d48296689764e1f5f27f16c881ee4c5dcb8445dd