From 2416116de4023b53871018e381c7f752768b0feb Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 30 Nov 2010 22:12:03 +0100 Subject: [PATCH 1/7] use ms_set_jvm() --- coreapi/linphonecore_jni.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index d52ce4396..fbe8783ee 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include "linphonecore.h" +#include "mediastreamer2/msjava.h" + #ifdef ANDROID #include extern "C" void libmsilbc_init(); @@ -47,6 +49,7 @@ static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_l JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) { #ifdef ANDROID + ms_set_jvm(ajvm); ms_andsnd_set_jvm(ajvm); #ifdef VIDEO_ENABLED ms_andvid_set_jvm(ajvm); From a907941285cd46d94da686d239b7367152b5bc56 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 1 Dec 2010 11:31:04 +0100 Subject: [PATCH 2/7] QVGA support --- java/common/org/linphone/core/VideoSize.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/common/org/linphone/core/VideoSize.java b/java/common/org/linphone/core/VideoSize.java index 1d931624b..98ae8222b 100644 --- a/java/common/org/linphone/core/VideoSize.java +++ b/java/common/org/linphone/core/VideoSize.java @@ -25,6 +25,7 @@ public final class VideoSize { public static final int QCIF = 0; public static final int CIF = 1; public static final int HVGA = 2; + public static final int QVGA = 3; private int width; public int getWidth() {return width;} @@ -47,7 +48,9 @@ public final class VideoSize { case CIF: return new VideoSize(352, 288); case HVGA: - return new VideoSize(320, 480); + return new VideoSize(480, 320); + case QVGA: + return new VideoSize(320, 240); default: return new VideoSize(); // Invalid one } From 6bb9300e7fcd3146f00b13c5cf0ce6389c7892c2 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 1 Dec 2010 11:31:42 +0100 Subject: [PATCH 3/7] Binding to Enable video on LinphoneCall --- coreapi/linphonecore_jni.cc | 4 ++++ java/common/org/linphone/core/LinphoneCall.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index d52ce4396..f9a85b627 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -1015,6 +1015,10 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParams(JNIEnv return (jlong) linphone_call_get_current_params((LinphoneCall*)lc); } +extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){ + linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b); +} + extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){ return (jlong) linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params); } diff --git a/java/common/org/linphone/core/LinphoneCall.java b/java/common/org/linphone/core/LinphoneCall.java index 9a1fe963d..fca8aad57 100644 --- a/java/common/org/linphone/core/LinphoneCall.java +++ b/java/common/org/linphone/core/LinphoneCall.java @@ -155,4 +155,6 @@ public interface LinphoneCall { */ public LinphoneCallParams getCurrentParamsReadOnly(); + public void enableCamera(boolean enabled); + } From a699e2a01aa1a6a487f3c674ee162f6a69cb65af Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 1 Dec 2010 17:01:59 +0100 Subject: [PATCH 4/7] Portrait standard sizes. --- java/common/org/linphone/core/VideoSize.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/java/common/org/linphone/core/VideoSize.java b/java/common/org/linphone/core/VideoSize.java index 98ae8222b..56d97aa55 100644 --- a/java/common/org/linphone/core/VideoSize.java +++ b/java/common/org/linphone/core/VideoSize.java @@ -41,16 +41,16 @@ public final class VideoSize { this.height = height; } - public static final VideoSize createStandard(int code) { + public static final VideoSize createStandard(int code, boolean inverted) { switch (code) { case QCIF: - return new VideoSize(176, 144); + return inverted? new VideoSize(144, 176) : new VideoSize(176, 144); case CIF: - return new VideoSize(352, 288); + return inverted? new VideoSize(288, 352) : new VideoSize(352, 288); case HVGA: - return new VideoSize(480, 320); + return inverted? new VideoSize(320,480) : new VideoSize(480, 320); case QVGA: - return new VideoSize(320, 240); + return inverted? new VideoSize(240, 320) : new VideoSize(320, 240); default: return new VideoSize(); // Invalid one } From 656db4fa166ceeebd3258696a9cbddfbf6a1c024 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 2 Dec 2010 15:39:52 +0100 Subject: [PATCH 5/7] Cleaned Android audio and video filters to use jvm detach on thread exit. --- coreapi/linphonecore_jni.cc | 10 ---------- mediastreamer2 | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index bf134ac6b..077de5f3f 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -26,9 +26,6 @@ extern "C" void libmsilbc_init(); extern "C" void libmsx264_init(); #endif /*ANDROID*/ -extern "C" void ms_andsnd_set_jvm(JavaVM *jvm) ; -extern "C" void ms_andvid_set_jvm(JavaVM *jvm) ; - static JavaVM *jvm=0; #ifdef ANDROID @@ -50,10 +47,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) { #ifdef ANDROID ms_set_jvm(ajvm); - ms_andsnd_set_jvm(ajvm); - #ifdef VIDEO_ENABLED - ms_andvid_set_jvm(ajvm); - #endif /*VIDEO_ENABLED*/ #endif /*ANDROID*/ jvm=ajvm; return JNI_VERSION_1_2; @@ -310,9 +303,6 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL; const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL; LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata); -#ifdef ANDROID - ms_andsnd_set_jvm(jvm); -#endif /*ANDROID*/ #ifdef HAVE_ILBC libmsilbc_init(); // requires an fpu diff --git a/mediastreamer2 b/mediastreamer2 index 28a6e7f22..bc6aeef2e 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 28a6e7f22fbdd93a01676fc9cc47a2605c846d75 +Subproject commit bc6aeef2ee689c5efe5222c2e696bd1f42a4846c From ffb978db26ee2ffacb821fd9cd35e96ac0b04235 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 3 Dec 2010 10:02:29 +0100 Subject: [PATCH 6/7] add proxy support to buddy_status tutorial --- coreapi/help/buddy_status.c | 57 ++++++++++++++++++- .../core/tutorials/TutorialBuddyStatus.java | 4 +- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/coreapi/help/buddy_status.c b/coreapi/help/buddy_status.c index 379122974..6fdb47f40 100644 --- a/coreapi/help/buddy_status.c +++ b/coreapi/help/buddy_status.c @@ -66,19 +66,36 @@ static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *friend, linphone_core_add_friend(lc,friend); /* add this new friend to the buddy list*/ } +/** + * Registration state notification callback + */ +static void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message){ + printf("New registration state %s for user id [%s] at proxy [%s]\n" + ,linphone_registration_state_to_string(cstate) + ,linphone_proxy_config_get_identity(cfg) + ,linphone_proxy_config_get_addr(cfg)); +} LinphoneCore *lc; int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; char* dest_friend=NULL; - + char* identity=NULL; + char* password=NULL; /* takes sip uri identity from the command line arguments */ if (argc>1){ dest_friend=argv[1]; } - + /* takes sip uri identity from the command line arguments */ + if (argc>2){ + identity=argv[2]; + } + /* takes password from the command line arguments */ + if (argc>3){ + password=argv[3]; + } signal(SIGINT,stop); //#define DEBUG #ifdef DEBUG @@ -91,11 +108,47 @@ int main(int argc, char *argv[]){ */ vtable.notify_presence_recv=notify_presence_recv_updated; vtable.new_subscription_request=new_subscription_request; + vtable.registration_state_changed=registration_state_changed; /*just in case sip proxy is used*/ /* Instantiate a LinphoneCore object given the LinphoneCoreVTable */ lc=linphone_core_new(&vtable,NULL,NULL,NULL); + /*sip proxy might be requested*/ + if (identity != NULL) { + /*create proxy config*/ + LinphoneProxyConfig* proxy_cfg = linphone_proxy_config_new(); + /*parse identity*/ + LinphoneAddress *from = linphone_address_new(identity); + if (from==NULL){ + printf("%s not a valid sip uri, must be like sip:toto@sip.linphone.org \n",identity); + goto end; + } + LinphoneAuthInfo *info; + if (password!=NULL){ + info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,NULL,NULL); /*create authentication structure from identity*/ + linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/ + } + + // configure proxy entries + linphone_proxy_config_set_identity(proxy_cfg,identity); /*set identity with user name and domain*/ + linphone_proxy_config_set_server_addr(proxy_cfg,linphone_address_get_domain(from)); /* we assume domain = proxy server address*/ + linphone_proxy_config_enable_register(proxy_cfg,TRUE); /*activate registration for this proxy config*/ + linphone_proxy_config_enable_publish(proxy_cfg,TRUE); /* enable presence satus publication for this proxy*/ + linphone_address_destroy(from); /*release resource*/ + + linphone_core_add_proxy_config(lc,proxy_cfg); /*add proxy config to linphone core*/ + linphone_core_set_default_proxy(lc,proxy_cfg); /*set to default proxy*/ + + + /* Loop until registration status is available */ + do { + linphone_core_iterate(lc); /* first iterate initiates registration */ + ms_usleep(100000); + } + while( running && linphone_proxy_config_get_state(proxy_cfg) == LinphoneRegistrationProgress); + + } LinphoneFriend* my_friend=NULL; if (dest_friend) { diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java index 61855d9e5..1c6c6715c 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java @@ -40,7 +40,9 @@ import org.linphone.core.LinphoneFriend.SubscribePolicy; * from a sip uri identity passed from the command line. *
Argument must be like sip:jehan@sip.linphone.org . * ex budy_list sip:jehan@sip.linphone.org - *
Subscription is cleared on SIGINT + *
+ * Optionnally argument 2 can be registration sip identy.Argument 3 can be passord. + * ex: budy_list sip:jehan@sip.linphone.org sip:myidentity@sip.linphone.org mypassword * * Ported from buddy_status.c * From 8b3112cca81a31e4b35b0c4e9e7c6217fefb5c4c Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 3 Dec 2010 16:11:05 +0100 Subject: [PATCH 7/7] Export video codecs list through JNI. --- coreapi/linphonecore.c | 10 +++++- coreapi/linphonecore_jni.cc | 35 ++++++++++++++++--- .../org/linphone/core/LinphoneCore.java | 3 ++ .../common/org/linphone/core/PayloadType.java | 1 + 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 8d40ac629..55e95a7fe 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3961,13 +3961,21 @@ static PayloadType* find_payload_type_from_list(const char* type, int rate,const const MSList *elem; for(elem=from;elem!=NULL;elem=elem->next){ PayloadType *pt=(PayloadType*)elem->data; - if ((strcmp((char*)type, payload_type_get_mime(pt)) == 0) && rate==pt->clock_rate) { + if ((strcmp((char*)type, payload_type_get_mime(pt)) == 0) && (rate == -1 || rate==pt->clock_rate)) { return pt; } } return NULL; } +static void printCodecs(const MSList* from) { + const MSList *elem; + for(elem=from;elem!=NULL;elem=elem->next){ + PayloadType *pt=(PayloadType*)elem->data; + ms_message(payload_type_get_mime(pt)); + } +} + /** * Get payload type from mime type and clock rate * @ingroup media_parameters diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 077de5f3f..91021d8e1 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -509,6 +509,24 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env->ReleaseStringUTFChars(jmime, mime); return result; } +extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env + ,jobject thiz + ,jlong lc) { + const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc); + int codecsCount = ms_list_size(codecs); + jlongArray jCodecs = env->NewLongArray(codecsCount); + jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL); + + for (int i = 0; i < codecsCount; i++ ) { + jInternalArray[i] = (unsigned long) (codecs->data); + codecs = codecs->next; + } + + env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0); + + return jCodecs; +} + extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env ,jobject thiz ,jlong lc @@ -831,12 +849,9 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE; } -extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env - ,jobject thiz - ,jlong ptr) { - +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 [%s], bitrate [%s]" + char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]" ,payload_type_get_mime(pt) ,payload_type_get_rate(pt) ,payload_type_get_bitrate(pt)); @@ -844,6 +859,16 @@ extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env ms_free(value); return jvalue; } +extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) { + PayloadType* pt = (PayloadType*)ptr; + jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt)); + return jvalue; +} +extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) { + PayloadType* pt = (PayloadType*)ptr; + return payload_type_get_rate(pt); +} + //LinphoneCall extern "C" void Java_org_linphone_core_LinphoneCallImpl_ref(JNIEnv* env ,jobject thiz diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index cbf3bdd34..c3166faa8 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -485,4 +485,7 @@ public interface LinphoneCore { public void setPreferredVideoSize(VideoSize vSize); public VideoSize getPreferredVideoSize(); + + public PayloadType[] listVideoCodecs(); + } diff --git a/java/common/org/linphone/core/PayloadType.java b/java/common/org/linphone/core/PayloadType.java index 59a64699b..952da57d2 100644 --- a/java/common/org/linphone/core/PayloadType.java +++ b/java/common/org/linphone/core/PayloadType.java @@ -20,4 +20,5 @@ package org.linphone.core; public interface PayloadType { + String getMime(); }