From 1b78b453c1fc7d4403f2d534feb5698b10d7f118 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 21 Aug 2017 13:42:50 +0200 Subject: [PATCH] Added LinphoneCall's setVideoWindowId method in JNI wrapper --- coreapi/linphonecore_jni.cc | 15 +++++++++++++++ java/common/org/linphone/core/LinphoneCall.java | 9 +++++++++ java/impl/org/linphone/core/LinphoneCallImpl.java | 6 ++++++ 3 files changed, 30 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 5f730ca0c..2a684c8b7 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -7846,6 +7846,21 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallImpl_setListener(JNIEn linphone_call_set_next_video_frame_decoded_callback(call, _next_video_frame_decoded_callback, listener); } +extern "C" void Java_org_linphone_core_LinphoneCallImpl_setVideoWindowId(JNIEnv* env + ,jobject thiz + ,jlong lc + ,jobject obj) { + jobject oldWindow = (jobject) linphone_call_get_native_video_window_id((LinphoneCall*)lc); + if (obj != NULL) { + obj = env->NewGlobalRef(obj); + ms_message("Java_org_linphone_core_LinphoneCallImpl_setVideoWindowId(): NewGlobalRef(%p)",obj); + }else ms_message("Java_org_linphone_core_LinphoneCallImpl_setVideoWindowId(): setting to NULL"); + linphone_call_set_native_video_window_id((LinphoneCall*)lc,(void *)obj); + if (oldWindow != NULL) { + ms_message("Java_org_linphone_core_LinphoneCallImpl_setVideoWindowId(): DeleteGlobalRef(%p)",oldWindow); + env->DeleteGlobalRef(oldWindow); + } +} /* * returns the java TunnelConfig associated with a C LinphoneTunnelConfig. diff --git a/java/common/org/linphone/core/LinphoneCall.java b/java/common/org/linphone/core/LinphoneCall.java index 8cb43e796..332a76b57 100644 --- a/java/common/org/linphone/core/LinphoneCall.java +++ b/java/common/org/linphone/core/LinphoneCall.java @@ -20,6 +20,8 @@ package org.linphone.core; import java.util.Vector; +import org.linphone.mediastream.video.AndroidVideoWindowImpl; + /** * Object representing a call. Calls are created using {@link LinphoneCore#invite(LinphoneAddress)} or passed to the application by listener {@link LinphoneCoreListener#callState} * @@ -404,6 +406,13 @@ public interface LinphoneCall { */ void setListener(LinphoneCall.LinphoneCallListener listener); + /** + * Set the native video window id where the video is to be displayed. + * On Android, it must be of type {@link AndroidVideoWindowImpl} + * @param w window of type {@link AndroidVideoWindowImpl} + */ + void setVideoWindow(Object w); + /** * Indicates if remote party requested automatic answering to be performed. * This is an indication - the application remains responsible for answering the call. diff --git a/java/impl/org/linphone/core/LinphoneCallImpl.java b/java/impl/org/linphone/core/LinphoneCallImpl.java index f1338c423..70c0b01dc 100644 --- a/java/impl/org/linphone/core/LinphoneCallImpl.java +++ b/java/impl/org/linphone/core/LinphoneCallImpl.java @@ -45,6 +45,7 @@ class LinphoneCallImpl implements LinphoneCall { private native float getAverageQuality(long nativePtr); private native boolean mediaInProgress(long nativePtr); private native void setListener(long ptr, LinphoneCallListener listener); + private native void setVideoWindowId(long nativePtr, Object wid); native private long getDiversionAddress(long nativePtr); native private Object getStats(long nativePtr, int stream_type); native private LinphoneCore getCore(long nativePtr); @@ -295,6 +296,11 @@ class LinphoneCallImpl implements LinphoneCall { setListener(nativePtr, listener); } } + + @Override + public synchronized void setVideoWindow(Object w) { + setVideoWindowId(nativePtr, w); + } public LinphoneAddress getDiversionAddress() { long lNativePtr = getDiversionAddress(nativePtr);