Commit 89187b02 authored by Filippo Carone's avatar Filippo Carone

jvlc: LibVlc class updated and code aligned to current native libvlc

parent 54aa31e6
......@@ -110,15 +110,13 @@ public class JVLC
public LoggerVerbosityLevel getLogVerbosity()
{
libvlc_exception_t exception = new libvlc_exception_t();
int level = libvlc.libvlc_get_log_verbosity(instance, exception);
int level = libvlc.libvlc_get_log_verbosity(instance);
return LoggerVerbosityLevel.getSeverity(level);
}
public void setLogVerbosity(LoggerVerbosityLevel level)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_set_log_verbosity(instance, level.ordinal(), exception);
libvlc.libvlc_set_log_verbosity(instance, level.ordinal());
}
......
......@@ -54,20 +54,17 @@ public class Logger
public void clear()
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_log_clear(logInstance, exception);
libvlc.libvlc_log_clear(logInstance);
}
public void close()
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_log_close(logInstance, exception);
libvlc.libvlc_log_close(logInstance);
}
public int count()
{
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_log_count(logInstance, exception);
return libvlc.libvlc_log_count(logInstance);
}
public Iterator<LoggerMessage> iterator()
......
......@@ -53,8 +53,7 @@ public class LoggerIterator implements Iterator<LoggerMessage>
*/
public boolean hasNext()
{
libvlc_exception_t exception = new libvlc_exception_t();
return logger.libvlc.libvlc_log_iterator_has_next(logIterator, exception) != 0;
return logger.libvlc.libvlc_log_iterator_has_next(logIterator) != 0;
}
/**
......@@ -84,8 +83,7 @@ public class LoggerIterator implements Iterator<LoggerMessage>
@Override
protected void finalize() throws Throwable
{
libvlc_exception_t exception = new libvlc_exception_t();
logger.libvlc.libvlc_log_iterator_free(logIterator, exception);
logger.libvlc.libvlc_log_iterator_free(logIterator);
super.finalize();
}
......
......@@ -68,7 +68,8 @@ public class MediaDescriptor
public String getMrl()
{
return libvlc.libvlc_media_get_mrl(instance);
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_get_mrl(instance, exception);
}
public MediaPlayer getMediaPlayer()
......
......@@ -31,28 +31,24 @@ package org.videolan.jvlc;
import java.awt.Dimension;
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class Video
{
private final LibVlcInstance libvlcInstance;
private final LibVlc libvlc;
public Video( JVLC jvlc) {
this.libvlcInstance = jvlc.getInstance();
this.libvlc = jvlc.getLibvlc();
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#destroyVideo()
/** (non-Javadoc)
* @deprecated
* @since
*/
public void destroyVideo(MediaPlayer media)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_video_destroy(media.getInstance(), exception );
return;
}
/* (non-Javadoc)
......@@ -87,48 +83,36 @@ public class Video
return libvlc.libvlc_video_get_width(media.getInstance(), exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#reparentVideo(java.awt.Component)
/**
* @deprecated
*/
public void reparent(MediaPlayer media, java.awt.Canvas canvas) {
libvlc_exception_t exception = new libvlc_exception_t();
long drawable = com.sun.jna.Native.getComponentID(canvas);
libvlc.libvlc_video_reparent(media.getInstance(), drawable, exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#resizeVideo(int, int)
/**
* @deprecated
*/
public void setSize(int width, int height) {
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_video_set_size(libvlcInstance, width, height, exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#setFullscreen(boolean)
*/
public void setFullscreen(MediaPlayer media, boolean fullscreen) {
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_set_fullscreen(media.getInstance(), fullscreen? 1 : 0, exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#toggleFullscreen()
*/
public void toggleFullscreen(MediaPlayer media) {
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_toggle_fullscreen(media.getInstance(), exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getSize()
*/
public Dimension getSize(MediaPlayer media) {
return new Dimension (getWidth(media), getHeight(media));
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#setSize(java.awt.Dimension)
/**
* @param d
* @deprecated
*/
public void setSize(Dimension d) {
setSize(d.width, d.height);
......
/*****************************************************************************
* VLC Java Bindings JNA Glue
*****************************************************************************
* Copyright (C) 1998-2009 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
* VLC bindings generator
*
*
* $Id $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
package org.videolan.jvlc.internal;
public enum MediaOption
{
libvlc_media_option_trusted, // 0x2,
libvlc_media_option_unique, // 0x100,
}
/*****************************************************************************
* VLC Java Bindings JNA Glue
*****************************************************************************
* Copyright (C) 1998-2009 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
* VLC bindings generator
*
*
* $Id $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
package org.videolan.jvlc.internal;
public enum Meta
{
libvlc_meta_Title, // 0,
libvlc_meta_Artist, // 1,
libvlc_meta_Genre, // 2,
libvlc_meta_Copyright, // 3,
libvlc_meta_Album, // 4,
libvlc_meta_TrackNumber, // 5,
libvlc_meta_Description, // 6,
libvlc_meta_Rating, // 7,
libvlc_meta_Date, // 8,
libvlc_meta_Setting, // 9,
libvlc_meta_URL, // 10,
libvlc_meta_Language, // 11,
libvlc_meta_NowPlaying, // 12,
libvlc_meta_Publisher, // 13,
libvlc_meta_EncodedBy, // 14,
libvlc_meta_ArtworkURL, // 15,
libvlc_meta_TrackID, // 16,
}
/*****************************************************************************
* VLC Java Bindings JNA Glue
*****************************************************************************
* Copyright (C) 1998-2009 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
* VLC bindings generator
*
*
* $Id $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
package org.videolan.jvlc.internal;
public enum PlaybackMode
{
libvlc_playback_mode_default, // 0,
libvlc_playback_mode_loop, // 1,
libvlc_playback_mode_repeat, // 2,
}
/*****************************************************************************
* VLC Java Bindings JNA Glue
*****************************************************************************
* Copyright (C) 1998-2009 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
* VLC bindings generator
*
*
* $Id $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
package org.videolan.jvlc.internal;
public enum VideoMarqueeIntOption
{
libvlc_marquee_Enabled, // 0,
libvlc_marquee_Color, // 1,
libvlc_marquee_Opacity, // 2,
libvlc_marquee_Position, // 3,
libvlc_marquee_Refresh, // 4,
libvlc_marquee_Size, // 5,
libvlc_marquee_Timeout, // 6,
libvlc_marquee_X, // 7,
libvlc_marquee_Y, // 8,
}
/*****************************************************************************
* VLC Java Bindings JNA Glue
*****************************************************************************
* Copyright (C) 1998-2009 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
* VLC bindings generator
*
*
* $Id $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
package org.videolan.jvlc.internal;
public enum VideoMarqueeStringOption
{
libvlc_marquee_Text, // 0,
}
......@@ -91,8 +91,7 @@ public abstract class AbstractVLCInternalTest
protected void catchException(libvlc_exception_t exception)
{
Assert.assertEquals(libvlc.libvlc_exception_get_message(exception), 0, libvlc
.libvlc_exception_raised(exception));
Assert.assertEquals(libvlc.libvlc_errmsg(), 0, libvlc.libvlc_exception_raised(exception));
}
private void downloadSample()
......
......@@ -48,7 +48,7 @@ public class LibVlcLogTest extends AbstractVLCInternalTest
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcLog libvlcLog = libvlc.libvlc_log_open(libvlcInstance, exception);
libvlc.libvlc_log_close(libvlcLog, exception);
libvlc.libvlc_log_close(libvlcLog);
Assert.assertEquals(0, exception.b_raised);
}
......@@ -57,9 +57,8 @@ public class LibVlcLogTest extends AbstractVLCInternalTest
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcLog libvlcLog = libvlc.libvlc_log_open(libvlcInstance, exception);
libvlc.libvlc_log_clear(libvlcLog, exception);
Assert.assertEquals(0, exception.b_raised);
Assert.assertEquals(0, libvlc.libvlc_log_count(libvlcLog, exception));
libvlc.libvlc_log_clear(libvlcLog);
Assert.assertEquals(0, libvlc.libvlc_log_count(libvlcLog));
}
//@Test
......@@ -67,9 +66,9 @@ public class LibVlcLogTest extends AbstractVLCInternalTest
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcLog libvlcLog = libvlc.libvlc_log_open(libvlcInstance, exception);
libvlc.libvlc_log_clear(libvlcLog, exception);
libvlc.libvlc_log_clear(libvlcLog);
Assert.assertEquals(0, exception.b_raised);
Assert.assertEquals(0, libvlc.libvlc_log_count(libvlcLog, exception));
Assert.assertEquals(0, libvlc.libvlc_log_count(libvlcLog));
LibVlcLogIterator logIterator = libvlc.libvlc_log_get_iterator(libvlcLog, exception);
Assert.assertNotNull(logIterator);
}
......
......@@ -27,7 +27,6 @@ package org.videolan.jvlc.internal;
import junit.framework.Assert;
import org.junit.After;
import org.junit.Test;
import org.videolan.jvlc.internal.LibVlc.LibVlcCallback;
import org.videolan.jvlc.internal.LibVlc.LibVlcEventManager;
......
......@@ -50,7 +50,7 @@ public class LibVlcMediaTest extends AbstractVLCInternalTest
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcMedia md = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
String mdMrl = libvlc.libvlc_media_get_mrl(md);
String mdMrl = libvlc.libvlc_media_get_mrl(md, exception);
Assert.assertEquals(mrl, mdMrl);
}
......@@ -61,7 +61,7 @@ public class LibVlcMediaTest extends AbstractVLCInternalTest
LibVlcMedia md = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
LibVlcMedia md2 = libvlc.libvlc_media_duplicate(md);
Assert.assertNotSame(md.getPointer(), md2.getPointer());
Assert.assertEquals(libvlc.libvlc_media_get_mrl(md2), libvlc.libvlc_media_get_mrl(md));
Assert.assertEquals(libvlc.libvlc_media_get_mrl(md2, exception), libvlc.libvlc_media_get_mrl(md, exception));
}
@Test
......
......@@ -31,17 +31,21 @@ import java.awt.event.WindowEvent;
import javax.swing.JPanel;
import org.videolan.jvlc.JVLC;
import org.videolan.jvlc.Playlist;
import org.videolan.jvlc.VLCException;
import org.videolan.jvlc.MediaPlayer;
class VLCPlayerFrame extends Frame
{
private Playlist playlist;
/**
*
*/
private static final long serialVersionUID = -7471950211795850421L;
public Canvas jvcanvas;
private MediaPlayer mediaPlayer;
public VLCPlayerFrame(String[] args)
{
initComponents(args);
......@@ -62,11 +66,10 @@ class VLCPlayerFrame extends Frame
jvcanvas = new java.awt.Canvas();
jvcanvas.setSize(200, 200);
jvcc.add(jvcanvas);
jvlc = new JVLC(args);
jvlc.setVideoOutput(jvcanvas);
playlist = new Playlist(jvlc);
setLayout(new java.awt.GridBagLayout());
gridBagConstraints = new java.awt.GridBagConstraints();
......@@ -150,41 +153,31 @@ class VLCPlayerFrame extends Frame
private void stopButtonActionPerformed(java.awt.event.ActionEvent evt)
{
try
{
playlist.stop();
}
catch (Exception e)
if (mediaPlayer == null)
{
e.printStackTrace();
return;
}
mediaPlayer.stop();
}
private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt)
{
try
{
playlist.togglePause();
}
catch (Exception e)
if (mediaPlayer == null)
{
e.printStackTrace();
return;
}
mediaPlayer.pause();
}
private void setButtonActionPerformed(java.awt.event.ActionEvent evt)
{
try
{
jvlc.setVideoOutput(jvcanvas);
playlist.add(jTextField1.getText(), "a.avi");
playlist.play();
}
catch (VLCException e)
if (mediaPlayer != null)
{
// TODO Auto-generated catch block
e.printStackTrace();
mediaPlayer.stop();
mediaPlayer.release();
jvcanvas = new java.awt.Canvas();
}
mediaPlayer = jvlc.play(jTextField1.getText());
}
private void fullScreenButtonActionPerformed(java.awt.event.ActionEvent evt)
......
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