Commit bc14424e authored by Filippo Carone's avatar Filippo Carone

Java bindings updated to latest jvlc version.

SWT components removed until we are able to configure and check for swt-*.jar
presence.

parent 88b0a696
= Frequently Asked Questions =
== 1. Is it possible to use JVLC in a Java Applet? ==
Yes and No.
Yes because it's a Java program and even if it contains
native code, it is still possible to deploy the applet (take a look at
[http://www.raditha.com/java/jni/ this] article).
No because native code for the Windows and MacOS platforms still needs
to be written.
== 2. Is it possible to use JVLC in Windows (or MacOS)? ==
It's not possible at the moment. JVLC is composed of two parts, a Java
multiplatform part and a C++ native code part. The native code has only
been tested on GNU/Linux platforms, but I'm looking forward to porting
it to Win32 and Darwin platforms.
== 3. What features of Videolan are available to JVLC? ==
JVLC contains all the features available in Videolan. In fact, JVLC uses
Videolan core as its core, so JVLC is capable of everything Videolan can
do.
== 4. Why shouldn't I use JMF (Java Media Framework) for multimedia
applications? ==
Well, JVLC and Videolan are free (as in freedom) software, so you can extend
and adapt them to your needs, while JMF is free as in beer. Furthermore JVLC
is really straightforward and simple to use.
== 5. How can I help you with this application? ==
Try the software and report any errors or bugs you find to me. This application
needs porting to MS/Windows and MacOS, if you are able to implement the JNI for
these platform you may contribute the code.
\ No newline at end of file
......@@ -4,7 +4,7 @@
if BUILD_JAVA
OBJECTS = org/videolan/jvlc/JVLCCanvas.class org/videolan/jvlc/JVLCPanel.class org/videolan/jvlc/AudioIntf.class org/videolan/jvlc/InputIntf.class org/videolan/jvlc/PlaylistIntf.class org/videolan/jvlc/VideoIntf.class org/videolan/jvlc/VLMIntf.class org/videolan/jvlc/Playlist.class org/videolan/jvlc/JLibVLC.class org/videolan/jvlc/JVLC.class org/videolan/jvlc/SWTVideoWidget.class
OBJECTS = org/videolan/jvlc/AudioIntf.class org/videolan/jvlc/InputIntf.class org/videolan/jvlc/PlaylistIntf.class org/videolan/jvlc/VideoIntf.class org/videolan/jvlc/JLibVLC.class org/videolan/jvlc/JVLC.class org/videolan/jvlc/JVLCCanvas.class org/videolan/jvlc/JVLCPanel.class org/videolan/jvlc/VLMIntf.class org/videolan/jvlc/Playlist.class
JNIHEADERS = org_videolan_jvlc_JVLC.h org_videolan_jvlc_JVLCCanvas.h org_videolan_jvlc_JVLCPanel.h
......@@ -16,7 +16,7 @@ SWT_PATH = /usr/share/java
# Binaries
JCC = gcj -g -I${SWT_PATH}/swt-gtk.jar
JCC = gcj -g
JCH = gcjh -jni
# Compile flags
......
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
*
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
import java.awt.Dialog;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;
import org.videolan.jvlc.*;
public class SWTUglyPlayer {
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="230,12"
private Canvas canvas = null;
private SWTVideoWidget vlc = null;
private Button button = null;
private Text text = null;
private Button button1 = null;
private Button button2 = null;
private Display display = new Display();
/**
* This method initializes sShell
*/
private void createSShell() {
sShell = new Shell(display);
sShell.setText("Shell");
createCanvas();
sShell.setSize(new org.eclipse.swt.graphics.Point(339,303));
button = new Button(sShell, SWT.NONE);
button.setText("Play");
button.setSize(new org.eclipse.swt.graphics.Point(70,30));
button.setLocation(new org.eclipse.swt.graphics.Point(26,185));
button.addMouseListener(new org.eclipse.swt.events.MouseAdapter() {
public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
vlc.getJVLC().playlist.add(text.getText(), text.getText());
vlc.getJVLC().playlist.play(-1, null);
}
});
text = new Text(sShell, SWT.BORDER);
text.setBounds(new org.eclipse.swt.graphics.Rectangle(26,222,200,25));
text.setText("~/a.avi");
button1 = new Button(sShell, SWT.NONE);
button1.setLocation(new org.eclipse.swt.graphics.Point(120,186));
button1.setText("Pause");
button1.setSize(new org.eclipse.swt.graphics.Point(70,30));
button1.addMouseListener(new org.eclipse.swt.events.MouseAdapter() {
public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
vlc.getJVLC().playlist.pause();
}
});
button2 = new Button(sShell, SWT.NONE);
button2.setText("Stop");
button2.setSize(new org.eclipse.swt.graphics.Point(70,30));
button2.setLocation(new org.eclipse.swt.graphics.Point(221,188));
button2.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
vlc.getJVLC().playlist.stop();
}
});
}
/**
* This method initializes canvas
*
*/
private void createCanvas() {
canvas = new Canvas(sShell, SWT.EMBEDDED);
canvas.setBounds(new org.eclipse.swt.graphics.Rectangle(22,15,248,145));
vlc = new SWTVideoWidget( canvas );
}
public Canvas getCanvas() {
return canvas;
}
public SWTUglyPlayer( ) {
createSShell();
sShell.open();
while( !sShell.isDisposed())
{
if(!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
static public void main( String[] args ) {
SWTUglyPlayer swt = new SWTUglyPlayer();
}
}
/*****************************************************************************
* AudioIntf.java: Audio methods interface
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-2006
*
* $Id$
*
*
* 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
* 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 {
void getMute();
void setMute();
void getVolume();
void setVolume();
boolean getMute();
void setMute(boolean value);
void toggleMute();
int getVolume();
void setVolume(int volume);
}
/*****************************************************************************
* InputIntf.java: Input interface
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-2006
*
* $Id$
*
* 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
* 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 InputIntf {
void getLength();
void getTime();
void getPosition();
void setTime();
double getFPS();
/**
* This function returns the total length of the current file playing
* in millis.
*/
long getInputLength();
/**
* This function returns the current position in millis within the
* currently playing playlist item.
*/
long getInputTime();
void getInputPosition();
void setInputTime();
double getInputFPS();
}
/*****************************************************************************
* JLibVLC.java: Main library interface
* JLibVLC.java: Main library interface
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-2006
*
* $Id$
*
* 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
* 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;
......
......@@ -25,9 +25,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*
*/
/**
* @author Filippo Carone <filippo@carone.org>
*/
package org.videolan.jvlc;
......@@ -65,6 +63,13 @@ public class JVLC implements JLibVLC {
private native void _toggleMute();
private native int _getVolume();
private native void _setVolume( int volume );
/*
* Input native methods
*/
private native long _getInputLength();
private native long _getInputTime();
/*
* Video native methods
......@@ -75,7 +80,6 @@ public class JVLC implements JLibVLC {
public boolean getMute() {
// TODO Auto-generated method stub
return _getMute();
}
......@@ -111,27 +115,25 @@ public class JVLC implements JLibVLC {
return _getFullscreen();
}
public void getLength() {
// TODO Auto-generated method stub
public long getInputLength() {
return _getInputLength();
}
public void getTime() {
// TODO Auto-generated method stub
public long getInputTime() {
return _getInputTime();
}
public void getPosition() {
public void getInputPosition() {
// TODO Auto-generated method stub
}
public void setTime() {
public void setInputTime() {
// TODO Auto-generated method stub
}
public double getFPS() {
public double getInputFPS() {
// TODO Auto-generated method stub
return 0;
}
......
/*****************************************************************************
* JVLCCanvas.java: AWT Canvas containing VLC Video Output
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* $Id$
*
* 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.
* Created on 25-nov-2005
*
* 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
* $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;
......@@ -31,12 +35,13 @@ public class JVLCCanvas extends Canvas {
public native void paint(Graphics g);
private final JVLC jvlc = new JVLC();
private final JVLC jvlc;
/**
* Default constructor. The canvas is set a dimension of 200x200
*/
public JVLCCanvas() {
jvlc = new JVLC();
setSize(200, 200);
}
......@@ -45,9 +50,13 @@ public class JVLCCanvas extends Canvas {
* @param height The initial canvas height
*/
public JVLCCanvas(int width, int height) {
jvlc = new JVLC();
setSize(width, height);
}
public JVLCCanvas(JVLC jvlc) {
this.jvlc = jvlc;
}
public JVLC getJVLC() {
return jvlc;
......
/*****************************************************************************
* JVLCPanel.java: Java Swing JPanel embedding VLC Video Output
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-nov-2005
*
* $Id$
*
* 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
*
* 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;
......
/*****************************************************************************
* Playlist.java: The playlist class
* PlaylistIntf.java: The playlist interface
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
*
* $Id$
*
* Authors: Filippo Carone <filippo@carone.org>
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: 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.
* Created on 28-feb-2006
*
* 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.
* $Id$
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* 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;
......@@ -33,21 +38,27 @@ public class Playlist implements PlaylistIntf {
this.libvlcInstance = _libvlcInstance;
}
native private int _playlist_add(String uri, String name);
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 _isPlaying();
public void play(int id, String[] options) {
_play(id, options);
}
public void play() {
play(-1, null);
}
public void pause() {
_pause();
......@@ -59,7 +70,7 @@ public class Playlist implements PlaylistIntf {
}
public boolean isPlaying() {
return (_isPlaying() == 1)? false : true ;
return (_isPlaying() == 0)? false : true ;
}
public int itemsCount() {
......@@ -67,6 +78,8 @@ public class Playlist implements PlaylistIntf {
}
public void next() {
if (! isPlaying())
play();
_next();
}
......@@ -75,17 +88,26 @@ public class Playlist implements PlaylistIntf {
}
public void clear() {
if (! isPlaying())
play();
_clear();
}
public int add(String uri, String name, String[] options) {
return _playlist_add(uri, name, options);
}
public int add(String uri, String name) {
return _playlist_add(uri, name);
return add(uri, name, null);
}
public void addExtended() {
// TODO Auto-generated method stub
}
public void deleteItem(int itemID) {
_deleteItem(itemID);
}
public long getInstance() {
return libvlcInstance;
}
......
/*****************************************************************************
* PlaylistIntf.java: The playlist interface
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
*
* $Id$
*
* Authors: Filippo Carone <filippo@carone.org>
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: 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.
* Created on 28-feb-2006
*
* 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.
* $Id$
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* 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;
......
/*****************************************************************************
* SWTVideoWidget.java: A component usable in SWT Application, embeds JVLC
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
*
* $Id$
*
* 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