Commit ca250026 authored by Filippo Carone's avatar Filippo Carone

Backport java bindings

parent e53d8f51
...@@ -2,47 +2,92 @@ ...@@ -2,47 +2,92 @@
# VLC Java Bindings # VLC Java Bindings
####################################################################### #######################################################################
if BUILD_JAVA #SUBDIRS= src
DIST_SUBDIRS = src
EXTRA_DIST= \
FAQ \
TODO \
README \
THANKS \
javadoc.xml \
VlcClient.java \
VLCExample.java
EXTRA_DIST+= \
org/videolan/jvlc/AudioIntf.java \
org/videolan/jvlc/Audio.java \
org/videolan/jvlc/GenericVideoWidget.java \
org/videolan/jvlc/InputIntf.java \
org/videolan/jvlc/Input.java \
org/videolan/jvlc/JLibVLC.java \
org/videolan/jvlc/JVLCCanvas.java \
org/videolan/jvlc/JVLC.java \
org/videolan/jvlc/JVLCPanel.java \
org/videolan/jvlc/PlaylistIntf.java \
org/videolan/jvlc/Playlist.java \
org/videolan/jvlc/VideoIntf.java \
org/videolan/jvlc/Video.java \
org/videolan/jvlc/VLCException.java \
org/videolan/jvlc/VLMIntf.java \
org/videolan/jvlc/VLM.java
OBJECTS = org/videolan/jvlc/VLCException.class org/videolan/jvlc/Playlist.class org/videolan/jvlc/AudioIntf.class org/videolan/jvlc/Audio.class org/videolan/jvlc/InputIntf.class org/videolan/jvlc/Input.class org/videolan/jvlc/PlaylistIntf.class org/videolan/jvlc/VideoIntf.class org/videolan/jvlc/Video.class org/videolan/jvlc/JLibVLC.class org/videolan/jvlc/JVLC.class org/videolan/jvlc/JVLCCanvas.class org/videolan/jvlc/JVLCPanel.class org/videolan/jvlc/VLMIntf.class org/videolan/jvlc/VLM.class org/videolan/jvlc/GenericVideoWidget.class
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
JNIHEADERS = org_videolan_jvlc_JVLC.h org_videolan_jvlc_JVLCCanvas.h org_videolan_jvlc_JVLCPanel.h COBJECTS = src/utils.o src/video-jni.o src/audio-jni.o src/input-jni.o src/playlist-jni.o src/vlm-jni.o src/core-jni.o src/graphics-jni.o
if BUILD_JAVA
# Include some JAVA stuff # Include some JAVA stuff
PROCESSOR_FAMILY = `uname -m | sed -e 's/^i.86/i386/' | sed -e 's/^x86_64/amd64/'` PROCESSOR_FAMILY = `uname -m | sed -e 's/^i.86/i386/' | sed -e 's/^x86_64/amd64/'`
if HAVE_WIN32
JINCLUDES = -I${JAVA_HOME}/include -I${JAVA_HOME}/include/win32
LIBJINCLUDES = -L${JAVA_HOME}/lib -ljawt
JCH = javah
JAVACXXFLAGS = `top_builddir=../.. ../../vlc-config --cflags pic` -I../../ -I ../../include $(JINCLUDES)
JAVALDFLAGS = -mno-cygwin -L../../src -lvlc `top_builddir=../.. ../../vlc-config --libs builtin vlc pic` -Wl,--kill-at
else
JINCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux JINCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
LIBJINCLUDES = -L$(JAVA_HOME)/jre/lib/$(PROCESSOR_FAMILY) -ljawt LIBJINCLUDES = -L$(JAVA_HOME)/jre/lib/$(PROCESSOR_FAMILY) -ljawt
SWT_PATH = /usr/share/java
# Binaries
JCC = gcj -g -I${SWT_PATH}/swt-gtk.jar
JCH = gcjh -jni JCH = gcjh -jni
# Compile flags
JAVACXXFLAGS = `top_builddir=../.. ../../vlc-config --cflags pic` -I../../ -I ../../include $(JINCLUDES) JAVACXXFLAGS = `top_builddir=../.. ../../vlc-config --cflags pic` -I../../ -I ../../include $(JINCLUDES)
JAVALDFLAGS = -L../../lib -lvlc_pic `top_builddir=../.. ../../vlc-config --libs builtin vlc pic` JAVALDFLAGS = -L../../src -lvlc `top_builddir=../.. ../../vlc-config --libs builtin vlc pic`
endif
# Build targets
all: libjvlc.so VlcClient
libjvlc.so: vlc-libvlc-jni.o vlc-graphics-jni.o export JINCLUDES
$(CXX) -shared vlc-libvlc-jni.o vlc-graphics-jni.o $(LIBJINCLUDES) $(LDFLAGS) $(JAVALDFLAGS) -o libjvlc.so
vlc-graphics-jni.o: VlcClient # Build targets
$(CXX) -c vlc-graphics-jni.cc $(CXXFLAGS) $(JAVACXXFLAGS) all: libjvlc.so VlcClient VLCExample
vlc-libvlc-jni.o: VlcClient if HAVE_WIN32
$(CXX) -c vlc-libvlc-jni.cc $(CXXFLAGS) $(JAVACXXFLAGS) libjvlc.so: $(OBJECTS)
$(MAKE) -C src
$(CXX) -shared $(COBJECTS) $(LIBJINCLUDES) $(LDFLAGS) $(JAVALDFLAGS) -o jvlc.dll
else
libjvlc.so: $(OBJECTS)
$(MAKE) -C src
$(CXX) -shared $(COBJECTS) $(LIBJINCLUDES) $(LDFLAGS) $(JAVALDFLAGS) -o libjvlc.so
endif
VlcClient: $(OBJECTS) VlcClient: $(OBJECTS)
$(JCC) -C VlcClient.java $(JAVAC) VlcClient.java
VLCExample: $(OBJECTS)
$(JAVAC) VLCExample.java
if HAVE_WIN32
%.class: %.java
$(JAVAC) $?
$(JCH) org.videolan.jvlc.$(*F)
else
%.class: %.java %.class: %.java
$(JCC) -C $? $(JAVAC) $?
$(JCH) org/videolan/jvlc/$(*F) $(JCH) $(@D)/$(*F) -o includes/$(*F).h
endif
clean: clean-local:
rm -f *.class *~ org/videolan/jvlc/*.class org_videolan*.h *.so *.o rm -f *.class *~ org/videolan/jvlc/*.class org_videolan*.h includes/*.h src/*.o *.so *.o *.dll
endif endif
/*****************************************************************************
* 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();
}
}
/*****************************************************************************
* VlcClient.java: Sample Swing player
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
*
* Created on 28-feb-2006
*
* $Id: AudioIntf.java 8 2006-02-28 12:03:47Z little $
*
* 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.
*
*/
import java.awt.Frame; import java.awt.Frame;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import org.videolan.jvlc.JVLCPanel; import org.videolan.jvlc.JVLCPanel;
import org.videolan.jvlc.JVLC; import org.videolan.jvlc.JVLC;
import org.videolan.jvlc.VLCException;
class VLCPlayerFrame extends Frame { class VLCPlayerFrame extends Frame {
public VLCPlayerFrame() { public VLCPlayerFrame() {
...@@ -109,15 +135,20 @@ class VLCPlayerFrame extends Frame { ...@@ -109,15 +135,20 @@ class VLCPlayerFrame extends Frame {
private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) { private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) {
try { try {
//System.out.println(mci.getMediaPosition(PositionOrigin.ABSOLUTE, PositionKey.BYTECOUNT)); //System.out.println(mci.getMediaPosition(PositionOrigin.ABSOLUTE, PositionKey.BYTECOUNT));
jvlc.playlist.pause(); jvlc.playlist.togglePause();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private void setButtonActionPerformed(java.awt.event.ActionEvent evt) { private void setButtonActionPerformed(java.awt.event.ActionEvent evt) {
jvlc.playlist.add("file:///home/little/a.avi", "a.avi"); try {
jvlc.playlist.play(-1, null); jvlc.playlist.add("file:///home/little/a.avi", "a.avi");
jvlc.playlist.play(-1, null);
} catch (VLCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
private void fullScreenButtonActionPerformed(java.awt.event.ActionEvent evt) { private void fullScreenButtonActionPerformed(java.awt.event.ActionEvent evt) {
......
package org.videolan.jvlc;
public class Audio implements AudioIntf {
private long libvlcInstance;
private native boolean _getMute();
private native void _setMute( boolean value );
private native void _toggleMute();
private native int _getVolume();
private native void _setVolume( int volume );
public Audio( long instance ) {
this.libvlcInstance = instance;
}
public boolean getMute() throws VLCException {
return _getMute();
}
public void setMute(boolean value) throws VLCException {
_setMute( value );
}
public void toggleMute() throws VLCException {
_toggleMute();
}
public int getVolume() throws VLCException {
return _getVolume();
}
public void setVolume(int volume) throws VLCException {
_setVolume( volume );
}
public long getInstance() {
return libvlcInstance;
}
}
/***************************************************************************** /*****************************************************************************
* AudioIntf.java: Audio methods interface * AudioIntf.java: Audio methods interface
***************************************************************************** *****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team * Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
* *
* Created on 28-feb-2006
*
* $Id$ * $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
* This program is free software; you can redistribute it and/or modify * as published by the Free Software Foundation; either version 2 of the
* it under the terms of the GNU General Public License as published by * License, or (at your option) any later version.
* 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
* This program is distributed in the hope that it will be useful, * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* but WITHOUT ANY WARRANTY; without even the implied warranty of * General Public License for more details.
* 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
* 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. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *
*/
package org.videolan.jvlc; package org.videolan.jvlc;
public interface AudioIntf { public interface AudioIntf {
void getMute(); /**
void setMute(); * @return True if input is currently muted.
void getVolume(); * @throws VLCException
void setVolume(); */
boolean getMute() throws VLCException;
/**
* @param value If true, then the input is muted.
* @throws VLCException
*/
void setMute(boolean value) throws VLCException;
/**
* Toggles mute
* @throws VLCException
*/
void toggleMute() throws VLCException;
/**
* @return The volume level
* @throws VLCException
*/
int getVolume() throws VLCException;
/**
* @param volume The volume level (0-200) to set.
* @throws VLCException
*/
void setVolume(int volume) throws VLCException;
} }
/***************************************************************************** /*****************************************************************************
* SWTVideoWidget.java: A component usable in SWT Application, embeds 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 * Copyright (C) 1998-2006 the VideoLAN team
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * Author: Kuldipsingh Pabla <Kuldipsingh.Pabla@sun.com>
* (at your option) any later version. *
* Created on 10-jun-2006
* *
* This program is distributed in the hope that it will be useful, * $Id $
* 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 * This program is free software; you can redistribute it
* along with this program; if not, write to the Free Software * 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. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *
*/
package org.videolan.jvlc;
import org.eclipse.swt.awt.SWT_AWT; package org.videolan.jvlc;
import org.eclipse.swt.widgets.Composite;
import java.awt.Frame; import java.awt.Frame;
import java.awt.Component;
public class SWTVideoWidget { public class GenericVideoWidget {
/* /*
* This class implements an SWTCanvas containing VLC Video Output * This class implements a Composite container for VLC Video Output
*/ */
/* /*
...@@ -41,13 +43,9 @@ public class SWTVideoWidget { ...@@ -41,13 +43,9 @@ public class SWTVideoWidget {
public Frame rootFrame; public Frame rootFrame;
private JVLCCanvas jvlcCanvas; private JVLCCanvas jvlcCanvas;
/* public GenericVideoWidget( Component parent ) {
* This class 'installs' the VLC video output window
* in a Composite container such as a canvas.
*/
public SWTVideoWidget( Composite parent ) {
// allocate the new AWT Frame to embed in the Composite // allocate the new AWT Frame to embed in the Composite
rootFrame = SWT_AWT.new_Frame( parent ); rootFrame = new Frame ();
// add the JVLCCanvas to the Frame // add the JVLCCanvas to the Frame
jvlcCanvas = new JVLCCanvas(); jvlcCanvas = new JVLCCanvas();
......
package org.videolan.jvlc;
public class Input implements InputIntf {
private long libvlcInstance;
/*
* Input native methods
*/
private native long _getLength();
private native float _getPosition();
private native long _getTime();
private native float _getFPS();
private native void _setTime(long value);
private native void _setPosition(float value);
private native boolean _isPlaying();
private native boolean _hasVout();
public Input( long instance ) {
this.libvlcInstance = instance;
}
public long getLength() throws VLCException {
return _getLength();
}
public long getTime() throws VLCException {
return _getTime();
}
public float getPosition() throws VLCException {
return _getPosition();
}
public void setTime(long time) throws VLCException {
_setTime(time);
}
public void setPosition(float position) throws VLCException {
_setPosition(position);
}
public double getFPS() throws VLCException {
return _getFPS();
}
public boolean isPlaying() throws VLCException {
return _isPlaying();
}
public boolean hasVout() throws VLCException {
return _hasVout();
}
public long getInstance() {
return libvlcInstance;
}
}
/***************************************************************************** /*****************************************************************************
* InputIntf.java: Input interface * InputIntf.java: Input interface
***************************************************************************** *****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team * Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-2006
* *
* $Id$ * $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
* This program is free software; you can redistribute it and/or modify * as published by the Free Software Foundation; either version 2 of the
* it under the terms of the GNU General Public License as published by * License, or (at your option) any later version.
* 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
* This program is distributed in the hope that it will be useful, * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* but WITHOUT ANY WARRANTY; without even the implied warranty of * General Public License for more details.
* 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
* 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. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *
*/
package org.videolan.jvlc; package org.videolan.jvlc;
/**
* @author little
*
*/
public interface InputIntf { public interface InputIntf {
void getLength();
void getTime();
void getPosition();
void setTime();
double getFPS();
/**
* @return The total length of the current file playing in millis.
* @throws VLCException
*/
long getLength() throws VLCException;
/**
* @return The current position in millis within the playing item.
* @throws VLCException
*/
long getTime() throws VLCException;
/**
* @return The position in %.
* @throws VLCException
*/
float getPosition() throws VLCException;
/**
* Moves current input to position specified in a float [0-1].
* @param value The position, from 0 to 1, to move the input to.
* @throws VLCException
*/
void setPosition( float value ) throws VLCException;
/**
* Moves current input to time specified in value
* @param value The time in milliseconds to move the input to.
* @throws VLCException
*/
void setTime(long value) throws VLCException;
/**
* @return If the playing item is a video file, returns the FPS, otherwise 0.
* @throws VLCException
*/
double getFPS() throws VLCException;
/**
* @return True if the current input is really playing
*/
boolean isPlaying() throws VLCException;
/**
* @return True if the current input has spawned a video output window
*/
boolean hasVout() throws VLCException;
} }
/***************************************************************************** /*****************************************************************************
* JLibVLC.java: Main library interface * JLibVLC.java: Main library interface
***************************************************************************** *****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team * Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-2006
* *
* $Id$ * $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
* This program is free software; you can redistribute it and/or modify * as published by the Free Software Foundation; either version 2 of the
* it under the terms of the GNU General Public License as published by * License, or (at your option) any later version.
* 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
* This program is distributed in the hope that it will be useful, * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* but WITHOUT ANY WARRANTY; without even the implied warranty of * General Public License for more details.
* 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
* 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. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *
*/
package org.videolan.jvlc; package org.videolan.jvlc;
public interface JLibVLC extends AudioIntf, VideoIntf, InputIntf { } public interface JLibVLC extends AudioIntf, VideoIntf, InputIntf, VLMIntf { }
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
* Copyright (C) 1998-2006 the VideoLAN team * Copyright (C) 1998-2006 the VideoLAN team
* *
* Author: Filippo Carone <filippo@carone.org> * Author: Filippo Carone <filippo@carone.org>
* * Philippe Morin <phmorin@free.fr>
*
* Created on 28-feb-2006 * Created on 28-feb-2006
* *
* $Id$ * $Id$
...@@ -25,126 +26,146 @@ ...@@ -25,126 +26,146 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* *
*/ */
/**
* @author Filippo Carone <filippo@carone.org>
*/
package org.videolan.jvlc; package org.videolan.jvlc;
public class JVLC implements JLibVLC {
public class JVLC implements Runnable {
static { static {
System.load(System.getProperty( "user.dir" ) + "/libjvlc.so" ); System.loadLibrary("jvlc" );
} }
/**
private long _instance; * These are set as final since they live along the jvlc object
public Playlist playlist;
public JVLC() {
_instance = createInstance();
playlist = new Playlist( _instance );
}
public JVLC(String[] args) {
_instance = createInstance( args );
playlist = new Playlist( _instance );
}
/*
* Core methods
*/ */
private native long createInstance(); private final long _instance;
private native long createInstance( String[] args );
/* public final Playlist playlist;
* Audio native methods public final Video video;
*/ public final Audio audio;
private native boolean _getMute(); public final Input input;
private native void _setMute( boolean value ); public final VLM vlm;
private native void _toggleMute();
private native int _getVolume();
private native void _setVolume( int volume );
/* private boolean beingDestroyed = false;
* Video native methods
/**
* This is the time in millis VLC checks for internal status
*/ */
private native void _toggleFullscreen(); private long resolution = 50;
private native void _setFullscreen( boolean value);
private native boolean _getFullscreen();
public boolean getMute() { private boolean inputPlaying = false;
// TODO Auto-generated method stub private boolean inputVout = false;
return _getMute();
}
public void setMute(boolean value) {
_setMute( value );
}
public void toggleMute() { public JVLC() {
_toggleMute(); String[] args = new String[1];
} args[0] = "jvlc";
public int getVolume() {
return _getVolume();
}
public void setVolume(int volume) {
_setVolume( volume );
}
public void toggleFullscreen() {
_toggleFullscreen();
}
public void setFullscreen( boolean value ) {
_setFullscreen( value );
}
public boolean getFullscreen() {
return _getFullscreen();
}
public void getLength() {
// TODO Auto-generated method stub
}
public void getTime() {
// TODO Auto-generated method stub
_instance = createInstance( args );
playlist = new Playlist ( _instance );
video = new Video ( _instance );
audio = new Audio ( _instance );
input = new Input ( _instance );
vlm = new VLM ( _instance );
new Thread(this).start();
} }
public void getPosition() { public JVLC(String[] args) {
// TODO Auto-generated method stub _instance = createInstance( args );
playlist = new Playlist ( _instance );
video = new Video ( _instance );
audio = new Audio ( _instance );
input = new Input ( _instance );
vlm = new VLM ( _instance );
new Thread(this).start();
} }
public void setTime() {
// TODO Auto-generated method stub /**
* Destroys the current instance of jvlc, cleaning up objects.
* This is unreversible.
*/
public void destroy() {
beingDestroyed = true;
_destroy();
} }
public double getFPS() { /*
// TODO Auto-generated method stub * Core methods
return 0; */
} private native long createInstance( String[] args );
private native void _destroy();
public long getInstance() { public long getInstance() throws VLCException {
return _instance; return _instance;
} }
/* /*
* Getters and setters * Getters and setters
*/ */
public Playlist getPlaylist() { public Playlist getPlaylist() throws VLCException {
return playlist; return playlist;
} }
/**
* Checks if the input is playing.
* @return True if there is a playing input.
*/
public boolean isInputPlaying() {
return inputPlaying;
}
/**
* Checks if the input has spawned a video window.
* @return True if there is a video window.
*/
public boolean hasVout() {
return inputVout;
}
/*
* (non-Javadoc)
* @see java.lang.Runnable#run()
*
* In this thread we check the playlist and input status.
*/
public void run() {
while (! beingDestroyed) {
try {
while (playlist.isRunning()) {
if (input.isPlaying()) {
inputPlaying = true;
}
else {
inputPlaying = false;
}
if (input.hasVout()) {
inputVout = true;
}
else {
inputVout = false;
}
try {
Thread.sleep(resolution);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} catch (VLCException e1) { } // while playlist running
inputPlaying = false;
inputVout = false;
try {
Thread.sleep(resolution);
} catch (InterruptedException e) {
e.printStackTrace();
} // try
} // while ! being destroyed
} // run
} }
/***************************************************************************** /*****************************************************************************
* JVLCCanvas.java: AWT Canvas containing VLC Video Output * JVLCCanvas.java: AWT Canvas containing VLC Video Output
***************************************************************************** *****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team * Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
* *
* $Id$ * Created on 25-nov-2005
*
* 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, * $Id$
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * This program is free software; you can redistribute it
* GNU General Public License for more details. * 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
* You should have received a copy of the GNU General Public License * License, or (at your option) any later version.
* along with this program; if not, write to the Free Software *
* 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. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *
*/
package org.videolan.jvlc; package org.videolan.jvlc;
...@@ -31,23 +35,38 @@ public class JVLCCanvas extends Canvas { ...@@ -31,23 +35,38 @@ public class JVLCCanvas extends Canvas {
public native void paint(Graphics g); 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 * Default constructor. The canvas is set a dimension of 200x200
*/ */
public JVLCCanvas() { public JVLCCanvas() {
jvlc = new JVLC();
setSize(200, 200); setSize(200, 200);
} }
public JVLCCanvas(String[] args) {
jvlc = new JVLC(args);
setSize(200, 200);
}
/** /**
* @param width The initial canvas width * @param width The initial canvas width
* @param height The initial canvas height * @param height The initial canvas height
*/ */
public JVLCCanvas(int width, int height) { public JVLCCanvas(int width, int height) {
jvlc = new JVLC();
setSize(width, height);
}
public JVLCCanvas(String[] args, int width, int height) {
jvlc = new JVLC(args);
setSize(width, height); setSize(width, height);
} }
public JVLCCanvas(JVLC jvlc) {
this.jvlc = jvlc;
}
public JVLC getJVLC() { public JVLC getJVLC() {
return jvlc; return jvlc;
......
/***************************************************************************** /*****************************************************************************
* JVLCPanel.java: Java Swing JPanel embedding VLC Video Output * 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$ * $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
* This program is free software; you can redistribute it and/or modify * as published by the Free Software Foundation; either version 2 of the
* it under the terms of the GNU General Public License as published by * License, or (at your option) any later version.
* 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
* This program is distributed in the hope that it will be useful, * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* but WITHOUT ANY WARRANTY; without even the implied warranty of * General Public License for more details.
* 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
* 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. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *
*/
package org.videolan.jvlc; package org.videolan.jvlc;
......
/***************************************************************************** /*****************************************************************************
* Playlist.java: The playlist class * Playlist.java: PlaylistIntf implementation class
***************************************************************************** *****************************************************************************
* 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 * Created on 28-feb-2006
* 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, * $Id$
* 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 * This program is free software; you can redistribute it
* along with this program; if not, write to the Free Software * 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. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *
*/
package org.videolan.jvlc; package org.videolan.jvlc;
...@@ -33,63 +38,87 @@ public class Playlist implements PlaylistIntf { ...@@ -33,63 +38,87 @@ public class Playlist implements PlaylistIntf {
this.libvlcInstance = _libvlcInstance; 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 _play(int _id, String[] options);
native private void _pause(); native private void _pause();
native private void _stop(); native private void _stop();
native private void _next(); native private void _next();
native private void _prev(); native private void _prev();
native private void _clear(); native private void _clear();
native private void _deleteItem(int itemID);
native private int _itemsCount(); native private int _itemsCount();
native private int _isPlaying(); native private int _isRunning();
public void play(int id, String[] options) {
public synchronized void play(int id, String[] options) throws VLCException {
_play(id, options); _play(id, options);
} }
public synchronized void play() throws VLCException {
play(-1, null);
}
public void pause() { public synchronized void togglePause() throws VLCException {
_pause(); _pause();
} }
public void stop() { public synchronized void stop() throws VLCException {
_stop(); _stop();
// do {
// try {
// Thread.sleep(50);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// } while (isRunning());
} }
public boolean isPlaying() { public boolean isRunning() throws VLCException {
return (_isPlaying() == 1)? false : true ; return (_isRunning() == 0)? false : true ;
} }
public int itemsCount() { public synchronized int itemsCount() throws VLCException {
return _itemsCount(); return _itemsCount();
} }
public void next() { public synchronized void next() throws VLCException {
if (! isRunning())
play();
_next(); _next();
} }
public void prev() { public synchronized void prev() throws VLCException {
if (! isRunning())
play();
_prev(); _prev();
} }
public void clear() { public synchronized void clear() throws VLCException {
_clear(); _clear();
} }
public int add(String uri, String name) { public synchronized int add(String uri, String name, String[] options) throws VLCException {
return _playlist_add(uri, name); return _playlist_add(uri, name, options);
}
public synchronized int add(String uri, String name) throws VLCException {
return add(uri, name, null);
} }
public void addExtended() { public synchronized void addExtended() {
// TODO Auto-generated method stub
} }
public long getInstance() { public synchronized void deleteItem(int itemID) throws VLCException {
_deleteItem(itemID);
}
public long getInstance() throws VLCException {
return libvlcInstance; return libvlcInstance;
} }
public void setPause(boolean pause) throws VLCException {
// TODO Auto-generated method stub
}
} }
/***************************************************************************** /*****************************************************************************
* PlaylistIntf.java: The playlist interface * 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 * Created on 28-feb-2006
* 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, * $Id$
* 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 * This program is free software; you can redistribute it
* along with this program; if not, write to the Free Software * 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. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *
*/
package org.videolan.jvlc; package org.videolan.jvlc;
public interface PlaylistIntf { public interface PlaylistIntf {
void play(int id, String[] options);
void pause(); /**
void stop(); * Plays the item specified in id, with options. At the moment options
boolean isPlaying(); * has no effect and can be safely set to null.
int itemsCount(); * @param id The ID to play
void next(); * @param options Options to play the item with
void prev(); */
void clear(); void play(int id, String[] options) throws VLCException;
int add(String uri, String name);
/**
* Plays the current item in the playlist.
*/
void play() throws VLCException;
/**
* Toggles pause for the current item.
*/
void togglePause() throws VLCException;
/**
* Pauses the currently playing item if pause value is true. Plays it
* otherwise. If you set pause to true and the current item is already
* playing, this has no effect.
*
* @param pause
* @throws VLCException
*/
void setPause(boolean pause) throws VLCException;
/**
* Stops the currently playing item. Differently from pause, stopping
* an item destroys any information related to the item.
*/
void stop() throws VLCException;
/**
* This function returns true if the current item has not been stopped.
* @return True if the current item has not been stopped
*/
boolean isRunning() throws VLCException;
/**
* TODO: this should return the number of items added with add, with no
* respect to videolan internal playlist.
*
* Returns the number of items in the playlist. Beware that this number
* could be bigger than the number of times add() has been called.
*
* @return Current number of items in the playlist
*/
int itemsCount() throws VLCException;
/**
* Move to next item in the playlist and play it.
*/
void next() throws VLCException;
/**
* Move to previous item in the playlist and play it.
*/
void prev() throws VLCException;
/**
* Clear the playlist which becomes empty after this call.
*/
void clear() throws VLCException;
/**
* TODO: document the kind of items that can be added.
* Add a new item in the playlist.
*
* @param uri Location of the item
* @param name Name of the item
* @return The item ID
*/
int add(String uri, String name) throws VLCException;
/**
* Currently not implemented
*/
void addExtended(); void addExtended();
} }
/*****************************************************************************
* JVLC.java: Main Java Class, represents a libvlc_instance_t object
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Philippe Morin <phmorin@free.fr>
*
* Created on 18-jul-2006
*
* $Id $
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*
*/
package org.videolan.jvlc;
import java.lang.Exception;
public class VLCException extends Exception {
public VLCException() {
super();
}
public VLCException(String message) {
super(message);
}
public VLCException(String message,Throwable cause) {
super(message,cause);
}
public VLCException(Throwable cause) {
super(cause);
}
}
package org.videolan.jvlc;
public class VLM implements VLMIntf {
private long libvlcInstance;
private native void _addBroadcast(String mediaName, String meditInputMRL,
String mediaOutputMRL, String[] additionalOptions,
boolean enableBroadcast, boolean isPlayableInLoop);
private native void _deleteMedia(String mediaName);
private native void _setEnabled(String mediaName, boolean newStatus);
private native void _setOutput(String mediaName, String mediaOutputMRL);
private native void _setInput(String mediaName, String mediaInputMRL);
private native void _setLoop(String mediaName, boolean isPlayableInLoop);
private native void _changeMedia(String newMediaName, String inputMRL,
String outputMRL, String[] additionalOptions,
boolean enableNewBroadcast, boolean isPlayableInLoop);
private native void _playMedia(String mediaName);
private native void _stopMedia(String mediaName);
private native void _pauseMedia(String mediaName);
public VLM( long instance ) {
this.libvlcInstance = instance;
}
public void addBroadcast(String name, String input, String output,
String[] options, boolean enabled, boolean loop)
throws VLCException {
_addBroadcast(name, input, output, options, enabled, loop);
}
public void deleteMedia(String name) throws VLCException {
_deleteMedia(name);
}
public void setEnabled(String name, boolean enabled) throws VLCException {
_setEnabled(name, enabled);
}
public void setOutput(String name, String output) throws VLCException {
_setOutput(name, output);
}
public void setInput(String name, String input) throws VLCException {
_setInput(name, input);
}
public void setLoop(String name, boolean loop) throws VLCException {
_setLoop(name, loop);
}
public void changeMedia(String name, String input, String output,
String[] options, boolean enabled, boolean loop)
throws VLCException {
_changeMedia(name, input, output, options, enabled, loop);
}
public void playMedia(String name) throws VLCException {
_playMedia(name);
}
public void stopMedia(String name) throws VLCException {
_stopMedia(name);
}
public void pauseMedia(String name) throws VLCException {
_pauseMedia(name);
}
public long getInstance() {
return libvlcInstance;
}
}
/***************************************************************************** /*****************************************************************************
* VLMIntf.java: VLM Interface * VLMIntf.java: VLM Interface
***************************************************************************** *****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team * Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-2006
* *
* $Id$ * $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
* This program is free software; you can redistribute it and/or modify * as published by the Free Software Foundation; either version 2 of the
* it under the terms of the GNU General Public License as published by * License, or (at your option) any later version.
* 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
* This program is distributed in the hope that it will be useful, * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* but WITHOUT ANY WARRANTY; without even the implied warranty of * General Public License for more details.
* 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
* 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. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *
*/
package org.videolan.jvlc; package org.videolan.jvlc;
public interface VLMIntf { public interface VLMIntf {
void addBroadcast();
void deleteMedia(); /**
void setEnabled(); * Add a broadcast, with one input
void setOutput(); * @param name the name of the new broadcast
void setInput(); * @param input the input MRL
void setLoop(); * @param output the output MRL (the parameter to the "sout" variable)
void changeMedia(); * @param options additional options
* @param enabled boolean for enabling the new broadcast
* @param loop Should this broadcast be played in loop ?
*/
void addBroadcast( String name, String input, String output, String[] options, boolean enabled, boolean loop )
throws VLCException;
/**
* Delete a media (vod or broadcast)
* @param name the media to delete
*/
void deleteMedia( String name ) throws VLCException;
/**
* Enable or disable a media (vod or broadcast)
* @param name the media to work on
* @param enabled the new status
*/
void setEnabled( String name, boolean enabled ) throws VLCException;
/**
* Set the output for a media
* @param name the media to work on
* @param output the output MRL (the parameter to the "sout" variable)
*/
void setOutput( String name, String output ) throws VLCException;
/**
* Set a media's input MRL. This will delete all existing inputs and
* add the specified one.
* @param name the media to work on
* @param input the input MRL
*/
void setInput( String name, String input ) throws VLCException;
/**
* Set loop mode for a media
* @param name the media to work on
* @param loop the new status
*/
void setLoop( String name, boolean loop ) throws VLCException;
/**
* Edit the parameters of a media. This will delete all existing inputs and
* add the specified one.
* @param name the name of the new broadcast
* @param input the input MRL
* @param output the output MRL (the parameter to the "sout" variable)
* @param options additional options
* @param enabled boolean for enabling the new broadcast
* @param loop Should this broadcast be played in loop ?
*/
void changeMedia( String name, String input, String output, String[] options, boolean enabled, boolean loop )
throws VLCException;
/**
* Plays a media
* @param name of the broadcast to play
*/
void playMedia(String name) throws VLCException;
/**
* Stops a media
* @param name of the broadcast to stop
*/
void stopMedia(String name) throws VLCException;
/**
* Pauses a media
* @param name name of the broadcast to pause
*/
void pauseMedia(String name) throws VLCException;
} }
/**
*
*/
package org.videolan.jvlc;
import java.awt.Component;
import java.awt.Dimension;
public final class Video implements VideoIntf {
private long libvlcInstance;
public Video( long libvlcInstance) {
this.libvlcInstance = libvlcInstance;
}
/*
* Video native methods
*/
private native void _toggleFullscreen();
private native void _setFullscreen( boolean value);
private native boolean _getFullscreen();
private native int _getHeight();
private native int _getWidth();
private native void _getSnapshot(String filename);
private native void _destroyVideo();
private native void _reparent(Component component);
private native void _setSize(int width, int height);
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#destroyVideo()
*/
public void destroyVideo() throws VLCException {
_destroyVideo();
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getFullscreen()
*/
public boolean getFullscreen() throws VLCException {
return _getFullscreen();
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getSnapshot(java.lang.String)
*/
public void getSnapshot(String filepath) throws VLCException {
_getSnapshot( filepath );
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getVideoHeight()
*/
public int getHeight() throws VLCException {
return _getHeight();
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getVideoWidth()
*/
public int getWidth() throws VLCException {
return _getWidth();
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#reparentVideo(java.awt.Component)
*/
public void reparent(Component c) throws VLCException {
_reparent(c);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#resizeVideo(int, int)
*/
public void setSize(int width, int height) throws VLCException {
_setSize( width, height );
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#setFullscreen(boolean)
*/
public void setFullscreen(boolean fullscreen) throws VLCException {
_setFullscreen( fullscreen );
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#toggleFullscreen()
*/
public void toggleFullscreen() throws VLCException {
_toggleFullscreen();
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getSize()
*/
public Dimension getSize() throws VLCException {
return new Dimension (getWidth(), getHeight());
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#setSize(java.awt.Dimension)
*/
public void setSize(Dimension d) throws VLCException {
setSize(d.width, d.height);
}
public long getInstance() {
return libvlcInstance;
}
}
/* /*****************************************************************************
* VideoIntf.java: Video methods interface
*****************************************************************************
*
* Copyright (C) 1998-2006 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
*
* Created on 28-feb-2006 * Created on 28-feb-2006
* *
* $Id$ * $Id$
...@@ -15,18 +22,93 @@ ...@@ -15,18 +22,93 @@
* *
* You should have received a copy of the GNU General Public * You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software * License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* *
*/ */
/**
* @author Filippo Carone <filippo@carone.org>
*/
package org.videolan.jvlc; package org.videolan.jvlc;
import java.awt.Component;
import java.awt.Dimension;
public interface VideoIntf { public interface VideoIntf {
void toggleFullscreen(); /**
void setFullscreen(); * Toggles the fullscreen.
void getFullscreen(); */
void toggleFullscreen() throws VLCException;
/**
* Sets fullscreen if fullscreen argument is true.
* @param fullscreen
*/
void setFullscreen( boolean fullscreen ) throws VLCException;
/**
* @return True if the current video window is in fullscreen mode.
*/
boolean getFullscreen() throws VLCException;
/**
* Saves a snapshot of the current video window.
* @param filepath The full path (including filename) were to save the snapshot to.
* If you only give a path, not including the filename, the snapshot will be saved in
* the specified path using vlc naming conventions.
*/
void getSnapshot(String filepath) throws VLCException;
/**
* @return The current video window height
*/
int getHeight() throws VLCException;
/**
* @return The current video window width
*/
int getWidth() throws VLCException;
/**
* Get the size of the video output window as a Dimension object.
* @return The video size in a Dimension object.
* @throws VLCException
*/
Dimension getSize() throws VLCException;
/**
* Destroys video output, but the item continues to play.
* @throws VLCException
*/
void destroyVideo() throws VLCException;
/**
* Moves video output from the current Canvas to another. This funtion
* doens't resize the video output to the new canvas size. See resizeVideo().
* @param c
* @throws VLCException
*/
void reparent(Component c) throws VLCException;
/**
* Resizes video output to width and height. This operation could be necessary
* after reparenting. See reparentVideo().
* @param width The new video output width
* @param height The new video output height
* @throws VLCException
*/
void setSize(int width, int height) throws VLCException;
/**
* Resizes video output to width and height. This operation could be necessary
* after reparenting. See reparentVideo().
*
* @param d The new size of video
* @throws VLCException
*/
void setSize(Dimension d) throws VLCException;
} }
/*****************************************************************************
* JVLC.java: JNI interface for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2005 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/* These are a must*/
#include <jni.h>
#include <vlc/vlc.h>
#include <jawt.h>
#include <jawt_md.h>
#include <X11/Xlib.h> // 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);
}
/*****************************************************************************
* JVLC.java: JNI interface for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* These are a must*/
#include <jni.h>
#include <vlc/libvlc.h>
#include <stdio.h> // for printf
#include <stdlib.h> // for calloc
#include <string.h> // for strcmp
/* JVLC internal imports, generated by gcjh */
#include "org_videolan_jvlc_JVLC.h"
#include "org_videolan_jvlc_Playlist.h"
jlong getClassInstance (JNIEnv *env, jobject _this);
jlong getPlaylistInstance (JNIEnv *env, jobject _this);
JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance__ (JNIEnv *env, jobject _this) {
// res is the pointer to libvlc_instance_t
long res;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
res = ( long ) libvlc_new( 0, NULL, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
return res;
}
JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance___3Ljava_lang_String_2 (JNIEnv *env, jobject _this, jobjectArray args) {
long res;
int argc;
const char **argv;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
libvlc_exception_init( exception );
argc = (int) env->GetArrayLength((jarray) args);
argv = (const char **) malloc(argc * sizeof(char*));
for (int i = 0; i < argc; i++) {
argv[i] = env->GetStringUTFChars((jstring) env->GetObjectArrayElement(args, i),
0
);
}
res = (long) libvlc_new(argc, (char**) argv, exception );
free( exception );
free( argv );
return res;
}
/*
* Audio native functions
*/
JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_JVLC__1getMute (JNIEnv *env, jobject _this)
{
// res is the final result
jboolean res;
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = (jboolean) libvlc_audio_get_mute( ( libvlc_instance_t * ) instance, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1setMute (JNIEnv *env, jobject _this, jboolean value)
{
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_audio_set_mute( ( libvlc_instance_t * ) instance, value, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1toggleMute (JNIEnv *env, jobject _this)
{
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
///\TODO: NO, this is not what we want.
libvlc_audio_get_mute( ( libvlc_instance_t * ) instance, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC__1getVolume (JNIEnv *env, jobject _this)
{
// res is the final result
jboolean res;
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = (jboolean) libvlc_audio_get_mute( ( libvlc_instance_t * ) instance, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
return res;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC__1getVolume (JNIEnv *env, jobject _this, jboolean value)
{
jint res = 0;
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = libvlc_audio_get_volume( ( libvlc_instance_t * ) instance, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1setVolume (JNIEnv *env, jobject _this, jint volume)
{
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_audio_set_volume( ( libvlc_instance_t * ) instance, volume, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
}
/*
* Video native functions
*/
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1toggleFullscreen (JNIEnv *env, jobject _this)
{
long instance = 0;
libvlc_input_t *input;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
input = libvlc_playlist_get_input( ( libvlc_instance_t *) instance, exception );
libvlc_toggle_fullscreen( input, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1setFullscreen (JNIEnv *env, jobject _this, jboolean value)
{
long instance = 0;
libvlc_input_t *input;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
input = libvlc_playlist_get_input( ( libvlc_instance_t *) instance, exception );
libvlc_set_fullscreen( input, value, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
}
JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_JVLC__1getFullscreen (JNIEnv *env, jobject _this)
{
int res = 0;
libvlc_input_t *input;
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
input = libvlc_playlist_get_input( ( libvlc_instance_t *) instance, exception );
res = libvlc_get_fullscreen( input, exception );
if ( libvlc_exception_raised( exception ))
{
///\TODO: raise java exception
printf("%s\n", libvlc_exception_get_message( exception ));
}
free( exception );
return res;
}
/*
* Playlist native functions
*/
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1playlist_1add (JNIEnv *env, jobject _this, jstring uri, jstring name) {
long instance = 0;
int res = 0;
const char* psz_uri = env->GetStringUTFChars( uri, 0 );
const char* psz_name = env->GetStringUTFChars( name, 0 );
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = libvlc_playlist_add( (libvlc_instance_t*) instance, psz_uri, psz_name, exception );
/// \todo check exceptions
/* free resources */
free(exception);
if (psz_uri != NULL) {
env->ReleaseStringUTFChars( uri, psz_uri );
}
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1play (JNIEnv *env, jobject _this, jint id, jobjectArray options) {
long instance = 0;
int i_options = 0;
char** ppsz_options = NULL;
instance = getPlaylistInstance( env, _this );
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
if ( options != NULL ) ;
/// \TODO: parse options
libvlc_playlist_play( ( libvlc_instance_t* ) instance, id, i_options, ppsz_options, exception );
free( exception );
return;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1pause (JNIEnv *env, jobject _this) {
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_pause( ( libvlc_instance_t* ) instance, exception );
free( exception );
return;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1stop (JNIEnv *env, jobject _this) {
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_stop( ( libvlc_instance_t* ) instance, exception );
free( exception );
return;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1next (JNIEnv *env, jobject _this) {
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_next( ( libvlc_instance_t* ) instance, exception );
free( exception );
return;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1prev (JNIEnv *env, jobject _this) {
long instance = 0;
libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_prev( (libvlc_instance_t*) instance, exception );
free( exception );
return;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1clear (JNIEnv *env, jobject _this) {
long instance = 0;
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
libvlc_playlist_clear( (libvlc_instance_t*) instance, exception );
free( exception );
return;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1itemsCount (JNIEnv *env, jobject _this) {
long instance = 0;
int res = 0;
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = libvlc_playlist_items_count( (libvlc_instance_t*) instance, exception );
free( exception );
return res;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1isPlaying (JNIEnv *env, jobject _this) {
long instance = 0;
int res = 0;
libvlc_exception_t *exception = (libvlc_exception_t *) malloc( sizeof( libvlc_exception_t ));
libvlc_exception_init( exception );
instance = getPlaylistInstance( env, _this );
res = libvlc_playlist_isplaying( (libvlc_instance_t*) instance, exception );
free( exception );
return res;
}
/*
* Utility functions
*/
jlong getClassInstance (JNIEnv *env, jobject _this) {
/* get the id field of object */
jclass cls = env->GetObjectClass(_this);
jmethodID mid = env->GetMethodID(cls, "getInstance", "()J");
jlong field = env->CallLongMethod(_this, mid);
return field;
}
jlong getPlaylistInstance (JNIEnv *env, jobject _this) {
/* get the instance field of object */
jclass cls = env->GetObjectClass(_this);
jmethodID mid = env->GetMethodID(cls, "getInstance", "()J");
jlong field = env->CallLongMethod(_this, mid);
return field;
}
...@@ -5427,6 +5427,7 @@ AC_CONFIG_FILES([ ...@@ -5427,6 +5427,7 @@ AC_CONFIG_FILES([
activex/axvlc.inf activex/axvlc.inf
bindings/Makefile bindings/Makefile
bindings/java/Makefile bindings/java/Makefile
bindings/java/src/Makefile
bindings/mediacontrol-python/Makefile bindings/mediacontrol-python/Makefile
doc/Makefile doc/Makefile
intl/Makefile intl/Makefile
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment