Commit 72f3bf6b authored by Filippo Carone's avatar Filippo Carone

audio / video libvlc functions binded.

parent fcd621cc
/*****************************************************************************
* JVLC.java: Main Java Class, represents a libvlc_instance_t object
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-2006
*
* $Id$
*
* Authors: Filippo Carone <filippo@carone.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
*
*/
/**
* @author Filippo Carone <filippo@carone.org>
*/
package org.videolan.jvlc;
public class JVLC implements JLibVLC {
static {
System.load(System.getProperty("user.dir") + "/libjvlc.so");
System.load(System.getProperty( "user.dir" ) + "/libjvlc.so" );
}
......@@ -36,50 +43,72 @@ public class JVLC implements JLibVLC {
public JVLC() {
_instance = createInstance();
playlist = new Playlist(_instance);
playlist = new Playlist( _instance );
}
public JVLC(String[] args) {
_instance = createInstance(args);
playlist = new Playlist(_instance);
_instance = createInstance( args );
playlist = new Playlist( _instance );
}
/*
* Core methods
*/
private native long createInstance();
private native long createInstance(String[] args);
private native long createInstance( String[] args );
/*
* Audio native methods
*/
private native boolean _getMute();
private native void _setMute( boolean value );
private native void _toggleMute();
private native int _getVolume();
private native void _setVolume( int volume );
public void getMute() {
/*
* Video native methods
*/
private native void _toggleFullscreen();
private native void _setFullscreen( boolean value);
private native boolean _getFullscreen();
public boolean getMute() {
// TODO Auto-generated method stub
return _getMute();
}
public void setMute() {
// TODO Auto-generated method stub
public void setMute(boolean value) {
_setMute( value );
}
public void toggleMute() {
_toggleMute();
}
public void getVolume() {
// TODO Auto-generated method stub
public int getVolume() {
return _getVolume();
}
public void setVolume() {
// TODO Auto-generated method stub
public void setVolume(int volume) {
_setVolume( volume );
}
public void toggleFullscreen() {
// TODO Auto-generated method stub
_toggleFullscreen();
}
public void setFullscreen() {
// TODO Auto-generated method stub
public void setFullscreen( boolean value ) {
_setFullscreen( value );
}
public void getFullscreen() {
// TODO Auto-generated method stub
public boolean getFullscreen() {
return _getFullscreen();
}
public void getLength() {
......@@ -111,4 +140,11 @@ public class JVLC implements JLibVLC {
return _instance;
}
/*
* Getters and setters
*/
public Playlist getPlaylist() {
return playlist;
}
}
/*****************************************************************************
* JVLC.java: JNI interface for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2005 the VideoLAN team
*
* $Id$
* Copyright (C) 1998-2006 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
......@@ -40,186 +40,419 @@ jlong getPlaylistInstance (JNIEnv *env, jobject _this);
JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance__ (JNIEnv *env, jobject _this) {
long res;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
// res is the pointer to libvlc_instance_t
long res;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
res = ( long ) libvlc_new( 0, NULL, exception );
libvlc_exception_init( exception );
res = ( long ) libvlc_new( 0, NULL, exception );
free( exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
return res;
free( exception );
return res;
}
JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance___3Ljava_lang_String_2 (JNIEnv *env, jobject _this, jobjectArray args) {
long res;
int argc;
const char **argv;
long res;
int argc;
const char **argv;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
libvlc_exception_init( exception );
libvlc_exception_init( exception );
argc = (int) env->GetArrayLength((jarray) args);
argv = (const char **) malloc(argc * sizeof(char*));
for (int i = 0; i < argc; i++) {
argv[i] = env->GetStringUTFChars((jstring) env->GetObjectArrayElement(args, i),
0
);
}
argc = (int) env->GetArrayLength((jarray) args);
argv = (const char **) malloc(argc * sizeof(char*));
for (int i = 0; i < argc; i++) {
argv[i] = env->GetStringUTFChars((jstring) env->GetObjectArrayElement(args, i),
0
);
}
res = (long) libvlc_new(argc, (char**) argv, exception );
free( exception );
free( argv );
return res;
}
res = (long) libvlc_new(argc, (char**) argv, exception );
/*
* Audio native functions
*/
JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_JVLC__1getMute (JNIEnv *env, jobject _this)
{
// res is the final result
jboolean res;
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = (jboolean) libvlc_audio_get_mute( ( libvlc_instance_t * ) instance, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1setMute (JNIEnv *env, jobject _this, jboolean value)
{
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
free( exception );
free( argv );
libvlc_exception_init( exception );
return res;
instance = getPlaylistInstance( env, _this );
libvlc_audio_set_mute( ( libvlc_instance_t * ) instance, value, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1toggleMute (JNIEnv *env, jobject _this)
{
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
///\TODO: NO, this is not what we want.
libvlc_audio_get_mute( ( libvlc_instance_t * ) instance, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC__1getVolume (JNIEnv *env, jobject _this)
{
// res is the final result
jboolean res;
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = (jboolean) libvlc_audio_get_mute( ( libvlc_instance_t * ) instance, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
return res;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC__1getVolume (JNIEnv *env, jobject _this, jboolean value)
{
jint res = 0;
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = libvlc_audio_get_volume( ( libvlc_instance_t * ) instance, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1setVolume (JNIEnv *env, jobject _this, jint volume)
{
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_audio_set_volume( ( libvlc_instance_t * ) instance, volume, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
}
/*
* Video native functions
*/
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1toggleFullscreen (JNIEnv *env, jobject _this)
{
long instance = 0;
libvlc_input_t *input;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
input = libvlc_playlist_get_input( ( libvlc_instance_t *) instance, exception );
libvlc_toggle_fullscreen( input, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1setFullscreen (JNIEnv *env, jobject _this, jboolean value)
{
long instance = 0;
libvlc_input_t *input;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
input = libvlc_playlist_get_input( ( libvlc_instance_t *) instance, exception );
libvlc_set_fullscreen( input, value, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
}
JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_JVLC__1getFullscreen (JNIEnv *env, jobject _this)
{
int res = 0;
libvlc_input_t *input;
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
input = libvlc_playlist_get_input( ( libvlc_instance_t *) instance, exception );
res = libvlc_get_fullscreen( input, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
return res;
}
/*
* Playlist native functions
*/
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1playlist_1add (JNIEnv *env, jobject _this, jstring uri, jstring name) {
long instance = 0;
int res = 0;
const char* psz_uri = env->GetStringUTFChars( uri, 0 );
const char* psz_name = env->GetStringUTFChars( name, 0 );
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
long instance = 0;
int res = 0;
const char* psz_uri = env->GetStringUTFChars( uri, 0 );
const char* psz_name = env->GetStringUTFChars( name, 0 );
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
instance = getPlaylistInstance( env, _this );
res = libvlc_playlist_add( (libvlc_instance_t*) instance, psz_uri, psz_name, exception );
res = libvlc_playlist_add( (libvlc_instance_t*) instance, psz_uri, psz_name, exception );
/// \todo check exceptions
/// \todo check exceptions
/* free resources */
free(exception);
if (psz_uri != NULL) {
env->ReleaseStringUTFChars( uri, psz_uri );
}
/* free resources */
free(exception);
if (psz_uri != NULL) {
env->ReleaseStringUTFChars( uri, psz_uri );
}
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
return res;
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1play (JNIEnv *env, jobject _this, jint id, jobjectArray options) {
long instance = 0;
int i_options = 0;
char** ppsz_options = NULL;
instance = getPlaylistInstance( env, _this );
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
long instance = 0;
int i_options = 0;
char** ppsz_options = NULL;
instance = getPlaylistInstance( env, _this );
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
libvlc_exception_init( exception );
if ( options != NULL ) ;
/// \TODO: parse options
if ( options != NULL ) ;
/// \TODO: parse options
libvlc_playlist_play( ( libvlc_instance_t* ) instance, id, i_options, ppsz_options, exception );
libvlc_playlist_play( ( libvlc_instance_t* ) instance, id, i_options, ppsz_options, exception );
free( exception );
return;
free( exception );
return;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1pause (JNIEnv *env, jobject _this) {
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_pause( ( libvlc_instance_t* ) instance, exception );
libvlc_playlist_pause( ( libvlc_instance_t* ) instance, exception );
free( exception );
return;
free( exception );
return;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1stop (JNIEnv *env, jobject _this) {
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_stop( ( libvlc_instance_t* ) instance, exception );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_stop( ( libvlc_instance_t* ) instance, exception );
free( exception );
return;
free( exception );
return;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1next (JNIEnv *env, jobject _this) {
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_next( ( libvlc_instance_t* ) instance, exception );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_next( ( libvlc_instance_t* ) instance, exception );
free( exception );
return;
free( exception );
return;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1prev (JNIEnv *env, jobject _this) {
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_prev( (libvlc_instance_t*) instance, exception );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_prev( (libvlc_instance_t*) instance, exception );
free( exception );
return;
free( exception );
return;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1clear (JNIEnv *env, jobject _this) {
long instance = 0;
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
long instance = 0;
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_clear( (libvlc_instance_t*) instance, exception );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_clear( (libvlc_instance_t*) instance, exception );
free( exception );
return;
free( exception );
return;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1itemsCount (JNIEnv *env, jobject _this) {
long instance = 0;
int res = 0;
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
long instance = 0;
int res = 0;
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = libvlc_playlist_items_count( (libvlc_instance_t*) instance, exception );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = libvlc_playlist_items_count( (libvlc_instance_t*) instance, exception );
free( exception );
return res;
free( exception );
return res;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1isPlaying (JNIEnv *env, jobject _this) {
long instance = 0;
int res = 0;
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
long instance = 0;
int res = 0;
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = libvlc_playlist_isplaying( (libvlc_instance_t*) instance, exception );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = libvlc_playlist_isplaying( (libvlc_instance_t*) instance, exception );
free( exception );
return res;
free( exception );
return res;
}
......@@ -228,17 +461,17 @@ JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1isPlaying (JNIEnv *env,
* Utility functions
*/
jlong getClassInstance (JNIEnv *env, jobject _this) {
/* get the id field of object */
jclass cls = env->GetObjectClass(_this);
jmethodID mid = env->GetMethodID(cls, "getInstance", "()J");
jlong field = env->CallLongMethod(_this, mid);
return field;
/* get the id field of object */
jclass cls = env->GetObjectClass(_this);
jmethodID mid = env->GetMethodID(cls, "getInstance", "()J");
jlong field = env->CallLongMethod(_this, mid);
return field;
}
jlong getPlaylistInstance (JNIEnv *env, jobject _this) {
/* get the instance field of object */
jclass cls = env->GetObjectClass(_this);
jmethodID mid = env->GetMethodID(cls, "getInstance", "()J");
jlong field = env->CallLongMethod(_this, mid);
return field;
/* get the instance field of object */
jclass cls = env->GetObjectClass(_this);
jmethodID mid = env->GetMethodID(cls, "getInstance", "()J");
jlong field = env->CallLongMethod(_this, mid);
return field;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment