java bindings huge update

This commit is contained in:
Filippo Carone 2008-03-09 01:53:36 +01:00
parent 4713a3672c
commit daa85a7f57
43 changed files with 1151 additions and 3272 deletions

View File

@ -102,6 +102,7 @@ S: France
N: Filippo Carone
E: filippo[dontspam]@carone.org
C: littlejohn
D: Java bindings
S: Italy

View File

@ -1 +1 @@
SUBDIRS = python java
SUBDIRS = python

View File

@ -1,68 +0,0 @@
#######################################################################
# VLC Java Bindings
#######################################################################
SUBDIRS= . src
EXTRA_DIST= \
FAQ \
TODO \
README \
THANKS \
javadoc.xml \
VlcClient.java \
VLCExample.java
EXTRA_DIST+= \
org/videolan/jvlc/AudioIntf.java \
org/videolan/jvlc/Audio.java \
org/videolan/jvlc/GenericVideoWidget.java \
org/videolan/jvlc/InputIntf.java \
org/videolan/jvlc/Input.java \
org/videolan/jvlc/JLibVLC.java \
org/videolan/jvlc/JVLCCanvas.java \
org/videolan/jvlc/JVLC.java \
org/videolan/jvlc/JVLCPanel.java \
org/videolan/jvlc/PlaylistIntf.java \
org/videolan/jvlc/Playlist.java \
org/videolan/jvlc/VideoIntf.java \
org/videolan/jvlc/Video.java \
org/videolan/jvlc/VLCException.java \
org/videolan/jvlc/VLMIntf.java \
org/videolan/jvlc/VLM.java \
org/videolan/jvlc/listener/VolumeListener.java
if BUILD_JAVA
OBJECTS = org/videolan/jvlc/VLM.class 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/JVLCCanvas.class org/videolan/jvlc/Video.class org/videolan/jvlc/JLibVLC.class org/videolan/jvlc/JVLC.class org/videolan/jvlc/JVLCPanel.class org/videolan/jvlc/VLMIntf.class org/videolan/jvlc/GenericVideoWidget.class org/videolan/jvlc/listener/VolumeListener.class
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
else
JINCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
LIBJINCLUDES = -L$(JAVA_HOME)/jre/lib/$(PROCESSOR_FAMILY) -ljawt
endif
export JINCLUDES
export LIBJINCLUDES
# Build targets
%.class: %.java
$(JAVAC) $?
VlcClient: $(OBJECTS)
$(JAVAC) VlcClient.java
VLCExample: $(OBJECTS)
$(JAVAC) VLCExample.java
all-am: VlcClient VLCExample
clean-local:
rm -f *.class *~ org/videolan/jvlc/*.class src/*.o *.so *.o *.dll
endif

View File

@ -2,33 +2,40 @@
First of all, this is a *developers* only version
Usage
-----
Compiling JVLC
--------------
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
(or use at least revison 18443) by doing:
In order to use these bindings you have to compile vlc from source, be sure
to use the latest git version (see http://wiki.videolan.org/Git for instructions
on how to get the latest vlc version).
svn co svn://svn.videolan.org/vlc/trunk vlc-trunk
JVLC depends on JNA, you can download JNA from http://jna.dev.java.net .
bootstrap, clean, set environment variables, configure and build:
JVLC is developed using the Sun JDK version 6, but version 5 should be fine too.
./bootstrap
Until the build.xml will be ready, you may compile jvlc issueing from the bindings
java folder:
export JAVA_HOME=/path/to/jvm
(for example i have JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun)
mkdir output
javac -d output -cp <path-to>/jna.jar -g org/videolan/jvlc/internal/*.java org/videolan/jvlc/event/*.java org/videolan/jvlc/*.java VLCExample.java VlcClient.java
./configure --enable-java-bindings && make && make install
where <path-to> is the folder where the file jna.jar is contained
and in the output folder you'll find the compiled classes.
You may also import jvlc in eclipse running the createEclipseProject.sh script.
Running JVLC Example
--------------------
To run a Java VLC example issue (be sure you have an a.avi and a.mp3 files
in your user.dir folder):
java -Djava.library.path=/usr/local/lib VLCExample
java -cp .:<path-to>jna.jar -Djna.library.path=/usr/local/lib VLCExample
(if you have specified a prefix in configure, change /usr/local/lib to
PREFIX/lib)
Be sure your ldconfig can find libjawt.so and libmawt.so or you will
get linking errors when you run the program.
Happy playing.

View File

@ -1,7 +1,10 @@
import org.videolan.jvlc.AudioIntf;
import org.videolan.jvlc.JVLC;
import org.videolan.jvlc.MediaDescriptor;
import org.videolan.jvlc.MediaInstance;
import org.videolan.jvlc.Playlist;
import org.videolan.jvlc.VLCException;
import org.videolan.jvlc.listener.VolumeListener;
import org.videolan.jvlc.Video;
import org.videolan.jvlc.event.MediaInstanceListener;
public class VLCExample
@ -24,131 +27,147 @@ public class VLCExample
}
}
JVLC jvlc = new JVLC(args);
Playlist playlist = new Playlist(jvlc);
System.out.println("... done.");
MediaDescriptor mediaDescriptor = new MediaDescriptor(jvlc, "/home/carone/a.avi");
MediaInstance mediaInstance = mediaDescriptor.getMediaInstance();
mediaInstance.addListener(new MediaInstanceListener()
{
@Override
public void endReached(MediaInstance mediaInstance)
{
System.out.println("Media instance end reached. MRL: " + mediaInstance.getMediaDescriptor().getMrl());
}
@Override
public void paused(MediaInstance mediaInstance)
{
System.out.println("Media instance paused. MRL: " + mediaInstance.getMediaDescriptor().getMrl());
}
@Override
public void played(MediaInstance mediaInstance)
{
System.out.println("Media instance played. MRL: " + mediaInstance.getMediaDescriptor().getMrl());
}
@Override
public void positionChanged(MediaInstance mediaInstance)
{
// TODO Auto-generated method stub
}
@Override
public void timeChanged(MediaInstance mediaInstance, long newTime)
{
System.out.println("new time: " + newTime);
}
});
mediaInstance.play();
// MediaInstance mediaInstance = playlist.getMediaInstance();
//
// while (! mediaInstance. playlist.isPlaying())
// {
// Thread.sleep(100);
// }
// while (! jvlc.hasVout() )
// {
// Thread.sleep(100);
// }
// testing vout functionalities
// Thread.sleep(2500);
// if (jvlc.hasVout())
// {
// videoInput = true;
// }
//
// if (videoInput)
// {
try
{
// jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.avi", "a.avi");
jvlc.playlist.add("file:///home/little/a.avi", "a.avi");
// jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.mp3", "a.mp3");
jvlc.playlist.play(-1, null);
Video video = new Video(jvlc);
System.out.print(video.getWidth(mediaInstance));
System.out.print("x");
System.out.println(video.getHeight(mediaInstance));
System.out.print("Fullscreen... ");
video.setFullscreen(mediaInstance, true);
Thread.sleep(3000);
System.out.println("real size.");
video.setFullscreen(mediaInstance, false);
System.out.print("Taking snapshot... ");
video.getSnapshot(mediaInstance, System.getProperty("user.dir") + "/snap.png", 0, 0);
System.out.println("taken. (see " + System.getProperty("user.dir") + "/snap.png )");
Thread.sleep(2000);
System.out.println("Resizing to 300x300");
video.setSize(300, 300);
}
catch (VLCException e)
{
e.printStackTrace();
}
while (! jvlc.isInputPlaying())
{
Thread.sleep(100);
}
while (! jvlc.hasVout() )
{
Thread.sleep(100);
}
// testing vout functionalities
Thread.sleep(2500);
if (jvlc.hasVout())
{
videoInput = true;
}
if (videoInput)
{
try
{
System.out.print(jvlc.video.getWidth());
System.out.print("x");
System.out.println(jvlc.video.getHeight());
}
catch (VLCException e)
{
e.printStackTrace();
}
}
try
{
if (videoInput)
{
System.out.print("Fullscreen... ");
jvlc.video.setFullscreen(true);
Thread.sleep(3000);
System.out.println("real size.");
jvlc.video.setFullscreen(false);
System.out.print("Taking snapshot... ");
jvlc.video.getSnapshot(System.getProperty("user.dir") + "/snap.png",0,0);
System.out.println("taken. (see " + System.getProperty("user.dir") + "/snap.png )");
Thread.sleep(2000);
System.out.println("Resizing to 300x300");
jvlc.video.setSize(300, 300);
}
jvlc.audio.addVolumeListener(new VolumeListener()
{
public void volumeChanged() {
System.out.println("====> From the listener: volume changed.");
}
});
System.out.print("Muting...");
jvlc.audio.setMute(true);
Thread.sleep(3000);
System.out.println("unmuting.");
jvlc.audio.setMute(false);
Thread.sleep(3000);
System.out.println("Volume is: " + jvlc.audio.getVolume());
System.out.print("Setting volume to 150... ");
jvlc.audio.setVolume(150);
System.out.println("done");
System.out.println("== AUDIO INFO ==");
int currentChannel = jvlc.audio.getChannel();
System.out.println("Audio track number: " + jvlc.audio.getTrack());
System.out.println("Audio channel info: " + jvlc.audio.getChannel());
System.out.print("Setting left channel... ");
jvlc.audio.setChannel(AudioIntf.LEFT_CHANNEL);
System.out.println("done.");
Thread.sleep(3000);
System.out.print("Setting right channel... ");
jvlc.audio.setChannel(AudioIntf.RIGHT_CHANNEL);
System.out.println("done.");
Thread.sleep(3000);
System.out.print("Reverting to original channel");
jvlc.audio.setChannel(currentChannel);
System.out.println("done.");
Thread.sleep(3000);
System.out.println("INPUT INFORMATION");
System.out.println("-----------------");
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.input.getFPS());
}
catch (Exception e)
{
System.out.println("Something was wrong. I die :(.");
jvlc.destroy();
e.printStackTrace();
System.exit(0);
}
// System.out.print("Muting...");
// jvlc.audio.setMute(true);
// Thread.sleep(3000);
// System.out.println("unmuting.");
// jvlc.audio.setMute(false);
// Thread.sleep(3000);
// System.out.println("Volume is: " + jvlc.audio.getVolume());
// System.out.print("Setting volume to 150... ");
// jvlc.audio.setVolume(150);
// System.out.println("done");
// System.out.println("== AUDIO INFO ==");
// int currentChannel = jvlc.audio.getChannel();
// System.out.println("Audio track number: " + jvlc.audio.getTrack());
// System.out.println("Audio channel info: " + jvlc.audio.getChannel());
// System.out.print("Setting left channel... ");
// jvlc.audio.setChannel(AudioIntf.LEFT_CHANNEL);
// System.out.println("done.");
// Thread.sleep(3000);
// System.out.print("Setting right channel... ");
// jvlc.audio.setChannel(AudioIntf.RIGHT_CHANNEL);
// System.out.println("done.");
// Thread.sleep(3000);
// System.out.print("Reverting to original channel");
// jvlc.audio.setChannel(currentChannel);
// System.out.println("done.");
// Thread.sleep(3000);
// System.out.println("INPUT INFORMATION");
// System.out.println("-----------------");
// 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.input.getFPS());
//
// }
//
// catch (Exception e)
// {
// System.out.println("Something was wrong. I die :(.");
// jvlc.destroy();
// e.printStackTrace();
// System.exit(0);
// }
System.out.println("Everything fine ;)");
System.out.println("Playing next item");
try
{
jvlc.playlist.next();
}
catch (VLCException e)
{
e.printStackTrace();
}
// try
// {
// jvlc.playlist.next();
// }
// catch (VLCException e)
// {
// e.printStackTrace();
// }
//
// Thread.sleep(3000);
Thread.sleep(3000);
jvlc.destroy();
// jvlc.destroy();
return;
}
}

View File

@ -23,31 +23,49 @@
*
*/
import java.awt.Canvas;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import org.videolan.jvlc.JVLCPanel;
import javax.swing.JPanel;
import org.videolan.jvlc.JVLC;
import org.videolan.jvlc.Playlist;
import org.videolan.jvlc.VLCException;
class VLCPlayerFrame extends Frame {
public VLCPlayerFrame() {
class VLCPlayerFrame extends Frame
{
private Playlist playlist;
public Canvas jvcanvas;
public VLCPlayerFrame()
{
initComponents();
}
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
private void initComponents()
{
fullScreenButton = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
setButton = new javax.swing.JButton();
pauseButton = new javax.swing.JButton();
stopButton = new javax.swing.JButton();
java.awt.GridBagConstraints gridBagConstraints;
jvcc = new JVLCPanel();
jvlc = jvcc.getJVLCObject();
fullScreenButton = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
setButton = new javax.swing.JButton();
pauseButton = new javax.swing.JButton();
stopButton = new javax.swing.JButton();
jvcc = new JPanel();
jvcanvas = new java.awt.Canvas();
jvcanvas.setSize(200, 200);
jvcc.add(jvcanvas);
jvlc = new JVLC();
playlist = new Playlist(jvlc);
setLayout(new java.awt.GridBagLayout());
@ -55,11 +73,14 @@ class VLCPlayerFrame extends Frame {
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.CENTER;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
add( jvcc , gridBagConstraints);
add(jvcc, gridBagConstraints);
fullScreenButton.setText("FullScreen");
fullScreenButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fullScreenButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
fullScreenButtonActionPerformed(evt);
}
});
@ -68,8 +89,7 @@ class VLCPlayerFrame extends Frame {
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
add( fullScreenButton, gridBagConstraints);
add(fullScreenButton, gridBagConstraints);
jTextField1.setText("file://a.avi");
gridBagConstraints = new java.awt.GridBagConstraints();
@ -79,10 +99,12 @@ class VLCPlayerFrame extends Frame {
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
add(jTextField1, gridBagConstraints);
setButton.setText("Set item");
setButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
setButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
setButtonActionPerformed(evt);
}
});
@ -92,10 +114,12 @@ class VLCPlayerFrame extends Frame {
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
add(setButton, gridBagConstraints);
pauseButton.setText("Play/Pause");
pauseButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pauseButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
pauseButtonActionPerformed(evt);
}
});
@ -106,8 +130,11 @@ class VLCPlayerFrame extends Frame {
add(pauseButton, gridBagConstraints);
stopButton.setText("Stop");
stopButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
stopButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
stopButtonActionPerformed(evt);
}
});
@ -116,67 +143,89 @@ class VLCPlayerFrame extends Frame {
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
add(stopButton, gridBagConstraints);
pack();
}
private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {
try {
//mci.stop(new Position(10000, PositionOrigin.ABSOLUTE, PositionKey.MEDIATIME));
jvlc.playlist.stop();
} catch (Exception e) {
private void stopButtonActionPerformed(java.awt.event.ActionEvent evt)
{
try
{
playlist.stop();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) {
try {
//System.out.println(mci.getMediaPosition(PositionOrigin.ABSOLUTE, PositionKey.BYTECOUNT));
jvlc.playlist.togglePause();
} catch (Exception e) {
private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt)
{
try
{
playlist.togglePause();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
private void setButtonActionPerformed(java.awt.event.ActionEvent evt) {
try {
jvlc.playlist.add("file://a.avi", "a.avi");
jvlc.playlist.play(-1, null);
} catch (VLCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
private void setButtonActionPerformed(java.awt.event.ActionEvent evt)
{
try
{
jvlc.setVideoOutput(jvcanvas);
playlist.add(jTextField1.getText(), "a.avi");
playlist.play();
}
catch (VLCException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void fullScreenButtonActionPerformed(java.awt.event.ActionEvent evt) {
//jvlc.fullScreen();
private void fullScreenButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// jvlc.fullScreen();
}
private javax.swing.JButton setButton;
private javax.swing.JButton pauseButton;
private javax.swing.JButton stopButton;
private javax.swing.JButton fullScreenButton;
private javax.swing.JTextField jTextField1;
private JVLCPanel jvcc;
private JPanel jvcc;
public JVLC jvlc;
//MediaControlInstance mci;
// MediaControlInstance mci;
}
public class VlcClient {
public class VlcClient
{
public static void main(String[] args) {
Frame f = new VLCPlayerFrame();
f.setBounds(0, 0, 500, 500);
f.addWindowListener( new WindowAdapter() {
public void windowClosing(WindowEvent ev) {
System.exit(0);
}
} );
f.setVisible(true);
public static void main(String[] args)
{
Frame f = new VLCPlayerFrame();
f.setBounds(0, 0, 500, 500);
f.addWindowListener(new WindowAdapter()
{
@Override
public void windowClosing(WindowEvent ev)
{
System.exit(0);
}
});
f.setVisible(true);
}
}

View File

@ -1,114 +0,0 @@
package org.videolan.jvlc;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.videolan.jvlc.listener.VolumeListener;
public class Audio implements AudioIntf {
private long libvlcInstance;
private native int _getTrack();
private native void _setTrack(int track);
private native int _getChannel();
private native void _setChannel(int channel);
private native boolean _getMute();
private native void _setMute(boolean value);
private native void _toggleMute();
private native int _getVolume();
private native void _setVolume(int volume);
private native void _install_callback();
private static Map objListeners = new HashMap();
public Audio(long instance) {
this.libvlcInstance = instance;
install_callaback();
}
private void install_callaback() {
objListeners.put(this, new HashSet());
_install_callback();
}
public int getTrack() throws VLCException {
return _getTrack();
}
public void setTrack(int track) throws VLCException {
_setTrack(track);
}
public int getChannel() throws VLCException {
return _getChannel();
}
public void setChannel(int channel) throws VLCException {
_setChannel(channel);
}
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 boolean addVolumeListener(VolumeListener listener) {
HashSet listeners = (HashSet) objListeners.get(this);
return listeners.add(listener);
}
public boolean removeVolumeListener(VolumeListener listener) {
HashSet listeners = (HashSet) objListeners.get(this);
return listeners.remove(listener);
}
// this method is invoked natively
private static void wakeupListeners() {
Set audioObjects = objListeners.keySet();
Iterator audioObjectsIterator = audioObjects.iterator();
while (audioObjectsIterator.hasNext()) {
Audio audioObject = (Audio) audioObjectsIterator.next();
HashSet listeners = (HashSet) objListeners.get(audioObject);
Iterator listenerIterator = listeners.iterator();
while (listenerIterator.hasNext()) {
VolumeListener listener = (VolumeListener) listenerIterator.next();
listener.volumeChanged();
}
}
}
public long getInstance() {
return libvlcInstance;
}
}

View File

@ -1,112 +0,0 @@
/*****************************************************************************
* AudioIntf.java: Audio methods interface
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-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;
public interface AudioIntf {
/**
* Constant for left channel audio
*/
final int LEFT_CHANNEL = 3;
/**
* Constant for right channel audio
*/
final int RIGHT_CHANNEL = 4;
/**
* Constant for reverse channel audio
*/
final int REVERSE_CHANNEL = 2;
/**
* Constant for stereo channel audio
*/
final int STEREO_CHANNEL = 1;
/**
* Constant for dolby channel audio
*/
final int DOLBY_CHANNEL = 5;
/**
* @return audio track
* @throws VLCException
*/
int getTrack() throws VLCException;
/**
* @param audio track
* @throws VLCException
*/
void setTrack(int track) throws VLCException;
/**
* @return channel
* @throws VLCException
*/
int getChannel() throws VLCException;
/**
* @param channel
* @throws VLCException
*/
void setChannel(int channel) throws VLCException;
/**
* @return True if input is currently muted.
* @throws VLCException
*/
boolean getMute() throws VLCException;
/**
* @param value If true, then the input is muted.
* @throws VLCException
*/
void setMute(boolean value) throws VLCException;
/**
* Toggles mute
* @throws VLCException
*/
void toggleMute() throws VLCException;
/**
* @return The volume level
* @throws VLCException
*/
int getVolume() throws VLCException;
/**
* @param volume The volume level (0-200) to set.
* @throws VLCException
*/
void setVolume(int volume) throws VLCException;
}

View File

@ -1,59 +0,0 @@
/*****************************************************************************
* 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();
}
}

View File

@ -1,61 +0,0 @@
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() throws VLCException;
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;
}
}

View File

@ -1,87 +0,0 @@
/*****************************************************************************
* InputIntf.java: Input interface
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-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;
/**
* @author little
*
*/
public interface InputIntf {
/**
* @return The total length of the current file playing in millis.
* @throws VLCException
*/
long getLength() throws VLCException;
/**
* @return The current position in millis within the playing item.
* @throws VLCException
*/
long getTime() throws VLCException;
/**
* @return The position in %.
* @throws VLCException
*/
float getPosition() throws VLCException;
/**
* 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 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 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;
}

View File

@ -1,31 +0,0 @@
/*****************************************************************************
* JLibVLC.java: Main library interface
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-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;
public interface JLibVLC extends AudioIntf, VideoIntf, InputIntf, VLMIntf { }

View File

@ -2,14 +2,14 @@
* JVLC.java: Main Java Class, represents a libvlc_instance_t object
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
* Copyright (C) 1998-2008 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
* Philippe Morin <phmorin@free.fr>
*
* Created on 28-feb-2006
*
* $Id$
* $Id: JVLC.java 20141 2007-05-16 19:31:35Z littlejohn $
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public License
@ -27,147 +27,90 @@
*
*/
package org.videolan.jvlc;
public class JVLC implements Runnable {
static {
System.loadLibrary("jvlc" );
}
/**
* These are set as final since they live along the jvlc object
*/
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;
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
/**
* This is the time in millis VLC checks for internal status
*/
private long resolution = 50;
import com.sun.jna.Native;
import java.awt.Canvas;
public class JVLC
{
private final LibVlcInstance instance;
private final LibVlc libvlc = LibVlc.SYNC_INSTANCE;
private boolean inputPlaying = false;
private boolean inputVout = false;
public JVLC() {
public JVLC()
{
String[] args = new String[1];
args[0] = "jvlc";
_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();
instance = createInstance(args);
}
public JVLC(String[] args) {
String[] myargs = new String[args.length + 1];
myargs[0] = "jvlc";
System.arraycopy( args, 0, myargs, 1, args.length );
_instance = createInstance( myargs );
playlist = new Playlist ( _instance );
video = new Video ( _instance );
audio = new Audio ( _instance );
input = new Input ( _instance );
vlm = new VLM ( _instance );
new Thread(this).start();
}
/**
* Destroys the current instance of jvlc, cleaning up objects.
* This is unreversible.
*/
public void destroy() {
if (!beingDestroyed)
{
beingDestroyed = true;
_destroy();
}
}
/*
* Core methods
*/
private native long createInstance( String[] args );
private native void _destroy();
public JVLC(String[] args)
{
String[] myargs = new String[args.length + 1];
myargs[0] = "jvlc";
System.arraycopy(args, 0, myargs, 1, args.length);
instance = createInstance(myargs);
}
public long getInstance() throws VLCException {
return _instance;
public MediaInstance play(String media)
{
MediaDescriptor mediaDescriptor = new MediaDescriptor(this, media);
MediaInstance mediaInstance = new MediaInstance(mediaDescriptor);
mediaInstance.play();
return mediaInstance;
}
public void setVideoOutput(Canvas canvas)
{
long drawable = Native.getComponentID(canvas);
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_video_set_parent(instance, drawable, exception );
}
/*
* Getters and setters
* Core methods
*/
public Playlist getPlaylist() throws VLCException {
return playlist;
}
private LibVlcInstance createInstance(String[] args)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_exception_init(exception);
return libvlc.libvlc_new(args.length, args, exception);
}
/**
* Checks if the input is playing.
* @return True if there is a playing input.
*/
public boolean isInputPlaying() {
return inputPlaying;
}
/**
* Returns the _instance.
* @return the _instance
*/
LibVlcInstance getInstance()
{
return instance;
}
/**
* 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() {
try {
while (!beingDestroyed) {
try {
while (playlist.isRunning()) {
inputPlaying = input.isPlaying();
inputVout = input.hasVout();
Thread.sleep(resolution);
} // while playlist running
} catch (VLCException e) {
// it is non-sense to show the stacktrace here
// e.printStackTrace();
}
inputPlaying = false;
inputVout = false;
Thread.sleep(resolution);
} // while ! being destroyed
} catch (InterruptedException e) {
e.printStackTrace();
}
}
/* (non-Javadoc)
* @see java.lang.Object#finalize()
*/
protected void finalize() throws Throwable {
destroy();
super.finalize();
}
/**
* Returns the libvlc.
* @return the libvlc
*/
LibVlc getLibvlc()
{
return libvlc;
}
/*
* (non-Javadoc)
* @see java.lang.Object#finalize()
*/
@Override
protected void finalize() throws Throwable
{
libvlc.libvlc_release(instance);
super.finalize();
}
}

View File

@ -1,100 +0,0 @@
/*****************************************************************************
* JVLCCanvas.java: AWT Canvas containing VLC Video Output
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 25-nov-2005
*
* $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.Canvas;
import java.awt.Graphics;
public class JVLCCanvas extends Canvas {
/**
* Serial version UID
*/
private static final long serialVersionUID = -1888309778861586426L;
public void paint(Graphics g) {
jvlc.video.paint(g);
}
private final JVLC jvlc;
/**
* Default constructor. The canvas is set a dimension of 200x200
*/
public JVLCCanvas() {
super();
jvlc = new JVLC();
jvlc.video.setActualCanvas(this);
setSize(200, 200);
}
public JVLCCanvas(String[] args) {
super();
jvlc = new JVLC(args);
jvlc.video.setActualCanvas(this);
setSize(200, 200);
}
/**
* @param width The initial canvas width
* @param height The initial canvas height
*/
public JVLCCanvas(int width, int height) {
super();
jvlc = new JVLC();
jvlc.video.setActualCanvas(this);
setSize(width, height);
}
public JVLCCanvas(String[] args, int width, int height) {
super();
jvlc = new JVLC(args);
jvlc.video.setActualCanvas(this);
setSize(width, height);
}
public JVLCCanvas(JVLC jvlc) {
super();
this.jvlc = jvlc;
jvlc.video.setActualCanvas(this);
}
public JVLC getJVLC() {
return jvlc;
}
/* (non-Javadoc)
* @see java.awt.Component#removeNotify()
*/
public void removeNotify() {
super.removeNotify();
jvlc.destroy();
}
}

View File

@ -1,74 +0,0 @@
/*****************************************************************************
* JVLCPanel.java: Java Swing JPanel embedding VLC Video Output
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-nov-2005
*
* $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 javax.swing.JPanel;
public class JVLCPanel extends JPanel {
private final JVLCCanvas jvcc;
/**
* Default constructor. The initial size is 200x200
*/
public JVLCPanel() {
jvcc = new JVLCCanvas();
add(jvcc);
}
/**
* @param args Arguments to initialize JVLC
*/
public JVLCPanel(String[] args)
{
jvcc = new JVLCCanvas(args);
add(jvcc);
}
/**
* @param width The width of the panel
* @param height The height of the panel
*/
public JVLCPanel(int width, int height) {
jvcc = new JVLCCanvas(width, height);
add(jvcc);
}
public JVLC getJVLCObject() {
return jvcc.getJVLC();
}
public void setSize(int width, int height) {
super.setSize(width, height);
jvcc.setSize(width, height);
}
}

View File

@ -1,7 +1,7 @@
/*****************************************************************************
* MediaDescriptor.java: VLC Java Bindings
* MediaDescriptor.java: VLC Java Bindings Media Descriptor
*****************************************************************************
* Copyright (C) 1998-2007 the VideoLAN team
* Copyright (C) 1998-2008 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
@ -25,23 +25,80 @@
package org.videolan.jvlc;
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlc.LibVlcEventManager;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaDescriptor;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class MediaDescriptor
{
private long mediaDescriptor;
private LibVlcMediaDescriptor instance;
private LibVlc libvlc;
private LibVlcEventManager eventManager;
public MediaDescriptor(long mediaDescriptor)
/**
* @param jvlc The jvlc instance to create the media descriptor for.
* @param media The media string
*/
public MediaDescriptor(JVLC jvlc, String media)
{
this.mediaDescriptor = mediaDescriptor;
libvlc_exception_t exception = new libvlc_exception_t();
libvlc = jvlc.getLibvlc();
instance = libvlc.libvlc_media_descriptor_new(jvlc.getInstance(), media, exception);
eventManager = libvlc.libvlc_media_descriptor_event_manager(instance, exception);
}
MediaDescriptor(JVLC jvlc, LibVlcMediaDescriptor instance)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc = jvlc.getLibvlc();
this.instance = instance;
eventManager = libvlc.libvlc_media_descriptor_event_manager(instance, exception);
}
public void addOption(String option)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_descriptor_add_option(instance, option, exception );
}
public String getMrl()
{
return libvlc.libvlc_media_descriptor_get_mrl(instance);
}
public MediaInstance getMediaInstance()
{
return new MediaInstance(this);
}
/**
* {@inheritDoc}
*/
@Override
protected void finalize() throws Throwable
{
libvlc.libvlc_media_descriptor_release(instance);
super.finalize();
}
/**
* Returns the mediaDescriptor.
* @return the mediaDescriptor
* Returns the instance.
* @return the instance
*/
public long getMediaDescriptor()
LibVlcMediaDescriptor getInstance()
{
return mediaDescriptor;
return instance;
}
/**
* Returns the libvlc.
* @return the libvlc
*/
LibVlc getLibvlc()
{
return libvlc;
}
}

View File

@ -1,7 +1,7 @@
/*****************************************************************************
* MediaInstance.java: VLC Java Bindings
* MediaInstance.java: VLC Java Bindings Media Instance
*****************************************************************************
* Copyright (C) 1998-2007 the VideoLAN team
* Copyright (C) 1998-2008 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
@ -25,135 +25,172 @@
package org.videolan.jvlc;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import org.videolan.jvlc.event.MediaInstanceCallback;
import org.videolan.jvlc.event.MediaInstanceListener;
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlcEventType;
import org.videolan.jvlc.internal.LibVlc.LibVlcEventManager;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaInstance;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class MediaInstance
{
private long _media_instance;
private native long _new_media_instance();
private native long _new_from_media_descriptor(MediaDescriptor mediaDescriptor);
private native void _instance_release(long mediaInstance);
private native void _instance_retain();
private native void _set_media_descriptor();
private native MediaDescriptor _get_media_descriptor();
private native EventManager _event_manager();
private native void _play();
private native void _stop();
private native void _pause();
private native void _set_drawable();
private native long _get_length();
private native long _get_time();
private native void _set_time(long time);
private native float _get_position();
private native void _set_position(float position);
private native boolean _will_play();
private native float _get_rate();
private native void _set_rate(float rate);
private native void _get_state();
private native boolean _has_vout();
private native float _get_fps();
public MediaInstance()
private final LibVlcMediaInstance instance;
private final LibVlc libvlc;
private final LibVlcEventManager eventManager;
private List<MediaInstanceCallback> callbacks = new ArrayList<MediaInstanceCallback>();
private MediaDescriptor mediaDescriptor;
MediaInstance(JVLC jvlc, LibVlcMediaInstance instance)
{
this._media_instance = _new_media_instance();
libvlc_exception_t exception = new libvlc_exception_t();
this.instance = instance;
libvlc = jvlc.getLibvlc();
eventManager = libvlc.libvlc_media_instance_event_manager(instance, exception);
}
public MediaInstance(MediaDescriptor mediaDescriptor)
{
this._media_instance = _new_from_media_descriptor(mediaDescriptor);
libvlc_exception_t exception = new libvlc_exception_t();
libvlc = mediaDescriptor.getLibvlc();
instance = libvlc.libvlc_media_instance_new_from_media_descriptor(mediaDescriptor.getInstance(), exception);
eventManager = libvlc.libvlc_media_instance_event_manager(instance, exception);
this.mediaDescriptor = mediaDescriptor;
}
public MediaDescriptor getMediaDescriptor()
{
return _get_media_descriptor();
return mediaDescriptor;
}
public void setMediaDescriptor(MediaDescriptor mediaDescriptor)
{
_new_from_media_descriptor(mediaDescriptor);
}
public EventManager getEventManager()
{
return _event_manager();
}
public void play()
{
_play();
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_instance_play(instance, exception);
}
public void stop()
{
_stop();
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_instance_stop(instance, exception);
}
public void pause()
{
_pause();
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_instance_pause(instance, exception);
}
public long getLength()
{
return _get_length();
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_instance_get_length(instance, exception);
}
public long getTime()
{
return _get_time();
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_instance_get_time(instance, exception);
}
public void setTime(long time)
{
_set_time(time);
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_instance_set_time(instance, time, exception);
}
public float getPosition()
{
return _get_position();
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_instance_get_position(instance, exception);
}
public void setPosition(float position)
{
_set_position(position);
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_instance_set_position(instance, position, exception);
}
public boolean willPlay()
{
return _will_play();
libvlc_exception_t exception = new libvlc_exception_t();
return (libvlc.libvlc_media_instance_will_play(instance, exception) == 1);
}
public float getRate()
{
return _get_rate();
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_instance_get_rate(instance, exception);
}
public void setRate(float rate)
{
_set_rate(rate);
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_instance_set_rate(instance, rate, exception);
}
public boolean hasVideoOutput()
{
return _has_vout();
libvlc_exception_t exception = new libvlc_exception_t();
return (libvlc.libvlc_media_instance_has_vout(instance, exception) == 1);
}
public float getFPS()
{
return _get_fps();
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_instance_get_fps(instance, exception);
}
public void addListener(final MediaInstanceListener listener)
{
MediaInstanceCallback callback = new MediaInstanceCallback(this, listener);
libvlc_exception_t exception = new libvlc_exception_t();
for (LibVlcEventType event : EnumSet.range(
LibVlcEventType.libvlc_MediaInstancePlayed,
LibVlcEventType.libvlc_MediaInstanceTimeChanged))
{
libvlc.libvlc_event_attach(eventManager, event.ordinal(), callback, null, exception);
}
callbacks.add(callback);
}
/**
* {@inheritDoc}
*/
@Override
protected void finalize() throws Throwable
{
libvlc_exception_t exception = new libvlc_exception_t();
for (MediaInstanceCallback callback : callbacks)
{
for (LibVlcEventType event : EnumSet.range(
LibVlcEventType.libvlc_MediaInstancePlayed,
LibVlcEventType.libvlc_MediaInstancePositionChanged))
{
libvlc.libvlc_event_detach(eventManager, event.ordinal(), callback, null, exception);
}
}
libvlc.libvlc_media_instance_release(instance);
super.finalize();
_instance_release(_media_instance);
}
/**
* Returns the instance.
* @return the instance
*/
LibVlcMediaInstance getInstance()
{
return instance;
}
}

View File

@ -0,0 +1,115 @@
/*****************************************************************************
* MediaList.java: VLC Java Bindings, MediaList
*****************************************************************************
* Copyright (C) 1998-2008 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
* (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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
package org.videolan.jvlc;
import org.videolan.jvlc.internal.LibVlc.LibVlcEventManager;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaDescriptor;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaList;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class MediaList
{
private final JVLC jvlc;
private final LibVlcMediaList instance;
private final LibVlcEventManager eventManager;
public MediaList(JVLC jvlc)
{
this.jvlc = jvlc;
libvlc_exception_t exception = new libvlc_exception_t();
instance = jvlc.getLibvlc().libvlc_media_list_new(jvlc.getInstance(), exception);
eventManager = jvlc.getLibvlc().libvlc_media_list_event_manager(instance, exception);
}
public void addMedia(String media)
{
MediaDescriptor descriptor = new MediaDescriptor(jvlc, media);
addMediaDescriptor(descriptor);
}
public void addMediaDescriptor(MediaDescriptor descriptor)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_add_media_descriptor(instance, descriptor.getInstance(), exception);
}
public int itemsCount()
{
libvlc_exception_t exception = new libvlc_exception_t();
return jvlc.getLibvlc().libvlc_media_list_count(instance, exception);
}
public int indexOf(MediaDescriptor descriptor)
{
libvlc_exception_t exception = new libvlc_exception_t();
return jvlc.getLibvlc().libvlc_media_list_index_of_item(instance, descriptor.getInstance(), exception);
}
public MediaDescriptor getMediaDescriptorAtIndex(int index)
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcMediaDescriptor descriptor = jvlc.getLibvlc().libvlc_media_list_item_at_index(instance, index, exception);
return new MediaDescriptor(jvlc, descriptor);
}
public void remove(int index)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_remove_index(instance, index, exception);
}
public void insertMediaDescriptor(MediaDescriptor descriptor, int index)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc
.getLibvlc()
.libvlc_media_list_insert_media_descriptor(instance, descriptor.getInstance(), index, exception);
}
/**
* {@inheritDoc}
*/
@Override
protected void finalize() throws Throwable
{
jvlc.getLibvlc().libvlc_media_list_release(instance);
super.finalize();
}
/**
* Returns the instance.
* @return the instance
*/
LibVlcMediaList getInstance()
{
return instance;
}
}

View File

@ -0,0 +1,105 @@
/*****************************************************************************
* MediaListPlayer.java: VLC Java Bindings, MediaList player
*****************************************************************************
* Copyright (C) 1998-2008 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
* (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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
package org.videolan.jvlc;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaListPlayer;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class MediaListPlayer
{
private final LibVlcMediaListPlayer instance;
private final JVLC jvlc;
public MediaListPlayer(JVLC jvlc)
{
libvlc_exception_t exception = new libvlc_exception_t();
this.jvlc = jvlc;
instance = jvlc.getLibvlc().libvlc_media_list_player_new(jvlc.getInstance(), exception);
}
public void setMediaList(MediaList list)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_set_media_list(instance, list.getInstance(), exception);
}
public boolean isPlaying()
{
libvlc_exception_t exception = new libvlc_exception_t();
return jvlc.getLibvlc().libvlc_media_list_player_is_playing(instance, exception) == 1;
}
public void play()
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_play(instance, exception);
}
public void stop()
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_stop(instance, exception);
}
public void pause()
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_pause(instance, exception);
}
public void playItem(MediaDescriptor descriptor)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_play_item(instance, descriptor.getInstance(), exception);
}
public void playItem(int index)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_play_item_at_index(instance, index, exception);
}
public void setMediaInstance(MediaInstance mediaInstance)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_set_media_instance(instance, mediaInstance.getInstance(), exception);
}
/**
* {@inheritDoc}
*/
@Override
protected void finalize() throws Throwable
{
jvlc.getLibvlc().libvlc_media_list_player_release(instance);
super.finalize();
}
}

View File

@ -2,13 +2,13 @@
* Playlist.java: PlaylistIntf implementation class
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
* Copyright (C) 1998-2008 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-2006
*
* $Id$
* $Id: Playlist.java 17089 2006-10-15 10:54:15Z littlejohn $
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public License
@ -29,101 +29,94 @@
package org.videolan.jvlc;
public class Playlist implements PlaylistIntf {
private long libvlcInstance;
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaInstance;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public Playlist(long _libvlcInstance) {
this.libvlcInstance = _libvlcInstance;
public class Playlist {
private final LibVlcInstance libvlcInstance;
private final LibVlc libvlc;
private final JVLC jvlc;
public Playlist(JVLC jvlc) {
this.jvlc = jvlc;
this.libvlcInstance = jvlc.getInstance();
this.libvlc = jvlc.getLibvlc();
}
native private int _playlist_add(String uri, String name, String[] options);
native private void _play(int _id, String[] options);
native private void _pause();
native private void _stop();
native private void _next();
native private void _prev();
native private void _clear();
native private void _deleteItem(int itemID);
native private int _itemsCount();
native private int _isRunning();
native private void _setLoop(boolean loop);
public synchronized void play(int id, String[] options) throws VLCException {
_play(id, options);
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_playlist_play(libvlcInstance, id, options.length, options, exception);
}
public synchronized void play() throws VLCException {
play(-1, null);
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_playlist_play(libvlcInstance, -1, 0, new String[] {}, exception);
}
public synchronized void togglePause() throws VLCException {
_pause();
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_playlist_pause(libvlcInstance, exception);
}
public synchronized void stop() throws VLCException {
_stop();
// do {
// try {
// Thread.sleep(50);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// } while (isRunning());
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_playlist_stop(libvlcInstance, exception);
}
public boolean isRunning() throws VLCException {
return (_isRunning() == 0)? false : true ;
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_playlist_isplaying(libvlcInstance, exception) == 0? false : true;
}
public synchronized int itemsCount() throws VLCException {
return _itemsCount();
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_playlist_items_count(libvlcInstance, exception);
}
public synchronized void next() throws VLCException {
libvlc_exception_t exception = new libvlc_exception_t();
if (! isRunning())
play();
_next();
libvlc.libvlc_playlist_next(libvlcInstance, exception);
}
public synchronized void prev() throws VLCException {
libvlc_exception_t exception = new libvlc_exception_t();
if (! isRunning())
play();
_prev();
libvlc.libvlc_playlist_prev(libvlcInstance, exception);
}
public synchronized void clear() throws VLCException {
_clear();
}
public synchronized int add(String uri, String name, String[] options) throws VLCException {
return _playlist_add(uri, name, options);
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_playlist_clear(libvlcInstance, exception);
}
public synchronized int add(String uri, String name) throws VLCException {
return add(uri, name, null);
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_playlist_add(libvlcInstance, uri, name, exception);
}
public synchronized void addExtended() {
}
public synchronized void deleteItem(int itemID) throws VLCException {
_deleteItem(itemID);
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_playlist_delete_item(libvlcInstance, itemID, exception);
}
public synchronized void setLoop(boolean loop) {
_setLoop(loop);
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_playlist_loop(libvlcInstance, loop? 1 : 0, exception);
}
public long getInstance() throws VLCException {
return libvlcInstance;
public MediaInstance getMediaInstance()
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcMediaInstance mi = libvlc.libvlc_playlist_get_media_instance(libvlcInstance, exception);
return new MediaInstance(jvlc, mi);
}
public void setPause(boolean pause) throws VLCException {
// TODO Auto-generated method stub
}
}

View File

@ -1,120 +0,0 @@
/*****************************************************************************
* PlaylistIntf.java: The playlist interface
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-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;
public interface PlaylistIntf {
/**
* Plays the item specified in id, with options. At the moment options
* has no effect and can be safely set to null.
* @param id The ID to play
* @param options Options to play the item with
*/
void play(int id, String[] options) throws VLCException;
/**
* Plays the current item in the playlist.
*/
void play() throws VLCException;
/**
* Toggles pause for the current item.
*/
void togglePause() throws VLCException;
/**
* Pauses the currently playing item if pause value is true. Plays it
* otherwise. If you set pause to true and the current item is already
* playing, this has no effect.
*
* @param pause
* @throws VLCException
*/
void setPause(boolean pause) throws VLCException;
/**
* Stops the currently playing item. Differently from pause, stopping
* an item destroys any information related to the item.
*/
void stop() throws VLCException;
/**
* This function returns true if the current item has not been stopped.
* @return True if the current item has not been stopped
*/
boolean isRunning() throws VLCException;
/**
* TODO: this should return the number of items added with add, with no
* respect to videolan internal playlist.
*
* Returns the number of items in the playlist. Beware that this number
* could be bigger than the number of times add() has been called.
*
* @return Current number of items in the playlist
*/
int itemsCount() throws VLCException;
/**
* Move to next item in the playlist and play it.
*/
void next() throws VLCException;
/**
* Move to previous item in the playlist and play it.
*/
void prev() throws VLCException;
/**
* Clear the playlist which becomes empty after this call.
*/
void clear() throws VLCException;
/**
* TODO: document the kind of items that can be added.
* Add a new item in the playlist.
*
* @param uri Location of the item
* @param name Name of the item
* @return The item ID
*/
int add(String uri, String name) throws VLCException;
/**
* Currently not implemented
*/
void addExtended();
/**
* @param loop
*/
void setLoop(boolean loop);
}

View File

@ -1,120 +0,0 @@
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);
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);
private native void _playMedia(String mediaName);
private native void _stopMedia(String mediaName);
private native void _pauseMedia(String mediaName);
private native void _seekMedia(String mediaName, float percentage);
private native String _showMedia(String mediaName);
private native float _getMediaposition(String name, int mediaInstance);
private native int _getMediatime(String name, int mediaInstance);
private native int _getMedialength(String name, int mediaInstance);
private native int _getMediarate(String name, int mediaInstance);
private native int _getMediatitle(String name, int mediaInstance);
private native int _getMediachapter(String name, int mediaInstance);
private native int _getMediaseekable(String name, int mediaInstance);
public VLM( long instance ) {
this.libvlcInstance = instance;
}
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);
}
public void playMedia(String name) throws VLCException {
_playMedia(name);
}
public void stopMedia(String name) throws VLCException {
_stopMedia(name);
}
public void pauseMedia(String name) throws VLCException {
_pauseMedia(name);
}
public void seekMedia(String name, float percentage) throws VLCException {
_seekMedia(name, percentage);
}
public String showMedia(String name) throws VLCException {
return _showMedia(name);
}
public float getMediaPosition(String name, int mediaInstance) throws VLCException {
return _getMediaposition(name, mediaInstance);
}
public int getMediaTime(String name, int mediaInstance) throws VLCException {
return _getMediatime(name, mediaInstance);
}
public int getMediaLength(String name, int mediaInstance) throws VLCException {
return _getMedialength(name, mediaInstance);
}
public int getMediaRate(String name, int mediaInstance) throws VLCException {
return _getMediarate(name, mediaInstance);
}
public int getMediaTitle(String name, int mediaInstance) throws VLCException {
return _getMediatitle(name, mediaInstance);
}
public int getMediaChapter(String name, int mediaInstance) throws VLCException {
return _getMediachapter(name, mediaInstance);
}
public boolean getMediaSeekable(String name, int mediaInstance) throws VLCException {
return _getMediaseekable(name, mediaInstance) > 0;
}
public long getInstance() {
return libvlcInstance;
}
}

View File

@ -1,110 +0,0 @@
/*****************************************************************************
* VLMIntf.java: VLM Interface
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-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;
public interface VLMIntf {
/**
* Add a broadcast, with one input
* @param name the name of the new broadcast
* @param input the input MRL
* @param output the output MRL (the parameter to the "sout" variable)
* @param options additional options
* @param enabled boolean for enabling the new broadcast
* @param loop Should this broadcast be played in loop ?
*/
void addBroadcast( String name, String input, String output, String[] options, boolean enabled, boolean loop )
throws VLCException;
/**
* Delete a media (vod or broadcast)
* @param name the media to delete
*/
void deleteMedia( String name ) throws VLCException;
/**
* Enable or disable a media (vod or broadcast)
* @param name the media to work on
* @param enabled the new status
*/
void setEnabled( String name, boolean enabled ) throws VLCException;
/**
* Set the output for a media
* @param name the media to work on
* @param output the output MRL (the parameter to the "sout" variable)
*/
void setOutput( String name, String output ) throws VLCException;
/**
* Set a media's input MRL. This will delete all existing inputs and
* add the specified one.
* @param name the media to work on
* @param input the input MRL
*/
void setInput( String name, String input ) throws VLCException;
/**
* Set loop mode for a media
* @param name the media to work on
* @param loop the new status
*/
void setLoop( String name, boolean loop ) throws VLCException;
/**
* Edit the parameters of a media. This will delete all existing inputs and
* add the specified one.
* @param name the name of the new broadcast
* @param input the input MRL
* @param output the output MRL (the parameter to the "sout" variable)
* @param options additional options
* @param enabled boolean for enabling the new broadcast
* @param loop Should this broadcast be played in loop ?
*/
void changeMedia( String name, String input, String output, String[] options, boolean enabled, boolean loop )
throws VLCException;
/**
* Plays a media
* @param name of the broadcast to play
*/
void playMedia(String name) throws VLCException;
/**
* Stops a media
* @param name of the broadcast to stop
*/
void stopMedia(String name) throws VLCException;
/**
* Pauses a media
* @param name name of the broadcast to pause
*/
void pauseMedia(String name) throws VLCException;
}

View File

@ -1,104 +1,131 @@
/**
/*****************************************************************************
* Video.java: JVLC Video Output
*****************************************************************************
*
* Copyright (C) 1998-2008 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
* Philippe Morin <phmorin@free.fr>
*
* Created on 28-feb-2006
*
* $Id: JVLC.java 20141 2007-05-16 19:31:35Z littlejohn $
*
* 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.Dimension;
import java.awt.Graphics;
public final class Video implements VideoIntf {
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class Video
{
private long libvlcInstance;
private final LibVlcInstance libvlcInstance;
private JVLCCanvas actualCanvas;
private final LibVlc libvlc;
public Video( long libvlcInstance) {
this.libvlcInstance = libvlcInstance;
public Video( JVLC jvlc) {
this.libvlcInstance = jvlc.getInstance();
this.libvlc = jvlc.getLibvlc();
}
/*
* Video native methods
*/
private native void _toggleFullscreen();
private native void _setFullscreen( boolean value);
private native boolean _getFullscreen();
private native int _getHeight();
private native int _getWidth();
private native void _getSnapshot(String filename,int width,int height);
private native void _destroyVideo();
private native void _reparent(JVLCCanvas component);
private native void _setSize(int width, int height);
private native void _paint(JVLCCanvas canvas, Graphics g);
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#destroyVideo()
*/
public void destroyVideo() throws VLCException {
_destroyVideo();
public void destroyVideo(MediaInstance media)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_video_destroy(media.getInstance(), exception );
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getFullscreen()
*/
public boolean getFullscreen() throws VLCException {
return _getFullscreen();
public boolean getFullscreen(MediaInstance media) throws VLCException {
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_get_fullscreen(media.getInstance(), exception) == 1 ? true : false;
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getSnapshot(java.lang.String)
*/
public void getSnapshot(String filepath,int width,int height) throws VLCException {
_getSnapshot( filepath , width, height);
public void getSnapshot(MediaInstance media, String filepath, int width, int height) throws VLCException {
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_video_take_snapshot(media.getInstance(), filepath, width, height, exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getVideoHeight()
*/
public int getHeight() throws VLCException {
return _getHeight();
public int getHeight(MediaInstance media) throws VLCException {
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_video_get_height(media.getInstance(), exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getVideoWidth()
*/
public int getWidth() throws VLCException {
return _getWidth();
public int getWidth(MediaInstance media) throws VLCException {
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_video_get_height(media.getInstance(), exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#reparentVideo(java.awt.Component)
*/
public void reparent(JVLCCanvas c) throws VLCException {
_reparent(c);
setActualCanvas(c);
public void reparent(MediaInstance media, java.awt.Canvas canvas) throws VLCException {
libvlc_exception_t exception = new libvlc_exception_t();
long drawable = com.sun.jna.Native.getComponentID(canvas);
libvlc.libvlc_video_reparent(media.getInstance(), drawable, exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#resizeVideo(int, int)
*/
public void setSize(int width, int height) throws VLCException {
_setSize( width, height );
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_video_set_size(libvlcInstance, width, height, exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#setFullscreen(boolean)
*/
public void setFullscreen(boolean fullscreen) throws VLCException {
_setFullscreen( fullscreen );
public void setFullscreen(MediaInstance media, boolean fullscreen) throws VLCException {
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_set_fullscreen(media.getInstance(), fullscreen? 1 : 0, exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#toggleFullscreen()
*/
public void toggleFullscreen() throws VLCException {
_toggleFullscreen();
public void toggleFullscreen(MediaInstance media) throws VLCException {
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_toggle_fullscreen(media.getInstance(), exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getSize()
*/
public Dimension getSize() throws VLCException {
return new Dimension (getWidth(), getHeight());
public Dimension getSize(MediaInstance media) throws VLCException {
return new Dimension (getWidth(media), getHeight(media));
}
/* (non-Javadoc)
@ -107,17 +134,4 @@ public final class Video implements VideoIntf {
public void setSize(Dimension d) throws VLCException {
setSize(d.width, d.height);
}
public void paint(Graphics g) {
_paint(actualCanvas, g);
}
public void setActualCanvas(JVLCCanvas canvas) {
actualCanvas = canvas;
}
public long getInstance() {
return libvlcInstance;
}
}

View File

@ -1,113 +0,0 @@
/*****************************************************************************
* VideoIntf.java: Video methods interface
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-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.Dimension;
public interface VideoIntf {
/**
* Toggles the fullscreen.
*/
void toggleFullscreen() throws VLCException;
/**
* Sets fullscreen if fullscreen argument is true.
* @param fullscreen
*/
void setFullscreen( boolean fullscreen ) throws VLCException;
/**
* @return True if the current video window is in fullscreen mode.
*/
boolean getFullscreen() throws VLCException;
/**
* Saves a snapshot of the current video window.
* @param filepath The full path (including filename) were to save the snapshot to.
* If you only give a path, not including the filename, the snapshot will be saved in
* the specified path using vlc naming conventions.
*/
void getSnapshot(String filepath,int width,int height) throws VLCException;
/**
* @return The current video window height
*/
int getHeight() throws VLCException;
/**
* @return The current video window width
*/
int getWidth() throws VLCException;
/**
* Get the size of the video output window as a Dimension object.
* @return The video size in a Dimension object.
* @throws VLCException
*/
Dimension getSize() throws VLCException;
/**
* Destroys video output, but the item continues to play.
* @throws VLCException
*/
void destroyVideo() throws VLCException;
/**
* Moves video output from the current Canvas to another. This funtion
* doens't resize the video output to the new canvas size. See resizeVideo().
* @param c
* @throws VLCException
*/
void reparent(JVLCCanvas c) throws VLCException;
/**
* Resizes video output to width and height. This operation could be necessary
* after reparenting. See reparentVideo().
* @param width The new video output width
* @param height The new video output height
* @throws VLCException
*/
void setSize(int width, int height) throws VLCException;
/**
* Resizes video output to width and height. This operation could be necessary
* after reparenting. See reparentVideo().
*
* @param d The new size of video
* @throws VLCException
*/
void setSize(Dimension d) throws VLCException;
}

View File

@ -0,0 +1,83 @@
/*****************************************************************************
* MediaInstancePlayCallback.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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
* (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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
package org.videolan.jvlc.event;
import org.videolan.jvlc.MediaInstance;
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlcEventType;
import org.videolan.jvlc.internal.LibVlc.LibVlcCallback;
import org.videolan.jvlc.internal.LibVlc.libvlc_event_t;
import org.videolan.jvlc.internal.LibVlc.media_instance_time_changed;
import com.sun.jna.Pointer;
public class MediaInstanceCallback implements LibVlcCallback
{
private MediaInstanceListener listener;
private MediaInstance mediaInstance;
public MediaInstanceCallback(MediaInstance mediaInstance, MediaInstanceListener listener)
{
this.mediaInstance = mediaInstance;
this.listener = listener;
}
/**
* {@inheritDoc}
*/
@Override
public void callback(libvlc_event_t libvlc_event, Pointer userData)
{
if (libvlc_event.type == LibVlcEventType.libvlc_MediaInstancePlayed.ordinal())
{
listener.played(mediaInstance);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaInstancePaused.ordinal())
{
listener.paused(mediaInstance);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaInstanceReachedEnd.ordinal())
{
listener.endReached(mediaInstance);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaInstancePositionChanged.ordinal())
{
listener.positionChanged(mediaInstance);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaInstanceTimeChanged.ordinal())
{
libvlc_event.event_type_specific.setType(LibVlc.media_instance_time_changed.class);
LibVlc.media_instance_time_changed timeChanged = (media_instance_time_changed) libvlc_event.event_type_specific
.readField("media_instance_time_changed");
listener.timeChanged(mediaInstance, timeChanged.new_time);
}
else
{
throw new RuntimeException("Unsupported event error. Event id: " + libvlc_event.type);
}
}
}

View File

@ -1,7 +1,7 @@
/*****************************************************************************
* EventManager.java: VLC Java Bindings
* MediaInstancePlayListener.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2007 the VideoLAN team
* Copyright (C) 1998-2008 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
@ -23,10 +23,22 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
package org.videolan.jvlc;
package org.videolan.jvlc.event;
import org.videolan.jvlc.MediaInstance;
public class EventManager
public interface MediaInstanceListener
{
void played(MediaInstance mediaInstance);
void paused(MediaInstance mediaInstance);
void endReached(MediaInstance mediaInstance);
void timeChanged(MediaInstance mediaInstance, long newTime);
void positionChanged(MediaInstance mediaInstance);
}

View File

@ -28,15 +28,18 @@ package org.videolan.jvlc.internal;
import com.sun.jna.Callback;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.PointerType;
import com.sun.jna.Structure;
import com.sun.jna.Union;
public interface LibVlc extends Library
{
LibVlc INSTANCE = (LibVlc) Native.loadLibrary("libvlc-control", LibVlc.class);
LibVlc SYNC_INSTANCE = (LibVlc) Native.synchronizedLibrary(INSTANCE);
public static class libvlc_exception_t extends Structure
{
@ -48,6 +51,168 @@ public interface LibVlc extends Library
public String message;
}
public static class libvlc_event_t extends Structure
{
public int type;
public Pointer obj;
public event_type_specific event_type_specific;
}
public class media_descriptor_meta_changed extends Structure
{
public Pointer meta_type;
}
public class media_descriptor_subitem_added extends Structure
{
public LibVlcMediaDescriptor new_child;
}
public class media_descriptor_duration_changed extends Structure
{
public NativeLong new_duration;
}
public class media_descriptor_preparsed_changed extends Structure
{
public int new_status;
}
public class media_descriptor_freed extends Structure
{
public LibVlcMediaDescriptor md;
}
public class media_descriptor_state_changed extends Structure
{
// @todo: check this one
public int new_state;
}
/* media instance */
public class media_instance_position_changed extends Structure
{
public float new_position;
}
public class media_instance_time_changed extends Structure
{
// @todo: check this one
public long new_time;
}
/* media list */
public class media_list_item_added extends Structure
{
public LibVlcMediaDescriptor item;
public int index;
}
public class media_list_will_add_item extends Structure
{
public LibVlcMediaDescriptor item;
public int index;
}
public class media_list_item_deleted extends Structure
{
public LibVlcMediaDescriptor item;
public int index;
}
public class media_list_will_delete_item extends Structure
{
public LibVlcMediaDescriptor item;
public int index;
}
/* media list view */
public class media_list_view_item_added extends Structure
{
public LibVlcMediaDescriptor item;
public int index;
}
public class media_list_view_will_add_item extends Structure
{
public LibVlcMediaDescriptor item;
public int index;
}
public class media_list_view_item_deleted extends Structure
{
public LibVlcMediaDescriptor item;
public int index;
}
public class media_list_view_will_delete_item extends Structure
{
public LibVlcMediaDescriptor item;
public int index;
}
/* media discoverer */
public class media_media_discoverer_started extends Structure
{
public Pointer unused;
}
public class media_media_discoverer_ended extends Structure
{
public Pointer unused;
}
public class event_type_specific extends Union
{
public media_descriptor_meta_changed media_descriptor_meta_changed;
public media_descriptor_subitem_added media_descriptor_subitem_added;
public media_descriptor_duration_changed media_descriptor_duration_changed;
public media_descriptor_preparsed_changed media_descriptor_preparsed_changed;
public media_descriptor_freed media_descriptor_freed;
public media_descriptor_state_changed media_descriptor_state_changed;
public media_instance_position_changed media_instance_position_changed;
public media_instance_time_changed media_instance_time_changed;
public media_list_item_added media_list_item_added;
public media_list_will_add_item media_list_will_add_item;
public media_list_item_deleted media_list_item_deleted;
public media_list_will_delete_item media_list_will_delete_item;
public media_list_view_item_added media_list_view_item_added;
public media_list_view_will_add_item media_list_view_will_add_item;
public media_list_view_item_deleted media_list_view_item_deleted;
public media_list_view_will_delete_item media_list_view_will_delete_item;
}
public class LibVlcInstance extends PointerType
{
}
@ -138,34 +303,36 @@ public interface LibVlc extends Library
int libvlc_audio_set_volume(LibVlcInstance instance, int volume, libvlc_exception_t exception);
// playlist
void libvlc_playlist_loop(LibVlcInstance instance, int loop, libvlc_exception_t exception);
void libvlc_playlist_play(LibVlcInstance instance, int itemIndex, int optionsCount, String[] options, libvlc_exception_t exception);
void libvlc_playlist_play(LibVlcInstance instance, int itemIndex, int optionsCount, String[] options,
libvlc_exception_t exception);
void libvlc_playlist_pause(LibVlcInstance instance, libvlc_exception_t exception);
void libvlc_playlist_stop(LibVlcInstance instance, libvlc_exception_t exception);
int libvlc_playlist_isplaying(LibVlcInstance instance, libvlc_exception_t exception);
int libvlc_playlist_items_count(LibVlcInstance instance, libvlc_exception_t exception);
void libvlc_playlist_next(LibVlcInstance instance, libvlc_exception_t exception);
void libvlc_playlist_prev(LibVlcInstance instance, libvlc_exception_t exception);
void libvlc_playlist_clear(LibVlcInstance instance, libvlc_exception_t exception);
int libvlc_playlist_add(LibVlcInstance instance, String uri, String name, libvlc_exception_t exception);
int libvlc_playlist_delete_item(LibVlcInstance instance, int itemIndex, libvlc_exception_t exception);
LibVlcMediaInstance libvlc_playlist_get_media_instance(LibVlcInstance instance, libvlc_exception_t exception);
int libvlc_media_instance_is_seekable(LibVlcMediaInstance instance, libvlc_exception_t exception);
int libvlc_media_instance_can_pause(LibVlcMediaInstance instance, libvlc_exception_t exception);
// media descriptor
LibVlcMediaDescriptor libvlc_media_descriptor_new(LibVlcInstance libvlc_instance, String mrl,
@ -204,7 +371,7 @@ public interface LibVlc extends Library
void libvlc_media_instance_set_time(LibVlcMediaInstance instance, long time, libvlc_exception_t exception);
float libvlc_media_instance_get_position(LibVlcMediaInstance instance, libvlc_exception_t exception);
void libvlc_media_instance_set_position(LibVlcMediaInstance instance, float position, libvlc_exception_t exception);
int libvlc_media_instance_will_play(LibVlcMediaInstance instance, libvlc_exception_t exception);
@ -218,7 +385,7 @@ public interface LibVlc extends Library
float libvlc_media_instance_get_fps(LibVlcMediaInstance instance2, libvlc_exception_t exception);
void libvlc_media_instance_release(LibVlcMediaInstance instance);
LibVlcEventManager libvlc_media_instance_event_manager(LibVlcMediaInstance media_instance,
libvlc_exception_t exception);
@ -293,7 +460,7 @@ public interface LibVlc extends Library
public static interface LibVlcCallback extends Callback
{
void callback(int libvlc_event_t, Pointer userData);
void callback(libvlc_event_t libvlc_event, Pointer userData);
}
void libvlc_event_attach(LibVlcEventManager event_manager, int event_type, LibVlcCallback callback,

View File

@ -36,5 +36,8 @@ public enum LibVlcEventType {
libvlc_MediaDescriptorStateChanged,
libvlc_MediaInstancePlayed,
libvlc_MediaInstancePaused,
libvlc_MediaInstanceReachedEnd;
libvlc_MediaInstanceReachedEnd,
libvlc_MediaInstanceEncounteredError,
libvlc_MediaInstanceTimeChanged,
libvlc_MediaInstancePositionChanged;
}

View File

@ -36,6 +36,7 @@ import org.videolan.jvlc.internal.LibVlc.LibVlcEventManager;
import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaDescriptor;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaInstance;
import org.videolan.jvlc.internal.LibVlc.libvlc_event_t;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
import com.sun.jna.Pointer;
@ -68,7 +69,7 @@ public class LibVlcImpl
{
@Override
public void callback(int libvlc_event_t, Pointer pointer)
public void callback(libvlc_event_t libvlc_event_t, Pointer pointer)
{
System.out.println("Playing started.");
}
@ -78,7 +79,7 @@ public class LibVlcImpl
{
@Override
public void callback(int libvlc_event_t, Pointer pointer)
public void callback(libvlc_event_t libvlc_event_t, Pointer pointer)
{
synchronized (lock)
{

View File

@ -1,8 +0,0 @@
package org.videolan.jvlc.listener;
public interface VolumeListener {
void volumeChanged();
}

View File

@ -1,50 +0,0 @@
libjvlc_la_SOURCES = \
audio-jni.cc \
core-jni.cc \
graphics-jni.cc \
input-jni.cc \
playlist-jni.cc \
utils.cc \
utils.h \
video-jni.cc \
vlm-jni.cc \
callback-jni.cc
libjvlc_la_CPPFLAGS = `$(VLC_CONFIG) --cflags pic` $(JINCLUDES)
libjvlc_la_LIBADD = ../../../src/libvlc-control.la $(LIBJINCLUDES)
if BUILD_JAVA
lib_LTLIBRARIES = libjvlc.la
if HAVE_WIN32
DATA_noinst_libjvlc = jvlc$(LIBEXT) libjvlc$(LIBEXT).a
LIBRARIES_libvlc = $(top_builddir)/src/.libs/libvlc.dll.a $(top_builddir)/src/.libs/libvlc-control.dll.a
LDFLAGS_jvlc = `$(VLC_CONFIG) --libs libvlc`
libjvlc_DATA = libjvlc.def libjvlc.dll.a jvlc$(LIBEXT)
libjvlcdir=$(srcdir)
libjvlc.dll.a libjvlc.def:
$(DLLTOOL) -z libjvlc.def -l libjvlc.dll.a -D jvlc.dll $< $(libjvlc_a_OBJECTS)
jvlc$(LIBEXT): $(libjvlc_a_OBJECTS) \
$(libjvlc_a_DEPENDENCIES)
$(CXXLINK) $(libjvlc_a_OBJECTS) -Wl,--kill-at \
$(srcdir)/libjvlc.def \
$(LIBRARIES_libvlc) -shared $(LIBRARIES_libvlc) $(LIBJINCLUDES) \
$(LDFLAGS_jvlc) $(LTLIBINTL)
# Cygwin work-around, copied by other makefiles
@if test -f "$@.exe"; then mv -f "$@.exe" "$@"; fi
all: libjvlc.dll.a
endif
.PHONY: clean-local
clean-local:
rm -f *.o *~ *.def *.dll
endif

View File

@ -1,133 +0,0 @@
/*****************************************************************************
* audio-jni.cc: JNI native audio functions for VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
* Philippe Morin <phmorin@free.fr>
*
*
* $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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* These are a must*/
#include <jni.h>
#include <vlc/libvlc.h>
/* JVLC internal imports, generated by gcjh */
#include "../includes/Audio.h"
#include "utils.h"
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Audio__1getTrack (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
GET_INPUT_THREAD;
jint res = 0;
res = libvlc_audio_get_track( input, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION;
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1setTrack (JNIEnv *env, jobject _this, jint value)
{
INIT_FUNCTION;
GET_INPUT_THREAD;
libvlc_audio_set_track( input, value, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Audio__1getChannel (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
int res = libvlc_audio_get_channel( ( libvlc_instance_t * ) instance, &exception);
CHECK_EXCEPTION;
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1setChannel (JNIEnv *env, jobject _this, jint channel)
{
INIT_FUNCTION;
libvlc_audio_set_channel( (libvlc_instance_t *) instance, channel, &exception);
CHECK_EXCEPTION;
}
JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Audio__1getMute (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
jboolean res;
res = (jboolean) libvlc_audio_get_mute( ( libvlc_instance_t * ) instance, &exception );
CHECK_EXCEPTION;
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1setMute (JNIEnv *env, jobject _this, jboolean value)
{
INIT_FUNCTION;
libvlc_audio_set_mute( ( libvlc_instance_t * ) instance, value, &exception );
CHECK_EXCEPTION;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1toggleMute (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
libvlc_audio_get_mute( ( libvlc_instance_t * ) instance, &exception );
CHECK_EXCEPTION;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Audio__1getVolume (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
jint res = 0;
res = libvlc_audio_get_volume( ( libvlc_instance_t * ) instance, &exception );
CHECK_EXCEPTION;
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1setVolume (JNIEnv *env, jobject _this, jint volume)
{
INIT_FUNCTION;
libvlc_audio_set_volume( ( libvlc_instance_t * ) instance, volume, &exception );
CHECK_EXCEPTION;
}

View File

@ -1,68 +0,0 @@
/*****************************************************************************
* callback-jni.cc: JNI native callback functions for VLC Java Bindings
*****************************************************************************
* 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
* (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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* These are a must*/
#include <jni.h>
#include <vlc/libvlc.h>
#ifdef WIN32
#include <windows.h>
#undef usleep
#define usleep(var) Sleep(var/1000)
#else
#include <unistd.h>
#endif
#include <stdio.h>
#include "utils.h"
#include "../includes/Audio.h"
static JavaVM *jvm;
static jclass audioClass;
static jmethodID wakeupListenersMethod;
void volumeChangedCallback( libvlc_instance_t *p_instance, libvlc_event_t *event, void *user_data );
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1install_1callback( JNIEnv *env, jobject _this )
{
INIT_FUNCTION ;
if (jvm == NULL)
{
env->GetJavaVM( &jvm );
audioClass = env->GetObjectClass( _this );
wakeupListenersMethod = env->GetStaticMethodID(audioClass, "wakeupListeners", "()V");
}
libvlc_exception_raise( &exception, "not implemented" );
CHECK_EXCEPTION ;
}
void volumeChangedCallback( struct libvlc_instance_t *p_instance, libvlc_event_t *event, void *user_data )
{
ATTACH_JVM;
env->CallStaticVoidMethod( audioClass, wakeupListenersMethod);
}

View File

@ -1,102 +0,0 @@
/*****************************************************************************
* vlc-libvlc-jni.cc: JNI interface for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
* Philippe Morin <phmorin@free.fr>
*
* $Id: core-jni.cc 156 2006-08-01 09:23:01Z littlejohn $
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* These are a must*/
#include <jni.h>
#include <vlc/libvlc.h>
#include <stdio.h> // for printf
#include <stdlib.h> // for calloc
#include <string.h> // for strcmp
#ifdef WIN32
#undef usleep
#define usleep(var) Sleep(var/1000)
#else
#include <unistd.h> // for usleep
#endif
/* JVLC internal imports, generated by gcjh */
#include "../includes/JVLC.h"
#include <jawt.h>
#include <jawt_md.h>
#include "utils.h"
jlong getClassInstance (JNIEnv *env, jobject _this);
JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env, jobject _this, jobjectArray args) {
long res;
int argc;
const char **argv;
libvlc_exception_t 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
);
}
res = (long) libvlc_new(argc, (char**) argv, &exception );
CHECK_EXCEPTION ;
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1destroy (JNIEnv *env, jobject _this)
{
long instance;
instance = getClassInstance( env, _this );
libvlc_release( (libvlc_instance_t *) instance );
return;
}
//JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1paint (JNIEnv *env, jobject _this, jobject canvas, jobject graphics)
/*
* 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;
}

View File

@ -1,144 +0,0 @@
/*****************************************************************************
* JVLC.java: JNI interface for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2005 the VideoLAN team
*
* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* These are a must*/
#include <jni.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc/vlc.h>
#include <vlc/libvlc.h>
#include <jawt.h>
#include <jawt_md.h>
#ifndef WIN32
#include <X11/Xlib.h> // for Xlibs graphics functions
#endif
#include <stdio.h> // for printf
#include <stdlib.h> // for malloc
/* JVLC internal imports, generated by gcjh */
#include "../includes/JVLCCanvas.h"
jlong getJVLCInstance (JNIEnv *env, jobject _this);
// JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, jobject canvas, jobject graphics) {
// JAWT awt;
// JAWT_DrawingSurface* ds;
// JAWT_DrawingSurfaceInfo* dsi;
// #ifdef WIN32
// JAWT_Win32DrawingSurfaceInfo* dsi_win;
// #else
// JAWT_X11DrawingSurfaceInfo* dsi_x11;
// GC gc;
// #endif
// jint lock;
// libvlc_drawable_t drawable;
// libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
// libvlc_exception_init( exception );
// /* Get the AWT */
// awt.version = JAWT_VERSION_1_3;
// if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
// printf("AWT Not found\n");
// return;
// }
// /* Get the drawing surface */
// ds = awt.GetDrawingSurface(env, canvas);
// if (ds == NULL) {
// printf("NULL drawing surface\n");
// return;
// }
// /* Lock the drawing surface */
// lock = ds->Lock(ds);
// if((lock & JAWT_LOCK_ERROR) != 0) {
// printf("Error locking surface\n");
// awt.FreeDrawingSurface(ds);
// return;
// }
// /* Get the drawing surface info */
// dsi = ds->GetDrawingSurfaceInfo(ds);
// if (dsi == NULL) {
// printf("Error getting surface info\n");
// ds->Unlock(ds);
// awt.FreeDrawingSurface(ds);
// return;
// }
// #ifdef WIN32
// /* Get the platform-specific drawing info */
// dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
// /* Now paint */
// drawable = reinterpret_cast<int>(dsi_win->hwnd);
// long vlcInstance = getJVLCInstance( env, canvas );
// libvlc_video_set_parent( (libvlc_instance_t *) vlcInstance, drawable, exception );
// #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);
// XSetBackground(dsi_x11->display, gc, 0);
// drawable = dsi_x11->drawable;
// long vlcInstance = getJVLCInstance( env, canvas );
// libvlc_video_set_parent( (libvlc_instance_t *)vlcInstance, drawable, exception );
// XFreeGC(dsi_x11->display, gc);
// #endif
// /* Free the drawing surface info */
// ds->FreeDrawingSurfaceInfo(dsi);
// /* Unlock the drawing surface */
// ds->Unlock(ds);
// /* Free the drawing surface */
// awt.FreeDrawingSurface(ds);
// }
/*
* Utility functions
*/
jlong getJVLCInstance (JNIEnv *env, jobject _this) {
/* get the id field of object */
jclass canvascls = env->GetObjectClass(_this);
jmethodID canvasmid = env->GetMethodID(canvascls, "getJVLC", "()Lorg/videolan/jvlc/JVLC;");
jobject canvasjvlc = env->CallObjectMethod(_this, canvasmid);
jclass cls = env->GetObjectClass(canvasjvlc);
jmethodID mid = env->GetMethodID(cls, "getInstance", "()J");
jlong field = env->CallLongMethod(canvasjvlc, mid);
return field;
}

View File

@ -1,146 +0,0 @@
/*****************************************************************************
* input-jni.cc: JNI native input functions for VLC Java Bindings
*****************************************************************************
* 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
* (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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <jni.h>
#include <vlc/libvlc.h>
/* JVLC internal imports, generated by gcjh */
#include "../includes/Input.h"
#include "utils.h"
JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_Input__1getLength (JNIEnv *env, jobject _this)
{
INIT_FUNCTION ;
vlc_int64_t res = 0;
GET_INPUT_THREAD ;
res = libvlc_media_instance_get_length( input, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION;
return res;
}
JNIEXPORT jfloat JNICALL Java_org_videolan_jvlc_Input__1getPosition (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
jfloat res;
GET_INPUT_THREAD ;
res = libvlc_media_instance_get_position( input, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION;
return res;
}
JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_Input__1getTime (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
vlc_int64_t res = 0;
GET_INPUT_THREAD ;
res = libvlc_media_instance_get_time( input, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION ;
return res;
}
JNIEXPORT jfloat JNICALL Java_org_videolan_jvlc_Input__1getFPS (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
float res;
GET_INPUT_THREAD ;
res = libvlc_media_instance_get_fps( input, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION ;
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Input__1setTime (JNIEnv *env, jobject _this, jlong time)
{
INIT_FUNCTION;
GET_INPUT_THREAD ;
libvlc_media_instance_set_time( input, time, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Input__1setPosition (JNIEnv *env, jobject _this, jfloat position )
{
INIT_FUNCTION;
GET_INPUT_THREAD ;
libvlc_media_instance_set_position( input, position, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION;
}
JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Input__1isPlaying (JNIEnv *env, jobject _this)
{
INIT_FUNCTION ;
vlc_bool_t res = 0;
GET_INPUT_THREAD ;
if (input == NULL) {
return false;
}
res = libvlc_media_instance_will_play( input, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION ;
return res;
}
JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Input__1hasVout (JNIEnv *env, jobject _this)
{
INIT_FUNCTION ;
vlc_bool_t res = 0;
GET_INPUT_THREAD ;
if (input == NULL) {
return false;
}
res = libvlc_media_instance_has_vout( input, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION ;
return res;
}

View File

@ -1,210 +0,0 @@
/*****************************************************************************
* playlist-jni.cc: JNI native playlist functions for VLC Java Bindings
*****************************************************************************
* 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
* (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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* These are a must*/
#include <jni.h>
#include <vlc/libvlc.h>
#ifdef WIN32
#include <windows.h>
#undef usleep
#define usleep(var) Sleep(var/1000)
#else
#include <unistd.h>
#endif
#include <stdio.h>
/* JVLC internal imports, generated by gcjh */
#include "../includes/Playlist.h"
#include "utils.h"
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1playlist_1add (JNIEnv *env, jobject _this, jstring uri, jstring name, jobjectArray options) {
INIT_FUNCTION ;
int res = 0;
int i_options = 0;
const char** ppsz_options = NULL;
const char* psz_uri = env->GetStringUTFChars( uri, 0 );
const char* psz_name = env->GetStringUTFChars( name, 0 );
if ( options != NULL ) {
i_options = ( int ) env->GetArrayLength( ( jarray ) options ) + 1;
ppsz_options = ( const char ** ) malloc( i_options * sizeof( char* ) );
sprintf( ( char * ) ppsz_options[0], "%s", "jvlc" );
for (int i = 0; i < i_options - 1; i++) {
ppsz_options[ i+1 ] =
env->GetStringUTFChars( ( jstring ) env->GetObjectArrayElement( options, i ), 0 );
}
res = libvlc_playlist_add_extended( ( libvlc_instance_t * ) instance, psz_uri, psz_name, i_options, ppsz_options, &exception );
CHECK_EXCEPTION;
} else {
res = libvlc_playlist_add( ( libvlc_instance_t * ) instance, psz_uri, psz_name, &exception );
CHECK_EXCEPTION;
}
if (psz_uri != NULL) {
env->ReleaseStringUTFChars( uri, psz_uri );
}
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1play (JNIEnv *env, jobject _this, jint id, jobjectArray options)
{
INIT_FUNCTION;
int i_options = 0;
const char** ppsz_options = NULL;
if ( options != NULL ) {
i_options = ( int ) env->GetArrayLength( ( jarray ) options );
ppsz_options = ( const char ** ) malloc( i_options * sizeof( char* ) );
for ( int i = 0; i < i_options - 1; i++ ) {
ppsz_options[ i ] =
env->GetStringUTFChars( ( jstring ) env->GetObjectArrayElement( options, i ), 0 );
}
}
libvlc_playlist_play( ( libvlc_instance_t * ) instance, id, i_options, ( char ** ) ppsz_options, &exception );
CHECK_EXCEPTION;
while (! libvlc_playlist_isplaying( (libvlc_instance_t*) instance, &exception ) )
{
usleep(100);
}
CHECK_EXCEPTION;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1pause (JNIEnv *env, jobject _this)
{
INIT_FUNCTION ;
libvlc_playlist_pause( ( libvlc_instance_t* ) instance, &exception );
CHECK_EXCEPTION ;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1stop (JNIEnv *env, jobject _this)
{
INIT_FUNCTION ;
libvlc_playlist_stop( ( libvlc_instance_t* ) instance, &exception );
while ( libvlc_playlist_isplaying( (libvlc_instance_t*) instance, &exception ) )
{
usleep(100);
}
CHECK_EXCEPTION ;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1next (JNIEnv *env, jobject _this)
{
INIT_FUNCTION ;
libvlc_playlist_next( ( libvlc_instance_t* ) instance, &exception );
CHECK_EXCEPTION ;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1prev (JNIEnv *env, jobject _this)
{
INIT_FUNCTION ;
libvlc_playlist_prev( (libvlc_instance_t*) instance, &exception );
CHECK_EXCEPTION ;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1clear (JNIEnv *env, jobject _this)
{
INIT_FUNCTION ;
libvlc_playlist_clear( (libvlc_instance_t*) instance, &exception );
CHECK_EXCEPTION ;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1deleteItem (JNIEnv *env, jobject _this, jint itemID)
{
INIT_FUNCTION ;
libvlc_playlist_delete_item( ( libvlc_instance_t * ) instance, itemID, &exception );
CHECK_EXCEPTION ;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1itemsCount (JNIEnv *env, jobject _this)
{
INIT_FUNCTION ;
int res = 0;
res = libvlc_playlist_items_count( (libvlc_instance_t*) instance, &exception );
CHECK_EXCEPTION ;
return res;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1isRunning (JNIEnv *env, jobject _this)
{
INIT_FUNCTION ;
int res = 0;
res = libvlc_playlist_isplaying( (libvlc_instance_t*) instance, &exception );
CHECK_EXCEPTION ;
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1setLoop
(JNIEnv *env, jobject _this, jboolean loop)
{
INIT_FUNCTION ;
libvlc_playlist_loop( (libvlc_instance_t*) instance, loop, &exception );
CHECK_EXCEPTION ;
}

View File

@ -1,52 +0,0 @@
/*****************************************************************************
* utils.cc: Utility functions for VLC Java Bindings
*****************************************************************************
* 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
* (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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* These are a must*/
#include <jni.h>
#include "utils.h"
JAWT awt;
JAWT_DrawingSurfaceInfo* dsi;
void handle_vlc_exception( JNIEnv* env, libvlc_exception_t* exception ) {
jclass newExcCls;
// raise a Java exception
newExcCls = env->FindClass("org/videolan/jvlc/VLCException");
if (newExcCls == 0) { /* Unable to find the new exception class, give up. */
return;
}
env->ThrowNew(newExcCls, libvlc_exception_get_message(exception));
}
jlong getInstance (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;
}

View File

@ -1,33 +0,0 @@
/* These are a must*/
#include <jni.h>
#include <jawt.h>
#include <jawt_md.h>
#include <vlc/libvlc.h>
#include <stdlib.h> // for free
void handle_vlc_exception( JNIEnv*, libvlc_exception_t* );
jlong getInstance ( JNIEnv* , jobject );
#define CHECK_EXCEPTION \
if ( libvlc_exception_raised( &exception )) \
{ \
handle_vlc_exception( env, &exception ); \
}
#define INIT_FUNCTION \
long instance; \
libvlc_exception_t exception; \
libvlc_exception_init( &exception ); \
instance = getInstance( env, _this );
#define GET_INPUT_THREAD \
libvlc_media_instance_t *input; \
input = libvlc_playlist_get_media_instance( ( libvlc_instance_t *) instance, &exception ); \
CHECK_EXCEPTION ;
#define ATTACH_JVM \
JNIEnv *env; \
jvm->AttachCurrentThread( ( void ** ) &env, NULL );

View File

@ -1,331 +0,0 @@
/*****************************************************************************
* video-jni.cc: JNI native video functions for VLC Java Bindings
*****************************************************************************
* 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
* (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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* These are a must*/
#include <jni.h>
#include <jawt.h>
#include <vlc/libvlc.h>
#include <stdio.h>
/* JVLC internal imports, generated by gcjh */
#include "../includes/Video.h"
#include "utils.h"
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1toggleFullscreen (JNIEnv *env, jobject _this)
{
INIT_FUNCTION ;
GET_INPUT_THREAD ;
libvlc_toggle_fullscreen( input, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION ;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1setFullscreen (JNIEnv *env, jobject _this, jboolean value)
{
INIT_FUNCTION ;
GET_INPUT_THREAD ;
libvlc_set_fullscreen( input, value, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION ;
}
JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Video__1getFullscreen (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
int res = 0;
GET_INPUT_THREAD ;
res = libvlc_get_fullscreen( input, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION ;
return res;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Video__1getHeight (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
int res = 0;
GET_INPUT_THREAD ;
res = libvlc_video_get_height( input, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION ;
return res;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Video__1getWidth (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
int res = 0;
GET_INPUT_THREAD ;
res = libvlc_video_get_width( input, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION ;
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1getSnapshot (JNIEnv *env, jobject _this, jstring filepath, jint width, jint height)
{
INIT_FUNCTION;
const char* psz_filepath = env->GetStringUTFChars( filepath, 0 );
GET_INPUT_THREAD ;
libvlc_video_take_snapshot( input, (char *) psz_filepath,(unsigned int) width,(unsigned int) height, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION ;
if (psz_filepath != NULL) {
env->ReleaseStringUTFChars( filepath, psz_filepath );
}
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1destroyVideo (JNIEnv *env, jobject _this)
{
INIT_FUNCTION ;
GET_INPUT_THREAD ;
libvlc_video_destroy( input, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1reparent (JNIEnv *env, jobject _this, jobject canvas)
{
INIT_FUNCTION ;
GET_INPUT_THREAD ;
libvlc_drawable_t drawable;
JAWT awt;
JAWT_DrawingSurface* ds;
JAWT_DrawingSurfaceInfo* dsi;
#ifdef WIN32
JAWT_Win32DrawingSurfaceInfo* dsi_win;
#else
JAWT_X11DrawingSurfaceInfo* dsi_x11;
GC gc;
#endif
jint lock;
/* Get the AWT */
awt.version = JAWT_VERSION_1_3;
if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
printf("AWT Not found\n");
libvlc_media_instance_release(input);
return;
}
/* Get the drawing surface */
ds = awt.GetDrawingSurface(env, canvas);
if (ds == NULL) {
printf("NULL drawing surface\n");
libvlc_media_instance_release(input);
return;
}
/* Lock the drawing surface */
lock = ds->Lock(ds);
if((lock & JAWT_LOCK_ERROR) != 0) {
printf("Error locking surface\n");
awt.FreeDrawingSurface(ds);
libvlc_media_instance_release(input);
return;
}
/* Get the drawing surface info */
dsi = ds->GetDrawingSurfaceInfo(ds);
if (dsi == NULL) {
printf("Error getting surface info\n");
ds->Unlock(ds);
awt.FreeDrawingSurface(ds);
libvlc_media_instance_release(input);
return;
}
#ifdef WIN32
/* Get the platform-specific drawing info */
dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
drawable = reinterpret_cast<int>(dsi_win->hwnd);
libvlc_video_set_parent((libvlc_instance_t *) instance, drawable, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION ;
#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);
XSetBackground(dsi_x11->display, gc, 0);
/* and reparent */
drawable = dsi_x11->drawable;
libvlc_video_set_parent( (libvlc_instance_t *) instance, drawable, &exception );
CHECK_EXCEPTION ;
XFreeGC(dsi_x11->display, gc);
#endif
/* Free the drawing surface info */
ds->FreeDrawingSurfaceInfo(dsi);
/* Unlock the drawing surface */
ds->Unlock(ds);
/* Free the drawing surface */
awt.FreeDrawingSurface(ds);
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1paint (JNIEnv *env, jobject _this, jobject canvas, jobject graphics)
{
INIT_FUNCTION ;
libvlc_drawable_t drawable;
JAWT awt;
JAWT_DrawingSurface* ds;
JAWT_DrawingSurfaceInfo* dsi;
#ifdef WIN32
JAWT_Win32DrawingSurfaceInfo* dsi_win;
#else
JAWT_X11DrawingSurfaceInfo* dsi_x11;
GC gc;
#endif
jint lock;
/* Get the AWT */
awt.version = JAWT_VERSION_1_3;
if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
printf("AWT Not found\n");
return;
}
/* Get the drawing surface */
ds = awt.GetDrawingSurface(env, canvas);
if (ds == NULL) {
printf("NULL drawing surface\n");
return;
}
/* Lock the drawing surface */
lock = ds->Lock(ds);
if((lock & JAWT_LOCK_ERROR) != 0) {
printf("Error locking surface\n");
awt.FreeDrawingSurface(ds);
return;
}
/* Get the drawing surface info */
dsi = ds->GetDrawingSurfaceInfo(ds);
if (dsi == NULL) {
printf("Error getting surface info\n");
ds->Unlock(ds);
awt.FreeDrawingSurface(ds);
return;
}
#ifdef WIN32
/* Get the platform-specific drawing info */
dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
drawable = reinterpret_cast<int>(dsi_win->hwnd);
libvlc_video_set_parent( (libvlc_instance_t *) instance, drawable, &exception );
CHECK_EXCEPTION ;
#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);
XSetBackground(dsi_x11->display, gc, 0);
/* and reparent */
drawable = dsi_x11->drawable;
libvlc_video_set_parent( (libvlc_instance_t *) instance, drawable, &exception );
CHECK_EXCEPTION ;
XFreeGC(dsi_x11->display, gc);
#endif
/* Free the drawing surface info */
ds->FreeDrawingSurfaceInfo(dsi);
/* Unlock the drawing surface */
ds->Unlock(ds);
/* Free the drawing surface */
awt.FreeDrawingSurface(ds);
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1setSize (JNIEnv *env, jobject _this, jint width, jint height)
{
INIT_FUNCTION ;
GET_INPUT_THREAD ;
libvlc_video_resize( input, width, height, &exception );
libvlc_media_instance_release(input);
CHECK_EXCEPTION ;
}

View File

@ -1,277 +0,0 @@
/*****************************************************************************
* vlm-jni.cc: JNI native VLM functions for VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
*
* Authors: Philippe Morin <phmorin@free.fr>
*
*
* $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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <jni.h>
#include <vlc/libvlc.h>
/* JVLC internal imports, generated by gcjh */
#include "../includes/VLM.h"
#include "utils.h"
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)
{
INIT_FUNCTION;
const char* psz_name = env->GetStringUTFChars( name, 0 );
const char* psz_inputmrl = env->GetStringUTFChars( inputmrl, 0 );
const char* psz_outputmrl = env->GetStringUTFChars( outputmrl, 0 );
int i_options = 0;
const char** ppsz_options = NULL;
if ( options != NULL ) {
i_options = ( int ) env->GetArrayLength( ( jarray ) options );
ppsz_options = ( const char ** ) malloc( i_options * sizeof( char* ) );
for ( int i = 0; i < i_options - 1; i++ ) {
ppsz_options[ i ] =
env->GetStringUTFChars( ( jstring ) env->GetObjectArrayElement( options, i ), 0 );
}
}
libvlc_vlm_add_broadcast( (libvlc_instance_t *) instance, (char*)psz_name, (char*)psz_inputmrl, (char*)psz_outputmrl ,
i_options, (char**)ppsz_options, enable, loop, &exception );
CHECK_EXCEPTION ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
if (psz_inputmrl != NULL) {
env->ReleaseStringUTFChars( inputmrl, psz_inputmrl );
}
if (psz_outputmrl != NULL) {
env->ReleaseStringUTFChars( outputmrl, psz_outputmrl );
}
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1deleteMedia (JNIEnv *env, jobject _this, jstring name)
{
INIT_FUNCTION ;
const char* psz_name = env->GetStringUTFChars( name, 0 );
libvlc_vlm_del_media( (libvlc_instance_t *) instance, (char*)psz_name, &exception);
CHECK_EXCEPTION ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1setEnabled (JNIEnv *env, jobject _this, jstring name, jboolean newStatus)
{
INIT_FUNCTION ;
const char* psz_name = env->GetStringUTFChars( name, 0 );
libvlc_vlm_set_enabled( (libvlc_instance_t *) instance, (char*)psz_name, newStatus, &exception);
CHECK_EXCEPTION ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1setOutput (JNIEnv *env, jobject _this, jstring name, jstring mrl)
{
INIT_FUNCTION;
const char* psz_name = env->GetStringUTFChars( name, 0 );
const char* psz_mrl = env->GetStringUTFChars( mrl, 0 );
libvlc_vlm_set_output((libvlc_instance_t *) instance, (char*)psz_name, (char*)psz_mrl, &exception);
CHECK_EXCEPTION ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
if (psz_mrl != NULL) {
env->ReleaseStringUTFChars( mrl, psz_mrl );
}
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1setInput (JNIEnv *env, jobject _this, jstring name, jstring mrl)
{
INIT_FUNCTION;
const char* psz_name = env->GetStringUTFChars( name, 0 );
const char* psz_mrl = env->GetStringUTFChars( mrl, 0 );
libvlc_vlm_set_input((libvlc_instance_t *) instance, (char*)psz_name, (char*)psz_mrl, &exception);
CHECK_EXCEPTION ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
if (psz_mrl != NULL) {
env->ReleaseStringUTFChars( mrl, psz_mrl );
}
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1setLoop (JNIEnv *env, jobject _this, jstring name, jboolean newStatus)
{
INIT_FUNCTION;
const char* psz_name = env->GetStringUTFChars( name, 0 );
libvlc_vlm_set_loop((libvlc_instance_t *) instance, (char*)psz_name, newStatus, &exception);
CHECK_EXCEPTION ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
}
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)
{
INIT_FUNCTION;
int i_options = 0;
const char** ppsz_options = NULL;
const char* psz_name = env->GetStringUTFChars( name, 0 );
const char* psz_inputmrl = env->GetStringUTFChars( inputmrl, 0 );
const char* psz_outputmrl = env->GetStringUTFChars( outputmrl, 0 );
if ( options != NULL ) {
i_options = ( int ) env->GetArrayLength( ( jarray ) options );
ppsz_options = ( const char ** ) malloc( i_options * sizeof( char* ) );
for ( int i = 0; i < i_options - 1; i++ ) {
ppsz_options[ i ] =
env->GetStringUTFChars( ( jstring ) env->GetObjectArrayElement( options, i ), 0 );
}
}
libvlc_vlm_change_media( (libvlc_instance_t *) instance, (char*)psz_name, (char*)psz_inputmrl, (char*)psz_outputmrl ,
i_options, (char**)ppsz_options, enablenewbroadcast, broadcast, &exception );
CHECK_EXCEPTION ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
if (psz_inputmrl != NULL) {
env->ReleaseStringUTFChars( name, psz_inputmrl );
}
if (psz_outputmrl != NULL) {
env->ReleaseStringUTFChars( name, psz_outputmrl );
}
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1playMedia (JNIEnv *env, jobject _this, jstring name)
{
INIT_FUNCTION;
const char* psz_name = env->GetStringUTFChars( name, 0 );
libvlc_vlm_play_media( (libvlc_instance_t *) instance, (char*)psz_name, &exception );
CHECK_EXCEPTION ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1stopMedia (JNIEnv *env, jobject _this, jstring name)
{
INIT_FUNCTION;
const char* psz_name = env->GetStringUTFChars( name, 0 );
libvlc_vlm_stop_media( (libvlc_instance_t *) instance, (char*)psz_name, &exception );
CHECK_EXCEPTION ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1pauseMedia (JNIEnv *env, jobject _this, jstring name)
{
INIT_FUNCTION;
const char* psz_name = env->GetStringUTFChars( name, 0 );
libvlc_vlm_pause_media( (libvlc_instance_t *) instance, (char*)psz_name, &exception );
CHECK_EXCEPTION ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1seekMedia (JNIEnv *env, jobject _this, jstring name, jfloat percentage)
{
INIT_FUNCTION;
const char* psz_name = env->GetStringUTFChars( name, 0 );
libvlc_vlm_seek_media( (libvlc_instance_t *) instance, (char*)psz_name, (float)percentage, &exception );
CHECK_EXCEPTION ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
}
JNIEXPORT jstring JNICALL Java_org_videolan_jvlc_VLM__1showMedia (JNIEnv *env, jobject _this, jstring name)
{
INIT_FUNCTION;
const char* psz_name = env->GetStringUTFChars( name, 0 );
char *psz_response;
jstring js_response;
psz_response = libvlc_vlm_show_media( (libvlc_instance_t *) instance, (char*)psz_name, &exception );
CHECK_EXCEPTION ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
js_response = env->NewStringUTF(psz_response);
if (psz_response != NULL) {
free(psz_response);
}
return js_response;
}
#define LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( attr, returnType, dummyGetType, dummyDefault)\
JNIEXPORT j ## returnType JNICALL Java_org_videolan_jvlc_VLM__1getMedia ## attr(JNIEnv *env, jobject _this, jstring name, jint index) \
{ \
INIT_FUNCTION; \
const char* psz_name = env->GetStringUTFChars( name, 0 ); \
returnType response; \
\
response = libvlc_vlm_get_media_ ## attr( (libvlc_instance_t *) instance, (char*)psz_name, (int)index, &exception ); \
CHECK_EXCEPTION ; \
\
if (psz_name != NULL) { \
env->ReleaseStringUTFChars( name, psz_name ); \
} \
return response; \
}
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( position, float, Float, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( time, int, Integer, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( length, int, Integer, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( rate, int, Integer, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( title, int, Integer, 0);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( chapter, int, Integer, 0);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( seekable, int, Bool, 0);
#undef LIBVLC_VLM_GET_MEDIA_ATTRIBUTE

View File

@ -5973,17 +5973,15 @@ AC_ARG_ENABLE(java-bindings,
[ --enable-java-bindings Enable Java bindings (default disabled)])
if test "${enable_java_bindings}" = "yes"
then
AS_IF([test "x${JAVA_HOME}" == "x"],
[AC_MSG_ERROR([Please set the JAVA_HOME variable to your JDK environment])])
AC_PROG_JAVAC
AC_PROG_JAVA
PLUGINS_BINDINGS="${PLUGINS_BINDINGS} java"
if test "${JAVAC}" == "javac${EXEEXT}"
then
JAVAC="javac${EXEEXT} -cp ./ "
fi
echo ""
echo "****** WARNING **** WARNING ***** WARNING *************"
echo "*** To compile the java bindings go to the
echo "*** bindings/java folder and run ant.
echo "*** This configuration will continue, so you will be
echo "*** able to compile VideoLAN as usual.
echo "*******************************************************"
echo ""
fi
AM_CONDITIONAL(BUILD_JAVA, [test "${enable_java_bindings}" = "yes"])
dnl
dnl test plugins
@ -6162,8 +6160,6 @@ AC_CONFIG_FILES([
projects/activex/Makefile
projects/activex/axvlc.inf
bindings/Makefile
bindings/java/Makefile
bindings/java/src/Makefile
bindings/python/Makefile
doc/Makefile
extras/package/ipkg/Makefile