Commit 08036628 authored by Rémi Duraffort's avatar Rémi Duraffort

bindings: remove java, phonon and python-ctypes. They moved to a dedicated git.

The new repositories are now on git.videolan.org/vlc/bindings/
* java => jvlc.git
* phonon => phonon.git
* python-ctypes => python.git
parent b1e53a17
.classpath
.project
.settings/*
core/.classpath
core/.project
core/.settings/*
core/target/*
samples/client/.classpath
samples/client/.project
samples/client/.settings/*
samples/client/target/*
samples/target/*
target/*
First of all, this is a *developers* only version
How to compile JVLC
-------------------
JVLC uses maven2 as a project the management tool, take a look at
http://maven.apache.org
to download and for general instructions on how to use it.
To compile the project, run from the bindings/java folder:
mvn install
To import the jvlc project into the eclipse IDE:
mvn eclipse:eclipse
and then import as an existing Java project.
How to run the sample client
----------------------------
1. mvn install (in bindings/java)
2. mvn package exec:java (in bindings/java/samples/client)
How to create the jvlc site
---------------------------
1. mvn site
Happy playing.
Thanks to:
* Adrien Grand
for splitting the maven project into modules
* Kuldipsingh Pabla
for solaris port and various contributions to the native interface.
for the GenericVideoWidget class
* Tvrtko Bedekovic
for initial win32 port
[general]
* JUnit testing
[build system]
* Detect SWT to add the SWTVideoWidget
Items are ordered by priority, the first having the highest priority
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.videolan</groupId>
<artifactId>jvlc-parent</artifactId>
<version>1.0.2-SNAPSHOT</version>
</parent>
<artifactId>jvlc-core</artifactId>
<packaging>jar</packaging>
<name>JVLC - Core</name>
<description>Java Bindings for VideoLAN - Core</description>
<licenses>
<license>
<name>GPLv2</name>
<url>http://www.gnu.org/licenses/old-licenses/gpl-2.0.html</url>
</license>
</licenses>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>3.0.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<ciManagement>
<system>Hudson</system>
<url>http://hudson.videolan.org/</url>
</ciManagement>
<repositories>
<repository>
<id>jvlc</id>
<name>JVLC Maven Repository</name>
<url>http://jvlc.ihack.it/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>central</id>
<name>Maven Repository</name>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
/*****************************************************************************
* Audio.java: VLC Java Bindings, audio methods
*****************************************************************************
*
* Copyright (C) 1998-2008 the VideoLAN team
*
* Author: 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*
*/
package org.videolan.jvlc;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class Audio
{
private final JVLC jvlc;
/**
* Constant for left channel audio
*/
public static final int LEFT_CHANNEL = 3;
/**
* Constant for right channel audio
*/
public static final int RIGHT_CHANNEL = 4;
/**
* Constant for reverse channel audio
*/
public static final int REVERSE_CHANNEL = 2;
/**
* Constant for stereo channel audio
*/
public static final int STEREO_CHANNEL = 1;
/**
* Constant for dolby channel audio
*/
public final int DOLBY_CHANNEL = 5;
public Audio(JVLC jvlc)
{
this.jvlc = jvlc;
}
public int getTrack(MediaPlayer mediaInstance)
{
libvlc_exception_t exception = new libvlc_exception_t();
return jvlc.getLibvlc().libvlc_audio_get_track(mediaInstance.getInstance(), exception);
}
public int getTrackCount(MediaPlayer mediaInstance)
{
libvlc_exception_t exception = new libvlc_exception_t();
return jvlc.getLibvlc().libvlc_audio_get_track_count(mediaInstance.getInstance(), exception);
}
public void setTrack(MediaPlayer mediaInstance, int track)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_audio_set_track(mediaInstance.getInstance(), track, exception);
}
public int getChannel()
{
libvlc_exception_t exception = new libvlc_exception_t();
return jvlc.getLibvlc().libvlc_audio_get_channel(jvlc.getInstance(), exception);
}
public void setChannel(int channel)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_audio_set_channel(jvlc.getInstance(), channel, exception);
}
public boolean getMute()
{
libvlc_exception_t exception = new libvlc_exception_t();
return jvlc.getLibvlc().libvlc_audio_get_mute(jvlc.getInstance(), exception) == 1 ? true : false;
}
public void setMute(boolean value)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_audio_set_mute(jvlc.getInstance(), value ? 1 : 0, exception);
}
public void toggleMute()
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_audio_toggle_mute(jvlc.getInstance(), exception);
}
public int getVolume()
{
libvlc_exception_t exception = new libvlc_exception_t();
return jvlc.getLibvlc().libvlc_audio_get_volume(jvlc.getInstance(), exception);
}
public void setVolume(int volume)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_audio_set_volume(jvlc.getInstance(), volume, exception);
}
}
/*****************************************************************************
* JVLC.java: Main Java Class, represents a libvlc_instance_t object
*****************************************************************************
*
* Copyright (C) 1998-2008 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
* Philippe Morin <phmorin@free.fr>
*
* Created on 28-feb-2006
*
* $Id: JVLC.java 20141 2007-05-16 19:31:35Z littlejohn $
*
* 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.awt.Canvas;
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class JVLC
{
private final LibVlcInstance instance;
private final LibVlc libvlc = LibVlc.SYNC_INSTANCE;
private VLM vlm;
private Audio audio;
private volatile boolean released;
private Canvas canvas;
public JVLC()
{
this(new String[] {});
}
public JVLC(String[] args)
{
instance = createInstance(args);
audio = new Audio(this);
}
public JVLC(String args)
{
this(args.split(" "));
}
/*
* Core methods
*/
private LibVlcInstance createInstance(String[] args)
{
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_new(args.length, args, exception);
}
public MediaPlayer play(String media)
{
MediaDescriptor mediaDescriptor = new MediaDescriptor(this, media);
MediaPlayer mediaPlayer = new MediaPlayer(mediaDescriptor);
if (canvas != null)
{
mediaPlayer.setParent(canvas);
}
mediaPlayer.play();
mediaDescriptor.release();
return mediaPlayer;
}
public void setVideoOutput(Canvas canvas)
{
this.canvas = canvas;
}
public Logger getLogger()
{
return new Logger(this);
}
public VLM getVLM()
{
if (vlm != null)
{
vlm.release();
}
this.vlm = new VLM(this);
return vlm;
}
public LoggerVerbosityLevel getLogVerbosity()
{
int level = libvlc.libvlc_get_log_verbosity(instance);
return LoggerVerbosityLevel.getSeverity(level);
}
public void setLogVerbosity(LoggerVerbosityLevel level)
{
libvlc.libvlc_set_log_verbosity(instance, level.ordinal());
}
/**
* Returns the _instance.
* @return the _instance
*/
LibVlcInstance getInstance()
{
return instance;
}
/**
* Returns the libvlc.
* @return the libvlc
*/
LibVlc getLibvlc()
{
return libvlc;
}
/**
* Releases this instance and the native resources.
*/
public void release()
{
if (released)
{
return;
}
released = true;
if (vlm != null)
{
vlm.release();
vlm = null;
}
libvlc.libvlc_release(instance);
}
/*
* (non-Javadoc)
* @see java.lang.Object#finalize()
*/
@Override
protected void finalize() throws Throwable
{
release();
super.finalize();
}
/**
* @return
*/
public Audio getAudio()
{
return audio;
}
}
/*****************************************************************************
* Logger.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import java.util.Iterator;
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlc.LibVlcLog;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class Logger
{
LibVlcLog logInstance;
LibVlc libvlc;
/**
* @param jvlc The current jvlc instance
*/
public Logger(JVLC jvlc)
{
this.libvlc = jvlc.getLibvlc();
libvlc_exception_t exception = new libvlc_exception_t();
this.logInstance = jvlc.getLibvlc().libvlc_log_open(jvlc.getInstance(), exception);
if (exception.b_raised == 1)
{
throw new RuntimeException("Native exception thrown");
}
}
public void clear()
{
libvlc.libvlc_log_clear(logInstance);
}
public void close()
{
libvlc.libvlc_log_close(logInstance);
}
public int count()
{
return libvlc.libvlc_log_count(logInstance);
}
public Iterator<LoggerMessage> iterator()
{
return new LoggerIterator(this);
}
}
/*****************************************************************************
* LoggerIterator.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import java.util.Iterator;
import org.videolan.jvlc.internal.LibVlc.LibVlcLogIterator;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
import org.videolan.jvlc.internal.LibVlc.libvlc_log_message_t;
public class LoggerIterator implements Iterator<LoggerMessage>
{
private Logger logger;
private LibVlcLogIterator logIterator;
/**
* @param logInstance
*/
LoggerIterator(Logger logger)
{
this.logger = logger;
libvlc_exception_t exception = new libvlc_exception_t();
this.logIterator = logger.libvlc.libvlc_log_get_iterator(logger.logInstance, exception);
}
/**
* {@inheritDoc}
*/
public boolean hasNext()
{
return logger.libvlc.libvlc_log_iterator_has_next(logIterator) != 0;
}
/**
* {@inheritDoc}
*/
public LoggerMessage next()
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc_log_message_t message = new libvlc_log_message_t();
logger.libvlc.libvlc_log_iterator_next(logIterator, message, exception);
LoggerMessage result = new LoggerMessage(message);
return result;
}
/**
* {@inheritDoc}
* Does not remove the element.
*/
public void remove()
{
//
}
/**
* {@inheritDoc}
*/
@Override
protected void finalize() throws Throwable
{
logger.libvlc.libvlc_log_iterator_free(logIterator);
super.finalize();
}
}
/*****************************************************************************
* LoggerMessage.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import org.videolan.jvlc.internal.LibVlc.libvlc_log_message_t;
public class LoggerMessage
{
private LoggerVerbosityLevel severity;
private String header;
private String message;
private String name;
private String type;
/**
* @param message
*/
LoggerMessage(libvlc_log_message_t message)
{
this.severity = LoggerVerbosityLevel.getSeverity(message.i_severity);
this.header = message.psz_header;
this.message = message.psz_message;
this.name = message.psz_name;
this.type = message.psz_type;
}
/**
* Returns the header.
* @return the header
*/
public String getHeader()
{
return header;
}
/**
* Returns the message.
* @return the message
*/
public String getMessage()
{
return message;
}
/**
* Returns the name.
* @return the name
*/
public String getName()
{
return name;
}
/**
* Returns the type.
* @return the type
*/
public String getType()
{
return type;
}
/**
* Returns the severity.
* @return the severity
*/
public LoggerVerbosityLevel getSeverity()
{
return severity;
}
}
/*****************************************************************************
* LoggerSeverityEnum.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
public enum LoggerVerbosityLevel {
INFO, ERROR, WARNING, DEBUG;
public static LoggerVerbosityLevel getSeverity(int ordinal)
{
return new LoggerVerbosityLevel[]{INFO, ERROR, WARNING, DEBUG }[ordinal];
}
}
/*****************************************************************************
* MediaDescriptor.java: VLC Java Bindings Media Descriptor
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlc.LibVlcEventManager;
import org.videolan.jvlc.internal.LibVlc.LibVlcMedia;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class MediaDescriptor
{
private LibVlcMedia instance;
private LibVlc libvlc;
private LibVlcEventManager eventManager;
private volatile boolean released;
private MediaPlayer mediaPlayer;
/**
* @param jvlc The jvlc instance to create the media descriptor for.
* @param media The media string
*/
public MediaDescriptor(JVLC jvlc, String media)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc = jvlc.getLibvlc();
instance = libvlc.libvlc_media_new(jvlc.getInstance(), media, exception);
eventManager = libvlc.libvlc_media_event_manager(instance, exception);
}
MediaDescriptor(JVLC jvlc, LibVlcMedia instance)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc = jvlc.getLibvlc();
this.instance = instance;
eventManager = libvlc.libvlc_media_event_manager(instance, exception);
}
public void addOption(String option)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_add_option(instance, option, exception );
}
public String getMrl()
{
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_get_mrl(instance, exception);
}
public MediaPlayer getMediaPlayer()
{
if (mediaPlayer == null)
{
this.mediaPlayer = new MediaPlayer(this);
}
return this.mediaPlayer;
}
/**
* {@inheritDoc}
*/
@Override
protected void finalize() throws Throwable
{
release();
super.finalize();
}
/**
* Returns the instance.
* @return the instance
*/
LibVlcMedia getInstance()
{
return instance;
}
/**
* Returns the libvlc.
* @return the libvlc
*/
LibVlc getLibvlc()
{
return libvlc;
}
/**
*
*/
public void release()
{
if (released)
{
return;
}
released = true;
libvlc.libvlc_media_release(instance);
}
}
/*****************************************************************************
* MediaList.java: VLC Java Bindings, MediaList
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import java.util.ArrayList;
import java.util.List;
import org.videolan.jvlc.internal.LibVlc.LibVlcEventManager;
import org.videolan.jvlc.internal.LibVlc.LibVlcMedia;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaList;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class MediaList
{
private final JVLC jvlc;
private final LibVlcMediaList instance;
private List<String> items = new ArrayList<String>();
private LibVlcEventManager eventManager;
private volatile boolean released;
public MediaList(JVLC jvlc)
{
this.jvlc = jvlc;
libvlc_exception_t exception = new libvlc_exception_t();
instance = jvlc.getLibvlc().libvlc_media_list_new(jvlc.getInstance(), exception);
eventManager = jvlc.getLibvlc().libvlc_media_list_event_manager(instance, exception);
}
/**
* @param mrl The media resource locator to add to the media list.
*/
public void addMedia(String mrl)
{
MediaDescriptor descriptor = new MediaDescriptor(jvlc, mrl);
addMedia(descriptor);
}
/**
* @param descriptor The media descriptor to add to the media list.
*/
public void addMedia(MediaDescriptor descriptor)
{
if (items.contains(descriptor.getMrl()))
{
return;
}
items.add(descriptor.getMrl());
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_add_media(instance, descriptor.getInstance(), exception);
}
/**
* @return The current number of items in the media list.
*/
public int size()
{
libvlc_exception_t exception = new libvlc_exception_t();
return jvlc.getLibvlc().libvlc_media_list_count(instance, exception);
}
/**
* @param descriptor The media descriptor to get the index of.
* @return The index of the media descriptor, or -1 if not found.
*/
public int indexOf(MediaDescriptor descriptor)
{
libvlc_exception_t exception = new libvlc_exception_t();
return jvlc.getLibvlc().libvlc_media_list_index_of_item(instance, descriptor.getInstance(), exception);
}
/**
* @param index The index of the media descriptor to get.
* @return The media descriptor at the given index.
* @throws IndexOutOfBoundsException if index is bigger than size() or < 0, or there are no items in the media_list.
*/
public MediaDescriptor getMediaDescriptorAtIndex(int index)
{
libvlc_exception_t exception = new libvlc_exception_t();
if (size() == 0)
{
throw new IndexOutOfBoundsException();
}
if (index < 0 || index > size())
{
throw new IndexOutOfBoundsException();
}
LibVlcMedia descriptor = jvlc.getLibvlc().libvlc_media_list_item_at_index(instance, index, exception);
return new MediaDescriptor(jvlc, descriptor);
}
/**
* @param index The index of the media to remove.
* @return True if the media was successfully removed, false otherwise.
*/
public boolean removeMedia(int index)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_remove_index(instance, index, exception);
if (exception.b_raised == 0)
{
items.remove(index);
return true;
}
return false;
}
/**
* @param mrl The media descriptor mrl.
*/
public boolean removeMedia(String mrl)
{
int index = items.indexOf(mrl);
if (index == -1)
{
return false;
}
return removeMedia(index);
}
/**
* @param mediaDescriptor The media descriptor to remove.
*/
public boolean removeMedia(MediaDescriptor mediaDescriptor)
{
String mrl = mediaDescriptor.getMrl();
int index = items.indexOf(mrl);
if (index == -1)
{
return false;
}
return removeMedia(index);
}
/**
* Removes all items from the media list.
*/
public void clear()
{
for (int i = 0; i < size(); i++)
{
removeMedia(i);
}
}
/**
* @param descriptor The media descriptor to insert.
* @param index The index of the inserted media descriptor.
*/
public void insertMediaDescriptor(MediaDescriptor descriptor, int index)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc
.getLibvlc()
.libvlc_media_list_insert_media(instance, descriptor.getInstance(), index, exception);
}
/**
* {@inheritDoc}
*/
@Override
protected void finalize() throws Throwable
{
release();
super.finalize();
}
/**
* Returns the instance.
* @return the instance
*/
LibVlcMediaList getInstance()
{
return instance;
}
/**
*
*/
public void release()
{
if (released)
{
return;
}
released = true;
jvlc.getLibvlc().libvlc_media_list_release(instance);
}
}
/*****************************************************************************
* MediaListPlayer.java: VLC Java Bindings, MediaList player
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaListPlayer;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class MediaListPlayer
{
private final LibVlcMediaListPlayer instance;
private final JVLC jvlc;
private volatile boolean released;
public MediaListPlayer(JVLC jvlc)
{
libvlc_exception_t exception = new libvlc_exception_t();
this.jvlc = jvlc;
instance = jvlc.getLibvlc().libvlc_media_list_player_new(jvlc.getInstance(), exception);
}
public void setMediaList(MediaList list)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_set_media_list(instance, list.getInstance(), exception);
}
public boolean isPlaying()
{
libvlc_exception_t exception = new libvlc_exception_t();
return jvlc.getLibvlc().libvlc_media_list_player_is_playing(instance, exception) == 1;
}
/**
*
*/
public void play()
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_play(instance, exception);
try
{
while (jvlc.getLibvlc().libvlc_media_list_player_is_playing(instance, exception) == 0)
{
Thread.sleep(25);
}
}
catch(InterruptedException e)
{
//
}
}
public void stop()
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_stop(instance, exception);
}
public void pause()
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_pause(instance, exception);
}
public void next()
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_next(instance, exception);
}
/**
* Plays the given descriptor and returns only when the player has started to play.
* @param descriptor The media descriptor to play
*/
public void playItem(MediaDescriptor descriptor)
{
playItem(descriptor, true);
}
/**
* @param descriptor The media descriptor to play
* @param synchronous If true it does not return until the player is not playing.
*/
public void playItem(MediaDescriptor descriptor, boolean synchronous)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_play_item(instance, descriptor.getInstance(), exception);
if (!synchronous)
{
return;
}
try
{
while (jvlc.getLibvlc().libvlc_media_list_player_is_playing(instance, exception) == 0)
{
Thread.sleep(25);
}
}
catch(InterruptedException e)
{
//
}
}
/**
* Plays the item at the given index and returns only when the player has started to play.
* @param index The item index to play.
*/
public void playItem(int index)
{
playItem(index, true);
}
/**
* @param index The item index to play.
* @param synchronous If true it does not return until the player is not playing.
*/
public void playItem(int index, boolean synchronous)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_play_item_at_index(instance, index, exception);
try
{
while (jvlc.getLibvlc().libvlc_media_list_player_is_playing(instance, exception) == 0)
{
Thread.sleep(25);
}
}
catch(InterruptedException e)
{
//
}
}
public void setMediaInstance(MediaPlayer mediaInstance)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_media_list_player_set_media_player(instance, mediaInstance.getInstance(), exception);
}
/**
* {@inheritDoc}
*/
@Override
protected void finalize() throws Throwable
{
release();
super.finalize();
}
/**
*
*/
public void release()
{
if (released)
{
return;
}
released = true;
jvlc.getLibvlc().libvlc_media_list_player_release(instance);
}
}
/*****************************************************************************
* MediaInstance.java: VLC Java Bindings Media Instance
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import java.awt.Canvas;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import org.videolan.jvlc.event.MediaPlayerCallback;
import org.videolan.jvlc.event.MediaPlayerListener;
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlcEventType;
import org.videolan.jvlc.internal.LibVlc.LibVlcEventManager;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaPlayer;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
import com.sun.jna.Native;
import com.sun.jna.Platform;
public class MediaPlayer
{
private final LibVlcMediaPlayer instance;
private final LibVlc libvlc;
private final LibVlcEventManager eventManager;
private List<MediaPlayerCallback> callbacks = new ArrayList<MediaPlayerCallback>();
private MediaDescriptor mediaDescriptor;
private volatile boolean released;
MediaPlayer(JVLC jvlc, LibVlcMediaPlayer instance)
{
libvlc_exception_t exception = new libvlc_exception_t();
this.instance = instance;
libvlc = jvlc.getLibvlc();
eventManager = libvlc.libvlc_media_player_event_manager(instance, exception);
}
public MediaPlayer(MediaDescriptor mediaDescriptor)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc = mediaDescriptor.getLibvlc();
instance = libvlc.libvlc_media_player_new_from_media(mediaDescriptor.getInstance(), exception);
eventManager = libvlc.libvlc_media_player_event_manager(instance, exception);
this.mediaDescriptor = mediaDescriptor;
}
public MediaDescriptor getMediaDescriptor()
{
return mediaDescriptor;
}
public void play()
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_player_play(instance, exception);
}
public void stop()
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_player_stop(instance, exception);
}
public void pause()
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_player_pause(instance, exception);
}
public long getLength()
{
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_player_get_length(instance, exception);
}
public long getTime()
{
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_player_get_time(instance, exception);
}
public void setTime(long time)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_player_set_time(instance, time, exception);
}
public float getPosition()
{
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_player_get_position(instance, exception);
}
public void setPosition(float position)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_player_set_position(instance, position, exception);
}
public boolean willPlay()
{
libvlc_exception_t exception = new libvlc_exception_t();
return (libvlc.libvlc_media_player_will_play(instance, exception) == 1);
}
public float getRate()
{
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_player_get_rate(instance, exception);
}
public void setRate(float rate)
{
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_media_player_set_rate(instance, rate, exception);
}
public boolean hasVideoOutput()
{
libvlc_exception_t exception = new libvlc_exception_t();
return (libvlc.libvlc_media_player_has_vout(instance, exception) == 1);
}
public float getFPS()
{
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_player_get_fps(instance, exception);
}
public boolean isPlaying()
{
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_media_player_is_playing(instance, exception) == 1 ? true : false;
}
public void addListener(final MediaPlayerListener listener)
{
MediaPlayerCallback callback = new MediaPlayerCallback(this, listener);
libvlc_exception_t exception = new libvlc_exception_t();
for (LibVlcEventType event : EnumSet.range(
LibVlcEventType.libvlc_MediaPlayerPlaying,
LibVlcEventType.libvlc_MediaPlayerTimeChanged))
{
libvlc.libvlc_event_attach(eventManager, event.ordinal(), callback, null, exception);
}
callbacks.add(callback);
}
public void setParent(Canvas canvas)
{
long drawable = Native.getComponentID(canvas);
libvlc_exception_t exception = new libvlc_exception_t();
if (Platform.isWindows())
{
libvlc.libvlc_media_player_set_hwnd(instance, drawable, exception);
}
else
{
libvlc.libvlc_media_player_set_xwindow(instance, drawable, exception);
}
}
/**
* {@inheritDoc}
*/
@Override
protected void finalize() throws Throwable
{
release();
super.finalize();
}
public void release()
{
if (released)
{
return;
}
released = true;
libvlc_exception_t exception = new libvlc_exception_t();
for (MediaPlayerCallback callback : callbacks)
{
for (LibVlcEventType event : EnumSet.range(
LibVlcEventType.libvlc_MediaPlayerPlaying,
LibVlcEventType.libvlc_MediaPlayerPositionChanged))
{
libvlc.libvlc_event_detach(eventManager, event.ordinal(), callback, null, exception);
}
}
libvlc.libvlc_media_player_release(instance);
}
/**
* Returns the instance.
* @return the instance
*/
LibVlcMediaPlayer getInstance()
{
return instance;
}
}
/*****************************************************************************
* 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
{
/**
*
*/
private static final long serialVersionUID = -3063632323017889L;
public VLCException()
{
super();
}
public VLCException(String message)
{
super(message);
}
public VLCException(String message, Throwable cause)
{
super(message, cause);
}
public VLCException(Throwable cause)
{
super(cause);
}
}
/*****************************************************************************
* VLM.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class VLM
{
private JVLC jvlc;
private volatile boolean released;
public VLM(JVLC jvlc)
{
this.jvlc = jvlc;
}
public void addBroadcast(String name, String input, String output, String[] options, boolean enabled, boolean loop)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_add_broadcast(
jvlc.getInstance(),
name,
input,
output,
options == null ? 0 : options.length,
options,
enabled ? 1 : 0,
loop ? 1 : 0,
exception);
}
public void addVod(String name, String input, String[] options, boolean enabled, String muxer)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_add_vod(
jvlc.getInstance(),
name,
input,
options == null ? 0 : options.length,
options,
enabled ? 1 : 0,
muxer,
exception);
}
public void deleteMedia(String name)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_del_media(jvlc.getInstance(), name, exception);
}
public void enableMedia(String name)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_set_enabled(jvlc.getInstance(), name, 1, exception);
}
public void disableMedia(String name)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_set_enabled(jvlc.getInstance(), name, 0, exception);
}
public void setMediaOutput(String name, String output)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_set_output(jvlc.getInstance(), name, output, exception);
}
public void setMediaInput(String name, String input)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_set_input(jvlc.getInstance(), name, input, exception);
}
public void addMediaInput(String name, String input)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_add_input(jvlc.getInstance(), name, input, exception);
}
public void setMux(String name, String muxer)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_set_mux(jvlc.getInstance(), name, muxer, exception);
}
public void setMediaLoop(String media, boolean loop)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_set_loop(jvlc.getInstance(), media, loop ? 1 : 0, exception);
}
public void changeMedia(String name, String input, String output, String[] options, boolean enabled, boolean loop)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_change_media(
jvlc.getInstance(),
name,
input,
output,
options == null ? 0 : options.length,
options,
enabled ? 1 : 0,
loop ? 1 : 0,
exception);
}
public void playMedia(String name)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_play_media(jvlc.getInstance(), name, exception);
}
public void stopMedia(String name)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_stop_media(jvlc.getInstance(), name, exception);
}
public void pauseMedia(String name)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_pause_media(jvlc.getInstance(), name, exception);
}
public void seekMedia(String name, float percentage)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_seek_media(jvlc.getInstance(), name, percentage, exception);
}
public void showMedia(String name)
{
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_show_media(jvlc.getInstance(), name, exception);
}
/**
* Releases native resources related to VLM.
*/
public void release()
{
if (released)
{
return;
}
released = true;
libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_release(jvlc.getInstance(), exception);
}
/**
* {@inheritDoc}
*/
@Override
protected void finalize() throws Throwable
{
release();
super.finalize();
}
}
/*****************************************************************************
* Video.java: JVLC Video Output
*****************************************************************************
*
* Copyright (C) 1998-2008 the VideoLAN team
*
* Author: Filippo Carone <filippo@carone.org>
* Philippe Morin <phmorin@free.fr>
*
* Created on 28-feb-2006
*
* $Id: JVLC.java 20141 2007-05-16 19:31:35Z littlejohn $
*
* 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.awt.Dimension;
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class Video
{
private final LibVlc libvlc;
public Video( JVLC jvlc) {
this.libvlc = jvlc.getLibvlc();
}
/** (non-Javadoc)
* @deprecated
* @since
*/
public void destroyVideo(MediaPlayer media)
{
return;
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getFullscreen()
*/
public boolean getFullscreen(MediaPlayer media) {
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_get_fullscreen(media.getInstance(), exception) == 1 ? true : false;
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getSnapshot(java.lang.String)
*/
public void getSnapshot(MediaPlayer media, String filepath, int width, int height) {
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_video_take_snapshot(media.getInstance(), filepath, width, height, exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getVideoHeight()
*/
public int getHeight(MediaPlayer media) {
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_video_get_height(media.getInstance(), exception);
}
/* (non-Javadoc)
* @see org.videolan.jvlc.VideoIntf#getVideoWidth()
*/
public int getWidth(MediaPlayer media) {
libvlc_exception_t exception = new libvlc_exception_t();
return libvlc.libvlc_video_get_width(media.getInstance(), exception);
}
/**
* @deprecated
*/
public void reparent(MediaPlayer media, java.awt.Canvas canvas) {
}
/**
* @deprecated
*/
public void setSize(int width, int height) {
}
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);
}
public void toggleFullscreen(MediaPlayer media) {
libvlc_exception_t exception = new libvlc_exception_t();
libvlc.libvlc_toggle_fullscreen(media.getInstance(), exception);
}
public Dimension getSize(MediaPlayer media) {
return new Dimension (getWidth(media), getHeight(media));
}
/**
* @param d
* @deprecated
*/
public void setSize(Dimension d) {
setSize(d.width, d.height);
}
}
/*****************************************************************************
* MediaInstancePlayCallback.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc.event;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.videolan.jvlc.MediaPlayer;
import org.videolan.jvlc.internal.LibVlc;
import org.videolan.jvlc.internal.LibVlcEventType;
import org.videolan.jvlc.internal.LibVlc.LibVlcCallback;
import org.videolan.jvlc.internal.LibVlc.libvlc_event_t;
import org.videolan.jvlc.internal.LibVlc.media_player_time_changed;
import com.sun.jna.Pointer;
public class MediaPlayerCallback implements LibVlcCallback
{
private MediaPlayerListener listener;
private MediaPlayer mediaPlayer;
/**
* Logger.
*/
private Logger log = LoggerFactory.getLogger(MediaPlayerCallback.class);
public MediaPlayerCallback(MediaPlayer mediaInstance, MediaPlayerListener listener)
{
this.mediaPlayer = mediaInstance;
this.listener = listener;
}
/**
* {@inheritDoc}
*/
public void callback(libvlc_event_t libvlc_event, Pointer userData)
{
if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPlaying.ordinal())
{
listener.playing(mediaPlayer);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPaused.ordinal())
{
listener.paused(mediaPlayer);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerEndReached.ordinal())
{
listener.endReached(mediaPlayer);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPositionChanged.ordinal())
{
listener.positionChanged(mediaPlayer);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerStopped.ordinal())
{
listener.stopped(mediaPlayer);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerTimeChanged.ordinal())
{
libvlc_event.event_type_specific.setType(LibVlc.media_player_time_changed.class);
LibVlc.media_player_time_changed timeChanged = (media_player_time_changed) libvlc_event.event_type_specific
.readField("media_player_time_changed");
listener.timeChanged(mediaPlayer, timeChanged.new_time);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerEncounteredError.ordinal())
{
log.warn("Media player encountered error.");
listener.errorOccurred(mediaPlayer);
}
else
{
log.debug("Unsupported event error. Event id: {}", libvlc_event.type);
}
}
}
/*****************************************************************************
* mediaPlayerPlayListener.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc.event;
import org.videolan.jvlc.MediaPlayer;
public interface MediaPlayerListener
{
void playing(MediaPlayer mediaPlayer);
void paused(MediaPlayer mediaPlayer);
void stopped(MediaPlayer mediaPlayer);
void endReached(MediaPlayer mediaPlayer);
void timeChanged(MediaPlayer mediaPlayer, long newTime);
void positionChanged(MediaPlayer mediaPlayer);
void errorOccurred(MediaPlayer mediaPlayer);
}
package org.videolan.jvlc.example;
import org.videolan.jvlc.Audio;
import org.videolan.jvlc.JVLC;
import org.videolan.jvlc.MediaDescriptor;
import org.videolan.jvlc.MediaPlayer;
import org.videolan.jvlc.Video;
import org.videolan.jvlc.event.MediaPlayerListener;
public class VLCExample
{
public static void main(String[] args) throws InterruptedException
{
System.out.println("== Starting VLCExample ==");
if (args.length == 0)
{
System.out.print("Creating a JVLC instance without args");
}
else
{
System.out.println("Creating a JVLC instance with args: ");
for (int i = 0; i < args.length; i++)
{
System.out.println(i + ") " + args[i]);
}
}
JVLC jvlc = new JVLC(args);
System.out.println("... done.");
MediaDescriptor mediaDescriptor = new MediaDescriptor(jvlc, "/home/carone/apps/a.avi");
MediaPlayer mediaPlayer = mediaDescriptor.getMediaPlayer();
mediaPlayer.addListener(new MediaPlayerListener()
{
public void endReached(MediaPlayer mediaPlayer)
{
System.out.println("Media instance end reached. MRL: " + mediaPlayer.getMediaDescriptor().getMrl());
}
public void paused(MediaPlayer mediaPlayer)
{
System.out.println("Media instance paused. MRL: " + mediaPlayer.getMediaDescriptor().getMrl());
}
public void playing(MediaPlayer mediaPlayer)
{
System.out.println("Media instance played. MRL: " + mediaPlayer.getMediaDescriptor().getMrl());
}
public void positionChanged(MediaPlayer mediaPlayer)
{
// TODO Auto-generated method stub
}
public void timeChanged(MediaPlayer mediaPlayer, long newTime)
{
System.out.println("new time: " + newTime);
}
public void stopped(MediaPlayer mediaPlayer)
{
System.out.println("Media player stopped. MRL: " + mediaPlayer.getMediaDescriptor().getMrl());
}
public void errorOccurred(MediaPlayer mediaPlayer)
{
System.out.println("An error has occurred.");
}
});
mediaPlayer.play();
while (!mediaPlayer.hasVideoOutput())
{
Thread.sleep(100);
}
Video video = new Video(jvlc);
System.out.print(video.getWidth(mediaPlayer));
System.out.print("x");
System.out.println(video.getHeight(mediaPlayer));
System.out.print("Fullscreen... ");
video.setFullscreen(mediaPlayer, true);
Thread.sleep(3000);
System.out.println("real size.");
video.setFullscreen(mediaPlayer, false);
System.out.print("Taking snapshot... ");
video.getSnapshot(mediaPlayer, System.getProperty("user.dir") + "/snap.png", 0, 0);
System.out.println("taken. (see " + System.getProperty("user.dir") + "/snap.png )");
Thread.sleep(2000);
System.out.println("Resizing to 300x300");
video.setSize(300, 300);
System.out.print("Muting...");
Audio audio = new Audio(jvlc);
audio.setMute(true);
Thread.sleep(3000);
System.out.println("unmuting.");
audio.setMute(false);
Thread.sleep(3000);
System.out.println("Volume is: " + audio.getVolume());
System.out.print("Setting volume to 150... ");
audio.setVolume(150);
System.out.println("done");
System.out.println("== AUDIO INFO ==");
System.out.println("Audio track number: " + audio.getTrack(mediaPlayer));
System.out.println("Audio channel info: " + audio.getChannel());
Thread.sleep(3000);
System.out.println("MEDIA PLAYER INFORMATION");
System.out.println("--------------------------");
System.out.println("Total length (ms) :\t" + mediaPlayer.getLength());
System.out.println("Input time (ms) :\t" + mediaPlayer.getTime());
System.out.println("Input position [0-1]:\t" + mediaPlayer.getPosition());
System.out.println("Input FPS :\t" + mediaPlayer.getFPS());
System.out.println("Everything fine ;)");
return;
}
}
/*****************************************************************************
* LibVlcEventType.java: VLC Java Bindings event types enum
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc.internal;
public enum LibVlcEventType {
libvlc_MediaMetaChanged, // 0
libvlc_MediaSubItemAdded, // 1
libvlc_MediaDurationChanged, // 2
libvlc_MediaPreparsedChanged, // 3
libvlc_MediaFreed, // 4
libvlc_MediaStateChanged, // 5
libvlc_MediaPlayerNothingSpecial, // 6
libvlc_MediaPlayerOpening, // 7
libvlc_MediaPlayerBuffering, // 8
libvlc_MediaPlayerPlaying, // 9
libvlc_MediaPlayerPaused, // 10
libvlc_MediaPlayerStopped, // 11
libvlc_MediaPlayerForward, // 12
libvlc_MediaPlayerBackward, // 13
libvlc_MediaPlayerEndReached, // 14
libvlc_MediaPlayerEncounteredError, // 15
libvlc_MediaPlayerTimeChanged, // 16
libvlc_MediaPlayerPositionChanged, // 17
libvlc_MediaPlayerSeekableChanged, // 18
libvlc_MediaPlayerPausableChanged, // 19
libvlc_MediaListItemAdded, // 20
libvlc_MediaListWillAddItem, // 21
libvlc_MediaListItemDeleted, // 22
libvlc_MediaListWillDeleteItem, // 23
libvlc_MediaListViewItemAdded, // 24
libvlc_MediaListViewWillAddItem, // 25
libvlc_MediaListViewItemDeleted, // 26
libvlc_MediaListViewWillDeleteItem, // 27
libvlc_MediaListPlayerPlayed, // 28
libvlc_MediaListPlayerNextItemSet, // 29
libvlc_MediaListPlayerStopped, // 30
libvlc_MediaDiscovererStarted, // 31
libvlc_MediaDiscovererEnded, // 32
libvlc_MediaPlayerTitleChanged, // 33
libvlc_MediaPlayerSnapshotTaken, // 34
libvlc_MediaPlayerLengthChanged, // 35
libvlc_VlmMediaAdded, // 36
libvlc_VlmMediaRemoved, // 37
libvlc_VlmMediaChanged, // 38
libvlc_VlmMediaInstanceStarted, // 39
libvlc_VlmMediaInstanceStopped, // 40
libvlc_VlmMediaInstanceStatusInit, // 41
libvlc_VlmMediaInstanceStatusOpening, // 42
libvlc_VlmMediaInstanceStatusPlaying, // 43
libvlc_VlmMediaInstanceStatusPause, // 44
libvlc_VlmMediaInstanceStatusEnd, // 45
libvlc_VlmMediaInstanceStatusError; // 46
}
/*****************************************************************************
* ${file_name}: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2007 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.
*****************************************************************************/
package org.videolan.jvlc.internal;
import java.awt.Canvas;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.videolan.jvlc.internal.LibVlc.LibVlcCallback;
import org.videolan.jvlc.internal.LibVlc.LibVlcEventManager;
import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
import org.videolan.jvlc.internal.LibVlc.LibVlcMedia;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaPlayer;
import org.videolan.jvlc.internal.LibVlc.libvlc_event_t;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
public class LibVlcImpl
{
public static boolean done;
public static void main(String[] args) throws InterruptedException
{
LibVlc libVlc = LibVlc.SYNC_INSTANCE;
libvlc_exception_t exception = new libvlc_exception_t();
libVlc.libvlc_exception_init(exception);
final Object lock = new Object();
System.out.println("Starting vlc");
System.out.println("version: " + libVlc.libvlc_get_version());
System.out.println("changeset: " + libVlc.libvlc_get_changeset());
System.out.println("compiler: " + libVlc.libvlc_get_compiler());
LibVlcInstance libvlc_instance_t = libVlc.libvlc_new(0, new String[] {"/usr/local/bin/vlc"}, exception);
LibVlcMedia mediaDescriptor = libVlc
.libvlc_media_new(libvlc_instance_t, "/home/carone/apps/a.avi", exception);
LibVlcMediaPlayer mediaPlayer = libVlc.libvlc_media_player_new_from_media(mediaDescriptor, exception);
LibVlcEventManager mediaInstanceEventManager = libVlc.libvlc_media_player_event_manager(mediaPlayer, exception);
LibVlcCallback played = new LibVlcCallback()
{
public void callback(libvlc_event_t libvlc_event_t, Pointer pointer)
{
System.out.println("Playing started.");
}
};
LibVlcCallback endReached = new LibVlcCallback()
{
public void callback(libvlc_event_t libvlc_event_t, Pointer pointer)
{
synchronized (lock)
{
System.out.println("Playing finished.");
LibVlcImpl.done = true;
}
}
};
libVlc.libvlc_event_attach(
mediaInstanceEventManager,
LibVlcEventType.libvlc_MediaPlayerPlaying.ordinal(),
played,
null,
exception);
libVlc.libvlc_event_attach(
mediaInstanceEventManager,
LibVlcEventType.libvlc_MediaPlayerEndReached.ordinal(),
endReached,
null,
exception);
JFrame frame = new JFrame("title");
frame.setVisible(true);
frame.setLocation(100, 100);
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
Canvas canvas = new Canvas();
canvas.setSize(500, 500);
panel.add(canvas);
frame.getContentPane().add(panel);
frame.pack();
int drawable = (int) com.sun.jna.Native.getComponentID(canvas);
if (Platform.isWindows())
{
libVlc.libvlc_media_player_set_hwnd(mediaPlayer, drawable, exception);
}
else
{
libVlc.libvlc_media_player_set_xwindow(mediaPlayer, drawable, exception);
}
libVlc.libvlc_media_player_play(mediaPlayer, exception);
}
}
/*****************************************************************************
* LibVlcState.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc.internal;
public enum LibVlcState
{
libvlc_NothingSpecial, // 0
libvlc_Opening, // 1
libvlc_Buffering, // 2
libvlc_Playing, // 3
libvlc_Paused, // 4
libvlc_Stopped, // 5
libvlc_Ended, // 6
libvlc_Error; // 7
}
/*****************************************************************************
* 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,
}
/*****************************************************************************
* AbstractJVLCTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.videolan.jvlc.internal.AbstractVLCInternalTest;
public abstract class AbstractJVLCTest
{
protected JVLC jvlc;
protected String mrl;
private String address = "http://streams.videolan.org/streams-videolan/avi/Hero-Div3.avi";
/**
* Logger.
*/
private Logger log = LoggerFactory.getLogger(AbstractVLCInternalTest.class);
@Before
public void testSetup()
{
jvlc = new JVLC("-vvv --ignore-config --no-media-library -I dummy -A dummy -V dummy --rtsp-host 127.0.0.1:5554");
jvlc.setLogVerbosity(LoggerVerbosityLevel.DEBUG);
downloadSample();
}
@After
public void tearDown()
{
jvlc.release();
}
private void downloadSample()
{
OutputStream out = null;
URLConnection conn = null;
InputStream in = null;
URL sampleResource = this.getClass().getResource("/sample.avi");
if (sampleResource != null)
{
log.debug("Sample file already downloaded");
mrl = sampleResource.getPath();
return;
}
try
{
log.info("Downloading sample: {}", address);
String testResoucesPath = this.getClass().getResource("/sample").getPath();
URL url = new URL(address);
out = new BufferedOutputStream(new FileOutputStream(testResoucesPath + ".avi"));
conn = url.openConnection();
in = conn.getInputStream();
byte[] buffer = new byte[1024];
int numRead;
long numWritten = 0;
while ((numRead = in.read(buffer)) != -1)
{
out.write(buffer, 0, numRead);
numWritten += numRead;
}
log.info("Sample downloaded.");
mrl = testResoucesPath + ".avi";
}
catch (Exception e)
{
log.error("{}", e);
}
finally
{
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
}
}
/*****************************************************************************
* JVLCTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import junit.framework.Assert;
import org.junit.Test;
public class JVLCTest extends AbstractJVLCTest
{
String mrl = getClass().getResource("/raffa_voice.ogg").getFile();
@Test
public void jvlcNew()
{
JVLC jvlc = new JVLC();
Assert.assertNotNull(jvlc.getAudio());
}
@Test
public void jvlcPlay()
{
MediaPlayer instance = jvlc.play(mrl);
Assert.assertNotNull(instance);
}
@Test
public void jvlcRelease()
{
JVLC jvlc = new JVLC();
jvlc.release();
}
@Test
public void jvlcMultipleInstances()
{
JVLC[] jvlcInstancesArray = new JVLC[10];
for (int i = 0; i < jvlcInstancesArray.length; i++)
{
jvlcInstancesArray[i] = new JVLC();
}
for (int i = 0; i < jvlcInstancesArray.length; i++)
{
jvlcInstancesArray[i].release();
}
}
@Test
public void twoAudioInstancesTest() throws Exception
{
JVLC instance1 = new JVLC();
JVLC instance2 = new JVLC();
instance1.play(mrl);
instance2.play(mrl);
Thread.sleep(1000);
instance1.getAudio().setMute(true);
Assert.assertNotNull(instance2.getAudio());
Assert.assertTrue(instance1.getAudio().getMute());
Assert.assertTrue(!instance2.getAudio().getMute());
}
}
/*****************************************************************************
* LoggerTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import java.util.Iterator;
import junit.framework.Assert;
import org.junit.Test;
public class LoggerTest extends AbstractJVLCTest
{
@Test
public void testLogDebug()
{
jvlc.setLogVerbosity(LoggerVerbosityLevel.DEBUG);
Logger logger = jvlc.getLogger();
jvlc.play(mrl);
Assert.assertTrue(logger.count() > 0);
logger.close();
}
/**
* Timeout added because of a poor spinlock usage in the native side.
*/
// @Test(timeout = 5000L)
public void testLogError()
{
jvlc.setLogVerbosity(LoggerVerbosityLevel.DEBUG);
Logger logger = jvlc.getLogger();
logger.clear();
Assert.assertEquals(0, logger.count());
jvlc.play(mrl);
Iterator<LoggerMessage> loggerIterator = logger.iterator();
while (loggerIterator.hasNext())
{
LoggerMessage message = loggerIterator.next();
Assert.assertNotNull(message.getMessage());
}
logger.close();
}
}
/*****************************************************************************
* MediaDescriptorTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import org.junit.Assert;
import org.junit.Test;
public class MediaDescriptorTest extends AbstractJVLCTest
{
@Test
public void getMrlTest()
{
MediaDescriptor md = new MediaDescriptor(jvlc, mrl);
Assert.assertEquals(mrl, md.getMrl());
}
@Test
public void getMediaPlayer()
{
MediaDescriptor md = new MediaDescriptor(jvlc, mrl);
MediaPlayer mp = md.getMediaPlayer();
Assert.assertNotNull(mp);
MediaPlayer mp2 = md.getMediaPlayer();
Assert.assertSame(mp, mp2);
}
}
/*****************************************************************************
* MediaListTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import org.junit.Assert;
import org.junit.Test;
public class MediaListTest extends AbstractJVLCTest
{
@Test
public void mediaListAddMedia()
{
MediaList mlist = new MediaList(jvlc);
mlist.addMedia(mrl);
Assert.assertEquals(1, mlist.size());
}
@Test
public void mediaListAddMedia2()
{
MediaList mlist = new MediaList(jvlc);
mlist.addMedia(mrl);
Assert.assertEquals(1, mlist.size());
mlist.addMedia(mrl);
Assert.assertEquals(1, mlist.size());
mlist.addMedia(new MediaDescriptor(jvlc, mrl));
Assert.assertEquals(1, mlist.size());
mlist.addMedia("non-existing");
Assert.assertEquals(2, mlist.size());
}
@Test
public void mediaListRemoveMedia()
{
MediaList mlist = new MediaList(jvlc);
mlist.addMedia(mrl);
Assert.assertEquals(1, mlist.size());
mlist.removeMedia(0);
Assert.assertEquals(0, mlist.size());
}
@Test
public void mediaListRemoveMedia2()
{
MediaList mlist = new MediaList(jvlc);
mlist.addMedia(mrl);
Assert.assertEquals(1, mlist.size());
mlist.removeMedia(0);
Assert.assertEquals(0, mlist.size());
mlist.addMedia(mrl);
mlist.removeMedia(0);
Assert.assertEquals(0, mlist.size());
mlist.addMedia(new MediaDescriptor(jvlc, mrl));
mlist.removeMedia(0);
Assert.assertEquals(0, mlist.size());
mlist.addMedia(new MediaDescriptor(jvlc, mrl));
mlist.removeMedia(mrl);
Assert.assertEquals(0, mlist.size());
mlist.addMedia(new MediaDescriptor(jvlc, mrl));
mlist.removeMedia(new MediaDescriptor(jvlc, mrl));
Assert.assertEquals(0, mlist.size());
}
@Test
public void mediaListRemoveNonExistingMedia()
{
MediaList mlist = new MediaList(jvlc);
boolean result = mlist.removeMedia(3);
Assert.assertFalse(result);
}
@Test
public void mediaListIndexOfNonExistingMediaDescriptor()
{
MediaList mlist = new MediaList(jvlc);
MediaDescriptor md = new MediaDescriptor(jvlc, "dummy");
int result = mlist.indexOf(md);
Assert.assertEquals(-1, result);
}
@Test(expected = IndexOutOfBoundsException.class)
public void mediaListGetMediaDesciptorAtInvalidIndex()
{
MediaList mlist = new MediaList(jvlc);
mlist.getMediaDescriptorAtIndex(5);
}
@Test(expected = IndexOutOfBoundsException.class)
public void mediaListGetMediaDesciptorAtInvalidIndex2()
{
MediaList mlist = new MediaList(jvlc);
mlist.getMediaDescriptorAtIndex(-5);
}
@Test(expected = IndexOutOfBoundsException.class)
public void mediaListGetMediaDesciptorAtInvalidIndex3()
{
MediaList mlist = new MediaList(jvlc);
mlist.getMediaDescriptorAtIndex(0);
}
}
/*****************************************************************************
* VLMTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc;
import junit.framework.Assert;
import org.junit.Test;
public class VLMTest extends AbstractJVLCTest
{
private String mediaName = "test";
@Test
public void testVLMInit()
{
VLM vlm = jvlc.getVLM();
Assert.assertNotNull(vlm);
}
//@Test
public void testAddBroadcast()
{
VLM vlm = jvlc.getVLM();
vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
}
//@Test(timeout = 2000L)
public void testAddVod()
{
VLM vlm = jvlc.getVLM();
vlm.addVod(mediaName, "file://" + mrl, null, true, null);
}
//@Test
public void testShowBroadcastMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
vlm.showMedia(mediaName);
}
//@Test
public void testShowVodMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addVod(mediaName, "file://" + mrl, null, true, null);
vlm.showMedia(mediaName);
}
//@Test
public void testDisableBroadcastMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
vlm.disableMedia(mediaName);
}
//@Test
public void testDisableVodMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addVod(mediaName, "file://" + mrl, null, true, null);
vlm.disableMedia(mediaName);
}
//@Test
public void testPauseBroadcastMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
vlm.playMedia(mediaName);
vlm.pauseMedia(mediaName);
vlm.stopMedia(mediaName);
}
//@Test
public void testPauseVodMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addVod(mediaName, "file://" + mrl, null, true, null);
vlm.playMedia(mediaName);
vlm.pauseMedia(mediaName);
vlm.stopMedia(mediaName);
}
//@Test
public void testStopBroadcastMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
vlm.playMedia(mediaName);
vlm.stopMedia(mediaName);
}
//@Test
public void testStopVodMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addVod(mediaName, "file://" + mrl, null, true, null);
vlm.playMedia(mediaName);
vlm.stopMedia(mediaName);
}
//@Test
public void testSeekBroadcastMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
vlm.playMedia(mediaName);
vlm.seekMedia(mediaName, 0.3f);
vlm.stopMedia(mediaName);
}
//@Test
public void testSeekVodMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addVod(mediaName, "file://" + mrl, null, true, null);
vlm.playMedia(mediaName);
vlm.seekMedia(mediaName, 0.3f);
vlm.stopMedia(mediaName);
}
//@Test
public void testAddMediaInputToBroadcast()
{
VLM vlm = jvlc.getVLM();
vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
vlm.addMediaInput(mediaName, "file://" + mrl);
}
//@Test
public void testAddMediaInputToVod()
{
VLM vlm = jvlc.getVLM();
vlm.addVod(mediaName, "file://" + mrl, null, true, null);
vlm.addMediaInput(mediaName, "file://" + mrl);
}
//@Test
public void testEnableBroadcastMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addBroadcast(mediaName, "file://" + mrl, "", null, false, false);
vlm.enableMedia(mediaName);
}
//@Test
public void testEnableVodMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addVod(mediaName, "file://" + mrl, null, true, null);
vlm.enableMedia(mediaName);
}
//@Test
public void testDeleteBroadcastMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addBroadcast(mediaName, "file://" + mrl, "", null, false, false);
vlm.deleteMedia(mediaName);
}
//@Test
public void testDeleteVodMedia()
{
VLM vlm = jvlc.getVLM();
vlm.addVod(mediaName, "file://" + mrl, null, true, null);
vlm.deleteMedia(mediaName);
}
//@Test
public void testMediaLoop()
{
VLM vlm = jvlc.getVLM();
vlm.addBroadcast(mediaName, "file://" + mrl, "", null, false, false);
vlm.setMediaLoop(mediaName, true);
}
//@Test
public void testSetMux()
{
VLM vlm = jvlc.getVLM();
vlm.addVod(mediaName, "file://" + mrl, null, true, null);
vlm.setMux(mediaName, "ts");
}
}
/*****************************************************************************
* AbstractVLCEventTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc.internal;
import org.junit.After;
public abstract class AbstractVLCEventTest extends AbstractVLCInternalTest
{
protected int eventFired;
@After
public void cleanupFired()
{
eventFired = 0;
}
}
/*****************************************************************************
* VLMInternalTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc.internal;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import junit.framework.Assert;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public abstract class AbstractVLCInternalTest
{
protected LibVlc libvlc = LibVlc.SYNC_INSTANCE;
protected LibVlcInstance libvlcInstance;
protected String mrl;
protected libvlc_exception_t exception;
private String address = "http://streams.videolan.org/streams-videolan/avi/Hero-Div3.avi";
/**
* Logger.
*/
private Logger log = LoggerFactory.getLogger(AbstractVLCInternalTest.class);
@Before
public void testSetup()
{
exception = new libvlc_exception_t();
String[] args = new String[]{
"-vvv",
"--ignore-config",
"--reset-plugins-cache",
"--no-media-library",
"-I",
"dummy",
"-A",
"dummy",
"-V",
"dummy" };
libvlcInstance = libvlc.libvlc_new(args.length, args, exception);
libvlc.libvlc_exception_clear(exception);
downloadSample();
}
@After
public void tearDown()
{
libvlc.libvlc_release(libvlcInstance);
libvlc.libvlc_exception_clear(exception);
}
protected void catchException(libvlc_exception_t exception)
{
Assert.assertEquals(libvlc.libvlc_errmsg(), 0, libvlc.libvlc_exception_raised(exception));
}
private void downloadSample()
{
OutputStream out = null;
URLConnection conn = null;
InputStream in = null;
URL sampleResource = this.getClass().getResource("/sample.avi");
if (sampleResource != null)
{
log.debug("Sample file already downloaded");
mrl = sampleResource.getPath();
return;
}
try
{
log.info("Downloading sample: {}", address);
String testResoucesPath = this.getClass().getResource("/sample").getPath();
URL url = new URL(address);
out = new BufferedOutputStream(new FileOutputStream(testResoucesPath + ".avi"));
conn = url.openConnection();
in = conn.getInputStream();
byte[] buffer = new byte[1024];
int numRead;
long numWritten = 0;
while ((numRead = in.read(buffer)) != -1)
{
out.write(buffer, 0, numRead);
numWritten += numRead;
}
if (numWritten == 0)
{
throw new RuntimeException("Cannot download sample, please check the url or your internet connection.");
}
log.info("Sample downloaded.");
mrl = testResoucesPath + ".avi";
}
catch (Exception e)
{
log.error("{}", e);
}
finally
{
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
}
}
/*****************************************************************************
* LibVlcCoreTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc.internal;
import org.junit.Assert;
import org.junit.Test;
import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class LibVlcCoreTest
{
private LibVlc instance = LibVlc.SYNC_INSTANCE;
@Test
public void testNew() throws Exception
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcInstance libvlcInstance = instance.libvlc_new(0, new String[] {"-I","dummy","--aout=dummy","--vout=dummy"}, exception);
Assert.assertNotNull(libvlcInstance);
Assert.assertEquals(0, exception.b_raised);
}
@Test
public void testRelease() throws Exception
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcInstance libvlcInstance = instance.libvlc_new(0, new String[] {}, exception);
instance.libvlc_release(libvlcInstance);
}
@Test
public void testAddIntf() throws Exception
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcInstance libvlcInstance = instance.libvlc_new(0, new String[] {}, exception);
instance.libvlc_add_intf(libvlcInstance, "dummy", exception);
Assert.assertEquals(0, exception.b_raised);
instance.libvlc_release(libvlcInstance);
}
}
/*****************************************************************************
* LibVlcLogTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc.internal;
import org.junit.Assert;
import org.junit.Test;
import org.videolan.jvlc.internal.LibVlc.LibVlcLog;
import org.videolan.jvlc.internal.LibVlc.LibVlcLogIterator;
import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class LibVlcLogTest extends AbstractVLCInternalTest
{
@Test
public void testLogOpen()
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcLog libvlcLog = libvlc.libvlc_log_open(libvlcInstance, exception);
Assert.assertNotNull(libvlcLog);
}
@Test
public void testLogClose()
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcLog libvlcLog = libvlc.libvlc_log_open(libvlcInstance, exception);
libvlc.libvlc_log_close(libvlcLog);
Assert.assertEquals(0, exception.b_raised);
}
//@Test
public void testLogClear()
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcLog libvlcLog = libvlc.libvlc_log_open(libvlcInstance, exception);
libvlc.libvlc_log_clear(libvlcLog);
Assert.assertEquals(0, libvlc.libvlc_log_count(libvlcLog));
}
//@Test
public void testLogGetIterator()
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcLog libvlcLog = libvlc.libvlc_log_open(libvlcInstance, exception);
libvlc.libvlc_log_clear(libvlcLog);
Assert.assertEquals(0, exception.b_raised);
Assert.assertEquals(0, libvlc.libvlc_log_count(libvlcLog));
LibVlcLogIterator logIterator = libvlc.libvlc_log_get_iterator(libvlcLog, exception);
Assert.assertNotNull(logIterator);
}
}
/*****************************************************************************
* LibVlcMediaEventsTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc.internal;
import junit.framework.Assert;
import org.junit.Test;
import org.videolan.jvlc.internal.LibVlc.LibVlcCallback;
import org.videolan.jvlc.internal.LibVlc.LibVlcEventManager;
import org.videolan.jvlc.internal.LibVlc.LibVlcMedia;
import org.videolan.jvlc.internal.LibVlc.libvlc_event_t;
import com.sun.jna.Pointer;
public class LibVlcMediaEventsTest extends AbstractVLCEventTest
{
@Test
public void mediaFreedTest()
{
LibVlcMedia media = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
LibVlcEventManager eventManager = libvlc.libvlc_media_event_manager(media, exception);
LibVlcCallback callback = new LibVlc.LibVlcCallback()
{
public void callback(libvlc_event_t libvlc_event, Pointer userData)
{
Assert.assertEquals(LibVlcEventType.libvlc_MediaFreed.ordinal(), libvlc_event.type);
eventFired = 1;
}
};
libvlc.libvlc_event_attach(eventManager, LibVlcEventType.libvlc_MediaFreed.ordinal(), callback, null, exception);
libvlc.libvlc_media_release(media);
Assert.assertEquals(1, eventFired);
}
}
/*****************************************************************************
* LibVlcMediaListEventsTest.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 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.
*****************************************************************************/
package org.videolan.jvlc.internal;
import junit.framework.Assert;
import org.junit.Test;
import org.videolan.jvlc.internal.LibVlc.LibVlcCallback;
import org.videolan.jvlc.internal.LibVlc.LibVlcEventManager;
import org.videolan.jvlc.internal.LibVlc.LibVlcMedia;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaList;
import org.videolan.jvlc.internal.LibVlc.libvlc_event_t;
import com.sun.jna.Pointer;
public class LibVlcMediaListEventsTest extends AbstractVLCEventTest
{
@Test
public void itemAddedTest()
{
LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
LibVlcMedia media = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
LibVlcEventManager eventManager = libvlc.libvlc_media_list_event_manager(mediaList, exception);
LibVlcCallback callback = new LibVlc.LibVlcCallback()
{
public void callback(libvlc_event_t libvlc_event, Pointer userData)
{
Assert.assertEquals(LibVlcEventType.libvlc_MediaListItemAdded.ordinal(), libvlc_event.type);
eventFired = 1;
}
};
libvlc.libvlc_event_attach(
eventManager,
LibVlcEventType.libvlc_MediaListItemAdded.ordinal(),
callback,
null,
exception);
libvlc.libvlc_media_list_add_media(mediaList, media, exception);
Assert.assertEquals(1, eventFired);
}
@Test
public void itemDeletedTest()
{
LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
LibVlcMedia media = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
LibVlcEventManager eventManager = libvlc.libvlc_media_list_event_manager(mediaList, exception);
LibVlcCallback callback = new LibVlc.LibVlcCallback()
{
public void callback(libvlc_event_t libvlc_event, Pointer userData)
{
Assert.assertEquals(LibVlcEventType.libvlc_MediaListItemDeleted.ordinal(), libvlc_event.type);
eventFired = 1;
}
};
libvlc.libvlc_event_attach(
eventManager,
LibVlcEventType.libvlc_MediaListItemDeleted.ordinal(),
callback,
null,
exception);
libvlc.libvlc_media_list_add_media(mediaList, media, exception);
libvlc.libvlc_media_list_remove_index(mediaList, 0, exception);
Assert.assertEquals(1, eventFired);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<!-- log4j test configuration -->
<appender name="test-appender" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c.%M(%C{1}.java:%L) %m%n" />
<!-- <param name="ConversionPattern" value="%-5p %m%n" />-->
</layout>
</appender>
<category name="org.videolan">
<priority value="info" />
</category>
<root>
<priority value="debug" />
<appender-ref ref="test-appender" />
</root>
</log4j:configuration>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.videolan</groupId>
<artifactId>jvlc-samples</artifactId>
<version>1.0.2-SNAPSHOT</version>
</parent>
<groupId>org.videolan</groupId>
<artifactId>jvlc-samples-client</artifactId>
<packaging>jar</packaging>
<name>JVLC - Client sample</name>
<description>Java Bindings for VideoLAN - Client sample</description>
<version>1.0.2-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>VlcClient</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.videolan</groupId>
<artifactId>jvlc-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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