/* 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) {
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;
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 */
/* 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
/* 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;
+}
* @{
*/
+typedef int libvlc_drawable_t;
+
/**
* Does this input have a video output ?
* \param p_input the input
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
* CGrafPort on MacOSX,
* HWND on win32
*/
-typedef int libvlc_drawable_t;
/**
* change the parent for the current the video output
* 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 )
{