From 7f4afe2954c1f92df5ca57e2a14e44e152e2b244 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 7 Jul 2014 16:45:22 +0200 Subject: [PATCH 1/9] Fix generation of gitversion.h. --- coreapi/Makefile.am | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/coreapi/Makefile.am b/coreapi/Makefile.am index 547623652..ce7dc56a0 100644 --- a/coreapi/Makefile.am +++ b/coreapi/Makefile.am @@ -130,7 +130,7 @@ test_numbers_LDADD=liblinphone.la $(liblinphone_la_LIBADD) endif AM_CPPFLAGS=\ - -I$(top_srcdir) -I$(top_srcdir)/include + -I$(top_srcdir) -I$(top_srcdir)/include -I$(builddir) AM_CFLAGS=\ $(STRICT_OPTIONS) -DIN_LINPHONE \ @@ -167,21 +167,21 @@ make_gitversion_h: echo "*** PACKAGE_VERSION and git tag differ. Please put them identical."; \ exit 1; \ fi ; \ - $(ECHO) -n "#define LIBLINPHONE_GIT_VERSION \"$(GITDESCRIBE)\"" > $(GITVERSION_FILE_TMP) ; \ + $(ECHO) -n "#define LIBLINPHONE_GIT_VERSION \"$(GITDESCRIBE)\"" > $(builddir)/$(GITVERSION_FILE_TMP) ; \ elif test "$(GITREVISION)" != "" ; then \ - $(ECHO) -n "#define LIBLINPHONE_GIT_VERSION \"$(LINPHONE_VERSION)_$(GITREVISION)\"" > $(GITVERSION_FILE_TMP) ; \ + $(ECHO) -n "#define LIBLINPHONE_GIT_VERSION \"$(LINPHONE_VERSION)_$(GITREVISION)\"" > $(builddir)/$(GITVERSION_FILE_TMP) ; \ else \ - $(ECHO) -n "" > $(GITVERSION_FILE_TMP) ; \ + $(ECHO) -n "" > $(builddir)/$(GITVERSION_FILE_TMP) ; \ fi ; \ else \ - $(ECHO) -n "" > $(GITVERSION_FILE_TMP) ; \ + $(ECHO) -n "" > $(builddir)/$(GITVERSION_FILE_TMP) ; \ fi - if ! test -f $(srcdir)/$(GITVERSION_FILE) ; then \ - cp -f $(srcdir)/$(GITVERSION_FILE_TMP) $(srcdir)/$(GITVERSION_FILE) ; \ + if ! test -f $(builddir)/$(GITVERSION_FILE) ; then \ + cp -f $(builddir)/$(GITVERSION_FILE_TMP) $(builddir)/$(GITVERSION_FILE) ; \ fi - if test "`cat $(GITVERSION_FILE_TMP)`" != "`cat $(srcdir)/$(GITVERSION_FILE)`" ; then \ - cp -f $(GITVERSION_FILE_TMP) $(srcdir)/$(GITVERSION_FILE) ; \ + if test "`cat $(builddir)/$(GITVERSION_FILE_TMP)`" != "`cat $(builddir)/$(GITVERSION_FILE)`" ; then \ + cp -f $(builddir)/$(GITVERSION_FILE_TMP) $(builddir)/$(GITVERSION_FILE) ; \ fi - rm -f $(GITVERSION_FILE_TMP) ; + rm -f $(builddir)/$(GITVERSION_FILE_TMP) ; $(GITVERSION_FILE): make_gitversion_h From d213cc9a731ced958b3bc8578fd4d35a0550f8c5 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 7 Jul 2014 15:40:48 +0200 Subject: [PATCH 2/9] Add StatisticsCollector in flexisip.conf for unit tests --- tester/flexisip.conf | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tester/flexisip.conf b/tester/flexisip.conf index 6c0d85b29..303a1022f 100755 --- a/tester/flexisip.conf +++ b/tester/flexisip.conf @@ -513,3 +513,25 @@ enabled=true filter = (user-agent contains 'redirect') && !(request.uri.params contains 'redirected') contact= +## +## The purpose of the StatisticsCollector module is to collect call +## statistics (RFC 6035) and store them on the server. +## +[module::StatisticsCollector] +# Indicate whether the module is activated. +# Default value: false +enabled=true + +# A request/response enters module if the boolean filter evaluates +# to true. Ex: from.uri.domain contains 'sip.linphone.org', from.uri.domain +# in 'a.org b.org c.org', (to.uri.domain in 'a.org b.org c.org') +# && (user-agent == 'Linphone v2') +# Default value: +filter= + +# SIP URI of the statistics collector. Note that the messages destinated +# to this address will be deleted by this module and thus not be +# delivered. +# Default value: +collector-address=sip:collector@sip.example.org + From 9280f2ba7371785fa3a9b464fef5aa1b1ef3c9bc Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 7 Jul 2014 16:20:27 +0200 Subject: [PATCH 3/9] fix unexpected high loss values in RTCP reports when resuming calls --- .gitignore | 1 + mediastreamer2 | 2 +- oRTP | 2 +- tester/call_tester.c | 81 +++++++++++++++++++++++++++++++++++++------- 4 files changed, 71 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 047ebb08c..6a94843fa 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,4 @@ tools/lpc2xml_test tools/xml2lpc_test coreapi/help/filetransfer tester/receive_file.dump +tester/tmp.db diff --git a/mediastreamer2 b/mediastreamer2 index 4a919b63a..0622ff738 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 4a919b63a6f4583d8dc464e32b542151359d264f +Subproject commit 0622ff73822d27191e31391f135c90f6e5e8dcbb diff --git a/oRTP b/oRTP index e56d11d0b..ad02c6d5e 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit e56d11d0b062ea96c8356513add39511b7cb4043 +Subproject commit ad02c6d5ed76092157aff9c1061abfd490ac03ae diff --git a/tester/call_tester.c b/tester/call_tester.c index f5eadb3b6..b507b5855 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -306,6 +306,8 @@ static void call_outbound_with_multiple_proxy() { // calling marie should go through the second proxy config CU_ASSERT_TRUE(call(marie, pauline)); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); } #if 0 /* TODO: activate test when the implementation is ready */ @@ -934,15 +936,11 @@ static void call_paused_resumed(void) { wait_for_until(pauline->lc, marie->lc, NULL, 5, 3000); - int exp_cum = - rtp_session_get_rcv_ext_seq_number(call_pauline->audiostream->ms.sessions.rtp_session); - linphone_core_pause_call(pauline->lc,call_pauline); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1)); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1)); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1)); - exp_cum += rtp_session_get_seq_number(linphone_core_get_current_call(marie->lc)->audiostream->ms.sessions.rtp_session); - /*stay in pause a little while in order to generate traffic*/ wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); @@ -953,11 +951,58 @@ static void call_paused_resumed(void) { /*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/ wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000); - /*there should be a bit of packets loss for the ones sent by PAUSED (pauline) between the latest RTCP SR report received - by PAUSER (marie) because PAUSER will drop any packets received after the pause. Keep a tolerance of 1 more packet lost - in case of ...*/ + /*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/ stats = rtp_session_get_stats(call_pauline->sessions->rtp_session); - CU_ASSERT_TRUE(abs(stats->cum_packet_loss - exp_cum)<=1); + CU_ASSERT_EQUAL(stats->cum_packet_loss, 0); + + /*just to sleep*/ + linphone_core_terminate_all_calls(pauline->lc); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1)); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1)); + + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_paused_resumed_with_loss(void) { + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); + LinphoneCall* call_pauline; + const rtp_stats_t * stats; + + + OrtpNetworkSimulatorParams params={0}; + params.enabled=TRUE; + params.loss_rate=25; + + + CU_ASSERT_TRUE(call(pauline,marie)); + call_pauline = linphone_core_get_current_call(pauline->lc); + rtp_session_enable_network_simulation(call_pauline->audiostream->ms.sessions.rtp_session,¶ms); + rtp_session_enable_network_simulation(call_pauline->videostream->ms.sessions.rtp_session,¶ms); + + wait_for_until(pauline->lc, marie->lc, NULL, 5, 4000); + + linphone_core_pause_call(pauline->lc,call_pauline); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1)); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1)); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1)); + + /*stay in pause a little while in order to generate traffic*/ + wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); + + linphone_core_resume_call(pauline->lc,call_pauline); + + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); + /*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/ + wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000); + + /*since stats are NOT totally reset during pause, the stats->packet_recv is computed from + the start of call. This test ensures that the loss rate is consistent during the entire call.*/ + stats = rtp_session_get_stats(call_pauline->sessions->rtp_session); + CU_ASSERT_TRUE(((stats->cum_packet_loss * 100.f / stats->packet_recv) / params.loss_rate) > .5f); /*just to sleep*/ linphone_core_terminate_all_calls(pauline->lc); @@ -984,19 +1029,29 @@ static bool_t pause_call_1(LinphoneCoreManager* mgr_1,LinphoneCall* call_1,Linph static void call_paused_resumed_from_callee(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); - LinphoneCall* call_obj; + LinphoneCall* call_marie; + const rtp_stats_t * stats; CU_ASSERT_TRUE(call(pauline,marie)); - call_obj = linphone_core_get_current_call(marie->lc); + call_marie = linphone_core_get_current_call(marie->lc); - linphone_core_pause_call(marie->lc,call_obj); + linphone_core_pause_call(marie->lc,call_marie); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausing,1)); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,1)); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPaused,1)); - linphone_core_resume_call(marie->lc,call_obj); + /*stay in pause a little while in order to generate traffic*/ + wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); + + linphone_core_resume_call(marie->lc,call_marie); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); + /*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/ + wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000); + + /*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/ + stats = rtp_session_get_stats(call_marie->sessions->rtp_session); + CU_ASSERT_EQUAL(stats->cum_packet_loss, 0); /*just to sleep*/ linphone_core_terminate_all_calls(pauline->lc); @@ -1007,7 +1062,6 @@ static void call_paused_resumed_from_callee(void) { linphone_core_manager_destroy(pauline); } - #ifdef VIDEO_ENABLED static bool_t add_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee) { LinphoneVideoPolicy caller_policy; @@ -2617,6 +2671,7 @@ test_t call_tests[] = { { "Call terminated by caller", call_terminated_by_caller }, { "Call without SDP", call_with_no_sdp}, { "Call paused resumed", call_paused_resumed }, + { "Call paused resumed with loss", call_paused_resumed_with_loss }, { "Call paused resumed from callee", call_paused_resumed_from_callee }, { "SRTP call", srtp_call }, { "ZRTP call",zrtp_call}, From a3f96a73cb84ff0a58f8497a5f51f3c83100e4fc Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 8 Jul 2014 08:33:02 +0200 Subject: [PATCH 4/9] add config param to disable vfu request --- coreapi/linphonecall.c | 11 +++++++---- coreapi/linphonecore.c | 1 + coreapi/private.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 5ed1b3c24..d78867bfd 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1278,11 +1278,14 @@ void linphone_call_enable_camera (LinphoneCall *call, bool_t enable){ /** * Request remote side to send us a Video Fast Update. **/ -void linphone_call_send_vfu_request(LinphoneCall *call) -{ +void linphone_call_send_vfu_request(LinphoneCall *call) { #ifdef VIDEO_ENABLED - if (LinphoneCallStreamsRunning == linphone_call_get_state(call)) - sal_call_send_vfu_request(call->op); + if (call->core->sip_conf.vfu_with_info) { + if (LinphoneCallStreamsRunning == linphone_call_get_state(call)) + sal_call_send_vfu_request(call->op); + } else { + ms_message("vfu request using sip disabled from config [sip,vfu_with_info]"); + } #endif } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 76a75f93c..276dd82f7 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -755,6 +755,7 @@ static void sip_config_read(LinphoneCore *lc) sal_use_one_matching_codec_policy(lc->sal,lp_config_get_int(lc->config,"sip","only_one_codec",0)); sal_use_dates(lc->sal,lp_config_get_int(lc->config,"sip","put_date",0)); sal_enable_sip_update_method(lc->sal,lp_config_get_int(lc->config,"sip","sip_update",1)); + lc->sip_conf.vfu_with_info=lp_config_get_int(lc->config,"sip","vfu_with_info",1); } static void rtp_config_read(LinphoneCore *lc) diff --git a/coreapi/private.h b/coreapi/private.h index 4722b4849..32e013c94 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -524,6 +524,7 @@ typedef struct sip_config bool_t ping_with_options; bool_t auto_net_state_mon; bool_t tcp_tls_keepalive; + bool_t vfu_with_info; /*use to enable vfu request using sip info*/ } sip_config_t; typedef struct rtp_config From c18f904b2917c1e8141eccf009e0800dcf9a0d8b Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 8 Jul 2014 14:30:52 +0200 Subject: [PATCH 5/9] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 0622ff738..6155d6437 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 0622ff73822d27191e31391f135c90f6e5e8dcbb +Subproject commit 6155d6437712ac049be34b73ddc51a85d62c9f9b From b5aeb7e7553ed1efc8d91384b29bf4116def4545 Mon Sep 17 00:00:00 2001 From: Margaux Clerc Date: Tue, 8 Jul 2014 15:41:39 +0200 Subject: [PATCH 6/9] Jni update proxyConfig wrapper --- coreapi/linphonecore_jni.cc | 39 +++++-- coreapi/proxy.c | 3 + .../linphone/core/LinphoneProxyConfig.java | 3 + .../org/linphone/core/LinphoneCoreImpl.java | 18 +-- .../core/LinphoneProxyConfigImpl.java | 110 ++++++++++++++---- 5 files changed, 128 insertions(+), 45 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 3ab985981..78eb797c3 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -77,6 +77,23 @@ extern "C" void libmswebrtc_init(); } +#define RETURN_PROXY_CONFIG_USER_DATA_OBJECT(javaclass, funcprefix, cobj) \ + { \ + jclass jUserDataObjectClass; \ + jmethodID jUserDataObjectCtor; \ + jobject jUserDataObj; \ + jUserDataObj = (jobject)funcprefix ## _get_user_data(cobj); \ + if (jUserDataObj == NULL) { \ + jUserDataObjectClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/" javaclass)); \ + jUserDataObjectCtor = env->GetMethodID(jUserDataObjectClass,"", "(J)V"); \ + jUserDataObj = env->NewObject(jUserDataObjectClass, jUserDataObjectCtor,(jlong) cobj); \ + jUserDataObj = env->NewGlobalRef(jUserDataObj); \ + funcprefix ## _set_user_data(cobj, jUserDataObj); \ + env->DeleteGlobalRef(jUserDataObjectClass); \ + } \ + return jUserDataObj; \ + } + static JavaVM *jvm=0; static const char* LogDomain = "Linphone"; @@ -880,24 +897,32 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( J extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env ,jobject thiz ,jlong lc) { + LinphoneProxyConfig *config=0; linphone_core_get_default_proxy((LinphoneCore*)lc,&config); return (jlong)config; } -extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) { +static jobject getOrCreateProxy(JNIEnv* env,LinphoneProxyConfig* proxy){ + RETURN_PROXY_CONFIG_USER_DATA_OBJECT("LinphoneProxyConfigImpl", linphone_proxy_config, proxy); +} + +extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) { const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc); int proxyCount = ms_list_size(proxies); - jlongArray jProxies = env->NewLongArray(proxyCount); - jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL); + jclass cls = env->FindClass("java/lang/Object"); + jobjectArray jProxies = env->NewObjectArray(proxyCount,cls,NULL); for (int i = 0; i < proxyCount; i++ ) { - jInternalArray[i] = (unsigned long) (proxies->data); + LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)proxies->data; + jobject jproxy = getOrCreateProxy(env,proxy); + if(jproxy != NULL){ + env->SetObjectArrayElement(jProxies, i, jproxy); + } else { + return NULL; + } proxies = proxies->next; } - - env->ReleaseLongArrayElements(jProxies, jInternalArray, 0); - return jProxies; } diff --git a/coreapi/proxy.c b/coreapi/proxy.c index a999d3b3c..fb8519c32 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -1116,6 +1116,9 @@ void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cf linphone_proxy_config_enable_register(cfg,FALSE); linphone_proxy_config_done(cfg); linphone_proxy_config_update(cfg); /*so that it has an effect*/ + + /*as cfg no longer in proxies, unregister will never be issued*/ + _linphone_proxy_config_unregister(cfg); } if (lc->default_proxy==cfg){ lc->default_proxy=NULL; diff --git a/java/common/org/linphone/core/LinphoneProxyConfig.java b/java/common/org/linphone/core/LinphoneProxyConfig.java index ded4f9457..b34363e5f 100644 --- a/java/common/org/linphone/core/LinphoneProxyConfig.java +++ b/java/common/org/linphone/core/LinphoneProxyConfig.java @@ -25,6 +25,9 @@ package org.linphone.core; */ public interface LinphoneProxyConfig { + public void setIsDeleted(boolean b); + public boolean getIsDeleted(); + /** *Starts editing a proxy configuration. *Because proxy configuration must be consistent, applications MUST call {@link #edit()} before doing any attempts to modify proxy configuration (such as identity, proxy address and so on). diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index bf43810a3..eeebbd328 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -105,7 +105,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native String getRing(long nativePtr); private native void setRootCA(long nativePtr, String path); private native long[] listVideoPayloadTypes(long nativePtr); - private native long[] getProxyConfigList(long nativePtr); + private native LinphoneProxyConfig[] getProxyConfigList(long nativePtr); private native long[] getAuthInfosList(long nativePtr); private native long findAuthInfos(long nativePtr, String username, String realm, String domain); private native long[] listAudioPayloadTypes(long nativePtr); @@ -190,7 +190,7 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized LinphoneProxyConfig getDefaultProxyConfig() { isValid(); - long lNativePtr = getDefaultProxyConfig(nativePtr); + long lNativePtr = getDefaultProxyConfig(nativePtr); if (lNativePtr!=0) { return new LinphoneProxyConfigImpl(this,lNativePtr); } else { @@ -224,6 +224,7 @@ class LinphoneCoreImpl implements LinphoneCore { isValid(); removeProxyConfig(nativePtr, ((LinphoneProxyConfigImpl)proxyCfg).nativePtr); ((LinphoneProxyConfigImpl)proxyCfg).mCore=null; + ((LinphoneProxyConfigImpl)proxyCfg).deleteNativePtr(); } public synchronized void clearAuthInfos() { isValid(); @@ -512,17 +513,8 @@ class LinphoneCoreImpl implements LinphoneCore { setRootCA(nativePtr, path); } - public synchronized LinphoneProxyConfig[] getProxyConfigList() { - long[] typesPtr = getProxyConfigList(nativePtr); - if (typesPtr == null) return null; - - LinphoneProxyConfig[] proxies = new LinphoneProxyConfig[typesPtr.length]; - - for (int i=0; i < proxies.length; i++) { - proxies[i] = new LinphoneProxyConfigImpl(this,typesPtr[i]); - } - - return proxies; + public synchronized LinphoneProxyConfig[] getProxyConfigList() { + return getProxyConfigList(nativePtr); } public synchronized PayloadType[] getVideoCodecs() { diff --git a/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java b/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java index aface8e36..1288ac39f 100644 --- a/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java +++ b/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java @@ -15,20 +15,17 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ + */ package org.linphone.core; import org.linphone.core.LinphoneCore.RegistrationState; - - - - class LinphoneProxyConfigImpl implements LinphoneProxyConfig { - protected final long nativePtr; + protected long nativePtr; protected LinphoneCoreImpl mCore; - + protected boolean isDeleting; + private native int getState(long nativePtr); private native void setExpires(long nativePtr, int delay); private native int getExpires(long nativePtr); @@ -39,14 +36,40 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { setIdentity(identity); setProxy(proxy); setRoute(route); + setIsDeleted(false); enableRegister(enableRegister); ownPtr=true; } - protected LinphoneProxyConfigImpl(LinphoneCoreImpl core, long aNativePtr) { + + protected LinphoneProxyConfigImpl(LinphoneCoreImpl core,long aNativePtr) { + mCore=core; nativePtr = aNativePtr; ownPtr=false; - mCore=core; } + + protected LinphoneProxyConfigImpl(long aNativePtr) { + nativePtr = aNativePtr; + ownPtr=false; + } + + public boolean getIsDeleted() { + return isDeleting; + } + + public void setIsDeleted(boolean b) { + isDeleting = b; + } + + private void isValid() { + if (nativePtr == 0) { + throw new RuntimeException("proxy config removed"); + } + } + + public void deleteNativePtr() { + nativePtr=0; + } + protected void finalize() throws Throwable { //Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config"); if (ownPtr) delete(nativePtr); @@ -56,42 +79,44 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { private native void edit(long ptr); private native void done(long ptr); - + private native void setIdentity(long ptr,String identity); private native String getIdentity(long ptr); private native int setProxy(long ptr,String proxy); private native String getProxy(long ptr); - + private native void enableRegister(long ptr,boolean value); private native boolean isRegisterEnabled(long ptr); - + private native boolean isRegistered(long ptr); private native void setDialPrefix(long ptr, String prefix); private native String getDialPrefix(long ptr); - + private native String normalizePhoneNumber(long ptr,String number); - + private native String getDomain(long ptr); - + private native void setDialEscapePlus(long ptr, boolean value); private native boolean getDialEscapePlus(long ptr); - + private native String getRoute(long ptr); private native int setRoute(long ptr,String uri); private native void enablePublish(long ptr,boolean enable); private native boolean publishEnabled(long ptr); private native void setContactParameters(long ptr, String params); - + private native int lookupCCCFromIso(long nativePtr, String iso); private native int lookupCCCFromE164(long nativePtr, String e164); - + public LinphoneProxyConfig enableRegister(boolean value) { + isValid(); enableRegister(nativePtr,value); return this; } public void done() { + isValid(); Object mutex=mCore!=null ? mCore : this; synchronized(mutex){ done(nativePtr); @@ -99,6 +124,7 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { } public LinphoneProxyConfig edit() { + isValid(); Object mutex=mCore!=null ? mCore : this; synchronized(mutex){ edit(nativePtr); @@ -107,139 +133,173 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { } public void setIdentity(String identity) throws LinphoneCoreException { + isValid(); setIdentity(nativePtr,identity); } public void setProxy(String proxyUri) throws LinphoneCoreException { + isValid(); if (setProxy(nativePtr,proxyUri)!=0) { throw new LinphoneCoreException("Bad proxy address ["+proxyUri+"]"); } } public String normalizePhoneNumber(String number) { + isValid(); return normalizePhoneNumber(nativePtr,number); } public void setDialPrefix(String prefix) { + isValid(); setDialPrefix(nativePtr, prefix); } public String getDialPrefix() { + isValid(); return getDialPrefix(nativePtr); } public String getDomain() { + isValid(); return getDomain(nativePtr); } public void setDialEscapePlus(boolean value) { - setDialEscapePlus(nativePtr,value); + isValid(); + setDialEscapePlus(nativePtr,value); } public boolean getDialEscapePlus() { + isValid(); return getDialEscapePlus(nativePtr); } public String getIdentity() { + isValid(); return getIdentity(nativePtr); } public String getProxy() { + isValid(); return getProxy(nativePtr); } public boolean isRegistered() { + isValid(); return isRegistered(nativePtr); } public boolean registerEnabled() { + isValid(); return isRegisterEnabled(nativePtr); } public String getRoute() { + isValid(); return getRoute(nativePtr); } public void setRoute(String routeUri) throws LinphoneCoreException { + isValid(); if (setRoute(nativePtr, routeUri) != 0) { throw new LinphoneCoreException("cannot set route ["+routeUri+"]"); } } public void enablePublish(boolean enable) { + isValid(); enablePublish(nativePtr,enable); } public RegistrationState getState() { + isValid(); return RegistrationState.fromInt(getState(nativePtr)); } public void setExpires(int delay) { + isValid(); setExpires(nativePtr, delay); } public int getExpires() { + isValid(); return getExpires(nativePtr); } public boolean publishEnabled() { + isValid(); return publishEnabled(nativePtr); } @Override public void setContactParameters(String params) { + isValid(); setContactParameters(nativePtr, params); } @Override public int lookupCCCFromIso(String iso) { + isValid(); return lookupCCCFromIso(nativePtr, iso); } @Override public int lookupCCCFromE164(String e164) { + isValid(); return lookupCCCFromE164(nativePtr, e164); } private native int getError(long nativeptr); @Override public Reason getError() { + isValid(); return Reason.fromInt(getError(nativePtr)); } private native void setPrivacy(long nativePtr, int mask); @Override public void setPrivacy(int privacy_mask) { + isValid(); setPrivacy(nativePtr,privacy_mask); } private native int getPrivacy(long nativePtr); @Override public int getPrivacy() { + isValid(); return getPrivacy(nativePtr); } - + private native void enableAvpf(long nativePtr, boolean enable); @Override public void enableAvpf(boolean enable) { + isValid(); enableAvpf(nativePtr, enable); } private native boolean avpfEnabled(long nativePtr); @Override public boolean avpfEnabled() { + isValid(); return avpfEnabled(nativePtr); } - + private native void setAvpfRRInterval(long nativePtr, int interval); @Override public void setAvpfRRInterval(int interval) { + isValid(); setAvpfRRInterval(nativePtr, interval); } - + private native int getAvpfRRInterval(long nativePtr); @Override public int getAvpfRRInterval() { + isValid(); return getAvpfRRInterval(nativePtr); } - + private native String getContactParameters(long ptr); @Override public String getContactParameters() { + isValid(); return getContactParameters(nativePtr); } - + private native void setContactUriParameters(long ptr, String params); @Override public void setContactUriParameters(String params) { + isValid(); setContactUriParameters(nativePtr,params); } - + private native String getContactUriParameters(long ptr); @Override public String getContactUriParameters() { + isValid(); return getContactUriParameters(nativePtr); } + private native long getErrorInfo(long nativePtr); + @Override public ErrorInfo getErrorInfo() { return new ErrorInfoImpl(getErrorInfo(nativePtr)); From 09be0d018de60f8864f17d477e137aff207fccd7 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 8 Jul 2014 16:22:54 +0200 Subject: [PATCH 7/9] ortp:fix compilation issue on macosx --- oRTP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oRTP b/oRTP index ad02c6d5e..99f33a0f5 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit ad02c6d5ed76092157aff9c1061abfd490ac03ae +Subproject commit 99f33a0f510310389c22bf88a39582450be38425 From c8d65fc4ecded76c8a5d6a6c9f79b81c2d066074 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 9 Jul 2014 15:28:13 +0200 Subject: [PATCH 8/9] Fix LINPHONE_PLUGIN_DIRS for Windows Phone 8. --- build/wp8/LibLinphone.vcxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/wp8/LibLinphone.vcxproj b/build/wp8/LibLinphone.vcxproj index ed1e7e847..797b2517d 100644 --- a/build/wp8/LibLinphone.vcxproj +++ b/build/wp8/LibLinphone.vcxproj @@ -54,7 +54,7 @@ Level4 $(ProjectDir)..\..\..\belle-sip\include;$(ProjectDir)..\..\oRTP\include;$(ProjectDir)..\..\mediastreamer2\include;$(ProjectDIr)..\..\..\tunnel\include;$(ProjectDir)..\..\coreapi;$(ProjectDir)..\..\include;$(SolutionDir)$(Platform)\$(Configuration)\include;%(AdditionalIncludeDirectories) - __STDC_CONSTANT_MACROS;_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;_USRDLL;WINDOW_NATIVE;_TRUE_TIME;IN_LINPHONE;USE_BELLESIP;TUNNEL_ENABLED;VIDEO_ENABLED;LINPHONE_PACKAGE_NAME="linphone";LINPHONE_VERSION="Devel";LIBLINPHONE_EXPORTS;LINPHONE_PLUGINS_DIR="";UNICODE;_XKEYCHECK_H;%(PreprocessorDefinitions) + __STDC_CONSTANT_MACROS;_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;_USRDLL;WINDOW_NATIVE;_TRUE_TIME;IN_LINPHONE;USE_BELLESIP;TUNNEL_ENABLED;VIDEO_ENABLED;LINPHONE_PACKAGE_NAME="linphone";LINPHONE_VERSION="Devel";LIBLINPHONE_EXPORTS;LINPHONE_PLUGINS_DIR=".";UNICODE;_XKEYCHECK_H;%(PreprocessorDefinitions) Default NotUsing false From 7ec3173462d4738192a22b18dc0cdb6f48c25da7 Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Wed, 9 Jul 2014 15:49:49 +0200 Subject: [PATCH 9/9] Detect invalid URI's for remote provisioning --- coreapi/remote_provisioning.c | 31 +++++++++++----------- tester/rcfiles/marie_remote_invalid_uri_rc | 3 +++ tester/remote_provisioning_tester.c | 9 ++++++- 3 files changed, 26 insertions(+), 17 deletions(-) create mode 100644 tester/rcfiles/marie_remote_invalid_uri_rc diff --git a/coreapi/remote_provisioning.c b/coreapi/remote_provisioning.c index 8c57b47ef..abf884e95 100644 --- a/coreapi/remote_provisioning.c +++ b/coreapi/remote_provisioning.c @@ -110,33 +110,32 @@ static void belle_request_process_auth_requested(void *ctx, belle_sip_auth_event } int linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char *remote_provisioning_uri) { - const char* file_path = strstr(remote_provisioning_uri, "file://"); - if( file_path == remote_provisioning_uri ){ - // We allow for 'local remote-provisioning' in case the file is to be opened from the hard drive - file_path += strlen("file://"); + belle_generic_uri_t *uri=belle_generic_uri_parse(remote_provisioning_uri); + const char* scheme = uri ? belle_generic_uri_get_scheme(uri) : NULL; + + if( scheme && (strcmp(scheme,"file") == 0) ){ + // We allow for 'local remote-provisioning' in case the file is to be opened from the hard drive. + const char* file_path = remote_provisioning_uri + strlen("file://"); // skip scheme return linphone_remote_provisioning_load_file(lc, file_path); - } else { - belle_generic_uri_t *uri=belle_generic_uri_parse(remote_provisioning_uri); + + } else if( scheme && strncmp(scheme, "http", 4) == 0 ) { belle_http_request_listener_callbacks_t belle_request_listener={0}; belle_http_request_listener_t *listener; belle_http_request_t *request; - + belle_request_listener.process_response=belle_request_process_response_event; belle_request_listener.process_auth_requested=belle_request_process_auth_requested; belle_request_listener.process_io_error=belle_request_process_io_error; belle_request_listener.process_timeout=belle_request_process_timeout; - - listener = belle_http_request_listener_create_from_callbacks(&belle_request_listener, lc); - - if (uri==NULL) { - belle_sip_error("Invalid provisioning URI [%s]",remote_provisioning_uri); - return -1; - } + listener = belle_http_request_listener_create_from_callbacks(&belle_request_listener, lc); + request=belle_http_request_create("GET",uri, NULL); - belle_http_provider_send_request(lc->http_provider, request, listener); - return 0; + return belle_http_provider_send_request(lc->http_provider, request, listener); + } else { + ms_error("Invalid provisioning URI [%s] (missing scheme?)",remote_provisioning_uri); + return -1; } } diff --git a/tester/rcfiles/marie_remote_invalid_uri_rc b/tester/rcfiles/marie_remote_invalid_uri_rc new file mode 100644 index 000000000..972c0a0c3 --- /dev/null +++ b/tester/rcfiles/marie_remote_invalid_uri_rc @@ -0,0 +1,3 @@ +[misc] +config-uri=/tmp/lol + diff --git a/tester/remote_provisioning_tester.c b/tester/remote_provisioning_tester.c index 21e9a3f6a..6864b573a 100644 --- a/tester/remote_provisioning_tester.c +++ b/tester/remote_provisioning_tester.c @@ -77,6 +77,12 @@ static void remote_provisioning_invalid(void) { linphone_core_manager_destroy(marie); } +static void remote_provisioning_invalid_uri(void) { + LinphoneCoreManager* marie = linphone_core_manager_new2("marie_remote_invalid_uri_rc", FALSE); + CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphoneConfiguringFailed,1)); + linphone_core_manager_destroy(marie); +} + static void remote_provisioning_default_values(void) { LinphoneProxyConfig *lpc; LinphoneCoreManager* marie = linphone_core_manager_new2("marie_remote_default_values_rc", FALSE); @@ -120,7 +126,8 @@ test_t remote_provisioning_tests[] = { { "Remote provisioning invalid", remote_provisioning_invalid }, { "Remote provisioning transient successful", remote_provisioning_transient }, { "Remote provisioning default values", remote_provisioning_default_values }, - { "Remote provisioning from file", remote_provisioning_file } + { "Remote provisioning from file", remote_provisioning_file }, + { "Remote provisioning invalid URI", remote_provisioning_invalid_uri } }; test_suite_t remote_provisioning_test_suite = {