diff options
author | Kurt Zenker <kz@openoffice.org> | 2011-04-13 12:42:35 +0200 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2011-04-13 12:42:35 +0200 |
commit | dc076846a9c1ddbcabd33677e595e6fab414e062 (patch) | |
tree | 8ef208ca5c753ec8c48a0d144d944eda99b4ed31 /avmedia/source | |
parent | f468f344e424802b977f85dedc1a862a9314b240 (diff) | |
parent | 66e66b326ce4fa6b1507373fe9e4cfbbfd08e257 (diff) |
CWS-TOOLING: integrate CWS impress210_OOO340
Diffstat (limited to 'avmedia/source')
-rw-r--r-- | avmedia/source/gstreamer/gstframegrabber.cxx | 8 | ||||
-rw-r--r-- | avmedia/source/gstreamer/gstframegrabber.hxx | 6 | ||||
-rw-r--r-- | avmedia/source/gstreamer/gstplayer.cxx | 34 | ||||
-rw-r--r-- | avmedia/source/gstreamer/gstplayer.hxx | 28 | ||||
-rw-r--r-- | avmedia/source/gstreamer/gstwindow.cxx | 2 | ||||
-rw-r--r-- | avmedia/source/viewer/mediawindowbase_impl.cxx | 14 | ||||
-rw-r--r-- | avmedia/source/win/player.cxx | 140 | ||||
-rw-r--r-- | avmedia/source/win/player.hxx | 17 | ||||
-rw-r--r-- | avmedia/source/win/window.cxx | 39 | ||||
-rw-r--r-- | avmedia/source/win/window.hxx | 2 |
10 files changed, 205 insertions, 85 deletions
diff --git a/avmedia/source/gstreamer/gstframegrabber.cxx b/avmedia/source/gstreamer/gstframegrabber.cxx index 49a6d9695fbc..daf64d80ed25 100644 --- a/avmedia/source/gstreamer/gstframegrabber.cxx +++ b/avmedia/source/gstreamer/gstframegrabber.cxx @@ -45,12 +45,18 @@ const gulong GRAB_TIMEOUT = 10000000; // ---------------- FrameGrabber::FrameGrabber( GString* pURI ) : - Player( pURI ), mpFrameMutex( g_mutex_new() ), mpFrameCond( g_cond_new() ), mpLastPixbuf( NULL ), mbIsInGrabMode( false ) { + if( pURI ) + { + OSL_TRACE( ">>> --------------------------------" ); + OSL_TRACE( ">>> Creating Player object with URL: %s", pURI->str ); + + mpThread = g_thread_create( Player::implThreadFunc, this, true, NULL ); + } } // ------------------------------------------------------------------------------ diff --git a/avmedia/source/gstreamer/gstframegrabber.hxx b/avmedia/source/gstreamer/gstframegrabber.hxx index 9a7ec1b74102..fac2e298fb2c 100644 --- a/avmedia/source/gstreamer/gstframegrabber.hxx +++ b/avmedia/source/gstreamer/gstframegrabber.hxx @@ -34,6 +34,7 @@ #ifndef _COM_SUN_STAR_MEDIA_XFRAMEGRABBER_HDL_ #include "com/sun/star/media/XFrameGrabber.hdl" #endif +#include <cppuhelper/implbase1.hxx> namespace avmedia { namespace gst { @@ -41,9 +42,8 @@ namespace avmedia { namespace gst { // - FrameGrabber - // ---------------- -class FrameGrabber : public Player, - public ::cppu::WeakImplHelper2 < ::com::sun::star::media::XFrameGrabber, - ::com::sun::star::lang::XServiceInfo > +class FrameGrabber : + public ::cppu::ImplInheritanceHelper1 < Player,::com::sun::star::media::XFrameGrabber > { public: diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx index 614ff80ce352..a056b14b2b99 100644 --- a/avmedia/source/gstreamer/gstplayer.cxx +++ b/avmedia/source/gstreamer/gstplayer.cxx @@ -156,6 +156,7 @@ lcl_implHandleCreateWindowFunc( GstBus* pBus, GstMessage* pMsg, gpointer pData ) // - Player - // --------------- Player::Player( GString* pURI ) : + Player_BASE(m_aMutex), mpMutex( g_mutex_new() ), mpCond( g_cond_new() ), mpThread( NULL ), @@ -274,6 +275,7 @@ Player* Player::create( const ::rtl::OUString& rURL ) void SAL_CALL Player::start() throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() && !isPlaying() ) { gst_element_set_state( mpPlayer, GST_STATE_PLAYING ); @@ -284,6 +286,7 @@ void SAL_CALL Player::start() void SAL_CALL Player::stop() throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() && isPlaying() ) { gst_element_set_state( mpPlayer, GST_STATE_PAUSED ); @@ -295,7 +298,7 @@ sal_Bool SAL_CALL Player::isPlaying() throw( uno::RuntimeException ) { GstState aState = GST_STATE_NULL; - + ::osl::MutexGuard aGuard(m_aMutex); if( mpPlayer ) { gst_element_get_state( mpPlayer, &aState, NULL, GST_MAX_TIMEOUT ); @@ -308,6 +311,7 @@ sal_Bool SAL_CALL Player::isPlaying() double SAL_CALL Player::getDuration() throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); gint64 nDuration = 0; if( implInitPlayer() ) @@ -329,6 +333,7 @@ double SAL_CALL Player::getDuration() void SAL_CALL Player::setMediaTime( double fTime ) throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() ) { fTime = ::std::min( ::std::max( fTime, 0.0 ), getDuration() ); @@ -344,7 +349,7 @@ double SAL_CALL Player::getMediaTime() throw( uno::RuntimeException ) { double fRet = 0.0; - + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() ) { GstFormat aFormat = GST_FORMAT_TIME; @@ -384,7 +389,7 @@ double SAL_CALL Player::getStopTime() Currently no need for implementation since higher levels of code don't set a stop time ATM !!! TODO: needs to be fully implemented if this functionality is needed at a later point of time */ - + ::osl::MutexGuard aGuard(m_aMutex); return( getDuration() ); } @@ -415,6 +420,7 @@ double SAL_CALL Player::getRate() void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet ) throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); if (bSet) { g_atomic_int_compare_and_exchange(&mnLooping, 0, 1); @@ -429,6 +435,7 @@ void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet ) sal_Bool SAL_CALL Player::isPlaybackLoop() throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); return( g_atomic_int_get( &mnLooping ) > 0 ); } @@ -436,6 +443,7 @@ sal_Bool SAL_CALL Player::isPlaybackLoop() void SAL_CALL Player::setMute( sal_Bool bSet ) throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() && ( bSet != isMute() ) ) { if( bSet ) @@ -454,6 +462,7 @@ sal_Bool SAL_CALL Player::isMute() throw( uno::RuntimeException ) { gdouble fGstVolume = 1.0; + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() ) { @@ -467,6 +476,7 @@ sal_Bool SAL_CALL Player::isMute() void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB ) throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() ) { g_mutex_lock( mpMutex ); @@ -485,6 +495,7 @@ void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB ) sal_Int16 SAL_CALL Player::getVolumeDB() throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); return( static_cast< sal_Int16 >( g_atomic_int_get( &mnVolumeDB ) ) ); } @@ -493,6 +504,7 @@ awt::Size SAL_CALL Player::getPreferredPlayerWindowSize() throw( uno::RuntimeException ) { awt::Size aSize( 0, 0 ); + ::osl::MutexGuard aGuard(m_aMutex); if( implInitPlayer() && ( g_atomic_int_get( &mnIsVideoSource ) > 0 ) ) { @@ -517,6 +529,7 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( const uno::Sequence< uno::Any >& rArguments ) throw( uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); uno::Reference< ::media::XPlayerWindow > xRet; awt::Size aSize( getPreferredPlayerWindowSize() ); @@ -560,6 +573,7 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber() throw( ::com::sun::star::uno::RuntimeException ) { + ::osl::MutexGuard aGuard(m_aMutex); FrameGrabber* pFrameGrabber = NULL; const awt::Size aPrefSize( getPreferredPlayerWindowSize() ); @@ -572,9 +586,9 @@ uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber() } // ------------------------------------------------------------------------------ -void SAL_CALL Player::dispose() - throw( uno::RuntimeException ) +void SAL_CALL Player::disposing() { + ::osl::MutexGuard aGuard(m_aMutex); if( mpPlayer ) { stop(); @@ -585,16 +599,6 @@ void SAL_CALL Player::dispose() } // ------------------------------------------------------------------------------ -void SAL_CALL Player::addEventListener( const uno::Reference< lang::XEventListener >& /*rxListener*/ ) - throw( uno::RuntimeException ) -{} - -// ------------------------------------------------------------------------------ -void SAL_CALL Player::removeEventListener( const uno::Reference< lang::XEventListener >& /*rxListener*/ ) - throw( uno::RuntimeException ) -{} - -// ------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL Player::getImplementationName() throw( uno::RuntimeException ) { diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx index 0793eaf8caf2..2127e87a93ec 100644 --- a/avmedia/source/gstreamer/gstplayer.hxx +++ b/avmedia/source/gstreamer/gstplayer.hxx @@ -46,6 +46,8 @@ typedef struct _GOptionGroup GOptionGroup; #include <gst/gst.h> #include "com/sun/star/media/XPlayer.hdl" +#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/basemutex.hxx> namespace avmedia { @@ -56,10 +58,11 @@ class Window; // --------------- // - Player_Impl - // --------------- +typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::media::XPlayer, + ::com::sun::star::lang::XServiceInfo > Player_BASE; -class Player : public ::cppu::WeakImplHelper3< ::com::sun::star::media::XPlayer, - ::com::sun::star::lang::XComponent, - ::com::sun::star::lang::XServiceInfo > +class Player : public cppu::BaseMutex, + public Player_BASE { public: @@ -67,7 +70,7 @@ public: static Player* create( const ::rtl::OUString& rURL ); ~Player(); - +//protected: // XPlayer virtual void SAL_CALL start() throw( ::com::sun::star::uno::RuntimeException ); @@ -127,18 +130,6 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XFrameGrabber > SAL_CALL createFrameGrabber() throw( ::com::sun::star::uno::RuntimeException ); - // XComponent - virtual void SAL_CALL dispose() - throw( ::com::sun::star::uno::RuntimeException ); - - virtual void SAL_CALL addEventListener( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) - throw( ::com::sun::star::uno::RuntimeException ); - - virtual void SAL_CALL removeEventListener( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) - throw( ::com::sun::star::uno::RuntimeException ); - // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); @@ -150,6 +141,7 @@ public: throw( ::com::sun::star::uno::RuntimeException ); // these are public because the C callbacks call them + virtual gboolean busCallback( GstBus* pBus, GstMessage* pMsg ); @@ -162,6 +154,9 @@ public: protected: + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + Player( GString* pURI = NULL ); void implQuitThread(); @@ -173,6 +168,7 @@ protected: return( g_atomic_int_get( &mnInitialized ) > 0 ); } + static gpointer implThreadFunc( gpointer pData ); private: diff --git a/avmedia/source/gstreamer/gstwindow.cxx b/avmedia/source/gstreamer/gstwindow.cxx index 12606ad5e88b..417525c1946e 100644 --- a/avmedia/source/gstreamer/gstwindow.cxx +++ b/avmedia/source/gstreamer/gstwindow.cxx @@ -271,7 +271,7 @@ value in sequence of arguments" ); if( pParentWindow ) { - meZoomLevel = media::ZoomLevel_ORIGINAL; + meZoomLevel = media::ZoomLevel_FIT_TO_WINDOW; mpPlayerWindow = new PlayerChildWindow( pParentWindow ); mpPlayerWindow->SetBackground( Color( COL_BLACK ) ); diff --git a/avmedia/source/viewer/mediawindowbase_impl.cxx b/avmedia/source/viewer/mediawindowbase_impl.cxx index 94a6c36ed064..cd9ac849132a 100644 --- a/avmedia/source/viewer/mediawindowbase_impl.cxx +++ b/avmedia/source/viewer/mediawindowbase_impl.cxx @@ -207,17 +207,11 @@ void MediaWindowBaseImpl::setPlayerWindow( const uno::Reference< media::XPlayerW void MediaWindowBaseImpl::cleanUp() { - if( mxPlayer.is() ) - { - mxPlayer->stop(); - - uno::Reference< lang::XComponent > xComponent( mxPlayer, uno::UNO_QUERY ); + uno::Reference< lang::XComponent > xComponent( mxPlayer, uno::UNO_QUERY ); + if( xComponent.is() ) // this stops the player + xComponent->dispose(); - if( xComponent.is() ) - xComponent->dispose(); - - mxPlayer.clear(); - } + mxPlayer.clear(); mpMediaWindow = NULL; } diff --git a/avmedia/source/win/player.cxx b/avmedia/source/win/player.cxx index d27b2b55ff93..56efbe6b107b 100644 --- a/avmedia/source/win/player.cxx +++ b/avmedia/source/win/player.cxx @@ -52,6 +52,30 @@ using namespace ::com::sun::star; namespace avmedia { namespace win { +LRESULT CALLBACK MediaPlayerWndProc_2( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 ) +{ + Player* pPlayer = (Player*) ::GetWindowLong( hWnd, 0 ); + bool bProcessed = true; + + if( pPlayer ) + { + switch( nMsg ) + { + case( WM_GRAPHNOTIFY ): + pPlayer->processEvent(); + break; + default: + bProcessed = false; + break; + } + } + else + bProcessed = false; + + return( bProcessed ? 0 : DefWindowProc( hWnd, nMsg, nPar1, nPar2 ) ); +} + + bool isWindowsVistaOrHigher() { // POST: return true if we are at least on Windows Vista @@ -59,10 +83,7 @@ bool isWindowsVistaOrHigher() ZeroMemory(&osvi, sizeof(osvi)); osvi.dwOSVersionInfoSize = sizeof(osvi); GetVersionEx(&osvi); - if ( osvi.dwMajorVersion >= 6 ) - return true; - - return false; + return osvi.dwMajorVersion >= 6; } // ---------------- @@ -70,6 +91,7 @@ bool isWindowsVistaOrHigher() // ---------------- Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) : + Player_BASE(m_aMutex), mxMgr( rxMgr ), mpGB( NULL ), mpOMF( NULL ), @@ -82,8 +104,10 @@ Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) : mpVW( NULL ), mpEV( NULL ), mnUnmutedVolume( 0 ), + mnFrameWnd( 0 ), mbMuted( false ), - mbLooping( false ) + mbLooping( false ), + mbAddWindow(sal_True) { ::CoInitialize( NULL ); } @@ -92,6 +116,18 @@ Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) : Player::~Player() { + if( mnFrameWnd ) + ::DestroyWindow( (HWND) mnFrameWnd ); + + ::CoUninitialize(); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Player::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + stop(); if( mpBA ) mpBA->Release(); @@ -108,7 +144,11 @@ Player::~Player() mpMS->Release(); if( mpME ) + { + mpME->SetNotifyWindow( 0, WM_GRAPHNOTIFY, 0); mpME->Release(); + } + if( mpMC ) mpMC->Release(); @@ -121,12 +161,8 @@ Player::~Player() if( mpGB ) mpGB->Release(); - - ::CoUninitialize(); } - // ------------------------------------------------------------------------------ - bool Player::create( const ::rtl::OUString& rURL ) { HRESULT hR; @@ -137,15 +173,12 @@ bool Player::create( const ::rtl::OUString& rURL ) // Don't use the overlay mixer on Windows Vista // It disables the desktop composition as soon as RenderFile is called // also causes some other problems: video rendering is not reliable - if( !isWindowsVistaOrHigher() ) + if( !isWindowsVistaOrHigher() && SUCCEEDED( CoCreateInstance( CLSID_OverlayMixer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**) &mpOMF ) ) ) { - if( SUCCEEDED( CoCreateInstance( CLSID_OverlayMixer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**) &mpOMF ) ) ) - { - mpGB->AddFilter( mpOMF, L"com_sun_star_media_OverlayMixerFilter" ); + mpGB->AddFilter( mpOMF, L"com_sun_star_media_OverlayMixerFilter" ); - if( !SUCCEEDED( mpOMF->QueryInterface( IID_IDDrawExclModeVideo, (void**) &mpEV ) ) ) - mpEV = NULL; - } + if( !SUCCEEDED( mpOMF->QueryInterface( IID_IDDrawExclModeVideo, (void**) &mpEV ) ) ) + mpEV = NULL; } if( SUCCEEDED( hR = mpGB->RenderFile( reinterpret_cast<LPCWSTR>(rURL.getStr()), NULL ) ) && @@ -187,6 +220,7 @@ const IVideoWindow* Player::getVideoWindow() const void Player::setNotifyWnd( int nNotifyWnd ) { + mbAddWindow = sal_False; if( mpME ) mpME->SetNotifyWindow( (OAHWND) nNotifyWnd, WM_GRAPHNOTIFY, reinterpret_cast< LONG_PTR>( this ) ); } @@ -208,7 +242,7 @@ long Player::processEvent() { long nCode, nParam1, nParam2; - if( mpME && SUCCEEDED( mpME->GetEvent( &nCode, &nParam1, &nParam2, 0 ) ) ) + while( mpME && SUCCEEDED( mpME->GetEvent( &nCode, &nParam1, &nParam2, 0 ) ) ) { if( EC_COMPLETE == nCode ) { @@ -235,8 +269,44 @@ long Player::processEvent() void SAL_CALL Player::start( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); if( mpMC ) + { + if ( mbAddWindow ) + { + static WNDCLASS* mpWndClass = NULL; + if ( !mpWndClass ) + { + mpWndClass = new WNDCLASS; + + memset( mpWndClass, 0, sizeof( *mpWndClass ) ); + mpWndClass->hInstance = GetModuleHandle( NULL ); + mpWndClass->cbWndExtra = sizeof( DWORD ); + mpWndClass->lpfnWndProc = MediaPlayerWndProc_2; + mpWndClass->lpszClassName = "com_sun_star_media_Sound_Player"; + mpWndClass->hbrBackground = (HBRUSH) ::GetStockObject( BLACK_BRUSH ); + mpWndClass->hCursor = ::LoadCursor( NULL, IDC_ARROW ); + + ::RegisterClass( mpWndClass ); + } + if ( !mnFrameWnd ) + { + mnFrameWnd = (int) ::CreateWindow( mpWndClass->lpszClassName, NULL, + 0, + 0, 0, 0, 0, + (HWND) NULL, NULL, mpWndClass->hInstance, 0 ); + if ( mnFrameWnd ) + { + ::ShowWindow((HWND) mnFrameWnd, SW_HIDE); + ::SetWindowLong( (HWND) mnFrameWnd, 0, (DWORD) this ); + // mpVW->put_Owner( (OAHWND) mnFrameWnd ); + setNotifyWnd( mnFrameWnd ); + } + } + } + mpMC->Run(); + } } // ------------------------------------------------------------------------------ @@ -244,6 +314,8 @@ void SAL_CALL Player::start( ) void SAL_CALL Player::stop( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + if( mpMC ) mpMC->Stop(); } @@ -253,6 +325,8 @@ void SAL_CALL Player::stop( ) sal_Bool SAL_CALL Player::isPlaying() throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + OAFilterState eFilterState; bool bRet = false; @@ -267,6 +341,8 @@ sal_Bool SAL_CALL Player::isPlaying() double SAL_CALL Player::getDuration( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + REFTIME aRefTime( 0.0 ); if( mpMP ) @@ -280,6 +356,8 @@ double SAL_CALL Player::getDuration( ) void SAL_CALL Player::setMediaTime( double fTime ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + if( mpMP ) { const bool bPlaying = isPlaying(); @@ -296,6 +374,8 @@ void SAL_CALL Player::setMediaTime( double fTime ) double SAL_CALL Player::getMediaTime( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + REFTIME aRefTime( 0.0 ); if( mpMP ) @@ -309,6 +389,8 @@ double SAL_CALL Player::getMediaTime( ) void SAL_CALL Player::setStopTime( double fTime ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + if( mpMP ) mpMP->put_StopTime( fTime ); } @@ -318,6 +400,8 @@ void SAL_CALL Player::setStopTime( double fTime ) double SAL_CALL Player::getStopTime( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + REFTIME aRefTime( 0.0 ); if( mpMP ) @@ -331,6 +415,8 @@ double SAL_CALL Player::getStopTime( ) void SAL_CALL Player::setRate( double fRate ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + if( mpMP ) mpMP->put_Rate( fRate ); } @@ -340,6 +426,8 @@ void SAL_CALL Player::setRate( double fRate ) double SAL_CALL Player::getRate( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + double fRet( 0.0 ); if( mpMP ) @@ -353,6 +441,8 @@ double SAL_CALL Player::getRate( ) void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + mbLooping = bSet; } @@ -361,6 +451,8 @@ void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet ) sal_Bool SAL_CALL Player::isPlaybackLoop( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + return mbLooping; } @@ -369,6 +461,8 @@ sal_Bool SAL_CALL Player::isPlaybackLoop( ) void SAL_CALL Player::setMute( sal_Bool bSet ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + if( mpBA && ( mbMuted != bSet ) ) { mbMuted = bSet; @@ -381,6 +475,8 @@ void SAL_CALL Player::setMute( sal_Bool bSet ) sal_Bool SAL_CALL Player::isMute( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + return mbMuted; } @@ -389,6 +485,8 @@ sal_Bool SAL_CALL Player::isMute( ) void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + mnUnmutedVolume = static_cast< long >( nVolumeDB ) * 100; if( !mbMuted && mpBA ) @@ -400,6 +498,8 @@ void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB ) sal_Int16 SAL_CALL Player::getVolumeDB( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + return( static_cast< sal_Int16 >( mnUnmutedVolume / 100 ) ); } @@ -408,6 +508,8 @@ sal_Int16 SAL_CALL Player::getVolumeDB( ) awt::Size SAL_CALL Player::getPreferredPlayerWindowSize( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + awt::Size aSize( 0, 0 ); if( mpBV ) @@ -427,6 +529,8 @@ awt::Size SAL_CALL Player::getPreferredPlayerWindowSize( ) uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( const uno::Sequence< uno::Any >& aArguments ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + uno::Reference< ::media::XPlayerWindow > xRet; awt::Size aSize( getPreferredPlayerWindowSize() ); @@ -448,6 +552,8 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber( ) throw (uno::RuntimeException) { + ::osl::MutexGuard aGuard(m_aMutex); + uno::Reference< media::XFrameGrabber > xRet; if( maURL.getLength() > 0 ) diff --git a/avmedia/source/win/player.hxx b/avmedia/source/win/player.hxx index 34a567750b74..eee9b52ee94b 100644 --- a/avmedia/source/win/player.hxx +++ b/avmedia/source/win/player.hxx @@ -30,9 +30,10 @@ #include "wincommon.hxx" -#ifndef _COM_SUN_STAR_MEDIA_XPLAYER_HDL_ #include "com/sun/star/media/XPlayer.hdl" -#endif + +#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/basemutex.hxx> struct IGraphBuilder; struct IBaseFilter; @@ -52,9 +53,11 @@ namespace avmedia { namespace win { // ---------- // - Player - // ---------- +typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::media::XPlayer, + ::com::sun::star::lang::XServiceInfo > Player_BASE; -class Player : public ::cppu::WeakImplHelper2< ::com::sun::star::media::XPlayer, - ::com::sun::star::lang::XServiceInfo > +class Player : public cppu::BaseMutex, + public Player_BASE { public: @@ -95,6 +98,9 @@ public: virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + private: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr; @@ -111,8 +117,11 @@ private: IVideoWindow* mpVW; IDDrawExclModeVideo* mpEV; long mnUnmutedVolume; + int mnFrameWnd; + sal_Bool mbMuted; sal_Bool mbLooping; + sal_Bool mbAddWindow; void ImplLayoutVideoWindow(); }; diff --git a/avmedia/source/win/window.cxx b/avmedia/source/win/window.cxx index 1170505b440b..8d4aeb73a65c 100644 --- a/avmedia/source/win/window.cxx +++ b/avmedia/source/win/window.cxx @@ -179,7 +179,25 @@ LRESULT CALLBACK MediaPlayerWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM n // - Window - // --------------- -WNDCLASS* Window::mpWndClass = NULL; +WNDCLASS* lcl_getWndClass() +{ + static WNDCLASS* s_pWndClass = NULL; + if ( !s_pWndClass ) + { + s_pWndClass = new WNDCLASS; + + memset( s_pWndClass, 0, sizeof( *s_pWndClass ) ); + s_pWndClass->hInstance = GetModuleHandle( NULL ); + s_pWndClass->cbWndExtra = sizeof( DWORD ); + s_pWndClass->lpfnWndProc = MediaPlayerWndProc; + s_pWndClass->lpszClassName = "com_sun_star_media_PlayerWnd"; + s_pWndClass->hbrBackground = (HBRUSH) ::GetStockObject( BLACK_BRUSH ); + s_pWndClass->hCursor = ::LoadCursor( NULL, IDC_ARROW ); + + ::RegisterClass( s_pWndClass ); + } + return s_pWndClass; +} // ------------------------------------------------------------------------------ @@ -194,20 +212,7 @@ Window::Window( const uno::Reference< lang::XMultiServiceFactory >& rxMgr, Playe { ::osl::MutexGuard aGuard( ImplGetOwnStaticMutex() ); - if( !mpWndClass ) - { - mpWndClass = new WNDCLASS; - - memset( mpWndClass, 0, sizeof( *mpWndClass ) ); - mpWndClass->hInstance = GetModuleHandle( NULL ); - mpWndClass->cbWndExtra = sizeof( DWORD ); - mpWndClass->lpfnWndProc = MediaPlayerWndProc; - mpWndClass->lpszClassName = "com_sun_star_media_PlayerWnd"; - mpWndClass->hbrBackground = (HBRUSH) ::GetStockObject( BLACK_BRUSH ); - mpWndClass->hCursor = ::LoadCursor( NULL, IDC_ARROW ); - - ::RegisterClass( mpWndClass ); - } + lcl_getWndClass(); } // ------------------------------------------------------------------------------ @@ -310,6 +315,8 @@ void Window::ImplLayoutVideoWindow() bool Window::create( const uno::Sequence< uno::Any >& rArguments ) { IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() ); + WNDCLASS* mpWndClass = lcl_getWndClass(); + if( !mnFrameWnd && pVideoWindow && mpWndClass ) { @@ -374,7 +381,7 @@ bool Window::create( const uno::Sequence< uno::Any >& rArguments ) mrPlayer.setNotifyWnd( mnFrameWnd ); - meZoomLevel = media::ZoomLevel_ORIGINAL; + meZoomLevel = media::ZoomLevel_FIT_TO_WINDOW; ImplLayoutVideoWindow(); #ifdef DDRAW_TEST_OUTPUT } diff --git a/avmedia/source/win/window.hxx b/avmedia/source/win/window.hxx index 36cff49a742a..3605ba970f7a 100644 --- a/avmedia/source/win/window.hxx +++ b/avmedia/source/win/window.hxx @@ -114,8 +114,6 @@ private: int mnParentWnd; int mnPointerType; - static WNDCLASS* mpWndClass; - void ImplLayoutVideoWindow(); }; |