]> git.sesse.net Git - vlc/commitdiff
avoid VLC_VariableSet to set the drawable, use libvlc_set_video_drawable instead.
authorFilippo Carone <littlejohn@videolan.org>
Wed, 1 Nov 2006 16:44:13 +0000 (16:44 +0000)
committerFilippo Carone <littlejohn@videolan.org>
Wed, 1 Nov 2006 16:44:13 +0000 (16:44 +0000)
bindings/java/src/graphics-jni.cc
include/vlc/libvlc.h
src/control/video.c

index 3e8d8d5ef92bd54a9c13f35ec01b3ce69d1a265f..6627feccde5f58dbe00b483a8c56d41eb6bbfb2f 100644 (file)
@@ -23,6 +23,7 @@
 /* These are a must*/
 #include <jni.h>
 #include <vlc/vlc.h>
+#include <vlc/libvlc.h>
 #include <jawt.h>
 #include <jawt_md.h>
 
 #endif
 
 #include <stdio.h>    // for printf
+#include <stdlib.h>   // for malloc
 
 /* JVLC internal imports, generated by gcjh */
 #include "../includes/JVLCCanvas.h"
 
-/*
- * This will only work on X11 at the moment
- */
+jlong getJVLCInstance (JNIEnv *env, jobject _this);
 
 JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, jobject canvas, jobject graphics) {
 
@@ -53,7 +53,9 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, job
   
   jint lock;
     
-  vlc_value_t value;
+  libvlc_drawable_t drawable;
+  libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
+  libvlc_exception_init( exception );
 
   /* Get the AWT */
   awt.version = JAWT_VERSION_1_3;
@@ -92,8 +94,10 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, job
   dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
 
   /* Now paint */
-  value.i_int = reinterpret_cast<int>(dsi_win->hwnd); 
-  VLC_VariableSet( 0, "drawable", value );
+
+  drawable = reinterpret_cast<int>(dsi_win->hwnd);
+  long vlcInstance = getJVLCInstance( env, canvas );
+  libvlc_set_video_drawable( (libvlc_instance_t *) vlcInstance, drawable, exception );
 
 #else // UNIX
   /* Get the platform-specific drawing info */
@@ -102,9 +106,11 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, job
   /* Now paint */
   gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0);
   XSetBackground(dsi_x11->display, gc, 0);
+  
+  drawable = dsi_x11->drawable;
+  long vlcInstance = getJVLCInstance( env, canvas );
+  libvlc_set_video_drawable( (libvlc_instance_t *)vlcInstance, drawable, exception );
 
-  value.i_int = dsi_x11->drawable;
-  VLC_VariableSet( 0, "drawable", value );
   XFreeGC(dsi_x11->display, gc);
 
 #endif
@@ -118,3 +124,17 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, job
   /* Free the drawing surface */
   awt.FreeDrawingSurface(ds);
 }
+
+/*
+ * Utility functions
+ */
+jlong getJVLCInstance (JNIEnv *env, jobject _this) {
+    /* get the id field of object */
+    jclass    canvascls   = env->GetObjectClass(_this);
+    jmethodID canvasmid   = env->GetMethodID(canvascls, "getJVLC", "()Lorg/videolan/jvlc/JVLC;");
+    jobject   canvasjvlc  = env->CallObjectMethod(_this, canvasmid);
+    jclass    cls   = env->GetObjectClass(canvasjvlc);
+    jmethodID mid   = env->GetMethodID(cls, "getInstance", "()J");
+    jlong     field = env->CallLongMethod(canvasjvlc, mid);
+    return field;
+}
index f6074ff8a8a3de8568680b89215bcef71c728f84..40e0ec3fa312c228fb6114153bbca02eccc5572f 100644 (file)
@@ -287,6 +287,8 @@ int         libvlc_input_get_state      ( libvlc_input_t *, libvlc_exception_t *
  * @{
  */
 
+typedef int libvlc_drawable_t;
+
 /**
  * Does this input have a video output ?
  * \param p_input the input
@@ -295,6 +297,14 @@ int         libvlc_input_get_state      ( libvlc_input_t *, libvlc_exception_t *
 vlc_bool_t  libvlc_input_has_vout       ( libvlc_input_t *, libvlc_exception_t *);
 float       libvlc_input_get_fps        ( libvlc_input_t *, libvlc_exception_t *);
 
+/**
+ * Toggle fullscreen status on video output
+ * \param p_input the input
+ * \param drawable the drawable where the video output thread will display the video
+ * \param p_exception an initialized exception
+ */
+void libvlc_set_video_drawable( libvlc_instance_t *, libvlc_drawable_t, libvlc_exception_t *);
+    
 /**
  * Toggle fullscreen status on video output
  * \param p_input the input
@@ -376,7 +386,6 @@ void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *);
 *  CGrafPort on MacOSX,
 *  HWND on win32
 */
-typedef int libvlc_drawable_t;
 
 /**
  * change the parent for the current the video output
index 2a291b44b0a2e5e8ac689d4dc9998a7e59286a52..fd176cb0ad94c235c6846ca5df674ef92ea4e2a2 100644 (file)
@@ -69,6 +69,18 @@ static vout_thread_t *GetVout( libvlc_input_t *p_input,
  * Exported functions
  **********************************************************************/
 
+void libvlc_set_video_drawable( libvlc_instance_t *p_instance,
+                                libvlc_drawable_t drawable,
+                                libvlc_exception_t *p_e )
+{
+    vlc_value_t value;
+    value.i_int = drawable;
+    
+    var_Set( p_instance->p_libvlc_int, "drawable", value);
+}
+
+
+
 void libvlc_set_fullscreen( libvlc_input_t *p_input, int b_fullscreen,
                             libvlc_exception_t *p_e )
 {