Kaydet (Commit) 6a9d3e7f authored tarafından Minh Ngo's avatar Minh Ngo

Avmedia/VLC component code refactoring.

Change-Id: Ibba5874e63356069d1af725d98980910dbaf8eb1
üst b3e0c808
......@@ -35,7 +35,7 @@ namespace
};
}
VLCFrameGrabber::VLCFrameGrabber( VLC::EventHandler& eh, const rtl::OUString& url )
VLCFrameGrabber::VLCFrameGrabber( wrapper::EventHandler& eh, const rtl::OUString& url )
: FrameGrabber_BASE()
, mInstance( sizeof( VLC_ARGS ) / sizeof( VLC_ARGS[0] ), VLC_ARGS )
, mMedia( url, mInstance )
......@@ -51,7 +51,7 @@ VLCFrameGrabber::VLCFrameGrabber( VLC::EventHandler& eh, const rtl::OUString& ur
const rtl::OUString& fileName = utl::TempFile::CreateTempName();
{
VLC::EventManager manager( mPlayer, mEventHandler );
wrapper::EventManager manager( mPlayer, mEventHandler );
manager.onPaused(boost::bind(&osl::Condition::set, &condition));
if ( !mPlayer.play() )
......
......@@ -26,11 +26,6 @@
#include "vlccommon.hxx"
#include "wrapper/Wrapper.hxx"
namespace VLC
{
class EventHandler;
}
namespace avmedia {
namespace vlc {
......@@ -39,18 +34,22 @@ typedef ::cppu::WeakImplHelper2< ::com::sun::star::media::XFrameGrabber,
class VLCFrameGrabber : public FrameGrabber_BASE
{
VLC::Instance mInstance;
VLC::Media mMedia;
VLC::Player mPlayer;
VLC::EventHandler& mEventHandler;
wrapper::Instance mInstance;
wrapper::Media mMedia;
wrapper::Player mPlayer;
wrapper::EventHandler& mEventHandler;
public:
VLCFrameGrabber( VLC::EventHandler& eh, const rtl::OUString& url );
VLCFrameGrabber( wrapper::EventHandler& eh, const rtl::OUString& url );
::com::sun::star::uno::Reference< css::graphic::XGraphic > SAL_CALL grabFrame( double fMediaTime ) throw ( ::com::sun::star::uno::RuntimeException );
::com::sun::star::uno::Reference< css::graphic::XGraphic > SAL_CALL grabFrame( double fMediaTime )
throw ( ::com::sun::star::uno::RuntimeException );
::rtl::OUString SAL_CALL getImplementationName() throw ( ::com::sun::star::uno::RuntimeException );
::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& serviceName ) throw ( ::com::sun::star::uno::RuntimeException );
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw ( ::com::sun::star::uno::RuntimeException );
::rtl::OUString SAL_CALL getImplementationName()
throw ( ::com::sun::star::uno::RuntimeException );
::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& serviceName )
throw ( ::com::sun::star::uno::RuntimeException );
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
throw ( ::com::sun::star::uno::RuntimeException );
};
}
......
......@@ -37,7 +37,7 @@ Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr )
: mEventHandler()
, mxMgr( rxMgr )
{
using namespace VLC;
using namespace wrapper;
static bool success = Instance::LoadSymbols() && EventManager::LoadSymbols()
&& Media::LoadSymbols() && Player::LoadSymbols()
&& Common::LoadSymbols();
......
......@@ -30,8 +30,8 @@ namespace vlc {
class Manager : public ::cppu::WeakImplHelper2 < ::com::sun::star::media::XManager,
::com::sun::star::lang::XServiceInfo >
{
boost::scoped_ptr<VLC::Instance> mInstance;
VLC::EventHandler mEventHandler;
boost::scoped_ptr<wrapper::Instance> mInstance;
wrapper::EventHandler mEventHandler;
public:
Manager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMgr );
~Manager();
......
......@@ -22,8 +22,8 @@ namespace
}
VLCPlayer::VLCPlayer( const rtl::OUString& url,
VLC::Instance& instance,
VLC::EventHandler& eh )
wrapper::Instance& instance,
wrapper::EventHandler& eh )
: VLC_Base( m_aMutex )
, mInstance( instance )
, mEventHandler( eh )
......
......@@ -42,19 +42,19 @@ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::media::XPlayer,
class VLCPlayer : public ::cppu::BaseMutex,
public VLC_Base
{
VLC::Instance& mInstance;
VLC::EventHandler& mEventHandler;
wrapper::Instance& mInstance;
wrapper::EventHandler& mEventHandler;
VLC::Media mMedia;
VLC::Player mPlayer;
VLC::EventManager mEventManager;
wrapper::Media mMedia;
wrapper::Player mPlayer;
wrapper::EventManager mEventManager;
const rtl::OUString mUrl;
bool mPlaybackLoop;
::com::sun::star::uno::Reference< css::media::XFrameGrabber > mrFrameGrabber;
public:
VLCPlayer( const rtl::OUString& url,
VLC::Instance& instance,
VLC::EventHandler& eh );
wrapper::Instance& instance,
wrapper::EventHandler& eh );
void SAL_CALL start() throw ( ::com::sun::star::uno::RuntimeException );
void SAL_CALL stop() throw ( ::com::sun::star::uno::RuntimeException );
......
......@@ -6,8 +6,11 @@ using namespace ::com::sun::star;
namespace avmedia {
namespace vlc {
const ::rtl::OUString AVMEDIA_VLC_WINDOW_IMPLEMENTATIONNAME = "com.sun.star.comp.avmedia.Window_VLC";
const ::rtl::OUString AVMEDIA_VLC_WINDOW_SERVICENAME = "com.sun.star.media.Window_VLC";
namespace
{
const ::rtl::OUString AVMEDIA_VLC_WINDOW_IMPLEMENTATIONNAME = "com.sun.star.comp.avmedia.Window_VLC";
const ::rtl::OUString AVMEDIA_VLC_WINDOW_SERVICENAME = "com.sun.star.media.Window_VLC";
}
VLCWindow::VLCWindow()
{
......
......@@ -9,13 +9,17 @@
#include "Common.hxx"
#include "SymbolLoader.hxx"
namespace VLC
{
namespace
{
const char* (*libvlc_get_version)(void);
const char* ( *libvlc_get_version ) (void);
}
namespace avmedia
{
namespace vlc
{
namespace wrapper
{
bool Common::LoadSymbols()
{
ApiMap VLC_COMMON_API[] =
......@@ -30,4 +34,6 @@ const char* Common::Version()
{
return libvlc_get_version();
}
}
}
}
\ No newline at end of file
......@@ -10,7 +10,11 @@
#ifndef _WRAPPER_COMMON_HXX
#define _WRAPPER_COMMON_HXX
namespace VLC
namespace avmedia
{
namespace vlc
{
namespace wrapper
{
class Common
{
......@@ -19,6 +23,8 @@ namespace VLC
static const char* Version();
};
}
}
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
......@@ -9,7 +9,11 @@
#include "EventHandler.hxx"
namespace VLC
namespace avmedia
{
namespace vlc
{
namespace wrapper
{
EventHandler::EventHandler()
: ::osl::Thread()
......@@ -35,7 +39,8 @@ void EventHandler::run()
callback();
} while ( true );
}
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
......@@ -10,12 +10,17 @@
#ifndef _WRAPPER_EVENT_HANDLER_HXX
#define _WRAPPER_EVENT_HANDLER_HXX
#include <boost/function.hpp>
#include <boost/noncopyable.hpp>
#include <salhelper/thread.hxx>
#include "ThreadsafeQueue.hxx"
namespace VLC
namespace avmedia
{
class EventHandler : public ::osl::Thread
namespace vlc
{
namespace wrapper
{
class EventHandler : public ::osl::Thread, boost::noncopyable
{
public:
EventHandler();
......@@ -26,9 +31,11 @@ namespace VLC
public:
typedef boost::function< void() > TCallback;
avmedia::vlc::ThreadsafeQueue< TCallback > mCallbackQueue;
ThreadsafeQueue< TCallback > mCallbackQueue;
};
}
}
}
#endif // _WRAPPER_EVENT_HANDLER_HXX
......
......@@ -12,25 +12,28 @@
#include "EventHandler.hxx"
#include "Types.hxx"
namespace VLC
namespace
{
namespace
{
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 );
}
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 );
}
namespace avmedia
{
namespace vlc
{
namespace wrapper
{
void EventManager::Handler( const libvlc_event_t *event, void *pData )
{
EventManager *instance = static_cast<EventManager*>( pData );
std::cout << "HANDLER" << std::endl;
switch ( event->type )
{
case libvlc_MediaPlayerPaused:
......@@ -54,7 +57,7 @@ bool EventManager::LoadSymbols()
return InitApiMap( VLC_EVENT_MANAGER_API );
}
EventManager::EventManager( VLC::Player& player, VLC::EventHandler& eh )
EventManager::EventManager( Player& player, EventHandler& eh )
: mEventHandler( eh )
, mManager( libvlc_media_player_event_manager( player ) )
{
......@@ -80,7 +83,8 @@ void EventManager::onEndReached( const Callback& callback )
mOnEndReached = callback;
registerSignal( libvlc_MediaPlayerEndReached, callback );
}
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -11,30 +11,33 @@
#define _WRAPPER_EVENT_MANAGER_HXX
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
#include "Player.hxx"
struct libvlc_event_manager_t;
struct libvlc_event_t;
namespace VLC
namespace avmedia
{
namespace vlc
{
namespace wrapper
{
class EventHandler;
class EventManager
class EventManager : boost::noncopyable
{
public:
static bool LoadSymbols();
typedef boost::function<void()> Callback;
EventManager( VLC::Player& player, VLC::EventHandler& eh );
EventManager( Player& player, EventHandler& eh );
void onPaused( const Callback& callback = Callback() );
void onEndReached( const Callback& callback = Callback() );
private:
VLC::EventHandler& mEventHandler;
EventHandler& mEventHandler;
typedef boost::function< void() > TCallback;
libvlc_event_manager_t *mManager;
TCallback mOnPaused;
......@@ -45,6 +48,8 @@ namespace VLC
static void Handler( const libvlc_event_t *event, void *pData );
};
}
}
}
#endif
......
......@@ -10,15 +10,19 @@
#include "Instance.hxx"
#include "SymbolLoader.hxx"
namespace VLC
namespace
{
namespace
{
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 );
}
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 );
}
namespace avmedia
{
namespace vlc
{
namespace wrapper
{
bool Instance::LoadSymbols()
{
ApiMap VLC_INSTANCE_API[] =
......@@ -38,7 +42,7 @@ namespace VLC
Instance::Instance( const Instance& other )
{
operator=(other);
operator=( other );
}
const Instance& Instance::operator=( const Instance& other )
......@@ -53,7 +57,8 @@ namespace VLC
{
libvlc_release( mInstance );
}
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -12,7 +12,11 @@
struct libvlc_instance_t;
namespace VLC
namespace avmedia
{
namespace vlc
{
namespace wrapper
{
class Instance
{
......@@ -32,6 +36,8 @@ namespace VLC
libvlc_instance_t *mInstance;
};
}
}
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -14,23 +14,28 @@
#include "Types.hxx"
struct libvlc_instance_t;
namespace VLC
namespace avmedia
{
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_retain ) ( libvlc_media_t *p_md );
libvlc_time_t ( *libvlc_media_get_duration ) ( libvlc_media_t *p_md );
namespace vlc
{
namespace wrapper
{
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_retain ) ( libvlc_media_t *p_md );
libvlc_time_t ( *libvlc_media_get_duration ) ( libvlc_media_t *p_md );
libvlc_media_t* InitMedia( const rtl::OUString& url, VLC::Instance& instance )
{
rtl::OString dest;
url.convertToString(&dest, RTL_TEXTENCODING_UTF8, 0);
libvlc_media_t* InitMedia( const rtl::OUString& url, Instance& instance )
{
rtl::OString dest;
url.convertToString(&dest, RTL_TEXTENCODING_UTF8, 0);
return libvlc_media_new_path(instance, dest.getStr());
}
return libvlc_media_new_path(instance, dest.getStr());
}
}
bool Media::LoadSymbols()
{
......@@ -52,7 +57,7 @@ Media::Media( const rtl::OUString& url, Instance& instance )
Media::Media( const Media& other )
{
operator=(other);
operator=( other );
}
const Media& Media::operator=( const Media& other )
......@@ -77,7 +82,8 @@ Media::~Media()
{
libvlc_media_release( mMedia );
}
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -14,7 +14,11 @@ struct libvlc_media_t;
namespace rtl { class OUString; }
namespace VLC
namespace avmedia
{
namespace vlc
{
namespace wrapper
{
class Instance;
class Media
......@@ -38,6 +42,8 @@ namespace VLC
libvlc_media_t *mMedia;
};
}
}
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -14,40 +14,47 @@
#include "SymbolLoader.hxx"
struct libvlc_media_t;
namespace VLC
namespace
{
namespace
{
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 );
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 );
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_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 );
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 );
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 );
#if defined UNX
void ( *libvlc_media_player_set_xwindow ) ( libvlc_media_player_t *p_mi, uint32_t drawable );
void ( *libvlc_media_player_set_xwindow ) ( libvlc_media_player_t *p_mi, uint32_t drawable );
#elif defined MACOSX
void ( *libvlc_media_player_set_nsobject ) ( libvlc_media_player_t *p_mi, void *drawable );
void ( *libvlc_media_player_set_nsobject ) ( libvlc_media_player_t *p_mi, void *drawable );
#elif defined WNT
void ( *libvlc_media_player_set_hwnd ) ( libvlc_media_player_t *p_mi, void *drawable );
void ( *libvlc_media_player_set_hwnd ) ( libvlc_media_player_t *p_mi, void *drawable );
#else
#error unknown OS
#endif
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);
}
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);
}
namespace avmedia
{
namespace vlc
{
namespace wrapper
{
bool Player::LoadSymbols()
{
ApiMap VLC_PLAYER_API[] =
......@@ -190,5 +197,7 @@ namespace VLC
return libvlc_media_player_has_vout( mPlayer );
}
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -20,7 +20,11 @@ namespace rtl
class OUString;
}
namespace VLC
namespace avmedia
{
namespace vlc
{
namespace wrapper
{
class Media;
class Player
......@@ -63,6 +67,8 @@ namespace VLC
libvlc_media_player_t *mPlayer;
};
}
}
}
#endif
......
......@@ -19,6 +19,12 @@
#define SYM_MAP(a) { #a, (SymbolFunc *)&a }
namespace avmedia
{
namespace vlc
{
namespace wrapper
{
typedef void (*SymbolFunc) (void);
struct ApiMap
......@@ -70,7 +76,7 @@ namespace
( aModule, OUString::createFromAscii( pMap[ i ].symName ).pData );
if ( !aMethod )
{
std::cerr << "Cannot load method " << pMap[ i ].symName << std::endl;
SAL_WARN("avmedia", "Cannot load method " << pMap[ i ].symName);
*pMap[ i ].refValue = NULL;
return false;
}
......@@ -82,8 +88,6 @@ namespace
}
}
namespace VLC
{
template<size_t N>
bool InitApiMap( const ApiMap ( &pMap )[N] )
{
......@@ -98,7 +102,7 @@ namespace VLC
if( aModule == NULL)
{
std::cerr << "Cannot load libvlc" << std::endl;
SAL_WARN("avmedia", "Cannot load libvlc");
return false;
}
......@@ -112,6 +116,8 @@ namespace VLC
return false;
}
}
}
}
#endif
......
......@@ -24,9 +24,12 @@
#include <osl/conditn.hxx>
#include <boost/noncopyable.hpp>
namespace avmedia {
namespace vlc {
namespace avmedia
{
namespace vlc
{
namespace wrapper
{
template<class T>
class ThreadsafeQueue : boost::noncopyable
{
......@@ -70,7 +73,7 @@ void ThreadsafeQueue<T>::pop( T& data )
data = mQueue.front();
mQueue.pop();
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment