1 /*****************************************************************************
2 * vlc-libvlc-jni.cc: JNI interface for vlc Java Bindings
3 *****************************************************************************
4 * Copyright (C) 1998-2006 the VideoLAN team
6 * Authors: Filippo Carone <filippo@carone.org>
7 * Philippe Morin <phmorin@free.fr>
9 * $Id: core-jni.cc 156 2006-08-01 09:23:01Z littlejohn $
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 *****************************************************************************/
28 #include <vlc/libvlc.h>
30 #include <stdio.h> // for printf
31 #include <stdlib.h> // for calloc
32 #include <string.h> // for strcmp
35 #define usleep(var) Sleep(var/1000)
37 #include <unistd.h> // for usleep
40 /* JVLC internal imports, generated by gcjh */
41 #include "../includes/JVLC.h"
49 jlong getClassInstance (JNIEnv *env, jobject _this);
51 JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env, jobject _this, jobjectArray args) {
57 libvlc_exception_t exception;
59 libvlc_exception_init( &exception );
61 argc = (int) env->GetArrayLength((jarray) args);
62 argv = (const char **) malloc(argc * sizeof(char*));
64 for (int i = 0; i < argc; i++) {
65 argv[i] = env->GetStringUTFChars((jstring) env->GetObjectArrayElement(args, i),
70 res = (long) libvlc_new(argc, (char**) argv, &exception );
78 JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1destroy (JNIEnv *env, jobject _this)
82 instance = getClassInstance( env, _this );
84 libvlc_release( (libvlc_instance_t *) instance );
90 //JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1paint (JNIEnv *env, jobject _this, jobject canvas, jobject graphics)
96 jlong getClassInstance (JNIEnv *env, jobject _this) {
97 /* get the id field of object */
98 jclass cls = env->GetObjectClass(_this);
99 jmethodID mid = env->GetMethodID(cls, "getInstance", "()J");
100 jlong field = env->CallLongMethod(_this, mid);