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 6aa3f51ad..79f541ac5 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 * 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 b6d2d89ee..951284375 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -18,15 +18,14 @@ 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(); 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 @@ -47,10 +46,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_andsnd_set_jvm(ajvm); - #ifdef VIDEO_ENABLED - ms_andvid_set_jvm(ajvm); - #endif /*VIDEO_ENABLED*/ + ms_set_jvm(ajvm); #endif /*ANDROID*/ jvm=ajvm; return JNI_VERSION_1_2; @@ -307,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 @@ -516,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 @@ -846,12 +857,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)); @@ -859,6 +867,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 @@ -1023,6 +1041,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); + } 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(); } diff --git a/java/common/org/linphone/core/VideoSize.java b/java/common/org/linphone/core/VideoSize.java index 1d931624b..56d97aa55 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;} @@ -40,14 +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(320, 480); + return inverted? new VideoSize(320,480) : new VideoSize(480, 320); + case QVGA: + return inverted? new VideoSize(240, 320) : new VideoSize(320, 240); default: return new VideoSize(); // Invalid one } diff --git a/mediastreamer2 b/mediastreamer2 index 28a6e7f22..bc6aeef2e 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 28a6e7f22fbdd93a01676fc9cc47a2605c846d75 +Subproject commit bc6aeef2ee689c5efe5222c2e696bd1f42a4846c