1 /*****************************************************************************
2 * video-jni.cc: JNI native video functions for VLC Java Bindings
3 *****************************************************************************
4 * Copyright (C) 1998-2006 the VideoLAN team
6 * Authors: Filippo Carone <filippo@carone.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
29 #include <vlc/libvlc.h>
31 /* JVLC internal imports, generated by gcjh */
32 #include "../includes/Video.h"
37 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1toggleFullscreen (JNIEnv *env, jobject _this)
43 libvlc_toggle_fullscreen( input, exception );
45 CHECK_EXCEPTION_FREE ;
48 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1setFullscreen (JNIEnv *env, jobject _this, jboolean value)
54 libvlc_set_fullscreen( input, value, exception );
56 CHECK_EXCEPTION_FREE ;
59 JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Video__1getFullscreen (JNIEnv *env, jobject _this)
66 res = libvlc_get_fullscreen( input, exception );
68 CHECK_EXCEPTION_FREE ;
73 JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Video__1getHeight (JNIEnv *env, jobject _this)
80 res = libvlc_video_get_height( input, exception );
82 CHECK_EXCEPTION_FREE ;
87 JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Video__1getWidth (JNIEnv *env, jobject _this)
94 res = libvlc_video_get_width( input, exception );
96 CHECK_EXCEPTION_FREE ;
101 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1getSnapshot (JNIEnv *env, jobject _this, jstring filepath)
105 const char* psz_filepath = env->GetStringUTFChars( filepath, 0 );
109 libvlc_video_take_snapshot( input, (char *) psz_filepath, exception );
111 CHECK_EXCEPTION_FREE ;
113 if (psz_filepath != NULL) {
114 env->ReleaseStringUTFChars( filepath, psz_filepath );
119 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1destroyVideo (JNIEnv *env, jobject _this)
125 libvlc_video_destroy( input, exception );
127 CHECK_EXCEPTION_FREE;
130 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1reparent (JNIEnv *env, jobject _this, jobject canvas)
137 JAWT_DrawingSurface* ds;
138 JAWT_DrawingSurfaceInfo* dsi;
140 JAWT_Win32DrawingSurfaceInfo* dsi_win;
142 JAWT_X11DrawingSurfaceInfo* dsi_x11;
150 awt.version = JAWT_VERSION_1_3;
151 if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
152 printf("AWT Not found\n");
156 /* Get the drawing surface */
157 ds = awt.GetDrawingSurface(env, canvas);
159 printf("NULL drawing surface\n");
163 /* Lock the drawing surface */
165 if((lock & JAWT_LOCK_ERROR) != 0) {
166 printf("Error locking surface\n");
167 awt.FreeDrawingSurface(ds);
171 /* Get the drawing surface info */
172 dsi = ds->GetDrawingSurfaceInfo(ds);
174 printf("Error getting surface info\n");
176 awt.FreeDrawingSurface(ds);
182 /* Get the platform-specific drawing info */
183 dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
185 libvlc_video_reparent( input, dsi_win->hwnd, exception );
187 CHECK_EXCEPTION_FREE ;
190 value.i_int = reinterpret_cast<int>(dsi_win->hwnd);
191 VLC_VariableSet( 1, "drawable", value );
194 /* Get the platform-specific drawing info */
196 dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
199 gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0);
200 XSetBackground(dsi_x11->display, gc, 0);
203 libvlc_video_reparent( input, dsi_x11->drawable, exception );
205 CHECK_EXCEPTION_FREE ;
207 /* also update the drawable variable value */
208 value.i_int = dsi_x11->drawable;
209 VLC_VariableSet( 0, "drawable", value );
211 XFreeGC(dsi_x11->display, gc);
214 /* Free the drawing surface info */
215 ds->FreeDrawingSurfaceInfo(dsi);
217 /* Unlock the drawing surface */
220 /* Free the drawing surface */
221 awt.FreeDrawingSurface(ds);
224 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1setSize__II (JNIEnv *env, jobject _this, jint width, jint height)
230 libvlc_video_resize( input, width, height, exception );
232 CHECK_EXCEPTION_FREE ;