Commit 10a63bb5 authored by ivoire's avatar ivoire

New C++ binding for libvlc.

parent b187fe3d
Doxyfile
admin/
m4/
INSTALL
This diff is collapsed.
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src
doc: Doxyfile
$(DOXYGEN)
.PHONY: doc
#!/bin/sh
# $Id$
#
# ***********************************************************************
# * Copyright © 2010 Rémi Duraffort. *
# * This program is free software; you can redistribute and/or modify *
# * it under the terms of the GNU General Public License as published *
# * by the Free Software Foundation; version 2 of the license. *
# * *
# * 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, you can get it from: *
# * http://www.gnu.org/copyleft/gpl.html *
# ***********************************************************************
set -xe
cd "$(dirname "$0")"
test -f src/libvlc.hpp || {
echo "You must run this script from your libvlcpp directory.">&2
exit 1
}
mkdir -p admin m4
autoreconf -sfi
set +x
echo ""
echo "Type \`./configure' to configure the package for your system"
echo "(type \`./configure -- help' for help)."
echo "Then you can use the usual \`make', \`make install', etc."
dnl configure.ac - Configure script for libvlcpp
AC_COPYRIGHT([Copyright (C) 2010 Rémi Duraffort])
AC_INIT(libvlcpp, 0.1.0, vlc-devel@no-spam@videolan.org)
AC_PREREQ([2.65])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_AUX_DIR(admin)
AC_CONFIG_MACRO_DIR([m4])
dnl Checks for programs.
AC_PROG_CXX
AM_PROG_LIBTOOL
AC_ARG_VAR([CXXFLAGS], [C++ compiler flag])
dnl Checks for vlc library
PKG_CHECK_MODULES([libvlc], [libvlc >= 1.1.0])
AC_SUBST([libvlc_CFLAGS])
AC_SUBST([libvlc_LIBS])
AC_ARG_VAR([DOXYGEN], [Doxygen command])
AC_PATH_PROG([DOXYGEN], [doxygen], [false])
AM_INIT_AUTOMAKE
AC_CONFIG_FILES([Makefile src/Makefile Doxyfile])
AC_OUTPUT
lib_LTLIBRARIES = libvlcpp.la
libvlcpp_la_SOURCES = \
exception.cpp \
exception.hpp \
libvlc.cpp \
libvlc.hpp \
media.cpp \
media.hpp \
media_player.cpp \
media_player.hpp
libvlcpp_la_CXXFLAGS = @libvlc_CFLAGS@
libvlcpp_la_LDFLAGS = @libvlc_LIBS@
library_includedir=$(includedir)/libvlcpp
library_include_HEADERS = exception.hpp libvlc.hpp media.hpp media_player.hpp
/*****************************************************************************
* exception.cpp: Handle exceptions
*****************************************************************************
* Copyright (C) 2010 the VideoLAN team
* $Id$
*
* Authors: Rémi Duraffort <ivoire@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "exception.hpp"
using namespace libvlc;
Exception::Exception()
{
libvlc_exception_init( &ex );
}
Exception::~Exception()
{
if( libvlc_exception_raised( &ex ) )
throw libvlc_errmsg();
libvlc_exception_clear( &ex );
}
/*****************************************************************************
* exception.hpp: handle exceptions
*****************************************************************************
* Copyright (C) 2010 the VideoLAN team
* $Id$
*
* Authors: Rémi Duraffort <ivoire@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef LIBVLCPP_EXCEPTION_HPP
#define LIBVLCPP_EXCEPTION_HPP
#include <vlc/libvlc.h>
#include "libvlc.hpp"
namespace libvlc
{
class Exception
{
public:
/** Create the exception */
Exception();
/** Destroy te exception */
~Exception();
/** The exception */
libvlc_exception_t ex;
};
};
#endif // LIBVLCPP_EXCEPTION_HPP
/*****************************************************************************
* libvlc.cpp: Main libvlc++ class
*****************************************************************************
* Copyright (C) 2010 the VideoLAN team
* $Id$
*
* Authors: Rémi Duraffort <ivoire@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "libvlc.hpp"
#include "exception.hpp"
using namespace libvlc;
libVLC::libVLC( int i_argc, const char *const *argv )
{
Exception ex;
m_instance = libvlc_new( i_argc, argv, &ex.ex);
}
libVLC::~libVLC()
{
libvlc_release( m_instance );
}
libvlc_instance_t *libVLC::getInstance()
{
return m_instance;
}
const char *libVLC::getVersion()
{
return libvlc_get_version();
}
const char *libVLC::getCompiler()
{
return libvlc_get_compiler();
}
const char *libVLC::getChanset()
{
return libvlc_get_changeset();
}
/*****************************************************************************
* libvlc.hpp: Main libvlc++ class
*****************************************************************************
* Copyright (C) 2010 the VideoLAN team
* $Id$
*
* Authors: Rémi Duraffort <ivoire@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef LIBVLCPP_HPP
#define LIBVLCPP_HPP
#include <vlc/libvlc.h>
namespace libvlc
{
class Media;
class MediaPlayer;
class libVLC
{
public:
/**
* Contructor
* @param i_argc: the number of arguments
* @param argv: arguments given to libvlc
*/
libVLC( int i_argc, const char* const* argv );
/* Destructor */
~libVLC();
/**
* Get the version of libVLC
* @return the version
*/
const char *getVersion();
/**
* Get the compiler use for this binari
* @return the compiler used
*/
const char *getCompiler();
/**
* Get the chanset of libvlc
* @return thje changeset
*/
const char *getChanset();
private:
/**
* Get the instance of libvlc that cannot be modified
* @return the instance of libvlc
*/
libvlc_instance_t *getInstance();
/** The instance of libvlc */
libvlc_instance_t *m_instance;
/**
* Some friends class to access the instance of libvlc
*/
friend class Media;
friend class MediaPlayer;
};
};
#endif // LIBVLCPP_HPP
/*****************************************************************************
* media.cpp: Represent a media
*****************************************************************************
* Copyright (C) 2010 the VideoLAN team
* $Id$
*
* Authors: Rémi Duraffort <ivoire@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "media.hpp"
#include "exception.hpp"
using namespace libvlc;
Media::Media( libVLC &libvlcInstance, const char *psz_mrl )
{
Exception ex;
m_media = libvlc_media_new( libvlcInstance.getInstance(), psz_mrl, &ex.ex );
}
Media::Media( const Media& original )
{
m_media = libvlc_media_duplicate( original.m_media );
}
Media::~Media()
{
libvlc_media_release( m_media );
}
void Media::addOption( const char *ppsz_options )
{
libvlc_media_add_option( m_media, ppsz_options );
}
void Media::addOption( const char *ppsz_options, libvlc_media_option_t flag )
{
libvlc_media_add_option_flag( m_media, ppsz_options, flag );
}
int64_t Media::getDuration()
{
Exception ex;
return libvlc_media_get_duration( m_media, &ex.ex );
}
int Media::isPreparsed()
{
return libvlc_media_is_preparsed( m_media );
}
char *Media::getMrl()
{
return libvlc_media_get_mrl( m_media );
}
char *Media::getMeta( libvlc_meta_t e_meta )
{
return libvlc_media_get_meta( m_media, e_meta );
}
void Media::setMeta( libvlc_meta_t e_meta, const char *psz_value )
{
libvlc_media_set_meta( m_media, e_meta, psz_value );
}
int Media::saveMeta()
{
return libvlc_media_save_meta( m_media );
}
libvlc_state_t Media::getState()
{
return libvlc_media_get_state( m_media );
}
void Media::setUserData( void *p_user_data )
{
libvlc_media_set_user_data( m_media, p_user_data );
}
void *Media::getUserData()
{
return libvlc_media_get_user_data( m_media );
}
libvlc_media_t *Media::getInstance()
{
return m_media;
}
/*****************************************************************************
* media.hpp: represent a media
*****************************************************************************
* Copyright (C) 2010 the VideoLAN team
* $Id$
*
* Authors: Rémi Duraffort <ivoire@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef LIBVLCPP_MEDIA_HPP
#define LIBVLCPP_MEDIA_HPP
#include <vlc/libvlc.h>
#include <vlc/libvlc_media.h>
#include "libvlc.hpp"
namespace libvlc
{
class MediaPlayer;
class Media
{
public:
/**
* Contructor
* @param libvlcInstance: instance of the libVLC class
* @param psz_mrl: MRL of the media
*/
Media( libVLC &libvlcInstance, const char *psz_mrl );
/**
* Copy contructor
* @param original: the instance to copy
*/
Media( const Media& original );
/** \todo: node contructor */
/** Destructor */
~Media();
/**
* Add an option to the media
* @param ppsz_options: the options as a string
*/
void addOption( const char *ppsz_options );
/**
* Add an option to the media
* @param ppsz_options: the options as a string
* @param flag: the flag for the options
*/
void addOption( const char *ppsz_options, libvlc_media_option_t flag );
/**
* Get the duration of the media
* @return the duration
*/
int64_t getDuration();
/**
* Get preparsed status of the media
* @return true if the media has been preparsed, false otherwise
*/
int isPreparsed();
/**
* Get the MRL of the media
* @return the MRL of the media
*/
char *getMrl();
/**
* Get the requiered meta
* @param e_meta: type of the meta
* @return the requiered meta
*/
char *getMeta( libvlc_meta_t e_meta );
/**
* Set the given meta
* @param e_meta: type of the meta
* @param psz_value: value of the meta
*/
void setMeta( libvlc_meta_t e_meta, const char *psz_value );
/**
* Save the meta to the file
* @return true if the operation was successfull
*/
int saveMeta();
/**
* Get the state of the media
* @return the state of the media
*/
libvlc_state_t getState();
/**
* Get some statistics about this media
* @return the statistics
*/
libvlc_media_stats_t *getStats();
/**\todo: getSubItems */
/**\todo: getEventManager */
/**
* Set media descriptor's user data
* @param p_user_data: pointer to user data
*/
void setUserData( void *p_user_data );
/**
* Retrive user data specified by a call to setUserData
* @return the user data pointer
*/
void *getUserData();
private:
/**
* Get the instance of the libvlc_media_t
* @return the pointer to libvlc_media_t
*/
libvlc_media_t *getInstance();
/** The media */
libvlc_media_t *m_media;
/** Friend class that can access the instance */
friend class MediaPlayer;
};
};
#endif // LIBVLCPP_MEDIA_HPP
/*****************************************************************************
* media_player.cpp: Represent a media player
*****************************************************************************
* Copyright (C) 2010 the VideoLAN team
* $Id$
*
* Authors: Rémi Duraffort <ivoire@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
<