[Libreoffice-commits] core.git: 18 commits - avmedia/Library_avmediavlc.mk avmedia/source

Minh Ngo nlminhtl at gmail.com
Wed Aug 21 02:56:31 PDT 2013


 avmedia/Library_avmediavlc.mk                  |   40 +++--
 avmedia/source/vlc/vlccommon.hxx               |    3 
 avmedia/source/vlc/vlcframegrabber.cxx         |  120 ++++++-----------
 avmedia/source/vlc/vlcframegrabber.hxx         |   11 +
 avmedia/source/vlc/vlcmanager.cxx              |   13 +
 avmedia/source/vlc/vlcmanager.hxx              |    5 
 avmedia/source/vlc/vlcplayer.cxx               |   95 +++++++------
 avmedia/source/vlc/vlcplayer.hxx               |   21 ++-
 avmedia/source/vlc/wrapper/EventHandler.cxx    |   24 +++
 avmedia/source/vlc/wrapper/EventHandler.hxx    |   42 ++++++
 avmedia/source/vlc/wrapper/EventManager.cxx    |   81 +++++++++++
 avmedia/source/vlc/wrapper/EventManager.hxx    |   56 ++++++++
 avmedia/source/vlc/wrapper/Instance.cxx        |   45 ++++++
 avmedia/source/vlc/wrapper/Instance.hxx        |   45 ++++++
 avmedia/source/vlc/wrapper/Media.cxx           |   58 ++++++++
 avmedia/source/vlc/wrapper/Media.hxx           |   52 +++++++
 avmedia/source/vlc/wrapper/Player.cxx          |  174 +++++++++++++++++++++++++
 avmedia/source/vlc/wrapper/Player.hxx          |   75 ++++++++++
 avmedia/source/vlc/wrapper/SymbolLoader.hxx    |   82 +++++++++++
 avmedia/source/vlc/wrapper/ThreadsafeQueue.cxx |    1 
 avmedia/source/vlc/wrapper/ThreadsafeQueue.hxx |   79 +++++++++++
 21 files changed, 970 insertions(+), 152 deletions(-)

New commits:
commit d71f56e413caf6616688d76a020b4ef4804c7714
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Aug 19 23:42:00 2013 +0300

    Fixing copy constructors/operators= for VLC wrapper instances.
    
    Change-Id: I9860b738bbb3a8a85e07555b97203bb63b80b9de

diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx
index adc59b7..8e75eb3 100644
--- a/avmedia/source/vlc/vlcframegrabber.cxx
+++ b/avmedia/source/vlc/vlcframegrabber.cxx
@@ -62,8 +62,6 @@ SAL_CALL VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, boost::shared_pt
             return ::uno::Reference< css::graphic::XGraphic >();
         }
 
-
-
         mPlayer.takeSnapshot( fileName );
 
         mPlayer.setMute( false );
diff --git a/avmedia/source/vlc/wrapper/Instance.cxx b/avmedia/source/vlc/wrapper/Instance.cxx
index 301d97b..4260836 100644
--- a/avmedia/source/vlc/wrapper/Instance.cxx
+++ b/avmedia/source/vlc/wrapper/Instance.cxx
@@ -8,11 +8,13 @@ namespace VLC
     {
         libvlc_instance_t* ( *libvlc_new ) ( int argc, const char * const *argv );
         void ( *libvlc_release ) ( libvlc_instance_t *p_instance );
+        void ( *libvlc_retain ) ( libvlc_instance_t *p_instance );
 
         ApiMap VLC_INSTANCE_API[] =
         {
             SYM_MAP( libvlc_new ),
-            SYM_MAP( libvlc_release )
+            SYM_MAP( libvlc_release ),
+            SYM_MAP( libvlc_retain )
         };
     }
 
@@ -23,6 +25,17 @@ namespace VLC
         mInstance = libvlc_new( sizeof( argv ) / sizeof( argv[0] ), argv );
     }
 
+    Instance::Instance( const Instance& other )
+    {
+    }
+
+    const Instance& Instance::operator=( const Instance& other )
+    {
+        libvlc_release( mInstance );
+        mInstance = other.mInstance;
+        libvlc_retain( mInstance );
+    }
+
     Instance::~Instance()
     {
         libvlc_release( mInstance );
diff --git a/avmedia/source/vlc/wrapper/Instance.hxx b/avmedia/source/vlc/wrapper/Instance.hxx
index 8358a94..6111262 100644
--- a/avmedia/source/vlc/wrapper/Instance.hxx
+++ b/avmedia/source/vlc/wrapper/Instance.hxx
@@ -27,6 +27,8 @@ namespace VLC
     {
     public:
         Instance( const char * const argv[] );
+        Instance( const Instance& other );
+        const Instance& operator=( const Instance& other );
         virtual ~Instance();
 
         inline operator libvlc_instance_t*()
diff --git a/avmedia/source/vlc/wrapper/Media.cxx b/avmedia/source/vlc/wrapper/Media.cxx
index 851a4f5..6b7e77e 100644
--- a/avmedia/source/vlc/wrapper/Media.cxx
+++ b/avmedia/source/vlc/wrapper/Media.cxx
@@ -9,12 +9,14 @@ namespace VLC
     namespace
     {
         libvlc_media_t* ( *libvlc_media_new_path ) ( libvlc_instance_t *p_instance, const char *path );
-        void ( *libvlc_media_release )( libvlc_media_t *p_md );
+        void ( *libvlc_media_release ) ( libvlc_media_t *p_md );
+        void ( *libvlc_media_retain ) ( libvlc_media_t *p_md );
 
         ApiMap VLC_MEDIA_API[] =
         {
             SYM_MAP( libvlc_media_new_path ),
-            SYM_MAP( libvlc_media_release )
+            SYM_MAP( libvlc_media_release ),
+            SYM_MAP( libvlc_media_retain )
         };
 
         libvlc_media_t* InitMedia( const rtl::OUString& url, VLC::Instance& instance )
@@ -34,6 +36,20 @@ Media::Media( const rtl::OUString& url, Instance& instance )
     mMedia = InitMedia( url, instance );
 }
 
+Media::Media( const Media& other )
+    : mMedia( other.mMedia )
+{
+    libvlc_media_retain( mMedia );
+}
+
+const Media& Media::operator=( const Media& other )
+{
+    libvlc_media_release( mMedia );
+    mMedia = other.mMedia;
+
+    libvlc_media_retain( mMedia );
+}
+
 Media::~Media()
 {
     libvlc_media_release( mMedia );
diff --git a/avmedia/source/vlc/wrapper/Media.hxx b/avmedia/source/vlc/wrapper/Media.hxx
index b513943..483e60b 100644
--- a/avmedia/source/vlc/wrapper/Media.hxx
+++ b/avmedia/source/vlc/wrapper/Media.hxx
@@ -33,6 +33,9 @@ namespace VLC
     {
     public:
         Media( const rtl::OUString& url, Instance& instance );
+        Media( const Media& other );
+        const Media& operator=( const Media& other );
+
         virtual ~Media();
 
         inline operator libvlc_media_t*()
diff --git a/avmedia/source/vlc/wrapper/Player.cxx b/avmedia/source/vlc/wrapper/Player.cxx
index a64b747..d4a2525 100644
--- a/avmedia/source/vlc/wrapper/Player.cxx
+++ b/avmedia/source/vlc/wrapper/Player.cxx
@@ -11,6 +11,7 @@ namespace VLC
     {
         typedef int64_t libvlc_time_t;
 
+        void ( *libvlc_media_player_retain ) ( libvlc_media_player_t *p_mi );
         libvlc_media_player_t * ( *libvlc_media_player_new_from_media ) ( libvlc_media_t *p_md );
         void ( *libvlc_media_player_release ) ( libvlc_media_player_t *p_mi );
         int ( *libvlc_media_player_play ) ( libvlc_media_player_t *p_mi );
@@ -51,7 +52,8 @@ namespace VLC
             SYM_MAP( libvlc_video_take_snapshot ),
             SYM_MAP( libvlc_media_player_set_xwindow ),
             SYM_MAP( libvlc_media_player_has_vout ),
-            SYM_MAP( libvlc_video_set_mouse_input )
+            SYM_MAP( libvlc_video_set_mouse_input ),
+            SYM_MAP( libvlc_media_player_retain )
         };
     }
 
@@ -61,6 +63,19 @@ namespace VLC
         mPlayer = libvlc_media_player_new_from_media( media );
     }
 
+    Player::Player( const Player& other )
+        : mPlayer( other.mPlayer )
+    {
+        libvlc_media_player_retain( mPlayer );
+    }
+
+    const Player& Player::operator=( const Player& other )
+    {
+        libvlc_media_player_release( mPlayer );
+        mPlayer = other.mPlayer;
+        libvlc_media_player_retain( mPlayer );
+    }
+
     Player::~Player()
     {
         libvlc_media_player_release( mPlayer );
diff --git a/avmedia/source/vlc/wrapper/Player.hxx b/avmedia/source/vlc/wrapper/Player.hxx
index ed52062..a2b17e8 100644
--- a/avmedia/source/vlc/wrapper/Player.hxx
+++ b/avmedia/source/vlc/wrapper/Player.hxx
@@ -32,7 +32,9 @@ namespace VLC
     class Player
     {
     public:
-        Player(Media& media);
+        Player( Media& media );
+        Player( const Player& other );
+        const Player& operator=( const Player& other );
         virtual ~Player();
 
         bool play();
commit 46575e931479a4e967f2ad6a056b5f4d5490146c
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Aug 19 00:50:58 2013 +0300

    Playback loop
    
    Change-Id: I1262f16e60f928481626ef952d929cc931335233

diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx
index 4ca6add..adc59b7 100644
--- a/avmedia/source/vlc/vlcframegrabber.cxx
+++ b/avmedia/source/vlc/vlcframegrabber.cxx
@@ -23,10 +23,11 @@ const ::rtl::OUString AVMEDIA_VLC_GRABBER_IMPLEMENTATIONNAME = "com.sun.star.com
 const ::rtl::OUString AVMEDIA_VLC_GRABBER_SERVICENAME = "com.sun.star.media.VLCFrameGrabber_VLC";
 const int MSEC_IN_SEC = 1000;
 
-SAL_CALL VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, const rtl::OUString& url )
+SAL_CALL VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, boost::shared_ptr<VLC::EventHandler> eh, const rtl::OUString& url )
     : FrameGrabber_BASE()
     , mPlayer( player )
     , mUrl( url )
+    , mEventHandler( eh )
 {
 }
 
@@ -34,39 +35,42 @@ SAL_CALL VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, const rtl::OUStr
 {
     osl::Condition condition;
 
-    VLC::EventManager manager( mPlayer );
-    manager.onPaused(boost::bind(&osl::Condition::set, &condition));
+    const rtl::OUString& fileName = utl::TempFile::CreateTempName();
+    {
+        VLC::EventManager manager( mPlayer, mEventHandler );
+        manager.onPaused(boost::bind(&osl::Condition::set, &condition));
 
-    mPlayer.setMute( true );
+        mPlayer.setMute( true );
 
-    if ( !mPlayer.play() )
-    {
-        std::cerr << "Couldn't play" << std::endl;
-    }
+        if ( !mPlayer.play() )
+        {
+            std::cerr << "Couldn't play" << std::endl;
+        }
 
-    mPlayer.setTime( ( fMediaTime > 0 ? fMediaTime : 0 ) * MSEC_IN_SEC );
-    mPlayer.pause();
+        mPlayer.setTime( ( fMediaTime > 0 ? fMediaTime : 0 ) * MSEC_IN_SEC );
+        mPlayer.pause();
 
-    const TimeValue timeout = {2, 0};
-    condition.wait(&timeout);
+        const TimeValue timeout = {2, 0};
+        condition.wait(&timeout);
 
-    if ( mUrl.isEmpty() || !mPlayer.hasVout() )
-    {
-        std::cerr << "Couldn't grab frame" << std::endl;
-        mPlayer.setMute( false );
+        if ( mUrl.isEmpty() || !mPlayer.hasVout() )
+        {
+            std::cerr << "Couldn't grab frame" << std::endl;
+            mPlayer.setMute( false );
+
+            manager.onPaused();
+            return ::uno::Reference< css::graphic::XGraphic >();
+        }
 
-        manager.onPaused();
-        return ::uno::Reference< css::graphic::XGraphic >();
-    }
 
-    const rtl::OUString& fileName = utl::TempFile::CreateTempName();
 
-    mPlayer.takeSnapshot( fileName );
+        mPlayer.takeSnapshot( fileName );
 
-    mPlayer.setMute( false );
-    mPlayer.stop();
+        mPlayer.setMute( false );
+        mPlayer.stop();
 
-    manager.onPaused();
+        manager.onPaused();
+    }
 
     rtl::OUString url;
     utl::LocalFileHelper::ConvertPhysicalNameToURL( fileName, url );
diff --git a/avmedia/source/vlc/vlcframegrabber.hxx b/avmedia/source/vlc/vlcframegrabber.hxx
index 53dce41..923b63f 100644
--- a/avmedia/source/vlc/vlcframegrabber.hxx
+++ b/avmedia/source/vlc/vlcframegrabber.hxx
@@ -28,6 +28,7 @@
 namespace VLC
 {
     class Player;
+    class EventHandler;
 }
 
 namespace avmedia {
@@ -40,8 +41,9 @@ class VLCFrameGrabber : public FrameGrabber_BASE
 {
     VLC::Player& mPlayer;
     const rtl::OUString& mUrl;
+    boost::shared_ptr<VLC::EventHandler> mEventHandler;
 public:
-    SAL_CALL VLCFrameGrabber( VLC::Player& player, const rtl::OUString& url );
+    SAL_CALL VLCFrameGrabber( VLC::Player& player, boost::shared_ptr<VLC::EventHandler> eh, const rtl::OUString& url );
 
     ::com::sun::star::uno::Reference< css::graphic::XGraphic > SAL_CALL grabFrame( double fMediaTime );
 
diff --git a/avmedia/source/vlc/vlcmanager.cxx b/avmedia/source/vlc/vlcmanager.cxx
index a3e762b..6a5431d 100644
--- a/avmedia/source/vlc/vlcmanager.cxx
+++ b/avmedia/source/vlc/vlcmanager.cxx
@@ -10,8 +10,10 @@ const rtl::OUString VLC_IMPLEMENTATION_NAME = "com.sun.star.comp.avmedia.Manager
 const ::rtl::OUString VLC_SERVICENAME = "com.sun.star.media.Manager_VLC";
 
 Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr )
-    : mxMgr( rxMgr )
+    : mEventHandler(new VLC::EventHandler( "EventHandler" ) )
+    , mxMgr( rxMgr )
 {
+    mEventHandler->launch();
 }
 
 Manager::~Manager()
@@ -23,7 +25,7 @@ uno::Reference< media::XPlayer > SAL_CALL Manager::createPlayer( const rtl::OUSt
 {
     if ( !rURL.isEmpty() || (mPlayer.is() && dynamic_cast<VLCPlayer*>( mPlayer.get() )->url() != rURL))
     {
-        VLCPlayer* pPlayer( new VLCPlayer( rURL/*, mxMgr */ ) );
+        VLCPlayer* pPlayer( new VLCPlayer( rURL, mEventHandler /*, mxMgr */ ) );
         mPlayer = uno::Reference< media::XPlayer >( pPlayer );
     }
 
diff --git a/avmedia/source/vlc/vlcmanager.hxx b/avmedia/source/vlc/vlcmanager.hxx
index 9417480..dbcaed6 100644
--- a/avmedia/source/vlc/vlcmanager.hxx
+++ b/avmedia/source/vlc/vlcmanager.hxx
@@ -19,10 +19,11 @@
 
 #ifndef _VLCMANAGER_HXX
 #define _VLCMANAGER_HXX
-
+#include <boost/shared_ptr.hpp>
 #include "vlccommon.hxx"
 
 #include "com/sun/star/media/XManager.hpp"
+#include "wrapper/EventHandler.hxx"
 
 namespace avmedia {
 namespace vlc {
@@ -30,6 +31,7 @@ namespace vlc {
 class Manager : public ::cppu::WeakImplHelper2 < ::com::sun::star::media::XManager,
                                                     ::com::sun::star::lang::XServiceInfo >
 {
+    boost::shared_ptr<VLC::EventHandler> mEventHandler;
 public:
     Manager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMgr );
     ~Manager();
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index 945d7d9..a0887c2 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -24,12 +24,13 @@ const char * const VLC_ARGS[] = {
 
 const int MS_IN_SEC = 1000; // Millisec in sec
 
-VLCPlayer::VLCPlayer( const rtl::OUString& url )
+VLCPlayer::VLCPlayer( const rtl::OUString& url, boost::shared_ptr<VLC::EventHandler> eh )
     : VLC_Base(m_aMutex)
+    , mEventHandler( eh )
     , mInstance( VLC_ARGS )
     , mMedia( url, mInstance )
     , mPlayer( mMedia )
-    , mEventManager( mPlayer )
+    , mEventManager( mPlayer, mEventHandler )
     , mUrl( url )
     , mPlaybackLoop( false )
 {
@@ -91,8 +92,10 @@ double SAL_CALL VLCPlayer::getRate()
 
 void VLCPlayer::replay()
 {
-    mPlayer.stop();
-    mPlayer.play();
+    setPlaybackLoop( false );
+    stop();
+    setMediaTime( 0 );
+    start();
 }
 
 void SAL_CALL VLCPlayer::setPlaybackLoop( ::sal_Bool bSet )
@@ -100,9 +103,6 @@ void SAL_CALL VLCPlayer::setPlaybackLoop( ::sal_Bool bSet )
     ::osl::MutexGuard aGuard(m_aMutex);
     mPlaybackLoop = bSet;
 
-    //TODO: Fix it
-    return;
-
     if ( bSet )
         mEventManager.onEndReached(boost::bind(&VLCPlayer::replay, this));
     else
@@ -190,7 +190,7 @@ uno::Reference< css::media::XPlayerWindow > SAL_CALL VLCPlayer::createPlayerWind
 uno::Reference< css::media::XFrameGrabber > SAL_CALL VLCPlayer::createFrameGrabber()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    VLCFrameGrabber *frameGrabber = new VLCFrameGrabber( mPlayer, mUrl );
+    VLCFrameGrabber *frameGrabber = new VLCFrameGrabber( mPlayer, mEventHandler, mUrl );
     return uno::Reference< css::media::XFrameGrabber >( frameGrabber );
 }
 
diff --git a/avmedia/source/vlc/vlcplayer.hxx b/avmedia/source/vlc/vlcplayer.hxx
index 3723f16..18e4e6f 100644
--- a/avmedia/source/vlc/vlcplayer.hxx
+++ b/avmedia/source/vlc/vlcplayer.hxx
@@ -41,6 +41,7 @@ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::media::XPlayer,
 class VLCPlayer : public ::cppu::BaseMutex,
                   public VLC_Base
 {
+    boost::shared_ptr<VLC::EventHandler> mEventHandler;
     VLC::Instance mInstance;
     VLC::Media mMedia;
     VLC::Player mPlayer;
@@ -48,7 +49,7 @@ class VLCPlayer : public ::cppu::BaseMutex,
     const rtl::OUString mUrl;
     bool mPlaybackLoop;
 public:
-    VLCPlayer( const rtl::OUString& url );
+    VLCPlayer( const rtl::OUString& url, boost::shared_ptr<VLC::EventHandler> eh );
 
     const rtl::OUString& url() const;
 
diff --git a/avmedia/source/vlc/wrapper/EventManager.cxx b/avmedia/source/vlc/wrapper/EventManager.cxx
index bafd4a9..96e86b6 100644
--- a/avmedia/source/vlc/wrapper/EventManager.cxx
+++ b/avmedia/source/vlc/wrapper/EventManager.cxx
@@ -1,9 +1,11 @@
+#include <boost/thread.hpp>
 #include <vlc/libvlc.h>
 #include <vlc/libvlc_media.h>
 #include <vlc/libvlc_events.h>
 
 #include "EventManager.hxx"
 #include "SymbolLoader.hxx"
+#include "EventHandler.hxx"
 
 typedef void ( *libvlc_callback_t ) ( const struct libvlc_event_t *, void * );
 
@@ -35,15 +37,16 @@ void EventManagerEventHandler( const libvlc_event_t *event, void *pData )
     switch ( event->type )
     {
     case libvlc_MediaPlayerPaused:
-        instance->mOnPaused();
+        instance->mEventHandler->mCallbackQueue.push( instance->mOnPaused );
         break;
     case libvlc_MediaPlayerEndReached:
-        instance->mOnEndReached();
+        instance->mEventHandler->mCallbackQueue.push( instance->mOnEndReached );
         break;
     }
 }
 
-EventManager::EventManager(VLC::Player& player)
+EventManager::EventManager( VLC::Player& player, boost::shared_ptr<VLC::EventHandler> eh )
+    : mEventHandler( eh )
 {
     InitApiMap( VLC_EVENT_MANAGER_API );
     mManager = libvlc_media_player_event_manager( player );
@@ -53,24 +56,26 @@ EventManager::~EventManager()
 {
 }
 
-void EventManager::registerSignal(int signal, const Callback& callback)
+void EventManager::registerSignal( int signal, const Callback& callback )
 {
-    if (callback.empty())
+    if ( callback.empty() )
         libvlc_event_detach( mManager, signal, EventManagerEventHandler, this );
     else
         libvlc_event_attach( mManager, signal, EventManagerEventHandler, this );
 }
 
-void EventManager::onPaused(const EventManager::Callback& callback)
+void EventManager::onPaused( const EventManager::Callback& callback )
 {
     mOnPaused = callback;
-    registerSignal(libvlc_MediaPlayerPaused, callback);
+    registerSignal( libvlc_MediaPlayerPaused, callback );
 }
 
-void EventManager::onEndReached(const Callback& callback)
+void EventManager::onEndReached( const Callback& callback )
 {
     mOnEndReached = callback;
-    registerSignal(libvlc_MediaPlayerEndReached, callback);
+    registerSignal( libvlc_MediaPlayerEndReached, callback );
 }
 
+
+
 }
\ No newline at end of file
diff --git a/avmedia/source/vlc/wrapper/EventManager.hxx b/avmedia/source/vlc/wrapper/EventManager.hxx
index 9143b55..aad486d 100644
--- a/avmedia/source/vlc/wrapper/EventManager.hxx
+++ b/avmedia/source/vlc/wrapper/EventManager.hxx
@@ -19,30 +19,36 @@
 #ifndef _WRAPPER_EVENT_MANAGER_HXX
 #define _WRAPPER_EVENT_MANAGER_HXX
 #include <boost/function.hpp>
+#include <boost/shared_ptr.hpp>
+
 #include "Player.hxx"
 
 struct libvlc_event_manager_t;
 struct libvlc_event_t;
+
 namespace VLC
 {
+    class EventHandler;
     class EventManager
     {
         friend void EventManagerEventHandler( const libvlc_event_t *event, void *pData );
     public:
         typedef boost::function<void()> Callback;
 
-        EventManager(VLC::Player& player);
+        EventManager( VLC::Player& player, boost::shared_ptr<VLC::EventHandler> eh );
         virtual ~EventManager();
 
-        void onPaused(const Callback& callback = Callback());
-        void onEndReached(const Callback& callback = Callback());
+        void onPaused( const Callback& callback = Callback() );
+        void onEndReached( const Callback& callback = Callback() );
 
     private:
+        boost::shared_ptr<VLC::EventHandler> mEventHandler;
+        typedef boost::function< void() > TCallback;
         libvlc_event_manager_t *mManager;
-        boost::function<void()> mOnPaused;
-        boost::function<void()> mOnEndReached;
+        TCallback mOnPaused;
+        TCallback mOnEndReached;
 
-        void registerSignal(int signal, const Callback& callback);
+        void registerSignal( int signal, const Callback& callback );
     };
 }
 
diff --git a/avmedia/source/vlc/wrapper/Player.cxx b/avmedia/source/vlc/wrapper/Player.cxx
index 37779d1..a64b747 100644
--- a/avmedia/source/vlc/wrapper/Player.cxx
+++ b/avmedia/source/vlc/wrapper/Player.cxx
@@ -154,8 +154,6 @@ namespace VLC
     {
         return libvlc_media_player_has_vout( mPlayer );
     }
-
-
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/avmedia/source/vlc/wrapper/Player.hxx b/avmedia/source/vlc/wrapper/Player.hxx
index 7832ad9..ed52062 100644
--- a/avmedia/source/vlc/wrapper/Player.hxx
+++ b/avmedia/source/vlc/wrapper/Player.hxx
@@ -64,7 +64,6 @@ namespace VLC
         }
 
         void setMouseHandling(bool flag);
-
     private:
         libvlc_media_player_t *mPlayer;
     };
commit c40a63642c402d8e6f52fcc3994ff5e8cf8ee50b
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Aug 19 00:49:40 2013 +0300

    VLC Event handling in the separate thread.
    
    Change-Id: I56daa508de79281df5536215222e5af224dae0f5

diff --git a/avmedia/Library_avmediavlc.mk b/avmedia/Library_avmediavlc.mk
index 5ab91d9..81e200b 100644
--- a/avmedia/Library_avmediavlc.mk
+++ b/avmedia/Library_avmediavlc.mk
@@ -36,6 +36,7 @@ $(eval $(call gb_Library_use_libraries,avmediavlc,\
     tl \
     vcl \
     utl \
+    salhelper \
     $(gb_UWINAPI) \
 ))
 
@@ -49,6 +50,8 @@ $(eval $(call gb_Library_add_exception_objects,avmediavlc,\
     avmedia/source/vlc/wrapper/Media \
     avmedia/source/vlc/wrapper/Player \
     avmedia/source/vlc/wrapper/EventManager \
+    avmedia/source/vlc/wrapper/EventHandler \
+    avmedia/source/vlc/wrapper/ThreadsafeQueue \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/avmedia/source/vlc/wrapper/EventHandler.cxx b/avmedia/source/vlc/wrapper/EventHandler.cxx
new file mode 100644
index 0000000..42fc0dc
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/EventHandler.cxx
@@ -0,0 +1,24 @@
+#include "EventHandler.hxx"
+
+namespace VLC
+{
+EventHandler::EventHandler( const char *name )
+    : Thread( name )
+{
+}
+
+void EventHandler::execute()
+{
+    TCallback callback;
+    do
+    {
+        mCallbackQueue.pop( callback );
+
+        if ( callback.empty() )
+            return;
+        else
+            callback();
+    } while ( true );
+}
+
+}
diff --git a/avmedia/source/vlc/wrapper/EventHandler.hxx b/avmedia/source/vlc/wrapper/EventHandler.hxx
new file mode 100644
index 0000000..50700c2
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/EventHandler.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _WRAPPER_EVENT_HANDLER_HXX
+#define _WRAPPER_EVENT_HANDLER_HXX
+#include <boost/function.hpp>
+#include <salhelper/thread.hxx>
+#include "ThreadsafeQueue.hxx"
+
+namespace VLC
+{
+    class EventHandler : public salhelper::Thread
+    {
+    public:
+        EventHandler( const char* name );
+
+    protected:
+        virtual void execute();
+
+    public:
+        typedef boost::function< void() > TCallback;
+        avmedia::vlc::ThreadsafeQueue< TCallback > mCallbackQueue;
+    };
+}
+
+#endif // _WRAPPER_EVENT_HANDLER_HXX
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
commit 626d99773e1a31ad190a4d3c5df33653b4d333b6
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Aug 19 00:47:43 2013 +0300

    Thread safe queue for VLC Event Handling
    
    Change-Id: I0e9b30639667a807cc316c89356803d99fa83ef8

diff --git a/avmedia/source/vlc/wrapper/ThreadsafeQueue.cxx b/avmedia/source/vlc/wrapper/ThreadsafeQueue.cxx
new file mode 100644
index 0000000..ea9294f
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/ThreadsafeQueue.cxx
@@ -0,0 +1 @@
+#include "ThreadsafeQueue.hxx"
\ No newline at end of file
diff --git a/avmedia/source/vlc/wrapper/ThreadsafeQueue.hxx b/avmedia/source/vlc/wrapper/ThreadsafeQueue.hxx
new file mode 100644
index 0000000..7f428c4
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/ThreadsafeQueue.hxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _THREADSAFE_QUEUE_HXX
+#define _THREADSAFE_QUEUE_HXX
+#include <queue>
+#include <iostream>
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+#include <boost/noncopyable.hpp>
+
+namespace avmedia {
+namespace vlc {
+
+template<class T>
+class ThreadsafeQueue : boost::noncopyable
+{
+public:
+    ThreadsafeQueue();
+
+    void push( const T& data );
+    void pop( T& data );
+
+private:
+    std::queue< T > mQueue;
+    mutable ::osl::Mutex mMutex;
+    ::osl::Condition mCondition;
+};
+
+template<class T>
+ThreadsafeQueue<T>::ThreadsafeQueue()
+{
+}
+
+template<class T>
+void ThreadsafeQueue<T>::push( const T& data )
+{
+    ::osl::MutexGuard guard( mMutex );
+    mQueue.push( data );
+    mCondition.set();
+}
+
+template<class T>
+void ThreadsafeQueue<T>::pop( T& data )
+{
+    mMutex.acquire();
+    if ( mQueue.empty() )
+    {
+        mMutex.release();
+        mCondition.wait();
+        mCondition.reset();
+    }
+
+    ::osl::MutexGuard guard( mMutex );
+
+    data = mQueue.front();
+    mQueue.pop();
+}
+
+}
+}
+
+#endif // _THREADSAFE_QUEUE_HXX
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
commit 4ed6ea7f2c529173399e9f80469fca41eba6195d
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Sat Aug 10 11:26:14 2013 +0300

    Includes for building.
    
    Change-Id: I55f9ea19f0be650bcf9dd63cd7a6f86a01679b62

diff --git a/avmedia/source/vlc/wrapper/EventManager.cxx b/avmedia/source/vlc/wrapper/EventManager.cxx
index 6ae5bc9..bafd4a9 100644
--- a/avmedia/source/vlc/wrapper/EventManager.cxx
+++ b/avmedia/source/vlc/wrapper/EventManager.cxx
@@ -1,84 +1,16 @@
+#include <vlc/libvlc.h>
+#include <vlc/libvlc_media.h>
+#include <vlc/libvlc_events.h>
+
 #include "EventManager.hxx"
 #include "SymbolLoader.hxx"
 
-typedef struct libvlc_event_t
-{
-    int   type;
-    void *p_obj;
-    union
-    {
-        struct
-        {
-            void *p;
-        } media_meta_changed;
-    } u;
-} libvlc_event_t;
-
-typedef int libvlc_event_type_t;
 typedef void ( *libvlc_callback_t ) ( const struct libvlc_event_t *, void * );
 
 namespace VLC
 {
     namespace
     {
-        enum libvlc_event_e {
-            libvlc_MediaMetaChanged=0,
-            libvlc_MediaSubItemAdded,
-            libvlc_MediaDurationChanged,
-            libvlc_MediaParsedChanged,
-            libvlc_MediaFreed,
-            libvlc_MediaStateChanged,
-
-            libvlc_MediaPlayerMediaChanged=0x100,
-            libvlc_MediaPlayerNothingSpecial,
-            libvlc_MediaPlayerOpening,
-            libvlc_MediaPlayerBuffering,
-            libvlc_MediaPlayerPlaying,
-            libvlc_MediaPlayerPaused,
-            libvlc_MediaPlayerStopped,
-            libvlc_MediaPlayerForward,
-            libvlc_MediaPlayerBackward,
-            libvlc_MediaPlayerEndReached,
-            libvlc_MediaPlayerEncounteredError,
-            libvlc_MediaPlayerTimeChanged,
-            libvlc_MediaPlayerPositionChanged,
-            libvlc_MediaPlayerSeekableChanged,
-            libvlc_MediaPlayerPausableChanged,
-            libvlc_MediaPlayerTitleChanged,
-            libvlc_MediaPlayerSnapshotTaken,
-            libvlc_MediaPlayerLengthChanged,
-            libvlc_MediaPlayerVout,
-
-            libvlc_MediaListItemAdded=0x200,
-            libvlc_MediaListWillAddItem,
-            libvlc_MediaListItemDeleted,
-            libvlc_MediaListWillDeleteItem,
-
-            libvlc_MediaListViewItemAdded=0x300,
-            libvlc_MediaListViewWillAddItem,
-            libvlc_MediaListViewItemDeleted,
-            libvlc_MediaListViewWillDeleteItem,
-
-            libvlc_MediaListPlayerPlayed=0x400,
-            libvlc_MediaListPlayerNextItemSet,
-            libvlc_MediaListPlayerStopped,
-
-            libvlc_MediaDiscovererStarted=0x500,
-            libvlc_MediaDiscovererEnded,
-
-            libvlc_VlmMediaAdded=0x600,
-            libvlc_VlmMediaRemoved,
-            libvlc_VlmMediaChanged,
-            libvlc_VlmMediaInstanceStarted,
-            libvlc_VlmMediaInstanceStopped,
-            libvlc_VlmMediaInstanceStatusInit,
-            libvlc_VlmMediaInstanceStatusOpening,
-            libvlc_VlmMediaInstanceStatusPlaying,
-            libvlc_VlmMediaInstanceStatusPause,
-            libvlc_VlmMediaInstanceStatusEnd,
-            libvlc_VlmMediaInstanceStatusError
-        };
-
         libvlc_event_manager_t* ( *libvlc_media_player_event_manager ) ( libvlc_media_player_t *p_mi );
         int ( *libvlc_event_attach ) ( libvlc_event_manager_t *p_event_manager,
                                        libvlc_event_type_t i_event_type,
commit c3de00df77fbab130526a49a2311da66181c5364
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Sat Aug 10 10:58:36 2013 +0300

    MacOS/Windows stuff
    
    Change-Id: I237cf543fc198a65af2d90ca6044f9e429b09b98

diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index 64d8565..945d7d9 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -179,13 +179,9 @@ uno::Reference< css::media::XPlayerWindow > SAL_CALL VLCPlayer::createPlayerWind
 
     const int winID = GetWindowID( aArguments );
 
-    if (winID != -1)
+    if ( winID != -1 )
     {
-#if defined(WIN32) && !defined(UNIX)
-        //TODO: Not works, will be crashed
-#else
-        mPlayer.setXWindow( winID );
-#endif
+        mPlayer.setWindow( winID );
     }
 
     return uno::Reference< css::media::XPlayerWindow >( window );
diff --git a/avmedia/source/vlc/wrapper/Player.cxx b/avmedia/source/vlc/wrapper/Player.cxx
index 29f2536..37779d1 100644
--- a/avmedia/source/vlc/wrapper/Player.cxx
+++ b/avmedia/source/vlc/wrapper/Player.cxx
@@ -131,9 +131,16 @@ namespace VLC
         return libvlc_audio_get_mute( mPlayer );
     }
 
-    void Player::setXWindow( int id )
+
+    void Player::setWindow( int id )
     {
+#if defined( UNX )
         libvlc_media_player_set_xwindow( mPlayer, id );
+#elif defined( MACOS )
+        libvlc_media_player_set_nsobject( mPlayer, reinterpret_cast<void*>( id ) );
+#elif defined( WNT )
+        libvlc_media_player_set_hwnd( mPlayer, reinterpret_cast<void*>( id ) );
+#endif
     }
 
     void Player::takeSnapshot(const rtl::OUString& file)
diff --git a/avmedia/source/vlc/wrapper/Player.hxx b/avmedia/source/vlc/wrapper/Player.hxx
index f1b3958..7832ad9 100644
--- a/avmedia/source/vlc/wrapper/Player.hxx
+++ b/avmedia/source/vlc/wrapper/Player.hxx
@@ -52,7 +52,7 @@ namespace VLC
         void setMute( bool mute);
         bool getMute() const;
 
-        void setXWindow( int id );
+        void setWindow( int id );
 
         void takeSnapshot(const rtl::OUString& file);
 
commit 254f7e8ffdf442398bfa361fc0e1bfeaec702ab0
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Sat Aug 10 10:34:13 2013 +0300

    Disabling the mouse handling event in the VLC engine.
    
    Change-Id: I348f7830b2ed86ddc21a48e0b482adfafc0175cd

diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index ba304f7..64d8565 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -19,7 +19,7 @@ const char * const VLC_ARGS[] = {
     "-Vdummy",
     "--snapshot-format=png",
     "--ffmpeg-threads",
-    "--verbose=-1",
+    "--verbose=2"
 };
 
 const int MS_IN_SEC = 1000; // Millisec in sec
@@ -33,6 +33,7 @@ VLCPlayer::VLCPlayer( const rtl::OUString& url )
     , mUrl( url )
     , mPlaybackLoop( false )
 {
+    mPlayer.setMouseHandling(false);
 }
 
 const rtl::OUString& VLCPlayer::url() const
diff --git a/avmedia/source/vlc/wrapper/Player.cxx b/avmedia/source/vlc/wrapper/Player.cxx
index b67f1b2..29f2536 100644
--- a/avmedia/source/vlc/wrapper/Player.cxx
+++ b/avmedia/source/vlc/wrapper/Player.cxx
@@ -30,6 +30,7 @@ namespace VLC
                                 unsigned int i_height );
         void ( *libvlc_media_player_set_xwindow ) ( libvlc_media_player_t *p_mi, uint32_t drawable );
         unsigned ( *libvlc_media_player_has_vout ) ( libvlc_media_player_t *p_mi );
+        void ( *libvlc_video_set_mouse_input ) ( libvlc_media_player_t *p_mi, unsigned on);
 
         ApiMap VLC_PLAYER_API[] =
         {
@@ -49,7 +50,8 @@ namespace VLC
             SYM_MAP( libvlc_audio_get_mute ),
             SYM_MAP( libvlc_video_take_snapshot ),
             SYM_MAP( libvlc_media_player_set_xwindow ),
-            SYM_MAP( libvlc_media_player_has_vout )
+            SYM_MAP( libvlc_media_player_has_vout ),
+            SYM_MAP( libvlc_video_set_mouse_input )
         };
     }
 
@@ -89,6 +91,11 @@ namespace VLC
         return libvlc_media_player_get_time( mPlayer );
     }
 
+    void Player::setMouseHandling(bool flag)
+    {
+        libvlc_video_set_mouse_input( mPlayer, flag );
+    }
+
     bool Player::isPlaying() const
     {
         return libvlc_media_player_is_playing( mPlayer ) == 1;
diff --git a/avmedia/source/vlc/wrapper/Player.hxx b/avmedia/source/vlc/wrapper/Player.hxx
index e23acb7..f1b3958 100644
--- a/avmedia/source/vlc/wrapper/Player.hxx
+++ b/avmedia/source/vlc/wrapper/Player.hxx
@@ -63,6 +63,8 @@ namespace VLC
             return mPlayer;
         }
 
+        void setMouseHandling(bool flag);
+
     private:
         libvlc_media_player_t *mPlayer;
     };
commit fb89c0c579f70734cd5c0f72316a77ce1b0b3cad
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Tue Aug 6 16:32:59 2013 +0300

    Porting all VLC API for loading by wrappers
    
    Change-Id: Idafdf7a43675efd74b6a198178c79342fbcee3d0

diff --git a/avmedia/Library_avmediavlc.mk b/avmedia/Library_avmediavlc.mk
index 0f8b039..5ab91d9 100644
--- a/avmedia/Library_avmediavlc.mk
+++ b/avmedia/Library_avmediavlc.mk
@@ -48,6 +48,7 @@ $(eval $(call gb_Library_add_exception_objects,avmediavlc,\
     avmedia/source/vlc/wrapper/Instance \
     avmedia/source/vlc/wrapper/Media \
     avmedia/source/vlc/wrapper/Player \
+    avmedia/source/vlc/wrapper/EventManager \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/avmedia/source/vlc/vlccommon.hxx b/avmedia/source/vlc/vlccommon.hxx
index 6b8e2ca..1bc9fa1 100644
--- a/avmedia/source/vlc/vlccommon.hxx
+++ b/avmedia/source/vlc/vlccommon.hxx
@@ -20,9 +20,6 @@
 #ifndef _VLCCOMMON_HXX
 #define _VLCCOMMON_HXX
 
-#include <vlc/libvlc.h>
-#include <vlc/libvlc_media.h>
-
 #include <osl/mutex.hxx>
 #include <tools/stream.hxx>
 #include <tools/urlobj.hxx>
diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx
index 4e0eaf9..4ca6add 100644
--- a/avmedia/source/vlc/vlcframegrabber.cxx
+++ b/avmedia/source/vlc/vlcframegrabber.cxx
@@ -1,3 +1,4 @@
+#include <boost/bind.hpp>
 #include <osl/conditn.hxx>
 #include <vcl/graph.hxx>
 #include <vcl/bmpacc.hxx>
@@ -11,8 +12,7 @@
 #include "vlcframegrabber.hxx"
 #include "vlcplayer.hxx"
 #include "wrapper/Player.hxx"
-
-#include <vlc/libvlc_events.h>
+#include "wrapper/EventManager.hxx"
 
 using namespace ::com::sun::star;
 
@@ -30,26 +30,12 @@ SAL_CALL VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, const rtl::OUStr
 {
 }
 
-namespace
-{
-    void EventHandler( const libvlc_event_t *evemt, void *pData )
-    {
-        switch ( evemt->type )
-        {
-        case libvlc_MediaPlayerPaused:
-            osl::Condition *condition = static_cast<osl::Condition*>( pData );
-            condition->set();
-            break;
-        }
-    }
-}
-
 ::uno::Reference< css::graphic::XGraphic > SAL_CALL VLCFrameGrabber::grabFrame( double fMediaTime )
 {
     osl::Condition condition;
 
-    libvlc_event_manager_t *manager = libvlc_media_player_event_manager( mPlayer );
-    libvlc_event_attach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
+    VLC::EventManager manager( mPlayer );
+    manager.onPaused(boost::bind(&osl::Condition::set, &condition));
 
     mPlayer.setMute( true );
 
@@ -69,7 +55,7 @@ namespace
         std::cerr << "Couldn't grab frame" << std::endl;
         mPlayer.setMute( false );
 
-        libvlc_event_detach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
+        manager.onPaused();
         return ::uno::Reference< css::graphic::XGraphic >();
     }
 
@@ -80,7 +66,7 @@ namespace
     mPlayer.setMute( false );
     mPlayer.stop();
 
-    libvlc_event_detach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
+    manager.onPaused();
 
     rtl::OUString url;
     utl::LocalFileHelper::ConvertPhysicalNameToURL( fileName, url );
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index 2bf15fb..ba304f7 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -1,3 +1,4 @@
+#include <boost/bind.hpp>
 #include <vcl/syschild.hxx>
 #include <vcl/sysdata.hxx>
 
@@ -28,6 +29,7 @@ VLCPlayer::VLCPlayer( const rtl::OUString& url )
     , mInstance( VLC_ARGS )
     , mMedia( url, mInstance )
     , mPlayer( mMedia )
+    , mEventManager( mPlayer )
     , mUrl( url )
     , mPlaybackLoop( false )
 {
@@ -86,20 +88,10 @@ double SAL_CALL VLCPlayer::getRate()
     return mPlayer.getRate();
 }
 
-namespace
+void VLCPlayer::replay()
 {
-    void EventHandler( const libvlc_event_t *evemt, void *pData )
-    {
-        switch (evemt->type)
-        {
-        case libvlc_MediaPlayerEndReached:
-            VLC::Player& player = *static_cast< VLC::Player* >( pData );
-
-            player.stop();
-            player.play();
-            break;
-        }
-    }
+    mPlayer.stop();
+    mPlayer.play();
 }
 
 void SAL_CALL VLCPlayer::setPlaybackLoop( ::sal_Bool bSet )
@@ -107,12 +99,13 @@ void SAL_CALL VLCPlayer::setPlaybackLoop( ::sal_Bool bSet )
     ::osl::MutexGuard aGuard(m_aMutex);
     mPlaybackLoop = bSet;
 
-    libvlc_event_manager_t *manager = libvlc_media_player_event_manager( mPlayer );
+    //TODO: Fix it
+    return;
 
     if ( bSet )
-        libvlc_event_attach( manager, libvlc_MediaPlayerEndReached, EventHandler, &mPlayer );
+        mEventManager.onEndReached(boost::bind(&VLCPlayer::replay, this));
     else
-        libvlc_event_detach( manager, libvlc_MediaPlayerEndReached, EventHandler, &mPlayer );
+        mEventManager.onEndReached();
 }
 
 ::sal_Bool SAL_CALL VLCPlayer::isPlaybackLoop()
diff --git a/avmedia/source/vlc/vlcplayer.hxx b/avmedia/source/vlc/vlcplayer.hxx
index 230b219..3723f16 100644
--- a/avmedia/source/vlc/vlcplayer.hxx
+++ b/avmedia/source/vlc/vlcplayer.hxx
@@ -30,6 +30,7 @@
 #include "wrapper/Instance.hxx"
 #include "wrapper/Media.hxx"
 #include "wrapper/Player.hxx"
+#include "wrapper/EventManager.hxx"
 
 namespace avmedia {
 namespace vlc {
@@ -43,6 +44,7 @@ class VLCPlayer : public ::cppu::BaseMutex,
     VLC::Instance mInstance;
     VLC::Media mMedia;
     VLC::Player mPlayer;
+    VLC::EventManager mEventManager;
     const rtl::OUString mUrl;
     bool mPlaybackLoop;
 public:
@@ -70,6 +72,9 @@ public:
     ::rtl::OUString SAL_CALL getImplementationName();
     ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& serviceName );
     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
+
+private:
+    void replay();
 };
 
 }
diff --git a/avmedia/source/vlc/wrapper/EventManager.cxx b/avmedia/source/vlc/wrapper/EventManager.cxx
new file mode 100644
index 0000000..6ae5bc9
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/EventManager.cxx
@@ -0,0 +1,144 @@
+#include "EventManager.hxx"
+#include "SymbolLoader.hxx"
+
+typedef struct libvlc_event_t
+{
+    int   type;
+    void *p_obj;
+    union
+    {
+        struct
+        {
+            void *p;
+        } media_meta_changed;
+    } u;
+} libvlc_event_t;
+
+typedef int libvlc_event_type_t;
+typedef void ( *libvlc_callback_t ) ( const struct libvlc_event_t *, void * );
+
+namespace VLC
+{
+    namespace
+    {
+        enum libvlc_event_e {
+            libvlc_MediaMetaChanged=0,
+            libvlc_MediaSubItemAdded,
+            libvlc_MediaDurationChanged,
+            libvlc_MediaParsedChanged,
+            libvlc_MediaFreed,
+            libvlc_MediaStateChanged,
+
+            libvlc_MediaPlayerMediaChanged=0x100,
+            libvlc_MediaPlayerNothingSpecial,
+            libvlc_MediaPlayerOpening,
+            libvlc_MediaPlayerBuffering,
+            libvlc_MediaPlayerPlaying,
+            libvlc_MediaPlayerPaused,
+            libvlc_MediaPlayerStopped,
+            libvlc_MediaPlayerForward,
+            libvlc_MediaPlayerBackward,
+            libvlc_MediaPlayerEndReached,
+            libvlc_MediaPlayerEncounteredError,
+            libvlc_MediaPlayerTimeChanged,
+            libvlc_MediaPlayerPositionChanged,
+            libvlc_MediaPlayerSeekableChanged,
+            libvlc_MediaPlayerPausableChanged,
+            libvlc_MediaPlayerTitleChanged,
+            libvlc_MediaPlayerSnapshotTaken,
+            libvlc_MediaPlayerLengthChanged,
+            libvlc_MediaPlayerVout,
+
+            libvlc_MediaListItemAdded=0x200,
+            libvlc_MediaListWillAddItem,
+            libvlc_MediaListItemDeleted,
+            libvlc_MediaListWillDeleteItem,
+
+            libvlc_MediaListViewItemAdded=0x300,
+            libvlc_MediaListViewWillAddItem,
+            libvlc_MediaListViewItemDeleted,
+            libvlc_MediaListViewWillDeleteItem,
+
+            libvlc_MediaListPlayerPlayed=0x400,
+            libvlc_MediaListPlayerNextItemSet,
+            libvlc_MediaListPlayerStopped,
+
+            libvlc_MediaDiscovererStarted=0x500,
+            libvlc_MediaDiscovererEnded,
+
+            libvlc_VlmMediaAdded=0x600,
+            libvlc_VlmMediaRemoved,
+            libvlc_VlmMediaChanged,
+            libvlc_VlmMediaInstanceStarted,
+            libvlc_VlmMediaInstanceStopped,
+            libvlc_VlmMediaInstanceStatusInit,
+            libvlc_VlmMediaInstanceStatusOpening,
+            libvlc_VlmMediaInstanceStatusPlaying,
+            libvlc_VlmMediaInstanceStatusPause,
+            libvlc_VlmMediaInstanceStatusEnd,
+            libvlc_VlmMediaInstanceStatusError
+        };
+
+        libvlc_event_manager_t* ( *libvlc_media_player_event_manager ) ( libvlc_media_player_t *p_mi );
+        int ( *libvlc_event_attach ) ( libvlc_event_manager_t *p_event_manager,
+                                       libvlc_event_type_t i_event_type,
+                                       libvlc_callback_t f_callback,
+                                       void *user_data );
+        void ( *libvlc_event_detach ) ( libvlc_event_manager_t *p_event_manager,
+                                        libvlc_event_type_t i_event_type,
+                                        libvlc_callback_t f_callback,
+                                        void *p_user_data );
+
+        ApiMap VLC_EVENT_MANAGER_API[] =
+        {
+            SYM_MAP( libvlc_media_player_event_manager ),
+            SYM_MAP( libvlc_event_attach ),
+            SYM_MAP( libvlc_event_detach )
+        };
+    }
+
+void EventManagerEventHandler( const libvlc_event_t *event, void *pData )
+{
+    EventManager *instance = static_cast<EventManager*>( pData );
+    switch ( event->type )
+    {
+    case libvlc_MediaPlayerPaused:
+        instance->mOnPaused();
+        break;
+    case libvlc_MediaPlayerEndReached:
+        instance->mOnEndReached();
+        break;
+    }
+}
+
+EventManager::EventManager(VLC::Player& player)
+{
+    InitApiMap( VLC_EVENT_MANAGER_API );
+    mManager = libvlc_media_player_event_manager( player );
+}
+
+EventManager::~EventManager()
+{
+}
+
+void EventManager::registerSignal(int signal, const Callback& callback)
+{
+    if (callback.empty())
+        libvlc_event_detach( mManager, signal, EventManagerEventHandler, this );
+    else
+        libvlc_event_attach( mManager, signal, EventManagerEventHandler, this );
+}
+
+void EventManager::onPaused(const EventManager::Callback& callback)
+{
+    mOnPaused = callback;
+    registerSignal(libvlc_MediaPlayerPaused, callback);
+}
+
+void EventManager::onEndReached(const Callback& callback)
+{
+    mOnEndReached = callback;
+    registerSignal(libvlc_MediaPlayerEndReached, callback);
+}
+
+}
\ No newline at end of file
diff --git a/avmedia/source/vlc/wrapper/EventManager.hxx b/avmedia/source/vlc/wrapper/EventManager.hxx
new file mode 100644
index 0000000..9143b55
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/EventManager.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _WRAPPER_EVENT_MANAGER_HXX
+#define _WRAPPER_EVENT_MANAGER_HXX
+#include <boost/function.hpp>
+#include "Player.hxx"
+
+struct libvlc_event_manager_t;
+struct libvlc_event_t;
+namespace VLC
+{
+    class EventManager
+    {
+        friend void EventManagerEventHandler( const libvlc_event_t *event, void *pData );
+    public:
+        typedef boost::function<void()> Callback;
+
+        EventManager(VLC::Player& player);
+        virtual ~EventManager();
+
+        void onPaused(const Callback& callback = Callback());
+        void onEndReached(const Callback& callback = Callback());
+
+    private:
+        libvlc_event_manager_t *mManager;
+        boost::function<void()> mOnPaused;
+        boost::function<void()> mOnEndReached;
+
+        void registerSignal(int signal, const Callback& callback);
+    };
+}
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
commit d160838b234c75455e26a91c65135cf1381e507a
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Tue Aug 6 00:56:33 2013 +0300

    VLC Player wrapper
    
    Change-Id: I507bbfb0426d003eca7cf0a3331128f8af1aee89

diff --git a/avmedia/Library_avmediavlc.mk b/avmedia/Library_avmediavlc.mk
index a04237b..0f8b039 100644
--- a/avmedia/Library_avmediavlc.mk
+++ b/avmedia/Library_avmediavlc.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_Library_add_exception_objects,avmediavlc,\
     avmedia/source/vlc/vlcframegrabber \
     avmedia/source/vlc/wrapper/Instance \
     avmedia/source/vlc/wrapper/Media \
+    avmedia/source/vlc/wrapper/Player \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx
index 4630f15..4e0eaf9 100644
--- a/avmedia/source/vlc/vlcframegrabber.cxx
+++ b/avmedia/source/vlc/vlcframegrabber.cxx
@@ -10,9 +10,9 @@
 
 #include "vlcframegrabber.hxx"
 #include "vlcplayer.hxx"
+#include "wrapper/Player.hxx"
 
 #include <vlc/libvlc_events.h>
-#include <vlc/libvlc_media_player.h>
 
 using namespace ::com::sun::star;
 
@@ -23,7 +23,7 @@ const ::rtl::OUString AVMEDIA_VLC_GRABBER_IMPLEMENTATIONNAME = "com.sun.star.com
 const ::rtl::OUString AVMEDIA_VLC_GRABBER_SERVICENAME = "com.sun.star.media.VLCFrameGrabber_VLC";
 const int MSEC_IN_SEC = 1000;
 
-SAL_CALL VLCFrameGrabber::VLCFrameGrabber( boost::shared_ptr<libvlc_media_player_t>& player, const rtl::OUString& url )
+SAL_CALL VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, const rtl::OUString& url )
     : FrameGrabber_BASE()
     , mPlayer( player )
     , mUrl( url )
@@ -48,38 +48,38 @@ namespace
 {
     osl::Condition condition;
 
-    libvlc_media_player_t *player = mPlayer.get();
-    libvlc_event_manager_t *manager = libvlc_media_player_event_manager( player );
+    libvlc_event_manager_t *manager = libvlc_media_player_event_manager( mPlayer );
     libvlc_event_attach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
 
-    libvlc_audio_set_mute( player, true );
-    if ( libvlc_media_player_play( player ) == -1 )
+    mPlayer.setMute( true );
+
+    if ( !mPlayer.play() )
     {
         std::cerr << "Couldn't play" << std::endl;
     }
 
-    libvlc_media_player_set_time( player, ( fMediaTime > 0 ? fMediaTime : 0 ) * MSEC_IN_SEC );
+    mPlayer.setTime( ( fMediaTime > 0 ? fMediaTime : 0 ) * MSEC_IN_SEC );
+    mPlayer.pause();
 
-    libvlc_media_player_pause( player );
     const TimeValue timeout = {2, 0};
     condition.wait(&timeout);
 
-    if ( mUrl.isEmpty() || !libvlc_media_player_has_vout( player ) )
+    if ( mUrl.isEmpty() || !mPlayer.hasVout() )
     {
         std::cerr << "Couldn't grab frame" << std::endl;
-        libvlc_audio_set_mute( player, false );
+        mPlayer.setMute( false );
 
         libvlc_event_detach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
         return ::uno::Reference< css::graphic::XGraphic >();
     }
 
     const rtl::OUString& fileName = utl::TempFile::CreateTempName();
-    rtl::OString dest;
-    fileName.convertToString( &dest, RTL_TEXTENCODING_UTF8, 0 );
 
-    libvlc_video_take_snapshot( player, 0, dest.getStr(), 0, 0 );
-    libvlc_audio_set_mute( player, false );
-    libvlc_media_player_stop( player );
+    mPlayer.takeSnapshot( fileName );
+
+    mPlayer.setMute( false );
+    mPlayer.stop();
+
     libvlc_event_detach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
 
     rtl::OUString url;
diff --git a/avmedia/source/vlc/vlcframegrabber.hxx b/avmedia/source/vlc/vlcframegrabber.hxx
index 7b83a1c..53dce41 100644
--- a/avmedia/source/vlc/vlcframegrabber.hxx
+++ b/avmedia/source/vlc/vlcframegrabber.hxx
@@ -25,7 +25,10 @@
 #include <cppuhelper/implbase2.hxx>
 #include "vlccommon.hxx"
 
-struct libvlc_media_player_t;
+namespace VLC
+{
+    class Player;
+}
 
 namespace avmedia {
 namespace vlc {
@@ -35,10 +38,10 @@ typedef ::cppu::WeakImplHelper2< ::com::sun::star::media::XFrameGrabber,
 
 class VLCFrameGrabber : public FrameGrabber_BASE
 {
-    boost::shared_ptr<libvlc_media_player_t> mPlayer;
+    VLC::Player& mPlayer;
     const rtl::OUString& mUrl;
 public:
-    SAL_CALL VLCFrameGrabber( boost::shared_ptr<libvlc_media_player_t>& player, const rtl::OUString& url );
+    SAL_CALL VLCFrameGrabber( VLC::Player& player, const rtl::OUString& url );
 
     ::com::sun::star::uno::Reference< css::graphic::XGraphic > SAL_CALL grabFrame( double fMediaTime );
 
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index f3e3f69..2bf15fb 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -27,7 +27,7 @@ VLCPlayer::VLCPlayer( const rtl::OUString& url )
     : VLC_Base(m_aMutex)
     , mInstance( VLC_ARGS )
     , mMedia( url, mInstance )
-    , mPlayer( libvlc_media_player_new_from_media( mMedia ), libvlc_media_player_release )
+    , mPlayer( mMedia )
     , mUrl( url )
     , mPlaybackLoop( false )
 {
@@ -41,49 +41,49 @@ const rtl::OUString& VLCPlayer::url() const
 void SAL_CALL VLCPlayer::start()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    libvlc_media_player_play( mPlayer.get() );
+    mPlayer.play();
 }
 
 void SAL_CALL VLCPlayer::stop()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    libvlc_media_player_pause( mPlayer.get() );
+    mPlayer.pause();
 }
 
 ::sal_Bool SAL_CALL VLCPlayer::isPlaying()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    return (libvlc_media_player_is_playing( mPlayer.get() ) == 1);
+    return mPlayer.isPlaying();
 }
 
 double SAL_CALL VLCPlayer::getDuration()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    return static_cast<double>( libvlc_media_player_get_length( mPlayer.get() ) ) / MS_IN_SEC;
+    return static_cast<double>( mPlayer.getLength() ) / MS_IN_SEC;
 }
 
 void SAL_CALL VLCPlayer::setMediaTime( double fTime )
 {
     ::osl::MutexGuard aGuard(m_aMutex);
 
-    if ( fTime < 0.00000001 && !libvlc_media_player_is_playing( mPlayer.get() ) )
+    if ( fTime < 0.00000001 && !mPlayer.isPlaying() )
     {
-        libvlc_media_player_stop( mPlayer.get() );
+        mPlayer.stop();
     }
 
-    libvlc_media_player_set_time( mPlayer.get(), fTime * MS_IN_SEC );
+    mPlayer.setTime( fTime * MS_IN_SEC );
 }
 
 double SAL_CALL VLCPlayer::getMediaTime()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    return static_cast<double>( libvlc_media_player_get_time( mPlayer.get() ) ) / MS_IN_SEC;
+    return static_cast<double>( mPlayer.getTime() ) / MS_IN_SEC;
 }
 
 double SAL_CALL VLCPlayer::getRate()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    return libvlc_media_player_get_rate( mPlayer.get() );
+    return mPlayer.getRate();
 }
 
 namespace
@@ -93,9 +93,10 @@ namespace
         switch (evemt->type)
         {
         case libvlc_MediaPlayerEndReached:
-            boost::shared_ptr<libvlc_media_player_t> player = *static_cast< boost::shared_ptr<libvlc_media_player_t>* >( pData );
-            libvlc_media_player_stop( player.get() );
-            libvlc_media_player_play( player.get() );
+            VLC::Player& player = *static_cast< VLC::Player* >( pData );
+
+            player.stop();
+            player.play();
             break;
         }
     }
@@ -106,7 +107,7 @@ void SAL_CALL VLCPlayer::setPlaybackLoop( ::sal_Bool bSet )
     ::osl::MutexGuard aGuard(m_aMutex);
     mPlaybackLoop = bSet;
 
-    libvlc_event_manager_t *manager = libvlc_media_player_event_manager( mPlayer.get() );
+    libvlc_event_manager_t *manager = libvlc_media_player_event_manager( mPlayer );
 
     if ( bSet )
         libvlc_event_attach( manager, libvlc_MediaPlayerEndReached, EventHandler, &mPlayer );
@@ -123,25 +124,25 @@ void SAL_CALL VLCPlayer::setPlaybackLoop( ::sal_Bool bSet )
 void SAL_CALL VLCPlayer::setVolumeDB( ::sal_Int16 nDB )
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    libvlc_audio_set_volume( mPlayer.get(), static_cast<sal_Int16>( ( nDB + 40 ) * 10.0  / 4 ) );
+    mPlayer.setVolume( static_cast<sal_Int16>( ( nDB + 40 ) * 10.0  / 4 ) );
 }
 
 ::sal_Int16 SAL_CALL VLCPlayer::getVolumeDB()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    return static_cast<sal_Int16>( libvlc_audio_get_volume( mPlayer.get() ) / 10.0 * 4 - 40 );
+    return static_cast<sal_Int16>( mPlayer.getVolume() / 10.0 * 4 - 40 );
 }
 
 void SAL_CALL VLCPlayer::setMute( ::sal_Bool bSet )
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    libvlc_audio_set_mute( mPlayer.get(), bSet );
+    mPlayer.setMute( bSet );
 }
 
 ::sal_Bool SAL_CALL VLCPlayer::isMute()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    return libvlc_audio_get_mute( mPlayer.get() );
+    return mPlayer.getMute();
 }
 
 css::awt::Size SAL_CALL VLCPlayer::getPreferredPlayerWindowSize()
@@ -189,7 +190,7 @@ uno::Reference< css::media::XPlayerWindow > SAL_CALL VLCPlayer::createPlayerWind
 #if defined(WIN32) && !defined(UNIX)
         //TODO: Not works, will be crashed
 #else
-        libvlc_media_player_set_xwindow( mPlayer.get(), winID );
+        mPlayer.setXWindow( winID );
 #endif
     }
 
diff --git a/avmedia/source/vlc/vlcplayer.hxx b/avmedia/source/vlc/vlcplayer.hxx
index e8d3fd0..230b219 100644
--- a/avmedia/source/vlc/vlcplayer.hxx
+++ b/avmedia/source/vlc/vlcplayer.hxx
@@ -29,6 +29,7 @@
 
 #include "wrapper/Instance.hxx"
 #include "wrapper/Media.hxx"
+#include "wrapper/Player.hxx"
 
 namespace avmedia {
 namespace vlc {
@@ -41,7 +42,7 @@ class VLCPlayer : public ::cppu::BaseMutex,
 {
     VLC::Instance mInstance;
     VLC::Media mMedia;
-    boost::shared_ptr<libvlc_media_player_t> mPlayer;
+    VLC::Player mPlayer;
     const rtl::OUString mUrl;
     bool mPlaybackLoop;
 public:
diff --git a/avmedia/source/vlc/wrapper/Media.cxx b/avmedia/source/vlc/wrapper/Media.cxx
index d2cf5c1..851a4f5 100644
--- a/avmedia/source/vlc/wrapper/Media.cxx
+++ b/avmedia/source/vlc/wrapper/Media.cxx
@@ -28,7 +28,7 @@ namespace VLC
     }
 
 
-Media::Media(const rtl::OUString& url, Instance& instance)
+Media::Media( const rtl::OUString& url, Instance& instance )
 {
     InitApiMap(VLC_MEDIA_API);
     mMedia = InitMedia( url, instance );
diff --git a/avmedia/source/vlc/wrapper/Media.hxx b/avmedia/source/vlc/wrapper/Media.hxx
index cbeef02..b513943 100644
--- a/avmedia/source/vlc/wrapper/Media.hxx
+++ b/avmedia/source/vlc/wrapper/Media.hxx
@@ -32,7 +32,7 @@ namespace VLC
     class Media
     {
     public:
-        Media(const rtl::OUString& url, Instance& instance);
+        Media( const rtl::OUString& url, Instance& instance );
         virtual ~Media();
 
         inline operator libvlc_media_t*()
diff --git a/avmedia/source/vlc/wrapper/Player.cxx b/avmedia/source/vlc/wrapper/Player.cxx
new file mode 100644
index 0000000..b67f1b2
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/Player.cxx
@@ -0,0 +1,147 @@
+#include <rtl/ustring.h>
+
+#include "Player.hxx"
+#include "Media.hxx"
+#include "SymbolLoader.hxx"
+
+struct libvlc_media_t;
+namespace VLC
+{
+    namespace
+    {
+        typedef int64_t libvlc_time_t;
+
+        libvlc_media_player_t * ( *libvlc_media_player_new_from_media ) ( libvlc_media_t *p_md );
+        void ( *libvlc_media_player_release ) ( libvlc_media_player_t *p_mi );
+        int ( *libvlc_media_player_play ) ( libvlc_media_player_t *p_mi );
+        void ( *libvlc_media_player_pause ) ( libvlc_media_player_t *p_mi );
+        int ( *libvlc_media_player_is_playing ) ( libvlc_media_player_t *p_mi );
+        void ( *libvlc_media_player_stop ) ( libvlc_media_player_t *p_mi );
+        void ( *libvlc_media_player_set_time ) ( libvlc_media_player_t *p_mi, libvlc_time_t i_time );
+        libvlc_time_t ( *libvlc_media_player_get_time ) ( libvlc_media_player_t *p_mi );
+        libvlc_time_t ( *libvlc_media_player_get_length ) ( libvlc_media_player_t *p_mi );
+        float ( *libvlc_media_player_get_rate )( libvlc_media_player_t *p_mi );
+        int ( *libvlc_audio_set_volume ) ( libvlc_media_player_t *p_mi, int i_volume );
+        int ( *libvlc_audio_get_volume ) ( libvlc_media_player_t *p_mi );
+        int ( *libvlc_audio_get_mute ) ( libvlc_media_player_t *p_mi );
+        void ( *libvlc_audio_set_mute ) ( libvlc_media_player_t *p_mi, int status );
+        int ( *libvlc_video_take_snapshot ) ( libvlc_media_player_t *p_mi, unsigned num,
+                                const char *psz_filepath, unsigned int i_width,
+                                unsigned int i_height );
+        void ( *libvlc_media_player_set_xwindow ) ( libvlc_media_player_t *p_mi, uint32_t drawable );
+        unsigned ( *libvlc_media_player_has_vout ) ( libvlc_media_player_t *p_mi );
+
+        ApiMap VLC_PLAYER_API[] =
+        {
+            SYM_MAP( libvlc_media_player_new_from_media ),
+            SYM_MAP( libvlc_media_player_release ),
+            SYM_MAP( libvlc_media_player_play ),
+            SYM_MAP( libvlc_media_player_pause ),
+            SYM_MAP( libvlc_media_player_is_playing ),
+            SYM_MAP( libvlc_media_player_stop ),
+            SYM_MAP( libvlc_media_player_set_time ),
+            SYM_MAP( libvlc_media_player_get_time ),
+            SYM_MAP( libvlc_media_player_get_length ),
+            SYM_MAP( libvlc_media_player_get_rate ),
+            SYM_MAP( libvlc_audio_set_volume ),
+            SYM_MAP( libvlc_audio_get_volume ),
+            SYM_MAP( libvlc_audio_set_mute ),
+            SYM_MAP( libvlc_audio_get_mute ),
+            SYM_MAP( libvlc_video_take_snapshot ),
+            SYM_MAP( libvlc_media_player_set_xwindow ),
+            SYM_MAP( libvlc_media_player_has_vout )
+        };
+    }
+
+    Player::Player(Media& media)
+    {
+        InitApiMap(VLC_PLAYER_API);
+        mPlayer = libvlc_media_player_new_from_media( media );
+    }
+
+    Player::~Player()
+    {
+        libvlc_media_player_release( mPlayer );
+    }
+
+    bool Player::play()
+    {
+        return libvlc_media_player_play( mPlayer );
+    }
+
+    void Player::pause()
+    {
+        libvlc_media_player_pause( mPlayer );
+    }
+
+    void Player::stop()
+    {
+        libvlc_media_player_stop( mPlayer );
+    }
+
+    void Player::setTime( int time )
+    {
+        libvlc_media_player_set_time( mPlayer, time );
+    }
+
+    int Player::getTime() const
+    {
+        return libvlc_media_player_get_time( mPlayer );
+    }
+
+    bool Player::isPlaying() const
+    {
+        return libvlc_media_player_is_playing( mPlayer ) == 1;
+    }
+
+    int Player::getLength() const
+    {
+        return libvlc_media_player_get_length( mPlayer );
+    }
+
+    float Player::getRate() const
+    {
+        return libvlc_media_player_get_rate( mPlayer );
+    }
+
+    void Player::setVolume( int volume )
+    {
+        libvlc_audio_set_volume( mPlayer, volume );
+    }
+
+    int Player::getVolume() const
+    {
+        return libvlc_audio_get_volume( mPlayer );
+    }
+
+    void Player::setMute( bool mute)
+    {
+        libvlc_audio_set_mute( mPlayer, mute );
+    }
+
+    bool Player::getMute() const
+    {
+        return libvlc_audio_get_mute( mPlayer );
+    }
+
+    void Player::setXWindow( int id )
+    {
+        libvlc_media_player_set_xwindow( mPlayer, id );
+    }
+
+    void Player::takeSnapshot(const rtl::OUString& file)
+    {
+        rtl::OString dest;
+        file.convertToString( &dest, RTL_TEXTENCODING_UTF8, 0 );
+        libvlc_video_take_snapshot( mPlayer, 0, dest.getStr(), 0, 0 );
+    }
+
+    bool Player::hasVout() const
+    {
+        return libvlc_media_player_has_vout( mPlayer );
+    }
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/avmedia/source/vlc/wrapper/Player.hxx b/avmedia/source/vlc/wrapper/Player.hxx
new file mode 100644
index 0000000..e23acb7
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/Player.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _WRAPPER_PLAYER_HXX
+#define _WRAPPER_PLAYER_HXX
+
+struct libvlc_media_player_t;
+
+namespace rtl
+{
+    class OUString;
+}
+
+namespace VLC
+{
+    class Media;
+    class Player
+    {
+    public:
+        Player(Media& media);
+        virtual ~Player();
+
+        bool play();
+        void pause();
+        void stop();
+        void setTime( int time );
+        int getTime() const;
+        bool isPlaying() const;
+
+        int getLength() const;
+
+        float getRate() const;
+
+        void setVolume( int volume );
+        int getVolume() const;
+
+        void setMute( bool mute);
+        bool getMute() const;
+
+        void setXWindow( int id );
+
+        void takeSnapshot(const rtl::OUString& file);
+
+        bool hasVout() const;
+
+        inline operator libvlc_media_player_t*()
+        {
+            return mPlayer;
+        }
+
+    private:
+        libvlc_media_player_t *mPlayer;
+    };
+}
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/avmedia/source/vlc/wrapper/SymbolLoader.hxx b/avmedia/source/vlc/wrapper/SymbolLoader.hxx
index 5e61258..0962a3e 100644
--- a/avmedia/source/vlc/wrapper/SymbolLoader.hxx
+++ b/avmedia/source/vlc/wrapper/SymbolLoader.hxx
@@ -39,8 +39,8 @@ namespace
         "libvlccore.so.5"
     };
 
-    template<size_t N> static bool
-    tryLink( oslModule &aModule, const char *pName, const ApiMap ( &pMap )[N] )
+    template<size_t N>
+    bool tryLink( oslModule &aModule, const ApiMap ( &pMap )[N] )
     {
         for (uint i = 0; i < N; ++i)
         {
@@ -70,7 +70,7 @@ bool InitApiMap( const ApiMap ( &pMap )[N]  )
         if( aModule == NULL)
             continue;
 
-        tryLink( aModule, libNames[ j ], pMap );
+        tryLink( aModule, pMap );
 
         osl_unloadModule( aModule );
     }
commit 23c29305a5fa21936a1123eaa938495ffddca8aa
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Aug 5 23:58:41 2013 +0300

    Media wrapper
    
    Change-Id: Ic6bbd4e192206b9be3db1f0e44f904ec51652ea7

diff --git a/avmedia/source/vlc/wrapper/Media.cxx b/avmedia/source/vlc/wrapper/Media.cxx
new file mode 100644
index 0000000..d2cf5c1
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/Media.cxx
@@ -0,0 +1,42 @@
+#include <rtl/ustring.h>
+#include "Media.hxx"
+#include "SymbolLoader.hxx"
+#include "Instance.hxx"
+
+struct libvlc_instance_t;
+namespace VLC
+{
+    namespace
+    {
+        libvlc_media_t* ( *libvlc_media_new_path ) ( libvlc_instance_t *p_instance, const char *path );
+        void ( *libvlc_media_release )( libvlc_media_t *p_md );
+
+        ApiMap VLC_MEDIA_API[] =
+        {
+            SYM_MAP( libvlc_media_new_path ),
+            SYM_MAP( libvlc_media_release )
+        };
+
+        libvlc_media_t* InitMedia( const rtl::OUString& url, VLC::Instance& instance )
+        {
+            rtl::OString dest;
+            url.convertToString(&dest, RTL_TEXTENCODING_UTF8, 0);
+
+            return libvlc_media_new_path(instance, dest.getStr());
+        }
+
+    }
+
+
+Media::Media(const rtl::OUString& url, Instance& instance)
+{
+    InitApiMap(VLC_MEDIA_API);
+    mMedia = InitMedia( url, instance );
+}
+
+Media::~Media()
+{
+    libvlc_media_release( mMedia );
+}
+
+}
diff --git a/avmedia/source/vlc/wrapper/Media.hxx b/avmedia/source/vlc/wrapper/Media.hxx
new file mode 100644
index 0000000..cbeef02
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/Media.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _WRAPPER_MEDIA_HXX
+#define _WRAPPER_MEDIA_HXX
+
+struct libvlc_media_t;
+
+namespace rtl
+{
+    class OUString;
+}
+
+namespace VLC
+{
+    class Instance;
+    class Media
+    {
+    public:
+        Media(const rtl::OUString& url, Instance& instance);
+        virtual ~Media();
+
+        inline operator libvlc_media_t*()
+        {
+            return mMedia;
+        }
+
+    private:
+        libvlc_media_t *mMedia;
+    };
+}
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit cb3ba53e3f995d4034bc5a9113015d81a1db30a4
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Aug 5 23:57:42 2013 +0300

    API interface for libvlc_media_t
    
    Change-Id: I5e1875dabc7bdf3717540343648a9212506faf1a

diff --git a/avmedia/Library_avmediavlc.mk b/avmedia/Library_avmediavlc.mk
index 1c317e3..a04237b 100644
--- a/avmedia/Library_avmediavlc.mk
+++ b/avmedia/Library_avmediavlc.mk
@@ -12,9 +12,9 @@ $(eval $(call gb_Library_Library,avmediavlc))
 $(eval $(call gb_Library_set_componentfile,avmediavlc,avmedia/source/vlc/avmediavlc))
 
 $(eval $(call gb_Library_set_include,avmediavlc,\
-	$$(INCLUDE) \
-	-I$(SRCDIR)/avmedia/source/inc \
-	$(VLC_CFLAGS) \
+    $$(INCLUDE) \
+    -I$(SRCDIR)/avmedia/source/inc \
+    $(VLC_CFLAGS) \
 ))
 $(eval $(call gb_Library_add_libs,avmediavlc,$(VLC_LIBS)))
 
@@ -24,28 +24,29 @@ $(eval $(call gb_Library_use_sdk_api,avmediavlc))
 
 ifeq ($(OS),WNT)
 $(eval $(call gb_Library_add_defs,avmediavlc,\
-	-DWINNT
+    -DWINNT
 ))
 endif
 
 $(eval $(call gb_Library_use_libraries,avmediavlc,\
-	comphelper \
-	cppu \
-	cppuhelper \
-	sal \
-	tl \
-	vcl \
-	utl \
-	$(gb_UWINAPI) \
+    comphelper \
+    cppu \
+    cppuhelper \
+    sal \
+    tl \
+    vcl \
+    utl \
+    $(gb_UWINAPI) \
 ))
 
 $(eval $(call gb_Library_add_exception_objects,avmediavlc,\
-	avmedia/source/vlc/vlcmanager \
-	avmedia/source/vlc/vlcplayer \
-	avmedia/source/vlc/vlcuno \
-	avmedia/source/vlc/vlcwindow \
-	avmedia/source/vlc/vlcframegrabber \
-	avmedia/source/vlc/wrapper/Instance \
+    avmedia/source/vlc/vlcmanager \
+    avmedia/source/vlc/vlcplayer \
+    avmedia/source/vlc/vlcuno \
+    avmedia/source/vlc/vlcwindow \
+    avmedia/source/vlc/vlcframegrabber \
+    avmedia/source/vlc/wrapper/Instance \
+    avmedia/source/vlc/wrapper/Media \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index bcfc04f..f3e3f69 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -23,22 +23,11 @@ const char * const VLC_ARGS[] = {
 
 const int MS_IN_SEC = 1000; // Millisec in sec
 
-namespace
-{
-    libvlc_media_t* InitMedia( const rtl::OUString& url, VLC::Instance& instance )
-    {
-        rtl::OString dest;
-        url.convertToString(&dest, RTL_TEXTENCODING_UTF8, 0);
-
-        return libvlc_media_new_path(instance, dest.getStr());
-    }
-}
-
 VLCPlayer::VLCPlayer( const rtl::OUString& url )
     : VLC_Base(m_aMutex)
     , mInstance( VLC_ARGS )
-    , mMedia( InitMedia( url, mInstance ), libvlc_media_release )
-    , mPlayer( libvlc_media_player_new_from_media( mMedia.get() ), libvlc_media_player_release )
+    , mMedia( url, mInstance )
+    , mPlayer( libvlc_media_player_new_from_media( mMedia ), libvlc_media_player_release )
     , mUrl( url )
     , mPlaybackLoop( false )
 {
diff --git a/avmedia/source/vlc/vlcplayer.hxx b/avmedia/source/vlc/vlcplayer.hxx
index b7c4bed..e8d3fd0 100644
--- a/avmedia/source/vlc/vlcplayer.hxx
+++ b/avmedia/source/vlc/vlcplayer.hxx
@@ -28,6 +28,7 @@
 #include <cppuhelper/basemutex.hxx>
 
 #include "wrapper/Instance.hxx"
+#include "wrapper/Media.hxx"
 
 namespace avmedia {
 namespace vlc {
@@ -39,7 +40,7 @@ class VLCPlayer : public ::cppu::BaseMutex,
                   public VLC_Base
 {
     VLC::Instance mInstance;
-    boost::shared_ptr<libvlc_media_t> mMedia;
+    VLC::Media mMedia;
     boost::shared_ptr<libvlc_media_player_t> mPlayer;
     const rtl::OUString mUrl;
     bool mPlaybackLoop;
diff --git a/avmedia/source/vlc/wrapper/Instance.cxx b/avmedia/source/vlc/wrapper/Instance.cxx
index a150fef..301d97b 100644
--- a/avmedia/source/vlc/wrapper/Instance.cxx
+++ b/avmedia/source/vlc/wrapper/Instance.cxx
@@ -1,5 +1,4 @@
-#include <rtl/ustring.hxx>
-
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 #include "Instance.hxx"
 #include "SymbolLoader.hxx"
 
@@ -7,8 +6,8 @@ namespace VLC
 {
     namespace
     {
-        libvlc_instance_t *(*libvlc_new) (int argc, const char * const *argv);
-        void (*libvlc_release) (libvlc_instance_t *p_instance);
+        libvlc_instance_t* ( *libvlc_new ) ( int argc, const char * const *argv );
+        void ( *libvlc_release ) ( libvlc_instance_t *p_instance );
 
         ApiMap VLC_INSTANCE_API[] =
         {
@@ -30,3 +29,4 @@ namespace VLC
     }
 
 }
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 619b848b66fd6e9825655cb6e9734c58e54fbe83
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Aug 5 23:27:40 2013 +0300

    Upd the instance API
    
    Change-Id: Iba79d423336f9914ded8a121ba8f99f52c16466f

diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index 20ed327..bcfc04f 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -36,7 +36,7 @@ namespace
 
 VLCPlayer::VLCPlayer( const rtl::OUString& url )
     : VLC_Base(m_aMutex)
-    , mInstance( sizeof( VLC_ARGS ) / sizeof( VLC_ARGS[0] ), VLC_ARGS )
+    , mInstance( VLC_ARGS )
     , mMedia( InitMedia( url, mInstance ), libvlc_media_release )
     , mPlayer( libvlc_media_player_new_from_media( mMedia.get() ), libvlc_media_player_release )
     , mUrl( url )
diff --git a/avmedia/source/vlc/wrapper/Instance.cxx b/avmedia/source/vlc/wrapper/Instance.cxx
index bc231672..a150fef 100644
--- a/avmedia/source/vlc/wrapper/Instance.cxx
+++ b/avmedia/source/vlc/wrapper/Instance.cxx
@@ -17,11 +17,11 @@ namespace VLC
         };
     }
 
-    Instance::Instance( int argc, const char * const *argv )
+    Instance::Instance( const char * const argv[] )
     {
         InitApiMap( VLC_INSTANCE_API );
 
-        mInstance = libvlc_new( argc, argv );
+        mInstance = libvlc_new( sizeof( argv ) / sizeof( argv[0] ), argv );
     }
 
     Instance::~Instance()
diff --git a/avmedia/source/vlc/wrapper/Instance.hxx b/avmedia/source/vlc/wrapper/Instance.hxx
index 0cad705..8358a94 100644
--- a/avmedia/source/vlc/wrapper/Instance.hxx
+++ b/avmedia/source/vlc/wrapper/Instance.hxx
@@ -26,7 +26,7 @@ namespace VLC
     class Instance
     {
     public:
-        Instance( int argc, const char * const *argv );
+        Instance( const char * const argv[] );
         virtual ~Instance();
 
         inline operator libvlc_instance_t*()
commit 5ae5a11f2ffbdb65da94e7ec1d54779603bfedb6
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Aug 5 22:57:02 2013 +0300

    VLC::Instance Wrapper class for libvlc_instance_t
    
    Change-Id: I46beb65c13ed349b0faadfab1be888d6cbd10ff9

diff --git a/avmedia/Library_avmediavlc.mk b/avmedia/Library_avmediavlc.mk
index f17b18c..1c317e3 100644
--- a/avmedia/Library_avmediavlc.mk
+++ b/avmedia/Library_avmediavlc.mk
@@ -45,6 +45,7 @@ $(eval $(call gb_Library_add_exception_objects,avmediavlc,\
 	avmedia/source/vlc/vlcuno \
 	avmedia/source/vlc/vlcwindow \
 	avmedia/source/vlc/vlcframegrabber \
+	avmedia/source/vlc/wrapper/Instance \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index ca32ef8..20ed327 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -4,6 +4,7 @@
 #include "vlcplayer.hxx"
 #include "vlcwindow.hxx"
 #include "vlcframegrabber.hxx"
+#include "wrapper/Instance.hxx"
 
 using namespace ::com::sun::star;
 
@@ -14,31 +15,28 @@ const ::rtl::OUString AVMEDIA_VLC_PLAYER_IMPLEMENTATIONNAME = "com.sun.star.comp
 const ::rtl::OUString AVMEDIA_VLC_PLAYER_SERVICENAME = "com.sun.star.media.Player_VLC";
 
 const char * const VLC_ARGS[] = {
-//    "-I",
     "-Vdummy",
     "--snapshot-format=png",
-//    "--ignore-config",
     "--ffmpeg-threads",
     "--verbose=-1",
-//    "--quiet"
 };
 
 const int MS_IN_SEC = 1000; // Millisec in sec
 
 namespace
 {
-    libvlc_media_t* InitMedia( const rtl::OUString& url, boost::shared_ptr<libvlc_instance_t>& instance )
+    libvlc_media_t* InitMedia( const rtl::OUString& url, VLC::Instance& instance )
     {
         rtl::OString dest;
         url.convertToString(&dest, RTL_TEXTENCODING_UTF8, 0);
 
-        return libvlc_media_new_path(instance.get(), dest.getStr());
+        return libvlc_media_new_path(instance, dest.getStr());
     }
 }
 
 VLCPlayer::VLCPlayer( const rtl::OUString& url )
     : VLC_Base(m_aMutex)
-    , mInstance( libvlc_new( sizeof( VLC_ARGS ) / sizeof( VLC_ARGS[0] ), VLC_ARGS ), libvlc_release )
+    , mInstance( sizeof( VLC_ARGS ) / sizeof( VLC_ARGS[0] ), VLC_ARGS )
     , mMedia( InitMedia( url, mInstance ), libvlc_media_release )
     , mPlayer( libvlc_media_player_new_from_media( mMedia.get() ), libvlc_media_player_release )
     , mUrl( url )
@@ -108,7 +106,7 @@ namespace
         case libvlc_MediaPlayerEndReached:
             boost::shared_ptr<libvlc_media_player_t> player = *static_cast< boost::shared_ptr<libvlc_media_player_t>* >( pData );
             libvlc_media_player_stop( player.get() );
-            libvlc_media_player_play( player.get() )
+            libvlc_media_player_play( player.get() );
             break;
         }
     }
diff --git a/avmedia/source/vlc/vlcplayer.hxx b/avmedia/source/vlc/vlcplayer.hxx
index acdee37..b7c4bed 100644
--- a/avmedia/source/vlc/vlcplayer.hxx
+++ b/avmedia/source/vlc/vlcplayer.hxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/media/XPlayer.hpp>
 #include <cppuhelper/basemutex.hxx>
 
+#include "wrapper/Instance.hxx"
 
 namespace avmedia {
 namespace vlc {
@@ -37,7 +38,7 @@ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::media::XPlayer,
 class VLCPlayer : public ::cppu::BaseMutex,
                   public VLC_Base
 {
-    boost::shared_ptr<libvlc_instance_t> mInstance;
+    VLC::Instance mInstance;
     boost::shared_ptr<libvlc_media_t> mMedia;
     boost::shared_ptr<libvlc_media_player_t> mPlayer;
     const rtl::OUString mUrl;
@@ -74,4 +75,4 @@ public:
 
 #endif
 
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/vlc/wrapper/Instance.cxx b/avmedia/source/vlc/wrapper/Instance.cxx
new file mode 100644
index 0000000..bc231672
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/Instance.cxx
@@ -0,0 +1,32 @@
+#include <rtl/ustring.hxx>
+
+#include "Instance.hxx"
+#include "SymbolLoader.hxx"
+
+namespace VLC
+{
+    namespace
+    {
+        libvlc_instance_t *(*libvlc_new) (int argc, const char * const *argv);
+        void (*libvlc_release) (libvlc_instance_t *p_instance);
+
+        ApiMap VLC_INSTANCE_API[] =
+        {
+            SYM_MAP( libvlc_new ),
+            SYM_MAP( libvlc_release )
+        };
+    }
+
+    Instance::Instance( int argc, const char * const *argv )
+    {
+        InitApiMap( VLC_INSTANCE_API );
+
+        mInstance = libvlc_new( argc, argv );
+    }
+
+    Instance::~Instance()
+    {
+        libvlc_release( mInstance );
+    }
+
+}
diff --git a/avmedia/source/vlc/wrapper/Instance.hxx b/avmedia/source/vlc/wrapper/Instance.hxx
new file mode 100644
index 0000000..0cad705
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/Instance.hxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _WRAPPER_INSTANCE_HXX
+#define _WRAPPER_INSTANCE_HXX
+
+struct libvlc_instance_t;
+
+namespace VLC
+{
+    class Instance
+    {
+    public:
+        Instance( int argc, const char * const *argv );
+        virtual ~Instance();
+
+        inline operator libvlc_instance_t*()
+        {
+            return mInstance;
+        }
+
+    private:
+        libvlc_instance_t *mInstance;
+    };
+}
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3e51dc6fe61a9bba90bb3b7e1d28a2146059063b
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Aug 5 22:55:51 2013 +0300

    libvlc API symbol loader routines
    
    Change-Id: I6800c7a75dbcdec53119f5f4da341aeb33c9d574

diff --git a/avmedia/source/vlc/wrapper/SymbolLoader.hxx b/avmedia/source/vlc/wrapper/SymbolLoader.hxx
new file mode 100644
index 0000000..5e61258
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/SymbolLoader.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _SYMBOL_LOADER_HXX
+#define _SYMBOL_LOADER_HXX
+#include <iostream>
+#include <osl/module.h>
+#include <rtl/ustring.hxx>
+
+#define SYM_MAP(a) { #a, (SymbolFunc *)&a }
+
+typedef void (*SymbolFunc) (void);
+
+struct ApiMap
+{
+    const char *symName;
+    SymbolFunc *refValue;
+};
+
+namespace
+{
+    const char *libNames[] = {
+        "libvlc.so.5",
+        "libvlccore.so.5"
+    };
+
+    template<size_t N> static bool
+    tryLink( oslModule &aModule, const char *pName, const ApiMap ( &pMap )[N] )
+    {
+        for (uint i = 0; i < N; ++i)
+        {
+            SymbolFunc aMethod = ( SymbolFunc )osl_getFunctionSymbol
+                ( aModule, OUString::createFromAscii ( pMap[ i ].symName ).pData );
+            if ( !aMethod )
+                return false;
+
+            *pMap[ i ].refValue = aMethod;
+        }
+
+        return true;
+    }
+}
+
+template<size_t N>
+bool InitApiMap( const ApiMap ( &pMap )[N]  )
+{
+    oslModule aModule;
+
+    for (uint j = 0; j < sizeof(libNames) / sizeof(libNames[0]); ++j)
+    {
+        aModule = osl_loadModule( OUString::createFromAscii
+                                  ( libNames[ j ] ).pData,
+                                  SAL_LOADMODULE_DEFAULT );
+
+        if( aModule == NULL)
+            continue;
+
+        tryLink( aModule, libNames[ j ], pMap );
+
+        osl_unloadModule( aModule );
+    }
+
+    return false;
+}
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 4f36924fcb92e54019d96811efb01bc7c3f6881b
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Wed Jul 31 09:18:36 2013 +0300

    Playback loop
    
    Change-Id: I18c544dadb553e7e173e9e377a337aa2b7eecb60

diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx
index efabd39..4630f15 100644
--- a/avmedia/source/vlc/vlcframegrabber.cxx
+++ b/avmedia/source/vlc/vlcframegrabber.cxx
@@ -34,7 +34,7 @@ namespace
 {
     void EventHandler( const libvlc_event_t *evemt, void *pData )
     {
-        switch (evemt->type)
+        switch ( evemt->type )
         {
         case libvlc_MediaPlayerPaused:
             osl::Condition *condition = static_cast<osl::Condition*>( pData );
@@ -53,7 +53,7 @@ namespace
     libvlc_event_attach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
 
     libvlc_audio_set_mute( player, true );
-    if (libvlc_media_player_play( player ) == -1)
+    if ( libvlc_media_player_play( player ) == -1 )
     {
         std::cerr << "Couldn't play" << std::endl;
     }
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index c4628ed..ca32ef8 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -42,6 +42,7 @@ VLCPlayer::VLCPlayer( const rtl::OUString& url )
     , mMedia( InitMedia( url, mInstance ), libvlc_media_release )
     , mPlayer( libvlc_media_player_new_from_media( mMedia.get() ), libvlc_media_player_release )
     , mUrl( url )
+    , mPlaybackLoop( false )
 {
 }
 
@@ -98,13 +99,38 @@ double SAL_CALL VLCPlayer::getRate()
     return libvlc_media_player_get_rate( mPlayer.get() );
 }
 
+namespace
+{
+    void EventHandler( const libvlc_event_t *evemt, void *pData )
+    {
+        switch (evemt->type)
+        {
+        case libvlc_MediaPlayerEndReached:
+            boost::shared_ptr<libvlc_media_player_t> player = *static_cast< boost::shared_ptr<libvlc_media_player_t>* >( pData );
+            libvlc_media_player_stop( player.get() );
+            libvlc_media_player_play( player.get() )
+            break;
+        }
+    }
+}
+
 void SAL_CALL VLCPlayer::setPlaybackLoop( ::sal_Bool bSet )
 {
+    ::osl::MutexGuard aGuard(m_aMutex);
+    mPlaybackLoop = bSet;
+
+    libvlc_event_manager_t *manager = libvlc_media_player_event_manager( mPlayer.get() );
+
+    if ( bSet )
+        libvlc_event_attach( manager, libvlc_MediaPlayerEndReached, EventHandler, &mPlayer );
+    else
+        libvlc_event_detach( manager, libvlc_MediaPlayerEndReached, EventHandler, &mPlayer );
 }
 
 ::sal_Bool SAL_CALL VLCPlayer::isPlaybackLoop()
 {
-    return false;
+    ::osl::MutexGuard aGuard(m_aMutex);
+    return mPlaybackLoop;
 }
 
 void SAL_CALL VLCPlayer::setVolumeDB( ::sal_Int16 nDB )
@@ -210,4 +236,4 @@ uno::Reference< css::media::XFrameGrabber > SAL_CALL VLCPlayer::createFrameGrabb
 }
 }
 
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/vlc/vlcplayer.hxx b/avmedia/source/vlc/vlcplayer.hxx
index 8113602..acdee37 100644
--- a/avmedia/source/vlc/vlcplayer.hxx
+++ b/avmedia/source/vlc/vlcplayer.hxx
@@ -41,6 +41,7 @@ class VLCPlayer : public ::cppu::BaseMutex,
     boost::shared_ptr<libvlc_media_t> mMedia;
     boost::shared_ptr<libvlc_media_player_t> mPlayer;
     const rtl::OUString mUrl;
+    bool mPlaybackLoop;
 public:
     VLCPlayer( const rtl::OUString& url );
 
commit 2a6b3cb7616abd80ed59304facde14a23387dd1d
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Jul 29 23:49:18 2013 +0300

    Optimizing VLC player initialization process.
    
    Manager checks if an URL is the same or empty.
    
    Change-Id: I4ab2db31f73fef45feff1973fa82452dc579ef9d

diff --git a/avmedia/source/vlc/vlcmanager.cxx b/avmedia/source/vlc/vlcmanager.cxx
index 0b2ad6a..a3e762b 100644
--- a/avmedia/source/vlc/vlcmanager.cxx
+++ b/avmedia/source/vlc/vlcmanager.cxx
@@ -21,10 +21,13 @@ Manager::~Manager()
 uno::Reference< media::XPlayer > SAL_CALL Manager::createPlayer( const rtl::OUString& rURL )
     throw (uno::RuntimeException)
 {
-    VLCPlayer* pPlayer( new VLCPlayer( rURL/*, mxMgr */ ) );
-    uno::Reference< media::XPlayer > xRet( pPlayer );
+    if ( !rURL.isEmpty() || (mPlayer.is() && dynamic_cast<VLCPlayer*>( mPlayer.get() )->url() != rURL))
+    {
+        VLCPlayer* pPlayer( new VLCPlayer( rURL/*, mxMgr */ ) );
+        mPlayer = uno::Reference< media::XPlayer >( pPlayer );
+    }
 
-    return xRet;
+    return mPlayer;
 }
 
 rtl::OUString SAL_CALL Manager::getImplementationName()
diff --git a/avmedia/source/vlc/vlcmanager.hxx b/avmedia/source/vlc/vlcmanager.hxx
index 2e81a35..9417480 100644
--- a/avmedia/source/vlc/vlcmanager.hxx
+++ b/avmedia/source/vlc/vlcmanager.hxx
@@ -42,6 +42,7 @@ public:
 
 private:
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr;
+    ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer >  mPlayer;
 };
 
 }
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index 34ebb00..c4628ed 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -14,11 +14,13 @@ const ::rtl::OUString AVMEDIA_VLC_PLAYER_IMPLEMENTATIONNAME = "com.sun.star.comp
 const ::rtl::OUString AVMEDIA_VLC_PLAYER_SERVICENAME = "com.sun.star.media.Player_VLC";
 
 const char * const VLC_ARGS[] = {
-    "-I",
+//    "-I",
     "-Vdummy",
-    "--ignore-config",
+    "--snapshot-format=png",
+//    "--ignore-config",
+    "--ffmpeg-threads",
     "--verbose=-1",
-    "--quiet"
+//    "--quiet"
 };
 
 const int MS_IN_SEC = 1000; // Millisec in sec
@@ -43,6 +45,11 @@ VLCPlayer::VLCPlayer( const rtl::OUString& url )
 {
 }
 
+const rtl::OUString& VLCPlayer::url() const
+{
+    return mUrl;
+}
+
 void SAL_CALL VLCPlayer::start()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
diff --git a/avmedia/source/vlc/vlcplayer.hxx b/avmedia/source/vlc/vlcplayer.hxx
index 00a55eb..8113602 100644
--- a/avmedia/source/vlc/vlcplayer.hxx
+++ b/avmedia/source/vlc/vlcplayer.hxx
@@ -44,6 +44,8 @@ class VLCPlayer : public ::cppu::BaseMutex,
 public:
     VLCPlayer( const rtl::OUString& url );
 
+    const rtl::OUString& url() const;
+
     void SAL_CALL start();
     void SAL_CALL stop();
     ::sal_Bool SAL_CALL isPlaying();
commit 569533275a23faa774f6b1c972ff99d872ea8da9
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Jul 29 23:47:20 2013 +0300

    Upd frame grabber. Will work with this patch [1][2].
    
    [1] vlc git 5a43de506f31e1fa5460f8b62e25a1d640136597
    [2] http://git.videolan.org/gitweb.cgi/vlc.git/?p=vlc.git;a=commitdiff_plain;h=5a43de506f31e1fa5460f8b62e25a1d640136597
    
    Change-Id: I2aa0b4c579ff534e20a425919f0efba59101d7af

diff --git a/avmedia/Library_avmediavlc.mk b/avmedia/Library_avmediavlc.mk
index 06fb035..f17b18c 100644
--- a/avmedia/Library_avmediavlc.mk
+++ b/avmedia/Library_avmediavlc.mk
@@ -35,6 +35,7 @@ $(eval $(call gb_Library_use_libraries,avmediavlc,\
 	sal \
 	tl \
 	vcl \
+	utl \
 	$(gb_UWINAPI) \
 ))
 
diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx
index a189190..efabd39 100644
--- a/avmedia/source/vlc/vlcframegrabber.cxx
+++ b/avmedia/source/vlc/vlcframegrabber.cxx
@@ -1,11 +1,18 @@
 #include <osl/conditn.hxx>
-#include <vcl/bmpacc.hxx>
 #include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/pngread.hxx>
 #include <avmedia/mediawindow.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <unotools/tempfile.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <tools/stream.hxx>
+
 #include "vlcframegrabber.hxx"
 #include "vlcplayer.hxx"
+
+#include <vlc/libvlc_events.h>
 #include <vlc/libvlc_media_player.h>
-#include <boost/bind.hpp>
 
 using namespace ::com::sun::star;
 
@@ -23,15 +30,68 @@ SAL_CALL VLCFrameGrabber::VLCFrameGrabber( boost::shared_ptr<libvlc_media_player
 {
 }
 
+namespace
+{
+    void EventHandler( const libvlc_event_t *evemt, void *pData )
+    {
+        switch (evemt->type)
+        {
+        case libvlc_MediaPlayerPaused:
+            osl::Condition *condition = static_cast<osl::Condition*>( pData );
+            condition->set();
+            break;
+        }
+    }
+}
+
 ::uno::Reference< css::graphic::XGraphic > SAL_CALL VLCFrameGrabber::grabFrame( double fMediaTime )
 {
-    if ( mUrl.isEmpty() )
+    osl::Condition condition;
+
+    libvlc_media_player_t *player = mPlayer.get();
+    libvlc_event_manager_t *manager = libvlc_media_player_event_manager( player );
+    libvlc_event_attach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
+
+    libvlc_audio_set_mute( player, true );
+    if (libvlc_media_player_play( player ) == -1)
+    {
+        std::cerr << "Couldn't play" << std::endl;
+    }
+
+    libvlc_media_player_set_time( player, ( fMediaTime > 0 ? fMediaTime : 0 ) * MSEC_IN_SEC );
+
+    libvlc_media_player_pause( player );
+    const TimeValue timeout = {2, 0};
+    condition.wait(&timeout);
+
+    if ( mUrl.isEmpty() || !libvlc_media_player_has_vout( player ) )
+    {
+        std::cerr << "Couldn't grab frame" << std::endl;
+        libvlc_audio_set_mute( player, false );
+
+        libvlc_event_detach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
         return ::uno::Reference< css::graphic::XGraphic >();
+    }
+
+    const rtl::OUString& fileName = utl::TempFile::CreateTempName();
+    rtl::OString dest;
+    fileName.convertToString( &dest, RTL_TEXTENCODING_UTF8, 0 );
+
+    libvlc_video_take_snapshot( player, 0, dest.getStr(), 0, 0 );
+    libvlc_audio_set_mute( player, false );
+    libvlc_media_player_stop( player );
+    libvlc_event_detach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
+
+    rtl::OUString url;
+    utl::LocalFileHelper::ConvertPhysicalNameToURL( fileName, url );
+    boost::shared_ptr<SvStream> stream( utl::UcbStreamHelper::CreateStream( url,
+                                                                            STREAM_STD_READ ) );
+
+    vcl::PNGReader reader( *stream );
 
-    // libvlc_video_take_snapshot must be used, but it doesn't work for PNG files
-    //
+    const BitmapEx& bitmap = reader.Read();
 
-    return ::uno::Reference< css::graphic::XGraphic >();
+    return Graphic( bitmap ).GetXGraphic();
 }
 
 ::rtl::OUString SAL_CALL VLCFrameGrabber::getImplementationName()
commit 872b10fe417a4ff06a14cff0de0ebea9fd12ac4a
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Mon Jul 29 08:11:31 2013 +0300

    Removing bad code. Fixing VLC starting arguments.
    
    Change-Id: I095638260d08d5d2fd67c93a42dbdbfe19581b75

diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx
index ec5b959..a189190 100644
--- a/avmedia/source/vlc/vlcframegrabber.cxx
+++ b/avmedia/source/vlc/vlcframegrabber.cxx
@@ -5,6 +5,7 @@
 #include "vlcframegrabber.hxx"
 #include "vlcplayer.hxx"
 #include <vlc/libvlc_media_player.h>
+#include <boost/bind.hpp>
 
 using namespace ::com::sun::star;
 
@@ -22,100 +23,15 @@ SAL_CALL VLCFrameGrabber::VLCFrameGrabber( boost::shared_ptr<libvlc_media_player
 {
 }
 
-namespace
-{
-    struct FrameData
-    {
-        ::osl::Condition mCondition;
-
-        std::vector<sal_uInt8> buffer;
-
-        libvlc_media_player_t *mpPlayer;
-
-        FrameData( libvlc_media_player_t *pPlayer )
-            : mpPlayer( pPlayer )
-        {
-        }
-
-        void updateSize()
-        {
-            unsigned int w, h;
-            libvlc_video_get_size( mpPlayer, 0, &w, &h );
-
-            buffer.resize(w * h * 3);
-        }
-
-        ~FrameData()
-        {
-        }
-    };
-
-    void *FrameLock( void *data, void **pPixels )
-    {
-        FrameData *frameData = static_cast<FrameData*>( data );
-
-        frameData->updateSize();
-
-        *pPixels = frameData->buffer.data();
-
-        return *pPixels;
-    }
-
-    void FrameUnlock( void *data, void */* id */, void *const * /* pPixels */ )
-    {
-        FrameData *frameData = static_cast<FrameData*>( data );
-
-        frameData->mCondition.set();
-    }
-
-    void FrameDisplay( void */* data */, void */* id */ )
-    {
-    }
-}
-
 ::uno::Reference< css::graphic::XGraphic > SAL_CALL VLCFrameGrabber::grabFrame( double fMediaTime )
 {
     if ( mUrl.isEmpty() )
         return ::uno::Reference< css::graphic::XGraphic >();
 
-    libvlc_media_player_t *pPlayer = mPlayer.get();
-    FrameData frameData( pPlayer );
-    libvlc_video_set_callbacks( pPlayer, FrameLock, FrameUnlock, FrameDisplay, &frameData );
-
-    const unsigned int w = 480, h = 360;
-
-    libvlc_video_set_format( pPlayer, "RV24", w, h, w * 3 );
-
-    libvlc_media_player_set_time( pPlayer, fMediaTime * MSEC_IN_SEC );
-    libvlc_media_player_play( pPlayer );
-
-    const TimeValue t = {2, 0};
-    frameData.mCondition.wait( &t );
-
-    if ( !frameData.mCondition.check() )
-        return ::uno::Reference< css::graphic::XGraphic >();
-
-    Bitmap aBmp( Size( w, h ), 24 );
-
-    sal_uInt8 *pData = frameData.buffer.data();
-    BitmapWriteAccess *pWrite = aBmp.AcquireWriteAccess();
-    if ( pWrite )
-    {
-        for ( std::size_t y = 0; y < h; ++y )
-        {
-            for ( std::size_t x = 0; x < w; ++x )
-            {
-                sal_uInt8 *p = pData + ( y * w + x ) * 3;
-                BitmapColor col( p[0], p[1], p[2] );
-                pWrite->SetPixel( y, x, col );
-            }
-        }
-    }
-    aBmp.ReleaseAccess( pWrite );
-
-    libvlc_media_player_stop( pPlayer );
+    // libvlc_video_take_snapshot must be used, but it doesn't work for PNG files
+    //
 
-    return Graphic( aBmp ).GetXGraphic();
+    return ::uno::Reference< css::graphic::XGraphic >();
 }
 
 ::rtl::OUString SAL_CALL VLCFrameGrabber::getImplementationName()
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index 92e0614..34ebb00 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -15,7 +15,7 @@ const ::rtl::OUString AVMEDIA_VLC_PLAYER_SERVICENAME = "com.sun.star.media.Playe
 
 const char * const VLC_ARGS[] = {
     "-I",
-    "dummy",
+    "-Vdummy",
     "--ignore-config",
     "--verbose=-1",
     "--quiet"
@@ -37,11 +37,10 @@ namespace
 VLCPlayer::VLCPlayer( const rtl::OUString& url )
     : VLC_Base(m_aMutex)
     , mInstance( libvlc_new( sizeof( VLC_ARGS ) / sizeof( VLC_ARGS[0] ), VLC_ARGS ), libvlc_release )
-    , mPlayer( libvlc_media_player_new( mInstance.get() ), libvlc_media_player_release )
+    , mMedia( InitMedia( url, mInstance ), libvlc_media_release )
+    , mPlayer( libvlc_media_player_new_from_media( mMedia.get() ), libvlc_media_player_release )
     , mUrl( url )
 {
-    boost::shared_ptr<libvlc_media_t> media( InitMedia( url, mInstance ), libvlc_media_release );
-    mPlayer.reset( libvlc_media_player_new_from_media( media.get() ), libvlc_media_player_release );
 }
 
 void SAL_CALL VLCPlayer::start()
@@ -180,7 +179,6 @@ uno::Reference< css::media::XPlayerWindow > SAL_CALL VLCPlayer::createPlayerWind
 uno::Reference< css::media::XFrameGrabber > SAL_CALL VLCPlayer::createFrameGrabber()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-
     VLCFrameGrabber *frameGrabber = new VLCFrameGrabber( mPlayer, mUrl );
     return uno::Reference< css::media::XFrameGrabber >( frameGrabber );
 }
diff --git a/avmedia/source/vlc/vlcplayer.hxx b/avmedia/source/vlc/vlcplayer.hxx
index 0c29f3f..00a55eb 100644
--- a/avmedia/source/vlc/vlcplayer.hxx
+++ b/avmedia/source/vlc/vlcplayer.hxx
@@ -38,6 +38,7 @@ class VLCPlayer : public ::cppu::BaseMutex,
                   public VLC_Base
 {
     boost::shared_ptr<libvlc_instance_t> mInstance;
+    boost::shared_ptr<libvlc_media_t> mMedia;
     boost::shared_ptr<libvlc_media_player_t> mPlayer;
     const rtl::OUString mUrl;
 public:


More information about the Libreoffice-commits mailing list