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
33 #include <unistd.h> // for usleep
35 /* JVLC internal imports, generated by gcjh */
36 #include "../includes/JVLC.h"
44 jlong getClassInstance (JNIEnv *env, jobject _this);
46 JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env, jobject _this, jobjectArray args) {
52 libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
54 libvlc_exception_init( exception );
56 argc = (int) env->GetArrayLength((jarray) args) + 1;
57 argv = (const char **) malloc(argc * sizeof(char*));
59 for (int i = 0; i < argc; i++) {
60 argv[i] = env->GetStringUTFChars((jstring) env->GetObjectArrayElement(args, i),
65 res = (long) libvlc_new(argc, (char**) argv, exception );
73 JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1destroy (JNIEnv *env, jobject _this)
77 instance = getClassInstance( env, _this );
79 libvlc_destroy( (libvlc_instance_t *) instance, NULL);
88 jlong getClassInstance (JNIEnv *env, jobject _this) {
89 /* get the id field of object */
90 jclass cls = env->GetObjectClass(_this);
91 jmethodID mid = env->GetMethodID(cls, "getInstance", "()J");
92 jlong field = env->CallLongMethod(_this, mid);