Commit 92fcb9b5 authored by Filippo Carone's avatar Filippo Carone

Java bindings update to latest JVLC (step 1/2)

JNI: unused files removed
JNI: libvlc.h dependent file added 
A sample SWT (ugly) player added
Old java bindings files removed
parent 77fa066c
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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();
}
}
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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 org.videolan.jvlc.*;
import java.awt.*;
......
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
/**
* This is the main Java VLC class which represents a vlc_object_t. Through this
* class it's possible to control media loading/playing. It's possible to have
* more than one JVLC object in the same program.
*/
public class JVLC {
static {
System.loadLibrary("jvlc");
}
private int id;
/**
* @param args Arguments for the vlc object. These are the same as the
* original C version of VLC.
*/
public JVLC(String[] args) {
String[] properArgs = new String[args.length + 1];
properArgs[0] = "jvlc";
for (int i = 0; i < args.length; i++)
properArgs[i+1] = args[i];
this.id = create();
init(properArgs);
}
public JVLC() {
new JVLC(new String[]{""});
}
/**
* @return Returns the ID of the VLC Object
*/
public int getID() {
return this.id;
}
/**
* Cleanup the VLC Object. It's the equivalent of
* calling VLC_Die() and VLC_CleanUp()
*/
public void quit() {
this.die();
this.cleanUp();
}
private native int create();
private native int init(String[] args);
/**
*
* Creates the interface of the videolan player
*
* @param moduleName The interface module to display
* @param blocking True if the interface is blocking, otherwise it runs on its own thread
* @param startPlay True if the player starts to play as soon as the interface is displayed
* @return An int which is &lt; 0 on error
*/
public native int addInterface(String moduleName, boolean blocking, boolean startPlay);
/**
*
* Creates the interface of the videolan player with the default interface
* or the interface set by -I
*
* @param blocking True if the interface is blocking, otherwise it runs on its own thread
* @param startPlay True if the player starts to play as soon as the interface is displayed
* @return An int which is &lt; 0 on error
*/
public int addInterface(boolean blocking, boolean startPlay) {
return addInterface(null, blocking, startPlay);
}
/**
* @return The version of the VideoLan object
*/
public native String getVersion();
public native String getError(int errorCode);
private native int die();
private native int cleanUp();
public native int setVariable(JVLCVariable jvlcVariable);
public native JVLCVariable getVariable(String varName); // XXX in progress
public native int addTarget(String URI, String[] options, int insertMode, int position);
/**
* Plays the media
*
* @return An int which is &lt; 0 on error
*/
public native int play();
/**
*
* Pauses the media. If the media is already paused, pause() restarts it.
*
* @return
*/
public native int pause();
/**
*
* Stops the media
*
* @return
*/
public native int stop();
/**
* @return True if the player is actually playing something
*/
public native boolean isPlaying();
/**
* @return The absolute position within the media
*/
public native float getPosition();
public native float setPosition(float position);
public native int getTime();
public native int setTime(int seconds, boolean relative);
public native int getLength();
public native float speedFaster();
public native float speedSlower();
public native int getPlaylistIndex();
public native int getPlaylistItems();
public native int playlistNext();
public native int playlistPrev();
public native int playlistClear();
public native int getVolume();
public native int setVolume(int volume);
public native int muteVolume();
public native int fullScreen();
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public class JVLCBoolVariable extends JVLCVariable {
public JVLCBoolVariable(String name, int value) throws JVLCNoSuchVariableNameException {
super(name);
this.value = (value != 0)? new Integer(1) : new Integer(0);
}
public int getBoolValue() {
return ((Integer)value).intValue();
}
}
/*
* Created on 25-nov-2005
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
*/
/**
* @author Filippo Carone <filippo@carone.org>
*/
package org.videolan.jvlc;
import java.awt.Canvas;
import java.awt.Graphics;
public class JVLCCanvas extends Canvas {
public native void paint(Graphics g);
private final JVLC jvlcObject = new JVLC();
public JVLCCanvas() {
jvlcObject.addInterface("dummy", false, false);
}
public JVLC getJVLCObject() {
return jvlcObject;
}
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public class JVLCFloatVariable extends JVLCVariable {
public JVLCFloatVariable(String name, float value) throws JVLCNoSuchVariableNameException {
super(name);
this.value = new Float(value);
}
public float getFloatValue() {
return ((Float)value).floatValue();
}
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public class JVLCIntVariable extends JVLCVariable {
public JVLCIntVariable(String name, int value) throws JVLCNoSuchVariableNameException {
super(name);
this.value = new Integer(value);
}
public int getIntValue() {
return ((Integer)value).intValue();
}
}
/*
* Created on 22-nov-2005
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
*/
/**
* @author Filippo Carone <filippo@carone.org>
*/
package org.videolan.jvlc;
public class JVLCNoSuchVariableNameException extends Exception {
public JVLCNoSuchVariableNameException() {
super();
// TODO Auto-generated constructor stub
}
public JVLCNoSuchVariableNameException(String message) {
super(message);
// TODO Auto-generated constructor stub
}
public JVLCNoSuchVariableNameException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}
public JVLCNoSuchVariableNameException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public class JVLCStringVariable extends JVLCVariable {
public JVLCStringVariable(String name, String value) throws JVLCNoSuchVariableNameException {
super(name);
this.value = value;
}
public String getStringValue() {
return (String)value;
}
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public class JVLCTimeVariable extends JVLCVariable {
public JVLCTimeVariable(String name, long value) throws JVLCNoSuchVariableNameException {
super(name);
this.value = new Long(value);
}
public long getTimeValue() {
return ((Long)value).longValue();
}
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public class JVLCVarValue {
String name;
int OID;
public JVLCVarValue(String name, int OID) {
this.name = name;
this.OID = OID;
}
public String getName() {
return name;
}
public int getOID() {
return OID;
}
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLCVarVariable.java: Varying Variable
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public class JVLCVarVariable extends JVLCVariable {
public JVLCVarVariable(String name, JVLCVarValue value) throws JVLCNoSuchVariableNameException {
super(name);
this.value = value;
}
public JVLCVarValue getVarValue() {
return (JVLCVarValue)value;
}
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLCVariable.java: Abstract Variable class 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.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public abstract class JVLCVariable {
protected String name;
protected Object value;
public JVLCVariable(String name) throws JVLCNoSuchVariableNameException {
if (name == null) throw new JVLCNoSuchVariableNameException();
this.name = name;
}
public String getName() {
return name;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
}
package org.videolan.jvlc.mediacontrol;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
public class MediaControl {
}
package org.videolan.jvlc.mediacontrol;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
public class MediaControlException extends Exception {
int code;
String message;
public MediaControlException() { // XXX maybe this is not the constructor signature
super();
}
}
package org.videolan.jvlc.mediacontrol;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
import org.videolan.jvlc.JVLC;
public class MediaControlInstance {
JVLC vlc;
//Playlist playlist;
//intf thread;
}
package org.videolan.jvlc.mediacontrol;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
public class MediaControlPlaylistSeq {
private int size;
private String[] data; // char**
public MediaControlPlaylistSeq() {
}
}
package org.videolan.jvlc.mediacontrol;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
public class MediaControlPosition {
private long value;
int origin; // one of MediaControlPositionOriginEnum
int key; // one of MediaControlPositionOriginEnum
/*
* Constructor
*/
public MediaControlPosition() {
}
/*
* Getters/Setters
*/
public long getValue() {
return value;
}
public void setValue(long value) {
this.value = value;
}
}
package org.videolan.jvlc.mediacontrol;
/*****************************************************************************
* MediaControlPositionOrigin.java: class for vlc MediaControl Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
public class MediaControlPositionKeyEnum {
public static final int BYTECOUNT = 1;
public static final int SAMPLECOUNT = 2;
public static final int MEDIATIME = 3;
}
package org.videolan.jvlc.mediacontrol;
/*****************************************************************************
* MediaControlPositionOrigin.java: class for vlc MediaControl Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
public class MediaControlPositionOrigin {
public static final int AbsolutePosition = 1;
public static final int RelativePosition = 2;
public static final int ModuloPosition = 3;
}
package org.videolan.jvlc.mediacontrol;
/*****************************************************************************
* MediaControlPositionOrigin.java: class for vlc MediaControl Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
public class MediaControlPositionOriginEnum {
public static final int ABSOLUTEPOSITION = 1;
public static final int RELATIVEPOSITION = 2;
public static final int MODULOPOSITION = 3;
}
package org.videolan.jvlc.mediacontrol;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 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.
*****************************************************************************/
import java.util.Date;
public class MediaControlRGBPicture {
private int width;
private int height;
long type;
Date date;
int size;
String data; // char *data
public MediaControlRGBPicture() {
}
}
/*****************************************************************************
* JVLC.java: CNI 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 <gcj/cni.h>
#include <vlc/vlc.h>
#include <stdio.h> // for printf
#include <stdlib.h> // for calloc
/* JVLC internal imports, generated by gcjh */
#include "org/videolan/jvlc/JVLC.h"
#include "org/videolan/jvlc/JVLCVariable.h"
#include "org/videolan/jvlc/JVLCIntVariable.h"
#include "org/videolan/jvlc/JVLCBoolVariable.h"
#include "org/videolan/jvlc/JVLCFloatVariable.h"
#include "org/videolan/jvlc/JVLCStringVariable.h"
#include "org/videolan/jvlc/JVLCTimeVariable.h"
#include "org/videolan/jvlc/JVLCVarVariable.h"
#include "org/videolan/jvlc/JVLCVarValue.h"
/* Java classes used throughout here */
#include <java/lang/String.h>
#include <java/lang/Class.h>
#include <java/lang/System.h>
#include <java/io/PrintStream.h>
void setString(jstring orig, char* dest);
jint org::videolan::jvlc::JVLC::create () {
return VLC_Create();
}
jint org::videolan::jvlc::JVLC::init(JArray< ::java::lang::String *> *args) {
int argc = 0;
char* arguments[argc];
if (args != NULL) // It's a very bad day otherwise
{
argc = args->length;
arguments[argc];
/*
* convert the JArray<String*>* in char**
* in a suitable way for VLC_Init
*/
jstring* argsElements = elements(args);
for (int i = 0; i < argc; i++) {
arguments[i] = (char*) malloc(JvGetStringUTFLength(argsElements[i]) + 1);
setString(argsElements[i], arguments[i]);
}
}
return VLC_Init(0, argc, arguments);
}
jint org::videolan::jvlc::JVLC::addInterface(java::lang::String* moduleName, jboolean blocking, jboolean startPlay) {
char* psz_module = NULL;
if (moduleName != NULL) {
psz_module = (char *) malloc(JvGetStringUTFLength(moduleName));
setString(moduleName, psz_module);
}
int i_blocking = 0;
int i_startPlay = 0;
if (blocking) i_blocking = 1;
if (startPlay) i_startPlay = 1;
int addIntf_res = VLC_AddIntf(this->id, (char* const) psz_module, i_blocking, i_startPlay);
if (psz_module != NULL)
free(psz_module);
return addIntf_res;
}
jstring org::videolan::jvlc::JVLC::getVersion() {
return JvNewStringUTF(VLC_Version());
}
jstring org::videolan::jvlc::JVLC::getError(jint errorCode) {
return JvNewStringUTF(VLC_Error(errorCode));
}
jint org::videolan::jvlc::JVLC::die() {
return VLC_Die(this->id);
}
jint org::videolan::jvlc::JVLC::cleanUp() {
return VLC_CleanUp(this->id);
}
jint org::videolan::jvlc::JVLC::setVariable(org::videolan::jvlc::JVLCVariable *jvlcVariable) {
/* these are the two parameters given the the
* VLC_VariableSet() function
*/
vlc_value_t value;
char* psz_var = NULL;
if (jvlcVariable != NULL) {
jclass variableClass = jvlcVariable->getClass();
/* We use the class name for kinda of instanceof */
jstring className = variableClass->getName();
/**
* VLC_SetVariable takes a union as its second argument.
* The union members are mapped 1:1 to java types which
* extend JVLCVariable. So here we check the runtime type
* of the actual variable and act consequently. Here is the
* mapping:
*
* typedef union
*{
* int i_int; JVLCIntVariable
* vlc_bool_t b_bool; JVLCBoolVariable
* float f_float; JVLCFloatVariable
* char * psz_string; JVLCStringVariable
* void * p_address; -- NOT IMPLEMENTED --
* vlc_object_t * p_object; -- NOT IMPLEMENTED --
* vlc_list_t * p_list; JVLCListVariable XXX:TODO
* signed long long i_time; JVLCTimeVariable
* struct { char *psz_name; int i_object_id; } var; JVLCVarVariable <- this name sucks
* // Make sure the structure is at least 64bits
* struct { char a, b, c, d, e, f, g, h; } padding; <- Do we really need this?
*
* } vlc_value_t;
*/
/* i_int */
if (className->equals(JvNewStringUTF("VLCIntVariable" ))) {
value.i_int = ((org::videolan::jvlc::JVLCIntVariable *)jvlcVariable)->getIntValue();
}
/* b_bool */
else if (className->equals(JvNewStringUTF("VLCBoolVariable"))) {
value.b_bool = ((org::videolan::jvlc::JVLCBoolVariable *)jvlcVariable)->getBoolValue();
}
/* f_float */
else if (className->equals(JvNewStringUTF("VLCFloatVariable"))) {
value.f_float = ((org::videolan::jvlc::JVLCFloatVariable *)jvlcVariable)->getFloatValue();
}
/* psz_string */
else if (className->equals(JvNewStringUTF("VLCStringVariable"))) {
value.psz_string = (char* const) elements((((org::videolan::jvlc::JVLCStringVariable *)jvlcVariable)->getStringValue())->toCharArray());
}
/* i_time */
else if (className->equals(JvNewStringUTF("VLCTimeVariable"))) {
value.i_time = ((org::videolan::jvlc::JVLCTimeVariable *)jvlcVariable)->getTimeValue();
}
/* var */
else if (className->equals(JvNewStringUTF("VLCVarVariable"))) {
jstring varValueName = ((org::videolan::jvlc::JVLCVarVariable *)jvlcVariable)->getVarValue()->getName();
value.var.psz_name = (char *) malloc(JvGetStringUTFLength(varValueName));
setString(varValueName, value.var.psz_name);
value.var.i_object_id = (((org::videolan::jvlc::JVLCVarVariable *)jvlcVariable)->getVarValue())->getOID();
}
psz_var = (char *) malloc(JvGetStringUTFLength(jvlcVariable->getName()));
setString(jvlcVariable->getName(), psz_var);
}
return VLC_VariableSet(this->id, (char* const) psz_var, value);
}
jint org::videolan::jvlc::JVLC::addTarget(::java::lang::String *URI, JArray< ::java::lang::String *> *options, jint insertMode, jint position) {
char* psz_target = NULL;
char** ppsz_options = NULL;
int options_number = 0;
if (URI != NULL) {
psz_target = (char *) malloc( JvGetStringUTFLength(URI));
setString(URI, psz_target);
}
if (options != NULL) {
options_number = options->length;
ppsz_options = (char **) malloc (options_number * sizeof(char*));
//ppsz_options[options_number];
jstring* jstr_options = elements(options);
for (jint i = 0; i < options_number; i++) {
ppsz_options[i] = (char *) malloc(JvGetStringUTFLength(jstr_options[i]));
setString(jstr_options[i], ppsz_options[i]);
}
}
int res = VLC_AddTarget(this->id, (char const *)psz_target, (const char **) ppsz_options, options_number, insertMode, position);
if (ppsz_options != NULL) {
for (int i = 0; i < options_number; i++) {
free(ppsz_options[i]);
}
free(ppsz_options);
}
if (psz_target != NULL) {
free(psz_target);
}
return res;
}
jint org::videolan::jvlc::JVLC::play() {
return VLC_Play(this->id);
}
jint org::videolan::jvlc::JVLC::pause() {
return VLC_Pause(this->id);
}
jint org::videolan::jvlc::JVLC::stop() {
return VLC_Stop(this->id);
}
jboolean org::videolan::jvlc::JVLC::isPlaying() {
return VLC_IsPlaying(this->id);
}
jfloat org::videolan::jvlc::JVLC::getPosition() {
return VLC_PositionGet(this->id);
}
jfloat org::videolan::jvlc::JVLC::setPosition(jfloat position) {
return VLC_PositionSet(this->id, position);
}
jint org::videolan::jvlc::JVLC::getTime() {
return VLC_TimeGet(this->id);
}
jint org::videolan::jvlc::JVLC::setTime(jint seconds, jboolean relative) {
return VLC_TimeSet(this->id, seconds, relative);
}
jint org::videolan::jvlc::JVLC::getLength() {
return VLC_LengthGet(this->id);
}
jfloat org::videolan::jvlc::JVLC::speedFaster() {
return VLC_SpeedFaster(this->id);
}
jfloat org::videolan::jvlc::JVLC::speedSlower() {
return VLC_SpeedSlower(this->id);
}
jint org::videolan::jvlc::JVLC::getPlaylistIndex() {
return VLC_PlaylistIndex(this->id);
}
jint org::videolan::jvlc::JVLC::getPlaylistItems() {
return VLC_PlaylistNumberOfItems(this->id);
}
jint org::videolan::jvlc::JVLC::playlistNext() {
return VLC_PlaylistNext(this->id);
}
jint org::videolan::jvlc::JVLC::playlistPrev() {
return VLC_PlaylistPrev(this->id);
}
jint org::videolan::jvlc::JVLC::playlistClear() {
return VLC_PlaylistClear(this->id);
}
jint org::videolan::jvlc::JVLC::setVolume(jint volume) {
return VLC_VolumeSet(this->id, volume);
}
jint org::videolan::jvlc::JVLC::getVolume() {
return VLC_VolumeGet(this->id);
}
jint org::videolan::jvlc::JVLC::muteVolume() {
return VLC_VolumeMute(this->id);
}
jint org::videolan::jvlc::JVLC::fullScreen() {
return VLC_FullScreen(this->id);
}
/* XXX: in progress */
org::videolan::jvlc::JVLCVariable* org::videolan::jvlc::JVLC::getVariable(::java::lang::String* varName) {
char* const psz_var = (char* const) elements( varName->toCharArray());
vlc_value_t value;
if (VLC_VariableGet(this->id, psz_var, &value) != VLC_SUCCESS) {
// throw exception
return NULL;
}
return NULL;
}
/*
* This is an helper function to convert jstrings to char*s
* setString _assumes_ the char* dest has been allocated
* XXX: should return >= 0 on success, < 0 on error
*/
void setString(jstring orig, char* dest) {
jsize chars = JvGetStringUTFRegion(orig, 0, orig->length(), dest);
// Note that dest is a buffer, not a C string. It is not null terminated.
dest[chars] = '\0';
}
/*****************************************************************************
* 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 <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_JVLCVariable.h"
#include "org_videolan_jvlc_JVLCIntVariable.h"
#include "org_videolan_jvlc_JVLCBoolVariable.h"
#include "org_videolan_jvlc_JVLCFloatVariable.h"
#include "org_videolan_jvlc_JVLCStringVariable.h"
#include "org_videolan_jvlc_JVLCTimeVariable.h"
#include "org_videolan_jvlc_JVLCVarVariable.h"
#include "org_videolan_jvlc_JVLCVarValue.h"
int getClassID (JNIEnv *env, jobject obj);
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_create (JNIEnv *env, jobject obj) {
return VLC_Create();
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_init (JNIEnv *env, jobject obj, jobjectArray args) {
/* build the argv vector */
const char **argv;
/* count the arguments */
// int argc = (int) (*env)->GetArrayLength(env, args)
int argc = (int) env->GetArrayLength((jarray) args);
/* convert java strings to c strings
how many pointers do we need? */
argv = (const char **) malloc(argc * sizeof(char*));
/* now fill the argv* */
for (int i = 0; i < argc; i++) {
argv[i] = env->GetStringUTFChars((jstring) env->GetObjectArrayElement(args, i),
0
);
}
/* execute the library call */
int res = VLC_Init(getClassID(env,obj), argc, (char **) argv);
free(argv);
return res;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_addInterface (JNIEnv *env, jobject obj, jstring moduleName, jboolean blocking, jboolean startPlay) {
const char *psz_module = NULL;
int i_blocking, i_startPlay;
if (moduleName != NULL) {
psz_module = env->GetStringUTFChars(moduleName, 0);
}
if (blocking == true) i_blocking = 1;
else i_blocking = 0;
if (startPlay == true) i_startPlay = 1;
else i_startPlay = 0;
int addIntf_res = VLC_AddIntf(getClassID(env,obj), psz_module, i_blocking, i_startPlay);
if (psz_module != NULL) {
env->ReleaseStringUTFChars(moduleName, psz_module);
}
return addIntf_res;
}
JNIEXPORT jstring JNICALL Java_org_videolan_jvlc_JVLC_getVersion (JNIEnv *env, jobject obj) {
return env->NewStringUTF(VLC_Version());
}
JNIEXPORT jstring JNICALL Java_org_videolan_jvlc_JVLC_getError (JNIEnv *env, jobject obj, jint errorCode) {
return env->NewStringUTF(VLC_Error(errorCode));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_die (JNIEnv *env, jobject obj) {
return VLC_Die(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_cleanUp (JNIEnv *env, jobject obj) {
return VLC_CleanUp(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_setVariable (JNIEnv *env, jobject obj, jobject jvlcVariable) {
vlc_value_t value;
char* psz_var = NULL;
jstring varName;
jstring stringValue = NULL;
if (jvlcVariable != NULL) {
/* get the name of jvlcVariable class */
jclass variableClass = env->GetObjectClass(jvlcVariable);
jclass varSuperClass = env->GetSuperclass (variableClass);
jmethodID getNameMethod = env->GetMethodID (varSuperClass, "getName", "()Ljava/lang/String;");
jstring varName = (jstring) env->CallObjectMethod (jvlcVariable, getNameMethod);
/* i_int */
jclass tmpClass = env->FindClass("org/videolan/jvlc/JVLCIntVariable");
if (env->IsInstanceOf(jvlcVariable, tmpClass)) {
jmethodID mid = env->GetMethodID(variableClass, "getIntValue", "()I");
value.i_int = env->CallIntMethod(jvlcVariable, mid);
goto done;
}
/* b_bool */
tmpClass = env->FindClass("org/videolan/jvlc/JVLCBoolVariable");
if (env->IsInstanceOf(jvlcVariable, tmpClass )) {
jmethodID mid = env->GetMethodID(variableClass, "getBoolValue", "()Z");
value.b_bool = env->CallBooleanMethod(jvlcVariable, mid);
goto done;
}
/* f_float */
tmpClass = env->FindClass("org/videolan/jvlc/JVLCFloatVariable");
if (env->IsInstanceOf(jvlcVariable, tmpClass )) {
jmethodID mid = env->GetMethodID(variableClass, "getFloatValue", "()F");
value.f_float = env->CallBooleanMethod(jvlcVariable, mid);
goto done;
}
/* psz_string */
tmpClass = env->FindClass("org/videolan/jvlc/JVLCStringVariable");
if (env->IsInstanceOf(jvlcVariable, tmpClass )) {
jmethodID mid = env->GetMethodID(variableClass, "getStringValue", "()Ljava/lang/String");
jstring stringValue = (jstring) env->CallObjectMethod(jvlcVariable, mid);
value.psz_string = (char *)env->GetStringUTFChars(stringValue, 0);
goto done;
}
/* i_time */
tmpClass = env->FindClass("org/videolan/jvlc/JVLCTimeVariable");
if (env->IsInstanceOf(jvlcVariable, tmpClass )) {
jmethodID mid = env->GetMethodID(variableClass, "getTimeValue", "()L");
value.i_time = env->CallLongMethod(jvlcVariable, mid);
goto done;
}
/* var */
tmpClass = env->FindClass("org/videolan/jvlc/JVLCVarVariable");
if (env->IsInstanceOf(jvlcVariable, tmpClass )) {
/*
* This is the longer one. We have to get the VarValue object
* from the JVLCVarVariable and retrieve the OID from it.
*/
jmethodID getVarValueMID = env->GetMethodID(variableClass, "getVarValue", "()Lorg/videolan/jvlc/JVLCVarValue;");
jobject varVariableObj = env->CallObjectMethod(jvlcVariable, getVarValueMID);
/*
* Now from the varVariableObj we need to retrieve its name and OID
*/
/*
* Get the VarValue name
*/
jclass varVariableCls = env->GetObjectClass(varVariableObj);
jmethodID getVarName = env->GetMethodID(varVariableCls, "getName","()Ljava/lang/String;");
jstring varName = (jstring) env->CallObjectMethod(varVariableObj, getVarName);
value.var.psz_name = (char *)env->GetStringUTFChars(varName, 0);
/*
* Get the VarValue OID
*/
jmethodID getOID = env->GetMethodID(varVariableCls, "getOID", "()I");
value.var.i_object_id = env->CallIntMethod(varVariableObj, getOID);
goto done;
}
done:
psz_var = (char *) env->GetStringUTFChars(varName, 0);
}
if (psz_var != NULL) {
int res = VLC_VariableSet(getClassID(env, obj), (char* const) psz_var, value);
env->ReleaseStringUTFChars(varName, psz_var);
if (stringValue != NULL) env->ReleaseStringUTFChars(stringValue, value.psz_string);
return res;
}
return -1;
}
JNIEXPORT jobject JNICALL Java_org_videolan_jvlc_JVLC_getVariable (JNIEnv *env, jobject obj, jstring varName) {
const char* psz_var = env->GetStringUTFChars(varName, 0);
vlc_value_t value;
if (VLC_VariableGet(getClassID(env, obj), psz_var, &value) != VLC_SUCCESS) {
// throw exception
return NULL;
}
return NULL;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_addTarget (JNIEnv *env, jobject obj, jstring URI, jobjectArray options, jint insertMode, jint position) {
char* psz_target = NULL;
char** ppsz_options = NULL;
int options_number = 0;
if (URI != NULL) {
psz_target = (char *) env->GetStringUTFChars(URI, 0);
}
if (options != NULL) {
options_number = env->GetArrayLength(options);
ppsz_options = (char **) malloc (options_number * sizeof(char*));
for (int i = 0; i < options_number; i++) {
ppsz_options[i] = (char *) env->GetStringUTFChars((jstring) env->GetObjectArrayElement(options, i), 0);
}
}
int res = VLC_AddTarget(getClassID(env, obj), (char const *)psz_target, (const char **) ppsz_options, options_number, insertMode, position);
if (ppsz_options != NULL) {
for (int i = 0; i < options_number; i++) {
free(ppsz_options[i]);
}
free(ppsz_options);
}
if (psz_target != NULL) {
free(psz_target);
}
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_play (JNIEnv *env, jobject obj) {
return VLC_Play(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_pause (JNIEnv *env, jobject obj) {
return VLC_Pause(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_stop (JNIEnv *env, jobject obj) {
return VLC_Stop(getClassID(env, obj));
}
JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_JVLC_isPlaying (JNIEnv *env, jobject obj) {
return VLC_IsPlaying(getClassID(env, obj));
}
JNIEXPORT jfloat JNICALL Java_org_videolan_jvlc_JVLC_getPosition (JNIEnv *env, jobject obj) {
return VLC_PositionGet(getClassID(env, obj));
}
JNIEXPORT jfloat JNICALL Java_org_videolan_jvlc_JVLC_setPosition (JNIEnv *env, jobject obj, jfloat position) {
return VLC_PositionSet(getClassID(env, obj), position);
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_getTime (JNIEnv *env, jobject obj) {
return VLC_TimeGet(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_setTime (JNIEnv *env, jobject obj, jint seconds, jboolean relative) {
return VLC_TimeSet(getClassID(env, obj), seconds, relative);
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_getLength (JNIEnv *env, jobject obj) {
return VLC_LengthGet(getClassID(env, obj));
}
JNIEXPORT jfloat JNICALL Java_org_videolan_jvlc_JVLC_speedFaster (JNIEnv *env, jobject obj) {
return VLC_SpeedFaster(getClassID(env, obj));
}
JNIEXPORT jfloat JNICALL Java_org_videolan_jvlc_JVLC_speedSlower (JNIEnv *env, jobject obj) {
return VLC_SpeedSlower(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_getPlaylistIndex (JNIEnv *env, jobject obj) {
return VLC_PlaylistIndex(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_getPlaylistItems (JNIEnv *env, jobject obj) {
return VLC_PlaylistNumberOfItems(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_playlistNext (JNIEnv *env, jobject obj) {
return VLC_PlaylistNext(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_playlistPrev (JNIEnv *env, jobject obj) {
return VLC_PlaylistPrev(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_playlistClear (JNIEnv *env, jobject obj) {
return VLC_PlaylistClear(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_getVolume (JNIEnv *env, jobject obj) {
return VLC_VolumeGet(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_setVolume (JNIEnv *env, jobject obj, jint volume) {
return VLC_VolumeSet(getClassID(env, obj), volume);
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_muteVolume (JNIEnv *env, jobject obj) {
return VLC_VolumeMute(getClassID(env, obj));
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC_fullScreen (JNIEnv *env, jobject obj) {
return VLC_FullScreen(getClassID(env, obj));
}
/*
* This method is an helper method
* only valid if obj == JVLC
*/
int getClassID (JNIEnv *env, jobject obj) {
/* get the id field of object */
jclass cls = env->GetObjectClass(obj);
jmethodID mid = env->GetMethodID(cls, "getID", "()I");
int field = env->CallIntMethod(obj, mid);
return field;
}
/*****************************************************************************
* JVLC.java: JNI interface for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2005 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., 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) {
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 );
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;
}
/*
* 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;
}
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