diff options
author | Minh Ngo <nlminhtl@gmail.com> | 2013-09-08 16:26:19 +0300 |
---|---|---|
committer | Minh Ngo <nlminhtl@gmail.com> | 2013-09-08 16:26:49 +0300 |
commit | 9f71d4e41aea338530ee297668b513645ae3d6b9 (patch) | |
tree | d2befcd86e58826157624147f08af4c8df82c3e6 | |
parent | 7c7d898b6e8f09f066817399214e51f454ff7982 (diff) |
Creating one single Player manager.
Change-Id: I2a56f38a0b28c828f365a24d744aea385436c2b5
-rw-r--r-- | avmedia/source/vlc/vlcframegrabber.cxx | 19 | ||||
-rw-r--r-- | avmedia/source/vlc/vlcmanager.cxx | 12 | ||||
-rw-r--r-- | avmedia/source/vlc/vlcmanager.hxx | 2 | ||||
-rw-r--r-- | avmedia/source/vlc/vlcuno.cxx | 4 |
4 files changed, 27 insertions, 10 deletions
diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx index 5c01a2d6f154..b7ef4a99cb0a 100644 --- a/avmedia/source/vlc/vlcframegrabber.cxx +++ b/avmedia/source/vlc/vlcframegrabber.cxx @@ -20,9 +20,12 @@ using namespace ::com::sun::star; namespace avmedia { namespace vlc { -const ::rtl::OUString AVMEDIA_VLC_GRABBER_IMPLEMENTATIONNAME = "com.sun.star.comp.avmedia.VLCFrameGrabber_VLC"; -const ::rtl::OUString AVMEDIA_VLC_GRABBER_SERVICENAME = "com.sun.star.media.VLCFrameGrabber_VLC"; -const int MSEC_IN_SEC = 1000; +namespace +{ + const ::rtl::OUString AVMEDIA_VLC_GRABBER_IMPLEMENTATIONNAME = "com.sun.star.comp.avmedia.VLCFrameGrabber_VLC"; + const ::rtl::OUString AVMEDIA_VLC_GRABBER_SERVICENAME = "com.sun.star.media.VLCFrameGrabber_VLC"; + const int MSEC_IN_SEC = 1000; +} VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, VLC::EventHandler& eh, const rtl::OUString& url ) : FrameGrabber_BASE() @@ -30,9 +33,11 @@ VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, VLC::EventHandler& eh, co , mUrl( url ) , mEventHandler( eh ) { + std::cout << "URL: " << url << std::endl; } -::uno::Reference< css::graphic::XGraphic > SAL_CALL VLCFrameGrabber::grabFrame( double fMediaTime ) throw ( ::com::sun::star::uno::RuntimeException ) +::uno::Reference< css::graphic::XGraphic > SAL_CALL VLCFrameGrabber::grabFrame( double fMediaTime ) + throw ( ::com::sun::star::uno::RuntimeException ) { osl::Condition condition; @@ -90,12 +95,14 @@ VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, VLC::EventHandler& eh, co return AVMEDIA_VLC_GRABBER_IMPLEMENTATIONNAME; } -::sal_Bool SAL_CALL VLCFrameGrabber::supportsService( const ::rtl::OUString& serviceName ) throw ( ::com::sun::star::uno::RuntimeException ) +::sal_Bool SAL_CALL VLCFrameGrabber::supportsService( const ::rtl::OUString& serviceName ) + throw ( ::com::sun::star::uno::RuntimeException ) { return AVMEDIA_VLC_GRABBER_SERVICENAME == serviceName; } -::uno::Sequence< ::rtl::OUString > SAL_CALL VLCFrameGrabber::getSupportedServiceNames() throw ( ::com::sun::star::uno::RuntimeException ) +::uno::Sequence< ::rtl::OUString > SAL_CALL VLCFrameGrabber::getSupportedServiceNames() + throw ( ::com::sun::star::uno::RuntimeException ) { ::uno::Sequence< OUString > aRet(1); aRet[0] = AVMEDIA_VLC_GRABBER_SERVICENAME; diff --git a/avmedia/source/vlc/vlcmanager.cxx b/avmedia/source/vlc/vlcmanager.cxx index ef536f44c060..4179ce293039 100644 --- a/avmedia/source/vlc/vlcmanager.cxx +++ b/avmedia/source/vlc/vlcmanager.cxx @@ -71,7 +71,17 @@ uno::Reference< media::XPlayer > SAL_CALL Manager::createPlayer( const rtl::OUSt if ( !m_is_vlc_found ) return uno::Reference< media::XPlayer >(); - VLCPlayer* pPlayer( new VLCPlayer( rURL, + if ( !rURL.isEmpty() ) + { + if (mURL == rURL) + return mPlayer; + + mURL = rURL; + } + else + return mPlayer; + + VLCPlayer* pPlayer( new VLCPlayer( mURL, *mInstance, mEventHandler /*, mxMgr */ ) ); mPlayer = uno::Reference< media::XPlayer >( pPlayer ); diff --git a/avmedia/source/vlc/vlcmanager.hxx b/avmedia/source/vlc/vlcmanager.hxx index 92e01691370a..b8cb15cfea4f 100644 --- a/avmedia/source/vlc/vlcmanager.hxx +++ b/avmedia/source/vlc/vlcmanager.hxx @@ -45,7 +45,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; - + rtl::OUString mURL; bool m_is_vlc_found; }; diff --git a/avmedia/source/vlc/vlcuno.cxx b/avmedia/source/vlc/vlcuno.cxx index 5421f62b3cdc..d41b2df9a174 100644 --- a/avmedia/source/vlc/vlcuno.cxx +++ b/avmedia/source/vlc/vlcuno.cxx @@ -28,8 +28,8 @@ using namespace ::com::sun::star; static uno::Reference< uno::XInterface > SAL_CALL create_MediaPlayer( const uno::Reference< lang::XMultiServiceFactory >& rxFact ) { fprintf (stderr, "create VLC Media player !\n"); - (void) rxFact; - return uno::Reference< uno::XInterface >(*new ::avmedia::vlc::Manager( rxFact ) ); + static uno::Reference< uno::XInterface > manager( *new ::avmedia::vlc::Manager( rxFact ) ); + return manager; } extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL avmediavlc_component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /*pRegistryKey*/ ) |