Try the software and report any errors or bugs you find to me. This application
needs porting to MS/Windows and MacOS, if you are able to implement the JNI for
-these platform you may contribute the code.
\ No newline at end of file
+these platforms you may contribute the code.
\ No newline at end of file
if BUILD_JAVA
-OBJECTS = org/videolan/jvlc/AudioIntf.class org/videolan/jvlc/InputIntf.class org/videolan/jvlc/PlaylistIntf.class org/videolan/jvlc/VideoIntf.class org/videolan/jvlc/JLibVLC.class org/videolan/jvlc/JVLC.class org/videolan/jvlc/JVLCCanvas.class org/videolan/jvlc/JVLCPanel.class org/videolan/jvlc/VLMIntf.class org/videolan/jvlc/Playlist.class
+OBJECTS = org/videolan/jvlc/AudioIntf.class org/videolan/jvlc/InputIntf.class org/videolan/jvlc/PlaylistIntf.class org/videolan/jvlc/VideoIntf.class org/videolan/jvlc/JLibVLC.class org/videolan/jvlc/JVLC.class org/videolan/jvlc/JVLCCanvas.class org/videolan/jvlc/JVLCPanel.class org/videolan/jvlc/VLMIntf.class org/videolan/jvlc/Playlist.class org/videolan/jvlc/Status.class
JNIHEADERS = org_videolan_jvlc_JVLC.h org_videolan_jvlc_JVLCCanvas.h org_videolan_jvlc_JVLCPanel.h
# Compile flags
JAVACXXFLAGS = `top_builddir=../.. ../../vlc-config --cflags pic` -I../../ -I ../../include $(JINCLUDES)
-JAVALDFLAGS = -L../../lib -lvlc_pic `top_builddir=../.. ../../vlc-config --libs builtin vlc pic`
+JAVALDFLAGS = -L../../src -lvlc `top_builddir=../.. ../../vlc-config --libs builtin vlc pic`
# Build targets
all: libjvlc.so VlcClient
-$Id$
+
First of all, this is a *developers* only version
In order to use these bindings you have to compile vlc from source. I
recommend you to take the latest version from videolan svn repository
-by doing:
+(or use at least revison 15823) by doing:
svn co svn://svn.videolan.org/vlc/trunk vlc-trunk
- bootstrap and configure. At the configure give the command:
+ bootstrap, clean and configure:
-./configure --enable-mozilla && make && make install
+./bootstrap && make distclean
+./configure --enable-java-bindings && make && make install
- to enable compilation of _pic version of libraries. If you give a
-prefix be sure to change the PREFIX variable in the Makefile from
- /usr/local to your prefix.
+ If you give a prefix be sure to change the PREFIX variable in the Makefile
+from /usr/local to your prefix.
Once you've done with vlc you can run make in jvlc directory. Be sure
you have gcj, gcjh and if you want to use the SUN Java compiler,
In the next releases I will automate this process.
- To run JVLC issue:
+ To run a Java VLC example issue:
java -Djava.library.path=. VlcClient
Be sure your ldconfig can find libjawt.so and libmawt.so or you will
get linking errors when you run the program.
- To try the SWT version of the player, issue:
-
-javac -cp /usr/share/java/swt-gtk.jar:. SWTUglyPlayer.java
-java -cp /usr/share/java/swt-gtk.jar:. -Djava.library.path=.:/usr/lib/jni SWTUglyPlayer
-
- using the appropriate paths.
-
Happy playing.
package org.videolan.jvlc;
public interface InputIntf {
+
/**
* This function returns the total length of the current file playing
* in millis.
* currently playing playlist item.
*/
long getInputTime();
- void getInputPosition();
+ long getInputPosition();
void setInputTime();
double getInputFPS();
+
}
private long _instance;
public Playlist playlist;
+ public Status status;
public JVLC() {
_instance = createInstance();
playlist = new Playlist( _instance );
+ status = new Status(this);
}
public JVLC(String[] args) {
_instance = createInstance( args );
playlist = new Playlist( _instance );
+ status = new Status(this);
}
/*
* Input native methods
*/
private native long _getInputLength();
+ private native long _getInputPosition();
private native long _getInputTime();
/*
* Video native methods
*/
- private native void _toggleFullscreen();
- private native void _setFullscreen( boolean value);
- private native boolean _getFullscreen();
+ private native void _toggleFullscreen();
+ private native void _setFullscreen( boolean value);
+ private native boolean _getFullscreen();
+ private native int _getVideoHeight();
+ private native int _getVideoWidth();
+ private native void _getSnapshot(String filename);
public boolean getMute() {
return _getFullscreen();
}
+ public int getVideoHeight() {
+ return _getVideoHeight();
+ }
+
+
+ public int getVideoWidth() {
+ return _getVideoWidth();
+ }
+
+
public long getInputLength() {
return _getInputLength();
}
return _getInputTime();
}
- public void getInputPosition() {
- // TODO Auto-generated method stub
+ public long getInputPosition() {
+ return _getInputPosition();
}
// TODO Auto-generated method stub
return 0;
}
-
+
public long getInstance() {
return _instance;
}
public Playlist getPlaylist() {
return playlist;
}
+
+
+ public void getSnapshot(String filename) {
+ _getSnapshot(filename);
+ }
}
-/*****************************************************************************
+ /*****************************************************************************
* PlaylistIntf.java: The playlist interface
*****************************************************************************
*
native private void _deleteItem(int itemID);
native private int _itemsCount();
- native private int _isPlaying();
+ native private int _isRunning();
+ native private boolean _inputIsPlaying();
+ native private boolean _inputHasVout();
- public void play(int id, String[] options) {
+ public synchronized void play(int id, String[] options) {
_play(id, options);
+ while (! _inputIsPlaying()) ;
}
- public void play() {
+ public synchronized void play() {
play(-1, null);
}
- public void pause() {
+ public synchronized void pause() {
_pause();
}
- public void stop() {
+ public synchronized void stop() {
_stop();
}
- public boolean isPlaying() {
- return (_isPlaying() == 0)? false : true ;
+ public boolean isRunning() {
+ return (_isRunning() == 0)? false : true ;
}
- public int itemsCount() {
+ public synchronized int itemsCount() {
return _itemsCount();
}
- public void next() {
- if (! isPlaying())
+ public synchronized void next() {
+ if (! isRunning())
play();
_next();
}
- public void prev() {
+ public synchronized void prev() {
+ if (! isRunning())
+ play();
_prev();
}
- public void clear() {
- if (! isPlaying())
- play();
- _clear();
+ public synchronized void clear() {
+ /*
+ * This method has been commented out until
+ * playlist_Clear has been fixed in vlc.
+ */
+ //_clear();
}
- public int add(String uri, String name, String[] options) {
+ public synchronized int add(String uri, String name, String[] options) {
return _playlist_add(uri, name, options);
}
- public int add(String uri, String name) {
+ public synchronized int add(String uri, String name) {
return add(uri, name, null);
}
- public void addExtended() {
+ public synchronized void addExtended() {
}
- public void deleteItem(int itemID) {
+ public synchronized void deleteItem(int itemID) {
_deleteItem(itemID);
}
public long getInstance() {
return libvlcInstance;
}
-
+ public synchronized boolean inputIsPlaying() {
+ return _inputIsPlaying();
+ }
+
+ public synchronized boolean inputHasVout() {
+ return _inputHasVout();
+ }
}
void play(int id, String[] options);
void pause();
void stop();
- boolean isPlaying();
+ boolean isRunning();
int itemsCount();
+ boolean inputIsPlaying();
void next();
void prev();
void clear();
int add(String uri, String name);
void addExtended();
+ boolean inputHasVout();
+
}
void toggleFullscreen();
void setFullscreen( boolean value );
boolean getFullscreen();
+ void getSnapshot(String filepath);
+ int getVideoHeight();
+ int getVideoWidth();
}
*
* 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.
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* These are a must*/
#include <jawt_md.h>
#include <X11/Xlib.h> // for Xlibs graphics functions
+#include <stdio.h> // for printf
/* JVLC internal imports, generated by gcjh */
#include "org_videolan_jvlc_JVLCCanvas.h"
JAWT_DrawingSurface* ds;
JAWT_DrawingSurfaceInfo* dsi;
JAWT_X11DrawingSurfaceInfo* dsi_x11;
- jboolean result;
+
jint lock;
GC gc;
vlc_value_t value;
- short i;
/* Get the AWT */
awt.version = JAWT_VERSION_1_3;
return;
}
+
+#ifdef WIN32
/* Get the platform-specific drawing info */
- dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
+ dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
+ /* Now paint */
+ value.i_int = reinterpret_cast<int>(dsi_win->hwnd);
+ VLC_VariableSet( 1, "drawable", value );
+
+#else // UNIX
+ /* Get the platform-specific drawing info */
+ dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
/* Now paint */
gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0);
value.i_int = dsi_x11->drawable;
VLC_VariableSet( 0, "drawable", value );
-
XFreeGC(dsi_x11->display, gc);
+#endif
+
/* Free the drawing surface info */
ds->FreeDrawingSurfaceInfo(dsi);
#include <stdio.h> // for printf
#include <stdlib.h> // for calloc
#include <string.h> // for strcmp
-
+#include <unistd.h> // for usleep
/* JVLC internal imports, generated by gcjh */
#include "org_videolan_jvlc_JVLC.h"
// res is the pointer to libvlc_instance_t
long res;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
+ char temp_argv[1][5] = {""};
libvlc_exception_init( exception );
- res = ( long ) libvlc_new( 0, NULL, exception );
+
+ res = ( long ) libvlc_new( 0, (char **)temp_argv, exception );
if ( libvlc_exception_raised( exception ))
{
free( exception );
+ //libvlc_playlist_lock( ( libvlc_instance_t * ) res, NULL);
+
return res;
}
return res;
}
+JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1getSnapshot (JNIEnv *env, jobject _this, jstring filepath)
+{
+ const char* psz_filepath = env->GetStringUTFChars( filepath, 0 );
+ libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
+ long instance = 0;
+ libvlc_input_t *input;
+
+ libvlc_exception_init( exception );
+
+ instance = getPlaylistInstance( env, _this );
+
+ input = libvlc_playlist_get_input( ( libvlc_instance_t *) instance, exception );
+
+ if ( libvlc_exception_raised( exception ))
+ {
+ ///\TODO: raise java exception
+ printf("%s\n", libvlc_exception_get_message( exception ));
+ }
+
+ libvlc_video_take_snapshot( input, (char *) psz_filepath, exception );
+
+ if ( libvlc_exception_raised( exception ))
+ {
+ ///\TODO: raise java exception
+ printf("%s\n", libvlc_exception_get_message( exception ));
+ }
+
+
+ if (psz_filepath != NULL) {
+ env->ReleaseStringUTFChars( filepath, psz_filepath );
+ }
+
+}
+
+JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC__1getVideoHeight (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_video_get_height( input, 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__1getVideoWidth (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_video_get_width( 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 void JNICALL Java_org_videolan_jvlc_Playlist__1play (JNIEnv *env, jobject _this, jint id, jobjectArray options) {
- long instance = 0;
int i_options = 0;
const char** ppsz_options = NULL;
- instance = getPlaylistInstance( env, _this );
+
+ libvlc_instance_t *p_instance = ( libvlc_instance_t * ) getPlaylistInstance( env, _this );
+
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
}
}
- libvlc_playlist_play( ( libvlc_instance_t * ) instance, id, i_options, ( char ** ) ppsz_options, exception );
+ libvlc_playlist_play( p_instance, id, i_options, ( char ** ) ppsz_options, exception );
free( exception );
return;
}
-JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1isPlaying (JNIEnv *env, jobject _this) {
+JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1isRunning (JNIEnv *env, jobject _this) {
long instance = 0;
int res = 0;
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
}
+JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Playlist__1inputIsPlaying (JNIEnv *env, jobject _this)
+{
+ vlc_bool_t res = 0;
+ long instance = 0;
+ libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
+ libvlc_input_t *input;
+
+ libvlc_exception_init( exception );
+ instance = getPlaylistInstance( env, _this );
+
+ input = libvlc_playlist_get_input( ( libvlc_instance_t* ) instance, exception );
+ /// \todo check exceptions
+
+ res = libvlc_input_will_play( input, exception );
+ /// \todo check exceptions
+
+ free( exception );
+ return res;
+}
+
+JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Playlist__1inputHasVout (JNIEnv *env, jobject _this)
+{
+ vlc_bool_t res = 0;
+ long instance = 0;
+ libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
+ libvlc_input_t *input;
+
+ libvlc_exception_init( exception );
+ instance = getPlaylistInstance( env, _this );
+
+ input = libvlc_playlist_get_input( ( libvlc_instance_t* ) instance, exception );
+ /// \todo check exceptions
+
+ res = libvlc_input_has_vout( input, exception );
+ /// \todo check exceptions
+
+ free( exception );
+ return res;
+}
+
/*
* Input handling functions
*/