From 244edb9b71a5061f2d65eecd73c55bb48355710f Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 15 Nov 2013 17:17:12 +0100 Subject: [PATCH 1/7] MS2: enable webrtc aecm for android x86 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index a3c366b6b..785a5d8f7 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit a3c366b6b5639f5c844ddbcd1d1f205ca7d8c22c +Subproject commit 785a5d8f76c336a51f8a21997e9dcaee669d4ec4 From 82eaf99776603b4f6e8eff8d1836f9184083255e Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Sun, 17 Nov 2013 22:29:59 +0100 Subject: [PATCH 2/7] adapt to new resolver api. --- coreapi/bellesip_sal/sal_impl.c | 10 ++++++---- coreapi/misc.c | 6 +++--- coreapi/private.h | 2 +- include/sal/sal.h | 6 ++++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index b3a7cfc78..f1daaa1bd 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -839,13 +839,15 @@ void sal_enable_test_features(Sal*ctx, bool_t enabled){ ctx->enable_test_features=enabled; } -unsigned long sal_resolve_a(Sal* sal, const char *name, int port, int family, SalResolverCallback cb, void *data){ - return belle_sip_stack_resolve_a(sal->stack,name,port,family,(belle_sip_resolver_callback_t)cb,data); +SalResolverContext * sal_resolve_a(Sal* sal, const char *name, int port, int family, SalResolverCallback cb, void *data){ + return (SalResolverContext*)belle_sip_stack_resolve_a(sal->stack,name,port,family,(belle_sip_resolver_callback_t)cb,data); } -void sal_resolve_cancel(Sal *sal, unsigned long id){ - belle_sip_stack_resolve_cancel(sal->stack,id); +/* +void sal_resolve_cancel(Sal *sal, SalResolverContext* ctx){ + belle_sip_stack_resolve_cancel(sal->stack,ctx); } +*/ void sal_enable_unconditional_answer(Sal *sal,int value) { belle_sip_provider_enable_unconditional_answer(sal->prov,value); diff --git a/coreapi/misc.c b/coreapi/misc.c index 7d9b70b3f..c96fde835 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -633,7 +633,7 @@ static void stun_server_resolved(LinphoneCore *lc, const char *name, struct addr ms_warning("Stun server resolution failed."); } lc->net_conf.stun_addrinfo=addrinfo; - lc->net_conf.stun_res_id=0; + lc->net_conf.stun_res=NULL; } void linphone_core_resolve_stun_server(LinphoneCore *lc){ @@ -642,7 +642,7 @@ void linphone_core_resolve_stun_server(LinphoneCore *lc){ char host[NI_MAXHOST]; int port=3478; linphone_parse_host_port(server,host,sizeof(host),&port); - lc->net_conf.stun_res_id=sal_resolve_a(lc->sal,host,port,AF_UNSPEC,(SalResolverCallback)stun_server_resolved,lc); + lc->net_conf.stun_res=sal_resolve_a(lc->sal,host,port,AF_UNSPEC,(SalResolverCallback)stun_server_resolved,lc); } } @@ -663,7 +663,7 @@ const struct addrinfo *linphone_core_get_stun_server_addrinfo(LinphoneCore *lc){ int wait_ms=0; int wait_limit=1000; linphone_core_resolve_stun_server(lc); - while (!lc->net_conf.stun_addrinfo && lc->net_conf.stun_res_id!=0 && wait_msnet_conf.stun_addrinfo && lc->net_conf.stun_res!=NULL && wait_mssal); ms_usleep(50000); wait_ms+=50; diff --git a/coreapi/private.h b/coreapi/private.h index 20397cefc..69eead0f1 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -498,7 +498,7 @@ typedef struct net_config char *nat_address_ip; /* ip translated from nat_address */ char *stun_server; struct addrinfo *stun_addrinfo; - unsigned long stun_res_id; + SalResolverContext * stun_res; int download_bw; int upload_bw; int mtu; diff --git a/include/sal/sal.h b/include/sal/sal.h index dd6a8f5db..ad230c9ae 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -594,8 +594,10 @@ void sal_get_default_local_ip(Sal *sal, int address_family, char *ip, size_t ipl typedef void (*SalResolverCallback)(void *data, const char *name, struct addrinfo *ai_list); -unsigned long sal_resolve_a(Sal* sal, const char *name, int port, int family, SalResolverCallback cb, void *data); -void sal_resolve_cancel(Sal *sal, unsigned long id); +typedef struct SalResolverContext SalResolverContext; + +SalResolverContext * sal_resolve_a(Sal* sal, const char *name, int port, int family, SalResolverCallback cb, void *data); +//void sal_resolve_cancel(Sal *sal, SalResolverContext *ctx); SalCustomHeader *sal_custom_header_append(SalCustomHeader *ch, const char *name, const char *value); const char *sal_custom_header_find(const SalCustomHeader *ch, const char *name); From d5a091ba0a904fcd0de7fe89b5c2ebaefa8ff0b2 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 18 Nov 2013 11:33:47 +0100 Subject: [PATCH 3/7] Updated README + fix SIP_INFO DTMF crash when trying to send a DTMF while call is ringing --- README | 3 ++- coreapi/bellesip_sal/sal_op_call.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README b/README index 0efd14949..8913f1205 100644 --- a/README +++ b/README @@ -10,6 +10,7 @@ This is Linphone, a free (GPL) video softphone based on the SIP protocol. - you need at least: - belle-sip>=1.0.0 - speex>=1.2.0 (including libspeexdsp part) + - libxml2 + if you want the gtk/glade interface: - libgtk >=2.16.0 @@ -32,7 +33,7 @@ This is Linphone, a free (GPL) video softphone based on the SIP protocol. Here is the command line to get these dependencies installed for Ubuntu && Debian - $ sudo apt-get install libtool intltool libgtk2.0-dev libosip2-dev libexosip2-dev libspeexdsp-dev libavcodec-dev libswscale-dev libx11-dev libvx-dev libgl1-mesa-dev libglew1.6-dev libv4l-dev + $ sudo apt-get install libtool intltool libgtk2.0-dev libosip2-dev libexosip2-dev libspeexdsp-dev libavcodec-dev libswscale-dev libx11-dev libxv-dev libgl1-mesa-dev libglew1.6-dev libv4l-dev libxml2-dev + for optional library $ sudo apt-get install libreadline-dev libgsm1-dev libtheora-dev libsoup2.4-dev libsqlite3-dev libupnp4-dev diff --git a/coreapi/bellesip_sal/sal_op_call.c b/coreapi/bellesip_sal/sal_op_call.c index 8a7037491..08059fb22 100644 --- a/coreapi/bellesip_sal/sal_op_call.c +++ b/coreapi/bellesip_sal/sal_op_call.c @@ -693,7 +693,7 @@ SalMediaDescription * sal_call_get_final_media_description(SalOp *h){ } int sal_call_send_dtmf(SalOp *h, char dtmf){ - if (h->dialog){ + if (h->dialog && (belle_sip_dialog_get_state(h->dialog) == BELLE_SIP_DIALOG_CONFIRMED || belle_sip_dialog_get_state(h->dialog) == BELLE_SIP_DIALOG_EARLY)){ belle_sip_request_t *req=belle_sip_dialog_create_queued_request(h->dialog,"INFO"); if (req){ int bodylen; From c75c44d56bcaa5532b492ff690395ba417e7fd18 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 18 Nov 2013 11:35:14 +0100 Subject: [PATCH 4/7] update README for mac --- README.macos | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.macos b/README.macos index 87817ac54..1713b7968 100644 --- a/README.macos +++ b/README.macos @@ -7,9 +7,11 @@ You need: - Macports: http://www.macports.org/ Download and install macports using its user friendly installer. -- In order to enable generation of bundle for multiple macos version it is recommended to edit /opt/local/etc/macports/macports.conf to add the - following line: - macosx_deployment_target 10.6 +- In order to enable generation of bundle for multiple macos version and 32 bit processors, it is recommended to: + 1) edit /opt/local/etc/macports/macports.conf to add the following line: + macosx_deployment_target 10.6 + 2) edit /opt/local/etc/macports/variants.conf to add the following line: + +universal - Install build time dependencies $ sudo port install automake autoconf libtool intltool @@ -34,7 +36,16 @@ You need: The softwares below need to be compiled manually. To ensure compatibility with multiple mac os version it is recommended to do: $ export MACOSX_DEPLOYMENT_TARGET=10.6 + $ export CFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.5" + $ export OBJCFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.5" + $ export CXXFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.5" + $ export LDFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.5" +- Install polarssl (encryption library used by belle-sip) + $ git clone git://git.linphone.org/polarssl.git -b linphone + $ cd polarssl + $ ./autogen.sh && ./configure --prefix=/opt/local && make + $ sudo make install - Install belle-sip (sip stack) $ git clone git://git.linphone.org/belle-sip.git From 5ad51122ba07d8600ba601cfb92f0e03e1862c88 Mon Sep 17 00:00:00 2001 From: Margaux Clerc Date: Mon, 18 Nov 2013 16:28:32 +0100 Subject: [PATCH 5/7] Fix compilation for Macos 32bit --- tools/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Makefile.am b/tools/Makefile.am index 6fa7fadb4..5ef2535ad 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -12,7 +12,7 @@ COMMON_CFLAGS=\ $(LIBXML2_CFLAGS) #-fpermissive to workaround a g++ bug on macos 32bit SDK. -AM_CXXFLAGS=$(LIBXML2_CFLAGS) $(STRICT_OPTIONS) -fpermissive +AM_CXXFLAGS=$(LIBXML2_CFLAGS) -fpermissive $(STRICT_OPTIONS) EXTRA_DIST=xml2lpc_jni.cc lpc2xml_jni.cc From 2f415bc619c758155b77aef31f0d3392717c7496 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 18 Nov 2013 22:23:41 +0100 Subject: [PATCH 6/7] modify JNI to allow passing raw data in LinphoneContent. --- coreapi/linphonecore_jni.cc | 67 ++++++++++++------- .../org/linphone/core/LinphoneContent.java | 16 +++++ .../linphone/core/LinphoneCoreFactory.java | 7 +- .../linphone/core/LinphoneContentImpl.java | 31 +++++++-- .../core/LinphoneCoreFactoryImpl.java | 8 ++- .../org/linphone/core/LinphoneCoreImpl.java | 10 +-- .../org/linphone/core/LinphoneEventImpl.java | 12 ++-- 7 files changed, 110 insertions(+), 41 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index a0e212c26..fa583f144 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -3102,7 +3102,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getUpnpExternalIpaddr * Signature: (JJLjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object; */ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_subscribe(JNIEnv *env, jobject jcore, jlong coreptr, jlong addrptr, - jstring jevname, jint expires, jstring jtype, jstring jsubtype, jstring jdata){ + jstring jevname, jint expires, jstring jtype, jstring jsubtype, jbyteArray jdata, jstring jencoding){ LinphoneCore *lc=(LinphoneCore*)coreptr; LinphoneAddress *addr=(LinphoneAddress*)addrptr; LinphoneContent content={0}; @@ -3114,14 +3114,16 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_subscribe(JNIE if (jtype){ content.type=(char*)env->GetStringUTFChars(jtype,NULL); content.subtype=(char*)env->GetStringUTFChars(jsubtype,NULL); - content.data=(void*)env->GetStringUTFChars(jdata,NULL); - content.size=strlen((char*)content.data); + content.encoding=jencoding ? (char*)env->GetStringUTFChars(jsubtype,NULL) : NULL; + content.data=(void*)env->GetByteArrayElements(jdata,NULL); + content.size=env->GetArrayLength(jdata); } ev=linphone_core_subscribe(lc,addr,evname,expires,content.type ? &content : NULL); if (jtype){ env->ReleaseStringUTFChars(jtype,content.type); env->ReleaseStringUTFChars(jsubtype,content.subtype); - env->ReleaseStringUTFChars(jdata,(char*)content.data); + if (jencoding) env->ReleaseStringUTFChars(jencoding,content.encoding); + env->ReleaseByteArrayElements(jdata,(jbyte*)content.data,JNI_ABORT); } env->ReleaseStringUTFChars(jevname,evname); if (ev){ @@ -3136,7 +3138,7 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_subscribe(JNIE * Signature: (JJLjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object; */ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_publish(JNIEnv *env, jobject jobj, jlong coreptr, jlong addrptr, jstring jevname, jint expires, - jstring jtype, jstring jsubtype, jstring jdata){ + jstring jtype, jstring jsubtype, jbyteArray jdata, jstring jencoding){ LinphoneCore *lc=(LinphoneCore*)coreptr; LinphoneAddress *addr=(LinphoneAddress*)addrptr; LinphoneContent content={0}; @@ -3148,14 +3150,16 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_publish(JNIEnv if (jtype){ content.type=(char*)env->GetStringUTFChars(jtype,NULL); content.subtype=(char*)env->GetStringUTFChars(jsubtype,NULL); - content.data=(void*)env->GetStringUTFChars(jdata,NULL); - content.size=strlen((char*)content.data); + content.encoding=jencoding ? (char*)env->GetStringUTFChars(jsubtype,NULL) : NULL; + content.data=(void*)env->GetByteArrayElements(jdata,NULL); + content.size=env->GetArrayLength(jdata); } ev=linphone_core_publish(lc,addr,evname,expires,content.type ? &content : NULL); if (jtype){ env->ReleaseStringUTFChars(jtype,content.type); env->ReleaseStringUTFChars(jsubtype,content.subtype); - env->ReleaseStringUTFChars(jdata,(char*)content.data); + if (jencoding) env->ReleaseStringUTFChars(jencoding,content.encoding); + env->ReleaseByteArrayElements(jdata,(jbyte*)content.data,JNI_ABORT); } env->ReleaseStringUTFChars(jevname,evname); if (ev){ @@ -3295,15 +3299,22 @@ extern "C" jintArray Java_org_linphone_core_LpConfigImpl_getIntRange(JNIEnv *env static jobject create_java_linphone_content(JNIEnv *env, const LinphoneContent *content){ jclass contentClass; jmethodID ctor; - jstring jtype, jsubtype, jdata; + jstring jtype, jsubtype, jencoding; + jbyteArray jdata=NULL; contentClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneContentImpl")); - ctor = env->GetMethodID(contentClass,"", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); + ctor = env->GetMethodID(contentClass,"", "(Ljava/lang/String;Ljava/lang/String;[BLjava/lang/String;)V"); jtype=env->NewStringUTF(content->type); jsubtype=env->NewStringUTF(content->subtype); - jdata=content->data ? env->NewStringUTF((const char*)content->data) : NULL; - jobject jobj=env->NewObject(contentClass,ctor,jtype, jsubtype, jdata); + jencoding=content->encoding ? env->NewStringUTF(content->encoding) : NULL; + + if (content->data){ + jdata=env->NewByteArray(content->size); + env->SetByteArrayRegion(jdata,0,content->size,(jbyte*)content->data); + } + + jobject jobj=env->NewObject(contentClass,ctor,jtype, jsubtype, jdata,jencoding); env->DeleteGlobalRef(contentClass); return jobj; } @@ -3327,7 +3338,7 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_getCont * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_setContent(JNIEnv *env, jobject jobj, jlong infoptr, jstring jtype, jstring jsubtype, jstring jdata){ - LinphoneContent content; + LinphoneContent content={0}; content.type=(char*)env->GetStringUTFChars(jtype,NULL); content.subtype=(char*)env->GetStringUTFChars(jsubtype,NULL); @@ -3428,7 +3439,7 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_denySubscription * Method: notify * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_notify(JNIEnv *env, jobject jobj, jlong evptr, jstring jtype, jstring jsubtype, jstring jdata){ +JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_notify(JNIEnv *env, jobject jobj, jlong evptr, jstring jtype, jstring jsubtype, jbyteArray jdata, jstring jencoding){ LinphoneContent content={0}; LinphoneEvent *ev=(LinphoneEvent*)evptr; jint err; @@ -3436,8 +3447,9 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_notify(JNIEnv *e if (jtype){ content.type=(char*)env->GetStringUTFChars(jtype,NULL); content.subtype=(char*)env->GetStringUTFChars(jsubtype,NULL); - content.data=(void*)env->GetStringUTFChars(jdata,NULL); - content.size=strlen((char*)content.data); + content.encoding=jencoding ? (char*)env->GetStringUTFChars(jsubtype,NULL) : NULL; + content.data=(void*)env->GetByteArrayElements(jdata,NULL); + content.size=env->GetArrayLength(jdata); } err=linphone_event_notify(ev,content.type ? &content : NULL); @@ -3445,7 +3457,8 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_notify(JNIEnv *e if (jtype){ env->ReleaseStringUTFChars(jtype,content.type); env->ReleaseStringUTFChars(jsubtype,content.subtype); - env->ReleaseStringUTFChars(jdata,(char*)content.data); + if (jencoding) env->ReleaseStringUTFChars(jencoding,content.encoding); + env->ReleaseByteArrayElements(jdata,(jbyte*)content.data,JNI_ABORT); } return err; } @@ -3455,7 +3468,7 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_notify(JNIEnv *e * Method: updateSubscribe * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_updateSubscribe(JNIEnv *env, jobject jobj, jlong evptr, jstring jtype, jstring jsubtype, jstring jdata){ +JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_updateSubscribe(JNIEnv *env, jobject jobj, jlong evptr, jstring jtype, jstring jsubtype, jbyteArray jdata, jstring jencoding){ LinphoneContent content={0}; LinphoneEvent *ev=(LinphoneEvent*)evptr; jint err; @@ -3463,8 +3476,9 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_updateSubscribe( if (jtype){ content.type=(char*)env->GetStringUTFChars(jtype,NULL); content.subtype=(char*)env->GetStringUTFChars(jsubtype,NULL); - content.data=(void*)env->GetStringUTFChars(jdata,NULL); - content.size=strlen((char*)content.data); + content.encoding=jencoding ? (char*)env->GetStringUTFChars(jsubtype,NULL) : NULL; + content.data=(void*)env->GetByteArrayElements(jdata,NULL); + content.size=env->GetArrayLength(jdata); } err=linphone_event_update_subscribe(ev,content.type ? &content : NULL); @@ -3472,7 +3486,8 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_updateSubscribe( if (jtype){ env->ReleaseStringUTFChars(jtype,content.type); env->ReleaseStringUTFChars(jsubtype,content.subtype); - env->ReleaseStringUTFChars(jdata,(char*)content.data); + if (jencoding) env->ReleaseStringUTFChars(jencoding,content.encoding); + env->ReleaseByteArrayElements(jdata,(jbyte*)content.data,JNI_ABORT); } return err; } @@ -3482,7 +3497,7 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_updateSubscribe( * Method: updatePublish * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_updatePublish(JNIEnv *env, jobject jobj, jlong evptr, jstring jtype, jstring jsubtype, jstring jdata){ +JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_updatePublish(JNIEnv *env, jobject jobj, jlong evptr, jstring jtype, jstring jsubtype, jbyteArray jdata, jstring jencoding){ LinphoneContent content={0}; LinphoneEvent *ev=(LinphoneEvent*)evptr; jint err; @@ -3490,8 +3505,9 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_updatePublish(JN if (jtype){ content.type=(char*)env->GetStringUTFChars(jtype,NULL); content.subtype=(char*)env->GetStringUTFChars(jsubtype,NULL); - content.data=(void*)env->GetStringUTFChars(jdata,NULL); - content.size=strlen((char*)content.data); + content.encoding=jencoding ? (char*)env->GetStringUTFChars(jsubtype,NULL) : NULL; + content.data=(void*)env->GetByteArrayElements(jdata,NULL); + content.size=env->GetArrayLength(jdata); } err=linphone_event_update_publish(ev,content.type ? &content : NULL); @@ -3499,7 +3515,8 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_updatePublish(JN if (jtype){ env->ReleaseStringUTFChars(jtype,content.type); env->ReleaseStringUTFChars(jsubtype,content.subtype); - env->ReleaseStringUTFChars(jdata,(char*)content.data); + if (jencoding) env->ReleaseStringUTFChars(jencoding,content.encoding); + env->ReleaseByteArrayElements(jdata,(jbyte*)content.data,JNI_ABORT); } return err; } diff --git a/java/common/org/linphone/core/LinphoneContent.java b/java/common/org/linphone/core/LinphoneContent.java index b3811006f..10c6e3dc9 100644 --- a/java/common/org/linphone/core/LinphoneContent.java +++ b/java/common/org/linphone/core/LinphoneContent.java @@ -17,11 +17,19 @@ public interface LinphoneContent { * @return the subtype */ String getSubtype(); + /** + * Get the encoding applied to the data, can be null if no encoding. + **/ + String getEncoding(); /** * Get the data as a string. * @return the data */ String getDataAsString(); + /** + * Get the data as a byte array. + **/ + byte [] getData(); /** * Get the data size. * @return the data size. @@ -38,9 +46,17 @@ public interface LinphoneContent { * @param subtype the subtype */ void setSubtype(String subtype); + /** + * Set the encoding applied to the data, can be null if no encoding. + **/ + void setEncoding(String encoding); /** * Set the data, supplied as String. * @param data the data */ void setStringData(String data); + /** + * Set the data, as a byte buffer. + **/ + void setData(byte data[]); } diff --git a/java/common/org/linphone/core/LinphoneCoreFactory.java b/java/common/org/linphone/core/LinphoneCoreFactory.java index dfbeb883b..95cfdeaf0 100644 --- a/java/common/org/linphone/core/LinphoneCoreFactory.java +++ b/java/common/org/linphone/core/LinphoneCoreFactory.java @@ -108,10 +108,15 @@ abstract public class LinphoneCoreFactory { abstract public LinphoneFriend createLinphoneFriend(); /** - * Create a LinphoneContent object + * Create a LinphoneContent object from string data. */ abstract public LinphoneContent createLinphoneContent(String type, String subType, String data); + /** + * Create a LinphoneContent object from byte array. + */ + abstract public LinphoneContent createLinphoneContent(String type, String subType,byte [] data, String encoding); + /** * Create a PresenceActivity object. */ diff --git a/java/impl/org/linphone/core/LinphoneContentImpl.java b/java/impl/org/linphone/core/LinphoneContentImpl.java index f74711042..b12e6580f 100644 --- a/java/impl/org/linphone/core/LinphoneContentImpl.java +++ b/java/impl/org/linphone/core/LinphoneContentImpl.java @@ -1,11 +1,14 @@ package org.linphone.core; public class LinphoneContentImpl implements LinphoneContent { - private String mType, mSubtype, mData; - public LinphoneContentImpl(String type, String subtype, String data){ + private String mType, mSubtype, mEncoding; + private byte[] mData; + + public LinphoneContentImpl(String type, String subtype, byte data[], String encoding ){ mType=type; mSubtype=subtype; mData=data; + mEncoding=encoding; } @Override @@ -20,12 +23,12 @@ public class LinphoneContentImpl implements LinphoneContent { @Override public String getDataAsString() { - return mData; + return new String(mData); } @Override public int getSize() { - return mData.length(); + return mData.length; } @Override @@ -40,7 +43,27 @@ public class LinphoneContentImpl implements LinphoneContent { @Override public void setStringData(String data) { + mData=data.getBytes(); + } + + @Override + public void setData(byte data[]){ mData=data; } + @Override + public String getEncoding() { + return mEncoding; + } + + @Override + public byte[] getData() { + return mData; + } + + @Override + public void setEncoding(String encoding) { + mEncoding=encoding; + } + } diff --git a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java index d2f635d4d..e526b47b5 100644 --- a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java @@ -151,10 +151,16 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { return new LinphoneAuthInfoImpl(username, userid, passwd, ha1, realm, domain); } + @Override + public LinphoneContent createLinphoneContent(String type, String subType, + byte [] data, String encoding) { + return new LinphoneContentImpl(type,subType,data,encoding); + } + @Override public LinphoneContent createLinphoneContent(String type, String subType, String data) { - return new LinphoneContentImpl(type,subType,data); + return new LinphoneContentImpl(type,subType,data.getBytes(),null); } @Override diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index f5740ff41..420547e57 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -1028,19 +1028,21 @@ class LinphoneCoreImpl implements LinphoneCore { return new LinphoneInfoMessageImpl(createInfoMessage(nativePtr)); } - private native Object subscribe(long coreptr, long addrptr, String eventname, int expires, String type, String subtype, String data); + private native Object subscribe(long coreptr, long addrptr, String eventname, int expires, String type, String subtype, byte data [], String encoding); @Override public LinphoneEvent subscribe(LinphoneAddress resource, String eventname, int expires, LinphoneContent content) { return (LinphoneEvent)subscribe(nativePtr, ((LinphoneAddressImpl)resource).nativePtr, eventname, expires, - content!=null ? content.getType() : null, content!=null ? content.getSubtype() : null, content!=null ? content.getDataAsString() : null); + content!=null ? content.getType() : null, content!=null ? content.getSubtype() : null, content!=null ? content.getData() : null, + content!=null ? content.getEncoding() : null); } - private native Object publish(long coreptr, long addrptr, String eventname, int expires, String type, String subtype, String data); + private native Object publish(long coreptr, long addrptr, String eventname, int expires, String type, String subtype, byte data [], String encoding); @Override public LinphoneEvent publish(LinphoneAddress resource, String eventname, int expires, LinphoneContent content) { return (LinphoneEvent)publish(nativePtr, ((LinphoneAddressImpl)resource).nativePtr, eventname, expires, - content!=null ? content.getType() : null, content!=null ? content.getSubtype() : null, content!=null ? content.getDataAsString() : null); + content!=null ? content.getType() : null, content!=null ? content.getSubtype() : null, content!=null ? content.getData() : null, + content!=null ? content.getEncoding() : null); } public void setChatDatabasePath(String path) { diff --git a/java/impl/org/linphone/core/LinphoneEventImpl.java b/java/impl/org/linphone/core/LinphoneEventImpl.java index ab201af99..9890f7cdf 100644 --- a/java/impl/org/linphone/core/LinphoneEventImpl.java +++ b/java/impl/org/linphone/core/LinphoneEventImpl.java @@ -26,22 +26,22 @@ public class LinphoneEventImpl implements LinphoneEvent { denySubscription(mNativePtr,reason.mValue); } - private native int notify(long nativeptr, String type, String subtype, String data); + private native int notify(long nativeptr, String type, String subtype, byte data[], String encoding); @Override public void notify(LinphoneContent content) { - notify(mNativePtr,content.getType(),content.getSubtype(),content.getDataAsString()); + notify(mNativePtr,content.getType(),content.getSubtype(),content.getData(),content.getEncoding()); } - private native int updateSubscribe(long nativePtr, String type, String subtype, String data); + private native int updateSubscribe(long nativePtr, String type, String subtype, byte data[], String encoding); @Override public void updateSubscribe(LinphoneContent content) { - updateSubscribe(mNativePtr,content.getType(), content.getSubtype(),content.getDataAsString()); + updateSubscribe(mNativePtr,content.getType(), content.getSubtype(),content.getData(),content.getEncoding()); } - private native int updatePublish(long nativePtr, String type, String subtype, String data); + private native int updatePublish(long nativePtr, String type, String subtype, byte data[], String encoding); @Override public void updatePublish(LinphoneContent content) { - updatePublish(mNativePtr,content.getType(), content.getSubtype(),content.getDataAsString()); + updatePublish(mNativePtr,content.getType(), content.getSubtype(),content.getData(),content.getEncoding()); } private native int terminate(long nativePtr); From df6e200585a62d95034032eef996fedf5a3f2015 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 19 Nov 2013 12:04:06 +0100 Subject: [PATCH 7/7] fix leaked streams in case of incoming call declined because media incompatible --- coreapi/linphonecall.c | 1 + coreapi/linphonecore.c | 1 + 2 files changed, 2 insertions(+) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 7c24bbbd4..6786209cd 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -762,6 +762,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const static void linphone_call_destroy(LinphoneCall *obj) { ms_message("Call [%p] freed.",obj); + linphone_call_stop_media_streams(obj); #ifdef BUILD_UPNP linphone_call_delete_upnp_session(obj); #endif //BUILD_UPNP diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index df4be1090..fdf54e745 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2852,6 +2852,7 @@ void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call){ if (md){ if (sal_media_description_empty(md) || linphone_core_incompatible_security(lc,md)){ sal_call_decline(call->op,SalReasonMedia,NULL); + linphone_call_stop_media_streams(call); linphone_core_del_call(lc,call); linphone_call_unref(call); return;