From b285efeb04f9393e4c9b066b1bf1a7b5ab2b4dd6 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 25 Feb 2015 14:55:51 +0100 Subject: [PATCH 1/8] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 938c6e4ca..6a3223bc1 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 938c6e4cade5c09e6cfa5a5e9189007f8323f3d0 +Subproject commit 6a3223bc1dba6060daae575da86496050a24fb95 From baf75dd419ea334835309e5906c9565c22563f1e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 25 Feb 2015 14:55:59 +0100 Subject: [PATCH 2/8] Add JNI wrapper to set audio/video codecs and to enable DNS SRV. --- coreapi/linphonecore_jni.cc | 30 +++++++++++++++++++ .../org/linphone/core/LinphoneCore.java | 26 ++++++++++++++-- .../org/linphone/core/LinphoneCoreImpl.java | 29 +++++++++++++++++- .../org/linphone/core/PayloadTypeImpl.java | 2 +- 4 files changed, 82 insertions(+), 5 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index e9fc0b787..2642451fa 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -1639,6 +1639,18 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTy return jCodecs; } +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setVideoCodecs(JNIEnv *env, jobject thiz, jlong lc, jlongArray jCodecs) { + MSList *pts = NULL; + int codecsCount = env->GetArrayLength(jCodecs); + jlong *codecs = env->GetLongArrayElements(jCodecs, NULL); + for (int i = 0; i < codecsCount; i++) { + PayloadType *pt = (PayloadType *)codecs[i]; + ms_list_append(pts, pt); + } + linphone_core_set_video_codecs((LinphoneCore *)lc, pts); + env->ReleaseLongArrayElements(jCodecs, codecs, 0); +} + extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env ,jobject thiz ,jlong lc) { @@ -1657,6 +1669,18 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTy return jCodecs; } +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setAudioCodecs(JNIEnv *env, jobject thiz, jlong lc, jlongArray jCodecs) { + MSList *pts = NULL; + int codecsCount = env->GetArrayLength(jCodecs); + jlong *codecs = env->GetLongArrayElements(jCodecs, NULL); + for (int i = 0; i < codecsCount; i++) { + PayloadType *pt = (PayloadType *)codecs[i]; + pts = ms_list_append(pts, pt); + } + linphone_core_set_audio_codecs((LinphoneCore *)lc, pts); + env->ReleaseLongArrayElements(jCodecs, codecs, 0); +} + extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env ,jobject thiz ,jlong lc @@ -5861,4 +5885,10 @@ extern "C" jboolean JNICALL Java_org_linphone_core_LinphoneCoreImpl_videoMultica return linphone_core_video_multicast_enabled((LinphoneCore*)ptr); } +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_enableDnsSrv(JNIEnv *env, jobject thiz, jlong lc, jboolean yesno) { + linphone_core_enable_dns_srv((LinphoneCore *)lc, yesno); +} +JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneCoreImpl_dnsSrvEnabled(JNIEnv *env, jobject thiz, jlong lc) { + return linphone_core_dns_srv_enabled((LinphoneCore *)lc); +} diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 495f6642a..62d6de6e8 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -1127,11 +1127,21 @@ public interface LinphoneCore { * @return */ PayloadType[] getAudioCodecs(); + /** + * Set the list of audio codecs. + * @param codecs List of PayloadType objects + */ + void setAudioCodecs(PayloadType[] codecs); /** * Returns the currently supported video codecs, as PayloadType elements * @return */ PayloadType[] getVideoCodecs(); + /** + * Set the list of video codecs. + * @param codecs List of PayloadType objects + */ + void setVideoCodecs(PayloadType[] codecs); /** * enable signaling keep alive. small udp packet sent periodically to keep udp NAT association */ @@ -2000,7 +2010,17 @@ public interface LinphoneCore { * @return true if subsequent calls will propose multicast ip set by {@link linphone_core_set_video_multicast_addr} **/ public boolean videoMulticastEnabled(); - - - + + /** + * Enable or disable DNS SRV resolution. + * @param yesno true to enable DNS SRV resolution, false to disable it. + */ + public void enableDnsSrv(boolean yesno); + + /** + * Tells whether DNS SRV resolution is enabled. + * @return true if DNS SRV resolution is enabled, false if disabled. + */ + public boolean dnsSrvEnabled(); + } diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 8595ff079..9586ea371 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -114,12 +114,14 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setRing(long nativePtr, String path); private native String getRing(long nativePtr); private native void setRootCA(long nativePtr, String path); - private native void setRingback(long nativePtr, String path); + private native void setRingback(long nativePtr, String path); private native long[] listVideoPayloadTypes(long nativePtr); + private native void setVideoCodecs(long nativePtr, long[] codecs); 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); + private native void setAudioCodecs(long nativePtr, long[] codecs); private native void enableKeepAlive(long nativePtr,boolean enable); private native boolean isKeepAliveEnabled(long nativePtr); private native int startEchoCalibration(long nativePtr,Object data); @@ -560,6 +562,13 @@ class LinphoneCoreImpl implements LinphoneCore { return codecs; } + public synchronized void setVideoCodecs(PayloadType[] codecs) { + long[] typesPtr = new long[codecs.length]; + for (int i=0; i < codecs.length; i++) { + typesPtr[i] = ((PayloadTypeImpl)codecs[i]).nativePtr; + } + setVideoCodecs(nativePtr, typesPtr); + } public synchronized PayloadType[] getAudioCodecs() { long[] typesPtr = listAudioPayloadTypes(nativePtr); if (typesPtr == null) return null; @@ -572,6 +581,13 @@ class LinphoneCoreImpl implements LinphoneCore { return codecs; } + public synchronized void setAudioCodecs(PayloadType[] codecs) { + long[] typesPtr = new long[codecs.length]; + for (int i=0; i < codecs.length; i++) { + typesPtr[i] = ((PayloadTypeImpl)codecs[i]).nativePtr; + } + setAudioCodecs(nativePtr, typesPtr); + } public synchronized boolean isNetworkReachable() { return isNetworkStateReachable(nativePtr); } @@ -1446,4 +1462,15 @@ class LinphoneCoreImpl implements LinphoneCore { public boolean videoMulticastEnabled() { return videoMulticastEnabled(nativePtr); } + + private native void enableDnsSrv(long ptr, boolean yesno); + @Override + public void enableDnsSrv(boolean yesno) { + enableDnsSrv(nativePtr, yesno); + } + private native boolean dnsSrvEnabled(long ptr); + @Override + public boolean dnsSrvEnabled() { + return dnsSrvEnabled(nativePtr); + } } diff --git a/java/impl/org/linphone/core/PayloadTypeImpl.java b/java/impl/org/linphone/core/PayloadTypeImpl.java index 436cd3f30..b882f1ecb 100644 --- a/java/impl/org/linphone/core/PayloadTypeImpl.java +++ b/java/impl/org/linphone/core/PayloadTypeImpl.java @@ -21,7 +21,7 @@ package org.linphone.core; class PayloadTypeImpl implements PayloadType { - protected final long nativePtr; + public final long nativePtr; private native String toString(long ptr); private native String getMime(long ptr); From 7a288ef21c854d2ba4a6f2170d74e62d5f088fee Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 25 Feb 2015 15:52:11 +0100 Subject: [PATCH 3/8] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 6a3223bc1..3e04d7979 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 6a3223bc1dba6060daae575da86496050a24fb95 +Subproject commit 3e04d797963618ea8db5226f0519b2f8074dbc70 From cde2d55d840fc3980f21c9c1a474fdb2704d0437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Wed, 25 Feb 2015 16:57:16 +0100 Subject: [PATCH 4/8] Fix charset issue with sqlite3_open() sqlite3_open() requires that the path is encoded into UTF-8 --- configure.ac | 3 +++ coreapi/message_storage.c | 40 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d696bf31b..f428f8dad 100644 --- a/configure.ac +++ b/configure.ac @@ -852,6 +852,9 @@ if test x$enable_msg_storage != xfalse; then fi if test "$found_sqlite" = "yes"; then SQLITE3_CFLAGS+="-DMSG_STORAGE_ENABLED" + if test "$build_macos" = "yes" -o "$ios_found"="yes"; then + SQLITE3_LIBS+=" -liconv" + fi enable_msg_storage=true else if test x$enable_msg_storage = xtrue; then diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 91fd8e333..d42d19236 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -25,6 +25,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define PRIu64 "I64u" #endif +#ifndef WIN32 +#include +#include +#include +#else +#include +#endif + +#define MAX_PATH_SIZE 1024 + #include "sqlite3.h" static ORTP_INLINE LinphoneChatMessage* get_transient_message(LinphoneChatRoom* cr, unsigned int storage_id){ @@ -579,6 +589,34 @@ void linphone_core_message_storage_set_debug(LinphoneCore *lc, bool_t debug){ } } +static int _linphone_sqlite3_open(const char *db_file, sqlite3 **db) { +#ifdef ANDROID + return sqlite3_open(db_file, db); +#elif defined(WIN32) + int ret; + wchar_t db_file_utf16[MAX_PATH_SIZE]; + ret = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, db_file, MAX_PATH_SIZE, db_file_utf16, MAX_PATH_SIZE); + if(ret == 0) db_file_utf16[0] = '\0'; + return sqlite3_open16(db_file_utf16, db); +#else + char db_file_locale[MAX_PATH_SIZE] = {'\0'}; + char db_file_utf8[MAX_PATH_SIZE] = ""; + char *inbuf=db_file_locale, *outbuf=db_file_utf8; + size_t inbyteleft = MAX_PATH_SIZE, outbyteleft = MAX_PATH_SIZE; + iconv_t cb; + + strncpy(db_file_locale, db_file, MAX_PATH_SIZE-1); + cb = iconv_open("UTF-8", nl_langinfo(CODESET)); + if(cb != (iconv_t)-1) { + int ret; + ret = iconv(cb, &inbuf, &inbyteleft, &outbuf, &outbyteleft); + if(ret == -1) db_file_utf8[0] = '\0'; + iconv_close(cb); + } + return sqlite3_open(db_file_utf8, db); +#endif +} + void linphone_core_message_storage_init(LinphoneCore *lc){ int ret; const char *errmsg; @@ -586,7 +624,7 @@ void linphone_core_message_storage_init(LinphoneCore *lc){ linphone_core_message_storage_close(lc); - ret=sqlite3_open(lc->chat_db_file,&db); + ret=_linphone_sqlite3_open(lc->chat_db_file,&db); if(ret != SQLITE_OK) { errmsg=sqlite3_errmsg(db); ms_error("Error in the opening: %s.\n", errmsg); From 76350ee45b904cb5601a62204f8e676f7ec12159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Wed, 25 Feb 2015 17:15:46 +0100 Subject: [PATCH 5/8] Fix configure issue --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f428f8dad..92b8fe3dd 100644 --- a/configure.ac +++ b/configure.ac @@ -852,7 +852,7 @@ if test x$enable_msg_storage != xfalse; then fi if test "$found_sqlite" = "yes"; then SQLITE3_CFLAGS+="-DMSG_STORAGE_ENABLED" - if test "$build_macos" = "yes" -o "$ios_found"="yes"; then + if test "$build_macos" = "yes" -o "$ios_found" = "yes"; then SQLITE3_LIBS+=" -liconv" fi enable_msg_storage=true From ea39673fff59fcfc6d3b1795e5a281cf24445963 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 25 Feb 2015 21:40:53 +0100 Subject: [PATCH 6/8] repair build --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index 3e04d7979..e35a1e71b 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 3e04d797963618ea8db5226f0519b2f8074dbc70 +Subproject commit e35a1e71bdc64bc914b866b1a66815d5e47f8a01 diff --git a/oRTP b/oRTP index d515df047..496b5b1fd 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit d515df047678da3777b5e4691dc069c6837f77bf +Subproject commit 496b5b1fd0053bf94e5e0fcecf9cd43713820ca1 From 0d4048dbdfbdf309264f9e28217ffde5faccef1e Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 25 Feb 2015 21:55:39 +0100 Subject: [PATCH 7/8] fix android compilation --- coreapi/message_storage.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index d42d19236..cfee1c873 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -26,9 +26,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #ifndef WIN32 -#include -#include -#include +#ifndef ANDROID +# include +# include +# include +#endif #else #include #endif From 9640d3431a503782bf851dac3a3dbd1fc72f0e78 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 27 Feb 2015 11:04:00 +0100 Subject: [PATCH 8/8] robustize test --- tester/call_tester.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/tester/call_tester.c b/tester/call_tester.c index 7171e22b9..dee0d259a 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -2966,31 +2966,33 @@ static void call_redirect(void){ static void call_established_with_rejected_reinvite_with_error(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); + bool_t call_ok=TRUE; - CU_ASSERT_TRUE(call(pauline,marie)); + CU_ASSERT_TRUE((call_ok=call(pauline,marie))); + + if (call_ok){ + linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMA",8000,1),TRUE); /*add PCMA*/ - linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMA",8000,1),TRUE); /*add PCMA*/ + sal_enable_unconditional_answer(marie->lc->sal,TRUE); + + linphone_core_update_call( pauline->lc + ,linphone_core_get_current_call(pauline->lc) + ,linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc))); - sal_enable_unconditional_answer(marie->lc->sal,TRUE); + CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); - linphone_core_update_call( pauline->lc - ,linphone_core_get_current_call(pauline->lc) - ,linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc))); + CU_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(pauline->lc)),LinphoneReasonTemporarilyUnavailable); /*might be change later*/ + CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning,1); + check_call_state(pauline,LinphoneCallStreamsRunning); + check_call_state(marie,LinphoneCallStreamsRunning); - CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); - - CU_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(pauline->lc)),LinphoneReasonTemporarilyUnavailable); /*might be change later*/ - - CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning,1); - check_call_state(pauline,LinphoneCallStreamsRunning); - check_call_state(marie,LinphoneCallStreamsRunning); - - /*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)); + /*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);