From 53e8222b87b6ae4f94daa402ff9e55567adab2d6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20Stenac?= Date: Sat, 26 Nov 2005 17:31:37 +0000 Subject: [PATCH] Java bindings by Filippo Carone. Tweaked to integrate into build system --- AUTHORS | 5 + bindings/Makefile.am | 2 +- bindings/java/Makefile.am | 48 +++ bindings/java/README | 38 ++ bindings/java/TODO | 21 ++ bindings/java/VlcClient.java | 139 +++++++ bindings/java/javadoc.xml | 6 + bindings/java/org/videolan/jvlc/JVLC.java | 180 +++++++++ .../org/videolan/jvlc/JVLCBoolVariable.java | 39 ++ .../java/org/videolan/jvlc/JVLCCanvas.java | 41 ++ .../org/videolan/jvlc/JVLCFloatVariable.java | 39 ++ .../org/videolan/jvlc/JVLCIntVariable.java | 40 ++ .../jvlc/JVLCNoSuchVariableNameException.java | 47 +++ .../org/videolan/jvlc/JVLCStringVariable.java | 39 ++ .../org/videolan/jvlc/JVLCTimeVariable.java | 39 ++ .../java/org/videolan/jvlc/JVLCVarValue.java | 46 +++ .../org/videolan/jvlc/JVLCVarVariable.java | 39 ++ .../java/org/videolan/jvlc/JVLCVariable.java | 49 +++ .../jvlc/mediacontrol/MediaControl.java | 26 ++ .../mediacontrol/MediaControlException.java | 34 ++ .../mediacontrol/MediaControlInstance.java | 33 ++ .../mediacontrol/MediaControlPlaylistSeq.java | 33 ++ .../mediacontrol/MediaControlPosition.java | 52 +++ .../MediaControlPositionKeyEnum.java | 30 ++ .../MediaControlPositionOrigin.java | 30 ++ .../MediaControlPositionOriginEnum.java | 30 ++ .../mediacontrol/MediaControlRGBPicture.java | 40 ++ bindings/java/vlc-glue-cni.cc | 337 +++++++++++++++++ bindings/java/vlc-glue-jni.cc | 356 ++++++++++++++++++ bindings/java/vlc-graphics-jni.cc | 103 +++++ configure.ac | 12 + 31 files changed, 1972 insertions(+), 1 deletion(-) create mode 100644 bindings/java/Makefile.am create mode 100644 bindings/java/README create mode 100644 bindings/java/TODO create mode 100644 bindings/java/VlcClient.java create mode 100644 bindings/java/javadoc.xml create mode 100644 bindings/java/org/videolan/jvlc/JVLC.java create mode 100644 bindings/java/org/videolan/jvlc/JVLCBoolVariable.java create mode 100644 bindings/java/org/videolan/jvlc/JVLCCanvas.java create mode 100644 bindings/java/org/videolan/jvlc/JVLCFloatVariable.java create mode 100644 bindings/java/org/videolan/jvlc/JVLCIntVariable.java create mode 100644 bindings/java/org/videolan/jvlc/JVLCNoSuchVariableNameException.java create mode 100644 bindings/java/org/videolan/jvlc/JVLCStringVariable.java create mode 100644 bindings/java/org/videolan/jvlc/JVLCTimeVariable.java create mode 100644 bindings/java/org/videolan/jvlc/JVLCVarValue.java create mode 100644 bindings/java/org/videolan/jvlc/JVLCVarVariable.java create mode 100644 bindings/java/org/videolan/jvlc/JVLCVariable.java create mode 100644 bindings/java/org/videolan/jvlc/mediacontrol/MediaControl.java create mode 100644 bindings/java/org/videolan/jvlc/mediacontrol/MediaControlException.java create mode 100644 bindings/java/org/videolan/jvlc/mediacontrol/MediaControlInstance.java create mode 100644 bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPlaylistSeq.java create mode 100644 bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPosition.java create mode 100644 bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPositionKeyEnum.java create mode 100644 bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPositionOrigin.java create mode 100644 bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPositionOriginEnum.java create mode 100644 bindings/java/org/videolan/jvlc/mediacontrol/MediaControlRGBPicture.java create mode 100644 bindings/java/vlc-glue-cni.cc create mode 100644 bindings/java/vlc-glue-jni.cc create mode 100644 bindings/java/vlc-graphics-jni.cc diff --git a/AUTHORS b/AUTHORS index 28f03afddc..04fd3cb373 100644 --- a/AUTHORS +++ b/AUTHORS @@ -100,6 +100,11 @@ C: bozo D: SDL video output S: France +N: Filippo Carone +E: filippo[dontspam]@carone.org +D: Java bindings +S: Italy + N: Tony Castley E: tony@castley.net C: tcastley diff --git a/bindings/Makefile.am b/bindings/Makefile.am index 96fcb3e253..083d6a1556 100644 --- a/bindings/Makefile.am +++ b/bindings/Makefile.am @@ -1 +1 @@ -SUBDIRS = python +SUBDIRS = python java diff --git a/bindings/java/Makefile.am b/bindings/java/Makefile.am new file mode 100644 index 0000000000..55126f53e2 --- /dev/null +++ b/bindings/java/Makefile.am @@ -0,0 +1,48 @@ +####################################################################### +# VLC Java Bindings +####################################################################### + +if BUILD_JAVA + +OBJECTS = org/videolan/jvlc/JVLCNoSuchVariableNameException.class org/videolan/jvlc/JVLCBoolVariable.class org/videolan/jvlc/JVLCIntVariable.class org/videolan/jvlc/JVLCTimeVariable.class org/videolan/jvlc/JVLCVarValue.class org/videolan/jvlc/JVLCVariable.class org/videolan/jvlc/JVLCFloatVariable.class org/videolan/jvlc/JVLCStringVariable.class org/videolan/jvlc/JVLCVarVariable.class org/videolan/jvlc/JVLC.class org/videolan/jvlc/JVLCCanvas.class + +JNIHEADERS = org/videolan/jvlc/JVLCNoSuchVariableNameException.h org_videolan_jvlc_JVLCBoolVariable.h org_videolan_jvlc_JVLCFloatVariable.h org_videolan_jvlc_JVLC.h org_videolan_jvlc_JVLCIntVariable.h org_videolan_jvlc_JVLCStringVariable.h org_videolan_jvlc_JVLCTimeVariable.h org_videolan_jvlc_JVLCVariable.h org_videolan_jvlc_JVLCVarValue.h org_videolan_jvlc_JVLCVarVariable.h org_videolan_jvlc_JVLCCanvas.h + +# Include some JAVA stuff +JINCLUDES = -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux +LIBJINCLUDES = -L${JAVA_HOME}/jre/lib/i386 -ljawt + +# Binaries +JCC = gcj -g +JCH = gcjh -jni + +# Compile flags +CXXFLAGS += `top_builddir=../.. ../../vlc-config --cflags` -I../../ -I ../../include ${JINCLUDES} +LDFLAGS += -L../../lib -lvlc_pic -fPIC `top_builddir=../.. ../../vlc-config --libs builtin pic` + +# Build targets +all: libjvlc.so VlcClient + +# FIXME: -ldbus-1 and -lhal are UGLY +# Problem is vlc-config --libs builtin does not output what is needed to build +# vlc. We need to clean up vlc-config first +libjvlc.so: vlc-glue-jni.o vlc-graphics-jni.o + $(CXX) -ldbus-1 -lhal -shared vlc-glue-jni.o vlc-graphics-jni.o $(LIBJINCLUDES) ${LDFLAGS} -o libjvlc.so + +vlc-graphics-jni.o: VlcClient + $(CXX) -c vlc-graphics-jni.cc $(CXXFLAGS) + +vlc-glue-jni.o: VlcClient + $(CXX) -c vlc-glue-jni.cc $(CXXFLAGS) + +VlcClient: $(OBJECTS) + $(JCC) -C VlcClient.java + +%.class: %.java + $(JCC) -C $? + $(JCH) org/videolan/jvlc/$(*F) + +clean: + rm -f *.class *~ org/videolan/jvlc/*.class org_videolan*.h *.so *.o + +endif diff --git a/bindings/java/README b/bindings/java/README new file mode 100644 index 0000000000..808246376b --- /dev/null +++ b/bindings/java/README @@ -0,0 +1,38 @@ + + First of all, this is a *developers* only version + + +Usage +----- + + In order to use these bindings you have to compile vlc from source. I +recommend you to take the latest version from videolan svn repository +by doing: + +svn co svn://svn.videolan.org/vlc/trunk vlc-trunk + + bootstrap and configure. At the configure give the command: + +./configure --enable-mozilla && make && make install + + to enable compilation of _pic version of libraries. If you give a +prefix be sure to change the PREFIX variable in the Makefile from + /usr/local to your prefix. + + Once you've done with vlc you can run make in jvlc directory. Be sure +you have gcj, gcjh and if you want to use the SUN Java compiler, +change the Makefile accordingly. You will probably need to change also + +JINCLUDES +LIBJINCLUDES + + In the next releases I will automate this process. + + To run JVLC issue: + +java -Djava.library.path=. VlcClient + + Be sure your ldconfig can find libjawt.so and libmawt.so or you will +get linking errors when you run the program. + + Happy playing. \ No newline at end of file diff --git a/bindings/java/TODO b/bindings/java/TODO new file mode 100644 index 0000000000..0c3a3f1aa9 --- /dev/null +++ b/bindings/java/TODO @@ -0,0 +1,21 @@ +[MediaControl - in progress] +* enums will be final classes with private constructor, for type safety + +[JNI] +* mediacontrol + +[general] +* JUnit testing + +* configure / make install + +* find a good way to divide CNI and JNI versions (same Java classes, + different interfaces) maybe: two JVLC.java classes, one with the + System.loadLibray for jni and the other without + +[CNI] +* mediacontrol + + + +Items are ordered by priority, the first having the highest priority diff --git a/bindings/java/VlcClient.java b/bindings/java/VlcClient.java new file mode 100644 index 0000000000..238467ae49 --- /dev/null +++ b/bindings/java/VlcClient.java @@ -0,0 +1,139 @@ +import org.videolan.jvlc.*; + +import java.awt.*; +import java.awt.event.*; + +class VLCPlayerFrame extends Frame { + public VLCPlayerFrame() { + initComponents(); + } + + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + 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(); + +// jPanel = new javax.swing.JPanel(); + jvcc = new JVLCCanvas(); + jvlc = jvcc.getJVLCObject(); +// jPanel.add( jvcc ); + add( jvcc ); + + // FIXME: Does not work with GridBagLayout + setLayout(new java.awt.GridLayout(3,2)); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; +// add( jPanel , gridBagConstraints); + + + fullScreenButton.setText("FullScreen"); + fullScreenButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + fullScreenButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + add( fullScreenButton, gridBagConstraints); + + + jTextField1.setText("URL"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridwidth = 2; + 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) { + setButtonActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 1; + 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) { + pauseButtonActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + add(pauseButton, gridBagConstraints); + + stopButton.setText("Stop"); + stopButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + stopButtonActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + add(stopButton, gridBagConstraints); + + pack(); + } + + private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) { + jvlc.stop(); + } + + private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) { + jvlc.pause(); + } + + private void setButtonActionPerformed(java.awt.event.ActionEvent evt) { + jvlc.stop(); + jvlc.playlistClear(); + jvlc.addTarget( jTextField1.getText(), null, 1, -666 ); + jvlc.play(); + } + + 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 javax.swing.JPanel jPanel; + private JVLCCanvas jvcc; + public JVLC jvlc; +} + + +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); + } +} diff --git a/bindings/java/javadoc.xml b/bindings/java/javadoc.xml new file mode 100644 index 0000000000..4fb614e0cf --- /dev/null +++ b/bindings/java/javadoc.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/bindings/java/org/videolan/jvlc/JVLC.java b/bindings/java/org/videolan/jvlc/JVLC.java new file mode 100644 index 0000000000..c65c79d191 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/JVLC.java @@ -0,0 +1,180 @@ +package org.videolan.jvlc; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +/** + * This is the main Java VLC class which represents a vlc_object_t. Through this + * class it's possible to control media loading/playing. It's possible to have + * more than one JVLC object in the same program. + */ +public class JVLC { + + static { + System.loadLibrary("jvlc"); + } + + private int id; + + /** + * @param args Arguments for the vlc object. These are the same as the + * original C version of VLC. + */ + public JVLC(String[] args) { + String[] properArgs = new String[args.length + 1]; + properArgs[0] = "jvlc"; + for (int i = 0; i < args.length; i++) + properArgs[i+1] = args[i]; + + this.id = create(); + init(properArgs); + } + + public JVLC() { + new JVLC(new String[]{""}); + } + + /** + * @return Returns the ID of the VLC Object + */ + public int getID() { + return this.id; + } + + + /** + * Cleanup the VLC Object. It's the equivalent of + * calling VLC_Die() and VLC_CleanUp() + */ + public void quit() { + this.die(); + this.cleanUp(); + } + + private native int create(); + + private native int init(String[] args); + + /** + * + * Creates the interface of the videolan player + * + * @param moduleName The interface module to display + * @param blocking True if the interface is blocking, otherwise it runs on its own thread + * @param startPlay True if the player starts to play as soon as the interface is displayed + * @return An int which is < 0 on error + */ + public native int addInterface(String moduleName, boolean blocking, boolean startPlay); + + /** + * + * Creates the interface of the videolan player with the default interface + * or the interface set by -I + * + * @param blocking True if the interface is blocking, otherwise it runs on its own thread + * @param startPlay True if the player starts to play as soon as the interface is displayed + * @return An int which is < 0 on error + */ + public int addInterface(boolean blocking, boolean startPlay) { + return addInterface(null, blocking, startPlay); + } + + /** + * @return The version of the VideoLan object + */ + public native String getVersion(); + + public native String getError(int errorCode); + + private native int die(); + + private native int cleanUp(); + + public native int setVariable(JVLCVariable jvlcVariable); + + public native JVLCVariable getVariable(String varName); // XXX in progress + + public native int addTarget(String URI, String[] options, int insertMode, int position); + + /** + * Plays the media + * + * @return An int which is < 0 on error + */ + public native int play(); + + /** + * + * Pauses the media. If the media is already paused, pause() restarts it. + * + * @return + */ + public native int pause(); + + /** + * + * Stops the media + * + * @return + */ + public native int stop(); + + /** + * @return True if the player is actually playing something + */ + public native boolean isPlaying(); + + /** + * @return The absolute position within the media + */ + public native float getPosition(); + + public native float setPosition(float position); + + public native int getTime(); + + public native int setTime(int seconds, boolean relative); + + public native int getLength(); + + public native float speedFaster(); + + public native float speedSlower(); + + public native int getPlaylistIndex(); + + public native int getPlaylistItems(); + + public native int playlistNext(); + + public native int playlistPrev(); + + public native int playlistClear(); + + public native int getVolume(); + + public native int setVolume(int volume); + + public native int muteVolume(); + + public native int fullScreen(); +} diff --git a/bindings/java/org/videolan/jvlc/JVLCBoolVariable.java b/bindings/java/org/videolan/jvlc/JVLCBoolVariable.java new file mode 100644 index 0000000000..ee43e2d6c4 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/JVLCBoolVariable.java @@ -0,0 +1,39 @@ +package org.videolan.jvlc; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +/** + * This class is part of JVLCVariable pool. + */ +public class JVLCBoolVariable extends JVLCVariable { + + public JVLCBoolVariable(String name, int value) throws JVLCNoSuchVariableNameException { + super(name); + this.value = (value != 0)? new Integer(1) : new Integer(0); + } + + public int getBoolValue() { + return ((Integer)value).intValue(); + } + +} diff --git a/bindings/java/org/videolan/jvlc/JVLCCanvas.java b/bindings/java/org/videolan/jvlc/JVLCCanvas.java new file mode 100644 index 0000000000..103abf2a0f --- /dev/null +++ b/bindings/java/org/videolan/jvlc/JVLCCanvas.java @@ -0,0 +1,41 @@ +/* + * Created on 25-nov-2005 + * + * 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-1307, USA. + * + */ +/** + * @author Filippo Carone + */ + +package org.videolan.jvlc; + +import java.awt.Canvas; +import java.awt.Graphics; + +public class JVLCCanvas extends Canvas { + + public native void paint(Graphics g); + + private final JVLC jvlcObject = new JVLC(); + + public JVLCCanvas() { + jvlcObject.addInterface("dummy", false, false); + } + + public JVLC getJVLCObject() { + return jvlcObject; + } +} diff --git a/bindings/java/org/videolan/jvlc/JVLCFloatVariable.java b/bindings/java/org/videolan/jvlc/JVLCFloatVariable.java new file mode 100644 index 0000000000..9938a06f59 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/JVLCFloatVariable.java @@ -0,0 +1,39 @@ +package org.videolan.jvlc; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +/** + * This class is part of JVLCVariable pool. + */ +public class JVLCFloatVariable extends JVLCVariable { + + public JVLCFloatVariable(String name, float value) throws JVLCNoSuchVariableNameException { + super(name); + this.value = new Float(value); + } + + public float getFloatValue() { + return ((Float)value).floatValue(); + } + +} diff --git a/bindings/java/org/videolan/jvlc/JVLCIntVariable.java b/bindings/java/org/videolan/jvlc/JVLCIntVariable.java new file mode 100644 index 0000000000..e5018c1898 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/JVLCIntVariable.java @@ -0,0 +1,40 @@ +package org.videolan.jvlc; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +/** + * This class is part of JVLCVariable pool. + */ +public class JVLCIntVariable extends JVLCVariable { + + + public JVLCIntVariable(String name, int value) throws JVLCNoSuchVariableNameException { + super(name); + this.value = new Integer(value); + } + + public int getIntValue() { + return ((Integer)value).intValue(); + } + +} diff --git a/bindings/java/org/videolan/jvlc/JVLCNoSuchVariableNameException.java b/bindings/java/org/videolan/jvlc/JVLCNoSuchVariableNameException.java new file mode 100644 index 0000000000..340c6115d4 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/JVLCNoSuchVariableNameException.java @@ -0,0 +1,47 @@ +/* + * Created on 22-nov-2005 + * + * 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-1307, USA. + * + */ +/** + * @author Filippo Carone + */ + +package org.videolan.jvlc; + +public class JVLCNoSuchVariableNameException extends Exception { + + public JVLCNoSuchVariableNameException() { + super(); + // TODO Auto-generated constructor stub + } + + public JVLCNoSuchVariableNameException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + public JVLCNoSuchVariableNameException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + public JVLCNoSuchVariableNameException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + +} diff --git a/bindings/java/org/videolan/jvlc/JVLCStringVariable.java b/bindings/java/org/videolan/jvlc/JVLCStringVariable.java new file mode 100644 index 0000000000..86518626a8 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/JVLCStringVariable.java @@ -0,0 +1,39 @@ +package org.videolan.jvlc; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +/** + * This class is part of JVLCVariable pool. + */ +public class JVLCStringVariable extends JVLCVariable { + + public JVLCStringVariable(String name, String value) throws JVLCNoSuchVariableNameException { + super(name); + this.value = value; + } + + public String getStringValue() { + return (String)value; + } + +} diff --git a/bindings/java/org/videolan/jvlc/JVLCTimeVariable.java b/bindings/java/org/videolan/jvlc/JVLCTimeVariable.java new file mode 100644 index 0000000000..8c7f1f802e --- /dev/null +++ b/bindings/java/org/videolan/jvlc/JVLCTimeVariable.java @@ -0,0 +1,39 @@ +package org.videolan.jvlc; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +/** + * This class is part of JVLCVariable pool. + */ +public class JVLCTimeVariable extends JVLCVariable { + + public JVLCTimeVariable(String name, long value) throws JVLCNoSuchVariableNameException { + super(name); + this.value = new Long(value); + } + + public long getTimeValue() { + return ((Long)value).longValue(); + } + +} diff --git a/bindings/java/org/videolan/jvlc/JVLCVarValue.java b/bindings/java/org/videolan/jvlc/JVLCVarValue.java new file mode 100644 index 0000000000..1d39c23f76 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/JVLCVarValue.java @@ -0,0 +1,46 @@ +package org.videolan.jvlc; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +/** + * This class is part of JVLCVariable pool. + */ +public class JVLCVarValue { + + String name; + int OID; + + public JVLCVarValue(String name, int OID) { + this.name = name; + this.OID = OID; + } + + public String getName() { + return name; + } + + public int getOID() { + return OID; + } + +} diff --git a/bindings/java/org/videolan/jvlc/JVLCVarVariable.java b/bindings/java/org/videolan/jvlc/JVLCVarVariable.java new file mode 100644 index 0000000000..053e2ad21a --- /dev/null +++ b/bindings/java/org/videolan/jvlc/JVLCVarVariable.java @@ -0,0 +1,39 @@ +package org.videolan.jvlc; + +/***************************************************************************** + * JVLCVarVariable.java: Varying Variable + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +/** + * This class is part of JVLCVariable pool. + */ +public class JVLCVarVariable extends JVLCVariable { + + public JVLCVarVariable(String name, JVLCVarValue value) throws JVLCNoSuchVariableNameException { + super(name); + this.value = value; + } + + public JVLCVarValue getVarValue() { + return (JVLCVarValue)value; + } + +} diff --git a/bindings/java/org/videolan/jvlc/JVLCVariable.java b/bindings/java/org/videolan/jvlc/JVLCVariable.java new file mode 100644 index 0000000000..7e7108f3d2 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/JVLCVariable.java @@ -0,0 +1,49 @@ +package org.videolan.jvlc; + +/***************************************************************************** + * JVLCVariable.java: Abstract Variable class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2005 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +/** + * This class is part of JVLCVariable pool. + */ +public abstract class JVLCVariable { + protected String name; + protected Object value; + + public JVLCVariable(String name) throws JVLCNoSuchVariableNameException { + if (name == null) throw new JVLCNoSuchVariableNameException(); + this.name = name; + } + + public String getName() { + return name; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + +} diff --git a/bindings/java/org/videolan/jvlc/mediacontrol/MediaControl.java b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControl.java new file mode 100644 index 0000000000..ae0e531ab0 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControl.java @@ -0,0 +1,26 @@ +package org.videolan.jvlc.mediacontrol; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +public class MediaControl { +} diff --git a/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlException.java b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlException.java new file mode 100644 index 0000000000..307399c382 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlException.java @@ -0,0 +1,34 @@ +package org.videolan.jvlc.mediacontrol; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +public class MediaControlException extends Exception { + + int code; + String message; + + public MediaControlException() { // XXX maybe this is not the constructor signature + super(); + } + +} diff --git a/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlInstance.java b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlInstance.java new file mode 100644 index 0000000000..944e50a2c9 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlInstance.java @@ -0,0 +1,33 @@ +package org.videolan.jvlc.mediacontrol; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +import org.videolan.jvlc.JVLC; + +public class MediaControlInstance { + + JVLC vlc; + //Playlist playlist; + //intf thread; + +} diff --git a/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPlaylistSeq.java b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPlaylistSeq.java new file mode 100644 index 0000000000..c532b69a4c --- /dev/null +++ b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPlaylistSeq.java @@ -0,0 +1,33 @@ +package org.videolan.jvlc.mediacontrol; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +public class MediaControlPlaylistSeq { + + private int size; + private String[] data; // char** + + public MediaControlPlaylistSeq() { + } + +} diff --git a/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPosition.java b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPosition.java new file mode 100644 index 0000000000..aa851c64ab --- /dev/null +++ b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPosition.java @@ -0,0 +1,52 @@ +package org.videolan.jvlc.mediacontrol; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +public class MediaControlPosition { + + private long value; + + int origin; // one of MediaControlPositionOriginEnum + int key; // one of MediaControlPositionOriginEnum + + + /* + * Constructor + */ + + public MediaControlPosition() { + } + + + /* + * Getters/Setters + */ + public long getValue() { + return value; + } + + public void setValue(long value) { + this.value = value; + } + +} diff --git a/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPositionKeyEnum.java b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPositionKeyEnum.java new file mode 100644 index 0000000000..b4922e5198 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPositionKeyEnum.java @@ -0,0 +1,30 @@ +package org.videolan.jvlc.mediacontrol; + +/***************************************************************************** + * MediaControlPositionOrigin.java: class for vlc MediaControl Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + + +public class MediaControlPositionKeyEnum { + public static final int BYTECOUNT = 1; + public static final int SAMPLECOUNT = 2; + public static final int MEDIATIME = 3; +} diff --git a/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPositionOrigin.java b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPositionOrigin.java new file mode 100644 index 0000000000..b10f4b01dc --- /dev/null +++ b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPositionOrigin.java @@ -0,0 +1,30 @@ +package org.videolan.jvlc.mediacontrol; + +/***************************************************************************** + * MediaControlPositionOrigin.java: class for vlc MediaControl Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + + +public class MediaControlPositionOrigin { + public static final int AbsolutePosition = 1; + public static final int RelativePosition = 2; + public static final int ModuloPosition = 3; +} diff --git a/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPositionOriginEnum.java b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPositionOriginEnum.java new file mode 100644 index 0000000000..ad93d49ef5 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlPositionOriginEnum.java @@ -0,0 +1,30 @@ +package org.videolan.jvlc.mediacontrol; + +/***************************************************************************** + * MediaControlPositionOrigin.java: class for vlc MediaControl Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + + +public class MediaControlPositionOriginEnum { + public static final int ABSOLUTEPOSITION = 1; + public static final int RELATIVEPOSITION = 2; + public static final int MODULOPOSITION = 3; +} diff --git a/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlRGBPicture.java b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlRGBPicture.java new file mode 100644 index 0000000000..e88d8c76c5 --- /dev/null +++ b/bindings/java/org/videolan/jvlc/mediacontrol/MediaControlRGBPicture.java @@ -0,0 +1,40 @@ +package org.videolan.jvlc.mediacontrol; + +/***************************************************************************** + * JVLC.java: global class for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2004 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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. + *****************************************************************************/ + +import java.util.Date; + +public class MediaControlRGBPicture { + + private int width; + private int height; + long type; + Date date; + int size; + String data; // char *data + + + public MediaControlRGBPicture() { + } + +} diff --git a/bindings/java/vlc-glue-cni.cc b/bindings/java/vlc-glue-cni.cc new file mode 100644 index 0000000000..50034e2ddb --- /dev/null +++ b/bindings/java/vlc-glue-cni.cc @@ -0,0 +1,337 @@ +/***************************************************************************** + * JVLC.java: CNI interface for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2005 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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 +#include + +#include // for printf +#include // for calloc + +/* JVLC internal imports, generated by gcjh */ +#include "org/videolan/jvlc/JVLC.h" +#include "org/videolan/jvlc/JVLCVariable.h" +#include "org/videolan/jvlc/JVLCIntVariable.h" +#include "org/videolan/jvlc/JVLCBoolVariable.h" +#include "org/videolan/jvlc/JVLCFloatVariable.h" +#include "org/videolan/jvlc/JVLCStringVariable.h" +#include "org/videolan/jvlc/JVLCTimeVariable.h" +#include "org/videolan/jvlc/JVLCVarVariable.h" +#include "org/videolan/jvlc/JVLCVarValue.h" + +/* Java classes used throughout here */ +#include +#include +#include +#include + +void setString(jstring orig, char* dest); + +jint org::videolan::jvlc::JVLC::create () { + return VLC_Create(); +} + +jint org::videolan::jvlc::JVLC::init(JArray< ::java::lang::String *> *args) { + + int argc = 0; + char* arguments[argc]; + + if (args != NULL) // It's a very bad day otherwise + { + argc = args->length; + arguments[argc]; + + /* + * convert the JArray* in char** + * in a suitable way for VLC_Init + */ + jstring* argsElements = elements(args); + + for (int i = 0; i < argc; i++) { + arguments[i] = (char*) malloc(JvGetStringUTFLength(argsElements[i]) + 1); + setString(argsElements[i], arguments[i]); + } + } + + return VLC_Init(0, argc, arguments); +} + + +jint org::videolan::jvlc::JVLC::addInterface(java::lang::String* moduleName, jboolean blocking, jboolean startPlay) { + + char* psz_module = NULL; + if (moduleName != NULL) { + psz_module = (char *) malloc(JvGetStringUTFLength(moduleName)); + setString(moduleName, psz_module); + } + + int i_blocking = 0; + int i_startPlay = 0; + if (blocking) i_blocking = 1; + if (startPlay) i_startPlay = 1; + + int addIntf_res = VLC_AddIntf(this->id, (char* const) psz_module, i_blocking, i_startPlay); + + if (psz_module != NULL) + free(psz_module); + + return addIntf_res; + +} + + +jstring org::videolan::jvlc::JVLC::getVersion() { + return JvNewStringUTF(VLC_Version()); +} + + +jstring org::videolan::jvlc::JVLC::getError(jint errorCode) { + return JvNewStringUTF(VLC_Error(errorCode)); +} + + +jint org::videolan::jvlc::JVLC::die() { + return VLC_Die(this->id); +} + + +jint org::videolan::jvlc::JVLC::cleanUp() { + return VLC_CleanUp(this->id); +} + + +jint org::videolan::jvlc::JVLC::setVariable(org::videolan::jvlc::JVLCVariable *jvlcVariable) { + + /* these are the two parameters given the the + * VLC_VariableSet() function + */ + vlc_value_t value; + char* psz_var = NULL; + + if (jvlcVariable != NULL) { + jclass variableClass = jvlcVariable->getClass(); + + /* We use the class name for kinda of instanceof */ + jstring className = variableClass->getName(); + + /** + * VLC_SetVariable takes a union as its second argument. + * The union members are mapped 1:1 to java types which + * extend JVLCVariable. So here we check the runtime type + * of the actual variable and act consequently. Here is the + * mapping: + * + * typedef union + *{ + * int i_int; JVLCIntVariable + * vlc_bool_t b_bool; JVLCBoolVariable + * float f_float; JVLCFloatVariable + * char * psz_string; JVLCStringVariable + * void * p_address; -- NOT IMPLEMENTED -- + * vlc_object_t * p_object; -- NOT IMPLEMENTED -- + * vlc_list_t * p_list; JVLCListVariable XXX:TODO + * signed long long i_time; JVLCTimeVariable + * struct { char *psz_name; int i_object_id; } var; JVLCVarVariable <- this name sucks + * // Make sure the structure is at least 64bits + * struct { char a, b, c, d, e, f, g, h; } padding; <- Do we really need this? + * + * } vlc_value_t; + */ + + /* i_int */ + if (className->equals(JvNewStringUTF("VLCIntVariable" ))) { + value.i_int = ((org::videolan::jvlc::JVLCIntVariable *)jvlcVariable)->getIntValue(); + } + /* b_bool */ + else if (className->equals(JvNewStringUTF("VLCBoolVariable"))) { + value.b_bool = ((org::videolan::jvlc::JVLCBoolVariable *)jvlcVariable)->getBoolValue(); + } + /* f_float */ + else if (className->equals(JvNewStringUTF("VLCFloatVariable"))) { + value.f_float = ((org::videolan::jvlc::JVLCFloatVariable *)jvlcVariable)->getFloatValue(); + } + /* psz_string */ + else if (className->equals(JvNewStringUTF("VLCStringVariable"))) { + value.psz_string = (char* const) elements((((org::videolan::jvlc::JVLCStringVariable *)jvlcVariable)->getStringValue())->toCharArray()); + } + /* i_time */ + else if (className->equals(JvNewStringUTF("VLCTimeVariable"))) { + value.i_time = ((org::videolan::jvlc::JVLCTimeVariable *)jvlcVariable)->getTimeValue(); + } + + /* var */ + else if (className->equals(JvNewStringUTF("VLCVarVariable"))) { + jstring varValueName = ((org::videolan::jvlc::JVLCVarVariable *)jvlcVariable)->getVarValue()->getName(); + value.var.psz_name = (char *) malloc(JvGetStringUTFLength(varValueName)); + setString(varValueName, value.var.psz_name); + value.var.i_object_id = (((org::videolan::jvlc::JVLCVarVariable *)jvlcVariable)->getVarValue())->getOID(); + } + psz_var = (char *) malloc(JvGetStringUTFLength(jvlcVariable->getName())); + setString(jvlcVariable->getName(), psz_var); + } + + return VLC_VariableSet(this->id, (char* const) psz_var, value); + +} + +jint org::videolan::jvlc::JVLC::addTarget(::java::lang::String *URI, JArray< ::java::lang::String *> *options, jint insertMode, jint position) { + + char* psz_target = NULL; + char** ppsz_options = NULL; + int options_number = 0; + + if (URI != NULL) { + psz_target = (char *) malloc( JvGetStringUTFLength(URI)); + setString(URI, psz_target); + } + + if (options != NULL) { + options_number = options->length; + ppsz_options = (char **) malloc (options_number * sizeof(char*)); + //ppsz_options[options_number]; + jstring* jstr_options = elements(options); + + for (jint i = 0; i < options_number; i++) { + ppsz_options[i] = (char *) malloc(JvGetStringUTFLength(jstr_options[i])); + setString(jstr_options[i], ppsz_options[i]); + } + } + + int res = VLC_AddTarget(this->id, (char const *)psz_target, (const char **) ppsz_options, options_number, insertMode, position); + + if (ppsz_options != NULL) { + for (int i = 0; i < options_number; i++) { + free(ppsz_options[i]); + } + free(ppsz_options); + } + if (psz_target != NULL) { + free(psz_target); + } + + + return res; +} + +jint org::videolan::jvlc::JVLC::play() { + return VLC_Play(this->id); +} + +jint org::videolan::jvlc::JVLC::pause() { + return VLC_Pause(this->id); +} + +jint org::videolan::jvlc::JVLC::stop() { + return VLC_Stop(this->id); +} + +jboolean org::videolan::jvlc::JVLC::isPlaying() { + return VLC_IsPlaying(this->id); +} + +jfloat org::videolan::jvlc::JVLC::getPosition() { + return VLC_PositionGet(this->id); +} + +jfloat org::videolan::jvlc::JVLC::setPosition(jfloat position) { + return VLC_PositionSet(this->id, position); +} + +jint org::videolan::jvlc::JVLC::getTime() { + return VLC_TimeGet(this->id); +} + +jint org::videolan::jvlc::JVLC::setTime(jint seconds, jboolean relative) { + return VLC_TimeSet(this->id, seconds, relative); +} + +jint org::videolan::jvlc::JVLC::getLength() { + return VLC_LengthGet(this->id); +} + +jfloat org::videolan::jvlc::JVLC::speedFaster() { + return VLC_SpeedFaster(this->id); +} + +jfloat org::videolan::jvlc::JVLC::speedSlower() { + return VLC_SpeedSlower(this->id); +} + +jint org::videolan::jvlc::JVLC::getPlaylistIndex() { + return VLC_PlaylistIndex(this->id); +} + +jint org::videolan::jvlc::JVLC::getPlaylistItems() { + return VLC_PlaylistNumberOfItems(this->id); +} + +jint org::videolan::jvlc::JVLC::playlistNext() { + return VLC_PlaylistNext(this->id); +} + +jint org::videolan::jvlc::JVLC::playlistPrev() { + return VLC_PlaylistPrev(this->id); +} + +jint org::videolan::jvlc::JVLC::playlistClear() { + return VLC_PlaylistClear(this->id); +} + +jint org::videolan::jvlc::JVLC::setVolume(jint volume) { + return VLC_VolumeSet(this->id, volume); +} + +jint org::videolan::jvlc::JVLC::getVolume() { + return VLC_VolumeGet(this->id); +} + +jint org::videolan::jvlc::JVLC::muteVolume() { + return VLC_VolumeMute(this->id); +} + +jint org::videolan::jvlc::JVLC::fullScreen() { + return VLC_FullScreen(this->id); +} + + +/* XXX: in progress */ +org::videolan::jvlc::JVLCVariable* org::videolan::jvlc::JVLC::getVariable(::java::lang::String* varName) { + + char* const psz_var = (char* const) elements( varName->toCharArray()); + vlc_value_t value; + if (VLC_VariableGet(this->id, psz_var, &value) != VLC_SUCCESS) { + // throw exception + return NULL; + } + return NULL; +} + +/* + * This is an helper function to convert jstrings to char*s + * setString _assumes_ the char* dest has been allocated + * XXX: should return >= 0 on success, < 0 on error + */ +void setString(jstring orig, char* dest) { + jsize chars = JvGetStringUTFRegion(orig, 0, orig->length(), dest); + // Note that dest is a buffer, not a C string. It is not null terminated. + dest[chars] = '\0'; +} diff --git a/bindings/java/vlc-glue-jni.cc b/bindings/java/vlc-glue-jni.cc new file mode 100644 index 0000000000..1bd60e35b0 --- /dev/null +++ b/bindings/java/vlc-glue-jni.cc @@ -0,0 +1,356 @@ +/***************************************************************************** + * JVLC.java: JNI interface for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2005 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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 +#include + +#include // for printf +#include // for calloc +#include // for strcmp + + +/* JVLC internal imports, generated by gcjh */ +#include "org_videolan_jvlc_JVLC.h" +#include "org_videolan_jvlc_JVLCVariable.h" +#include "org_videolan_jvlc_JVLCIntVariable.h" +#include "org_videolan_jvlc_JVLCBoolVariable.h" +#include "org_videolan_jvlc_JVLCFloatVariable.h" +#include "org_videolan_jvlc_JVLCStringVariable.h" +#include "org_videolan_jvlc_JVLCTimeVariable.h" +#include "org_videolan_jvlc_JVLCVarVariable.h" +#include "org_videolan_jvlc_JVLCVarValue.h" + +int getClassID (JNIEnv *env, jobject obj); + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_create (JNIEnv *env, jobject obj) { + return VLC_Create(); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_init (JNIEnv *env, jobject obj, jobjectArray args) { + + /* build the argv vector */ + const char **argv; + + /* count the arguments */ + // int argc = (int) (*env)->GetArrayLength(env, args) + int argc = (int) env->GetArrayLength((jarray) args); + + /* convert java strings to c strings + how many pointers do we need? */ + argv = (const char **) malloc(argc * sizeof(char*)); + + /* now fill the argv* */ + for (int i = 0; i < argc; i++) { + argv[i] = env->GetStringUTFChars((jstring) env->GetObjectArrayElement(args, i), + 0 + ); + } + + /* execute the library call */ + int res = VLC_Init(getClassID(env,obj), argc, (char **) argv); + + free(argv); + + return res; +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_addInterface (JNIEnv *env, jobject obj, jstring moduleName, jboolean blocking, jboolean startPlay) { + const char *psz_module = NULL; + int i_blocking, i_startPlay; + + if (moduleName != NULL) { + psz_module = env->GetStringUTFChars(moduleName, 0); + } + + if (blocking == true) i_blocking = 1; + else i_blocking = 0; + + if (startPlay == true) i_startPlay = 1; + else i_startPlay = 0; + + int addIntf_res = VLC_AddIntf(getClassID(env,obj), psz_module, i_blocking, i_startPlay); + + if (psz_module != NULL) { + env->ReleaseStringUTFChars(moduleName, psz_module); + } + return addIntf_res; +} + +JNIEXPORT jstring JNICALL Java_org_videolan_jvlc_JVLC_getVersion (JNIEnv *env, jobject obj) { + return env->NewStringUTF(VLC_Version()); +} + +JNIEXPORT jstring JNICALL Java_org_videolan_jvlc_JVLC_getError (JNIEnv *env, jobject obj, jint errorCode) { + return env->NewStringUTF(VLC_Error(errorCode)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_die (JNIEnv *env, jobject obj) { + return VLC_Die(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_cleanUp (JNIEnv *env, jobject obj) { + return VLC_CleanUp(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_setVariable (JNIEnv *env, jobject obj, jobject jvlcVariable) { + vlc_value_t value; + char* psz_var = NULL; + jstring varName; + jstring stringValue = NULL; + + if (jvlcVariable != NULL) { + /* get the name of jvlcVariable class */ + jclass variableClass = env->GetObjectClass(jvlcVariable); + jclass varSuperClass = env->GetSuperclass (variableClass); + jmethodID getNameMethod = env->GetMethodID (varSuperClass, "getName", "()Ljava/lang/String;"); + jstring varName = (jstring) env->CallObjectMethod (jvlcVariable, getNameMethod); + + /* i_int */ + jclass tmpClass = env->FindClass("org/videolan/jvlc/JVLCIntVariable"); + if (env->IsInstanceOf(jvlcVariable, tmpClass)) { + jmethodID mid = env->GetMethodID(variableClass, "getIntValue", "()I"); + value.i_int = env->CallIntMethod(jvlcVariable, mid); + goto done; + } + + /* b_bool */ + tmpClass = env->FindClass("org/videolan/jvlc/JVLCBoolVariable"); + if (env->IsInstanceOf(jvlcVariable, tmpClass )) { + jmethodID mid = env->GetMethodID(variableClass, "getBoolValue", "()Z"); + value.b_bool = env->CallBooleanMethod(jvlcVariable, mid); + goto done; + } + + /* f_float */ + tmpClass = env->FindClass("org/videolan/jvlc/JVLCFloatVariable"); + if (env->IsInstanceOf(jvlcVariable, tmpClass )) { + jmethodID mid = env->GetMethodID(variableClass, "getFloatValue", "()F"); + value.f_float = env->CallBooleanMethod(jvlcVariable, mid); + goto done; + } + + /* psz_string */ + tmpClass = env->FindClass("org/videolan/jvlc/JVLCStringVariable"); + if (env->IsInstanceOf(jvlcVariable, tmpClass )) { + jmethodID mid = env->GetMethodID(variableClass, "getStringValue", "()Ljava/lang/String"); + jstring stringValue = (jstring) env->CallObjectMethod(jvlcVariable, mid); + value.psz_string = (char *)env->GetStringUTFChars(stringValue, 0); + goto done; + } + + /* i_time */ + tmpClass = env->FindClass("org/videolan/jvlc/JVLCTimeVariable"); + if (env->IsInstanceOf(jvlcVariable, tmpClass )) { + jmethodID mid = env->GetMethodID(variableClass, "getTimeValue", "()L"); + value.i_time = env->CallLongMethod(jvlcVariable, mid); + goto done; + } + + /* var */ + tmpClass = env->FindClass("org/videolan/jvlc/JVLCVarVariable"); + if (env->IsInstanceOf(jvlcVariable, tmpClass )) { + /* + * This is the longer one. We have to get the VarValue object + * from the JVLCVarVariable and retrieve the OID from it. + */ + jmethodID getVarValueMID = env->GetMethodID(variableClass, "getVarValue", "()Lorg/videolan/jvlc/JVLCVarValue;"); + jobject varVariableObj = env->CallObjectMethod(jvlcVariable, getVarValueMID); + + /* + * Now from the varVariableObj we need to retrieve its name and OID + */ + + /* + * Get the VarValue name + */ + + jclass varVariableCls = env->GetObjectClass(varVariableObj); + jmethodID getVarName = env->GetMethodID(varVariableCls, "getName","()Ljava/lang/String;"); + jstring varName = (jstring) env->CallObjectMethod(varVariableObj, getVarName); + value.var.psz_name = (char *)env->GetStringUTFChars(varName, 0); + + /* + * Get the VarValue OID + */ + + jmethodID getOID = env->GetMethodID(varVariableCls, "getOID", "()I"); + value.var.i_object_id = env->CallIntMethod(varVariableObj, getOID); + + goto done; + } + + done: + psz_var = (char *) env->GetStringUTFChars(varName, 0); + } + + if (psz_var != NULL) { + int res = VLC_VariableSet(getClassID(env, obj), (char* const) psz_var, value); + env->ReleaseStringUTFChars(varName, psz_var); + if (stringValue != NULL) env->ReleaseStringUTFChars(stringValue, value.psz_string); + return res; + } + return -1; +} + + +JNIEXPORT jobject JNICALL Java_org_videolan_jvlc_JVLC_getVariable (JNIEnv *env, jobject obj, jstring varName) { + + const char* psz_var = env->GetStringUTFChars(varName, 0); + vlc_value_t value; + if (VLC_VariableGet(getClassID(env, obj), psz_var, &value) != VLC_SUCCESS) { + // throw exception + return NULL; + } + + + + return NULL; + +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_addTarget (JNIEnv *env, jobject obj, jstring URI, jobjectArray options, jint insertMode, jint position) { + + char* psz_target = NULL; + char** ppsz_options = NULL; + int options_number = 0; + + if (URI != NULL) { + psz_target = (char *) env->GetStringUTFChars(URI, 0); + } + + if (options != NULL) { + options_number = env->GetArrayLength(options); + ppsz_options = (char **) malloc (options_number * sizeof(char*)); + + for (int i = 0; i < options_number; i++) { + ppsz_options[i] = (char *) env->GetStringUTFChars((jstring) env->GetObjectArrayElement(options, i), 0); + } + } + + int res = VLC_AddTarget(getClassID(env, obj), (char const *)psz_target, (const char **) ppsz_options, options_number, insertMode, position); + + if (ppsz_options != NULL) { + for (int i = 0; i < options_number; i++) { + free(ppsz_options[i]); + } + free(ppsz_options); + } + if (psz_target != NULL) { + free(psz_target); + } + +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_play (JNIEnv *env, jobject obj) { + return VLC_Play(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_pause (JNIEnv *env, jobject obj) { + return VLC_Pause(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_stop (JNIEnv *env, jobject obj) { + return VLC_Stop(getClassID(env, obj)); +} + +JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_JVLC_isPlaying (JNIEnv *env, jobject obj) { + return VLC_IsPlaying(getClassID(env, obj)); +} + +JNIEXPORT jfloat JNICALL Java_org_videolan_jvlc_JVLC_getPosition (JNIEnv *env, jobject obj) { + return VLC_PositionGet(getClassID(env, obj)); +} + +JNIEXPORT jfloat JNICALL Java_org_videolan_jvlc_JVLC_setPosition (JNIEnv *env, jobject obj, jfloat position) { + return VLC_PositionSet(getClassID(env, obj), position); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_getTime (JNIEnv *env, jobject obj) { + return VLC_TimeGet(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_setTime (JNIEnv *env, jobject obj, jint seconds, jboolean relative) { + return VLC_TimeSet(getClassID(env, obj), seconds, relative); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_getLength (JNIEnv *env, jobject obj) { + return VLC_LengthGet(getClassID(env, obj)); +} + +JNIEXPORT jfloat JNICALL Java_org_videolan_jvlc_JVLC_speedFaster (JNIEnv *env, jobject obj) { + return VLC_SpeedFaster(getClassID(env, obj)); +} + +JNIEXPORT jfloat JNICALL Java_org_videolan_jvlc_JVLC_speedSlower (JNIEnv *env, jobject obj) { + return VLC_SpeedSlower(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_getPlaylistIndex (JNIEnv *env, jobject obj) { + return VLC_PlaylistIndex(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_getPlaylistItems (JNIEnv *env, jobject obj) { + return VLC_PlaylistNumberOfItems(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_playlistNext (JNIEnv *env, jobject obj) { + return VLC_PlaylistNext(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_playlistPrev (JNIEnv *env, jobject obj) { + return VLC_PlaylistPrev(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_playlistClear (JNIEnv *env, jobject obj) { + return VLC_PlaylistClear(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_getVolume (JNIEnv *env, jobject obj) { + return VLC_VolumeGet(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_setVolume (JNIEnv *env, jobject obj, jint volume) { + return VLC_VolumeSet(getClassID(env, obj), volume); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_muteVolume (JNIEnv *env, jobject obj) { + return VLC_VolumeMute(getClassID(env, obj)); +} + +JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_fullScreen (JNIEnv *env, jobject obj) { + return VLC_FullScreen(getClassID(env, obj)); +} + +/* + * This method is an helper method + * only valid if obj == JVLC + */ + +int getClassID (JNIEnv *env, jobject obj) { + /* get the id field of object */ + jclass cls = env->GetObjectClass(obj); + jmethodID mid = env->GetMethodID(cls, "getID", "()I"); + int field = env->CallIntMethod(obj, mid); + return field; +} + diff --git a/bindings/java/vlc-graphics-jni.cc b/bindings/java/vlc-graphics-jni.cc new file mode 100644 index 0000000000..081c0b50e5 --- /dev/null +++ b/bindings/java/vlc-graphics-jni.cc @@ -0,0 +1,103 @@ +/***************************************************************************** + * JVLC.java: JNI interface for vlc Java Bindings + ***************************************************************************** + * Copyright (C) 1998-2005 the VideoLAN team + * + * Authors: Filippo Carone + * + * 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 +#include +#include +#include + +#include // for Xlibs graphics functions + +/* JVLC internal imports, generated by gcjh */ +#include "org_videolan_jvlc_JVLCCanvas.h" + +/* + * This will only work on X11 at the moment + */ + +JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, jobject canvas, jobject graphics) { + + JAWT awt; + JAWT_DrawingSurface* ds; + JAWT_DrawingSurfaceInfo* dsi; + JAWT_X11DrawingSurfaceInfo* dsi_x11; + jboolean result; + jint lock; + GC gc; + + vlc_value_t value; + short i; + + /* Get the AWT */ + awt.version = JAWT_VERSION_1_3; + 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; + } + + /* 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); + + value.i_int = dsi_x11->drawable; + VLC_VariableSet( 0, "drawable", value ); + + XFreeGC(dsi_x11->display, gc); + + /* Free the drawing surface info */ + ds->FreeDrawingSurfaceInfo(dsi); + + /* Unlock the drawing surface */ + ds->Unlock(ds); + + /* Free the drawing surface */ + awt.FreeDrawingSurface(ds); +} diff --git a/configure.ac b/configure.ac index b6293f7d84..fbdd1f8971 100644 --- a/configure.ac +++ b/configure.ac @@ -4823,6 +4823,17 @@ then build_pic=yes fi +dnl +dnl Java bindings +dnl +AC_ARG_ENABLE(java-bindings, + [ --enable-java-bindings Enable Java bindings (default disabled)]) +AM_CONDITIONAL( BUILD_JAVA, [test "${enable_java_bindings}" = "yes"] ) +if test "${enable_java_bindings}" = "yes" +then + build_pic=yes +fi + dnl dnl test plugins @@ -5033,6 +5044,7 @@ AC_CONFIG_FILES([ activex/Makefile activex/axvlc.inf bindings/Makefile + bindings/java/Makefile bindings/python/Makefile debian/Makefile doc/Makefile -- 2.39.2