Commit 10a63bb5 authored by Rémi Duraffort's avatar Rémi Duraffort

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.
*****************************************************************************/
#include "media_player.hpp"
#include "exception.hpp"
using namespace libvlc;
MediaPlayer::MediaPlayer( libVLC &libvlcInstance )
{
Exception ex;
m_player = libvlc_media_player_new( libvlcInstance.getInstance(), &ex.ex );
}
MediaPlayer::MediaPlayer( Media &media )
{
Exception ex;
m_player = libvlc_media_player_new_from_media( media.getInstance(), &ex.ex );
}
MediaPlayer::~MediaPlayer()
{
libvlc_media_player_release( m_player );
}
void MediaPlayer::setMedia( Media &media )
{
Exception ex;
libvlc_media_player_set_media( m_player, media.getInstance(), &ex.ex );
}
int MediaPlayer::isPlaying()
{
Exception ex;
return libvlc_media_player_is_playing( m_player, &ex.ex );
}
void MediaPlayer::play()
{
Exception ex;
libvlc_media_player_play( m_player, &ex.ex );
}
void MediaPlayer::pause()
{
Exception ex;
libvlc_media_player_pause( m_player, &ex.ex );
}
void MediaPlayer::stop()
{
Exception ex;
libvlc_media_player_stop( m_player, &ex.ex );
}
void MediaPlayer::setNSObject( void *drawable )
{
Exception ex;
libvlc_media_player_set_nsobject( m_player, drawable, &ex.ex );
}
void* MediaPlayer::getNSObject()
{
return libvlc_media_player_get_nsobject( m_player );
}
void MediaPlayer::setAgl( uint32_t drawable )
{
Exception ex;
libvlc_media_player_set_agl( m_player, drawable, &ex.ex );
}
uint32_t MediaPlayer::getAgl()
{
return libvlc_media_player_get_agl( m_player );
}
void MediaPlayer::setXWindow( uint32_t drawable )
{
Exception ex;
libvlc_media_player_set_xwindow( m_player, drawable, &ex.ex );
}
uint32_t MediaPlayer::getXWindow()
{
return libvlc_media_player_get_xwindow( m_player );
}
void MediaPlayer::setHwnd( void *drawable )
{
Exception ex;
libvlc_media_player_set_hwnd( m_player, drawable, &ex.ex );
}
void *MediaPlayer::getHwnd()
{
return libvlc_media_player_get_hwnd( m_player );
}
int64_t MediaPlayer::getLenght()
{
Exception ex;
return libvlc_media_player_get_length( m_player, &ex.ex );
}
int64_t MediaPlayer::getTime()
{
Exception ex;
return libvlc_media_player_get_time( m_player, &ex.ex );
}
void MediaPlayer::setTime( int64_t new_time )
{
Exception ex;
libvlc_media_player_set_time( m_player, new_time, &ex.ex );
}
float MediaPlayer::getPosition()
{
Exception ex;
return libvlc_media_player_get_position( m_player, &ex.ex );
}
void MediaPlayer::setPosition( float position )
{
Exception ex;
libvlc_media_player_set_position( m_player, position, &ex.ex );
}
int MediaPlayer::getChapter()
{
Exception ex;
return libvlc_media_player_get_chapter( m_player, &ex.ex );
}
int MediaPlayer::getChapterCount()
{
Exception ex;
return libvlc_media_player_get_chapter_count( m_player, &ex.ex );
}
int MediaPlayer::willPlay()
{
Exception ex;
return libvlc_media_player_will_play( m_player, &ex.ex );
}
/*int MediaPlayer::getTitle()
{
Exception ex;
return libvlc_media_player_get_title( m_player, &ex.ex );
}*/
/*****************************************************************************
* media_player.hpp: 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.
*****************************************************************************/
#ifndef LIBVLCPP_MEDIA_PLAYER_HPP
#define LIBVLCPP_MEDIA_PLAYER_HPP
#include <vlc/libvlc.h>
#include <vlc/libvlc_media.h>
#include <vlc/libvlc_media_player.h>
#include "libvlc.hpp"
#include "media.hpp"
namespace libvlc
{
class MediaPlayer
{
public:
/**
* Create a media player without a media associated
* @param libvlcInstance: instance of the libVLC class
*/
MediaPlayer( libVLC &libvlcInstance );
/**
* Create a media player with a media associated
* @param media: the associated media (the media can be safely destroy afterward)
*/
MediaPlayer( Media &media);
/**
* Destructor
*/
~MediaPlayer();
/**
* Set the media associated with the player
* @param media: the media to associated with the player
*/
void setMedia( Media &media );
/**
* Get the media associated with the player
* @return the media
*/
///@todo getMedia();
/**
* Get the event manager associated to the media player
* @return the event manager
*/
///@todo getEventManager()
/**
* Is the player playing
* @return true if the player is playing, false overwise
*/
int isPlaying();
/**
* Play
*/
void play();
/**
* Pause
*/
void pause();
/**
* Stop
*/
void stop();
/**
* Set the NSView handler where the media player shoud render the video
* @param drawable: the NSView handler
*/
void setNSObject( void *drawable );
/**
* Get the NSView handler associated with the media player
* @return the NSView handler
*/
void* getNSObject();
/**
* Set the agl handler where the media player shoud render the video
* @param drawable: the agl handler
*/
void setAgl( uint32_t drawable );
/**
* Get the agl handler associated with the media player
* @return the agl handler
*/
uint32_t getAgl();
/**
* Set the X Window drawable where the media player shoud render the video
* @param drawable: the X Window drawable
*/
void setXWindow( uint32_t drawable );
/**
* Get the X Window drawable associated with the media player
* @return the X Window drawable
*/
uint32_t getXWindow();
/**
* Set the Win32/Win64 API window handle where the media player shoud
* render the video
* @param drawable: the windows handle
*/
void setHwnd( void *drawable );
/**
* Get the Win32/Win64 API window handle associated with the media player
* @return the windows handle
*/
void *getHwnd();
/**
* Get the movie lenght (in ms)
* @return the movie length
*/
int64_t getLenght();
/**
* Get the current movie time (in ms)
* @return the current movie time
*/
int64_t getTime();
/**
* Set the movie time (in ms)
* @param the movie time (in ms)
*/
void setTime( int64_t new_time );
/**
* Get the movie position (in percent)
* @return the movie position
*/
float getPosition();
/**
* Set the movie position (in percent)
* @param the movie position
*/
void setPosition( float position );
/**
* Get the current movie chapter
* @return the current chapter
*/
int getChapter();
/**
* Get the movie chapter count
* @return the movie chapter count
*/
int getChapterCount();
/**
* Is the player going to play the media (not dead or dying)
* @return true if the player will play
*/
int willPlay();
protected:
libvlc_media_player_t *m_player;
};
};
#endif // LIBVLCPP_MEDIA_PLAYER_HPP
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