1 /*****************************************************************************
2 * JVLC.java: JNI interface for vlc Java Bindings
3 *****************************************************************************
4 * Copyright (C) 1998-2005 the VideoLAN team
6 * Authors: Filippo Carone <filippo@carone.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
21 *****************************************************************************/
30 #include <vlc/libvlc.h>
35 #include <X11/Xlib.h> // for Xlibs graphics functions
38 #include <stdio.h> // for printf
39 #include <stdlib.h> // for malloc
41 /* JVLC internal imports, generated by gcjh */
42 #include "../includes/JVLCCanvas.h"
44 jlong getJVLCInstance (JNIEnv *env, jobject _this);
46 // JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, jobject canvas, jobject graphics) {
49 // JAWT_DrawingSurface* ds;
50 // JAWT_DrawingSurfaceInfo* dsi;
52 // JAWT_Win32DrawingSurfaceInfo* dsi_win;
54 // JAWT_X11DrawingSurfaceInfo* dsi_x11;
60 // libvlc_drawable_t drawable;
61 // libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
62 // libvlc_exception_init( exception );
65 // awt.version = JAWT_VERSION_1_3;
66 // if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
67 // printf("AWT Not found\n");
71 // /* Get the drawing surface */
72 // ds = awt.GetDrawingSurface(env, canvas);
74 // printf("NULL drawing surface\n");
78 // /* Lock the drawing surface */
79 // lock = ds->Lock(ds);
80 // if((lock & JAWT_LOCK_ERROR) != 0) {
81 // printf("Error locking surface\n");
82 // awt.FreeDrawingSurface(ds);
86 // /* Get the drawing surface info */
87 // dsi = ds->GetDrawingSurfaceInfo(ds);
89 // printf("Error getting surface info\n");
91 // awt.FreeDrawingSurface(ds);
97 // /* Get the platform-specific drawing info */
98 // dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
102 // drawable = reinterpret_cast<int>(dsi_win->hwnd);
103 // long vlcInstance = getJVLCInstance( env, canvas );
104 // libvlc_video_set_parent( (libvlc_instance_t *) vlcInstance, drawable, exception );
107 // /* Get the platform-specific drawing info */
108 // dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
111 // gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0);
112 // XSetBackground(dsi_x11->display, gc, 0);
114 // drawable = dsi_x11->drawable;
115 // long vlcInstance = getJVLCInstance( env, canvas );
116 // libvlc_video_set_parent( (libvlc_instance_t *)vlcInstance, drawable, exception );
118 // XFreeGC(dsi_x11->display, gc);
122 // /* Free the drawing surface info */
123 // ds->FreeDrawingSurfaceInfo(dsi);
125 // /* Unlock the drawing surface */
128 // /* Free the drawing surface */
129 // awt.FreeDrawingSurface(ds);
135 jlong getJVLCInstance (JNIEnv *env, jobject _this) {
136 /* get the id field of object */
137 jclass canvascls = env->GetObjectClass(_this);
138 jmethodID canvasmid = env->GetMethodID(canvascls, "getJVLC", "()Lorg/videolan/jvlc/JVLC;");
139 jobject canvasjvlc = env->CallObjectMethod(_this, canvasmid);
140 jclass cls = env->GetObjectClass(canvasjvlc);
141 jmethodID mid = env->GetMethodID(cls, "getInstance", "()J");
142 jlong field = env->CallLongMethod(canvasjvlc, mid);