]> sjero.net Git - linphone/blobdiff - coreapi/linphonecore_jni.cc
Merge commit '2e953b4'
[linphone] / coreapi / linphonecore_jni.cc
index 3a9346999fa5e514d422323e111936e8ef4f6c62..64c5997d6d2ff15d548e7af986b7c4203b0bddc5 100644 (file)
@@ -18,12 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 #include <jni.h>
 #include "linphonecore.h"
+#include "mediastreamer2/msjava.h"
+
 #ifdef ANDROID
 #include <android/log.h>
 extern "C" void libmsilbc_init();
+extern "C" void libmsx264_init();
 #endif /*ANDROID*/
 
-extern "C" void ms_andsnd_set_jvm(JavaVM *jvm) ;
 static JavaVM *jvm=0;
 
 #ifdef ANDROID
@@ -44,7 +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);
+       ms_set_jvm(ajvm);
 #endif /*ANDROID*/
        jvm=ajvm;
        return JNI_VERSION_1_2;
@@ -298,15 +300,15 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv*
                ,jstring jfactoryConfig
                ,jobject  juserdata){
 
-       const char* userConfig = env->GetStringUTFChars(juserConfig, NULL);
-       const char* factoryConfig = env->GetStringUTFChars(jfactoryConfig, NULL);
+       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
+#endif
+#ifdef VIDEO_ENABLED
+       libmsx264_init();
 #endif
        jlong nativePtr = (jlong)linphone_core_new(     &ldata->vTable
                        ,userConfig
@@ -317,8 +319,8 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv*
        //clear existing proxy config
        linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
 
-       env->ReleaseStringUTFChars(juserConfig, userConfig);
-       env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
+       if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
+       if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
        return nativePtr;
 }
 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv*  env
@@ -507,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
@@ -546,9 +566,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv*
                                                                                                                                                        ,jint minute_away
                                                                                                                                                        ,jstring jalternative_contact
                                                                                                                                                        ,jint status) {
-       const char* alternative_contact = env->GetStringUTFChars(jalternative_contact, NULL);
+       const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
        linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
-       env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
+       if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
 }
 
 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv*  env
@@ -562,6 +582,40 @@ extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv*
        return (long)lResult;
 }
 
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv*  env
+                                                                                                                                                       ,jobject  thiz
+                                                                                                                                                       ,jlong lc
+                                                                                                                                                       ,jboolean vcap_enabled
+                                                                                                                                                       ,jboolean display_enabled) {
+       linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
+
+}
+extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv*  env
+                                                                                                                                                       ,jobject  thiz
+                                                                                                                                                       ,jlong lc) {
+       return linphone_core_video_enabled((LinphoneCore*)lc);
+}
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv*  env
+                                                                                                                                                       ,jobject  thiz
+                                                                                                                                                       ,jlong lc
+                                                                                                                                                       ,jstring jpath) {
+       const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
+       linphone_core_set_ring((LinphoneCore*)lc,path);
+       if (path) env->ReleaseStringUTFChars(jpath, path);
+}
+extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv*  env
+                                                                                                                                                       ,jobject  thiz
+                                                                                                                                                       ,jlong lc
+                                                                                                                                                       ) {
+       const char* path = linphone_core_get_ring((LinphoneCore*)lc);
+       if (path) {
+               return env->NewStringUTF(path);
+       } else {
+               return NULL;
+       }
+}
+
+
 //ProxyConfig
 
 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv*  env,jobject  thiz) {
@@ -671,7 +725,15 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNI
        linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
        env->ReleaseStringUTFChars(jprefix, prefix);
 }
-
+extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
+                                                                                                                                                               ,jobject thiz
+                                                                                                                                                               ,jlong proxyCfg
+                                                                                                                                                               ,jboolean val) {
+       linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
+}
+extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
+       return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
+}
 
 //Auth Info
 
@@ -795,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));
@@ -808,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
@@ -924,6 +993,98 @@ extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv*
 
 }
 
+<<<<<<< HEAD
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
+                                                                                                                                               ,jobject thiz
+                                                                                                                                               ,jlong lc
+                                                                                                                                               ,jobject obj) {
+       linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
+}
+
+
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
+       linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
+}
+
+extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
+       return linphone_core_get_firewall_policy((LinphoneCore*)lc);
+}
+
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
+       const char* server = NULL;
+       if (jserver) server=env->GetStringUTFChars(jserver, NULL);
+       linphone_core_set_stun_server((LinphoneCore*)lc,server);
+       if (server) env->ReleaseStringUTFChars(jserver,server);
+}
+
+extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
+       const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
+       if (ret==NULL) return NULL;
+       jstring jvalue =env->NewStringUTF(ret);
+       return jvalue;
+}
+
+extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
+       linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
+}
+
+extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
+       linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
+}
+
+extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
+       return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
+}
+extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
+       return linphone_call_params_destroy((LinphoneCallParams*)lc);
+}
+extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
+       return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
+}
+
+extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
+       return (jlong) linphone_call_params_copy(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);
+}
+
+extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
+       return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
+}
+
+extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
+       return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
+}
+
+
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
+       MSVideoSize vsize;
+       vsize.width = (int)width;
+       vsize.height = (int)height;
+       linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
+}
+
+extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
+       MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
+    jintArray arr = env->NewIntArray(2);
+       int tVsize [2]= {vsize.width,vsize.height};
+    env->SetIntArrayRegion(arr, 0, 2, tVsize);
+    return arr;
+}
+
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
+       linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
+}
+
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
+       linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
+
 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv*  env,jobject thiz,jlong ptr) {
        return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
 }