summaryrefslogtreecommitdiffstats
path: root/avmedia/source/win
diff options
context:
space:
mode:
Diffstat (limited to 'avmedia/source/win')
-rw-r--r--avmedia/source/win/player.cxx140
-rw-r--r--avmedia/source/win/player.hxx17
-rw-r--r--avmedia/source/win/window.cxx39
-rw-r--r--avmedia/source/win/window.hxx2
4 files changed, 159 insertions, 39 deletions
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();
};