summaryrefslogtreecommitdiff
path: root/avmedia/source/win
diff options
context:
space:
mode:
Diffstat (limited to 'avmedia/source/win')
-rw-r--r--avmedia/source/win/exports.dxp4
-rw-r--r--avmedia/source/win/framegrabber.cxx250
-rw-r--r--avmedia/source/win/framegrabber.hxx75
-rw-r--r--avmedia/source/win/interface.hxx125
-rw-r--r--avmedia/source/win/makefile.mk80
-rw-r--r--avmedia/source/win/manager.cxx100
-rw-r--r--avmedia/source/win/manager.hxx67
-rw-r--r--avmedia/source/win/player.cxx498
-rw-r--r--avmedia/source/win/player.hxx124
-rw-r--r--avmedia/source/win/wincommon.hxx59
-rw-r--r--avmedia/source/win/window.cxx743
-rw-r--r--avmedia/source/win/window.hxx126
-rw-r--r--avmedia/source/win/winuno.cxx107
13 files changed, 2358 insertions, 0 deletions
diff --git a/avmedia/source/win/exports.dxp b/avmedia/source/win/exports.dxp
new file mode 100644
index 000000000000..db9c0a52f288
--- /dev/null
+++ b/avmedia/source/win/exports.dxp
@@ -0,0 +1,4 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
+
diff --git a/avmedia/source/win/framegrabber.cxx b/avmedia/source/win/framegrabber.cxx
new file mode 100644
index 000000000000..3cfe5f89264d
--- /dev/null
+++ b/avmedia/source/win/framegrabber.cxx
@@ -0,0 +1,250 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <tools/prewin.h>
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable: 4917)
+#endif
+#include <windows.h>
+#include <objbase.h>
+#include <strmif.h>
+#include <Amvideo.h>
+#if defined(_MSC_VER) && (_MSC_VER < 1500)
+#include <Qedit.h>
+#else
+#include "interface.hxx"
+#endif
+#include <uuids.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <tools/postwin.h>
+
+#include "framegrabber.hxx"
+#include "player.hxx"
+
+#include <tools/stream.hxx>
+#include <vcl/graph.hxx>
+#include <unotools/localfilehelper.hxx>
+
+#define AVMEDIA_WIN_FRAMEGRABBER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.FrameGrabber_DirectX"
+#define AVMEDIA_WIN_FRAMEGRABBER_SERVICENAME "com.sun.star.media.FrameGrabber_DirectX"
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace win {
+
+// ----------------
+// - FrameGrabber -
+// ----------------
+
+FrameGrabber::FrameGrabber( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
+ mxMgr( rxMgr )
+{
+ ::CoInitialize( NULL );
+}
+
+// ------------------------------------------------------------------------------
+
+FrameGrabber::~FrameGrabber()
+{
+ ::CoUninitialize();
+}
+
+// ------------------------------------------------------------------------------
+
+IMediaDet* FrameGrabber::implCreateMediaDet( const ::rtl::OUString& rURL ) const
+{
+ IMediaDet* pDet = NULL;
+
+ if( SUCCEEDED( CoCreateInstance( CLSID_MediaDet, NULL, CLSCTX_INPROC_SERVER, IID_IMediaDet, (void**) &pDet ) ) )
+ {
+ String aLocalStr;
+
+ if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( rURL, aLocalStr ) && aLocalStr.Len() )
+ {
+ if( !SUCCEEDED( pDet->put_Filename( ::SysAllocString( reinterpret_cast<LPCOLESTR>(aLocalStr.GetBuffer()) ) ) ) )
+ {
+ pDet->Release();
+ pDet = NULL;
+ }
+ }
+ }
+
+ return pDet;
+}
+
+// ------------------------------------------------------------------------------
+
+bool FrameGrabber::create( const ::rtl::OUString& rURL )
+{
+ // just check if a MediaDet interface can be created with the given URL
+ IMediaDet* pDet = implCreateMediaDet( rURL );
+
+ if( pDet )
+ {
+ maURL = rURL;
+ pDet->Release();
+ pDet = NULL;
+ }
+ else
+ maURL = ::rtl::OUString();
+
+ return( maURL.getLength() > 0 );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMediaTime )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< graphic::XGraphic > xRet;
+ IMediaDet* pDet = implCreateMediaDet( maURL );
+
+ if( pDet )
+ {
+ double fLength;
+ long nStreamCount;
+ bool bFound = false;
+
+ if( SUCCEEDED( pDet->get_OutputStreams( &nStreamCount ) ) )
+ {
+ for( long n = 0; ( n < nStreamCount ) && !bFound; ++n )
+ {
+ GUID aMajorType;
+
+ if( SUCCEEDED( pDet->put_CurrentStream( n ) ) &&
+ SUCCEEDED( pDet->get_StreamType( &aMajorType ) ) &&
+ ( aMajorType == MEDIATYPE_Video ) )
+ {
+ bFound = true;
+ }
+ }
+ }
+
+ if( bFound &&
+ ( S_OK == pDet->get_StreamLength( &fLength ) ) &&
+ ( fLength > 0.0 ) && ( fMediaTime >= 0.0 ) && ( fMediaTime <= fLength ) )
+ {
+ AM_MEDIA_TYPE aMediaType;
+ long nWidth = 0, nHeight = 0, nSize = 0;
+
+ if( SUCCEEDED( pDet->get_StreamMediaType( &aMediaType ) ) )
+ {
+ if( ( aMediaType.formattype == FORMAT_VideoInfo ) &&
+ ( aMediaType.cbFormat >= sizeof( VIDEOINFOHEADER ) ) )
+ {
+ VIDEOINFOHEADER* pVih = reinterpret_cast< VIDEOINFOHEADER* >( aMediaType.pbFormat );
+
+ nWidth = pVih->bmiHeader.biWidth;
+ nHeight = pVih->bmiHeader.biHeight;
+
+ if( nHeight < 0 )
+ nHeight *= -1;
+ }
+
+ if( aMediaType.cbFormat != 0 )
+ {
+ ::CoTaskMemFree( (PVOID) aMediaType.pbFormat );
+ aMediaType.cbFormat = 0;
+ aMediaType.pbFormat = NULL;
+ }
+
+ if( aMediaType.pUnk != NULL )
+ {
+ aMediaType.pUnk->Release();
+ aMediaType.pUnk = NULL;
+ }
+ }
+
+ if( ( nWidth > 0 ) && ( nHeight > 0 ) &&
+ SUCCEEDED( pDet->GetBitmapBits( 0, &nSize, NULL, nWidth, nHeight ) ) &&
+ ( nSize > 0 ) )
+ {
+ char* pBuffer = new char[ nSize ];
+
+ try
+ {
+ if( SUCCEEDED( pDet->GetBitmapBits( fMediaTime, NULL, pBuffer, nWidth, nHeight ) ) )
+ {
+ SvMemoryStream aMemStm( pBuffer, nSize, STREAM_READ | STREAM_WRITE );
+ Bitmap aBmp;
+
+ if( aBmp.Read( aMemStm, false ) && !aBmp.IsEmpty() )
+ {
+ const Graphic aGraphic( aBmp );
+ xRet = aGraphic.GetXGraphic();
+ }
+ }
+ }
+ catch( ... )
+ {
+ }
+
+ delete [] pBuffer;
+ }
+ }
+
+ pDet->Release();
+ }
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL FrameGrabber::getImplementationName( )
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_WIN_FRAMEGRABBER_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL FrameGrabber::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_WIN_FRAMEGRABBER_SERVICENAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL FrameGrabber::getSupportedServiceNames( )
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aRet(1);
+ aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_WIN_FRAMEGRABBER_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace win
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/win/framegrabber.hxx b/avmedia/source/win/framegrabber.hxx
new file mode 100644
index 000000000000..0499a5086e49
--- /dev/null
+++ b/avmedia/source/win/framegrabber.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _FRAMEGRABBER_HXX
+#define _FRAMEGRABBER_HXX
+
+#include "wincommon.hxx"
+
+#include "com/sun/star/media/XFrameGrabber.hdl"
+
+struct IMediaDet;
+
+namespace avmedia { namespace win {
+
+// ----------------
+// - FrameGrabber -
+// ----------------
+
+class FrameGrabber : public ::cppu::WeakImplHelper2 < ::com::sun::star::media::XFrameGrabber,
+ ::com::sun::star::lang::XServiceInfo >
+{
+public:
+
+ FrameGrabber( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMgr );
+ ~FrameGrabber();
+
+ bool create( const ::rtl::OUString& rURL );
+
+ // XFrameGrabber
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL grabFrame( double fMediaTime ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ 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);
+
+private:
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr;
+ ::rtl::OUString maURL;
+
+ IMediaDet* implCreateMediaDet( const ::rtl::OUString& rURL ) const;
+};
+
+} // namespace win
+} // namespace avmedia
+
+#endif // _FRAMEGRABBER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/win/interface.hxx b/avmedia/source/win/interface.hxx
new file mode 100644
index 000000000000..0e1944c4923e
--- /dev/null
+++ b/avmedia/source/win/interface.hxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+extern "C" const CLSID CLSID_MediaDet;
+extern "C" const IID IID_IMediaDet;
+struct ISampleGrabber;
+
+struct
+#ifndef __MINGW32__
+__declspec(uuid("65BD0710-24D2-4ff7-9324-ED2E5D3ABAFA")) __declspec(novtable)
+#endif
+IMediaDet : public IUnknown
+{
+public:
+ virtual HRESULT __stdcall get_Filter(
+ IUnknown **pVal) = 0;
+ virtual HRESULT __stdcall put_Filter(
+ IUnknown *newVal) = 0;
+ virtual HRESULT __stdcall get_OutputStreams(
+ long *pVal) = 0;
+ virtual HRESULT __stdcall get_CurrentStream(
+ long *pVal) = 0;
+ virtual HRESULT __stdcall put_CurrentStream(
+ long newVal) = 0;
+ virtual HRESULT __stdcall get_StreamType(
+ GUID *pVal) = 0;
+ virtual HRESULT __stdcall get_StreamTypeB(
+ BSTR *pVal) = 0;
+ virtual HRESULT __stdcall get_StreamLength(
+ double *pVal) = 0;
+ virtual HRESULT __stdcall get_Filename(
+ BSTR *pVal) = 0;
+ virtual HRESULT __stdcall put_Filename(
+ BSTR newVal) = 0;
+ virtual HRESULT __stdcall GetBitmapBits(
+ double StreamTime,
+ long *pBufferSize,
+ char *pBuffer,
+ long Width,
+ long Height) = 0;
+ virtual HRESULT __stdcall WriteBitmapBits(
+ double StreamTime,
+ long Width,
+ long Height,
+ BSTR Filename) = 0;
+ virtual HRESULT __stdcall get_StreamMediaType(
+ AM_MEDIA_TYPE *pVal) = 0;
+ virtual HRESULT __stdcall GetSampleGrabber(
+ ISampleGrabber **ppVal) = 0;
+ virtual HRESULT __stdcall get_FrameRate(
+ double *pVal) = 0;
+ virtual HRESULT __stdcall EnterBitmapGrabMode(
+ double SeekTime) = 0;
+};
+
+extern "C" const IID IID_ISampleGrabberCB;
+struct
+#ifndef __MINGW32__
+__declspec(uuid("0579154A-2B53-4994-B0D0-E773148EFF85")) __declspec(novtable)
+#endif
+ISampleGrabberCB : public IUnknown
+{
+public:
+ virtual HRESULT __stdcall SampleCB(
+ double SampleTime,
+ IMediaSample *pSample) = 0;
+ virtual HRESULT __stdcall BufferCB(
+ double SampleTime,
+ WIN_BYTE *pBuffer,
+ long BufferLen) = 0;
+};
+
+extern "C" const IID IID_ISampleGrabber;
+struct
+#ifndef __MINGW32__
+__declspec(uuid("6B652FFF-11FE-4fce-92AD-0266B5D7C78F")) __declspec(novtable)
+#endif
+ISampleGrabber : public IUnknown
+{
+public:
+ virtual HRESULT __stdcall SetOneShot(
+ WIN_BOOL OneShot) = 0;
+ virtual HRESULT __stdcall SetMediaType(
+ const AM_MEDIA_TYPE *pType) = 0;
+ virtual HRESULT __stdcall GetConnectedMediaType(
+ AM_MEDIA_TYPE *pType) = 0;
+ virtual HRESULT __stdcall SetBufferSamples(
+ WIN_BOOL BufferThem) = 0;
+ virtual HRESULT __stdcall GetCurrentBuffer(
+ long *pBufferSize,
+ long *pBuffer) = 0;
+ virtual HRESULT __stdcall GetCurrentSample(
+ IMediaSample **ppSample) = 0;
+ virtual HRESULT __stdcall SetCallback(
+ ISampleGrabberCB *pCallback,
+ long WhichMethodToCallback) = 0;
+
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/win/makefile.mk b/avmedia/source/win/makefile.mk
new file mode 100644
index 000000000000..7fdb92378da4
--- /dev/null
+++ b/avmedia/source/win/makefile.mk
@@ -0,0 +1,80 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=avmedia
+TARGET=avmediawin
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(ENABLE_DIRECTX)" != ""
+
+.IF "$(verbose)"!="" || "$(VERBOSE)"!=""
+CDEFS+= -DVERBOSE
+.ENDIF
+
+# --- Files ----------------------------------
+
+.IF "$(GUI)" == "WNT"
+
+SLOFILES= \
+ $(SLO)$/winuno.obj \
+ $(SLO)$/manager.obj \
+ $(SLO)$/window.obj \
+ $(SLO)$/player.obj \
+ $(SLO)$/framegrabber.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/winuno.obj \
+ $(SLO)$/framegrabber.obj
+
+SHL1TARGET=$(TARGET)
+SHL1STDLIBS= $(CPPULIB) $(SALLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(UNOTOOLSLIB) $(TOOLSLIB) $(VCLLIB)
+SHL1IMPLIB=i$(TARGET)
+SHL1LIBS=$(SLB)$/$(TARGET).lib
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=exports.dxp
+
+SHL1STDLIBS += $(OLE32LIB)
+SHL1STDLIBS += $(OLEAUT32LIB)
+SHL1STDLIBS += $(GDI32LIB)
+
+.IF "$(COM)"=="GCC"
+SHL1STDLIBS += $(PSDK_HOME)$/lib$/strmiids.lib
+.ELSE
+SHL1STDLIBS += strmiids.lib
+SHL1STDLIBS += dxguid.lib
+.ENDIF
+
+.ENDIF
+.ENDIF
+
+.INCLUDE : target.mk
diff --git a/avmedia/source/win/manager.cxx b/avmedia/source/win/manager.cxx
new file mode 100644
index 000000000000..c10a96233766
--- /dev/null
+++ b/avmedia/source/win/manager.cxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "manager.hxx"
+#include "player.hxx"
+
+#include <tools/urlobj.hxx>
+
+#define AVMEDIA_WIN_MANAGER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Manager_DirectX"
+#define AVMEDIA_WIN_MANAGER_SERVICENAME "com.sun.star.media.Manager"
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace win {
+// ----------------
+// - Manager -
+// ----------------
+
+Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
+ mxMgr( rxMgr )
+{
+}
+
+// ------------------------------------------------------------------------------
+
+Manager::~Manager()
+{
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< media::XPlayer > SAL_CALL Manager::createPlayer( const ::rtl::OUString& rURL )
+ throw (uno::RuntimeException)
+{
+ Player* pPlayer( new Player( mxMgr ) );
+ uno::Reference< media::XPlayer > xRet( pPlayer );
+ const INetURLObject aURL( rURL );
+
+ if( !pPlayer->create( aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) )
+ xRet = uno::Reference< media::XPlayer >();
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL Manager::getImplementationName( )
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_WIN_MANAGER_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Manager::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_WIN_MANAGER_SERVICENAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL Manager::getSupportedServiceNames( )
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aRet(1);
+ aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_WIN_MANAGER_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace win
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/win/manager.hxx b/avmedia/source/win/manager.hxx
new file mode 100644
index 000000000000..0dd52627641b
--- /dev/null
+++ b/avmedia/source/win/manager.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _MANAGER_HXX
+#define _MANAGER_HXX
+
+#include "wincommon.hxx"
+
+#include "com/sun/star/media/XManager.hdl"
+
+// -----------
+// - Manager -
+// -----------
+
+namespace avmedia { namespace win {
+
+class Manager : public ::cppu::WeakImplHelper2 < ::com::sun::star::media::XManager,
+ ::com::sun::star::lang::XServiceInfo >
+{
+public:
+
+ Manager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMgr );
+ ~Manager();
+
+ // XManager
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > SAL_CALL createPlayer( const ::rtl::OUString& aURL ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ 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);
+private:
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr;
+};
+
+} // namespace win
+} // namespace avmedia
+
+#endif // _MANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/win/player.cxx b/avmedia/source/win/player.cxx
new file mode 100644
index 000000000000..10ee2f2b9734
--- /dev/null
+++ b/avmedia/source/win/player.cxx
@@ -0,0 +1,498 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <tools/prewin.h>
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable: 4917)
+#endif
+#include <windows.h>
+#include <objbase.h>
+#include <strmif.h>
+#include <control.h>
+#include <uuids.h>
+#include <evcode.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <tools/postwin.h>
+
+#include "player.hxx"
+#include "framegrabber.hxx"
+#include "window.hxx"
+
+#define AVMEDIA_WIN_PLAYER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Player_DirectX"
+#define AVMEDIA_WIN_PLAYER_SERVICENAME "com.sun.star.media.Player_DirectX"
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace win {
+
+bool isWindowsVistaOrHigher()
+{
+ // POST: return true if we are at least on Windows Vista
+ OSVERSIONINFO osvi;
+ ZeroMemory(&osvi, sizeof(osvi));
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx(&osvi);
+ if ( osvi.dwMajorVersion >= 6 )
+ return true;
+
+ return false;
+}
+
+// ----------------
+// - Player -
+// ----------------
+
+Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
+ mxMgr( rxMgr ),
+ mpGB( NULL ),
+ mpOMF( NULL ),
+ mpMC( NULL ),
+ mpME( NULL ),
+ mpMS( NULL ),
+ mpMP( NULL ),
+ mpBA( NULL ),
+ mpBV( NULL ),
+ mpVW( NULL ),
+ mpEV( NULL ),
+ mnUnmutedVolume( 0 ),
+ mbMuted( false ),
+ mbLooping( false )
+{
+ ::CoInitialize( NULL );
+}
+
+// ------------------------------------------------------------------------------
+
+Player::~Player()
+{
+ if( mpBA )
+ mpBA->Release();
+
+ if( mpBV )
+ mpBV->Release();
+
+ if( mpVW )
+ mpVW->Release();
+
+ if( mpMP )
+ mpMP->Release();
+
+ if( mpMS )
+ mpMS->Release();
+
+ if( mpME )
+ mpME->Release();
+
+ if( mpMC )
+ mpMC->Release();
+
+ if( mpEV )
+ mpEV->Release();
+
+ if( mpOMF )
+ mpOMF->Release();
+
+ if( mpGB )
+ mpGB->Release();
+
+ ::CoUninitialize();
+}
+
+// ------------------------------------------------------------------------------
+
+bool Player::create( const ::rtl::OUString& rURL )
+{
+ HRESULT hR;
+ bool bRet = false;
+
+ if( SUCCEEDED( hR = CoCreateInstance( CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**) &mpGB ) ) )
+ {
+ // 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( SUCCEEDED( CoCreateInstance( CLSID_OverlayMixer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**) &mpOMF ) ) )
+ {
+ mpGB->AddFilter( mpOMF, L"com_sun_star_media_OverlayMixerFilter" );
+
+ if( !SUCCEEDED( mpOMF->QueryInterface( IID_IDDrawExclModeVideo, (void**) &mpEV ) ) )
+ mpEV = NULL;
+ }
+ }
+
+ if( SUCCEEDED( hR = mpGB->RenderFile( reinterpret_cast<LPCWSTR>(rURL.getStr()), NULL ) ) &&
+ SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaControl, (void**) &mpMC ) ) &&
+ SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaEventEx, (void**) &mpME ) ) &&
+ SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaSeeking, (void**) &mpMS ) ) &&
+ SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaPosition, (void**) &mpMP ) ) )
+ {
+ // Video interfaces
+ mpGB->QueryInterface( IID_IVideoWindow, (void**) &mpVW );
+ mpGB->QueryInterface( IID_IBasicVideo, (void**) &mpBV );
+
+ // Audio interface
+ mpGB->QueryInterface( IID_IBasicAudio, (void**) &mpBA );
+
+ if( mpBA )
+ mpBA->put_Volume( mnUnmutedVolume );
+
+ bRet = true;
+ }
+ }
+
+ if( bRet )
+ maURL = rURL;
+ else
+ maURL = ::rtl::OUString();
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------------
+
+const IVideoWindow* Player::getVideoWindow() const
+{
+ return mpVW;
+}
+
+// ------------------------------------------------------------------------------
+
+void Player::setNotifyWnd( int nNotifyWnd )
+{
+ if( mpME )
+ mpME->SetNotifyWindow( (OAHWND) nNotifyWnd, WM_GRAPHNOTIFY, reinterpret_cast< LONG_PTR>( this ) );
+}
+
+// ------------------------------------------------------------------------------
+
+void Player::setDDrawParams( IDirectDraw* pDDraw, IDirectDrawSurface* pDDrawSurface )
+{
+ if( mpEV && pDDraw && pDDrawSurface )
+ {
+ mpEV->SetDDrawObject( pDDraw );
+ mpEV->SetDDrawSurface( pDDrawSurface );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+long Player::processEvent()
+{
+ long nCode;
+ LONG_PTR nParam1, nParam2;
+
+ if( mpME && SUCCEEDED( mpME->GetEvent( &nCode, &nParam1, &nParam2, 0 ) ) )
+ {
+ if( EC_COMPLETE == nCode )
+ {
+ if( mbLooping )
+ {
+ setMediaTime( 0.0 );
+ start();
+ }
+ else
+ {
+ setMediaTime( getDuration() );
+ stop();
+ }
+ }
+
+ mpME->FreeEventParams( nCode, nParam1, nParam2 );
+ }
+
+ return 0;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::start( )
+ throw (uno::RuntimeException)
+{
+ if( mpMC )
+ mpMC->Run();
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::stop( )
+ throw (uno::RuntimeException)
+{
+ if( mpMC )
+ mpMC->Stop();
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::isPlaying()
+ throw (uno::RuntimeException)
+{
+ OAFilterState eFilterState;
+ bool bRet = false;
+
+ if( mpMC && SUCCEEDED( mpMC->GetState( 10, &eFilterState ) ) )
+ bRet = ( State_Running == eFilterState );
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getDuration( )
+ throw (uno::RuntimeException)
+{
+ REFTIME aRefTime( 0.0 );
+
+ if( mpMP )
+ mpMP->get_Duration( &aRefTime );
+
+ return aRefTime;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setMediaTime( double fTime )
+ throw (uno::RuntimeException)
+{
+ if( mpMP )
+ {
+ const bool bPlaying = isPlaying();
+
+ mpMP->put_CurrentPosition( fTime );
+
+ if( !bPlaying && mpMC )
+ mpMC->StopWhenReady();
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getMediaTime( )
+ throw (uno::RuntimeException)
+{
+ REFTIME aRefTime( 0.0 );
+
+ if( mpMP )
+ mpMP->get_CurrentPosition( &aRefTime );
+
+ return aRefTime;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setStopTime( double fTime )
+ throw (uno::RuntimeException)
+{
+ if( mpMP )
+ mpMP->put_StopTime( fTime );
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getStopTime( )
+ throw (uno::RuntimeException)
+{
+ REFTIME aRefTime( 0.0 );
+
+ if( mpMP )
+ mpMP->get_StopTime( &aRefTime );
+
+ return aRefTime;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setRate( double fRate )
+ throw (uno::RuntimeException)
+{
+ if( mpMP )
+ mpMP->put_Rate( fRate );
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getRate( )
+ throw (uno::RuntimeException)
+{
+ double fRet( 0.0 );
+
+ if( mpMP )
+ mpMP->get_Rate( &fRet );
+
+ return fRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet )
+ throw (uno::RuntimeException)
+{
+ mbLooping = bSet;
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::isPlaybackLoop( )
+ throw (uno::RuntimeException)
+{
+ return mbLooping;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setMute( sal_Bool bSet )
+ throw (uno::RuntimeException)
+{
+ if( mpBA && ( mbMuted != bSet ) )
+ {
+ mbMuted = bSet;
+ mpBA->put_Volume( mbMuted ? -10000 : mnUnmutedVolume );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::isMute( )
+ throw (uno::RuntimeException)
+{
+ return mbMuted;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB )
+ throw (uno::RuntimeException)
+{
+ mnUnmutedVolume = static_cast< long >( nVolumeDB ) * 100;
+
+ if( !mbMuted && mpBA )
+ mpBA->put_Volume( mnUnmutedVolume );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL Player::getVolumeDB( )
+ throw (uno::RuntimeException)
+{
+ return( static_cast< sal_Int16 >( mnUnmutedVolume / 100 ) );
+}
+
+// ------------------------------------------------------------------------------
+
+awt::Size SAL_CALL Player::getPreferredPlayerWindowSize( )
+ throw (uno::RuntimeException)
+{
+ awt::Size aSize( 0, 0 );
+
+ if( mpBV )
+ {
+ long nWidth = 0, nHeight = 0;
+
+ mpBV->GetVideoSize( &nWidth, &nHeight );
+ aSize.Width = nWidth;
+ aSize.Height = nHeight;
+ }
+
+ return aSize;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( const uno::Sequence< uno::Any >& aArguments )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< ::media::XPlayerWindow > xRet;
+ awt::Size aSize( getPreferredPlayerWindowSize() );
+
+ if( mpVW && aSize.Width > 0 && aSize.Height > 0 )
+ {
+ ::avmedia::win::Window* pWindow = new ::avmedia::win::Window( mxMgr, *this );
+
+ xRet = pWindow;
+
+ if( !pWindow->create( aArguments ) )
+ xRet = uno::Reference< ::media::XPlayerWindow >();
+ }
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber( )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< media::XFrameGrabber > xRet;
+
+ if( maURL.getLength() > 0 )
+ {
+ FrameGrabber* pGrabber = new FrameGrabber( mxMgr );
+
+ xRet = pGrabber;
+
+ if( !pGrabber->create( maURL ) )
+ xRet.clear();
+ }
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL Player::getImplementationName( )
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_WIN_PLAYER_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_WIN_PLAYER_SERVICENAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL Player::getSupportedServiceNames( )
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aRet(1);
+ aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_WIN_PLAYER_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace win
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/win/player.hxx b/avmedia/source/win/player.hxx
new file mode 100644
index 000000000000..7f87511209bd
--- /dev/null
+++ b/avmedia/source/win/player.hxx
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _PLAYER_HXX
+#define _PLAYER_HXX
+
+#include "wincommon.hxx"
+
+#include "com/sun/star/media/XPlayer.hdl"
+
+struct IGraphBuilder;
+struct IBaseFilter;
+struct IMediaControl;
+struct IMediaEventEx;
+struct IMediaSeeking;
+struct IMediaPosition;
+struct IBasicAudio;
+struct IBasicVideo;
+struct IVideoWindow;
+struct IDDrawExclModeVideo;
+struct IDirectDraw;
+struct IDirectDrawSurface;
+
+namespace avmedia { namespace win {
+
+// ----------
+// - Player -
+// ----------
+
+class Player : public ::cppu::WeakImplHelper2< ::com::sun::star::media::XPlayer,
+ ::com::sun::star::lang::XServiceInfo >
+{
+public:
+
+ Player( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMgr );
+ ~Player();
+
+ bool create( const ::rtl::OUString& rURL );
+
+ void setNotifyWnd( int nNotifyWnd );
+ void setDDrawParams( IDirectDraw* pDDraw, IDirectDrawSurface* pDDrawSurface );
+ long processEvent();
+
+ const IVideoWindow* getVideoWindow() const;
+
+ // XPlayer
+ virtual void SAL_CALL start( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL stop( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isPlaying( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getDuration( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMediaTime( double fTime ) throw (::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getMediaTime( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setStopTime( double fTime ) throw (::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getStopTime( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRate( double fRate ) throw (::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getRate( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPlaybackLoop( sal_Bool bSet ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isPlaybackLoop( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMute( sal_Bool bSet ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isMute( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setVolumeDB( sal_Int16 nVolumeDB ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getVolumeDB( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL getPreferredPlayerWindowSize( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > SAL_CALL createPlayerWindow( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XFrameGrabber > SAL_CALL createFrameGrabber( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ 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);
+
+private:
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr;
+
+ ::rtl::OUString maURL;
+ IGraphBuilder* mpGB;
+ IBaseFilter* mpOMF;
+ IMediaControl* mpMC;
+ IMediaEventEx* mpME;
+ IMediaSeeking* mpMS;
+ IMediaPosition* mpMP;
+ IBasicAudio* mpBA;
+ IBasicVideo* mpBV;
+ IVideoWindow* mpVW;
+ IDDrawExclModeVideo* mpEV;
+ long mnUnmutedVolume;
+ sal_Bool mbMuted;
+ sal_Bool mbLooping;
+
+ void ImplLayoutVideoWindow();
+};
+
+} // namespace win
+} // namespace avmedia
+
+#endif // _PLAYER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/win/wincommon.hxx b/avmedia/source/win/wincommon.hxx
new file mode 100644
index 000000000000..0dd7cae023d3
--- /dev/null
+++ b/avmedia/source/win/wincommon.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _WINCOMMON_HXX
+#define _WINCOMMON_HXX
+
+#include <osl/mutex.hxx>
+#include <rtl/ustring.hxx>
+#include <tools/debug.hxx>
+#include <tools/stream.hxx>
+#include <tools/string.hxx>
+#include <tools/urlobj.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/factory.hxx>
+
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/awt/KeyModifier.hpp>
+#include <com/sun/star/awt/MouseButton.hpp>
+#include <com/sun/star/media/XManager.hpp>
+
+#define WM_GRAPHNOTIFY (WM_USER + 567)
+
+#endif // _WINCOMMOM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/win/window.cxx b/avmedia/source/win/window.cxx
new file mode 100644
index 000000000000..7163c076fb8b
--- /dev/null
+++ b/avmedia/source/win/window.cxx
@@ -0,0 +1,743 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <tools/prewin.h>
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable: 4917)
+#endif
+#include <windows.h>
+#include <objbase.h>
+#include <strmif.h>
+#include <control.h>
+#include <dshow.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <tools/postwin.h>
+#include <com/sun/star/awt/SystemPointer.hdl>
+
+#include "window.hxx"
+#include "player.hxx"
+
+#define AVMEDIA_WIN_WINDOW_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Window_DirectX"
+#define AVMEDIA_WIN_WINDOW_SERVICENAME "com.sun.star.media.Window_DirectX"
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace win {
+
+// -----------
+// - statics -
+// -----------
+
+static ::osl::Mutex& ImplGetOwnStaticMutex()
+{
+ static ::osl::Mutex* pMutex = NULL;
+
+ if( pMutex == NULL )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+
+ if( pMutex == NULL )
+ {
+ static ::osl::Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+
+ return *pMutex;
+}
+
+// -----------
+// - WndProc -
+// -----------
+
+LRESULT CALLBACK MediaPlayerWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
+{
+ Window* pWindow = (Window*) ::GetWindowLong( hWnd, 0 );
+ bool bProcessed = true;
+
+ if( pWindow )
+ {
+ switch( nMsg )
+ {
+ case( WM_SETCURSOR ):
+ pWindow->updatePointer();
+ break;
+
+ case( WM_GRAPHNOTIFY ):
+ pWindow->processGraphEvent();
+ break;
+
+ case( WM_MOUSEMOVE ):
+ case( WM_LBUTTONDOWN ):
+ case( WM_MBUTTONDOWN ):
+ case( WM_RBUTTONDOWN ):
+ case( WM_LBUTTONUP ):
+ case( WM_MBUTTONUP ):
+ case( WM_RBUTTONUP ):
+ {
+ awt::MouseEvent aUNOEvt;
+ POINT aWinPoint;
+
+ if( !::GetCursorPos( &aWinPoint ) || !::ScreenToClient( hWnd, &aWinPoint ) )
+ {
+ aWinPoint.x = GET_X_LPARAM( nPar2 );
+ aWinPoint.y = GET_Y_LPARAM( nPar2 );
+ }
+ aUNOEvt.Modifiers = 0;
+ aUNOEvt.Buttons = 0;
+ aUNOEvt.X = aWinPoint.x;
+ aUNOEvt.Y = aWinPoint.y;
+ aUNOEvt.PopupTrigger = false;
+
+ // Modifiers
+ if( nPar1 & MK_SHIFT )
+ aUNOEvt.Modifiers |= awt::KeyModifier::SHIFT;
+
+ if( nPar1 & MK_CONTROL )
+ aUNOEvt.Modifiers |= awt::KeyModifier::MOD1;
+
+ // Buttons
+ if( WM_LBUTTONDOWN == nMsg || WM_LBUTTONUP == nMsg )
+ aUNOEvt.Buttons |= awt::MouseButton::LEFT;
+
+ if( WM_MBUTTONDOWN == nMsg || WM_MBUTTONUP == nMsg )
+ aUNOEvt.Buttons |= awt::MouseButton::MIDDLE;
+
+ if( WM_RBUTTONDOWN == nMsg || WM_RBUTTONUP == nMsg )
+ aUNOEvt.Buttons |= awt::MouseButton::RIGHT;
+
+ // event type
+ if( WM_LBUTTONDOWN == nMsg ||
+ WM_MBUTTONDOWN == nMsg ||
+ WM_RBUTTONDOWN == nMsg )
+ {
+ aUNOEvt.ClickCount = 1;
+ pWindow->fireMousePressedEvent( aUNOEvt );
+ }
+ else if( WM_LBUTTONUP == nMsg ||
+ WM_MBUTTONUP == nMsg ||
+ WM_RBUTTONUP == nMsg )
+ {
+ aUNOEvt.ClickCount = 1;
+ pWindow->fireMouseReleasedEvent( aUNOEvt );
+ }
+ else if( WM_MOUSEMOVE == nMsg )
+ {
+ aUNOEvt.ClickCount = 0;
+ pWindow->fireMouseMovedEvent( aUNOEvt );
+ pWindow->updatePointer();
+ }
+ }
+ break;
+
+ case( WM_SETFOCUS ):
+ {
+ const awt::FocusEvent aUNOEvt;
+ pWindow->fireSetFocusEvent( aUNOEvt );
+ }
+ break;
+
+ default:
+ bProcessed = false;
+ break;
+ }
+ }
+ else
+ bProcessed = false;
+
+ return( bProcessed ? 0 : DefWindowProc( hWnd, nMsg, nPar1, nPar2 ) );
+}
+
+// ---------------
+// - Window -
+// ---------------
+
+WNDCLASS* Window::mpWndClass = NULL;
+
+// ------------------------------------------------------------------------------
+
+Window::Window( const uno::Reference< lang::XMultiServiceFactory >& rxMgr, Player& rPlayer ) :
+ mxMgr( rxMgr ),
+ mrPlayer( rPlayer ),
+ meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ),
+ mnParentWnd( 0 ),
+ mnFrameWnd( 0 ),
+ maListeners( maMutex ),
+ mnPointerType( awt::SystemPointer::ARROW )
+{
+ ::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 );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+Window::~Window()
+{
+ if( mnFrameWnd )
+ ::DestroyWindow( (HWND) mnFrameWnd );
+}
+
+// ------------------------------------------------------------------------------
+
+void Window::ImplLayoutVideoWindow()
+{
+ if( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel )
+ {
+ awt::Size aPrefSize( mrPlayer.getPreferredPlayerWindowSize() );
+ awt::Rectangle aRect = getPosSize();
+ int nW = aRect.Width, nH = aRect.Height;
+ int nVideoW = nW, nVideoH = nH;
+ int nX = 0, nY = 0, nWidth = 0, nHeight = 0;
+ bool bDone = false, bZoom = false;
+
+ if( media::ZoomLevel_ORIGINAL == meZoomLevel )
+ {
+ bZoom = true;
+ }
+ else if( media::ZoomLevel_ZOOM_1_TO_4 == meZoomLevel )
+ {
+ aPrefSize.Width >>= 2;
+ aPrefSize.Height >>= 2;
+ bZoom = true;
+ }
+ else if( media::ZoomLevel_ZOOM_1_TO_2 == meZoomLevel )
+ {
+ aPrefSize.Width >>= 1;
+ aPrefSize.Height >>= 1;
+ bZoom = true;
+ }
+ else if( media::ZoomLevel_ZOOM_2_TO_1 == meZoomLevel )
+ {
+ aPrefSize.Width <<= 1;
+ aPrefSize.Height <<= 1;
+ bZoom = true;
+ }
+ else if( media::ZoomLevel_ZOOM_4_TO_1 == meZoomLevel )
+ {
+ aPrefSize.Width <<= 2;
+ aPrefSize.Height <<= 2;
+ bZoom = true;
+ }
+ else if( media::ZoomLevel_FIT_TO_WINDOW == meZoomLevel )
+ {
+ nWidth = nVideoW;
+ nHeight = nVideoH;
+ bDone = true;
+ }
+
+ if( bZoom )
+ {
+ if( ( aPrefSize.Width <= nVideoW ) && ( aPrefSize.Height <= nVideoH ) )
+ {
+ nX = ( nVideoW - aPrefSize.Width ) >> 1;
+ nY = ( nVideoH - aPrefSize.Height ) >> 1;
+ nWidth = aPrefSize.Width;
+ nHeight = aPrefSize.Height;
+ bDone = true;
+ }
+ }
+
+ if( !bDone )
+ {
+ if( aPrefSize.Width > 0 && aPrefSize.Height > 0 && nVideoW > 0 && nVideoH > 0 )
+ {
+ double fPrefWH = (double) aPrefSize.Width / aPrefSize.Height;
+
+ if( fPrefWH < ( (double) nVideoW / nVideoH ) )
+ nVideoW = (int)( nVideoH * fPrefWH );
+ else
+ nVideoH = (int)( nVideoW / fPrefWH );
+
+ nX = ( nW - nVideoW ) >> 1;
+ nY = ( nH - nVideoH ) >> 1;
+ nWidth = nVideoW;
+ nHeight = nVideoH;
+ }
+ else
+ nX = nY = nWidth = nHeight = 0;
+ }
+
+ IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() );
+
+ if( pVideoWindow )
+ pVideoWindow->SetWindowPosition( nX, nY, nWidth, nHeight );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+bool Window::create( const uno::Sequence< uno::Any >& rArguments )
+{
+ IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() );
+
+ if( !mnFrameWnd && pVideoWindow && mpWndClass )
+ {
+ awt::Rectangle aRect;
+ sal_IntPtr nWnd;
+
+ rArguments[ 0 ] >>= nWnd;
+ rArguments[ 1 ] >>= aRect;
+
+ mnParentWnd = static_cast<int>(nWnd);
+
+ mnFrameWnd = (int) ::CreateWindow( mpWndClass->lpszClassName, NULL,
+ WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ aRect.X, aRect.Y, aRect.Width, aRect.Height,
+ (HWND) mnParentWnd, NULL, mpWndClass->hInstance, 0 );
+
+ // if the last CreateWindow failed...
+ if( mnFrameWnd == 0 )
+ {
+ // try again and this time assume that mnParent is indeed a dc
+ mnParentWnd = reinterpret_cast<int>(::WindowFromDC( (HDC)mnParentWnd ));
+ mnFrameWnd = (int) ::CreateWindow( mpWndClass->lpszClassName, NULL,
+ WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ aRect.X, aRect.Y, aRect.Width, aRect.Height,
+ (HWND)mnParentWnd , NULL, mpWndClass->hInstance, 0 );
+ }
+
+ if( mnFrameWnd )
+ {
+ ::SetWindowLong( (HWND) mnFrameWnd, 0, (DWORD) this );
+
+#ifdef DDRAW_TEST_OUTPUT
+ IDirectDraw7* pDDraw;
+ IDirectDrawSurface7* pDDSurface;
+ IDirectDrawClipper* pDDClipper;
+
+ if( DD_OK == DirectDrawCreateEx( NULL, (void**) &pDDraw, IID_IDirectDraw7, NULL ) )
+ {
+ if( DD_OK == pDDraw->SetCooperativeLevel( (HWND) mnParentWnd, DDSCL_NORMAL ) )
+ {
+ DDSURFACEDESC2 aDDDesc;
+
+ memset( &aDDDesc, 0, sizeof( aDDDesc ) );
+ aDDDesc.dwSize = sizeof( aDDDesc );
+ aDDDesc.dwFlags = DDSD_CAPS;
+ aDDDesc.ddsCaps.dwCaps |= DDSCAPS_PRIMARYSURFACE;
+
+ if( DD_OK == pDDraw->CreateSurface( &aDDDesc, &pDDSurface, NULL ) )
+ {
+ if( DD_OK == pDDraw->CreateClipper( 0, &pDDClipper, NULL ) )
+ {
+ pDDClipper->SetHWnd( 0, (HWND) mnFrameWnd );
+ pDDSurface->SetClipper( pDDClipper );
+ }
+
+ mrPlayer.setDDrawParams( (IDirectDraw*) pDDraw, (IDirectDrawSurface*) pDDSurface );
+#endif
+
+ pVideoWindow->put_Owner( (OAHWND) mnFrameWnd );
+ pVideoWindow->put_MessageDrain( (OAHWND) mnFrameWnd );
+ pVideoWindow->put_WindowStyle( WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN );
+
+ mrPlayer.setNotifyWnd( mnFrameWnd );
+
+ meZoomLevel = media::ZoomLevel_ORIGINAL;
+ ImplLayoutVideoWindow();
+#ifdef DDRAW_TEST_OUTPUT
+ }
+ }
+ }
+#endif
+ }
+ }
+
+ return( mnFrameWnd != 0 );
+}
+
+// ------------------------------------------------------------------------------
+
+void Window::processGraphEvent()
+{
+ mrPlayer.processEvent();
+}
+
+// ------------------------------------------------------------------------------
+
+void Window::updatePointer()
+{
+ char* pCursorName;
+
+ switch( mnPointerType )
+ {
+ case( awt::SystemPointer::CROSS ): pCursorName = IDC_CROSS; break;
+ //case( awt::SystemPointer::HAND ): pCursorName = IDC_HAND; break;
+ case( awt::SystemPointer::MOVE ): pCursorName = IDC_SIZEALL; break;
+ case( awt::SystemPointer::WAIT ): pCursorName = IDC_WAIT; break;
+
+ default:
+ pCursorName = IDC_ARROW;
+ break;
+ }
+
+ ::SetCursor( ::LoadCursor( NULL, pCursorName ) );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::update( )
+ throw (uno::RuntimeException)
+{
+ ::RedrawWindow( (HWND) mnFrameWnd, NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Window::setZoomLevel( media::ZoomLevel eZoomLevel )
+ throw (uno::RuntimeException)
+{
+ boolean bRet = false;
+
+ if( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel &&
+ media::ZoomLevel_NOT_AVAILABLE != eZoomLevel )
+ {
+ if( eZoomLevel != meZoomLevel )
+ {
+ meZoomLevel = eZoomLevel;
+ ImplLayoutVideoWindow();
+ }
+
+ bRet = true;
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------------
+
+media::ZoomLevel SAL_CALL Window::getZoomLevel( )
+ throw (uno::RuntimeException)
+{
+ return meZoomLevel;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setPointerType( sal_Int32 nPointerType )
+ throw (uno::RuntimeException)
+{
+ mnPointerType = nPointerType;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 )
+ throw (uno::RuntimeException)
+{
+ if( mnFrameWnd )
+ {
+ ::SetWindowPos( (HWND) mnFrameWnd, HWND_TOP, X, Y, Width, Height, 0 );
+ ImplLayoutVideoWindow();
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+awt::Rectangle SAL_CALL Window::getPosSize()
+ throw (uno::RuntimeException)
+{
+ awt::Rectangle aRet;
+
+ if( mnFrameWnd )
+ {
+ ::RECT aWndRect;
+
+ if( ::GetClientRect( (HWND) mnFrameWnd, &aWndRect ) )
+ {
+ aRet.X = aWndRect.left;
+ aRet.Y = aWndRect.top;
+ aRet.Width = aWndRect.right - aWndRect.left + 1;
+ aRet.Height = aWndRect.bottom - aWndRect.top + 1;
+ }
+ }
+
+ return aRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setVisible( sal_Bool bVisible )
+ throw (uno::RuntimeException)
+{
+ if( mnFrameWnd )
+ {
+ IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() );
+
+ if( pVideoWindow )
+ pVideoWindow->put_Visible( bVisible ? OATRUE : OAFALSE );
+
+ ::ShowWindow( (HWND) mnFrameWnd, bVisible ? SW_SHOW : SW_HIDE );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setEnable( sal_Bool bEnable )
+ throw (uno::RuntimeException)
+{
+ if( mnFrameWnd )
+ ::EnableWindow( (HWND) mnFrameWnd, bEnable );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setFocus( )
+ throw (uno::RuntimeException)
+{
+ if( mnFrameWnd )
+ ::SetFocus( (HWND) mnFrameWnd );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::addWindowListener( const uno::Reference< awt::XWindowListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.addInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::removeWindowListener( const uno::Reference< awt::XWindowListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.removeInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.addInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.removeInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::addKeyListener( const uno::Reference< awt::XKeyListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.addInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::removeKeyListener( const uno::Reference< awt::XKeyListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.removeInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::addMouseListener( const uno::Reference< awt::XMouseListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.addInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.removeInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.addInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.removeInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::addPaintListener( const uno::Reference< awt::XPaintListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.addInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.removeInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::dispose( )
+ throw (uno::RuntimeException)
+{
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.addInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maListeners.removeInterface( getCppuType( &xListener ), xListener );
+}
+
+// ------------------------------------------------------------------------------
+
+void Window::fireMousePressedEvent( const ::com::sun::star::awt::MouseEvent& rEvt )
+{
+ ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XMouseListener >*) 0 ) );
+
+ if( pContainer )
+ {
+ ::cppu::OInterfaceIteratorHelper aIter( *pContainer );
+
+ while( aIter.hasMoreElements() )
+ uno::Reference< awt::XMouseListener >( aIter.next(), uno::UNO_QUERY )->mousePressed( rEvt );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void Window::fireMouseReleasedEvent( const ::com::sun::star::awt::MouseEvent& rEvt )
+{
+ ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XMouseListener >*) 0 ) );
+
+ if( pContainer )
+ {
+ ::cppu::OInterfaceIteratorHelper aIter( *pContainer );
+
+ while( aIter.hasMoreElements() )
+ uno::Reference< awt::XMouseListener >( aIter.next(), uno::UNO_QUERY )->mouseReleased( rEvt );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void Window::fireMouseMovedEvent( const ::com::sun::star::awt::MouseEvent& rEvt )
+{
+ ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XMouseMotionListener >*) 0 ) );
+
+ if( pContainer )
+ {
+ ::cppu::OInterfaceIteratorHelper aIter( *pContainer );
+
+ while( aIter.hasMoreElements() )
+ uno::Reference< awt::XMouseMotionListener >( aIter.next(), uno::UNO_QUERY )->mouseMoved( rEvt );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void Window::fireSetFocusEvent( const ::com::sun::star::awt::FocusEvent& rEvt )
+{
+ ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XFocusListener >*) 0 ) );
+
+ if( pContainer )
+ {
+ ::cppu::OInterfaceIteratorHelper aIter( *pContainer );
+
+ while( aIter.hasMoreElements() )
+ uno::Reference< awt::XFocusListener >( aIter.next(), uno::UNO_QUERY )->focusGained( rEvt );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL Window::getImplementationName( )
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_WIN_WINDOW_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Window::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_WIN_WINDOW_SERVICENAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL Window::getSupportedServiceNames( )
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aRet(1);
+ aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_WIN_WINDOW_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace win
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/win/window.hxx b/avmedia/source/win/window.hxx
new file mode 100644
index 000000000000..22a6c295f8d3
--- /dev/null
+++ b/avmedia/source/win/window.hxx
@@ -0,0 +1,126 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _WINDOW_HXX
+#define _WINDOW_HXX
+
+#include "wincommon.hxx"
+#include <cppuhelper/interfacecontainer.h>
+
+#include "com/sun/star/media/XPlayerWindow.hdl"
+
+struct IVideoWindow;
+
+namespace avmedia { namespace win {
+
+// ---------------
+// - Window -
+// ---------------
+
+class Player;
+
+class Window : public ::cppu::WeakImplHelper2 < ::com::sun::star::media::XPlayerWindow,
+ ::com::sun::star::lang::XServiceInfo >
+{
+public:
+
+ Window( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMgr,
+ Player& rPlayer );
+ ~Window();
+
+ bool create( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments );
+ void processGraphEvent();
+ void updatePointer();
+
+ // XPlayerWindow
+ virtual void SAL_CALL update( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL setZoomLevel( ::com::sun::star::media::ZoomLevel ZoomLevel ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::media::ZoomLevel SAL_CALL getZoomLevel( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPointerType( sal_Int32 nPointerType ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XWindow
+ virtual void SAL_CALL setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL getPosSize( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setVisible( sal_Bool Visible ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setEnable( sal_Bool Enable ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFocus( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) 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);
+ 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);
+
+public:
+
+ void fireMousePressedEvent( const ::com::sun::star::awt::MouseEvent& rEvt );
+ void fireMouseReleasedEvent( const ::com::sun::star::awt::MouseEvent& rEvt );
+ void fireMouseMovedEvent( const ::com::sun::star::awt::MouseEvent& rEvt );
+ void fireKeyPressedEvent( const ::com::sun::star::awt::KeyEvent& rEvt );
+ void fireKeyReleasedEvent( const ::com::sun::star::awt::KeyEvent& rEvt );
+ void fireSetFocusEvent( const ::com::sun::star::awt::FocusEvent& rEvt );
+
+private:
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr;
+
+ ::osl::Mutex maMutex;
+ ::cppu::OMultiTypeInterfaceContainerHelper maListeners;
+ ::com::sun::star::media::ZoomLevel meZoomLevel;
+ Player& mrPlayer;
+ int mnFrameWnd;
+ int mnParentWnd;
+ int mnPointerType;
+
+ static WNDCLASS* mpWndClass;
+
+ void ImplLayoutVideoWindow();
+};
+
+} // namespace win
+} // namespace avmedia
+
+#endif // _WINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/win/winuno.cxx b/avmedia/source/win/winuno.cxx
new file mode 100644
index 000000000000..85a3795c4d6e
--- /dev/null
+++ b/avmedia/source/win/winuno.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "wincommon.hxx"
+#include "manager.hxx"
+
+using namespace ::com::sun::star;
+
+// -------------------
+// - factory methods -
+// -------------------
+
+static uno::Reference< uno::XInterface > SAL_CALL create_MediaPlayer( const uno::Reference< lang::XMultiServiceFactory >& rxFact )
+{
+ return uno::Reference< uno::XInterface >( *new ::avmedia::win::Manager( rxFact ) );
+}
+
+// ------------------------------------------
+// - component_getImplementationEnvironment -
+// ------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+// -----------------------
+// - component_writeInfo -
+// -----------------------
+
+extern "C" sal_Bool SAL_CALL component_writeInfo( void*, void* pRegistryKey )
+{
+ sal_Bool bRet = sal_False;
+
+ if( pRegistryKey )
+ {
+ try
+ {
+ uno::Reference< registry::XRegistryKey > xNewKey1(
+ static_cast< registry::XRegistryKey* >( pRegistryKey )->createKey(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/com.sun.star.comp.media.Manager_DirectX/UNO/SERVICES/com.sun.star.media.Manager_DirectX" )) ) );
+
+ bRet = sal_True;
+ }
+ catch( registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------
+// - component_getFactory -
+// ------------------------
+
+extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* )
+{
+ uno::Reference< lang::XSingleServiceFactory > xFactory;
+ void* pRet = 0;
+
+ if( rtl_str_compare( pImplName, "com.sun.star.comp.media.Manager_DirectX" ) == 0 )
+ {
+ const ::rtl::OUString aServiceName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.media.Manager_DirectX" )) );
+
+ xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
+ reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.media.Manager_DirectX" )),
+ create_MediaPlayer, uno::Sequence< ::rtl::OUString >( &aServiceName, 1 ) ) );
+ }
+
+ if( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+
+ return pRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */