[Android] jni: add jni_GetWindowSize

Thomas Guillem git at videolan.org
Tue Nov 25 17:34:19 CET 2014


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Nov 21 16:16:30 2014 +0100| [6cb263e66f238c3fefbbbaac606076abf29025cf] | committer: Thomas Guillem

jni: add jni_GetWindowSize

return the up to date window width and height.

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=6cb263e66f238c3fefbbbaac606076abf29025cf
---

 libvlc/jni/libvlcjni.c                             |   20 ++++++++++++++++++++
 libvlc/src/org/videolan/libvlc/LibVLC.java         |    1 +
 .../vlc/gui/video/VideoPlayerActivity.java         |    2 ++
 3 files changed, 23 insertions(+)

diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c
index ccba63c..b310e96 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -646,3 +646,23 @@ void Java_org_videolan_libvlc_LibVLC_playerNavigate(JNIEnv *env, jobject thiz, j
         libvlc_media_player_navigate(mp, (unsigned) nav);
 }
 
+// TODO: remove static variables
+static int i_window_width = 0;
+static int i_window_height = 0;
+
+void Java_org_videolan_libvlc_LibVLC_setWindowSize(JNIEnv *env, jobject thiz, jint width, jint height)
+{
+    pthread_mutex_lock(&vout_android_lock);
+    i_window_width = width;
+    i_window_height = height;
+    pthread_mutex_unlock(&vout_android_lock);
+}
+
+int jni_GetWindowSize(int *width, int *height)
+{
+    pthread_mutex_lock(&vout_android_lock);
+    *width = i_window_width;
+    *height = i_window_height;
+    pthread_mutex_unlock(&vout_android_lock);
+    return 0;
+}
diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index 7efd1af..4d4f67a 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -883,4 +883,5 @@ public class LibVLC {
 
     public native String getMeta(int meta);
 
+    public native int setWindowSize(int width, int height);
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index cf11ef6..4cf4793 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1301,6 +1301,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
             sw = mPresentation.getWindow().getDecorView().getWidth();
             sh = mPresentation.getWindow().getDecorView().getHeight();
         }
+        if (mLibVLC != null)
+            mLibVLC.setWindowSize(sw, sh);
 
         double dw = sw, dh = sh;
         boolean isPortrait;



More information about the Android mailing list