Commit bcf43dd0 authored by Filippo Carone's avatar Filippo Carone

avoid VLC_VariableSet to set the drawable, use libvlc_set_video_drawable instead.

parent 491321f3
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
/* These are a must*/ /* These are a must*/
#include <jni.h> #include <jni.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/libvlc.h>
#include <jawt.h> #include <jawt.h>
#include <jawt_md.h> #include <jawt_md.h>
...@@ -31,13 +32,12 @@ ...@@ -31,13 +32,12 @@
#endif #endif
#include <stdio.h> // for printf #include <stdio.h> // for printf
#include <stdlib.h> // for malloc
/* JVLC internal imports, generated by gcjh */ /* JVLC internal imports, generated by gcjh */
#include "../includes/JVLCCanvas.h" #include "../includes/JVLCCanvas.h"
/* jlong getJVLCInstance (JNIEnv *env, jobject _this);
* This will only work on X11 at the moment
*/
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, jobject canvas, jobject graphics) { 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 ...@@ -53,7 +53,9 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, job
jint lock; 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 */ /* Get the AWT */
awt.version = JAWT_VERSION_1_3; awt.version = JAWT_VERSION_1_3;
...@@ -92,8 +94,10 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, job ...@@ -92,8 +94,10 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, job
dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
/* Now paint */ /* 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 #else // UNIX
/* Get the platform-specific drawing info */ /* Get the platform-specific drawing info */
...@@ -103,8 +107,10 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, job ...@@ -103,8 +107,10 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, job
gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0); gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0);
XSetBackground(dsi_x11->display, gc, 0); XSetBackground(dsi_x11->display, gc, 0);
value.i_int = dsi_x11->drawable; drawable = dsi_x11->drawable;
VLC_VariableSet( 0, "drawable", value ); long vlcInstance = getJVLCInstance( env, canvas );
libvlc_set_video_drawable( (libvlc_instance_t *)vlcInstance, drawable, exception );
XFreeGC(dsi_x11->display, gc); XFreeGC(dsi_x11->display, gc);
#endif #endif
...@@ -118,3 +124,17 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, job ...@@ -118,3 +124,17 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, job
/* Free the drawing surface */ /* Free the drawing surface */
awt.FreeDrawingSurface(ds); 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;
}
...@@ -287,6 +287,8 @@ int libvlc_input_get_state ( libvlc_input_t *, libvlc_exception_t * ...@@ -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 ? * Does this input have a video output ?
* \param p_input the input * \param p_input the input
...@@ -295,6 +297,14 @@ int libvlc_input_get_state ( libvlc_input_t *, libvlc_exception_t * ...@@ -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 *); vlc_bool_t libvlc_input_has_vout ( libvlc_input_t *, libvlc_exception_t *);
float libvlc_input_get_fps ( 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 * Toggle fullscreen status on video output
* \param p_input the input * \param p_input the input
...@@ -376,7 +386,6 @@ void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *); ...@@ -376,7 +386,6 @@ void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *);
* CGrafPort on MacOSX, * CGrafPort on MacOSX,
* HWND on win32 * HWND on win32
*/ */
typedef int libvlc_drawable_t;
/** /**
* change the parent for the current the video output * change the parent for the current the video output
......
...@@ -69,6 +69,18 @@ static vout_thread_t *GetVout( libvlc_input_t *p_input, ...@@ -69,6 +69,18 @@ static vout_thread_t *GetVout( libvlc_input_t *p_input,
* Exported functions * 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, void libvlc_set_fullscreen( libvlc_input_t *p_input, int b_fullscreen,
libvlc_exception_t *p_e ) libvlc_exception_t *p_e )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment