From f8ead1facbda0de1b03eb29031f9d13e0f7d569c Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 23 Sep 2013 15:25:23 +0200 Subject: [PATCH] fixes around opengl display for androdi --- coreapi/linphonecore.c | 32 ++++++++++++++++++++++++++++++-- coreapi/linphonecore_jni.cc | 8 ++++++-- mediastreamer2 | 2 +- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 5dfbd37a9..308e6b425 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -4905,12 +4905,37 @@ unsigned long linphone_core_get_native_video_window_id(const LinphoneCore *lc){ return 0; } +/* unsets the video id for all calls (indeed it may be kept by filters or videostream object itself by paused calls)*/ +static void unset_video_window_id(LinphoneCore *lc, bool_t preview, unsigned long id){ + LinphoneCall *call; + MSList *elem; + + if (id!=0 && id!=-1) { + ms_error("Invalid use of unset_video_window_id()"); + return; + } +#ifdef VIDEO_ENABLED + for(elem=lc->calls;elem!=NULL;elem=elem->next){ + call=(LinphoneCall *) elem->data; + if (call->videostream){ + if (preview) + video_stream_set_native_preview_window_id(call->videostream,id); + else + video_stream_set_native_window_id(call->videostream,id); + } + } +#endif +} + /** * @ingroup media_parameters * Set the native video window id where the video is to be displayed. - * If not set the core will create its own window. + * For MacOS, Linux, Windows: if not set or zero the core will create its own window, unless the special id -1 is given. **/ void linphone_core_set_native_video_window_id(LinphoneCore *lc, unsigned long id){ + if (id==0 || id==(unsigned long)-1){ + unset_video_window_id(lc,FALSE,id); + } lc->video_window_id=id; #ifdef VIDEO_ENABLED { @@ -4948,9 +4973,12 @@ unsigned long linphone_core_get_native_preview_window_id(const LinphoneCore *lc) * @ingroup media_parameters * Set the native window id where the preview video (local camera) is to be displayed. * This has to be used in conjonction with linphone_core_use_preview_window(). - * If not set the core will create its own window. + * MacOS, Linux, Windows: if not set or zero the core will create its own window, unless the special id -1 is given. **/ void linphone_core_set_native_preview_window_id(LinphoneCore *lc, unsigned long id){ + if (id==0 || id==(unsigned long)-1){ + unset_video_window_id(lc,TRUE,id); + } lc->preview_window_id=id; #ifdef VIDEO_ENABLED { diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index b243d25d9..d647b94c1 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -2379,9 +2379,11 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc); if (obj != NULL) { obj = env->NewGlobalRef(obj); - } + ms_message("Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(): NewGlobalRef(%p)",obj); + }else ms_message("Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(): setting to NULL"); linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj); if (oldWindow != NULL) { + ms_message("Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(): DeleteGlobalRef(%p)",oldWindow); env->DeleteGlobalRef(oldWindow); } } @@ -2393,9 +2395,11 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEn jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc); if (obj != NULL) { obj = env->NewGlobalRef(obj); - } + ms_message("Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(): NewGlobalRef(%p)",obj); + }else ms_message("Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(): setting to NULL"); linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj); if (oldWindow != NULL) { + ms_message("Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(): DeleteGlobalRef(%p)",oldWindow); env->DeleteGlobalRef(oldWindow); } } diff --git a/mediastreamer2 b/mediastreamer2 index 56128aa7e..def761ec9 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 56128aa7e5e613708cd8a35beb5d2643dc4dae67 +Subproject commit def761ec9d8bdbeee5dd7d1ba343675bfc999989