Commit 7eee710f authored by Filippo Carone's avatar Filippo Carone

Java Bindings synched with lastest version.

parent fac890f0
......@@ -4,47 +4,42 @@
if BUILD_JAVA
OBJECTS = org/videolan/jvlc/VLCException.class org/videolan/jvlc/Playlist.class 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/GenericVideoWidget.class
OBJECTS = org/videolan/jvlc/VLCException.class org/videolan/jvlc/Playlist.class org/videolan/jvlc/AudioIntf.class org/videolan/jvlc/Audio.class org/videolan/jvlc/InputIntf.class org/videolan/jvlc/Input.class org/videolan/jvlc/PlaylistIntf.class org/videolan/jvlc/VideoIntf.class org/videolan/jvlc/Video.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/VLM.class org/videolan/jvlc/GenericVideoWidget.class
COBJECTS = src/utils.o src/video-jni.o src/audio-jni.o src/input-jni.o src/playlist-jni.o src/vlm-jni.o src/core-jni.o src/graphics-jni.o
# Include some JAVA stuff
PROCESSOR_FAMILY = `uname -m | sed -e 's/^i.86/i386/' | sed -e 's/^x86_64/amd64/'`
if HAVE_WIN32
JINCLUDES = -I${JAVA_HOME}/include -I${JAVA_HOME}/include/win32
LIBJINCLUDES = -L${JAVA_HOME}/lib -ljawt
#JAVAC = javac
JCH = javah
#CXX = g++ -Wall -mno-cygwin -g
#LDFLAGS = -mno-cygwin `vlc-config --libs external pic` -Wl,--kill-at
JAVACXXFLAGS = `top_builddir=../.. ../../vlc-config --cflags pic` -I../../ -I ../../include $(JINCLUDES)
JAVALDFLAGS = -mno-cygwin -L../../src -lvlc `top_builddir=../.. ../../vlc-config --libs builtin vlc pic` -Wl,--kill-at
else
JINCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
LIBJINCLUDES = -L$(JAVA_HOME)/jre/lib/$(PROCESSOR_FAMILY) -ljawt
#JAVAC = gcj -Wall -g -C
JCH = gcjh -jni
SWT_PATH = /usr/share/java
# Compile flags
JAVACXXFLAGS = `top_builddir=../.. ../../vlc-config --cflags pic` -I../../ -I ../../include $(JINCLUDES)
JAVALDFLAGS = -L../../src -lvlc `top_builddir=../.. ../../vlc-config --libs builtin vlc pic`
endif
export JINCLUDES
# Build targets
all: libjvlc.so VlcClient VLCExample
if HAVE_WIN32
libjvlc.so: vlc-libvlc-jni.o vlc-graphics-jni.o
$(CXX) -shared vlc-libvlc-jni.o vlc-graphics-jni.o $(LIBJINCLUDES) $(LDFLAGS) $(JAVALDFLAGS) -o jvlc.dll
libjvlc.so: $(OBJECTS)
$(MAKE) -C src
$(CXX) -shared $(COBJECTS) $(LIBJINCLUDES) $(LDFLAGS) $(JAVALDFLAGS) -o jvlc.dll
else
libjvlc.so: vlc-libvlc-jni.o vlc-graphics-jni.o
$(CXX) -shared vlc-libvlc-jni.o vlc-graphics-jni.o $(LIBJINCLUDES) $(LDFLAGS) $(JAVALDFLAGS) -o libjvlc.so
libjvlc.so: $(OBJECTS)
$(MAKE) -C src
$(CXX) -shared $(COBJECTS) $(LIBJINCLUDES) $(LDFLAGS) $(JAVALDFLAGS) -o libjvlc.so
endif
vlc-graphics-jni.o: VlcClient
$(CXX) -c vlc-graphics-jni.cc $(CXXFLAGS) $(JAVACXXFLAGS)
vlc-libvlc-jni.o: VlcClient
$(CXX) -c vlc-libvlc-jni.cc $(CXXFLAGS) $(JAVACXXFLAGS)
VlcClient: $(OBJECTS)
$(JAVAC) VlcClient.java
......@@ -54,14 +49,15 @@ VLCExample: $(OBJECTS)
if HAVE_WIN32
%.class: %.java
$(JAVAC) $?
$(JCH) org.videolan.jvlc.$(*F)
$(JCH) org.videolan.jvlc.$(*F) -o includes/$(*F).h
else
%.class: %.java
$(JAVAC) $?
$(JCH) org/videolan/jvlc/$(*F)
$(JCH) org/videolan/jvlc/$(*F) -o includes/$(*F).h
endif
clean:
rm -f *.class *~ org/videolan/jvlc/*.class org_videolan*.h *.so *.o *.dll
$(MAKE) -C src clean-local
endif
......@@ -32,9 +32,9 @@ public class VLCExample
if (videoInput) {
try {
System.out.print(jvlc.getVideoWidth());
System.out.print(jvlc.video.getWidth());
System.out.print("x");
System.out.println(jvlc.getVideoHeight());
System.out.println(jvlc.video.getHeight());
} catch (VLCException e) {
e.printStackTrace();
}
......@@ -43,32 +43,32 @@ public class VLCExample
{
if (videoInput) {
System.out.print("Fullscreen... ");
jvlc.setFullscreen(true);
jvlc.video.setFullscreen(true);
Thread.sleep(3000);
System.out.println("real size.");
jvlc.setFullscreen(false);
jvlc.video.setFullscreen(false);
System.out.print("Taking snapshot... ");
jvlc.getSnapshot( System.getProperty( "user.dir" ) + "/snap.png");
jvlc.video.getSnapshot( System.getProperty( "user.dir" ) + "/snap.png");
System.out.println("taken. (see " + System.getProperty( "user.dir" ) + "/snap.png )");
}
System.out.print("Muting...");
jvlc.setMute(true);
jvlc.audio.setMute(true);
Thread.sleep(3000);
System.out.println("unmuting.");
jvlc.setMute(false);
jvlc.audio.setMute(false);
Thread.sleep(3000);
System.out.println("Volume is: " + jvlc.getVolume());
System.out.println("Volume is: " + jvlc.audio.getVolume());
System.out.print("Setting volume to 150... ");
jvlc.setVolume(150);
jvlc.audio.setVolume(150);
System.out.println("done");
Thread.sleep(3000);
System.out.println("INPUT INFORMATION");
System.out.println("-----------------");
System.out.println("Total length (ms) :\t" + jvlc.getInputLength());
System.out.println("Input time (ms) :\t" + jvlc.getInputTime());
System.out.println("Input position [0-1]:\t" + jvlc.getInputPosition());
System.out.println("Total length (ms) :\t" + jvlc.input.getLength());
System.out.println("Input time (ms) :\t" + jvlc.input.getTime());
System.out.println("Input position [0-1]:\t" + jvlc.input.getPosition());
if (videoInput)
System.out.println("Input FPS :\t" + jvlc.getInputFPS());
System.out.println("Input FPS :\t" + jvlc.input.getFPS());
}
......
package org.videolan.jvlc;
public class Audio implements AudioIntf {
private long libvlcInstance;
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 Audio( long instance ) {
this.libvlcInstance = instance;
}
public boolean getMute() throws VLCException {
return _getMute();
}
public void setMute(boolean value) throws VLCException {
_setMute( value );
}
public void toggleMute() throws VLCException {
_toggleMute();
}
public int getVolume() throws VLCException {
return _getVolume();
}
public void setVolume(int volume) throws VLCException {
_setVolume( volume );
}
public long getInstance() {
return libvlcInstance;
}
}
package org.videolan.jvlc;
public class Input implements InputIntf {
private long libvlcInstance;
/*
* Input native methods
*/
private native long _getLength();
private native float _getPosition();
private native long _getTime();
private native float _getFPS();
private native void _setTime(long value);
private native void _setPosition(float value);
private native boolean _isPlaying();
private native boolean _hasVout();
public Input( long instance ) {
this.libvlcInstance = instance;
}
public long getLength() throws VLCException {
return _getLength();
}
public long getTime() throws VLCException {
return _getTime();
}
public float getPosition() throws VLCException {
return _getPosition();
}
public void setTime(long time) throws VLCException {
_setTime(time);
}
public void setPosition(float position) throws VLCException {
_setPosition(position);
}
public double getFPS() throws VLCException {
return _getFPS();
}
public boolean isPlaying() throws VLCException {
return _isPlaying();
}
public boolean hasVout() throws VLCException {
return _hasVout();
}
public long getInstance() {
return libvlcInstance;
}
}
......@@ -39,31 +39,49 @@ public interface InputIntf {
* @return The total length of the current file playing in millis.
* @throws VLCException
*/
long getInputLength() throws VLCException;
long getLength() throws VLCException;
/**
* @return The current position in millis within the playing item.
* @throws VLCException
*/
long getInputTime() throws VLCException;
long getTime() throws VLCException;
/**
* @return The position in %.
* @throws VLCException
*/
float getInputPosition() throws VLCException;
float getPosition() throws VLCException;
/**
* Not implemented
* Moves current input to position specified in a float [0-1].
* @param value The position, from 0 to 1, to move the input to.
* @throws VLCException
*/
void setInputTime() throws VLCException;
void setPosition( float value ) throws VLCException;
/**
* Moves current input to time specified in value
* @param value The time in milliseconds to move the input to.
* @throws VLCException
*/
void setTime(long value) throws VLCException;
/**
* @return If the playing item is a video file, returns the FPS, otherwise 0.
* @throws VLCException
*/
double getInputFPS() throws VLCException;
double getFPS() throws VLCException;
/**
* @return True if the current input is really playing
*/
boolean isPlaying() throws VLCException;
/**
* @return True if the current input has spawned a video output window
*/
boolean hasVout() throws VLCException;
}
......@@ -30,7 +30,8 @@
package org.videolan.jvlc;
public class JVLC implements JLibVLC, Runnable {
public class JVLC implements Runnable {
static {
System.loadLibrary("jvlc" );
......@@ -39,9 +40,13 @@ public class JVLC implements JLibVLC, Runnable {
/**
* These are set as final since they live along the jvlc object
*/
private final long _instance;
public final Playlist playlist;
private final long _instance;
public final Playlist playlist;
public final Video video;
public final Audio audio;
public final Input input;
public final VLM vlm;
private boolean beingDestroyed = false;
......@@ -57,14 +62,23 @@ public class JVLC implements JLibVLC, Runnable {
String[] args = new String[1];
args[0] = "";
_instance = createInstance(args);
playlist = new Playlist( _instance );
_instance = createInstance( args );
playlist = new Playlist ( _instance );
video = new Video ( _instance );
audio = new Audio ( _instance );
input = new Input ( _instance );
vlm = new VLM ( _instance );
new Thread(this).start();
}
public JVLC(String[] args) {
_instance = createInstance( args );
playlist = new Playlist( _instance );
_instance = createInstance( args );
playlist = new Playlist ( _instance );
video = new Video ( _instance );
audio = new Audio ( _instance );
input = new Input ( _instance );
vlm = new VLM ( _instance );
new Thread(this).start();
}
......@@ -82,123 +96,9 @@ public class JVLC implements JLibVLC, Runnable {
/*
* Core methods
*/
private native long createInstance();
private native long createInstance( String[] args );
private native void _destroy();
/*
* 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 );
/*
* Input native methods
*/
private native long _getInputLength();
private native float _getInputPosition();
private native long _getInputTime();
private native float _getInputFPS();
/*
* Video native methods
*/
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);
/*
* VLM native methods
*/
private native void _addBroadcast(String mediaName, String meditInputMRL, String mediaOutputMRL ,
String[] additionalOptions, boolean enableBroadcast, boolean isPlayableInLoop);
private native void _deleteMedia (String mediaName);
private native void _setEnabled (String mediaName, boolean newStatus);
private native void _setOutput (String mediaName, String mediaOutputMRL);
private native void _setInput (String mediaName, String mediaInputMRL);
private native void _setLoop (String mediaName, boolean isPlayableInLoop);
private native void _changeMedia (String newMediaName, String inputMRL, String outputMRL , String[] additionalOptions, boolean enableNewBroadcast, boolean isPlayableInLoop);
/*
* Native methods wrappers
*/
public boolean getMute() throws VLCException {
return _getMute();
}
public void setMute(boolean value) throws VLCException {
_setMute( value );
}
public void toggleMute() throws VLCException {
_toggleMute();
}
public int getVolume() throws VLCException {
return _getVolume();
}
public void setVolume(int volume) throws VLCException {
_setVolume( volume );
}
public void toggleFullscreen() throws VLCException {
_toggleFullscreen();
}
public void setFullscreen( boolean value ) throws VLCException {
_setFullscreen( value );
}
public boolean getFullscreen() throws VLCException {
return _getFullscreen();
}
public int getVideoHeight() throws VLCException {
return _getVideoHeight();
}
public int getVideoWidth() throws VLCException {
return _getVideoWidth();
}
public long getInputLength() throws VLCException {
return _getInputLength();
}
public long getInputTime() throws VLCException {
return _getInputTime();
}
public float getInputPosition() throws VLCException {
return _getInputPosition();
}
public void setInputTime() throws VLCException {
// TODO Auto-generated method stub
}
public double getInputFPS() throws VLCException {
return _getInputFPS();
}
public long getInstance() throws VLCException {
return _instance;
}
......@@ -211,42 +111,7 @@ public class JVLC implements JLibVLC, Runnable {
}
public void getSnapshot(String filename) throws VLCException {
_getSnapshot(filename);
}
public void addBroadcast( String name, String input, String output, String[] options, boolean enabled, boolean loop )
throws VLCException {
_addBroadcast(name, input, output, options, enabled, loop);
}
public void deleteMedia( String name ) throws VLCException {
_deleteMedia(name);
}
public void setEnabled( String name, boolean enabled ) throws VLCException {
_setEnabled(name, enabled);
}
public void setOutput( String name, String output ) throws VLCException {
_setOutput(name, output);
}
public void setInput( String name, String input ) throws VLCException {
_setInput(name, input);
}
public void setLoop( String name, boolean loop ) throws VLCException {
_setLoop(name, loop);
}
public void changeMedia( String name, String input, String output, String[] options, boolean enabled, boolean loop )
throws VLCException {
_changeMedia(name, input, output, options, enabled, loop);
}
/**
* Checks if the input is playing.
* @return True if there is a playing input.
......@@ -273,14 +138,14 @@ public class JVLC implements JLibVLC, Runnable {
while (! beingDestroyed) {
try {
while (playlist.isRunning()) {
if (playlist.inputIsPlaying()) {
if (input.isPlaying()) {
inputPlaying = true;
}
else {
inputPlaying = false;
}
if (playlist.inputHasVout()) {
if (input.hasVout()) {
inputVout = true;
}
else {
......@@ -302,6 +167,5 @@ public class JVLC implements JLibVLC, Runnable {
} // try
} // while ! being destroyed
} // run
}
......@@ -45,6 +45,11 @@ public class JVLCCanvas extends Canvas {
setSize(200, 200);
}
public JVLCCanvas(String[] args) {
jvlc = new JVLC(args);
setSize(200, 200);
}
/**
* @param width The initial canvas width
* @param height The initial canvas height
......@@ -53,6 +58,11 @@ public class JVLCCanvas extends Canvas {
jvlc = new JVLC();
setSize(width, height);
}
public JVLCCanvas(String[] args, int width, int height) {
jvlc = new JVLC(args);
setSize(width, height);
}
public JVLCCanvas(JVLC jvlc) {
this.jvlc = jvlc;
......
......@@ -50,8 +50,6 @@ public class Playlist implements PlaylistIntf {
native private int _itemsCount();
native private int _isRunning();
native private boolean _inputIsPlaying();
native private boolean _inputHasVout();
public synchronized void play(int id, String[] options) throws VLCException {
......@@ -113,13 +111,4 @@ public class Playlist implements PlaylistIntf {
public long getInstance() throws VLCException {
return libvlcInstance;
}
public synchronized boolean inputIsPlaying() throws VLCException {
return _inputIsPlaying();
}
public synchronized boolean inputHasVout() throws VLCException {
return _inputHasVout();
}
}
......@@ -61,11 +61,6 @@ public interface PlaylistIntf {
*/
int itemsCount() throws VLCException;
/**
* @return True if the current input is really playing
*/
boolean inputIsPlaying() throws VLCException;
/**
* Move to next item
*/
......@@ -94,8 +89,5 @@ public interface PlaylistIntf {
*/
void addExtended();
/**
* @return True if the current input has spawned a video output window
*/
boolean inputHasVout() throws VLCException;
}
/*****************************************************************************
* Status.java: VLC status thread
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 5-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;
/**
* In this thread we check the playlist status and the input status to see if:
* - the playlist is running
* - the input is playing
* - if the input has a vout child
*
*/
public class Status implements Runnable {
final JVLC jvlc;
public boolean inputPlaying;
public boolean inputVout;
private long resolution = 50;
public Status(JVLC jvlc) {
if (jvlc == null)
throw new RuntimeException("No jvlc instance.. I die");
if (jvlc.playlist == null)
throw new RuntimeException("No playlist instance.. I die");
this.jvlc = jvlc;
new Thread(this).start();
}
public void run() {
while (true) {
while (jvlc.playlist.isRunning()) {
if (jvlc.playlist.inputIsPlaying()) {
inputPlaying = true;
}
else {
inputPlaying = false;
}
if (jvlc.playlist.inputHasVout()) {
inputVout = true;
}
else {
inputVout = false;
}
try {
Thread.sleep(resolution);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
inputPlaying = false;
inputVout = false;
try {
Thread.sleep(resolution);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
package org.videolan.jvlc;
public class VLM implements VLMIntf {
private long libvlcInstance;
private native void _addBroadcast(String mediaName, String meditInputMRL,
String mediaOutputMRL, String[] additionalOptions,
boolean enableBroadcast, boolean isPlayableInLoop);