Commit 0627647f authored by Filippo Carone's avatar Filippo Carone

Java bindings update.

* new JVLC.destroy() method to cleanup a JVLC object
* new GenericVideoWidget for general use (thx: Kuldipsingh Pabla)
* Status class removed
* new JVLC.isInputPlaying() and JVLC.hasVout() methods
parent 599b0d51
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
if BUILD_JAVA 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 org/videolan/jvlc/Status.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/GenericVideoWidget.class
JNIHEADERS = org_videolan_jvlc_JVLC.h org_videolan_jvlc_JVLCCanvas.h org_videolan_jvlc_JVLCPanel.h JNIHEADERS = org_videolan_jvlc_JVLC.h org_videolan_jvlc_JVLCCanvas.h org_videolan_jvlc_JVLCPanel.h
......
...@@ -2,6 +2,7 @@ Thanks to: ...@@ -2,6 +2,7 @@ Thanks to:
* Kuldipsingh Pabla * Kuldipsingh Pabla
for solaris port and various contributions to the native interface. for solaris port and various contributions to the native interface.
for the GenericVideoWidget class
* Tvrtko Bedekovic * Tvrtko Bedekovic
for initial win32 port for initial win32 port
......
/*****************************************************************************
* SWTVideoWidget.java: A component usable in SWT Application, embeds JVLC
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Kuldipsingh Pabla <Kuldipsingh.Pabla@sun.com>
*
* Created on 10-jun-2006
*
* $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 (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.
*
*/
package org.videolan.jvlc;
import java.awt.Frame;
import java.awt.Component;
public class GenericVideoWidget {
/*
* This class implements a Composite container for VLC Video Output
*/
/*
* The root SWT Frame we embed JVLCCanvas in
*/
public Frame rootFrame;
private JVLCCanvas jvlcCanvas;
public GenericVideoWidget( Component parent ) {
// allocate the new AWT Frame to embed in the Composite
rootFrame = new Frame ();
// add the JVLCCanvas to the Frame
jvlcCanvas = new JVLCCanvas();
rootFrame.add( jvlcCanvas );
}
public JVLC getJVLC() {
return jvlcCanvas.getJVLC();
}
}
...@@ -29,35 +29,57 @@ ...@@ -29,35 +29,57 @@
package org.videolan.jvlc; package org.videolan.jvlc;
public class JVLC implements JLibVLC { /**
* @author little
*
*/
public class JVLC implements JLibVLC, Runnable {
static { static {
System.load(System.getProperty( "user.dir" ) + "/libjvlc.so" ); System.load(System.getProperty( "user.dir" ) + "/libjvlc.so" );
} }
/**
* These are set as final since they live along the jvlc object
*/
private final long _instance;
public final Playlist playlist;
private long _instance;
public Playlist playlist; private boolean beingDestroyed = false;
public Status status; private long resolution = 50;
private boolean inputPlaying = false;
private boolean inputVout = false;
public JVLC() { public JVLC() {
_instance = createInstance(); _instance = createInstance();
playlist = new Playlist( _instance ); playlist = new Playlist( _instance );
status = new Status(this); new Thread(this).start();
} }
public JVLC(String[] args) { public JVLC(String[] args) {
_instance = createInstance( args ); _instance = createInstance( args );
playlist = new Playlist( _instance ); playlist = new Playlist( _instance );
status = new Status(this); new Thread(this).start();
} }
/*
/**
* Destroys the current instance of jvlc, cleaning up objects.
* This is unreversible.
*/
public void destroy() {
beingDestroyed = true;
_destroy();
}
/*
* Core methods * Core methods
*/ */
private native long createInstance(); private native long createInstance();
private native long createInstance( String[] args ); private native long createInstance( String[] args );
private native void _destroy();
/* /*
* Audio native methods * Audio native methods
*/ */
...@@ -170,5 +192,60 @@ public class JVLC implements JLibVLC { ...@@ -170,5 +192,60 @@ public class JVLC implements JLibVLC {
public void getSnapshot(String filename) { public void getSnapshot(String filename) {
_getSnapshot(filename); _getSnapshot(filename);
} }
/**
* Checks if the input is playing.
* @return True if there is a playing input.
*/
public boolean isInputPlaying() {
return inputPlaying;
}
/**
* Checks if the input has spawned a video window.
* @return True if there is a video window.
*/
public boolean hasVout() {
return inputVout;
}
/*
* (non-Javadoc)
* @see java.lang.Runnable#run()
*
* In this thread we check the playlist and input status.
*/
public void run() {
while (! beingDestroyed) {
while (playlist.isRunning()) {
if (playlist.inputIsPlaying()) {
inputPlaying = true;
}
else {
inputPlaying = false;
}
if (playlist.inputHasVout()) {
inputVout = true;
}
else {
inputVout = false;
}
try {
Thread.sleep(resolution);
} catch (InterruptedException e) {
e.printStackTrace();
}
} // while playlist running
inputPlaying = false;
inputVout = false;
try {
Thread.sleep(resolution);
} catch (InterruptedException e) {
e.printStackTrace();
} // try
} // while ! being destroyed
} // run
} }
...@@ -93,11 +93,7 @@ public class Playlist implements PlaylistIntf { ...@@ -93,11 +93,7 @@ public class Playlist implements PlaylistIntf {
} }
public synchronized void clear() { public synchronized void clear() {
/* _clear();
* This method has been commented out until
* playlist_Clear has been fixed in vlc.
*/
//_clear();
} }
public synchronized int add(String uri, String name, String[] options) { public synchronized int add(String uri, String name, String[] options) {
......
...@@ -29,12 +29,48 @@ ...@@ -29,12 +29,48 @@
package org.videolan.jvlc; package org.videolan.jvlc;
/**
* @author little
*
*/
/**
* @author little
*
*/
public interface VideoIntf { public interface VideoIntf {
void toggleFullscreen(); /**
void setFullscreen( boolean value ); * Toggles the fullscreen.
*/
void toggleFullscreen();
/**
* Sets fullscreen if fullscreen argument is true.
* @param fullscreen
*/
void setFullscreen( boolean fullscreen );
/**
* @return True if the current video window is in fullscreen mode.
*/
boolean getFullscreen(); boolean getFullscreen();
void getSnapshot(String filepath);
int getVideoHeight();
int getVideoWidth();
/**
* Saves a snapshot of the current video window.
* @param filepath The full path (including filename) were to save the snapshot to.
*/
void getSnapshot(String filepath);
/**
* @return The current video window height
*/
int getVideoHeight();
/**
* @return The current video window width
*/
int getVideoWidth();
} }
...@@ -91,6 +91,20 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance___3Ljava_lang ...@@ -91,6 +91,20 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance___3Ljava_lang
} }
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1destroy (JNIEnv *env, jobject _this)
{
long instance;
instance = getClassInstance( env, _this );
libvlc_destroy( (libvlc_instance_t *) instance);
return;
}
/* /*
* Audio native functions * Audio native functions
*/ */
......
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