]> sjero.net Git - linphone/blobdiff - coreapi/linphonecore_jni.cc
Merge remote-tracking branch 'private/srtp'
[linphone] / coreapi / linphonecore_jni.cc
index 1ec1c4a5f68696bb90690adb9ef6b689e83d05fe..4dab0d0a84ca2cf505cafc0b252b62306136ce23 100644 (file)
@@ -36,6 +36,9 @@ extern "C" void libmsx264_init();
 #ifdef HAVE_AMR
 extern "C" void libmsamr_init();
 #endif
+#ifdef HAVE_SILK
+extern "C" void libmssilk_init();
+#endif
 #endif /*ANDROID*/
 
 static JavaVM *jvm=0;
@@ -405,6 +408,9 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv*
 #endif
 #ifdef HAVE_AMR
        libmsamr_init();
+#endif
+#ifdef HAVE_SILK
+       libmssilk_init();
 #endif
        jlong nativePtr = (jlong)linphone_core_new(     &ldata->vTable
                        ,userConfig
@@ -1266,6 +1272,13 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv*
                                                                                                                                                ,jobject thiz
                                                                                                                                                ,jlong lc
                                                                                                                                                ,jobject obj) {
+       jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
+       if (oldWindow != NULL) {
+               env->DeleteGlobalRef(oldWindow);
+       }
+       if (obj != NULL) {
+               obj = env->NewGlobalRef(obj);
+       }
        linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
 }
 
@@ -1273,6 +1286,13 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEn
                                                                                                                                                ,jobject thiz
                                                                                                                                                ,jlong lc
                                                                                                                                                ,jobject obj) {
+       jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
+       if (oldWindow != NULL) {
+               env->DeleteGlobalRef(oldWindow);
+       }
+       if (obj != NULL) {
+               obj = env->NewGlobalRef(obj);
+       }
        linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
 }
 
@@ -1469,8 +1489,10 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv
 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
        linphone_core_terminate_all_calls((LinphoneCore *) pCore);
 }
-extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
-       return (jlong)ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
+extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
+       LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
+       LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
+       return lcd->getCall(env,lCall);
 }
 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
        return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
@@ -1495,11 +1517,12 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIE
        }
 }
 
-extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
+extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
        const char* cUri=env->GetStringUTFChars(jUri, NULL);
-       const LinphoneCall *call=linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
+       LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
        env->ReleaseStringUTFChars(jUri, cUri);
-       return (jlong) call;
+       LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
+       return (jobject) lcdata->getCall(env,call);
 }
 
 
@@ -1558,11 +1581,20 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_areStreamsEncrypted(
        return linphone_call_are_all_streams_encrypted((LinphoneCall *) ptr);
 }
 
+extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
+       return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
+}
+
 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
 // Implemented directly in msandroid.cpp (sound filters for Android).
 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
 
 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv*  env,jobject thiz,jboolean speakerOn){
        msandroid_hack_speaker_state(speakerOn);
+}
 // End Galaxy S hack functions
+
+
+extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
+       return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
 }