1 /*****************************************************************************
2 * vlm-jni.cc: JNI native VLM functions for VLC Java Bindings
3 *****************************************************************************
4 * Copyright (C) 1998-2006 the VideoLAN team
6 * Authors: Philippe Morin <phmorin@free.fr>
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 /* JVLC internal imports, generated by gcjh */
31 #include "../includes/VLM.h"
34 JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1addBroadcast (JNIEnv *env, jobject _this, jstring name, jstring inputmrl, jstring outputmrl, jobjectArray options, jboolean enable, jboolean loop)
37 const char* psz_name = env->GetStringUTFChars( name, 0 );
38 const char* psz_inputmrl = env->GetStringUTFChars( inputmrl, 0 );
39 const char* psz_outputmrl = env->GetStringUTFChars( outputmrl, 0 );
41 const char** ppsz_options = NULL;
43 if ( options != NULL ) {
44 i_options = ( int ) env->GetArrayLength( ( jarray ) options );
45 ppsz_options = ( const char ** ) malloc( i_options * sizeof( char* ) );
47 for ( int i = 0; i < i_options - 1; i++ ) {
49 env->GetStringUTFChars( ( jstring ) env->GetObjectArrayElement( options, i ), 0 );
53 libvlc_vlm_add_broadcast( (libvlc_instance_t *) instance, (char*)psz_name, (char*)psz_inputmrl, (char*)psz_outputmrl ,
54 i_options, (char**)ppsz_options, enable, loop, &exception );
59 if (psz_name != NULL) {
60 env->ReleaseStringUTFChars( name, psz_name );
62 if (psz_inputmrl != NULL) {
63 env->ReleaseStringUTFChars( inputmrl, psz_inputmrl );
65 if (psz_outputmrl != NULL) {
66 env->ReleaseStringUTFChars( outputmrl, psz_outputmrl );
70 JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1deleteMedia (JNIEnv *env, jobject _this, jstring name)
73 const char* psz_name = env->GetStringUTFChars( name, 0 );
75 libvlc_vlm_del_media( (libvlc_instance_t *) instance, (char*)psz_name, &exception);
78 if (psz_name != NULL) {
79 env->ReleaseStringUTFChars( name, psz_name );
83 JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1setEnabled (JNIEnv *env, jobject _this, jstring name, jboolean newStatus)
86 const char* psz_name = env->GetStringUTFChars( name, 0 );
88 libvlc_vlm_set_enabled( (libvlc_instance_t *) instance, (char*)psz_name, newStatus, &exception);
91 if (psz_name != NULL) {
92 env->ReleaseStringUTFChars( name, psz_name );
96 JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1setOutput (JNIEnv *env, jobject _this, jstring name, jstring mrl)
99 const char* psz_name = env->GetStringUTFChars( name, 0 );
100 const char* psz_mrl = env->GetStringUTFChars( mrl, 0 );
102 libvlc_vlm_set_output((libvlc_instance_t *) instance, (char*)psz_name, (char*)psz_mrl, &exception);
105 if (psz_name != NULL) {
106 env->ReleaseStringUTFChars( name, psz_name );
109 if (psz_mrl != NULL) {
110 env->ReleaseStringUTFChars( mrl, psz_mrl );
114 JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1setInput (JNIEnv *env, jobject _this, jstring name, jstring mrl)
117 const char* psz_name = env->GetStringUTFChars( name, 0 );
118 const char* psz_mrl = env->GetStringUTFChars( mrl, 0 );
120 libvlc_vlm_set_input((libvlc_instance_t *) instance, (char*)psz_name, (char*)psz_mrl, &exception);
123 if (psz_name != NULL) {
124 env->ReleaseStringUTFChars( name, psz_name );
126 if (psz_mrl != NULL) {
127 env->ReleaseStringUTFChars( mrl, psz_mrl );
131 JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1setLoop (JNIEnv *env, jobject _this, jstring name, jboolean newStatus)
134 const char* psz_name = env->GetStringUTFChars( name, 0 );
136 libvlc_vlm_set_loop((libvlc_instance_t *) instance, (char*)psz_name, newStatus, &exception);
139 if (psz_name != NULL) {
140 env->ReleaseStringUTFChars( name, psz_name );
144 JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1changeMedia (JNIEnv *env, jobject _this, jstring name, jstring inputmrl, jstring outputmrl, jobjectArray options, jboolean enablenewbroadcast, jboolean broadcast)
148 const char** ppsz_options = NULL;
149 const char* psz_name = env->GetStringUTFChars( name, 0 );
150 const char* psz_inputmrl = env->GetStringUTFChars( inputmrl, 0 );
151 const char* psz_outputmrl = env->GetStringUTFChars( outputmrl, 0 );
153 if ( options != NULL ) {
154 i_options = ( int ) env->GetArrayLength( ( jarray ) options );
155 ppsz_options = ( const char ** ) malloc( i_options * sizeof( char* ) );
157 for ( int i = 0; i < i_options - 1; i++ ) {
159 env->GetStringUTFChars( ( jstring ) env->GetObjectArrayElement( options, i ), 0 );
163 libvlc_vlm_change_media( (libvlc_instance_t *) instance, (char*)psz_name, (char*)psz_inputmrl, (char*)psz_outputmrl ,
164 i_options, (char**)ppsz_options, enablenewbroadcast, broadcast, &exception );
167 if (psz_name != NULL) {
168 env->ReleaseStringUTFChars( name, psz_name );
171 if (psz_inputmrl != NULL) {
172 env->ReleaseStringUTFChars( name, psz_inputmrl );
175 if (psz_outputmrl != NULL) {
176 env->ReleaseStringUTFChars( name, psz_outputmrl );
180 JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1playMedia (JNIEnv *env, jobject _this, jstring name)
183 const char* psz_name = env->GetStringUTFChars( name, 0 );
185 libvlc_vlm_play_media( (libvlc_instance_t *) instance, (char*)psz_name, &exception );
188 if (psz_name != NULL) {
189 env->ReleaseStringUTFChars( name, psz_name );
193 JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1stopMedia (JNIEnv *env, jobject _this, jstring name)
196 const char* psz_name = env->GetStringUTFChars( name, 0 );
199 libvlc_vlm_stop_media( (libvlc_instance_t *) instance, (char*)psz_name, &exception );
202 if (psz_name != NULL) {
203 env->ReleaseStringUTFChars( name, psz_name );
207 JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1pauseMedia (JNIEnv *env, jobject _this, jstring name)
210 const char* psz_name = env->GetStringUTFChars( name, 0 );
212 libvlc_vlm_pause_media( (libvlc_instance_t *) instance, (char*)psz_name, &exception );
215 if (psz_name != NULL) {
216 env->ReleaseStringUTFChars( name, psz_name );
220 JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1seekMedia (JNIEnv *env, jobject _this, jstring name, jfloat percentage)
223 const char* psz_name = env->GetStringUTFChars( name, 0 );
225 libvlc_vlm_seek_media( (libvlc_instance_t *) instance, (char*)psz_name, (float)percentage, &exception );
228 if (psz_name != NULL) {
229 env->ReleaseStringUTFChars( name, psz_name );
233 JNIEXPORT jstring JNICALL Java_org_videolan_jvlc_VLM__1showMedia (JNIEnv *env, jobject _this, jstring name)
236 const char* psz_name = env->GetStringUTFChars( name, 0 );
240 psz_response = libvlc_vlm_show_media( (libvlc_instance_t *) instance, (char*)psz_name, &exception );
243 if (psz_name != NULL) {
244 env->ReleaseStringUTFChars( name, psz_name );
246 js_response = env->NewStringUTF(psz_response);
247 if (psz_response != NULL) {
253 #define LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( attr, returnType, dummyGetType, dummyDefault)\
254 JNIEXPORT j ## returnType JNICALL Java_org_videolan_jvlc_VLM__1getMedia ## attr(JNIEnv *env, jobject _this, jstring name, jint index) \
257 const char* psz_name = env->GetStringUTFChars( name, 0 ); \
258 returnType response; \
260 response = libvlc_vlm_get_media_ ## attr( (libvlc_instance_t *) instance, (char*)psz_name, (int)index, &exception ); \
263 if (psz_name != NULL) { \
264 env->ReleaseStringUTFChars( name, psz_name ); \
269 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( position, float, Float, -1);
270 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( time, int, Integer, -1);
271 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( length, int, Integer, -1);
272 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( rate, int, Integer, -1);
273 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( title, int, Integer, 0);
274 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( chapter, int, Integer, 0);
275 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( seekable, int, Bool, 0);
277 #undef LIBVLC_VLM_GET_MEDIA_ATTRIBUTE