summaryrefslogtreecommitdiff
path: root/avmedia
diff options
context:
space:
mode:
Diffstat (limited to 'avmedia')
-rw-r--r--avmedia/inc/avmedia/mediaitem.hxx134
-rw-r--r--avmedia/inc/avmedia/mediaplayer.hxx99
-rw-r--r--avmedia/inc/avmedia/mediatoolbox.hxx68
-rw-r--r--avmedia/inc/avmedia/mediawindow.hxx172
-rwxr-xr-xavmedia/inc/helpids.hrc44
-rw-r--r--avmedia/inc/mediacontrol.hxx117
-rw-r--r--avmedia/prj/build.lst11
-rw-r--r--avmedia/prj/d.lst23
-rwxr-xr-xavmedia/source/framework/makefile.mk57
-rw-r--r--avmedia/source/framework/mediacontrol.cxx634
-rwxr-xr-xavmedia/source/framework/mediacontrol.hrc51
-rw-r--r--avmedia/source/framework/mediacontrol.src127
-rw-r--r--avmedia/source/framework/mediaitem.cxx332
-rw-r--r--avmedia/source/framework/mediamisc.cxx51
-rw-r--r--avmedia/source/framework/mediaplayer.cxx169
-rw-r--r--avmedia/source/framework/mediatoolbox.cxx171
-rw-r--r--avmedia/source/framework/soundhandler.cxx523
-rw-r--r--avmedia/source/framework/soundhandler.hxx189
-rwxr-xr-xavmedia/source/framework/soundhandler.xml47
-rw-r--r--avmedia/source/gstreamer/avmediagstreamer.component6
-rwxr-xr-xavmedia/source/gstreamer/exports.dxp2
-rw-r--r--avmedia/source/gstreamer/gstcommon.hxx60
-rw-r--r--avmedia/source/gstreamer/gstframegrabber.cxx236
-rw-r--r--avmedia/source/gstreamer/gstframegrabber.hxx71
-rw-r--r--avmedia/source/gstreamer/gstmanager.cxx109
-rw-r--r--avmedia/source/gstreamer/gstmanager.hxx67
-rw-r--r--avmedia/source/gstreamer/gstplayer.cxx634
-rw-r--r--avmedia/source/gstreamer/gstplayer.hxx114
-rw-r--r--avmedia/source/gstreamer/gstuno.cxx71
-rw-r--r--avmedia/source/gstreamer/gstwindow.cxx326
-rw-r--r--avmedia/source/gstreamer/gstwindow.hxx111
-rwxr-xr-xavmedia/source/gstreamer/makefile.mk88
-rw-r--r--avmedia/source/inc/mediamisc.hxx70
-rwxr-xr-xavmedia/source/java/FrameGrabber.java190
-rwxr-xr-xavmedia/source/java/Manager.java148
-rwxr-xr-xavmedia/source/java/MediaUno.java67
-rwxr-xr-xavmedia/source/java/Player.java325
-rwxr-xr-xavmedia/source/java/PlayerWindow.java600
-rwxr-xr-xavmedia/source/java/WindowAdapter.java496
-rwxr-xr-xavmedia/source/java/avmedia.jarbin0 -> 15776 bytes
-rwxr-xr-xavmedia/source/java/avmedia.jar.component34
-rwxr-xr-xavmedia/source/java/makefile.mk69
-rwxr-xr-xavmedia/source/java/manifest2
-rwxr-xr-xavmedia/source/java/win/SystemWindowAdapter.java53
-rwxr-xr-xavmedia/source/java/x11/SystemWindowAdapter.java123
-rwxr-xr-xavmedia/source/quicktime/avmediaQuickTime.component34
-rw-r--r--avmedia/source/quicktime/framegrabber.cxx155
-rw-r--r--avmedia/source/quicktime/framegrabber.hxx74
-rwxr-xr-xavmedia/source/quicktime/makefile.mk93
-rw-r--r--avmedia/source/quicktime/manager.cxx99
-rw-r--r--avmedia/source/quicktime/manager.hxx67
-rw-r--r--avmedia/source/quicktime/player.cxx502
-rw-r--r--avmedia/source/quicktime/player.hxx110
-rw-r--r--avmedia/source/quicktime/quicktimecommon.hxx83
-rw-r--r--avmedia/source/quicktime/quicktimeuno.cxx80
-rw-r--r--avmedia/source/quicktime/window.cxx354
-rw-r--r--avmedia/source/quicktime/window.hxx116
-rwxr-xr-xavmedia/source/viewer/makefile.mk55
-rw-r--r--avmedia/source/viewer/mediaevent_impl.cxx225
-rw-r--r--avmedia/source/viewer/mediaevent_impl.hxx92
-rw-r--r--avmedia/source/viewer/mediawindow.cxx574
-rwxr-xr-xavmedia/source/viewer/mediawindow.hrc9
-rw-r--r--avmedia/source/viewer/mediawindow.src77
-rw-r--r--avmedia/source/viewer/mediawindow_impl.cxx546
-rw-r--r--avmedia/source/viewer/mediawindow_impl.hxx151
-rw-r--r--avmedia/source/viewer/mediawindowbase_impl.cxx435
-rw-r--r--avmedia/source/viewer/mediawindowbase_impl.hxx136
-rwxr-xr-xavmedia/source/win/avmediawin.component34
-rwxr-xr-xavmedia/source/win/exports.dxp3
-rw-r--r--avmedia/source/win/framegrabber.cxx249
-rw-r--r--avmedia/source/win/framegrabber.hxx75
-rw-r--r--avmedia/source/win/interface.hxx125
-rwxr-xr-xavmedia/source/win/makefile.mk88
-rw-r--r--avmedia/source/win/manager.cxx100
-rw-r--r--avmedia/source/win/manager.hxx67
-rw-r--r--avmedia/source/win/player.cxx495
-rw-r--r--avmedia/source/win/player.hxx124
-rw-r--r--avmedia/source/win/wincommon.hxx59
-rw-r--r--avmedia/source/win/window.cxx707
-rw-r--r--avmedia/source/win/window.hxx126
-rw-r--r--avmedia/source/win/winuno.cxx80
-rwxr-xr-xavmedia/util/avmedia.component34
-rw-r--r--avmedia/util/hidother.src41
-rwxr-xr-xavmedia/util/makefile.mk87
84 files changed, 13652 insertions, 0 deletions
diff --git a/avmedia/inc/avmedia/mediaitem.hxx b/avmedia/inc/avmedia/mediaitem.hxx
new file mode 100644
index 000000000000..4ae504fc58c9
--- /dev/null
+++ b/avmedia/inc/avmedia/mediaitem.hxx
@@ -0,0 +1,134 @@
+/* -*- 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 _AVMEDIA_MEDIAITEM_HXX
+#define _AVMEDIA_MEDIAITEM_HXX
+
+#include <tools/rtti.hxx>
+#include <svl/poolitem.hxx>
+#include <com/sun/star/media/ZoomLevel.hpp>
+
+#define AVMEDIA_SETMASK_NONE ((sal_uInt32)(0x00000000))
+#define AVMEDIA_SETMASK_STATE ((sal_uInt32)(0x00000001))
+#define AVMEDIA_SETMASK_DURATION ((sal_uInt32)(0x00000002))
+#define AVMEDIA_SETMASK_TIME ((sal_uInt32)(0x00000004))
+#define AVMEDIA_SETMASK_LOOP ((sal_uInt32)(0x00000008))
+#define AVMEDIA_SETMASK_MUTE ((sal_uInt32)(0x00000010))
+#define AVMEDIA_SETMASK_VOLUMEDB ((sal_uInt32)(0x00000020))
+#define AVMEDIA_SETMASK_ZOOM ((sal_uInt32)(0x00000040))
+#define AVMEDIA_SETMASK_URL ((sal_uInt32)(0x00000080))
+#define AVMEDIA_SETMASK_ALL ((sal_uInt32)(0xffffffff))
+
+class SvStream;
+
+namespace avmedia
+{
+
+//---------------
+// - MediaState -
+// --------------
+
+enum MediaState
+{
+ MEDIASTATE_STOP = 0,
+ MEDIASTATE_PLAY = 1,
+ MEDIASTATE_PLAYFFW = 2,
+ MEDIASTATE_PAUSE = 3
+};
+
+// -------------
+// - MediaItem -
+// -------------
+
+class MediaItem : public SfxPoolItem
+{
+public:
+ TYPEINFO();
+
+ MediaItem( sal_uInt16 nWhich = 0, sal_uInt32 nMaskSet = AVMEDIA_SETMASK_NONE );
+ MediaItem( const MediaItem& rMediaItem );
+ virtual ~MediaItem();
+
+ virtual int operator==( const SfxPoolItem& ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const;
+ virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
+ SfxMapUnit eCoreUnit,
+ SfxMapUnit ePresUnit,
+ XubString& rText,
+ const IntlWrapper *pIntl ) const;
+ virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
+ virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
+
+ void merge( const MediaItem& rMediaItem );
+
+ sal_uInt32 getMaskSet() const;
+
+ void setState( MediaState eState );
+ MediaState getState() const;
+
+ void setDuration( double fDuration );
+ double getDuration() const;
+
+ void setTime( double fTime );
+ double getTime() const;
+
+ void setLoop( sal_Bool bLoop );
+ sal_Bool isLoop() const;
+
+ void setMute( sal_Bool bMute );
+ sal_Bool isMute() const;
+
+ void setVolumeDB( sal_Int16 nDB );
+ sal_Int16 getVolumeDB() const;
+
+ void setZoom( ::com::sun::star::media::ZoomLevel eZoom );
+ ::com::sun::star::media::ZoomLevel getZoom() const;
+
+ void setURL( const ::rtl::OUString& rURL );
+ const ::rtl::OUString& getURL() const;
+
+private:
+
+ ::rtl::OUString maURL;
+ sal_uInt32 mnMaskSet;
+ MediaState meState;
+ double mfTime;
+ double mfDuration;
+ sal_Int16 mnVolumeDB;
+ sal_Bool mbLoop;
+ sal_Bool mbMute;
+ ::com::sun::star::media::ZoomLevel meZoom;
+};
+
+typedef ::avmedia::MediaItem avmedia_MediaItem;
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/inc/avmedia/mediaplayer.hxx b/avmedia/inc/avmedia/mediaplayer.hxx
new file mode 100644
index 000000000000..2d49f80e2af7
--- /dev/null
+++ b/avmedia/inc/avmedia/mediaplayer.hxx
@@ -0,0 +1,99 @@
+/* -*- 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 _AVMEDIA_MEDIACHILD_HXX
+#define _AVMEDIA_MEDIACHILD_HXX
+
+#include <sfx2/ctrlitem.hxx>
+#include <sfx2/dockwin.hxx>
+#include <tools/urlobj.hxx>
+
+// -----------
+// - Defines -
+// -----------
+
+#define AVMEDIA_MEDIAWINDOW() \
+(static_cast< ::avmedia::MediaFloater* >( ( \
+SfxViewFrame::Current() && SfxViewFrame::Current()->GetChildWindow(::avmedia::MediaPlayer::GetChildWindowId())) ? \
+SfxViewFrame::Current()->GetChildWindow(::avmedia::MediaPlayer::GetChildWindowId())->GetWindow() : \
+NULL))
+
+namespace avmedia
+{
+
+// ---------------
+// - MediaPlayer -
+// ---------------
+
+class MediaPlayer : public SfxChildWindow
+{
+public:
+ MediaPlayer( Window*, sal_uInt16, SfxBindings*, SfxChildWinInfo* );
+ ~MediaPlayer();
+
+ SFX_DECL_CHILDWINDOW( MediaPlayer );
+};
+
+// ----------------
+// - MediaFloater -
+// ----------------
+
+class MediaWindow;
+
+class MediaFloater : public SfxDockingWindow
+{
+public:
+
+ MediaFloater( SfxBindings* pBindings, SfxChildWindow* pCW, Window* pParent );
+ ~MediaFloater();
+
+ void setURL( const ::rtl::OUString& rURL, bool bPlayImmediately );
+ const ::rtl::OUString& getURL() const;
+
+ void dispatchCurrentURL();
+
+protected:
+
+ virtual void Resize();
+ virtual void ToggleFloatingMode();
+
+private:
+
+ MediaWindow* mpMediaWindow;
+ Size maLastSize;
+ long mnDummy1;
+ long mnDummy2;
+
+ void implInit();
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/inc/avmedia/mediatoolbox.hxx b/avmedia/inc/avmedia/mediatoolbox.hxx
new file mode 100644
index 000000000000..3b5023a4c908
--- /dev/null
+++ b/avmedia/inc/avmedia/mediatoolbox.hxx
@@ -0,0 +1,68 @@
+/* -*- 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 _AVMEDIA_MEDIATOOLBOX_HXX
+#define _AVMEDIA_MEDIATOOLBOX_HXX
+
+#include <svl/lstner.hxx>
+#include <sfx2/tbxctrl.hxx>
+
+namespace avmedia
+{
+
+// -------------------------------
+// - SvxGrafFilterToolBoxControl -
+// -------------------------------
+
+class MediaItem;
+
+class MediaToolBoxControl : public SfxToolBoxControl
+{
+ friend class MediaToolBoxControl_Impl;
+
+public:
+
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ MediaToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbX );
+ ~MediaToolBoxControl();
+
+ virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
+ virtual Window* CreateItemWindow( Window* pParent );
+
+private:
+
+ void implUpdateMediaControl();
+ void implExecuteMediaControl( const MediaItem& rItem );
+};
+
+}
+
+#endif // _AVMEDIA_MEDIATOOLBOX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/inc/avmedia/mediawindow.hxx b/avmedia/inc/avmedia/mediawindow.hxx
new file mode 100644
index 000000000000..5b56f1fd3aa2
--- /dev/null
+++ b/avmedia/inc/avmedia/mediawindow.hxx
@@ -0,0 +1,172 @@
+/* -*- 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 _AVMEDIA_MEDIAWINDOW_HXX
+#define _AVMEDIA_MEDIAWINDOW_HXX
+
+#include <memory>
+#include <vector>
+#include <tools/gen.hxx>
+#include <com/sun/star/media/ZoomLevel.hpp>
+#include <com/sun/star/media/XPlayer.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+
+// -----------
+// - Defines -
+// -----------
+
+#define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME -1.0
+
+// ------------------------
+// - Forward Declarations -
+// ------------------------
+
+class Window;
+class KeyEvent;
+class MouseEvent;
+class CommandEvent;
+class PopupMenu;
+class Pointer;
+struct AcceptDropEvent;
+struct ExecuteDropEvent;
+
+namespace rtl { class OUString; }
+
+/* Declaration of MediaWindow class */
+
+namespace avmedia
+{
+ typedef ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > FilterNameVector;
+
+ class MediaItem;
+
+ namespace priv { class MediaWindowImpl; }
+
+ // ---------------
+ // - MediaWindow -
+ // ---------------
+
+ class MediaWindow
+ {
+ public:
+ MediaWindow( Window* parent, bool bInternalMediaControl );
+ virtual ~MediaWindow();
+
+ void setURL( const ::rtl::OUString& rURL );
+ const ::rtl::OUString& getURL() const;
+
+ bool isValid() const;
+ bool hasPreferredSize() const;
+ Size getPreferredSize() const;
+
+ Window* getWindow() const;
+
+ void setPosSize( const Rectangle& rNewRect );
+ Rectangle getPosSize() const;
+
+ void setPointer( const Pointer& rPointer );
+ const Pointer& getPointer() const;
+
+ bool setZoom( ::com::sun::star::media::ZoomLevel eLevel );
+ ::com::sun::star::media::ZoomLevel getZoom() const;
+
+ bool start();
+ void stop();
+
+ bool isPlaying() const;
+
+ double getDuration() const;
+
+ void setMediaTime( double fTime );
+ double getMediaTime() const;
+
+ void setStopTime( double fTime );
+ double getStopTime() const;
+
+ void setRate( double fRate );
+ double getRate() const;
+
+ void setPlaybackLoop( bool bSet );
+ bool isPlaybackLoop() const;
+
+ void setMute( bool bSet );
+ bool isMute() const;
+
+ void updateMediaItem( MediaItem& rItem ) const;
+ void executeMediaItem( const MediaItem& rItem );
+
+ void show();
+ void hide();
+
+ void enable();
+ void disable();
+
+ public:
+
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void KeyUp( const KeyEvent& rKEvt );
+
+ virtual void Command( const CommandEvent& rCEvt );
+
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+ public:
+
+ static void getMediaFilters( FilterNameVector& rFilterNameVector );
+ static bool executeMediaURLDialog( Window* pParent, ::rtl::OUString& rURL, bool bInsertDialog = true );
+ static void executeFormatErrorBox( Window* pParent );
+ static bool isMediaURL( const ::rtl::OUString& rURL, bool bDeep = false, Size* pPreferredSizePixel = NULL );
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const ::rtl::OUString& rURL );
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > grabFrame( const ::rtl::OUString& rURL,
+ bool bAllowToCreateReplacementGraphic = false,
+ double fMediaTime = AVMEDIA_FRAMEGRABBER_DEFAULTFRAME );
+
+ private:
+
+ // default: disabled copy/assignment
+ MediaWindow(const MediaWindow&);
+ MediaWindow& operator =( const MediaWindow& );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxIFace;
+ priv::MediaWindowImpl* mpImpl;
+ };
+}
+
+#endif // _AVMEDIA_MEDIAWINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/inc/helpids.hrc b/avmedia/inc/helpids.hrc
new file mode 100755
index 000000000000..4b1d2e04d628
--- /dev/null
+++ b/avmedia/inc/helpids.hrc
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * 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 _AVMEDIA_HELPIDS_HRC
+#define _AVMEDIA_HELPIDS_HRC
+
+#define HID_AVMEDIA_TOOLBOXITEM_PLAY "AVMEDIA_HID_AVMEDIA_TOOLBOXITEM_PLAY"
+#define HID_AVMEDIA_TOOLBOXITEM_PAUSE "AVMEDIA_HID_AVMEDIA_TOOLBOXITEM_PAUSE"
+#define HID_AVMEDIA_TOOLBOXITEM_STOP "AVMEDIA_HID_AVMEDIA_TOOLBOXITEM_STOP"
+#define HID_AVMEDIA_TOOLBOXITEM_MUTE "AVMEDIA_HID_AVMEDIA_TOOLBOXITEM_MUTE"
+#define HID_AVMEDIA_TOOLBOXITEM_LOOP "AVMEDIA_HID_AVMEDIA_TOOLBOXITEM_LOOP"
+#define HID_AVMEDIA_TOOLBOXITEM_OPEN "AVMEDIA_HID_AVMEDIA_TOOLBOXITEM_OPEN"
+#define HID_AVMEDIA_TOOLBOXITEM_INSERT "AVMEDIA_HID_AVMEDIA_TOOLBOXITEM_INSERT"
+#define HID_AVMEDIA_ZOOMLISTBOX "AVMEDIA_HID_AVMEDIA_ZOOMLISTBOX"
+#define HID_AVMEDIA_TIMESLIDER "AVMEDIA_HID_AVMEDIA_TIMESLIDER"
+#define HID_AVMEDIA_TIMEEDIT "AVMEDIA_HID_AVMEDIA_TIMEEDIT"
+#define HID_AVMEDIA_VOLUMESLIDER "AVMEDIA_HID_AVMEDIA_VOLUMESLIDER"
+#define HID_AVMEDIA_PLAYERWINDOW "AVMEDIA_HID_AVMEDIA_PLAYERWINDOW"
+
+#endif // _AVMEDIA_HELPIDS_HRC
diff --git a/avmedia/inc/mediacontrol.hxx b/avmedia/inc/mediacontrol.hxx
new file mode 100644
index 000000000000..022a32eb9586
--- /dev/null
+++ b/avmedia/inc/mediacontrol.hxx
@@ -0,0 +1,117 @@
+/* -*- 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 _AVMEDIA_MEDIACONTROL_HXX
+#define _AVMEDIA_MEDIACONTROL_HXX
+
+#include <avmedia/mediaitem.hxx>
+
+#include <vcl/timer.hxx>
+#include <vcl/slider.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/image.hxx>
+
+#define AVMEDIA_CONTROLOFFSET 6
+
+class ListBox;
+
+namespace avmedia
+{
+
+// ---------------------
+// - MediaControlStyle -
+// ---------------------
+
+enum MediaControlStyle
+{
+ MEDIACONTROLSTYLE_SINGLELINE = 0,
+ MEDIACONTROLSTYLE_MULTILINE = 1
+};
+
+// ----------------
+// - MediaControl -
+// ---------------
+
+class MediaItem;
+
+class MediaControl : public Control
+{
+public:
+
+ MediaControl( Window* pParent, MediaControlStyle eControlStyle );
+ virtual ~MediaControl();
+
+ const Size& getMinSizePixel() const;
+
+ void setState( const MediaItem& rItem );
+ void getState( MediaItem& rItem ) const;
+
+protected:
+
+ virtual void update() = 0;
+ virtual void execute( const MediaItem& rItem ) = 0;
+
+ virtual void Resize();
+
+private:
+
+ void implUpdateToolboxes();
+ void implUpdateTimeSlider();
+ void implUpdateVolumeSlider();
+ void implUpdateTimeField( double fCurTime );
+ Image implGetImage( sal_Int32 nImageId ) const;
+
+ DECL_LINK( implTimeHdl, Slider* );
+ DECL_LINK( implTimeEndHdl, Slider* );
+ DECL_LINK( implVolumeHdl, Slider* );
+ DECL_LINK( implVolumeEndHdl, Slider* );
+ DECL_LINK( implSelectHdl, ToolBox* );
+ DECL_LINK( implZoomSelectHdl, ListBox* );
+ DECL_LINK( implTimeoutHdl, Timer* );
+
+ ImageList maImageList;
+ Timer maTimer;
+ MediaItem maItem;
+ ToolBox maPlayToolBox;
+ Slider maTimeSlider;
+ ToolBox maMuteToolBox;
+ Slider maVolumeSlider;
+ ToolBox maZoomToolBox;
+ ListBox* mpZoomListBox;
+ Edit maTimeEdit;
+ Size maMinSize;
+ MediaControlStyle meControlStyle;
+ bool mbLocked;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/prj/build.lst b/avmedia/prj/build.lst
new file mode 100644
index 000000000000..78397f235b93
--- /dev/null
+++ b/avmedia/prj/build.lst
@@ -0,0 +1,11 @@
+av avmedia : TRANSLATIONS:translations tools sfx2 LIBXSLT:libxslt NULL
+av avmedia usr1 - all av_mkout NULL
+av avmedia\prj get - all av_prj NULL
+av avmedia\inc get - all av_inv NULL
+av avmedia\source\viewer nmake - all av_viewer NULL
+av avmedia\source\framework nmake - all av_framework NULL
+av avmedia\source\win nmake - all av_win NULL
+av avmedia\source\java nmake - all av_java NULL
+av avmedia\source\quicktime nmake - all av_quicktime NULL
+av avmedia\source\gstreamer nmake - all av_gstreamer NULL
+av avmedia\util nmake - all av_util av_viewer av_framework av_win av_java av_quicktime av_gstreamer NULL
diff --git a/avmedia/prj/d.lst b/avmedia/prj/d.lst
new file mode 100644
index 000000000000..23f7c35723cf
--- /dev/null
+++ b/avmedia/prj/d.lst
@@ -0,0 +1,23 @@
+mkdir: %COMMON_DEST%\bin%_EXT%\hid
+mkdir: %COMMON_DEST%\res%_EXT%
+
+..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid
+..\%__SRC%\bin\avmedia*.dll %_DEST%\bin%_EXT%\avmedia*.dll
+..\source\java\avmedia.jar %_DEST%\bin%_EXT%\avmedia.jar
+..\%__SRC%\lib\lib*.* %_DEST%\lib%_EXT%\lib*.*
+..\%__SRC%\lib\*.lib %_DEST%\lib%_EXT%\*.lib
+..\%__SRC%\bin\avmedia*.res %_DEST%\bin%_EXT%\avmedia*.res
+
+mkdir: %_DEST%\inc%_EXT%\avmedia
+
+..\inc\avmedia\mediawindow.hxx %_DEST%\inc%_EXT%\avmedia\mediawindow.hxx
+..\inc\avmedia\mediaitem.hxx %_DEST%\inc%_EXT%\avmedia\mediaitem.hxx
+..\inc\avmedia\mediaplayer.hxx %_DEST%\inc%_EXT%\avmedia\mediaplayer.hxx
+..\inc\avmedia\mediatoolbox.hxx %_DEST%\inc%_EXT%\avmedia\mediatoolbox.hxx
+
+..\%__SRC%\class\avmedia.jar %_DEST%\bin%_EXT%\avmedia.jar
+..\%__SRC%\misc\avmedia.component %_DEST%\xml%_EXT%\avmedia.component
+..\%__SRC%\misc\avmedia.jar.component %_DEST%\xml%_EXT%\avmedia.jar.component
+..\%__SRC%\misc\avmediaQuickTime.component %_DEST%\xml%_EXT%\avmediaQuickTime.component
+..\%__SRC%\misc\avmediagstreamer.component %_DEST%\xml%_EXT%\avmediagstreamer.component
+..\%__SRC%\misc\avmediawin.component %_DEST%\xml%_EXT%\avmediawin.component
diff --git a/avmedia/source/framework/makefile.mk b/avmedia/source/framework/makefile.mk
new file mode 100755
index 000000000000..4c814c534844
--- /dev/null
+++ b/avmedia/source/framework/makefile.mk
@@ -0,0 +1,57 @@
+#*************************************************************************
+#
+# 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=framework
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Resources ---------------------------------
+
+SRS1NAME=$(TARGET)
+SRC1FILES =\
+ mediacontrol.src
+
+# --- Files -------------------------------------
+
+SLOFILES= \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/mediaitem.obj \
+
+EXCEPTIONSFILES = \
+ $(SLO)$/mediacontrol.obj \
+ $(SLO)$/mediamisc.obj \
+ $(SLO)$/mediaplayer.obj \
+ $(SLO)$/mediatoolbox.obj \
+ $(SLO)$/soundhandler.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx
new file mode 100644
index 000000000000..e69d4d3b93a0
--- /dev/null
+++ b/avmedia/source/framework/mediacontrol.cxx
@@ -0,0 +1,634 @@
+/* -*- 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 "mediacontrol.hxx"
+#include "mediacontrol.hrc"
+#include "mediamisc.hxx"
+#include <avmedia/mediawindow.hxx>
+#include <avmedia/mediaplayer.hxx>
+#include "helpids.hrc"
+#include <tools/time.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/lstbox.hxx>
+#include <unotools/syslocale.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <math.h>
+#include <algorithm>
+
+#define AVMEDIA_TIMEOUT 100
+#define AVMEDIA_TIME_RANGE 2048
+#define AVMEDIA_DB_RANGE -40
+#define AVMEDIA_LINEINCREMENT 1.0
+#define AVMEDIA_PAGEINCREMENT 10.0
+
+#define AVMEDIA_TOOLBOXITEM_PLAY 0x0001
+#define AVMEDIA_TOOLBOXITEM_PLAYFFW 0x0002
+#define AVMEDIA_TOOLBOXITEM_PAUSE 0x0004
+#define AVMEDIA_TOOLBOXITEM_STOP 0x0008
+#define AVMEDIA_TOOLBOXITEM_MUTE 0x0010
+#define AVMEDIA_TOOLBOXITEM_LOOP 0x0011
+#define AVMEDIA_TOOLBOXITEM_ZOOM 0x0012
+#define AVMEDIA_TOOLBOXITEM_OPEN 0x0014
+#define AVMEDIA_TOOLBOXITEM_INSERT 0x0018
+
+#define AVMEDIA_ZOOMLEVEL_50 0
+#define AVMEDIA_ZOOMLEVEL_100 1
+#define AVMEDIA_ZOOMLEVEL_200 2
+#define AVMEDIA_ZOOMLEVEL_FIT 3
+#define AVMEDIA_ZOOMLEVEL_SCALED 4
+#define AVMEDIA_ZOOMLEVEL_INVALID 65535
+
+namespace avmedia
+{
+
+// ----------------
+// - MediaControl -
+// ---------------
+
+MediaControl::MediaControl( Window* pParent, MediaControlStyle eControlStyle ) :
+ Control( pParent ),
+ maImageList( AVMEDIA_RESID( AVMEDIA_IMGLST ) ),
+ maItem( 0, AVMEDIA_SETMASK_ALL ),
+ maPlayToolBox( this, WB_3DLOOK ),
+ maTimeSlider( this, WB_HORZ | WB_DRAG | WB_3DLOOK | WB_SLIDERSET ),
+ maMuteToolBox( this, WB_3DLOOK ),
+ maVolumeSlider( this, WB_HORZ | WB_DRAG | WB_SLIDERSET ),
+ maZoomToolBox( this, WB_3DLOOK ),
+ mpZoomListBox( new ListBox( &maZoomToolBox, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_3DLOOK ) ),
+ maTimeEdit( this, WB_CENTER | WB_READONLY | WB_BORDER | WB_3DLOOK | WB_READONLY ),
+ meControlStyle( eControlStyle ),
+ mbLocked( false )
+{
+ const String aTimeText( RTL_CONSTASCII_USTRINGPARAM( " 00:00:00/00:00:00 " ) );
+
+ SetBackground();
+ SetPaintTransparent( sal_True );
+ SetParentClipMode( PARENTCLIPMODE_NOCLIP );
+
+ if( MEDIACONTROLSTYLE_SINGLELINE != meControlStyle )
+ {
+ maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_OPEN, implGetImage( AVMEDIA_IMG_OPEN ), String( AVMEDIA_RESID( AVMEDIA_STR_OPEN ) ) );
+ maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_OPEN, HID_AVMEDIA_TOOLBOXITEM_OPEN );
+
+ maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_INSERT, implGetImage( AVMEDIA_IMG_INSERT ), String( AVMEDIA_RESID( AVMEDIA_STR_INSERT ) ) );
+ maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_INSERT, HID_AVMEDIA_TOOLBOXITEM_INSERT );
+
+ maPlayToolBox.InsertSeparator();
+ }
+ else
+ {
+ mpZoomListBox->SetBackground();
+
+ maZoomToolBox.SetBackground();
+ maZoomToolBox.SetPaintTransparent( sal_True );
+ maPlayToolBox.SetBackground();
+ maPlayToolBox.SetPaintTransparent( sal_True );
+ maMuteToolBox.SetBackground();
+ maMuteToolBox.SetPaintTransparent( sal_True );
+
+ }
+
+ maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_PLAY, implGetImage( AVMEDIA_IMG_PLAY ), String( AVMEDIA_RESID( AVMEDIA_STR_PLAY ) ), TIB_CHECKABLE );
+ maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_PLAY, HID_AVMEDIA_TOOLBOXITEM_PLAY );
+
+ maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_PAUSE, implGetImage( AVMEDIA_IMG_PAUSE ), String( AVMEDIA_RESID( AVMEDIA_STR_PAUSE ) ), TIB_CHECKABLE );
+ maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_PAUSE, HID_AVMEDIA_TOOLBOXITEM_PAUSE );
+
+ maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_STOP, implGetImage( AVMEDIA_IMG_STOP ), String( AVMEDIA_RESID( AVMEDIA_STR_STOP ) ), TIB_CHECKABLE );
+ maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_STOP, HID_AVMEDIA_TOOLBOXITEM_STOP );
+
+ maPlayToolBox.InsertSeparator();
+
+ maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_LOOP, implGetImage( AVMEDIA_IMG_ENDLESS ), String( AVMEDIA_RESID( AVMEDIA_STR_ENDLESS ) ) );
+ maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_LOOP, HID_AVMEDIA_TOOLBOXITEM_LOOP );
+
+ if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle )
+ maPlayToolBox.InsertSeparator();
+
+ maPlayToolBox.SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) );
+ maPlayToolBox.SetSizePixel( maPlayToolBox.CalcWindowSizePixel() );
+ maPlayToolBox.Show();
+ maMinSize = maPlayToolBox.GetSizePixel();
+
+ maTimeSlider.SetSlideHdl( LINK( this, MediaControl, implTimeHdl ) );
+ maTimeSlider.SetEndSlideHdl( LINK( this, MediaControl, implTimeEndHdl ) );
+ maTimeSlider.SetRange( Range( 0, AVMEDIA_TIME_RANGE ) );
+ maTimeSlider.SetHelpId( HID_AVMEDIA_TIMESLIDER );
+ maTimeSlider.SetUpdateMode( true );
+ maTimeSlider.SetSizePixel( Size( 128, maPlayToolBox.GetSizePixel().Height() ) );
+ maTimeSlider.Show();
+ maMinSize.Width() += maTimeSlider.GetSizePixel().Width();
+
+ maTimeEdit.SetText( aTimeText );
+ maTimeEdit.SetUpdateMode( true );
+ maTimeEdit.SetSizePixel( Size( maTimeEdit.GetTextWidth( aTimeText ) + 8, maPlayToolBox.GetSizePixel().Height() ) );
+ maTimeEdit.SetControlBackground( Application::GetSettings().GetStyleSettings().GetWindowColor() );
+ maTimeEdit.SetHelpId( HID_AVMEDIA_TIMEEDIT );
+ maTimeEdit.Disable();
+ maTimeEdit.Show();
+ maMinSize.Width() += maTimeEdit.GetSizePixel().Width();
+
+ if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle )
+ maMuteToolBox.InsertSeparator();
+
+ maMuteToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_MUTE, implGetImage( AVMEDIA_IMG_MUTE ), String( AVMEDIA_RESID( AVMEDIA_STR_MUTE ) ) );
+ maMuteToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_MUTE, HID_AVMEDIA_TOOLBOXITEM_MUTE );
+
+ maMuteToolBox.SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) );
+ maMuteToolBox.SetSizePixel( maMuteToolBox.CalcWindowSizePixel() );
+ maMuteToolBox.Show();
+ maMinSize.Width() += maMuteToolBox.GetSizePixel().Width();
+
+ maVolumeSlider.SetSlideHdl( LINK( this, MediaControl, implVolumeHdl ) );
+ maVolumeSlider.SetEndSlideHdl( LINK( this, MediaControl, implVolumeEndHdl ) );
+ maVolumeSlider.SetRange( Range( AVMEDIA_DB_RANGE, 0 ) );
+ maVolumeSlider.SetUpdateMode( true );
+ maVolumeSlider.SetHelpId( HID_AVMEDIA_VOLUMESLIDER );
+ maVolumeSlider.SetSizePixel( Size( 48, maPlayToolBox.GetSizePixel().Height() ) );
+ maVolumeSlider.Show();
+ maMinSize.Width() += maVolumeSlider.GetSizePixel().Width();
+
+ mpZoomListBox->SetSizePixel( Size( maTimeEdit.GetSizePixel().Width(), 260 ) );
+ mpZoomListBox->InsertEntry( String( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_50 ) ), AVMEDIA_ZOOMLEVEL_50 );
+ mpZoomListBox->InsertEntry( String( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_100 ) ), AVMEDIA_ZOOMLEVEL_100 );
+ mpZoomListBox->InsertEntry( String( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_200 ) ), AVMEDIA_ZOOMLEVEL_200 );
+ mpZoomListBox->InsertEntry( String( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_FIT ) ), AVMEDIA_ZOOMLEVEL_FIT );
+ mpZoomListBox->SetSelectHdl( LINK( this, MediaControl, implZoomSelectHdl ) );
+ mpZoomListBox->SetHelpId( HID_AVMEDIA_ZOOMLISTBOX );
+
+ maZoomToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_ZOOM, String( AVMEDIA_RESID( AVMEDIA_STR_ZOOM ) ) );
+ maZoomToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_ZOOM, HID_AVMEDIA_ZOOMLISTBOX );
+
+ maZoomToolBox.SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, mpZoomListBox );
+ maZoomToolBox.SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) );
+ maZoomToolBox.SetSizePixel( maZoomToolBox.CalcWindowSizePixel() );
+ maZoomToolBox.Show();
+ maMinSize.Width() += maZoomToolBox.GetSizePixel().Width();
+
+ if( MEDIACONTROLSTYLE_MULTILINE == meControlStyle )
+ {
+ maMinSize.Width() = 256;
+ maMinSize.Height() = ( maMinSize.Height() << 1 ) + AVMEDIA_CONTROLOFFSET;
+ }
+
+ maTimer.SetTimeout( AVMEDIA_TIMEOUT );
+ maTimer.SetTimeoutHdl( LINK( this, MediaControl, implTimeoutHdl ) );
+ maTimer.Start();
+}
+
+// ------------------------------------------------------------------------------
+
+MediaControl::~MediaControl()
+{
+ maZoomToolBox.SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, NULL );
+ delete mpZoomListBox;
+}
+
+// ------------------------------------------------------------------------------
+
+const Size& MediaControl::getMinSizePixel() const
+{
+ return maMinSize;
+}
+
+// ------------------------------------------------------------------------------
+
+void MediaControl::Resize()
+{
+ Point aPos( 0, 0 );
+ const sal_Int32 nPlayToolBoxWidth = maPlayToolBox.GetSizePixel().Width();
+ const sal_Int32 nMuteToolBoxWidth = maMuteToolBox.GetSizePixel().Width();
+ const sal_Int32 nVolumeSliderWidth = maVolumeSlider.GetSizePixel().Width();
+ const sal_Int32 nZoomToolBoxWidth = maZoomToolBox.GetSizePixel().Width();
+ const sal_Int32 nTimeEditWidth = maTimeEdit.GetSizePixel().Width();
+ const sal_Int32 nTimeSliderHeight = maTimeSlider.GetSizePixel().Height();
+
+ if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle )
+ {
+ const sal_Int32 nTimeSliderWidth = GetSizePixel().Width() - ( AVMEDIA_CONTROLOFFSET * 3 ) -
+ nPlayToolBoxWidth - nMuteToolBoxWidth - nVolumeSliderWidth - nTimeEditWidth - nZoomToolBoxWidth;
+
+ maPlayToolBox.SetPosSizePixel( aPos, maPlayToolBox.GetSizePixel() );
+
+ aPos.X() += nPlayToolBoxWidth;
+ maTimeSlider.SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) );
+
+ aPos.X() += nTimeSliderWidth + AVMEDIA_CONTROLOFFSET;
+ maTimeEdit.SetPosSizePixel( aPos, maTimeEdit.GetSizePixel() );
+
+ aPos.X() += nTimeEditWidth + AVMEDIA_CONTROLOFFSET;
+ maMuteToolBox.SetPosSizePixel( aPos, maMuteToolBox.GetSizePixel() );
+
+ aPos.X() += nMuteToolBoxWidth;
+ maVolumeSlider.SetPosSizePixel( aPos, maVolumeSlider.GetSizePixel() );
+
+ aPos.X() += nVolumeSliderWidth + AVMEDIA_CONTROLOFFSET;
+ maZoomToolBox.SetPosSizePixel( aPos, maZoomToolBox.GetSizePixel() );
+ }
+ else
+ {
+ const sal_Int32 nTimeSliderWidth = GetSizePixel().Width() - AVMEDIA_CONTROLOFFSET - nTimeEditWidth;
+
+ maTimeSlider.SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) );
+
+ aPos.X() += nTimeSliderWidth + AVMEDIA_CONTROLOFFSET;
+ maTimeEdit.SetPosSizePixel( aPos, maTimeEdit.GetSizePixel() );
+
+ aPos.X() = 0;
+ aPos.Y() += nTimeSliderHeight + AVMEDIA_CONTROLOFFSET;
+ maPlayToolBox.SetPosSizePixel( aPos, maPlayToolBox.GetSizePixel() );
+
+ aPos.X() = GetSizePixel().Width() - nVolumeSliderWidth - nMuteToolBoxWidth - nZoomToolBoxWidth - AVMEDIA_CONTROLOFFSET;
+ maMuteToolBox.SetPosSizePixel( aPos, maMuteToolBox.GetSizePixel() );
+
+ aPos.X() += nMuteToolBoxWidth;
+ maVolumeSlider.SetPosSizePixel( aPos, maVolumeSlider.GetSizePixel() );
+
+ aPos.X() = GetSizePixel().Width() - nZoomToolBoxWidth;
+ maZoomToolBox.SetPosSizePixel( aPos, maZoomToolBox.GetSizePixel() );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void MediaControl::setState( const MediaItem& rItem )
+{
+ if( !mbLocked )
+ {
+ maItem.merge( rItem );
+
+ implUpdateToolboxes();
+ implUpdateTimeSlider();
+ implUpdateVolumeSlider();
+ implUpdateTimeField( maItem.getTime() );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void MediaControl::getState( MediaItem& rItem ) const
+{
+ rItem.merge( maItem );
+}
+
+// ------------------------------------------------------------------------------
+
+void MediaControl::update()
+{
+}
+
+// ------------------------------------------------------------------------------
+
+void MediaControl::execute( const MediaItem& )
+{
+}
+
+// ------------------------------------------------------------------------------
+
+void MediaControl::implUpdateToolboxes()
+{
+ const bool bValidURL = ( maItem.getURL().getLength() > 0 );
+
+ maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_INSERT, bValidURL );
+ maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_PLAY, bValidURL );
+ maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_PLAYFFW, bValidURL );
+ maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_PAUSE, bValidURL );
+ maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_STOP, bValidURL );
+ maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_LOOP, bValidURL );
+ maMuteToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_MUTE, bValidURL );
+
+ if( !bValidURL || !IsEnabled() )
+ {
+ mpZoomListBox->Disable();
+
+ if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle )
+ maPlayToolBox.Disable();
+
+ maMuteToolBox.Disable();
+ }
+ else
+ {
+ maPlayToolBox.Enable();
+ maMuteToolBox.Enable();
+
+ if( MEDIASTATE_PLAY == maItem.getState() || MEDIASTATE_PLAYFFW == maItem.getState() )
+ {
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, true );
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAYFFW, MEDIASTATE_PLAYFFW == maItem.getState() );
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false );
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false );
+ }
+ else if( maItem.getTime() > 0.0 && ( maItem.getTime() < maItem.getDuration() ) )
+ {
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false );
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAYFFW, false );
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, true );
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false );
+ }
+ else
+ {
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false );
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAYFFW, false );
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false );
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_STOP, true );
+ }
+
+ maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_LOOP, maItem.isLoop() );
+ maMuteToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_MUTE, maItem.isMute() );
+
+ if( !mpZoomListBox->IsTravelSelect() && !mpZoomListBox->IsInDropDown() )
+ {
+ sal_uInt16 nSelectEntryPos ;
+
+ switch( maItem.getZoom() )
+ {
+ case( ::com::sun::star::media::ZoomLevel_ZOOM_1_TO_2 ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_50; break;
+ case( ::com::sun::star::media::ZoomLevel_ORIGINAL ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_100; break;
+ case( ::com::sun::star::media::ZoomLevel_ZOOM_2_TO_1 ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_200; break;
+ case( ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_FIT; break;
+ case( ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_SCALED; break;
+
+ default: nSelectEntryPos = AVMEDIA_ZOOMLEVEL_INVALID; break;
+ }
+
+ if( nSelectEntryPos != AVMEDIA_ZOOMLEVEL_INVALID )
+ {
+ mpZoomListBox->Enable();
+ mpZoomListBox->SelectEntryPos( nSelectEntryPos );
+ }
+ else
+ mpZoomListBox->Disable();
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void MediaControl::implUpdateTimeSlider()
+{
+ if( !maItem.getURL().getLength() || !IsEnabled() )
+ maTimeSlider.Disable();
+ else
+ {
+ maTimeSlider.Enable();
+
+ const double fDuration = maItem.getDuration();
+
+ if( fDuration > 0.0 )
+ {
+ const double fTime = ::std::min( maItem.getTime(), fDuration );
+
+ if( !maTimeSlider.GetLineSize() )
+ maTimeSlider.SetLineSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_LINEINCREMENT / fDuration ) );
+
+ if( !maTimeSlider.GetPageSize() )
+ maTimeSlider.SetPageSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_PAGEINCREMENT / fDuration ) );
+
+ maTimeSlider.SetThumbPos( static_cast< sal_Int32 >( fTime / fDuration * AVMEDIA_TIME_RANGE ) );
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void MediaControl::implUpdateVolumeSlider()
+{
+ if( !maItem.getURL().getLength() || !IsEnabled() )
+ maVolumeSlider.Disable();
+ else
+ {
+ maVolumeSlider.Enable();
+
+ const sal_Int32 nVolumeDB = maItem.getVolumeDB();
+
+ maVolumeSlider.SetThumbPos( ::std::min( ::std::max( nVolumeDB, static_cast< sal_Int32 >( AVMEDIA_DB_RANGE ) ),
+ static_cast< sal_Int32 >( 0 ) ) );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void MediaControl::implUpdateTimeField( double fCurTime )
+{
+ if( maItem.getURL().getLength() > 0 )
+ {
+ String aTimeString;
+
+ SvtSysLocale aSysLocale;
+ const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
+
+ aTimeString += rLocaleData.getDuration( Time( 0, 0, static_cast< sal_uInt32 >( floor( fCurTime ) ) ) );
+ aTimeString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " ));
+ aTimeString += rLocaleData.getDuration( Time( 0, 0, static_cast< sal_uInt32 >( floor( maItem.getDuration() ) )) );
+
+ if( maTimeEdit.GetText() != aTimeString )
+ maTimeEdit.SetText( aTimeString );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+Image MediaControl::implGetImage( sal_Int32 nImageId ) const
+{
+ return maImageList.GetImage( static_cast< sal_uInt16 >( nImageId ) );
+}
+
+// ------------------------------------------------------------------------------
+
+IMPL_LINK( MediaControl, implTimeHdl, Slider*, p )
+{
+ mbLocked = true;
+ maTimer.Stop();
+ implUpdateTimeField( p->GetThumbPos() * maItem.getDuration() / AVMEDIA_TIME_RANGE );
+
+ return 0;
+}
+
+// ------------------------------------------------------------------------------
+
+IMPL_LINK( MediaControl, implTimeEndHdl, Slider*, p )
+{
+ MediaItem aExecItem;
+
+ aExecItem.setTime( p->GetThumbPos() * maItem.getDuration() / AVMEDIA_TIME_RANGE );
+ execute( aExecItem );
+ update();
+ maTimer.Start();
+ mbLocked = false;
+
+ return 0;
+}
+
+// ------------------------------------------------------------------------------
+
+IMPL_LINK( MediaControl, implVolumeHdl, Slider*, p )
+{
+ MediaItem aExecItem;
+
+ aExecItem.setVolumeDB( static_cast< sal_Int16 >( p->GetThumbPos() ) );
+ execute( aExecItem );
+ update();
+
+ return 0;
+}
+
+// ------------------------------------------------------------------------------
+
+IMPL_LINK( MediaControl, implVolumeEndHdl, Slider*, EMPTYARG )
+{
+ return 0;
+}
+
+// ------------------------------------------------------------------------------
+
+IMPL_LINK( MediaControl, implSelectHdl, ToolBox*, p )
+{
+ if( p )
+ {
+ MediaItem aExecItem;
+
+ switch( p->GetCurItemId() )
+ {
+ case( AVMEDIA_TOOLBOXITEM_OPEN ):
+ {
+ ::rtl::OUString aURL;
+
+ if( ::avmedia::MediaWindow::executeMediaURLDialog( GetParent(), aURL, false ) )
+ {
+ if( !::avmedia::MediaWindow::isMediaURL( aURL, true ) )
+ ::avmedia::MediaWindow::executeFormatErrorBox( this );
+ else
+ {
+ aExecItem.setURL( aURL );
+ aExecItem.setState( MEDIASTATE_PLAY );
+ }
+ }
+ }
+ break;
+
+ case( AVMEDIA_TOOLBOXITEM_INSERT ):
+ {
+ MediaFloater* pFloater = AVMEDIA_MEDIAWINDOW();
+
+ if( pFloater )
+ pFloater->dispatchCurrentURL();
+ }
+ break;
+
+ case( AVMEDIA_TOOLBOXITEM_PLAY ):
+ case( AVMEDIA_TOOLBOXITEM_PLAYFFW ):
+ {
+ aExecItem.setState( ( AVMEDIA_TOOLBOXITEM_PLAYFFW == p->GetCurItemId() ) ? MEDIASTATE_PLAYFFW : MEDIASTATE_PLAY );
+
+ if( maItem.getTime() == maItem.getDuration() )
+ aExecItem.setTime( 0.0 );
+ else
+ aExecItem.setTime( maItem.getTime() );
+ }
+ break;
+
+ case( AVMEDIA_TOOLBOXITEM_PAUSE ):
+ {
+ aExecItem.setState( MEDIASTATE_PAUSE );
+ }
+ break;
+
+ case( AVMEDIA_TOOLBOXITEM_STOP ):
+ {
+ aExecItem.setState( MEDIASTATE_STOP );
+ aExecItem.setTime( 0.0 );
+ }
+ break;
+
+ case( AVMEDIA_TOOLBOXITEM_MUTE ):
+ {
+ aExecItem.setMute( !maMuteToolBox.IsItemChecked( AVMEDIA_TOOLBOXITEM_MUTE ) );
+ }
+ break;
+
+ case( AVMEDIA_TOOLBOXITEM_LOOP ):
+ {
+ aExecItem.setLoop( !maPlayToolBox.IsItemChecked( AVMEDIA_TOOLBOXITEM_LOOP ) );
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if( aExecItem.getMaskSet() != AVMEDIA_SETMASK_NONE )
+ execute( aExecItem );
+ }
+
+ update();
+ p->Invalidate( INVALIDATE_UPDATE );
+
+ return 0;
+}
+
+// ------------------------------------------------------------------------------
+
+IMPL_LINK( MediaControl, implZoomSelectHdl, ListBox*, p )
+{
+ if( p )
+ {
+ MediaItem aExecItem;
+ ::com::sun::star::media::ZoomLevel eLevel;
+
+ switch( p->GetSelectEntryPos() )
+ {
+ case( AVMEDIA_ZOOMLEVEL_50 ): eLevel = ::com::sun::star::media::ZoomLevel_ZOOM_1_TO_2; break;
+ case( AVMEDIA_ZOOMLEVEL_100 ): eLevel = ::com::sun::star::media::ZoomLevel_ORIGINAL; break;
+ case( AVMEDIA_ZOOMLEVEL_200 ): eLevel = ::com::sun::star::media::ZoomLevel_ZOOM_2_TO_1; break;
+ case( AVMEDIA_ZOOMLEVEL_FIT ): eLevel = ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT; break;
+ case( AVMEDIA_ZOOMLEVEL_SCALED ): eLevel = ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW; break;
+
+ default: eLevel = ::com::sun::star::media::ZoomLevel_NOT_AVAILABLE; break;
+ }
+
+ aExecItem.setZoom( eLevel );
+ execute( aExecItem );
+ update();
+ }
+
+ return 0;
+}
+
+// ------------------------------------------------------------------------------
+
+IMPL_LINK( MediaControl, implTimeoutHdl, Timer*, EMPTYARG )
+{
+ update();
+ maTimer.Start();
+
+ return 0;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/framework/mediacontrol.hrc b/avmedia/source/framework/mediacontrol.hrc
new file mode 100755
index 000000000000..f69ab937f5f5
--- /dev/null
+++ b/avmedia/source/framework/mediacontrol.hrc
@@ -0,0 +1,51 @@
+ /*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#define AVMEDIA_STR_PLAY 1024
+#define AVMEDIA_STR_PAUSE 1025
+#define AVMEDIA_STR_STOP 1026
+#define AVMEDIA_STR_ENDLESS 1027
+#define AVMEDIA_STR_ZOOM 1028
+#define AVMEDIA_STR_ZOOM_50 1029
+#define AVMEDIA_STR_ZOOM_100 1030
+#define AVMEDIA_STR_ZOOM_200 1031
+#define AVMEDIA_STR_ZOOM_FIT 1032
+#define AVMEDIA_STR_MUTE 1033
+#define AVMEDIA_STR_OPEN 1034
+#define AVMEDIA_STR_INSERT 1035
+#define AVMEDIA_STR_MEDIAPLAYER 1036
+
+#define AVMEDIA_IMG_OPEN 2048
+#define AVMEDIA_IMG_PLAY 2049
+#define AVMEDIA_IMG_PAUSE 2050
+#define AVMEDIA_IMG_STOP 2051
+#define AVMEDIA_IMG_ENDLESS 2052
+#define AVMEDIA_IMG_INSERT 2053
+#define AVMEDIA_IMG_MUTE 2054
+
+#define AVMEDIA_IMGLST 3072
+#define AVMEDIA_IMGLST_L 3074
diff --git a/avmedia/source/framework/mediacontrol.src b/avmedia/source/framework/mediacontrol.src
new file mode 100644
index 000000000000..22ddc29b3550
--- /dev/null
+++ b/avmedia/source/framework/mediacontrol.src
@@ -0,0 +1,127 @@
+ /*************************************************************************
+ *
+ * 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 "mediacontrol.hrc"
+
+String AVMEDIA_STR_OPEN
+{
+ Text[en-US] = "Open";
+};
+
+String AVMEDIA_STR_INSERT
+{
+ Text [ en-US ] = "Apply" ;
+};
+
+String AVMEDIA_STR_PLAY
+{
+ Text[en-US] = "Play";
+};
+
+String AVMEDIA_STR_PAUSE
+{
+ Text[en-US] = "Pause";
+};
+
+String AVMEDIA_STR_STOP
+{
+ Text[en-US] = "Stop";
+};
+
+String AVMEDIA_STR_ENDLESS
+{
+ Text[en-US] = "Repeat";
+};
+
+String AVMEDIA_STR_MUTE
+{
+ Text[en-US] = "Mute";
+};
+
+String AVMEDIA_STR_ZOOM
+{
+ Text[en-US] = "View";
+};
+
+String AVMEDIA_STR_ZOOM_50
+{
+ Text[en-US] = "50%";
+};
+
+String AVMEDIA_STR_ZOOM_100
+{
+ Text[en-US] = "100%";
+};
+
+String AVMEDIA_STR_ZOOM_200
+{
+ Text[en-US] = "200%";
+};
+
+String AVMEDIA_STR_ZOOM_FIT
+{
+ Text[en-US] = "Scaled";
+};
+
+String AVMEDIA_STR_MEDIAPLAYER
+{
+ Text[en-US] = "Media Player";
+};
+
+ImageList AVMEDIA_IMGLST
+{
+ Prefix = "av";
+ MaskColor = Color{ Red = 0xff00; Green = 0x0000; Blue = 0xff00; };
+ IdList =
+ {
+ AVMEDIA_IMG_OPEN;
+ AVMEDIA_IMG_PLAY;
+ AVMEDIA_IMG_PAUSE;
+ AVMEDIA_IMG_STOP;
+ AVMEDIA_IMG_ENDLESS;
+ AVMEDIA_IMG_INSERT;
+ AVMEDIA_IMG_MUTE;
+ };
+ IdCount = 7;
+};
+
+ImageList AVMEDIA_IMGLST_L
+{
+ Prefix = "avl";
+ MaskColor = Color{ Red = 0xff00; Green = 0x0000; Blue = 0xff00; };
+ IdList =
+ {
+ AVMEDIA_IMG_OPEN;
+ AVMEDIA_IMG_PLAY;
+ AVMEDIA_IMG_PAUSE;
+ AVMEDIA_IMG_STOP;
+ AVMEDIA_IMG_ENDLESS;
+ AVMEDIA_IMG_INSERT;
+ AVMEDIA_IMG_MUTE;
+ };
+ IdCount = 7;
+};
diff --git a/avmedia/source/framework/mediaitem.cxx b/avmedia/source/framework/mediaitem.cxx
new file mode 100644
index 000000000000..babaa39b427c
--- /dev/null
+++ b/avmedia/source/framework/mediaitem.cxx
@@ -0,0 +1,332 @@
+/* -*- 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 <avmedia/mediaitem.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+using namespace ::com::sun::star;
+
+namespace avmedia
+{
+
+// -------------
+// - MediaItem -
+// -------------
+
+TYPEINIT1_AUTOFACTORY( MediaItem, ::SfxPoolItem );
+ ::rtl::OUString maURL;
+ sal_uInt32 mnMaskSet;
+ MediaState meState;
+ double mfTime;
+ double mfDuration;
+ sal_Int16 mnVolumeDB;
+ sal_Bool mbLoop;
+ sal_Bool mbMute;
+ ::com::sun::star::media::ZoomLevel meZoom;
+
+// ------------------------------------------------------------------------------
+
+MediaItem::MediaItem( sal_uInt16 _nWhich, sal_uInt32 nMaskSet ) :
+ SfxPoolItem( _nWhich ),
+ mnMaskSet( nMaskSet ),
+ meState( MEDIASTATE_STOP ),
+ mfTime( 0.0 ),
+ mfDuration( 0.0 ),
+ mnVolumeDB( 0 ),
+ mbLoop( false ),
+ mbMute( false ),
+ meZoom( ::com::sun::star::media::ZoomLevel_NOT_AVAILABLE )
+{
+}
+
+// ------------------------------------------------------------------------------
+
+MediaItem::MediaItem( const MediaItem& rItem ) :
+ SfxPoolItem( rItem ),
+ maURL( rItem.maURL ),
+ mnMaskSet( rItem.mnMaskSet ),
+ meState( rItem.meState ),
+ mfTime( rItem.mfTime ),
+ mfDuration( rItem.mfDuration ),
+ mnVolumeDB( rItem.mnVolumeDB ),
+ mbLoop( rItem.mbLoop ),
+ mbMute( rItem.mbMute ),
+ meZoom( rItem.meZoom )
+{
+}
+
+// ------------------------------------------------------------------------------
+
+MediaItem::~MediaItem()
+{
+}
+
+// ------------------------------------------------------------------------------
+
+int MediaItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==(rItem), "unequal types" );
+ return( mnMaskSet == static_cast< const MediaItem& >( rItem ).mnMaskSet &&
+ maURL == static_cast< const MediaItem& >( rItem ).maURL &&
+ meState == static_cast< const MediaItem& >( rItem ).meState &&
+ mfDuration == static_cast< const MediaItem& >( rItem ).mfDuration &&
+ mfTime == static_cast< const MediaItem& >( rItem ).mfTime &&
+ mnVolumeDB == static_cast< const MediaItem& >( rItem ).mnVolumeDB &&
+ mbLoop == static_cast< const MediaItem& >( rItem ).mbLoop &&
+ mbMute == static_cast< const MediaItem& >( rItem ).mbMute &&
+ meZoom == static_cast< const MediaItem& >( rItem ).meZoom );
+}
+
+// ------------------------------------------------------------------------------
+
+SfxPoolItem* MediaItem::Clone( SfxItemPool* ) const
+{
+ return new MediaItem( *this );
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation MediaItem::GetPresentation( SfxItemPresentation,
+ SfxMapUnit,
+ SfxMapUnit,
+ XubString& rText,
+ const IntlWrapper * ) const
+{
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//------------------------------------------------------------------------
+
+bool MediaItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 ) const
+{
+ uno::Sequence< uno::Any > aSeq( 9 );
+
+ aSeq[ 0 ] <<= maURL;
+ aSeq[ 1 ] <<= mnMaskSet;
+ aSeq[ 2 ] <<= static_cast< sal_Int32 >( meState );
+ aSeq[ 3 ] <<= mfTime;
+ aSeq[ 4 ] <<= mfDuration;
+ aSeq[ 5 ] <<= mnVolumeDB;
+ aSeq[ 6 ] <<= mbLoop;
+ aSeq[ 7 ] <<= mbMute;
+ aSeq[ 8 ] <<= meZoom;
+
+ rVal <<= aSeq;
+
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+bool MediaItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 )
+{
+ uno::Sequence< uno::Any > aSeq;
+ bool bRet = false;
+
+ if( ( rVal >>= aSeq ) && ( aSeq.getLength() == 9 ) )
+ {
+ sal_Int32 nInt32 = 0;
+
+ aSeq[ 0 ] >>= maURL;
+ aSeq[ 1 ] >>= mnMaskSet;
+ aSeq[ 2 ] >>= nInt32; meState = static_cast< MediaState >( nInt32 );
+ aSeq[ 3 ] >>= mfTime;
+ aSeq[ 4 ] >>= mfDuration;
+ aSeq[ 5 ] >>= mnVolumeDB;
+ aSeq[ 6 ] >>= mbLoop;
+ aSeq[ 7 ] >>= mbMute;
+ aSeq[ 8 ] >>= meZoom;
+
+ bRet = true;
+ }
+
+ return bRet;
+}
+
+//------------------------------------------------------------------------
+
+void MediaItem::merge( const MediaItem& rMediaItem )
+{
+ const sal_uInt32 nMaskSet = rMediaItem.getMaskSet();
+
+ if( AVMEDIA_SETMASK_URL & nMaskSet )
+ setURL( rMediaItem.getURL() );
+
+ if( AVMEDIA_SETMASK_STATE & nMaskSet )
+ setState( rMediaItem.getState() );
+
+ if( AVMEDIA_SETMASK_DURATION & nMaskSet )
+ setDuration( rMediaItem.getDuration() );
+
+ if( AVMEDIA_SETMASK_TIME & nMaskSet )
+ setTime( rMediaItem.getTime() );
+
+ if( AVMEDIA_SETMASK_LOOP & nMaskSet )
+ setLoop( rMediaItem.isLoop() );
+
+ if( AVMEDIA_SETMASK_MUTE & nMaskSet )
+ setMute( rMediaItem.isMute() );
+
+ if( AVMEDIA_SETMASK_VOLUMEDB & nMaskSet )
+ setVolumeDB( rMediaItem.getVolumeDB() );
+
+ if( AVMEDIA_SETMASK_ZOOM & nMaskSet )
+ setZoom( rMediaItem.getZoom() );
+}
+
+//------------------------------------------------------------------------
+
+sal_uInt32 MediaItem::getMaskSet() const
+{
+ return mnMaskSet;
+}
+
+//------------------------------------------------------------------------
+
+void MediaItem::setURL( const ::rtl::OUString& rURL )
+{
+ maURL = rURL;
+ mnMaskSet |= AVMEDIA_SETMASK_URL;
+}
+
+//------------------------------------------------------------------------
+
+const ::rtl::OUString& MediaItem::getURL() const
+{
+ return maURL;
+}
+
+//------------------------------------------------------------------------
+
+void MediaItem::setState( MediaState eState )
+{
+ meState = eState;
+ mnMaskSet |= AVMEDIA_SETMASK_STATE;
+}
+
+//------------------------------------------------------------------------
+
+MediaState MediaItem::getState() const
+{
+ return meState;
+}
+
+//------------------------------------------------------------------------
+
+void MediaItem::setDuration( double fDuration )
+{
+ mfDuration = fDuration;
+ mnMaskSet |= AVMEDIA_SETMASK_DURATION;
+}
+
+//------------------------------------------------------------------------
+
+double MediaItem::getDuration() const
+{
+ return mfDuration;
+}
+
+//------------------------------------------------------------------------
+
+void MediaItem::setTime( double fTime )
+{
+ mfTime = fTime;
+ mnMaskSet |= AVMEDIA_SETMASK_TIME;
+}
+
+//------------------------------------------------------------------------
+
+double MediaItem::getTime() const
+{
+ return mfTime;
+}
+
+//------------------------------------------------------------------------
+
+void MediaItem::setLoop( sal_Bool bLoop )
+{
+ mbLoop = bLoop;
+ mnMaskSet |= AVMEDIA_SETMASK_LOOP;
+}
+
+//------------------------------------------------------------------------
+
+sal_Bool MediaItem::isLoop() const
+{
+ return mbLoop;
+}
+
+//------------------------------------------------------------------------
+
+void MediaItem::setMute( sal_Bool bMute )
+{
+ mbMute = bMute;
+ mnMaskSet |= AVMEDIA_SETMASK_MUTE;
+}
+
+//------------------------------------------------------------------------
+
+sal_Bool MediaItem::isMute() const
+{
+ return mbMute;
+}
+
+//------------------------------------------------------------------------
+
+void MediaItem::setVolumeDB( sal_Int16 nDB )
+{
+ mnVolumeDB = nDB;
+ mnMaskSet |= AVMEDIA_SETMASK_VOLUMEDB;
+}
+
+//------------------------------------------------------------------------
+
+sal_Int16 MediaItem::getVolumeDB() const
+{
+ return mnVolumeDB;
+}
+
+//------------------------------------------------------------------------
+
+void MediaItem::setZoom( ::com::sun::star::media::ZoomLevel eZoom )
+{
+ meZoom = eZoom;
+ mnMaskSet |= AVMEDIA_SETMASK_ZOOM;
+}
+
+//------------------------------------------------------------------------
+
+::com::sun::star::media::ZoomLevel MediaItem::getZoom() const
+{
+ return meZoom;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/framework/mediamisc.cxx b/avmedia/source/framework/mediamisc.cxx
new file mode 100644
index 000000000000..882f5db55d9c
--- /dev/null
+++ b/avmedia/source/framework/mediamisc.cxx
@@ -0,0 +1,51 @@
+/* -*- 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/resmgr.hxx>
+#include <svl/solar.hrc>
+#include <vcl/svapp.hxx>
+
+namespace avmedia {
+
+ResMgr* GetResMgr()
+{
+ static ResMgr* pResMgr = NULL;
+
+ if( !pResMgr )
+ {
+ ByteString aResMgrName( "avmedia" );
+
+ pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
+ }
+
+ return pResMgr;
+}
+
+} // namespace avemdia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/framework/mediaplayer.cxx b/avmedia/source/framework/mediaplayer.cxx
new file mode 100644
index 000000000000..350e4e92bbe2
--- /dev/null
+++ b/avmedia/source/framework/mediaplayer.cxx
@@ -0,0 +1,169 @@
+/* -*- 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 <avmedia/mediaplayer.hxx>
+#include <avmedia/mediawindow.hxx>
+#include <avmedia/mediaitem.hxx>
+#include "mediamisc.hxx"
+#include "mediacontrol.hrc"
+#include "helpids.hrc"
+
+#include <svl/stritem.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+
+namespace avmedia
+{
+
+// ---------------
+// - MediaPlayer -
+// ---------------
+
+MediaPlayer::MediaPlayer( Window* _pParent, sal_uInt16 nId, SfxBindings* _pBindings, SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( _pParent, nId )
+{
+ pWindow = new MediaFloater( _pBindings, this, _pParent );
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+ static_cast< MediaFloater* >( pWindow )->Initialize( pInfo );
+};
+
+// -----------------------------------------------------------------------------
+
+MediaPlayer::~MediaPlayer()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SFX_IMPL_DOCKINGWINDOW( MediaPlayer, SID_AVMEDIA_PLAYER )
+
+// ----------------
+// - MediaFloater -
+// ----------------
+
+MediaFloater::MediaFloater( SfxBindings* _pBindings, SfxChildWindow* pCW, Window* pParent ) :
+ SfxDockingWindow( _pBindings, pCW, pParent, WB_CLOSEABLE | WB_MOVEABLE | WB_SIZEABLE | WB_DOCKABLE ),
+ mpMediaWindow( new MediaWindow( this, true ) )
+{
+ const Size aSize( 378, 256 );
+
+ SetPosSizePixel( Point( 0, 0 ), aSize );
+ SetMinOutputSizePixel( aSize );
+ SetText( String( AVMEDIA_RESID( AVMEDIA_STR_MEDIAPLAYER ) ) );
+ implInit();
+ mpMediaWindow->show();
+}
+
+// -----------------------------------------------------------------------------
+
+MediaFloater::~MediaFloater()
+{
+ delete mpMediaWindow;
+ mpMediaWindow = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+void MediaFloater::implInit()
+{
+}
+
+// -------------------------------------------------------------------------
+
+void MediaFloater::Resize()
+{
+ SfxDockingWindow::Resize();
+
+ if( mpMediaWindow )
+ mpMediaWindow->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void MediaFloater::ToggleFloatingMode()
+{
+ ::avmedia::MediaItem aRestoreItem;
+
+ mpMediaWindow->updateMediaItem( aRestoreItem );
+ delete mpMediaWindow;
+ mpMediaWindow = NULL;
+
+ SfxDockingWindow::ToggleFloatingMode();
+
+ mpMediaWindow = new MediaWindow( this, true );
+
+ mpMediaWindow->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
+ mpMediaWindow->executeMediaItem( aRestoreItem );
+
+ Window* pWindow = mpMediaWindow->getWindow();
+
+ if( pWindow )
+ pWindow->SetHelpId( HID_AVMEDIA_PLAYERWINDOW );
+
+ mpMediaWindow->show();
+}
+
+// -----------------------------------------------------------------------------
+
+void MediaFloater::setURL( const ::rtl::OUString& rURL, bool bPlayImmediately )
+{
+ if( mpMediaWindow )
+ {
+ mpMediaWindow->setURL( rURL );
+
+ if( mpMediaWindow->isValid() && bPlayImmediately )
+ mpMediaWindow->start();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+const ::rtl::OUString& MediaFloater::getURL() const
+{
+ static const ::rtl::OUString aEmptyStr;
+ return( mpMediaWindow ? mpMediaWindow->getURL() : aEmptyStr );
+}
+
+// -----------------------------------------------------------------------------
+
+void MediaFloater::dispatchCurrentURL()
+{
+ SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
+
+ if( pDispatcher )
+ {
+ const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, getURL() );
+ pDispatcher->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_RECORD, &aMediaURLItem, 0L );
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/framework/mediatoolbox.cxx b/avmedia/source/framework/mediatoolbox.cxx
new file mode 100644
index 000000000000..cb795692011b
--- /dev/null
+++ b/avmedia/source/framework/mediatoolbox.cxx
@@ -0,0 +1,171 @@
+/* -*- 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 <avmedia/mediatoolbox.hxx>
+#include <avmedia/mediaitem.hxx>
+#include "mediacontrol.hxx"
+
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/sfxsids.hrc>
+
+using namespace ::com::sun::star;
+
+namespace avmedia
+{
+
+// -----------------------
+// - MediaToolboxControl -
+// -----------------------
+
+class MediaToolBoxControl_Impl : public MediaControl
+{
+public:
+
+ MediaToolBoxControl_Impl( Window& rParent, MediaToolBoxControl& rControl );
+ ~MediaToolBoxControl_Impl();
+
+ void update();
+ void execute( const MediaItem& rItem );
+
+private:
+
+ MediaToolBoxControl* mpToolBoxControl;
+};
+
+// ---------------------------------------------------------------------
+
+MediaToolBoxControl_Impl::MediaToolBoxControl_Impl( Window& rParent, MediaToolBoxControl& rControl ) :
+ MediaControl( &rParent, MEDIACONTROLSTYLE_SINGLELINE ),
+ mpToolBoxControl( &rControl )
+{
+ SetSizePixel( getMinSizePixel() );
+}
+
+// ---------------------------------------------------------------------
+
+MediaToolBoxControl_Impl::~MediaToolBoxControl_Impl()
+{
+}
+
+// ---------------------------------------------------------------------
+
+void MediaToolBoxControl_Impl::update()
+{
+ mpToolBoxControl->implUpdateMediaControl();
+}
+
+// ---------------------------------------------------------------------
+
+void MediaToolBoxControl_Impl::execute( const MediaItem& rItem )
+{
+ mpToolBoxControl->implExecuteMediaControl( rItem );
+}
+
+// -----------------------
+// - MediaToolBoxControl -
+// -----------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( ::avmedia::MediaToolBoxControl, ::avmedia::MediaItem );
+
+// -----------------------------------------------------------------------------
+
+MediaToolBoxControl::MediaToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.Invalidate();
+}
+
+// -----------------------------------------------------------------------------
+
+MediaToolBoxControl::~MediaToolBoxControl()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void MediaToolBoxControl::StateChanged( sal_uInt16 /* nSID */, SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ MediaToolBoxControl_Impl* pCtrl = static_cast< MediaToolBoxControl_Impl* >( GetToolBox().GetItemWindow( GetId() ) );
+
+ DBG_ASSERT( pCtrl, "MediaToolBoxControl::StateChanged: media control not found" );
+
+ if( eState == SFX_ITEM_DISABLED )
+ {
+ pCtrl->Enable( false, false );
+ pCtrl->SetText( String() );
+
+ const MediaItem aEmptyMediaItem( 0, AVMEDIA_SETMASK_ALL );
+ pCtrl->setState( aEmptyMediaItem );
+ }
+ else
+ {
+ pCtrl->Enable( true, false );
+
+ const MediaItem* pMediaItem = PTR_CAST( MediaItem, pState );
+
+ if( pMediaItem && ( SFX_ITEM_AVAILABLE == eState ) )
+ pCtrl->setState( *pMediaItem );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+Window* MediaToolBoxControl::CreateItemWindow( Window *pParent )
+{
+ return( pParent ? new MediaToolBoxControl_Impl( *pParent, *this ) : NULL );
+}
+
+// -----------------------------------------------------------------------------
+
+void MediaToolBoxControl::implUpdateMediaControl()
+{
+ updateStatus( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AVMediaToolBox" ) ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void MediaToolBoxControl::implExecuteMediaControl( const MediaItem& rItem )
+{
+ MediaItem aExecItem( SID_AVMEDIA_TOOLBOX );
+ uno::Sequence< beans::PropertyValue > aArgs( 1 );
+ uno::Any aAny;
+
+ aExecItem.merge( rItem );
+ aExecItem.QueryValue( aAny );
+ aArgs[ 0 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AVMediaToolBox" ) );
+ aArgs[ 0 ].Value = aAny;
+
+ Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AVMediaToolBox" ) ), aArgs );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/framework/soundhandler.cxx b/avmedia/source/framework/soundhandler.cxx
new file mode 100644
index 000000000000..c8213f6c1301
--- /dev/null
+++ b/avmedia/source/framework/soundhandler.cxx
@@ -0,0 +1,523 @@
+/* -*- 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.
+ *
+ ************************************************************************/
+
+//_________________________________________________________________________________________________________________
+// my own includes
+//_________________________________________________________________________________________________________________
+
+#include "soundhandler.hxx"
+
+#include <comphelper/mediadescriptor.hxx>
+
+//_________________________________________________________________________________________________________________
+// interface includes
+//_________________________________________________________________________________________________________________
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/frame/DispatchResultState.hpp>
+
+//_________________________________________________________________________________________________________________
+// includes of other projects
+//_________________________________________________________________________________________________________________
+#include <comphelper/sequenceashashmap.hxx>
+#include <rtl/ustrbuf.hxx>
+
+#include <cppuhelper/typeprovider.hxx>
+#include <cppuhelper/factory.hxx>
+
+//_________________________________________________________________________________________________________________
+// namespace
+//_________________________________________________________________________________________________________________
+
+namespace avmedia{
+
+//_________________________________________________________________________________________________________________
+// non exported const
+//_________________________________________________________________________________________________________________
+
+//_________________________________________________________________________________________________________________
+// non exported definitions
+//_________________________________________________________________________________________________________________
+
+//_________________________________________________________________________________________________________________
+// declarations
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// XInterface, XTypeProvider, XServiceInfo
+//*****************************************************************************************************************
+
+void SAL_CALL SoundHandler::acquire() throw()
+{
+ /* Don't use mutex in methods of XInterface! */
+ OWeakObject::acquire();
+}
+
+void SAL_CALL SoundHandler::release() throw()
+{
+ /* Don't use mutex in methods of XInterface! */
+ OWeakObject::release();
+}
+
+css::uno::Any SAL_CALL SoundHandler::queryInterface( const css::uno::Type& aType ) throw( css::uno::RuntimeException )
+{
+ /* Attention: Don't use mutex or guard in this method!!! Is a method of XInterface. */
+ /* Ask for my own supported interfaces ...*/
+ css::uno::Any aReturn( ::cppu::queryInterface( aType,
+ static_cast< css::lang::XTypeProvider* >(this),
+ static_cast< css::lang::XServiceInfo* >(this),
+ static_cast< css::frame::XNotifyingDispatch* >(this),
+ static_cast< css::frame::XDispatch* >(this),
+ static_cast< css::document::XExtendedFilterDetection* >(this)));
+ /* If searched interface not supported by this class ... */
+ if ( aReturn.hasValue() == sal_False )
+ {
+ /* ... ask baseclass for interfaces! */
+ aReturn = OWeakObject::queryInterface( aType );
+ }
+ /* Return result of this search. */
+ return aReturn;
+}
+
+css::uno::Sequence< sal_Int8 > SAL_CALL SoundHandler::getImplementationId() throw( css::uno::RuntimeException )
+{
+ /* Create one Id for all instances of this class. */
+ /* Use ethernet address to do this! (sal_True) */
+ /* Optimize this method */
+ /* We initialize a static variable only one time. And we don't must use a mutex at every call! */
+ /* For the first call; pID is NULL - for the second call pID is different from NULL! */
+ static ::cppu::OImplementationId* pID = NULL ;
+ if ( pID == NULL )
+ {
+ /* Ready for multithreading; get global mutex for first call of this method only! see before */
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ /* Control these pointer again ... it can be, that another instance will be faster then these! */
+ if ( pID == NULL )
+ {
+ /* Create a new static ID ... */
+ static ::cppu::OImplementationId aID( sal_False );
+ /* ... and set his address to static pointer! */
+ pID = &aID ;
+ }
+ }
+ return pID->getImplementationId();
+}
+
+css::uno::Sequence< css::uno::Type > SAL_CALL SoundHandler::getTypes() throw( css::uno::RuntimeException )
+{
+ /* Optimize this method ! */
+ /* We initialize a static variable only one time. */
+ /* And we don't must use a mutex at every call! */
+ /* For the first call; pTypeCollection is NULL - */
+ /* for the second call pTypeCollection is different from NULL! */
+ static ::cppu::OTypeCollection* pTypeCollection = NULL ;
+ if ( pTypeCollection == NULL )
+ {
+ /* Ready for multithreading; get global mutex for first call of this method only! see before */
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ /* Control these pointer again ... it can be, that another instance will be faster then these! */
+ if ( pTypeCollection == NULL )
+ {
+ /* Create a static typecollection ... */
+ static ::cppu::OTypeCollection aTypeCollection
+ (
+ ::getCppuType(( const ::com::sun::star::uno::Reference< css::lang::XTypeProvider >*)NULL ),
+ ::getCppuType(( const ::com::sun::star::uno::Reference< css::lang::XServiceInfo >*)NULL ),
+ ::getCppuType(( const ::com::sun::star::uno::Reference< css::frame::XNotifyingDispatch >*)NULL ),
+ ::getCppuType(( const ::com::sun::star::uno::Reference< css::frame::XDispatch >*)NULL ),
+ ::getCppuType(( const ::com::sun::star::uno::Reference< css::document::XExtendedFilterDetection >*)NULL )
+ );
+ /* ... and set his address to static pointer! */
+ pTypeCollection = &aTypeCollection ;
+ }
+ }
+ return pTypeCollection->getTypes();
+}
+
+#define DECLARE_ASCII( SASCIIVALUE ) \
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SASCIIVALUE ) )
+
+#define IMPLEMENTATIONNAME_SOUNDHANDLER DECLARE_ASCII("com.sun.star.comp.framework.SoundHandler")
+#define SERVICENAME_CONTENTHANDLER DECLARE_ASCII("com.sun.star.frame.ContentHandler")
+
+/*===========================================================================================================*/
+/* XServiceInfo */
+/*===========================================================================================================*/
+::rtl::OUString SAL_CALL SoundHandler::getImplementationName() throw( css::uno::RuntimeException )
+{
+ return impl_getStaticImplementationName();
+}
+
+/*===========================================================================================================*/
+/* XServiceInfo */
+/*===========================================================================================================*/
+sal_Bool SAL_CALL SoundHandler::supportsService( const ::rtl::OUString& sServiceName ) throw( css::uno::RuntimeException )
+{
+ /* Set default return value. */
+ sal_Bool bReturn = sal_False ;
+ /* Get names of all supported servicenames. */
+ css::uno::Sequence< ::rtl::OUString > seqServiceNames = getSupportedServiceNames();
+ const ::rtl::OUString* pArray = seqServiceNames.getConstArray();
+ sal_Int32 nCounter = 0;
+ sal_Int32 nLength = seqServiceNames.getLength();
+ /* Search for right name in list. */
+ while (
+ ( nCounter < nLength ) &&
+ ( bReturn == sal_False )
+ )
+ {
+ /* Is name was found, say "YES, SERVICE IS SUPPORTED." and break loop. */
+ if ( pArray[nCounter] == sServiceName )
+ {
+ bReturn = sal_True ;
+ }
+ /* Else step to next element in list. */
+ ++nCounter;
+ }
+ /* Return state of search. */
+ return bReturn;
+}
+
+/*===========================================================================================================*/
+/* XServiceInfo */
+/*===========================================================================================================*/
+css::uno::Sequence< ::rtl::OUString > SAL_CALL SoundHandler::getSupportedServiceNames() throw( css::uno::RuntimeException )
+{
+ return impl_getStaticSupportedServiceNames();
+}
+
+/*===========================================================================================================*/
+/* Helper for XServiceInfo */
+/*===========================================================================================================*/
+css::uno::Sequence< ::rtl::OUString > SoundHandler::impl_getStaticSupportedServiceNames()
+{
+ css::uno::Sequence< ::rtl::OUString > seqServiceNames( 1 );
+ seqServiceNames.getArray() [0] = SERVICENAME_CONTENTHANDLER;
+ return seqServiceNames;
+}
+
+/*===========================================================================================================*/
+/* Helper for XServiceInfo */
+/*===========================================================================================================*/
+::rtl::OUString SoundHandler::impl_getStaticImplementationName()
+{
+ return IMPLEMENTATIONNAME_SOUNDHANDLER;
+}
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL SoundHandler::impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception )
+{
+ /* create new instance of service */
+ SoundHandler* pClass = new SoundHandler( xServiceManager );
+ /* hold it alive by increasing his ref count!!! */
+ css::uno::Reference< css::uno::XInterface > xService( static_cast< ::cppu::OWeakObject* >(pClass), css::uno::UNO_QUERY );
+ /* initialize new service instance ... he can use his own refcount ... we hold it! */
+ pClass->impl_initService();
+ /* return new created service as reference */
+ return xService;
+}
+
+css::uno::Reference< css::lang::XSingleServiceFactory > SoundHandler::impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager )
+{
+ css::uno::Reference< css::lang::XSingleServiceFactory > xReturn ( cppu::createSingleFactory (
+ xServiceManager,
+ SoundHandler::impl_getStaticImplementationName(),
+ SoundHandler::impl_createInstance,
+ SoundHandler::impl_getStaticSupportedServiceNames()
+ )
+ );
+ return xReturn;
+}
+
+void SAL_CALL SoundHandler::impl_initService()
+{
+}
+
+/*-************************************************************************************************************//**
+ @short standard ctor
+ @descr These initialize a new instance of this class with needed informations for work.
+
+ @seealso using at owner
+
+ @param "xFactory", reference to service manager for creation of new services
+ @return -
+
+ @onerror Show an assertion and do nothing else.
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+SoundHandler::SoundHandler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory )
+ // Init baseclasses first
+ : ThreadHelpBase ( )
+ , ::cppu::OWeakObject ( )
+ // Init member
+ , m_bError ( false )
+ , m_xFactory ( xFactory )
+{
+ m_aUpdateTimer.SetTimeoutHdl(LINK(this, SoundHandler, implts_PlayerNotify));
+}
+
+/*-************************************************************************************************************//**
+ @short standard dtor
+ @descr -
+
+ @seealso -
+
+ @param -
+ @return -
+
+ @onerror -
+ @threadsafe -
+*//*-*************************************************************************************************************/
+SoundHandler::~SoundHandler()
+{
+ if (m_xListener.is())
+ {
+ css::frame::DispatchResultEvent aEvent;
+ aEvent.State = css::frame::DispatchResultState::FAILURE;
+ m_xListener->dispatchFinished(aEvent);
+ m_xListener = css::uno::Reference< css::frame::XDispatchResultListener >();
+ }
+}
+
+/*-************************************************************************************************************//**
+ @interface ::com::sun::star::frame::XDispatch
+
+ @short try to load audio file
+ @descr This method try to load given audio file by URL and play it. We use vcl/Sound class to do that.
+ Playing of sound is asynchron everytime.
+
+ @attention We must hold us alive by ourself ... because we use async. vcl sound player ... but playing is started
+ in async interface call "dispatch()" too. And caller forget us imediatly. But then our uno ref count
+ will decreased to 0 and will die. The only solution is to use own reference to our implementation.
+ But we do it for realy started jobs only and release it during call back of vcl.
+
+ @seealso class vcl/Sound
+ @seealso method implts_PlayerNotify()
+
+ @param "aURL" , URL to dispatch.
+ @param "lArguments", list of optional arguments.
+ @return -
+
+ @onerror We do nothing.
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+void SAL_CALL SoundHandler::dispatchWithNotification(const css::util::URL& aURL ,
+ const css::uno::Sequence< css::beans::PropertyValue >& lDescriptor,
+ const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException)
+{
+ // SAFE {
+ const ::osl::MutexGuard aLock( m_aLock );
+
+ {
+ //close streams otherwise on windows we can't reopen the file in the
+ //media player when we pass the url to directx as it'll already be open
+ ::comphelper::MediaDescriptor aDescriptor(lDescriptor);
+
+ css::uno::Reference< css::io::XInputStream > xInputStream =
+ aDescriptor.getUnpackedValueOrDefault(::comphelper::MediaDescriptor::PROP_INPUTSTREAM(),
+ css::uno::Reference< css::io::XInputStream >());
+ if (xInputStream.is()) xInputStream->closeInput();
+ }
+
+ // If player currently used for other dispatch() requests ...
+ // cancel it by calling stop()!
+ m_aUpdateTimer.Stop();
+ if (m_xPlayer.is())
+ {
+ if (m_xPlayer->isPlaying())
+ m_xPlayer->stop();
+ m_xPlayer.clear();
+ }
+
+ // Try to initialize player.
+ m_xListener = xListener;
+ try
+ {
+ m_bError = false;
+ m_xPlayer.set( avmedia::MediaWindow::createPlayer( aURL.Complete ), css::uno::UNO_QUERY_THROW );
+ // OK- we can start async playing ...
+ // Count this request and initialize self-holder against dieing by uno ref count ...
+ m_xSelfHold = css::uno::Reference< css::uno::XInterface >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
+ m_xPlayer->start();
+ m_aUpdateTimer.SetTimeout( 200 );
+ m_aUpdateTimer.Start();
+ }
+ catch( css::uno::Exception& e )
+ {
+ m_bError = true;
+ (void)e;
+ m_xPlayer.clear();
+ }
+
+ // } SAFE
+}
+
+void SAL_CALL SoundHandler::dispatch( const css::util::URL& aURL ,
+ const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException )
+{
+ dispatchWithNotification(aURL, lArguments, css::uno::Reference< css::frame::XDispatchResultListener >());
+}
+
+/*-************************************************************************************************************//**
+ @interface ::com::sun::star::document::XExtendedFilterDetection
+
+ @short try to detect file (given as argument included in "lDescriptor")
+ @descr We try to detect, if given file could be handled by this class and is a well known one.
+ If it is - we return right internal type name - otherwise we return nothing!
+ So call can search for another detect service and ask him too.
+
+ @attention a) We don't need any mutex here ... because we don't use any member!
+ b) Dont' use internal player instance "m_pPlayer" to detect given sound file!
+ It's not neccessary to do that ... and we can use temp. variable to do the same.
+ This way is easy - we don't must synchronize it with currently played sounds!
+ Another reason to do so ... We are a listener on our internal ma_Player object.
+ If you would call "IsSoundFile()" on this instance, he would call us back and
+ we make some uneccssary things ...
+
+ @seealso -
+
+ @param "lDescriptor", description of file to detect
+ @return Internal type name which match this file ... or nothing if it is unknown.
+
+ @onerror We return nothing.
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+::rtl::OUString SAL_CALL SoundHandler::detect( css::uno::Sequence< css::beans::PropertyValue >& lDescriptor ) throw( css::uno::RuntimeException )
+{
+ // Our default is "nothing". So we can return it, if detection failed or fily type is realy unknown.
+ ::rtl::OUString sTypeName;
+
+ // Analyze given descriptor to find filename or input stream or ...
+ ::comphelper::MediaDescriptor aDescriptor(lDescriptor);
+ ::rtl::OUString sURL = aDescriptor.getUnpackedValueOrDefault(::comphelper::MediaDescriptor::PROP_URL(), ::rtl::OUString());
+
+ if (
+ (sURL.getLength() ) &&
+ (avmedia::MediaWindow::isMediaURL(sURL))
+ )
+ {
+ // If the file type is supported depends on the OS, so...
+ // I think we can the following ones:
+ // a) look for given extension of url to map our type decision HARD CODED!!!
+ // b) return preferred type every time... it's easy :-)
+ sTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("wav_Wave_Audio_File"));
+ aDescriptor[::comphelper::MediaDescriptor::PROP_TYPENAME()] <<= sTypeName;
+ aDescriptor >> lDescriptor;
+ }
+
+ // Return our decision.
+ return sTypeName;
+}
+
+/*-************************************************************************************************************//**
+ @short call back of sound player
+ @descr Our player call us back to give us some informations.
+ We use this informations to callback our might existing listener.
+
+ @seealso method dispatchWithNotification()
+
+ @param -
+ @return 0 everytime ... it doesnt matter for us.
+
+ @onerror -
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+IMPL_LINK( SoundHandler, implts_PlayerNotify, void*, EMPTYARG )
+{
+ // SAFE {
+ ::osl::ClearableMutexGuard aLock( m_aLock );
+
+ if (m_xPlayer.is() && m_xPlayer->isPlaying() && m_xPlayer->getMediaTime() < m_xPlayer->getDuration())
+ {
+ m_aUpdateTimer.Start();
+ return 0L;
+ }
+ m_xPlayer.clear();
+
+ // We use m_xSelfHold to let us die ... but we must live till real finishing of this method too!!!
+ // So we SHOULD use another "self-holder" temp. to provide that ...
+ css::uno::Reference< css::uno::XInterface > xOperationHold = m_xSelfHold;
+ m_xSelfHold = css::uno::Reference< css::uno::XInterface >();
+
+ // notify might existing listener
+ // And forget this listener!
+ // Because the corresponding dispatch was finished.
+ if (m_xListener.is())
+ {
+ css::frame::DispatchResultEvent aEvent;
+ if (!m_bError)
+ aEvent.State = css::frame::DispatchResultState::SUCCESS;
+ else
+ aEvent.State = css::frame::DispatchResultState::FAILURE;
+ m_xListener->dispatchFinished(aEvent);
+ m_xListener = css::uno::Reference< css::frame::XDispatchResultListener >();
+ }
+
+ // } SAFE
+ //release aLock before end of method at which point xOperationHold goes out of scope and pThis dies
+ aLock.clear();
+ return 0;
+}
+
+} // namespace framework
+
+// ------------------------------------------
+// - component_getImplementationEnvironment -
+// ------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+// ------------------------
+// - component_getFactory -
+// ------------------------
+
+extern "C" void* SAL_CALL component_getFactory(const sal_Char* pImplementationName, void* pServiceManager, void* /*pRegistryKey*/ )
+{
+ void* pReturn = NULL;
+ if (pServiceManager != NULL )
+ {
+ /* Define variables which are used in following macros. */
+ css::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory;
+ css::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager;
+ xServiceManager = reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pServiceManager ) ;
+
+ if ( avmedia::SoundHandler::impl_getStaticImplementationName().equals( ::rtl::OUString::createFromAscii( pImplementationName ) ) )
+ xFactory = avmedia::SoundHandler::impl_createFactory( xServiceManager );
+
+ if ( xFactory.is() == sal_True )
+ {
+ xFactory->acquire();
+ pReturn = xFactory.get();
+ }
+ }
+ /* Return with result of this operation. */
+ return pReturn;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/framework/soundhandler.hxx b/avmedia/source/framework/soundhandler.hxx
new file mode 100644
index 000000000000..d76bd13df5b7
--- /dev/null
+++ b/avmedia/source/framework/soundhandler.hxx
@@ -0,0 +1,189 @@
+/* -*- 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 __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
+#define __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
+
+//_________________________________________________________________________________________________________________
+// interface includes
+//_________________________________________________________________________________________________________________
+
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/frame/XNotifyingDispatch.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/media/XPlayer.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/util/URL.hpp>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+//_________________________________________________________________________________________________________________
+// other includes
+//_________________________________________________________________________________________________________________
+#include <cppuhelper/weak.hxx>
+
+#include <vcl/timer.hxx>
+#include <tools/link.hxx>
+#include <avmedia/mediawindow.hxx>
+#include <osl/mutex.hxx>
+
+namespace css = ::com::sun::star;
+
+//_________________________________________________________________________________________________________________
+// namespace
+//_________________________________________________________________________________________________________________
+
+namespace avmedia{
+
+//_________________________________________________________________________________________________________________
+// exported const
+//_________________________________________________________________________________________________________________
+
+//_________________________________________________________________________________________________________________
+// exported definitions
+//_________________________________________________________________________________________________________________
+
+struct ThreadHelpBase
+{
+ public:
+ mutable ::osl::Mutex m_aLock;
+};
+
+/*-************************************************************************************************************//**
+ @short handler to detect and play sounds ("wav" and "au" only!)
+ @descr Register this implementation as a content handler to detect and/or play wav- and au-sounds.
+ It doesn't depend from the target platform. But one instance of this class
+ can play one sound at the same time only. Means every new dispatch request will stop the
+ might still running one. So we support one operation/one URL/one listener at the same time
+ only.
+
+ @devstatus ready
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+class SoundHandler : // interfaces
+ public css::lang::XTypeProvider
+ , public css::lang::XServiceInfo
+ , public css::frame::XNotifyingDispatch // => XDispatch
+ , public css::document::XExtendedFilterDetection
+ // baseclasses
+ // Order is neccessary for right initialization!
+ , private ThreadHelpBase
+ , public ::cppu::OWeakObject
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+ SoundHandler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
+ virtual ~SoundHandler( );
+
+ //---------------------------------------------------------------------------------------------------------
+ // XInterface, XTypeProvider, XServiceInfo
+ //---------------------------------------------------------------------------------------------------------
+ virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw( css::uno::RuntimeException );
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes () throw( css::uno::RuntimeException );
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw( css::uno::RuntimeException );
+
+ /* interface XServiceInfo */
+ virtual ::rtl::OUString SAL_CALL getImplementationName ( ) throw( css::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService ( const ::rtl::OUString& sServiceName ) throw( css::uno::RuntimeException );
+ virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames ( ) throw( css::uno::RuntimeException );
+ /* Helper for XServiceInfo */
+ static css::uno::Sequence< ::rtl::OUString > SAL_CALL impl_getStaticSupportedServiceNames( );
+ static ::rtl::OUString SAL_CALL impl_getStaticImplementationName ( );
+ /* Helper for registry */
+ static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception );
+ static css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
+ /* Helper for initialization of service by using own reference! */
+ virtual void SAL_CALL impl_initService ( );
+
+ //---------------------------------------------------------------------------------------------------------
+ // XNotifyingDispatch
+ //---------------------------------------------------------------------------------------------------------
+ virtual void SAL_CALL dispatchWithNotification(const css::util::URL& aURL ,
+ const css::uno::Sequence< css::beans::PropertyValue >& lArguments,
+ const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException);
+
+ //---------------------------------------------------------------------------------------------------------
+ // XDispatch
+ //---------------------------------------------------------------------------------------------------------
+ virtual void SAL_CALL dispatch ( const css::util::URL& aURL ,
+ const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException );
+ // not supported !
+ virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/ ,
+ const css::util::URL& /*aURL*/ ) throw( css::uno::RuntimeException ) {};
+ virtual void SAL_CALL removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/ ,
+ const css::util::URL& /*aURL*/ ) throw( css::uno::RuntimeException ) {};
+
+ //---------------------------------------------------------------------------------------------------------
+ // XExtendedFilterDetection
+ //---------------------------------------------------------------------------------------------------------
+ virtual ::rtl::OUString SAL_CALL detect ( css::uno::Sequence< css::beans::PropertyValue >& lDescriptor ) throw( css::uno::RuntimeException );
+
+ //-------------------------------------------------------------------------------------------------------------
+ // protected methods
+ //-------------------------------------------------------------------------------------------------------------
+ protected:
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+ private:
+ DECL_LINK( implts_PlayerNotify, void* );
+
+ //-------------------------------------------------------------------------------------------------------------
+ // variables
+ // (should be private everyway!)
+ //-------------------------------------------------------------------------------------------------------------
+ private:
+
+ bool m_bError;
+ css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// global uno service factory to create new services
+ css::uno::Reference< css::uno::XInterface > m_xSelfHold ; /// we must protect us against dieing during async(!) dispatch() call!
+ css::uno::Reference< css::media::XPlayer > m_xPlayer ; /// uses avmedia player to play sounds ...
+
+ css::uno::Reference< css::frame::XDispatchResultListener > m_xListener ;
+ Timer m_aUpdateTimer;
+
+}; // class SoundHandler
+
+} // namespace avmedia
+
+#endif // #ifndef __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/framework/soundhandler.xml b/avmedia/source/framework/soundhandler.xml
new file mode 100755
index 000000000000..065b31a2c402
--- /dev/null
+++ b/avmedia/source/framework/soundhandler.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+
+ <module-name> avmedia </module-name>
+
+ <component-description>
+ <author> Andreas Schluens </author>
+ <name> com.sun.star.comp.framework.SoundHandler </name>
+ <description>
+ Implements a handler service to detect and/or play audio files.
+ supported formats: wav/au
+ </description>
+ <loader-name> com.sun.star.loader.SharedLibrary </loader-name>
+ <language> c++ </language>
+ <status value="final"/>
+ <supported-service> com.sun.star.frame.ContentHandler </supported-service>
+ </component-description>
+
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <project-build-dependency> tools </project-build-dependency>
+ <project-build-dependency> svtools </project-build-dependency>
+ <project-build-dependency> toolkit </project-build-dependency>
+ <project-build-dependency> sv </project-build-dependency>
+ <project-build-dependency> comphelper </project-build-dependency>
+ <project-build-dependency> unotools </project-build-dependency>
+ <project-build-dependency> ucbhelper </project-build-dependency>
+ <project-build-dependency> svl </project-build-dependency>
+ <project-build-dependency> sot </project-build-dependency>
+
+ <runtime-module-dependency> cppu2 </runtime-module-dependency>
+ <runtime-module-dependency> cppuhelper </runtime-module-dependency>
+ <runtime-module-dependency> sal2 </runtime-module-dependency>
+ <runtime-module-dependency> tl </runtime-module-dependency>
+ <runtime-module-dependency> svt </runtime-module-dependency>
+ <runtime-module-dependency> svl </runtime-module-dependency>
+ <runtime-module-dependency> tk </runtime-module-dependency>
+ <runtime-module-dependency> sv </runtime-module-dependency>
+ <runtime-module-dependency> comphelp2 </runtime-module-dependency>
+ <runtime-module-dependency> utl </runtime-module-dependency>
+ <runtime-module-dependency> ucb </runtime-module-dependency>
+ <runtime-module-dependency> sot </runtime-module-dependency>
+
+</module-description>
diff --git a/avmedia/source/gstreamer/avmediagstreamer.component b/avmedia/source/gstreamer/avmediagstreamer.component
new file mode 100644
index 000000000000..cd25a6b0cc26
--- /dev/null
+++ b/avmedia/source/gstreamer/avmediagstreamer.component
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component loader="com.sun.star.loader.SharedLibrary" xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.media.Manager_GStreamer">
+ <service name="com.sun.star.media.Manager_GStreamer"/>
+ </implementation>
+</component>
diff --git a/avmedia/source/gstreamer/exports.dxp b/avmedia/source/gstreamer/exports.dxp
new file mode 100755
index 000000000000..f0e1c69934bc
--- /dev/null
+++ b/avmedia/source/gstreamer/exports.dxp
@@ -0,0 +1,2 @@
+component_getImplementationEnvironment
+component_getFactory
diff --git a/avmedia/source/gstreamer/gstcommon.hxx b/avmedia/source/gstreamer/gstcommon.hxx
new file mode 100644
index 000000000000..1d9b5caaff96
--- /dev/null
+++ b/avmedia/source/gstreamer/gstcommon.hxx
@@ -0,0 +1,60 @@
+/* -*- 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 2010 Novell, Inc.
+ *
+ * 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 _GSTCOMMON_HXX
+#define _GSTCOMMON_HXX
+
+#include <gst/gst.h>
+
+#include <osl/mutex.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 // _GSTCOMMOM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/gstreamer/gstframegrabber.cxx b/avmedia/source/gstreamer/gstframegrabber.cxx
new file mode 100644
index 000000000000..fc775fe01287
--- /dev/null
+++ b/avmedia/source/gstreamer/gstframegrabber.cxx
@@ -0,0 +1,236 @@
+/* -*- 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 2010 Novell, Inc.
+ *
+ * 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 <objbase.h>
+#include <strmif.h>
+#include <Amvideo.h>
+#include <Qedit.h>
+#include <uuids.h>
+
+#include "framegrabber.hxx"
+#include "player.hxx"
+
+#include <tools/stream.hxx>
+#include <vcl/graph.hxx>
+#include <unotools/localfilehelper.hxx>
+
+#define AVMEDIA_GST_FRAMEGRABBER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.FrameGrabber_GStreamer"
+#define AVMEDIA_GST_FRAMEGRABBER_SERVICENAME "com.sun.star.media.FrameGrabber_GStreamer"
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace gstreamer {
+
+// ----------------
+// - 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( 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_GST_FRAMEGRABBER_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL FrameGrabber::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_GST_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_GST_FRAMEGRABBER_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace gstreamer
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/gstreamer/gstframegrabber.hxx b/avmedia/source/gstreamer/gstframegrabber.hxx
new file mode 100644
index 000000000000..fc0795221a88
--- /dev/null
+++ b/avmedia/source/gstreamer/gstframegrabber.hxx
@@ -0,0 +1,71 @@
+/* -*- 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 2010 Novell, Inc.
+ *
+ * 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 "gstcommon.hxx"
+
+#include "com/sun/star/media/XFrameGrabber.hdl"
+
+namespace avmedia { namespace gstreamer {
+
+// ----------------
+// - 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;
+};
+
+} // namespace gstreamer
+} // namespace avmedia
+
+#endif // _FRAMEGRABBER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/gstreamer/gstmanager.cxx b/avmedia/source/gstreamer/gstmanager.cxx
new file mode 100644
index 000000000000..e3b2c158c1b9
--- /dev/null
+++ b/avmedia/source/gstreamer/gstmanager.cxx
@@ -0,0 +1,109 @@
+/* -*- 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 2010 Novell, Inc.
+ *
+ * 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 "gstmanager.hxx"
+#include "gstplayer.hxx"
+
+#include <tools/urlobj.hxx>
+
+#define AVMEDIA_GST_MANAGER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Manager_GStreamer"
+#define AVMEDIA_GST_MANAGER_SERVICENAME "com.sun.star.media.Manager"
+
+#if OSL_DEBUG_LEVEL > 2
+#define DBG OSL_TRACE
+#else
+#define DBG(...)
+#endif
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace gstreamer {
+// ----------------
+// - Manager -
+// ----------------
+
+Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
+ mxMgr( rxMgr )
+{
+ DBG( "avmediagst: Manager::Manager" );
+}
+
+// ------------------------------------------------------------------------------
+
+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 );
+
+ DBG( "avmediagst: Manager::createPlayer" );
+
+ 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_GST_MANAGER_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Manager::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_GST_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_GST_MANAGER_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace gstreamer
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/gstreamer/gstmanager.hxx b/avmedia/source/gstreamer/gstmanager.hxx
new file mode 100644
index 000000000000..2d83215402df
--- /dev/null
+++ b/avmedia/source/gstreamer/gstmanager.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 2010 Novell, Inc.
+ *
+ * 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 "gstcommon.hxx"
+
+#include "com/sun/star/media/XManager.hdl"
+
+// -----------
+// - Manager -
+// -----------
+
+namespace avmedia { namespace gstreamer {
+
+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 gstreamer
+} // namespace avmedia
+
+#endif // _MANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx
new file mode 100644
index 000000000000..1e2d0b70800e
--- /dev/null
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -0,0 +1,634 @@
+/* -*- 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 2010 Novell, Inc.
+ *
+ * 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 <math.h>
+
+#include <rtl/string.hxx>
+
+#include <vcl/syschild.hxx>
+#include <vcl/sysdata.hxx>
+
+
+#include "gstplayer.hxx"
+#include "gstframegrabber.hxx"
+#include "gstwindow.hxx"
+
+#include <gst/interfaces/xoverlay.h>
+
+#define AVMEDIA_GST_PLAYER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Player_GStreamer"
+#define AVMEDIA_GST_PLAYER_SERVICENAME "com.sun.star.media.Player_GStreamer"
+
+#if OSL_DEBUG_LEVEL > 2
+#define DBG OSL_TRACE
+#else
+#define DBG(...)
+#endif
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace gstreamer {
+
+// ----------------
+// - Player -
+// ----------------
+
+Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
+ mxMgr( rxMgr ),
+ mpPlaybin( NULL ),
+ mbFakeVideo (sal_False ),
+ mnUnmutedVolume( 0 ),
+ mbPlayPending ( false ),
+ mbMuted( false ),
+ mbLooping( false ),
+ mbInitialized( false ),
+ mnWindowID( 0 ),
+ mpXOverlay( NULL ),
+ mnDuration( 0 ),
+ mnWidth( 0 ),
+ mnHeight( 0 ),
+ maSizeCondition( osl_createCondition() )
+{
+ // Initialize GStreamer library
+ int argc = 1;
+ char name[] = "libreoffice";
+ char *arguments[] = { name };
+ char** argv = arguments;
+ GError* pError = NULL;
+
+ mbInitialized = gst_init_check( &argc, &argv, &pError );
+
+ if (pError != NULL)
+ // TODO: thow an exception?
+ g_error_free (pError);
+}
+
+// ------------------------------------------------------------------------------
+
+Player::~Player()
+{
+ // Release the elements and pipeline
+ if( mbInitialized )
+ {
+ if( mpPlaybin )
+ {
+ gst_element_set_state( mpPlaybin, GST_STATE_NULL );
+ gst_object_unref( GST_OBJECT( mpPlaybin ) );
+
+ mpPlaybin = NULL;
+ }
+
+ if( mpXOverlay ) {
+ g_object_unref( G_OBJECT ( mpXOverlay ) );
+ mpXOverlay = NULL;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+static gboolean gst_pipeline_bus_callback( GstBus *, GstMessage *message, gpointer data )
+{
+ Player* pPlayer = (Player *) data;
+
+ pPlayer->processMessage( message );
+
+ return TRUE;
+}
+
+static GstBusSyncReply gst_pipeline_bus_sync_handler( GstBus *, GstMessage * message, gpointer data )
+{
+ Player* pPlayer = (Player *) data;
+
+ return pPlayer->processSyncMessage( message );
+}
+
+void Player::processMessage( GstMessage *message )
+{
+ switch( GST_MESSAGE_TYPE( message ) ) {
+ case GST_MESSAGE_EOS:
+ gst_element_set_state( mpPlaybin, GST_STATE_READY );
+ mbPlayPending = false;
+ if (mbLooping)
+ start();
+ break;
+ case GST_MESSAGE_STATE_CHANGED:
+ if( message->src == GST_OBJECT( mpPlaybin ) ) {
+ GstState newstate, pendingstate;
+
+ gst_message_parse_state_changed (message, NULL, &newstate, &pendingstate);
+
+ if( newstate == GST_STATE_PAUSED &&
+ pendingstate == GST_STATE_VOID_PENDING &&
+ mpXOverlay )
+ gst_x_overlay_expose( mpXOverlay );
+
+ if (mbPlayPending)
+ mbPlayPending = ((newstate == GST_STATE_READY) || (newstate == GST_STATE_PAUSED));
+ }
+ default:
+ break;
+ }
+}
+
+GstBusSyncReply Player::processSyncMessage( GstMessage *message )
+{
+ DBG( "%p processSyncMessage: %s", this, GST_MESSAGE_TYPE_NAME( message ) );
+
+#if OSL_DEBUG_LEVEL > 0
+ if ( GST_MESSAGE_TYPE( message ) == GST_MESSAGE_ERROR )
+ {
+ GError* error;
+ gchar* error_debug;
+
+ gst_message_parse_error( message, &error, &error_debug );
+ OSL_TRACE("gstreamer error: '%s' debug: '%s'", error->message, error_debug);
+ }
+#endif
+
+ if (message->structure) {
+ if( !strcmp( gst_structure_get_name( message->structure ), "prepare-xwindow-id" ) && mnWindowID != 0 ) {
+ if( mpXOverlay )
+ g_object_unref( G_OBJECT ( mpXOverlay ) );
+ mpXOverlay = GST_X_OVERLAY( GST_MESSAGE_SRC( message ) );
+ g_object_ref( G_OBJECT ( mpXOverlay ) );
+ gst_x_overlay_set_xwindow_id( mpXOverlay, mnWindowID );
+ return GST_BUS_DROP;
+ }
+ }
+
+ if( GST_MESSAGE_TYPE( message ) == GST_MESSAGE_STATE_CHANGED ) {
+ if( message->src == GST_OBJECT( mpPlaybin ) ) {
+ GstState newstate, pendingstate;
+
+ gst_message_parse_state_changed (message, NULL, &newstate, &pendingstate);
+
+ DBG( "%p state change received, new state %d", this, newstate );
+ if( newstate == GST_STATE_PAUSED &&
+ pendingstate == GST_STATE_VOID_PENDING ) {
+
+ DBG( "%p change to paused received", this );
+
+ if( mnDuration == 0) {
+ GstFormat format = GST_FORMAT_TIME;
+ gint64 gst_duration = 0L;
+
+ if( gst_element_query_duration( mpPlaybin, &format, &gst_duration) && format == GST_FORMAT_TIME && gst_duration > 0L )
+ mnDuration = gst_duration;
+ }
+
+ if( mnWidth == 0 ) {
+ GList *pStreamInfo = NULL;
+
+ g_object_get( G_OBJECT( mpPlaybin ), "stream-info", &pStreamInfo, NULL );
+
+ for ( ; pStreamInfo != NULL; pStreamInfo = pStreamInfo->next) {
+ GObject *pInfo = G_OBJECT( pStreamInfo->data );
+
+ if( !pInfo )
+ continue;
+
+ int nType;
+ g_object_get( pInfo, "type", &nType, NULL );
+ GEnumValue *pValue = g_enum_get_value( G_PARAM_SPEC_ENUM( g_object_class_find_property( G_OBJECT_GET_CLASS( pInfo ), "type" ) )->enum_class,
+ nType );
+
+ if( !g_strcasecmp( pValue->value_nick, "video" ) ) {
+ GstStructure *pStructure;
+ GstPad *pPad;
+
+ g_object_get( pInfo, "object", &pPad, NULL );
+ pStructure = gst_caps_get_structure( GST_PAD_CAPS( pPad ), 0 );
+ if( pStructure ) {
+ gst_structure_get_int( pStructure, "width", &mnWidth );
+ gst_structure_get_int( pStructure, "height", &mnHeight );
+ DBG( "queried size: %d x %d", mnWidth, mnHeight );
+ }
+ }
+ }
+
+#if OSL_DEBUG_LEVEL > 2
+ sal_Bool aSuccess =
+#endif
+ osl_setCondition( maSizeCondition );
+ DBG( "%p set condition result: %d", this, aSuccess );
+ }
+ }
+ }
+ } else if( GST_MESSAGE_TYPE( message ) == GST_MESSAGE_ERROR ) {
+ if( mnWidth == 0 ) {
+ // an error occurred, set condition so that OOo thread doesn't wait for us
+#if OSL_DEBUG_LEVEL > 2
+ sal_Bool aSuccess =
+#endif
+ osl_setCondition( maSizeCondition );
+ DBG( "%p set condition result: %d", this, aSuccess );
+ }
+ }
+
+ return GST_BUS_PASS;
+}
+
+void Player::preparePlaybin( const ::rtl::OUString& rURL, bool bFakeVideo )
+{
+ GstBus *pBus;
+
+ if( mpPlaybin != NULL ) {
+ gst_element_set_state( mpPlaybin, GST_STATE_NULL );
+ mbPlayPending = false;
+ g_object_unref( mpPlaybin );
+ }
+
+ mpPlaybin = gst_element_factory_make( "playbin", NULL );
+
+ if( bFakeVideo )
+ g_object_set( G_OBJECT( mpPlaybin ), "video-sink", gst_element_factory_make( "fakesink", NULL ), NULL );
+
+ mbFakeVideo = bFakeVideo;
+
+ rtl::OString ascURL = OUStringToOString( rURL, RTL_TEXTENCODING_ASCII_US );
+ g_object_set( G_OBJECT( mpPlaybin ), "uri", ascURL.getStr() , NULL );
+
+ pBus = gst_element_get_bus( mpPlaybin );
+ gst_bus_add_watch( pBus, gst_pipeline_bus_callback, this );
+ DBG( "%p set sync handler", this );
+ gst_bus_set_sync_handler( pBus, gst_pipeline_bus_sync_handler, this );
+ g_object_unref( pBus );
+}
+
+bool Player::create( const ::rtl::OUString& rURL )
+{
+ bool bRet = false;
+
+ // create all the elements and link them
+
+ DBG("create player, URL: %s", OUStringToOString( rURL, RTL_TEXTENCODING_UTF8 ).getStr());
+
+ if( mbInitialized )
+ {
+ preparePlaybin( rURL, true );
+
+ gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
+ mbPlayPending = false;
+
+ bRet = true;
+ }
+
+ if( bRet )
+ maURL = rURL;
+ else
+ maURL = ::rtl::OUString();
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::start( )
+ throw (uno::RuntimeException)
+{
+ // set the pipeline state to READY and run the loop
+ if( mbInitialized && NULL != mpPlaybin )
+ {
+ gst_element_set_state( mpPlaybin, GST_STATE_PLAYING );
+ mbPlayPending = true;
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::stop( )
+ throw (uno::RuntimeException)
+{
+ // set the pipeline in PAUSED STATE
+ if( mpPlaybin )
+ gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
+
+ mbPlayPending = false;
+ DBG( "stop %p", mpPlaybin );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::isPlaying()
+ throw (uno::RuntimeException)
+{
+ bool bRet = mbPlayPending;
+
+ // return whether the pipeline is in PLAYING STATE or not
+ if( !mbPlayPending && mbInitialized && mpPlaybin )
+ {
+ bRet = GST_STATE_PLAYING == GST_STATE( mpPlaybin );
+ }
+
+ DBG( "isPlaying %d", bRet );
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getDuration( )
+ throw (uno::RuntimeException)
+{
+ // slideshow checks for non-zero duration, so cheat here
+ double duration = 0.01;
+
+ if( mpPlaybin && mnDuration > 0 ) {
+ duration = mnDuration / 1E9;
+ }
+
+ return duration;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setMediaTime( double fTime )
+ throw (uno::RuntimeException)
+{
+ if( mpPlaybin ) {
+ gint64 gst_position = llround (fTime * 1E9);
+
+ gst_element_seek( mpPlaybin, 1.0,
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH,
+ GST_SEEK_TYPE_SET, gst_position,
+ GST_SEEK_TYPE_NONE, 0 );
+ if( !isPlaying() )
+ gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
+
+ DBG( "seek to: %"SAL_PRIdINT64" ns original: %lf s", gst_position, fTime );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getMediaTime( )
+ throw (uno::RuntimeException)
+{
+ double position = 0.0;
+
+ if( mpPlaybin ) {
+ // get current position in the stream
+ GstFormat format = GST_FORMAT_TIME;
+ gint64 gst_position;
+ if( gst_element_query_position( mpPlaybin, &format, &gst_position ) && format == GST_FORMAT_TIME && gst_position > 0L )
+ position = gst_position / 1E9;
+ }
+
+ return position;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setStopTime( double /*fTime*/ )
+ throw (uno::RuntimeException)
+{
+ // TODO implement
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getStopTime( )
+ throw (uno::RuntimeException)
+{
+ // Get the time at which to stop
+
+ return 0;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setRate( double /*fRate*/ )
+ throw (uno::RuntimeException)
+{
+ // TODO set the window rate
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getRate( )
+ throw (uno::RuntimeException)
+{
+ double rate = 0.0;
+
+ // TODO get the window rate
+ if( mbInitialized )
+ {
+
+ }
+
+ return rate;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet )
+ throw (uno::RuntimeException)
+{
+ // TODO check how to do with GST
+ mbLooping = bSet;
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::isPlaybackLoop( )
+ throw (uno::RuntimeException)
+{
+ // TODO check how to do with GST
+ return mbLooping;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setMute( sal_Bool bSet )
+ throw (uno::RuntimeException)
+{
+ DBG( "set mute: %d muted: %d unmuted volume: %lf", bSet, mbMuted, mnUnmutedVolume );
+
+ // change the volume to 0 or the unmuted volume
+ if( mpPlaybin && mbMuted != bSet )
+ {
+ double nVolume = mnUnmutedVolume;
+ if( bSet )
+ {
+ nVolume = 0.0;
+ }
+
+ g_object_set( G_OBJECT( mpPlaybin ), "volume", nVolume, NULL );
+
+ mbMuted = bSet;
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::isMute( )
+ throw (uno::RuntimeException)
+{
+ return mbMuted;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB )
+ throw (uno::RuntimeException)
+{
+ mnUnmutedVolume = pow( 10.0, nVolumeDB / 20.0 );
+
+ DBG( "set volume: %d gst volume: %lf", nVolumeDB, mnUnmutedVolume );
+
+ // change volume
+ if( !mbMuted && mpPlaybin )
+ {
+ g_object_set( G_OBJECT( mpPlaybin ), "volume", (gdouble) mnUnmutedVolume, NULL );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL Player::getVolumeDB( )
+ throw (uno::RuntimeException)
+{
+ sal_Int16 nVolumeDB(0);
+
+ if( mpPlaybin ) {
+ double nGstVolume = 0.0;
+
+ g_object_get( G_OBJECT( mpPlaybin ), "volume", &nGstVolume, NULL );
+
+ nVolumeDB = (sal_Int16) ( 20.0*log10 ( nGstVolume ) );
+ }
+
+ return nVolumeDB;
+}
+
+// ------------------------------------------------------------------------------
+
+awt::Size SAL_CALL Player::getPreferredPlayerWindowSize( )
+ throw (uno::RuntimeException)
+{
+ awt::Size aSize( 0, 0 );
+
+ DBG( "%p Player::getPreferredPlayerWindowSize, member %d x %d", this, mnWidth, mnHeight );
+
+ TimeValue aTimeout = { 10, 0 };
+#if OSL_DEBUG_LEVEL > 2
+ oslConditionResult aResult =
+#endif
+ osl_waitCondition( maSizeCondition, &aTimeout );
+
+ if( mbFakeVideo ) {
+ mbFakeVideo = sal_False;
+
+ g_object_set( G_OBJECT( mpPlaybin ), "video-sink", NULL, NULL );
+ gst_element_set_state( mpPlaybin, GST_STATE_READY );
+ gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
+ }
+
+ DBG( "%p Player::getPreferredPlayerWindowSize after waitCondition %d, member %d x %d", this, aResult, mnWidth, mnHeight );
+
+ if( mnWidth != 0 && mnHeight != 0 ) {
+ aSize.Width = mnWidth;
+ aSize.Height = mnHeight;
+ }
+
+ return aSize;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( const uno::Sequence< uno::Any >& rArguments )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< ::media::XPlayerWindow > xRet;
+ awt::Size aSize( getPreferredPlayerWindowSize() );
+
+ DBG( "Player::createPlayerWindow %d %d length: %d", aSize.Width, aSize.Height, rArguments.getLength() );
+
+ if( aSize.Width > 0 && aSize.Height > 0 )
+ {
+ ::avmedia::gstreamer::Window* pWindow = new ::avmedia::gstreamer::Window( mxMgr, *this );
+
+ xRet = pWindow;
+
+ if( rArguments.getLength() > 2 )
+ {
+ sal_IntPtr pIntPtr = 0;
+ rArguments[ 2 ] >>= pIntPtr;
+ SystemChildWindow *pParentWindow = reinterpret_cast< SystemChildWindow* >( pIntPtr );
+ const SystemEnvData* pEnvData = pParentWindow ? pParentWindow->GetSystemData() : NULL;
+ OSL_ASSERT(pEnvData);
+ if (pEnvData)
+ mnWindowID = pEnvData->aWindow;
+ }
+ }
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber( )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< media::XFrameGrabber > xRet;
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL Player::getImplementationName( )
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_GST_PLAYER_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_GST_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_GST_PLAYER_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace gstreamer
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx
new file mode 100644
index 000000000000..02839dc9b2bd
--- /dev/null
+++ b/avmedia/source/gstreamer/gstplayer.hxx
@@ -0,0 +1,114 @@
+/* -*- 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 2010 Novell, Inc.
+ *
+ * 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 <osl/conditn.h>
+#include "gstcommon.hxx"
+
+#include "com/sun/star/media/XPlayer.hdl"
+
+typedef struct _GstXOverlay GstXOverlay;
+
+namespace avmedia { namespace gstreamer {
+
+// ----------
+// - 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();
+
+ void preparePlaybin( const ::rtl::OUString& rURL, bool bFakeVideo );
+ bool create( const ::rtl::OUString& rURL );
+ void processMessage( GstMessage *message );
+ GstBusSyncReply processSyncMessage( GstMessage *message );
+
+ // 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;
+
+ // Add elements and pipeline here
+ GstElement* mpPlaybin; // the playbin is also a pipeline
+ sal_Bool mbFakeVideo;
+
+ gdouble mnUnmutedVolume;
+ sal_Bool mbPlayPending;
+ sal_Bool mbMuted;
+ sal_Bool mbLooping;
+ sal_Bool mbInitialized;
+
+ long mnWindowID;
+ GstXOverlay* mpXOverlay;
+ gint64 mnDuration;
+ int mnWidth;
+ int mnHeight;
+
+ oslCondition maSizeCondition;
+};
+
+} // namespace gstreamer
+} // namespace avmedia
+
+#endif // _PLAYER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/gstreamer/gstuno.cxx b/avmedia/source/gstreamer/gstuno.cxx
new file mode 100644
index 000000000000..4695ba646a47
--- /dev/null
+++ b/avmedia/source/gstreamer/gstuno.cxx
@@ -0,0 +1,71 @@
+/* -*- 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 2010 Novell, Inc.
+ *
+ * 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 "gstmanager.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::gstreamer::Manager( rxFact ) );
+}
+
+extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /*pRegistryKey*/ )
+{
+ uno::Reference< lang::XSingleServiceFactory > xFactory;
+ void* pRet = 0;
+
+ if( rtl_str_compare( pImplName, "com.sun.star.comp.media.Manager_GStreamer" ) == 0 )
+ {
+ const ::rtl::OUString aServiceName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.media.Manager_GStreamer" )) );
+
+ xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
+ reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.media.Manager_GStreamer" )),
+ 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: */
diff --git a/avmedia/source/gstreamer/gstwindow.cxx b/avmedia/source/gstreamer/gstwindow.cxx
new file mode 100644
index 000000000000..9228f9e6c9a0
--- /dev/null
+++ b/avmedia/source/gstreamer/gstwindow.cxx
@@ -0,0 +1,326 @@
+/* -*- 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 2010 Novell, Inc.
+ *
+ * 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 <com/sun/star/awt/SystemPointer.hdl>
+
+#include "gstwindow.hxx"
+#include "gstplayer.hxx"
+
+#define AVMEDIA_GST_WINDOW_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Window_GStreamer"
+#define AVMEDIA_GST_WINDOW_SERVICENAME "com.sun.star.media.Window_GStreamer"
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace gstreamer {
+
+// -----------
+// - 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;
+}
+
+// ---------------
+// - Window -
+// ---------------
+
+// ------------------------------------------------------------------------------
+
+Window::Window( const uno::Reference< lang::XMultiServiceFactory >& rxMgr, Player& rPlayer ) :
+ mxMgr( rxMgr ),
+ maListeners( maMutex ),
+ meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ),
+ mrPlayer( rPlayer ),
+ mnPointerType( awt::SystemPointer::ARROW )
+{
+ ::osl::MutexGuard aGuard( ImplGetOwnStaticMutex() );
+
+}
+
+// ------------------------------------------------------------------------------
+
+Window::~Window()
+{
+}
+
+// XPlayerWindow
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::update( )
+ throw (uno::RuntimeException)
+{
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Window::setZoomLevel( media::ZoomLevel eZoomLevel )
+ throw (uno::RuntimeException)
+{
+ sal_Bool bRet = false;
+
+ if( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel &&
+ media::ZoomLevel_NOT_AVAILABLE != eZoomLevel )
+ {
+ if( eZoomLevel != meZoomLevel )
+ {
+ meZoomLevel = eZoomLevel;
+ }
+
+ 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;
+}
+
+// XWindow
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setPosSize( sal_Int32 /*X*/, sal_Int32 /*Y*/, sal_Int32 /*Width*/, sal_Int32 /*Height*/, sal_Int16 /*Flags*/ )
+ throw (uno::RuntimeException)
+{
+}
+
+// ------------------------------------------------------------------------------
+
+awt::Rectangle SAL_CALL Window::getPosSize()
+ throw (uno::RuntimeException)
+{
+ awt::Rectangle aRet;
+
+ aRet.X = aRet.Y = 0;
+ aRet.Width = 320;
+ aRet.Height = 240;
+
+ return aRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setVisible( sal_Bool /*bVisible*/ )
+ throw (uno::RuntimeException)
+{
+
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setEnable( sal_Bool /*bEnable*/ )
+ throw (uno::RuntimeException)
+{
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setFocus( )
+ throw (uno::RuntimeException)
+{
+}
+
+// ------------------------------------------------------------------------------
+
+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 );
+}
+
+// XComponent
+// ------------------------------------------------------------------------------
+
+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 );
+}
+
+// XServiceInfo
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL Window::getImplementationName( )
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_GST_WINDOW_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Window::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_GST_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_GST_WINDOW_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace gstreamer
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/gstreamer/gstwindow.hxx b/avmedia/source/gstreamer/gstwindow.hxx
new file mode 100644
index 000000000000..18b9a7dbd0ae
--- /dev/null
+++ b/avmedia/source/gstreamer/gstwindow.hxx
@@ -0,0 +1,111 @@
+/* -*- 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 2010 Novell, Inc.
+ *
+ * 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 "gstcommon.hxx"
+#include <cppuhelper/interfacecontainer.h>
+
+#include "com/sun/star/media/XPlayerWindow.hdl"
+
+namespace avmedia { namespace gstreamer {
+
+// ---------------
+// - 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);
+
+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 mnPointerType;
+
+ void ImplLayoutVideoWindow();
+};
+
+} // namespace gstreamer
+} // namespace avmedia
+
+#endif // _WINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/gstreamer/makefile.mk b/avmedia/source/gstreamer/makefile.mk
new file mode 100755
index 000000000000..0bea1330a099
--- /dev/null
+++ b/avmedia/source/gstreamer/makefile.mk
@@ -0,0 +1,88 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2010 Novell, Inc.
+#
+# 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=avmediagst
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(ENABLE_GSTREAMER)" == "TRUE"
+
+.IF "$(verbose)"!="" || "$(VERBOSE)"!=""
+CDEFS+= -DVERBOSE
+.ENDIF
+
+PKGCONFIG_MODULES=gstreamer-0.10, gstreamer-plugins-base-0.10
+.INCLUDE: pkg_config.mk
+PKGCONFIG_LIBS+=-lgstinterfaces-0.10
+
+# --- Files ----------------------------------
+
+.IF "$(GUI)" == "UNX" || "$(GUI)" == "WNT"
+
+.IF "$(GUI)" == "WNT"
+CDEFS+= -DWINNT
+.ENDIF
+
+SLOFILES= \
+ $(SLO)$/gstuno.obj \
+ $(SLO)$/gstmanager.obj \
+ $(SLO)$/gstplayer.obj \
+ $(SLO)$/gstwindow.obj
+
+
+EXCEPTIONSFILES= \
+ $(SLO)$/gstuno.obj \
+
+SHL1TARGET=$(TARGET)
+SHL1STDLIBS= $(CPPULIB) $(SALLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(PKGCONFIG_LIBS) $(TOOLSLIB) $(VCLLIB)
+SHL1IMPLIB=i$(TARGET)
+SHL1LIBS=$(SLB)$/$(TARGET).lib
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=exports.dxp
+
+.ENDIF # UNX / WNT
+.ENDIF # ENABLE_GSTREAMER
+
+.INCLUDE : target.mk
+
+.IF "$(ENABLE_GSTREAMER)" == "TRUE"
+.IF "$(GUI)" == "UNX" || "$(GUI)" == "WNT"
+
+ALLTAR : $(MISC)/avmediagstreamer.component
+$(MISC)/avmediagstreamer.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt avmediagstreamer.component
+ $(XSLTPROC) --nonet \
+ --stringparam uri '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' \
+ -o $@ $(SOLARENV)/bin/createcomponent.xslt avmediagstreamer.component
+
+.ENDIF # UNX / WNT
+.ENDIF # ENABLE_GSTREAMER
diff --git a/avmedia/source/inc/mediamisc.hxx b/avmedia/source/inc/mediamisc.hxx
new file mode 100644
index 000000000000..85e14abf9fb2
--- /dev/null
+++ b/avmedia/source/inc/mediamisc.hxx
@@ -0,0 +1,70 @@
+/* -*- 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.
+ *
+ ************************************************************************/
+
+class ResMgr;
+
+#define AVMEDIA_RESID( nId ) ResId( nId, * ::avmedia::GetResMgr() )
+
+#ifdef GSTREAMER
+#define AVMEDIA_MANAGER_SERVICE_NAME "com.sun.star.media.Manager_GStreamer"
+#else
+#ifdef WNT
+
+#define AVMEDIA_MANAGER_SERVICE_NAME "com.sun.star.comp.avmedia.Manager_DirectX"
+#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED sal_False
+
+#define AVMEDIA_MANAGER_SERVICE_NAME_FALLBACK1 ""
+#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED_FALLBACK1 sal_False
+
+#else
+#ifdef QUARTZ
+
+#define AVMEDIA_MANAGER_SERVICE_NAME "com.sun.star.comp.avmedia.Manager_QuickTime"
+#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED sal_False
+
+#define AVMEDIA_MANAGER_SERVICE_NAME_FALLBACK1 ""
+#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED_FALLBACK1 sal_False
+
+#else
+
+#define AVMEDIA_MANAGER_SERVICE_NAME "com.sun.star.comp.avmedia.Manager_GStreamer"
+#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED sal_False
+
+#define AVMEDIA_MANAGER_SERVICE_NAME_FALLBACK1 "com.sun.star.comp.avmedia.Manager_Java"
+#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED_FALLBACK1 sal_True
+
+#endif
+#endif
+#endif
+
+namespace avmedia
+{
+ ResMgr* GetResMgr();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/java/FrameGrabber.java b/avmedia/source/java/FrameGrabber.java
new file mode 100755
index 000000000000..1a0deda4ce57
--- /dev/null
+++ b/avmedia/source/java/FrameGrabber.java
@@ -0,0 +1,190 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.IQueryInterface;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XEventListener;
+import com.sun.star.awt.*;
+import com.sun.star.media.*;
+import com.sun.star.graphic.*;
+
+// -----------------
+// - Player Window -
+// -----------------
+
+public class FrameGrabber implements com.sun.star.lang.XServiceInfo,
+ com.sun.star.media.XFrameGrabber
+{
+ private com.sun.star.lang.XMultiServiceFactory maFactory = null;
+ private javax.media.Player maPlayer = null;
+ private javax.media.control.FrameGrabbingControl maFrameGrabbingControl = null;
+
+ // -------------------------------------------------------------------------
+
+ public FrameGrabber( com.sun.star.lang.XMultiServiceFactory aFactory, String aURL )
+ {
+ maFactory = aFactory;
+
+ try
+ {
+ maPlayer = javax.media.Manager.createRealizedPlayer( new java.net.URL( aURL ) );
+ }
+ catch( java.net.MalformedURLException e )
+ {
+ }
+ catch( java.io.IOException e )
+ {
+ }
+ catch( javax.media.NoPlayerException e )
+ {
+ }
+ catch( javax.media.CannotRealizeException e )
+ {
+ }
+ catch( java.lang.Exception e )
+ {
+ }
+
+ if( maPlayer != null )
+ {
+ maFrameGrabbingControl = (javax.media.control.FrameGrabbingControl) maPlayer.getControl(
+ "javax.media.control.FrameGrabbingControl" );
+ }
+ }
+
+ // -------------------------------------------------------------------------
+
+ public com.sun.star.graphic.XGraphic implImageToXGraphic( java.awt.Image aImage )
+ {
+ com.sun.star.graphic.XGraphic aRet = null;
+
+ if( maFactory != null && aImage != null )
+ {
+ if( aImage instanceof java.awt.image.BufferedImage )
+ {
+ java.io.File aTempFile = null;
+
+ try
+ {
+ aTempFile = java.io.File.createTempFile( "sv0", ".png" );
+
+ if( aTempFile.canWrite() )
+ {
+ javax.imageio.ImageIO.write( (java.awt.image.BufferedImage) aImage, "png", aTempFile );
+
+ com.sun.star.graphic.XGraphicProvider aProvider =
+ (com.sun.star.graphic.XGraphicProvider) UnoRuntime.queryInterface(
+ com.sun.star.graphic.XGraphicProvider.class,
+ maFactory.createInstance("com.sun.star.graphic.GraphicProvider") );
+
+ if( aProvider != null )
+ {
+ com.sun.star.beans.PropertyValue[] aArgs = new com.sun.star.beans.PropertyValue[ 1 ];
+
+ aArgs[ 0 ] = new com.sun.star.beans.PropertyValue();
+ aArgs[ 0 ].Name = "URL";
+ aArgs[ 0 ].Value = "file://" + aTempFile.toString();
+
+ aRet = aProvider.queryGraphic( aArgs );
+ }
+ }
+ }
+ catch( java.lang.IllegalArgumentException aExcp )
+ {
+ }
+ catch( java.io.IOException aExcp )
+ {
+ }
+ catch( com.sun.star.uno.Exception aExcp )
+ {
+ }
+
+ if( aTempFile != null )
+ aTempFile.delete();
+ }
+ }
+
+ return aRet;
+ }
+
+ // -----------------
+ // - XFrameGrabber -
+ // -----------------
+
+ public synchronized com.sun.star.graphic.XGraphic grabFrame( double fMediaTime )
+ {
+ com.sun.star.graphic.XGraphic aRet = null;
+
+ if( maFrameGrabbingControl != null )
+ {
+ if( fMediaTime >= 0.0 && fMediaTime <= maPlayer.getDuration().getSeconds() )
+ {
+ maPlayer.setMediaTime( new javax.media.Time( fMediaTime ) );
+
+ javax.media.Buffer aBuffer = maFrameGrabbingControl.grabFrame();
+
+ if( aBuffer != null && aBuffer.getFormat() instanceof javax.media.format.VideoFormat )
+ {
+ aRet = implImageToXGraphic( new javax.media.util.BufferToImage(
+ (javax.media.format.VideoFormat) aBuffer.getFormat() ).
+ createImage( aBuffer ) );
+ }
+ }
+ }
+
+ return aRet;
+ }
+
+ // ----------------
+ // - XServiceInfo -
+ // ----------------
+
+ private static final String s_implName = "com.sun.star.comp.FrameGrabber_Java";
+ private static final String s_serviceName = "com.sun.star.media.FrameGrabber_Java";
+
+ public synchronized String getImplementationName()
+ {
+ return s_implName;
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized String [] getSupportedServiceNames()
+ {
+ return new String [] { s_serviceName };
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized boolean supportsService( String serviceName )
+ {
+ return serviceName.equals( s_serviceName );
+ }
+}
diff --git a/avmedia/source/java/Manager.java b/avmedia/source/java/Manager.java
new file mode 100755
index 000000000000..47707478fd5b
--- /dev/null
+++ b/avmedia/source/java/Manager.java
@@ -0,0 +1,148 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// UNO
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.IQueryInterface;
+import com.sun.star.lang.XInitialization;
+
+// media
+import com.sun.star.media.*;
+
+public class Manager implements com.sun.star.lang.XServiceInfo,
+ com.sun.star.lang.XTypeProvider,
+ com.sun.star.media.XManager
+
+{
+ private com.sun.star.lang.XMultiServiceFactory maFactory;
+
+ // -------------------------------------------------------------------------
+
+ public Manager( com.sun.star.lang.XMultiServiceFactory aFactory )
+ {
+ maFactory = aFactory;
+ }
+
+ // ------------
+ // - XManager -
+ // ------------
+
+ public com.sun.star.media.XPlayer createPlayer( String aURL )
+ {
+ javax.media.Player aPlayer = null;
+
+ try
+ {
+ aPlayer = javax.media.Manager.createRealizedPlayer( new java.net.URL( aURL ) );
+ }
+ catch( java.net.MalformedURLException e )
+ {
+ }
+ catch( java.io.IOException e )
+ {
+ }
+ catch( javax.media.NoPlayerException e )
+ {
+ }
+ catch( javax.media.CannotRealizeException e )
+ {
+ }
+ catch( java.lang.Exception e )
+ {
+ }
+
+ if( aPlayer != null )
+ {
+ return new Player( maFactory, aPlayer, aURL );
+ }
+ else
+ return null;
+ }
+
+ // ----------------
+ // - XServiceInfo -
+ // ----------------
+
+ private static final String s_implName = "com.sun.star.comp.media.Manager_Java";
+ private static final String s_serviceName = "com.sun.star.media.Manager_Java";
+
+ public synchronized String getImplementationName()
+ {
+ return s_implName;
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized String [] getSupportedServiceNames()
+ {
+ return new String [] { s_serviceName };
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized boolean supportsService( String serviceName )
+ {
+ return serviceName.equals( s_serviceName );
+ }
+
+ // -----------------
+ // - XTypeProvider -
+ // -----------------
+ protected byte[] maImplementationId;
+
+ public com.sun.star.uno.Type[] getTypes()
+ {
+ com.sun.star.uno.Type[] retValue = new com.sun.star.uno.Type[ 3 ];
+
+ retValue[ 0 ]= new com.sun.star.uno.Type( com.sun.star.lang.XServiceInfo.class );
+ retValue[ 1 ]= new com.sun.star.uno.Type( com.sun.star.lang.XTypeProvider.class );
+ retValue[ 2 ]= new com.sun.star.uno.Type( com.sun.star.media.XManager.class );
+
+ return retValue;
+ }
+
+ // -------------------------------------------------------------------------
+
+ synchronized public byte[] getImplementationId()
+ {
+ if( maImplementationId == null)
+ {
+ maImplementationId = new byte[ 16 ];
+
+ int hash = hashCode();
+
+ maImplementationId[ 0 ] = (byte)(hash & 0xff);
+ maImplementationId[ 1 ] = (byte)((hash >>> 8) & 0xff);
+ maImplementationId[ 2 ] = (byte)((hash >>> 16) & 0xff);
+ maImplementationId[ 3 ] = (byte)((hash >>>24) & 0xff);
+ }
+
+ return maImplementationId;
+ }
+}
diff --git a/avmedia/source/java/MediaUno.java b/avmedia/source/java/MediaUno.java
new file mode 100755
index 000000000000..3e4387840741
--- /dev/null
+++ b/avmedia/source/java/MediaUno.java
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// UNO
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.IQueryInterface;
+import com.sun.star.lang.XInitialization;
+
+public class MediaUno
+{
+ private static final String s_implName = "com.sun.star.comp.media.Manager_Java";
+ private static final String s_serviceName = "com.sun.star.media.Manager_Java";
+
+ // -------------------------------------------------------------------------
+
+ public MediaUno()
+ {
+ }
+
+ // -------------------------------------------------------------------------
+
+ public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(
+ String implName,
+ com.sun.star.lang.XMultiServiceFactory multiFactory,
+ com.sun.star.registry.XRegistryKey regKey )
+ {
+ if (implName.equals( s_implName ))
+ {
+ try
+ {
+ return com.sun.star.comp.loader.FactoryHelper.getServiceFactory(
+ Class.forName( "Manager" ), s_serviceName, multiFactory, regKey );
+ }
+ catch( java.lang.ClassNotFoundException exception )
+ {
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/avmedia/source/java/Player.java b/avmedia/source/java/Player.java
new file mode 100755
index 000000000000..be3b3d62d367
--- /dev/null
+++ b/avmedia/source/java/Player.java
@@ -0,0 +1,325 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// UNO
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.IQueryInterface;
+import com.sun.star.lang.XInitialization;
+
+// awt
+import com.sun.star.awt.*;
+
+// media
+import com.sun.star.media.*;
+
+public class Player implements javax.media.ControllerListener,
+ com.sun.star.lang.XServiceInfo,
+ com.sun.star.media.XPlayer,
+ com.sun.star.lang.XComponent
+
+
+{
+ private com.sun.star.lang.XMultiServiceFactory maFactory;
+ private String maURL;
+ private javax.media.Player maPlayer;
+ private javax.media.GainControl maGainControl;
+ private boolean mbStarted = false;
+ private boolean mbLooping = false;
+
+ // -------------------------------------------------------------------------
+
+ public Player( com.sun.star.lang.XMultiServiceFactory aFactory,
+ javax.media.Player aPlayer, String aURL )
+ {
+ maFactory = aFactory;
+ maURL = aURL;
+ maPlayer = aPlayer;
+ maPlayer.addControllerListener( this );
+ maGainControl = maPlayer.getGainControl();
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void controllerUpdate( javax.media.ControllerEvent aEvt )
+ {
+ if( aEvt instanceof javax.media.EndOfMediaEvent ||
+ aEvt instanceof javax.media.StopAtTimeEvent )
+ {
+ mbStarted = false;
+
+ if( mbLooping )
+ {
+ setMediaTime( 0.0 );
+ start();
+ }
+ else if( aEvt instanceof javax.media.EndOfMediaEvent )
+ setMediaTime( getDuration() );
+ }
+ }
+
+ // -----------
+ // - XPlayer -
+ // -----------
+
+ public synchronized void start()
+ {
+ if( !mbStarted )
+ {
+ maPlayer.start();
+ mbStarted = true;
+ }
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void stop()
+ {
+ if( mbStarted )
+ {
+ maPlayer.stop();
+ mbStarted = false;
+ }
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized boolean isPlaying()
+ {
+ return mbStarted;
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized double getDuration()
+ {
+ return maPlayer.getDuration().getSeconds();
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void setMediaTime( double fTime )
+ {
+ if( fTime >= 0.0 && fTime <= getDuration() )
+ maPlayer.setMediaTime( new javax.media.Time( fTime ) );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized double getMediaTime()
+ {
+ return maPlayer.getMediaTime().getSeconds();
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void setStopTime( double fTime )
+ {
+ boolean bOldStarted = mbStarted;
+
+ if( mbStarted )
+ stop();
+
+ maPlayer.setStopTime( new javax.media.Time( fTime ) );
+
+ if( bOldStarted )
+ start();
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized double getStopTime()
+ {
+ return maPlayer.getStopTime().getSeconds();
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void setRate( double fRate )
+ {
+ boolean bOldStarted = mbStarted;
+
+ if( mbStarted )
+ stop();
+
+ maPlayer.setRate( (float) fRate );
+
+ if( bOldStarted )
+ start();
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized double getRate()
+ {
+ return (double) maPlayer.getRate();
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void setPlaybackLoop( boolean bSet )
+ {
+ mbLooping = bSet;
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized boolean isPlaybackLoop()
+ {
+ return mbLooping;
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void setVolumeDB( short nVolumeDB )
+ {
+ if( maGainControl != null )
+ maGainControl.setDB( nVolumeDB );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized short getVolumeDB()
+ {
+ return( maGainControl != null ? (short) maGainControl.getDB() : 0 );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void setMute( boolean bSet )
+ {
+ if( maGainControl != null )
+ maGainControl.setMute( bSet );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized boolean isMute()
+ {
+ return( maGainControl != null ? maGainControl.getMute() : false );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized com.sun.star.awt.Size getPreferredPlayerWindowSize()
+ {
+ java.awt.Component aVisualComponent = maPlayer.getVisualComponent();
+ com.sun.star.awt.Size aSize = new com.sun.star.awt.Size( 0, 0 );
+
+ if( aVisualComponent != null )
+ {
+ java.awt.Dimension aDim = aVisualComponent.getPreferredSize();
+
+ aSize.Width = Math.max( aDim.width, 0 );
+ aSize.Height = Math.max( aDim.height, 0 );
+ }
+
+ return aSize;
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized com.sun.star.media.XPlayerWindow createPlayerWindow( java.lang.Object[] aArgs )
+ {
+ try
+ {
+ com.sun.star.media.XPlayerWindow xPlayerWindow = ( ( ( aArgs.length > 1 ) && ( AnyConverter.toInt( aArgs[ 0 ] ) > 0 ) ) ?
+ new PlayerWindow( maFactory, aArgs, maPlayer ) :
+ null );
+
+ // check if it is a real player window (video window)
+ if( xPlayerWindow != null && xPlayerWindow.getZoomLevel() == com.sun.star.media.ZoomLevel.NOT_AVAILABLE )
+ xPlayerWindow = null;
+
+ return xPlayerWindow;
+ }
+ catch( com.sun.star.lang.IllegalArgumentException e )
+ {
+ return null;
+ }
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized com.sun.star.media.XFrameGrabber createFrameGrabber()
+ {
+ return( (com.sun.star.media.XFrameGrabber) new FrameGrabber( maFactory, maURL ) );
+ }
+
+ // --------------
+ // - XComponent -
+ // --------------
+
+ public synchronized void addEventListener( com.sun.star.lang.XEventListener xListener )
+ {
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void removeEventListener( com.sun.star.lang.XEventListener xListener )
+ {
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void dispose()
+ {
+ if( maPlayer != null )
+ {
+ maPlayer.stop();
+ maPlayer.close();
+ maPlayer = null;
+ }
+ }
+
+ // ----------------
+ // - XServiceInfo -
+ // ----------------
+
+ private static final String s_implName = "com.sun.star.comp.Player_Java";
+ private static final String s_serviceName = "com.sun.star.media.Player_Java";
+
+ public synchronized String getImplementationName()
+ {
+ return s_implName;
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized String [] getSupportedServiceNames()
+ {
+ return new String [] { s_serviceName };
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized boolean supportsService( String serviceName )
+ {
+ return serviceName.equals( s_serviceName );
+ }
+}
diff --git a/avmedia/source/java/PlayerWindow.java b/avmedia/source/java/PlayerWindow.java
new file mode 100755
index 000000000000..2229e4f1644b
--- /dev/null
+++ b/avmedia/source/java/PlayerWindow.java
@@ -0,0 +1,600 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.IQueryInterface;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XEventListener;
+import com.sun.star.awt.*;
+import com.sun.star.media.*;
+
+// -----------------
+// - Player Window -
+// -----------------
+
+public class PlayerWindow implements java.awt.event.KeyListener,
+ java.awt.event.MouseListener,
+ java.awt.event.MouseMotionListener,
+ java.awt.event.FocusListener,
+ com.sun.star.lang.XServiceInfo,
+ com.sun.star.media.XPlayerWindow
+{
+ private com.sun.star.lang.XMultiServiceFactory maFactory;
+ private WindowAdapter maFrame;
+ private javax.media.Player maPlayer;
+ private com.sun.star.media.ZoomLevel meZoomLevel = com.sun.star.media.ZoomLevel.ORIGINAL;
+ private boolean mbShowControls = false;
+
+
+ // -------------------------------------------------------------------------
+
+ public PlayerWindow( com.sun.star.lang.XMultiServiceFactory aFactory,
+ java.lang.Object[] aArgs, javax.media.Player aPlayer )
+ {
+ maFactory = aFactory;
+
+ try
+ {
+ if( aArgs.length > 1 )
+ {
+ com.sun.star.awt.Rectangle aBoundRect = (com.sun.star.awt.Rectangle) aArgs[ 1 ];
+
+ maFrame = new WindowAdapter( AnyConverter.toInt( aArgs[ 0 ] ) );
+ maFrame.setPosSize( aBoundRect.X, aBoundRect.Y, aBoundRect.Width, aBoundRect.Height, (short) 0 );
+ mbShowControls = false;
+
+ java.awt.Panel aPanel = new java.awt.Panel( new java.awt.BorderLayout() );
+
+ aPanel.setLayout( null );
+ aPanel.setBackground( java.awt.Color.black );
+ aPanel.addKeyListener( this );
+ aPanel.addMouseListener( this );
+ aPanel.addMouseMotionListener( this );
+
+ if( mbShowControls )
+ {
+ java.awt.Component aControlComponent = aPlayer.getControlPanelComponent();
+
+ if( aControlComponent != null )
+ aPanel.add( aControlComponent );
+ else
+ mbShowControls = false;
+ }
+
+ java.awt.Component aVisualComponent = aPlayer.getVisualComponent();
+
+ if( aVisualComponent != null )
+ {
+ aVisualComponent.addKeyListener( this );
+ aVisualComponent.addMouseListener( this );
+ aVisualComponent.addMouseMotionListener( this );
+ aVisualComponent.addFocusListener( this );
+ aPanel.add( aVisualComponent );
+ }
+ else
+ meZoomLevel = com.sun.star.media.ZoomLevel.NOT_AVAILABLE;
+
+ if( maFrame.getJavaFrame() != null )
+ maFrame.getJavaFrame().add( aPanel );
+
+ LayoutComponents();
+ }
+ }
+ catch( com.sun.star.lang.IllegalArgumentException e )
+ {
+ }
+ }
+
+ // -------------------------------------------------------------------------
+
+ protected synchronized void LayoutComponents()
+ {
+ if( maFrame.getJavaFrame() != null )
+ {
+ java.awt.Panel aPanel = (java.awt.Panel) maFrame.getJavaFrame().getComponent( 0 );
+ int nW = maFrame.getJavaFrame().getWidth();
+ int nH = maFrame.getJavaFrame().getHeight();
+ int nControlH = 0;
+
+ aPanel.setBounds( 0, 0, nW, nH );
+
+ if( mbShowControls )
+ {
+ java.awt.Component aControlComponent = aPanel.getComponent( 0 );
+
+ if( aControlComponent != null )
+ {
+ java.awt.Dimension aControlDimension = aControlComponent.getPreferredSize();
+
+ nControlH = Math.min( nH, aControlDimension.height );
+ aControlComponent.setBounds( 0, nH - nControlH, nW, nControlH );
+ }
+ }
+
+ if( com.sun.star.media.ZoomLevel.NOT_AVAILABLE != meZoomLevel )
+ {
+ java.awt.Component aVisualComponent = aPanel.getComponent( mbShowControls ? 1 : 0 );
+
+ if( aVisualComponent != null )
+ {
+ java.awt.Dimension aPrefDim = aVisualComponent.getPreferredSize();
+ int nVideoW = nW, nVideoH = ( nH - nControlH );
+ int nX = 0, nY = 0, nWidth = 0, nHeight = 0;
+ boolean bDone = false, bZoom = false;
+
+ if( com.sun.star.media.ZoomLevel.ORIGINAL == meZoomLevel )
+ {
+ bZoom = true;
+ }
+ else if( com.sun.star.media.ZoomLevel.ZOOM_1_TO_4 == meZoomLevel )
+ {
+ aPrefDim.width >>= 2;
+ aPrefDim.height >>= 2;
+ bZoom = true;
+ }
+ else if( com.sun.star.media.ZoomLevel.ZOOM_1_TO_2 == meZoomLevel )
+ {
+ aPrefDim.width >>= 1;
+ aPrefDim.height >>= 1;
+ bZoom = true;
+ }
+ else if( com.sun.star.media.ZoomLevel.ZOOM_2_TO_1 == meZoomLevel )
+ {
+ aPrefDim.width <<= 1;
+ aPrefDim.height <<= 1;
+ bZoom = true;
+ }
+ else if( com.sun.star.media.ZoomLevel.ZOOM_4_TO_1 == meZoomLevel )
+ {
+ aPrefDim.width <<= 2;
+ aPrefDim.height <<= 2;
+ bZoom = true;
+ }
+ else if( com.sun.star.media.ZoomLevel.FIT_TO_WINDOW == meZoomLevel )
+ {
+ nWidth = nVideoW;
+ nHeight = nVideoH;
+ bDone = true;
+ }
+
+ if( bZoom )
+ {
+ if( ( aPrefDim.width <= nVideoW ) && ( aPrefDim.height <= nVideoH ) )
+ {
+ nX = ( nVideoW - aPrefDim.width ) >> 1;
+ nY = ( nVideoH - aPrefDim.height ) >> 1;
+ nWidth = aPrefDim.width;
+ nHeight = aPrefDim.height;
+ bDone = true;
+ }
+ }
+
+ if( !bDone )
+ {
+ if( aPrefDim.width > 0 && aPrefDim.height > 0 && nVideoW > 0 && nVideoH > 0 )
+ {
+ double fPrefWH = (double) aPrefDim.width / aPrefDim.height;
+
+ if( fPrefWH < ( (double) nVideoW / nVideoH ) )
+ nVideoW = (int)( nVideoH * fPrefWH );
+ else
+ nVideoH = (int)( nVideoW / fPrefWH );
+
+ nX = ( nW - nVideoW ) >> 1;
+ nY = ( nH - nControlH - nVideoH ) >> 1;
+ nWidth = nVideoW;
+ nHeight = nVideoH;
+ }
+ else
+ nX = nY = nWidth = nHeight = 0;
+ }
+
+ aVisualComponent.setBounds( nX, nY, nWidth, nHeight );
+ aVisualComponent.requestFocus();
+ }
+ else
+ aPanel.requestFocus();
+ }
+ else
+ aPanel.requestFocus();
+ }
+ }
+
+ // -------------------------------------------------------------------------
+
+ private void implFireMouseEvent( java.awt.event.MouseEvent aEvt )
+ {
+ if( aEvt.getSource() != null &&
+ aEvt.getSource() instanceof java.awt.Component )
+ {
+ aEvt.translatePoint( ( (java.awt.Component) aEvt.getSource() ).getX(),
+ ( (java.awt.Component) aEvt.getSource() ).getY() );
+ }
+
+ maFrame.fireMouseEvent( aEvt );
+ }
+
+ // ---------------
+ // - KeyListener -
+ // ---------------
+
+ public void keyPressed( java.awt.event.KeyEvent aEvt )
+ {
+ maFrame.fireKeyEvent( aEvt );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public void keyReleased( java.awt.event.KeyEvent aEvt )
+ {
+ maFrame.fireKeyEvent( aEvt );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public void keyTyped( java.awt.event.KeyEvent aEvt )
+ {
+ maFrame.fireKeyEvent( aEvt );
+ }
+
+ // -----------------
+ // - MouseListener -
+ // -----------------
+
+ public void mousePressed( java.awt.event.MouseEvent aEvt )
+ {
+ implFireMouseEvent( aEvt );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public void mouseClicked( java.awt.event.MouseEvent aEvt )
+ {
+ implFireMouseEvent( aEvt );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public void mouseEntered( java.awt.event.MouseEvent aEvt )
+ {
+ implFireMouseEvent( aEvt );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public void mouseExited( java.awt.event.MouseEvent aEvt )
+ {
+ implFireMouseEvent( aEvt );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public void mouseReleased( java.awt.event.MouseEvent aEvt )
+ {
+ implFireMouseEvent( aEvt );
+ }
+
+ // -----------------------
+ // - MouseMotionListener -
+ // -----------------------
+
+ public void mouseDragged( java.awt.event.MouseEvent aEvt )
+ {
+ implFireMouseEvent( aEvt );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public void mouseMoved( java.awt.event.MouseEvent aEvt )
+ {
+ implFireMouseEvent( aEvt );
+ }
+
+ // -----------------------
+ // - FocusListener -
+ // -----------------------
+
+ public void focusGained( java.awt.event.FocusEvent aEvt )
+ {
+ if( maFrame.getJavaFrame() != null )
+ maFrame.fireFocusEvent( aEvt );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public void focusLost( java.awt.event.FocusEvent aEvt )
+ {
+ if( maFrame.getJavaFrame() != null )
+ maFrame.fireFocusEvent( aEvt );
+ }
+
+ // -----------------
+ // - XPlayerWindow -
+ // -----------------
+
+ public synchronized void update()
+ {
+ if( maFrame.getJavaFrame() != null )
+ maFrame.getJavaFrame().repaint();
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized boolean setZoomLevel( com.sun.star.media.ZoomLevel eZoomLevel )
+ {
+ boolean bRet = false;
+
+ if( com.sun.star.media.ZoomLevel.NOT_AVAILABLE != meZoomLevel &&
+ com.sun.star.media.ZoomLevel.NOT_AVAILABLE != eZoomLevel )
+ {
+ if( eZoomLevel != meZoomLevel )
+ {
+ meZoomLevel = eZoomLevel;
+ LayoutComponents();
+ }
+
+ bRet = true;
+ }
+
+ return bRet;
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized com.sun.star.media.ZoomLevel getZoomLevel()
+ {
+ return meZoomLevel;
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void setPointerType( int nPointerType )
+ {
+ if( maFrame.getJavaFrame() != null )
+ {
+ int nCursor;
+
+ switch( nPointerType )
+ {
+ case( com.sun.star.awt.SystemPointer.CROSS ): nCursor = java.awt.Cursor.CROSSHAIR_CURSOR; break;
+ case( com.sun.star.awt.SystemPointer.HAND ): nCursor = java.awt.Cursor.HAND_CURSOR; break;
+ case( com.sun.star.awt.SystemPointer.MOVE ): nCursor = java.awt.Cursor.MOVE_CURSOR; break;
+ case( com.sun.star.awt.SystemPointer.WAIT ): nCursor = java.awt.Cursor.WAIT_CURSOR; break;
+
+ default: nCursor = java.awt.Cursor.DEFAULT_CURSOR; break;
+ }
+
+ maFrame.getJavaFrame().setCursor( java.awt.Cursor.getPredefinedCursor( nCursor ) );
+ }
+ }
+
+ // --------------
+ // - XComponent -
+ // --------------
+
+ public synchronized void dispose()
+ {
+ if( maFrame != null )
+ {
+ java.awt.Panel aPanel = (java.awt.Panel) maFrame.getJavaFrame().getComponent( 0 );
+
+ if( aPanel != null && aPanel.getComponent( 0 ) != null )
+ aPanel.getComponent( 0 ).removeFocusListener( this );
+
+ if( maFrame.getJavaFrame() != null )
+ maFrame.getJavaFrame().dispose();
+
+ maFrame.fireDisposingEvent();
+ }
+
+ maFrame = null;
+ }
+
+ // -----------
+ // - XWindow -
+ // -----------
+
+ public synchronized void setPosSize( int X, int Y, int Width, int Height, short Flags )
+ {
+ if( maFrame != null )
+ {
+ maFrame.setPosSize( X, Y, Width, Height, Flags );
+ LayoutComponents();
+ }
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized com.sun.star.awt.Rectangle getPosSize()
+ {
+ return( ( maFrame != null ) ? maFrame.getPosSize() : new com.sun.star.awt.Rectangle() );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void setVisible( boolean visible )
+ {
+ if( maFrame != null )
+ maFrame.setVisible( visible );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void setEnable( boolean enable )
+ {
+ if( maFrame != null )
+ maFrame.setEnable( enable );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void setFocus()
+ {
+ if( maFrame != null )
+ maFrame.setFocus();
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void addEventListener( com.sun.star.lang.XEventListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.addEventListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void removeEventListener( com.sun.star.lang.XEventListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.removeEventListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void addWindowListener( XWindowListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.addWindowListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void removeWindowListener( XWindowListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.removeWindowListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void addFocusListener( XFocusListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.addFocusListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void removeFocusListener( XFocusListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.removeFocusListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void addKeyListener( XKeyListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.addKeyListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void removeKeyListener( XKeyListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.removeKeyListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void addMouseListener( XMouseListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.addMouseListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void removeMouseListener( XMouseListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.removeMouseListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void addMouseMotionListener( XMouseMotionListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.addMouseMotionListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void removeMouseMotionListener( XMouseMotionListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.removeMouseMotionListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void addPaintListener( XPaintListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.addPaintListener( xListener );
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized void removePaintListener( XPaintListener xListener )
+ {
+ if( maFrame != null )
+ maFrame.removePaintListener( xListener );
+ }
+
+ // ----------------
+ // - XServiceInfo -
+ // ----------------
+
+ private static final String s_implName = "com.sun.star.comp.PlayerWindow_Java";
+ private static final String s_serviceName = "com.sun.star.media.PlayerWindow_Java";
+
+ public synchronized String getImplementationName()
+ {
+ return s_implName;
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized String [] getSupportedServiceNames()
+ {
+ return new String [] { s_serviceName };
+ }
+
+ // -------------------------------------------------------------------------
+
+ public synchronized boolean supportsService( String serviceName )
+ {
+ return serviceName.equals( s_serviceName );
+ }
+}
diff --git a/avmedia/source/java/WindowAdapter.java b/avmedia/source/java/WindowAdapter.java
new file mode 100755
index 000000000000..e44d9e4c9c0b
--- /dev/null
+++ b/avmedia/source/java/WindowAdapter.java
@@ -0,0 +1,496 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+import sun.awt.*;
+import com.sun.star.awt.*;
+import com.sun.star.lang.*;
+import java.util.*;
+import javax.swing.*;
+
+public class WindowAdapter
+{
+ private java.awt.Frame maFrame;
+ private LinkedList maEventListeners = new LinkedList();
+ private LinkedList maWindowListeners = new LinkedList();
+ private LinkedList maFocusListeners = new LinkedList();
+ private LinkedList maKeyListeners = new LinkedList();
+ private LinkedList maMouseListeners = new LinkedList();
+ private LinkedList maMouseMotionListeners = new LinkedList();
+ private LinkedList maPaintListeners = new LinkedList();
+ private boolean mbShift = false, mbMod1 = false, mbMod2 = false;
+
+ // -----------------
+ // - WindowAdapter -
+ // -----------------
+
+ public WindowAdapter( int windowHandle )
+ {
+ maFrame = SystemWindowAdapter.createFrame( windowHandle );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public java.awt.Frame getJavaFrame()
+ {
+ return maFrame;
+ }
+
+ //----------------------------------------------------------------------------------
+
+ private short implGetUNOKeyCode( int nJavaKeyCode )
+ {
+ short nRet = 0;
+
+ switch( nJavaKeyCode )
+ {
+ case( java.awt.event.KeyEvent.VK_NUMPAD0 ):
+ case( java.awt.event.KeyEvent.VK_0 ): nRet = com.sun.star.awt.Key.NUM0; break;
+ case( java.awt.event.KeyEvent.VK_NUMPAD1 ):
+ case( java.awt.event.KeyEvent.VK_1 ): nRet = com.sun.star.awt.Key.NUM1; break;
+ case( java.awt.event.KeyEvent.VK_NUMPAD2 ):
+ case( java.awt.event.KeyEvent.VK_2 ): nRet = com.sun.star.awt.Key.NUM2; break;
+ case( java.awt.event.KeyEvent.VK_NUMPAD3 ):
+ case( java.awt.event.KeyEvent.VK_3 ): nRet = com.sun.star.awt.Key.NUM3; break;
+ case( java.awt.event.KeyEvent.VK_NUMPAD4 ):
+ case( java.awt.event.KeyEvent.VK_4 ): nRet = com.sun.star.awt.Key.NUM4; break;
+ case( java.awt.event.KeyEvent.VK_NUMPAD5 ):
+ case( java.awt.event.KeyEvent.VK_5 ): nRet = com.sun.star.awt.Key.NUM5; break;
+ case( java.awt.event.KeyEvent.VK_NUMPAD6 ):
+ case( java.awt.event.KeyEvent.VK_6 ): nRet = com.sun.star.awt.Key.NUM6; break;
+ case( java.awt.event.KeyEvent.VK_NUMPAD7 ):
+ case( java.awt.event.KeyEvent.VK_7 ): nRet = com.sun.star.awt.Key.NUM7; break;
+ case( java.awt.event.KeyEvent.VK_NUMPAD8 ):
+ case( java.awt.event.KeyEvent.VK_8 ): nRet = com.sun.star.awt.Key.NUM8; break;
+ case( java.awt.event.KeyEvent.VK_NUMPAD9 ):
+ case( java.awt.event.KeyEvent.VK_9 ): nRet = com.sun.star.awt.Key.NUM9; break;
+
+ case( java.awt.event.KeyEvent.VK_A ): nRet = com.sun.star.awt.Key.A; break;
+ case( java.awt.event.KeyEvent.VK_B ): nRet = com.sun.star.awt.Key.B; break;
+ case( java.awt.event.KeyEvent.VK_C ): nRet = com.sun.star.awt.Key.C; break;
+ case( java.awt.event.KeyEvent.VK_D ): nRet = com.sun.star.awt.Key.D; break;
+ case( java.awt.event.KeyEvent.VK_E ): nRet = com.sun.star.awt.Key.E; break;
+ case( java.awt.event.KeyEvent.VK_F ): nRet = com.sun.star.awt.Key.F; break;
+ case( java.awt.event.KeyEvent.VK_G ): nRet = com.sun.star.awt.Key.G; break;
+ case( java.awt.event.KeyEvent.VK_H ): nRet = com.sun.star.awt.Key.H; break;
+ case( java.awt.event.KeyEvent.VK_I ): nRet = com.sun.star.awt.Key.I; break;
+ case( java.awt.event.KeyEvent.VK_J ): nRet = com.sun.star.awt.Key.J; break;
+ case( java.awt.event.KeyEvent.VK_K ): nRet = com.sun.star.awt.Key.K; break;
+ case( java.awt.event.KeyEvent.VK_L ): nRet = com.sun.star.awt.Key.L; break;
+ case( java.awt.event.KeyEvent.VK_M ): nRet = com.sun.star.awt.Key.M; break;
+ case( java.awt.event.KeyEvent.VK_N ): nRet = com.sun.star.awt.Key.N; break;
+ case( java.awt.event.KeyEvent.VK_O ): nRet = com.sun.star.awt.Key.O; break;
+ case( java.awt.event.KeyEvent.VK_P ): nRet = com.sun.star.awt.Key.P; break;
+ case( java.awt.event.KeyEvent.VK_Q ): nRet = com.sun.star.awt.Key.Q; break;
+ case( java.awt.event.KeyEvent.VK_R ): nRet = com.sun.star.awt.Key.R; break;
+ case( java.awt.event.KeyEvent.VK_S ): nRet = com.sun.star.awt.Key.S; break;
+ case( java.awt.event.KeyEvent.VK_T ): nRet = com.sun.star.awt.Key.T; break;
+ case( java.awt.event.KeyEvent.VK_U ): nRet = com.sun.star.awt.Key.U; break;
+ case( java.awt.event.KeyEvent.VK_V ): nRet = com.sun.star.awt.Key.V; break;
+ case( java.awt.event.KeyEvent.VK_W ): nRet = com.sun.star.awt.Key.W; break;
+ case( java.awt.event.KeyEvent.VK_X ): nRet = com.sun.star.awt.Key.X; break;
+ case( java.awt.event.KeyEvent.VK_Y ): nRet = com.sun.star.awt.Key.Y; break;
+ case( java.awt.event.KeyEvent.VK_Z ): nRet = com.sun.star.awt.Key.Z; break;
+
+ case( java.awt.event.KeyEvent.VK_F1 ): nRet = com.sun.star.awt.Key.F1; break;
+ case( java.awt.event.KeyEvent.VK_F2 ): nRet = com.sun.star.awt.Key.F2; break;
+ case( java.awt.event.KeyEvent.VK_F3 ): nRet = com.sun.star.awt.Key.F3; break;
+ case( java.awt.event.KeyEvent.VK_F4 ): nRet = com.sun.star.awt.Key.F4; break;
+ case( java.awt.event.KeyEvent.VK_F5 ): nRet = com.sun.star.awt.Key.F5; break;
+ case( java.awt.event.KeyEvent.VK_F6 ): nRet = com.sun.star.awt.Key.F6; break;
+ case( java.awt.event.KeyEvent.VK_F7 ): nRet = com.sun.star.awt.Key.F7; break;
+ case( java.awt.event.KeyEvent.VK_F8 ): nRet = com.sun.star.awt.Key.F8; break;
+ case( java.awt.event.KeyEvent.VK_F9 ): nRet = com.sun.star.awt.Key.F9; break;
+ case( java.awt.event.KeyEvent.VK_F10 ): nRet = com.sun.star.awt.Key.F10; break;
+ case( java.awt.event.KeyEvent.VK_F11 ): nRet = com.sun.star.awt.Key.F11; break;
+ case( java.awt.event.KeyEvent.VK_F12 ): nRet = com.sun.star.awt.Key.F12; break;
+ case( java.awt.event.KeyEvent.VK_F13 ): nRet = com.sun.star.awt.Key.F13; break;
+ case( java.awt.event.KeyEvent.VK_F14 ): nRet = com.sun.star.awt.Key.F14; break;
+ case( java.awt.event.KeyEvent.VK_F15 ): nRet = com.sun.star.awt.Key.F15; break;
+ case( java.awt.event.KeyEvent.VK_F16 ): nRet = com.sun.star.awt.Key.F16; break;
+ case( java.awt.event.KeyEvent.VK_F17 ): nRet = com.sun.star.awt.Key.F17; break;
+ case( java.awt.event.KeyEvent.VK_F18 ): nRet = com.sun.star.awt.Key.F18; break;
+ case( java.awt.event.KeyEvent.VK_F19 ): nRet = com.sun.star.awt.Key.F19; break;
+ case( java.awt.event.KeyEvent.VK_F20 ): nRet = com.sun.star.awt.Key.F20; break;
+ case( java.awt.event.KeyEvent.VK_F21 ): nRet = com.sun.star.awt.Key.F21; break;
+ case( java.awt.event.KeyEvent.VK_F22 ): nRet = com.sun.star.awt.Key.F22; break;
+ case( java.awt.event.KeyEvent.VK_F23 ): nRet = com.sun.star.awt.Key.F23; break;
+ case( java.awt.event.KeyEvent.VK_F24 ): nRet = com.sun.star.awt.Key.F24; break;
+
+ case( java.awt.event.KeyEvent.VK_UP ): nRet = com.sun.star.awt.Key.UP; break;
+ case( java.awt.event.KeyEvent.VK_DOWN): nRet = com.sun.star.awt.Key.DOWN; break;
+ case( java.awt.event.KeyEvent.VK_LEFT ): nRet = com.sun.star.awt.Key.LEFT; break;
+ case( java.awt.event.KeyEvent.VK_RIGHT ): nRet = com.sun.star.awt.Key.RIGHT; break;
+
+ case( java.awt.event.KeyEvent.VK_HOME ): nRet = com.sun.star.awt.Key.HOME; break;
+ case( java.awt.event.KeyEvent.VK_END ): nRet = com.sun.star.awt.Key.END; break;
+
+ case( java.awt.event.KeyEvent.VK_PAGE_UP ): nRet = com.sun.star.awt.Key.PAGEUP; break;
+ case( java.awt.event.KeyEvent.VK_PAGE_DOWN ): nRet = com.sun.star.awt.Key.PAGEDOWN; break;
+
+ case( java.awt.event.KeyEvent.VK_ENTER ): nRet = com.sun.star.awt.Key.RETURN; break;
+ case( java.awt.event.KeyEvent.VK_ESCAPE ): nRet = com.sun.star.awt.Key.ESCAPE; break;
+
+ case( java.awt.event.KeyEvent.VK_TAB ): nRet = com.sun.star.awt.Key.TAB; break;
+ case( java.awt.event.KeyEvent.VK_BACK_SPACE ): nRet = com.sun.star.awt.Key.BACKSPACE; break;
+ case( java.awt.event.KeyEvent.VK_SPACE ): nRet = com.sun.star.awt.Key.SPACE; break;
+ case( java.awt.event.KeyEvent.VK_INSERT): nRet = com.sun.star.awt.Key.INSERT; break;
+ case( java.awt.event.KeyEvent.VK_DELETE): nRet = com.sun.star.awt.Key.DELETE; break;
+ case( java.awt.event.KeyEvent.VK_ADD ): nRet = com.sun.star.awt.Key.ADD; break;
+ case( java.awt.event.KeyEvent.VK_SUBTRACT ): nRet = com.sun.star.awt.Key.SUBTRACT; break;
+ case( java.awt.event.KeyEvent.VK_MULTIPLY ): nRet = com.sun.star.awt.Key.MULTIPLY; break;
+ case( java.awt.event.KeyEvent.VK_DIVIDE ): nRet = com.sun.star.awt.Key.DIVIDE; break;
+ case( java.awt.event.KeyEvent.VK_DECIMAL ): nRet = com.sun.star.awt.Key.POINT; break;
+ case( java.awt.event.KeyEvent.VK_LESS ): nRet = com.sun.star.awt.Key.LESS; break;
+ case( java.awt.event.KeyEvent.VK_GREATER ): nRet = com.sun.star.awt.Key.GREATER; break;
+ case( java.awt.event.KeyEvent.VK_EQUALS ): nRet = com.sun.star.awt.Key.EQUAL; break;
+
+ default:
+ break;
+ }
+
+ return nRet;
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void fireKeyEvent( java.awt.event.KeyEvent aEvt )
+ {
+ if( maKeyListeners.size() > 0 )
+ {
+ boolean bProcess = false, bPressed = false;
+
+ if( java.awt.event.KeyEvent.KEY_PRESSED == aEvt.getID() )
+ {
+ switch( aEvt.getKeyCode() )
+ {
+ case( java.awt.event.KeyEvent.VK_SHIFT ): mbShift = true; break;
+ case( java.awt.event.KeyEvent.VK_CONTROL ): mbMod1 = true; break;
+ case( java.awt.event.KeyEvent.VK_ALT ): mbMod2 = true; break;
+
+ default:
+ {
+ bProcess = bPressed = true;
+ }
+ break;
+ }
+ }
+ else if( java.awt.event.KeyEvent.KEY_RELEASED == aEvt.getID() )
+ {
+ switch( aEvt.getKeyCode() )
+ {
+ case( java.awt.event.KeyEvent.VK_SHIFT ): mbShift = false; break;
+ case( java.awt.event.KeyEvent.VK_CONTROL ): mbMod1 = false; break;
+ case( java.awt.event.KeyEvent.VK_ALT ): mbMod2 = false; break;
+
+ default:
+ {
+ bProcess = true;
+ }
+ break;
+ }
+ }
+
+ if( bProcess )
+ {
+ KeyEvent aUNOEvt = new KeyEvent();
+
+ aUNOEvt.Modifiers = 0;
+
+ if( mbShift )
+ aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.SHIFT;
+
+ if( mbMod1 )
+ aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.MOD1;
+
+ if( mbMod2 )
+ aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.MOD2;
+
+ aUNOEvt.KeyCode = implGetUNOKeyCode( aEvt.getKeyCode() );
+ aUNOEvt.KeyChar = aEvt.getKeyChar();
+ aUNOEvt.KeyFunc = com.sun.star.awt.KeyFunction.DONTKNOW;
+
+ ListIterator aIter = maKeyListeners.listIterator( 0 );
+
+ while( aIter.hasNext() )
+ {
+ if( bPressed )
+ ( (XKeyListener) aIter.next() ).keyPressed( aUNOEvt );
+ else
+ ( (XKeyListener) aIter.next() ).keyReleased( aUNOEvt );
+ }
+ }
+ }
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void fireMouseEvent( java.awt.event.MouseEvent aEvt )
+ {
+ MouseEvent aUNOEvt = new MouseEvent();
+
+ aUNOEvt.Modifiers = 0;
+ aUNOEvt.Buttons = 0;
+ aUNOEvt.X = aEvt.getX();
+ aUNOEvt.Y = aEvt.getY();
+ aUNOEvt.PopupTrigger = false;
+
+ // Modifiers
+ if( aEvt.isShiftDown() )
+ aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.SHIFT;
+
+ if( aEvt.isControlDown() )
+ aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.MOD1;
+
+ if( aEvt.isAltDown() )
+ aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.MOD2;
+
+ // Buttons
+ if( SwingUtilities.isLeftMouseButton( aEvt ) )
+ aUNOEvt.Buttons |= com.sun.star.awt.MouseButton.LEFT;
+
+ if( SwingUtilities.isMiddleMouseButton( aEvt ) )
+ aUNOEvt.Buttons |= com.sun.star.awt.MouseButton.MIDDLE;
+
+ if( SwingUtilities.isRightMouseButton( aEvt ) )
+ aUNOEvt.Buttons |= com.sun.star.awt.MouseButton.RIGHT;
+
+ // event type
+ if( java.awt.event.MouseEvent.MOUSE_PRESSED == aEvt.getID() )
+ {
+ ListIterator aIter = maMouseListeners.listIterator( 0 );
+
+ aUNOEvt.ClickCount = 1;
+
+ while( aIter.hasNext() )
+ ( (XMouseListener) aIter.next() ).mousePressed( aUNOEvt );
+ }
+ else if( java.awt.event.MouseEvent.MOUSE_RELEASED == aEvt.getID() )
+ {
+ ListIterator aIter = maMouseListeners.listIterator( 0 );
+
+ aUNOEvt.ClickCount = 1;
+
+ while( aIter.hasNext() )
+ ( (XMouseListener) aIter.next() ).mouseReleased( aUNOEvt );
+ }
+ else if( java.awt.event.MouseEvent.MOUSE_DRAGGED == aEvt.getID() )
+ {
+ ListIterator aIter = maMouseMotionListeners.listIterator( 0 );
+
+ aUNOEvt.ClickCount = 0;
+
+ while( aIter.hasNext() )
+ ( (XMouseMotionListener) aIter.next() ).mouseDragged( aUNOEvt );
+ }
+ else if( java.awt.event.MouseEvent.MOUSE_MOVED == aEvt.getID() )
+ {
+ ListIterator aIter = maMouseMotionListeners.listIterator( 0 );
+
+ aUNOEvt.ClickCount = 0;
+
+ while( aIter.hasNext() )
+ ( (XMouseMotionListener) aIter.next() ).mouseMoved( aUNOEvt );
+ }
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void fireFocusEvent( java.awt.event.FocusEvent aEvt )
+ {
+ if( java.awt.event.FocusEvent.FOCUS_GAINED == aEvt.getID() )
+ {
+ ListIterator aIter = maFocusListeners.listIterator( 0 );
+ FocusEvent aUNOEvt = new FocusEvent();
+
+ while( aIter.hasNext() )
+ {
+ ( (XFocusListener) aIter.next() ).focusGained( aUNOEvt );
+ }
+ }
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void fireDisposingEvent()
+ {
+ ListIterator aIter = maEventListeners.listIterator( 0 );
+
+ while( aIter.hasNext() )
+ {
+ ( (XEventListener) aIter.next() ).disposing( new com.sun.star.lang.EventObject() );
+ }
+ }
+
+ // --------------------
+ // - XWindow methods -
+ // --------------------
+
+ public void setPosSize( int X, int Y, int Width, int Height, short Flags )
+ {
+ maFrame.setBounds( X, Y, Width, Height );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public com.sun.star.awt.Rectangle getPosSize( )
+ {
+ java.awt.Rectangle bounds = maFrame.getBounds();
+ return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void setVisible( boolean visible )
+ {
+ maFrame.setVisible( visible );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void setEnable( boolean enable )
+ {
+ maFrame.setEnabled( enable );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void setFocus()
+ {
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void addEventListener( XEventListener xListener )
+ {
+ if( xListener != null )
+ maEventListeners.add( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void removeEventListener( XEventListener xListener )
+ {
+ if( xListener != null )
+ maEventListeners.remove( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void addWindowListener( XWindowListener xListener )
+ {
+ if( xListener != null )
+ maWindowListeners.add( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void removeWindowListener( XWindowListener xListener )
+ {
+ if( xListener != null )
+ maWindowListeners.remove( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void addFocusListener( XFocusListener xListener )
+ {
+ if( xListener != null )
+ maFocusListeners.add( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void removeFocusListener( XFocusListener xListener )
+ {
+ if( xListener != null )
+ maFocusListeners.remove( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void addKeyListener( XKeyListener xListener )
+ {
+ if( xListener != null )
+ maKeyListeners.add( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void removeKeyListener( XKeyListener xListener )
+ {
+ if( xListener != null )
+ maKeyListeners.remove( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void addMouseListener( XMouseListener xListener )
+ {
+ if( xListener != null )
+ maMouseListeners.add( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void removeMouseListener( XMouseListener xListener )
+ {
+ if( xListener != null )
+ maMouseListeners.remove( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void addMouseMotionListener( XMouseMotionListener xListener )
+ {
+ if( xListener != null )
+ maMouseMotionListeners.add( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void removeMouseMotionListener( XMouseMotionListener xListener )
+ {
+ if( xListener != null )
+ maMouseMotionListeners.remove( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void addPaintListener( XPaintListener xListener )
+ {
+ if( xListener != null )
+ maPaintListeners.add( xListener );
+ }
+
+ //----------------------------------------------------------------------------------
+
+ public void removePaintListener( XPaintListener xListener )
+ {
+ if( xListener != null )
+ maPaintListeners.remove( xListener );
+ }
+}
diff --git a/avmedia/source/java/avmedia.jar b/avmedia/source/java/avmedia.jar
new file mode 100755
index 000000000000..85a98bbcf33c
--- /dev/null
+++ b/avmedia/source/java/avmedia.jar
Binary files differ
diff --git a/avmedia/source/java/avmedia.jar.component b/avmedia/source/java/avmedia.jar.component
new file mode 100755
index 000000000000..d7cc160bd7d0
--- /dev/null
+++ b/avmedia/source/java/avmedia.jar.component
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* 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.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.media.Manager_Java">
+ <service name="com.sun.star.media.Manager_Java"/>
+ </implementation>
+</component>
diff --git a/avmedia/source/java/makefile.mk b/avmedia/source/java/makefile.mk
new file mode 100755
index 000000000000..1fe771c117f2
--- /dev/null
+++ b/avmedia/source/java/makefile.mk
@@ -0,0 +1,69 @@
+#*************************************************************************
+#
+# 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.
+#
+#**************************************************************************
+
+# Builds the Java Canvas implementation.
+
+PRJNAME = avmedia
+PRJ = ..$/..
+TARGET = avmedia
+PACKAGE = avmedia
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE: settings.mk
+
+.IF "$(GUIBASE)"=="javamedia"
+
+JAVAFILES = \
+ Manager.java \
+ Player.java \
+ PlayerWindow.java \
+ WindowAdapter.java \
+ MediaUno.java \
+ FrameGrabber.java \
+ x11$/SystemWindowAdapter.java
+
+JARFILES = jurt.jar unoil.jar ridl.jar juh.jar java_uno.jar jmf.jar
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:s/.java//).class)
+
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+CUSTOMMANIFESTFILE = manifest
+
+.ENDIF # "$(GUIBASE)"=="javamedia"
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE: target.mk
+
+ALLTAR : $(MISC)/avmedia.jar.component
+
+$(MISC)/avmedia.jar.component .ERRREMOVE : \
+ $(SOLARENV)/bin/createcomponent.xslt avmedia.jar.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)avmedia.jar' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt avmedia.jar.component
diff --git a/avmedia/source/java/manifest b/avmedia/source/java/manifest
new file mode 100755
index 000000000000..fa9c2500d385
--- /dev/null
+++ b/avmedia/source/java/manifest
@@ -0,0 +1,2 @@
+RegistrationClassName: MediaUno
+UNO-Type-Path:
diff --git a/avmedia/source/java/win/SystemWindowAdapter.java b/avmedia/source/java/win/SystemWindowAdapter.java
new file mode 100755
index 000000000000..ebf3cac99307
--- /dev/null
+++ b/avmedia/source/java/win/SystemWindowAdapter.java
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+import sun.awt.*;
+import com.sun.star.awt.*;
+
+public class SystemWindowAdapter
+{
+ static public java.awt.Frame createFrame( int windowHandle )
+ {
+ java.awt.Frame aFrame;
+
+ // we're initialized with the operating system window handle
+ // as the parameter. We then generate a dummy Java frame with
+ // that window as the parent, to fake a root window for the
+ // Java implementation.
+
+ // now, we're getting slightly system dependent here.
+ String os = (String) System.getProperty( "os.name" );
+
+ // create the embedded frame
+ if( os.startsWith( "Windows" ) )
+ aFrame = new sun.awt.windows.WEmbeddedFrame( windowHandle );
+ else
+ throw new com.sun.star.uno.RuntimeException();
+
+ return aFrame;
+ }
+}
diff --git a/avmedia/source/java/x11/SystemWindowAdapter.java b/avmedia/source/java/x11/SystemWindowAdapter.java
new file mode 100755
index 000000000000..4292dabe6775
--- /dev/null
+++ b/avmedia/source/java/x11/SystemWindowAdapter.java
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+import java.awt.*;
+import java.lang.reflect.*;
+
+public class SystemWindowAdapter
+{
+ static public java.awt.Frame createFrame( int windowHandle )
+ {
+ String aOS = (String) System.getProperty( "os.name" );
+ java.awt.Frame aFrame = null;
+
+ if( aOS.startsWith( "SunOS" ) )
+ {
+ try
+ {
+ Class aClass = Class.forName( "sun.awt.motif.MEmbeddedFrame" );
+
+ if( aClass != null )
+ {
+ try
+ {
+ Constructor aCtor = aClass.getConstructor( new Class[] { long.class, boolean.class } );
+
+ if( aCtor != null )
+ {
+ aFrame = (java.awt.Frame) aCtor.newInstance( new Object[] { new Long( windowHandle ),
+ new Boolean( false ) } );
+ }
+ }
+ catch( Exception e )
+ {
+ }
+
+ if( aFrame == null )
+ {
+ try
+ {
+ Constructor aCtor = aClass.getConstructor( new Class[] { long.class } );
+
+ if( aCtor != null )
+ {
+ aFrame = (java.awt.Frame) aCtor.newInstance( new Object[] { new Long( windowHandle ) } );
+ }
+ }
+ catch( Exception e )
+ {
+ }
+ }
+ }
+ }
+ catch( Exception e )
+ {
+ }
+ }
+ else
+ {
+ try
+ {
+ Class aClass = Class.forName( "sun.awt.motif.MEmbeddedFrame" );
+
+ if( aClass != null )
+ {
+ Constructor aCtor = aClass.getConstructor( new Class[] { long.class } );
+
+ if( aCtor != null )
+ {
+ aFrame = (java.awt.Frame) aCtor.newInstance( new Object[] { new Long( windowHandle ) } );
+ }
+ }
+ }
+ catch( Exception e )
+ {
+ }
+
+ if( aFrame == null )
+ {
+ try
+ {
+ Class aClass = Class.forName( "sun.awt.X11.XEmbeddedFrame" );
+
+ if( aClass != null )
+ {
+ Constructor aCtor = aClass.getConstructor( new Class[] { long.class } );
+
+ if( aCtor != null )
+ aFrame = (java.awt.Frame) aCtor.newInstance( new Object[] { new Long( windowHandle ) } );
+ }
+ }
+ catch( Exception e )
+ {
+ }
+ }
+ }
+
+ return aFrame;
+ }
+}
diff --git a/avmedia/source/quicktime/avmediaQuickTime.component b/avmedia/source/quicktime/avmediaQuickTime.component
new file mode 100755
index 000000000000..aa0251d74c9d
--- /dev/null
+++ b/avmedia/source/quicktime/avmediaQuickTime.component
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* 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.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.SharedLibrary"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.avmedia.Manager_QuickTime">
+ <service name="com.sun.star.media.Manager_QuickTime"/>
+ </implementation>
+</component>
diff --git a/avmedia/source/quicktime/framegrabber.cxx b/avmedia/source/quicktime/framegrabber.cxx
new file mode 100644
index 000000000000..5da2aa2f2836
--- /dev/null
+++ b/avmedia/source/quicktime/framegrabber.cxx
@@ -0,0 +1,155 @@
+/* -*- 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 "framegrabber.hxx"
+#include "player.hxx"
+
+#include <tools/stream.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <unotools/localfilehelper.hxx>
+
+#define AVMEDIA_QUICKTIME_FRAMEGRABBER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.FrameGrabber_Quicktime"
+#define AVMEDIA_QUICKTIME_FRAMEGRABBER_SERVICENAME "com.sun.star.media.FrameGrabber_Quicktime"
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace quicktime {
+
+// ----------------
+// - FrameGrabber -
+// ----------------
+
+FrameGrabber::FrameGrabber( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
+ mxMgr( rxMgr )
+{
+ OSErr result;
+
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ // check the version of QuickTime installed
+ result = Gestalt(gestaltQuickTime,&mnVersion);
+ if ((result == noErr) && (mnVersion >= QT701))
+ {
+ // we have version 7.01 or later, initialize
+ mpMovie = [QTMovie movie];
+ [mpMovie retain];
+ mbInitialized = true;
+ }
+ [pool release];
+}
+
+// ------------------------------------------------------------------------------
+
+FrameGrabber::~FrameGrabber()
+{
+ if( mbInitialized )
+ {
+ if( mpMovie )
+ {
+ [mpMovie release];
+ mpMovie = nil;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+bool FrameGrabber::create( const ::rtl::OUString& rURL )
+{
+ bool bRet = false;
+ maURL = rURL;
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ NSString* aNSStr = [[[NSString alloc] initWithCharacters: rURL.getStr() length: rURL.getLength()]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
+ NSURL* aURL = [NSURL URLWithString:aNSStr ];
+
+ // create the Movie
+
+ mpMovie = [mpMovie initWithURL:aURL error:nil];
+ if(mpMovie)
+ {
+ [mpMovie retain];
+ bRet = true;
+ }
+
+ [pool release];
+
+ return( bRet );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMediaTime )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< graphic::XGraphic > xRet;
+
+ NSImage* pImage = [mpMovie frameImageAtTime: QTMakeTimeWithTimeInterval(fMediaTime)];
+ NSData *pBitmap = [pImage TIFFRepresentation];
+ long nSize = [pBitmap length];
+ const void* pBitmapData = [pBitmap bytes];
+ SvMemoryStream aMemStm( (char *)pBitmapData, nSize, STREAM_READ | STREAM_WRITE );
+ Graphic aGraphic;
+ if ( GraphicConverter::Import( aMemStm, aGraphic, CVT_TIF ) == ERRCODE_NONE )
+ {
+ xRet = aGraphic.GetXGraphic();
+ }
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL FrameGrabber::getImplementationName( )
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_FRAMEGRABBER_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL FrameGrabber::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_QUICKTIME_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_QUICKTIME_FRAMEGRABBER_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace quicktime
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/framegrabber.hxx b/avmedia/source/quicktime/framegrabber.hxx
new file mode 100644
index 000000000000..8fa2b5b5fc95
--- /dev/null
+++ b/avmedia/source/quicktime/framegrabber.hxx
@@ -0,0 +1,74 @@
+/* -*- 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 "quicktimecommon.hxx"
+
+#include "com/sun/star/media/XFrameGrabber.hdl"
+
+namespace avmedia { namespace quicktime {
+
+// ----------------
+// - 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;
+ QTMovie* mpMovie;
+ sal_Bool mbInitialized;
+ long mnVersion;
+};
+
+} // namespace quicktime
+} // namespace avmedia
+
+#endif // _FRAMEGRABBER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/makefile.mk b/avmedia/source/quicktime/makefile.mk
new file mode 100755
index 000000000000..358fce491847
--- /dev/null
+++ b/avmedia/source/quicktime/makefile.mk
@@ -0,0 +1,93 @@
+#*************************************************************************
+#
+# 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=avmediaQuickTime
+
+.IF "$(GUIBASE)"=="aqua"
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(verbose)"!="" || "$(VERBOSE)"!=""
+CDEFS+= -DVERBOSE
+.ENDIF
+
+# --- Files ----------------------------------
+
+CFLAGSCXX+=$(OBJCXXFLAGS)
+
+SLOFILES= \
+ $(SLO)$/quicktimeuno.obj \
+ $(SLO)$/manager.obj \
+ $(SLO)$/window.obj \
+ $(SLO)$/framegrabber.obj \
+ $(SLO)$/player.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/quicktimeuno.obj
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(TOOLSLIB) \
+ $(VCLLIB)
+
+SHL1STDLIBS+= \
+ -framework Cocoa \
+ -framework QTKit \
+ -framework QuickTime
+
+# build DLL
+SHL1LIBS=$(SLB)$/$(TARGET).lib
+SHL1IMPLIB=i$(TARGET)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @echo " Nothing to build for GUIBASE=$(GUIBASE)"
+.ENDIF
+
+ALLTAR : $(MISC)/avmediaQuickTime.component
+
+$(MISC)/avmediaQuickTime.component .ERRREMOVE : \
+ $(SOLARENV)/bin/createcomponent.xslt avmediaQuickTime.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt avmediaQuickTime.component
diff --git a/avmedia/source/quicktime/manager.cxx b/avmedia/source/quicktime/manager.cxx
new file mode 100644
index 000000000000..ca8da8e5d8b4
--- /dev/null
+++ b/avmedia/source/quicktime/manager.cxx
@@ -0,0 +1,99 @@
+/* -*- 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>
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace quicktime {
+// ----------------
+// - Manager -
+// ----------------
+
+Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
+ mxMgr( rxMgr )
+{
+ OSL_TRACE( "avmediaquicktime: Manager::Manager" );
+}
+
+// ------------------------------------------------------------------------------
+
+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 );
+ INetURLObject aURL( rURL );
+
+ OSL_TRACE( "avmediaquicktime: Manager::createPlayer" );
+
+ 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_QUICKTIME_MANAGER_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Manager::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_QUICKTIME_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_QUICKTIME_MANAGER_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace quicktime
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/manager.hxx b/avmedia/source/quicktime/manager.hxx
new file mode 100644
index 000000000000..8c8749683ce7
--- /dev/null
+++ b/avmedia/source/quicktime/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 "quicktimecommon.hxx"
+
+#include "com/sun/star/media/XManager.hdl"
+
+// -----------
+// - Manager -
+// -----------
+
+namespace avmedia { namespace quicktime {
+
+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 quicktime
+} // namespace avmedia
+
+#endif // _MANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/player.cxx b/avmedia/source/quicktime/player.cxx
new file mode 100644
index 000000000000..8b623e93c8ce
--- /dev/null
+++ b/avmedia/source/quicktime/player.cxx
@@ -0,0 +1,502 @@
+/* -*- 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 <math.h>
+
+#include "player.hxx"
+#include "framegrabber.hxx"
+#include "window.hxx"
+
+// dbg_dump for development
+#if OSL_DEBUG_LEVEL > 1
+#include <rtl/strbuf.hxx>
+#include <rtl/ustring.hxx>
+
+const sal_Char *dbg_dump(const rtl::OString &rStr)
+{
+ static rtl::OStringBuffer aStr;
+
+ aStr = rtl::OStringBuffer(rStr);
+ aStr.append(static_cast<char>(0));
+ return aStr.getStr();
+}
+
+const sal_Char *dbg_dump(const rtl::OUString &rStr)
+{
+ return dbg_dump(rtl::OUStringToOString(rStr, RTL_TEXTENCODING_UTF8));
+}
+
+const sal_Char *dbg_dump(rtl_String *pStr)
+{
+ return dbg_dump(rtl::OString(pStr));
+}
+
+const sal_Char *dbg_dump(rtl_uString *pStr)
+{
+ return dbg_dump(rtl::OUString(pStr));
+}
+
+#endif
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace quicktime {
+
+// ----------------
+// - Player -
+// ----------------
+
+Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
+ mxMgr( rxMgr ),
+ mpMovie( nil ),
+ /* GST
+ mbFakeVideo (sal_False ),
+ */
+ mnUnmutedVolume( 0 ),
+ mnStopTime( DBL_MAX ), //max double
+ mbMuted( false ),
+ mbLooping( false ),
+ mbInitialized( false ),
+ mnWindowID( 0 ),
+ mnDuration( 0 ),
+ mnWidth( 0 ),
+ mnHeight( 0 ),
+ mnVersion( 0 ),
+ maSizeCondition( osl_createCondition() )
+{
+ OSErr result;
+
+ NSApplicationLoad();
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ // check the version of QuickTime installed
+ result = Gestalt(gestaltQuickTime,&mnVersion);
+ if ((result == noErr) && (mnVersion >= QT701))
+ {
+ // we have version 7.01 or later, initialize
+ mbInitialized = true;
+ }
+ [pool release];
+}
+
+// ------------------------------------------------------------------------------
+
+Player::~Player()
+{
+ if( mpMovie )
+ {
+ [mpMovie release];
+ mpMovie = nil;
+ }
+}
+// ------------------------------------------------------------------------------
+
+QTMovie* Player::getMovie()
+{
+ OSL_ASSERT( mpMovie );
+ return mpMovie;
+}
+
+// ------------------------------------------------------------------------------
+
+bool Player::create( const ::rtl::OUString& rURL )
+{
+ bool bRet = false;
+ // create the Movie
+ if( mbInitialized )
+ {
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+ if( mpMovie )
+ {
+ [mpMovie release];
+ mpMovie = nil;
+ }
+
+ NSString* aNSStr = [[[NSString alloc] initWithCharacters: rURL.getStr() length: rURL.getLength()]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
+ NSURL* aURL = [NSURL URLWithString:aNSStr ];
+
+ NSError* pErr = nil;
+ mpMovie = [QTMovie movieWithURL:aURL error:&pErr];
+ if(mpMovie)
+ {
+ [mpMovie retain];
+ maURL = rURL;
+ bRet = true;
+ }
+ if( pErr )
+ {
+ OSL_TRACE( "NSMovie create failed with error %ld (%s)",
+ (long)[pErr code],
+ [[pErr localizedDescription] cString]
+ );
+ }
+ [pool release];
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::start( )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::start");
+
+ if( mpMovie )
+ {
+ [mpMovie play];
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::stop( )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::stop");
+ if( mpMovie )
+ {
+ [mpMovie stop];
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::isPlaying()
+ throw (uno::RuntimeException)
+{
+ bool bRet = false;
+
+ if ( mpMovie )
+ {
+ if ([mpMovie rate] != 0)
+ {
+ bRet = true;
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getDuration( )
+ throw (uno::RuntimeException)
+{
+ // slideshow checks for non-zero duration, so cheat here
+ double duration = 0.01;
+
+ if ( mpMovie ) // && mnDuration > 0 ) {
+ {
+ QTTime structDuration = [mpMovie duration] ;
+ duration = (double)structDuration.timeValue / (double)structDuration.timeScale;
+ }
+
+ return duration;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setMediaTime( double fTime )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::setMediaTime");
+
+ if ( mpMovie )
+ {
+ [mpMovie setCurrentTime: QTMakeTimeWithTimeInterval(fTime)];
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getMediaTime( )
+ throw (uno::RuntimeException)
+{
+ double position = 0.0;
+
+ if ( mpMovie )
+ {
+ QTTime structDuration = [mpMovie currentTime] ;
+ position = (double)structDuration.timeValue / (double)structDuration.timeScale;
+ }
+
+ if(isPlaying() && position>mnStopTime)
+ {
+ stop();
+ }
+
+ return position;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setStopTime( double fTime )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::setStopTime %f", fTime);
+
+ mnStopTime = fTime;
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getStopTime( )
+ throw (uno::RuntimeException)
+{
+ double fRet = mnStopTime;
+
+ return fRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setRate( double fRate )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::setRate");
+
+ // Quicktime: 0 = stop, 1 = normal speed, 2 = double speed, -1 = normal speed backwards
+ if ( mpMovie )
+ {
+ [mpMovie setRate: fRate];
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getRate( )
+ throw (uno::RuntimeException)
+{
+ // Quicktime: 0 = stop, 1 = normal speed, 2 = double speed, -1 = normal speed backwards
+ double rate = 1.0;
+
+ OSL_TRACE ("Player::getRate");
+
+ if ( mpMovie )
+ {
+ rate = (double) [mpMovie rate];
+ }
+
+ return rate;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::setPlaybackLoop? %s", bSet?"True":"False" );
+
+ if(bSet)
+ {
+ [mpMovie setAttribute:[NSNumber numberWithBool:YES] forKey: QTMovieLoopsAttribute] ;
+ }
+ else
+ {
+ [mpMovie setAttribute:[NSNumber numberWithBool:NO] forKey: QTMovieLoopsAttribute] ;
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::isPlaybackLoop( )
+ throw (uno::RuntimeException)
+{
+ bool bRet = [[mpMovie attributeForKey:QTMovieLoopsAttribute] boolValue];
+
+ OSL_TRACE ("Player::isPlaybackLoop ? %s", bRet?"True":"False" );
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setMute( sal_Bool bSet )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE( "set mute: %d muted: %d unmuted volume: %lf", bSet, mbMuted, mnUnmutedVolume );
+
+ // change the volume to 0 or the unmuted volume
+ if( mpMovie && mbMuted != bSet )
+ {
+ [mpMovie setMuted: bSet ];
+ mbMuted = bSet;
+ }
+
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::isMute( )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::isMuted");
+
+ return mbMuted;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB )
+ throw (uno::RuntimeException)
+{
+ // OOo db volume -40 = QTVolume 0
+ // OOo db volume 0 = QTvolume 1
+ if(nVolumeDB==-40)
+ {
+ mnUnmutedVolume = 0;
+ }
+ else
+ {
+ mnUnmutedVolume = pow( 10.0, nVolumeDB / 20.0 );
+ }
+
+ OSL_TRACE( "set volume: %d gst volume: %f", nVolumeDB, mnUnmutedVolume );
+
+ // change volume
+ if( !mbMuted && mpMovie )
+ {
+ [mpMovie setVolume: mnUnmutedVolume ];
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL Player::getVolumeDB( )
+ throw (uno::RuntimeException)
+{
+ sal_Int16 nVolumeDB = 0.0;
+
+ if( mpMovie )
+ {
+ float volume = 0.0;
+
+ volume = [mpMovie volume];
+ if(volume>0) //protect from log10(0)
+ {
+ nVolumeDB = (sal_Int16) ( 20.0*log10 ( volume ) );
+ }
+ else
+ {
+ nVolumeDB = -40 ; // QT zero volume is no volume, -40db
+ }
+ }
+
+ return nVolumeDB;
+}
+
+// ------------------------------------------------------------------------------
+
+awt::Size SAL_CALL Player::getPreferredPlayerWindowSize( )
+ throw (uno::RuntimeException)
+{
+ NSSize nsSize = [[mpMovie attributeForKey:QTMovieNaturalSizeAttribute] sizeValue];
+ awt::Size aSize( nsSize.width, nsSize.height );
+ 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() );
+ NSSize nsSize( NSMakeSize(aSize.Width, aSize.Height) );
+
+ OSL_TRACE( "Player::createPlayerWindow %d %d length: %d", aSize.Width, aSize.Height, aArguments.getLength() );
+
+ if( aSize.Width > 0 && aSize.Height > 0 )
+ {
+ sal_IntPtr nPtr = NULL;
+ aArguments[0] >>= nPtr;
+ NSView* pParentView = reinterpret_cast< NSView * >(nPtr);
+
+ ::avmedia::quicktime::Window* pWindow = new ::avmedia::quicktime::Window( mxMgr, *this, pParentView );
+ xRet = pWindow;
+ }
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber( )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ uno::Reference< media::XFrameGrabber > xRet;
+ OSL_TRACE ("Player::createFrameGrabber");
+
+ 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_QUICKTIME_PLAYER_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_QUICKTIME_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_QUICKTIME_PLAYER_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace quicktime
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/player.hxx b/avmedia/source/quicktime/player.hxx
new file mode 100644
index 000000000000..da9bbfc8ec8b
--- /dev/null
+++ b/avmedia/source/quicktime/player.hxx
@@ -0,0 +1,110 @@
+/* -*- 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 <osl/conditn.h>
+#include "quicktimecommon.hxx"
+
+#include "com/sun/star/media/XPlayer.hdl"
+
+namespace avmedia { namespace quicktime {
+
+/*
+// ----------
+// - 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 );
+
+ // 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);
+
+ QTMovie* getMovie();
+
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr;
+
+ ::rtl::OUString maURL;
+
+ QTMovie *mpMovie; // the Movie object
+
+ float mnUnmutedVolume;
+ double mnStopTime;
+
+ sal_Bool mbMuted;
+ sal_Bool mbLooping;
+ sal_Bool mbInitialized;
+
+ long mnWindowID;
+ long mnDuration;
+ int mnWidth;
+ int mnHeight;
+
+ long mnVersion;
+ oslCondition maSizeCondition;
+};
+
+} // namespace quicktime
+} // namespace avmedia
+
+#endif // _PLAYER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/quicktimecommon.hxx b/avmedia/source/quicktime/quicktimecommon.hxx
new file mode 100644
index 000000000000..1c22377efe9a
--- /dev/null
+++ b/avmedia/source/quicktime/quicktimecommon.hxx
@@ -0,0 +1,83 @@
+/* -*- 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 _QUICKTIMECOMMON_HXX
+#define _QUICKTIMECOMMON_HXX
+
+#ifdef MACOSX
+#include <premac.h>
+#import <Cocoa/Cocoa.h>
+#import <QTKit/QTKit.h>
+#import <QuickTime/QuickTime.h>
+#include <postmac.h>
+#endif
+#include <osl/mutex.hxx>
+#ifndef __RTL_USTRING_
+#include <rtl/ustring.hxx>
+#endif
+#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 AVMEDIA_QUICKTIME_MANAGER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Manager_QuickTime"
+#define AVMEDIA_QUICKTIME_MANAGER_SERVICENAME "com.sun.star.media.Manager_QuickTime"
+
+#define AVMEDIA_QUICKTIME_PLAYER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Player_QuickTime"
+#define AVMEDIA_QUICKTIME_PLAYER_SERVICENAME "com.sun.star.media.Player_QuickTime"
+
+#define AVMEDIA_QUICKTIME_WINDOW_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Window_QuickTime"
+#define AVMEDIA_QUICKTIME_WINDOW_SERVICENAME "com.sun.star.media.Window_QuickTime"
+
+#define WM_GRAPHNOTIFY (WM_USER + 567)
+
+// Quicktime 7+ in Mac OS X 10.4
+#define QT701 0x07010000
+
+// Quicktime 6.4+ in Mac OS X 10.3
+#define QT64 0x06400000
+
+#endif // _QUICKTIMECOMMOM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/quicktimeuno.cxx b/avmedia/source/quicktime/quicktimeuno.cxx
new file mode 100644
index 000000000000..275c9446e23b
--- /dev/null
+++ b/avmedia/source/quicktime/quicktimeuno.cxx
@@ -0,0 +1,80 @@
+/* -*- 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 "quicktimecommon.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::quicktime::Manager( rxFact ) );
+}
+
+// ------------------------------------------
+// - component_getImplementationEnvironment -
+// ------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+// ------------------------
+// - component_getFactory -
+// ------------------------
+
+extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /* pRegistryKey */ )
+{
+ uno::Reference< lang::XSingleServiceFactory > xFactory;
+ void* pRet = 0;
+
+ if( rtl_str_compare( pImplName, AVMEDIA_QUICKTIME_MANAGER_IMPLEMENTATIONNAME ) == 0 )
+ {
+ const ::rtl::OUString aServiceName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_MANAGER_SERVICENAME )) );
+
+ xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
+ reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_MANAGER_IMPLEMENTATIONNAME )),
+ 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: */
diff --git a/avmedia/source/quicktime/window.cxx b/avmedia/source/quicktime/window.cxx
new file mode 100644
index 000000000000..9b9c14ae2622
--- /dev/null
+++ b/avmedia/source/quicktime/window.cxx
@@ -0,0 +1,354 @@
+/* -*- 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 <com/sun/star/awt/SystemPointer.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+
+#include "window.hxx"
+#include "player.hxx"
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace quicktime {
+
+// -----------
+// - 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;
+}
+
+// ---------------
+// - Window -
+// ---------------
+
+// ------------------------------------------------------------------------------
+
+Window::Window( const uno::Reference< lang::XMultiServiceFactory >& i_rxMgr, Player& i_rPlayer, NSView* i_pParentView ) :
+ mxMgr( i_rxMgr ),
+ maListeners( maMutex ),
+ meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ),
+ mrPlayer( i_rPlayer ),
+ mnPointerType( awt::SystemPointer::ARROW ),
+ mpParentView( i_pParentView ),
+ mpMovieView( nil )
+{
+
+ ::osl::MutexGuard aGuard( ImplGetOwnStaticMutex() );
+
+ if( mpParentView ) // sanity check
+ {
+
+ NSRect aViewRect = [mpParentView frame];
+ aViewRect.origin.x = aViewRect.origin.y = 0;
+ mpMovieView = [[QTMovieView alloc] initWithFrame: aViewRect];
+ [mpMovieView setMovie: mrPlayer.getMovie() ];
+ [mpMovieView setControllerVisible: NO];
+ [mpMovieView setPreservesAspectRatio: YES];
+ [mpMovieView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
+ [mpParentView addSubview: mpMovieView];
+ [mpParentView setAutoresizesSubviews: YES];
+ }
+
+ OSL_TRACE ("Window::Window");
+}
+
+// ------------------------------------------------------------------------------
+
+Window::~Window()
+{
+ if( mpMovieView )
+ {
+ [mpMovieView removeFromSuperview];
+ [mpMovieView setMovie:nil];
+ [mpMovieView release];
+ mpMovieView = nil;
+ }
+}
+
+bool Window::create( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+{
+ return true;
+}
+
+// XPlayerWindow
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::update( )
+ throw (uno::RuntimeException)
+{
+ ;
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Window::setZoomLevel( media::ZoomLevel eZoomLevel )
+ throw (uno::RuntimeException)
+{
+ return false;
+}
+
+// ------------------------------------------------------------------------------
+
+media::ZoomLevel SAL_CALL Window::getZoomLevel( )
+ throw (uno::RuntimeException)
+{
+ return meZoomLevel;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setPointerType( sal_Int32 nPointerType )
+ throw (uno::RuntimeException)
+{
+ mnPointerType = nPointerType;
+}
+
+// XWindow
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags )
+ throw (uno::RuntimeException)
+{
+ if( mpParentView && mpMovieView )
+ {
+ NSRect aRect = [mpMovieView frame];
+ if( (Flags & awt::PosSize::WIDTH) )
+ aRect.size.width = Width;
+ if( (Flags & awt::PosSize::HEIGHT) )
+ aRect.size.height = Height;
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+awt::Rectangle SAL_CALL Window::getPosSize()
+ throw (uno::RuntimeException)
+{
+ awt::Rectangle aRet;
+
+ NSRect aRect = [mpMovieView frame];
+ aRet.X = aRet.Y = 0;
+ aRet.Width = aRect.size.width;
+ aRet.Height = aRect.size.height;
+
+ return aRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setVisible( sal_Bool bVisible )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Window::setVisible");
+
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setEnable( sal_Bool bEnable )
+ throw (uno::RuntimeException)
+{
+ ;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Window::setFocus( )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Window::setFocus");
+}
+
+// ------------------------------------------------------------------------------
+
+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 );
+}
+
+// XComponent
+// ------------------------------------------------------------------------------
+
+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 );
+}
+
+// XServiceInfo
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL Window::getImplementationName( )
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_WINDOW_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Window::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_QUICKTIME_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_QUICKTIME_WINDOW_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace quicktime
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/window.hxx b/avmedia/source/quicktime/window.hxx
new file mode 100644
index 000000000000..e782e6367af9
--- /dev/null
+++ b/avmedia/source/quicktime/window.hxx
@@ -0,0 +1,116 @@
+/* -*- 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 "quicktimecommon.hxx"
+#include <cppuhelper/interfacecontainer.h>
+
+#include "com/sun/star/media/XPlayerWindow.hdl"
+
+namespace avmedia { namespace quicktime {
+
+// ---------------
+// - 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 >& i_rxMgr,
+ Player& i_rPlayer,
+ NSView* i_pParentView
+ );
+ ~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);
+
+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 mnPointerType;
+
+ NSView* mpParentView; // parent view for our own private movie view
+ QTMovieView* mpMovieView; // the view containing the movie object, output target and controller
+
+ void ImplLayoutVideoWindow();
+};
+
+} // namespace quicktime
+} // namespace avmedia
+
+#endif // _WINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/viewer/makefile.mk b/avmedia/source/viewer/makefile.mk
new file mode 100755
index 000000000000..7771d1eb0528
--- /dev/null
+++ b/avmedia/source/viewer/makefile.mk
@@ -0,0 +1,55 @@
+#*************************************************************************
+#
+# 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=viewer
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Resources ---------------------------------
+
+SRS1NAME=$(TARGET)
+SRC1FILES =\
+ mediawindow.src
+
+# --- Files -------------------------------------
+
+SLOFILES= \
+ $(EXCEPTIONSFILES)
+
+EXCEPTIONSFILES= \
+ $(SLO)$/mediaevent_impl.obj \
+ $(SLO)$/mediawindow.obj \
+ $(SLO)$/mediawindow_impl.obj \
+ $(SLO)$/mediawindowbase_impl.obj \
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
diff --git a/avmedia/source/viewer/mediaevent_impl.cxx b/avmedia/source/viewer/mediaevent_impl.cxx
new file mode 100644
index 000000000000..f7cd33409cea
--- /dev/null
+++ b/avmedia/source/viewer/mediaevent_impl.cxx
@@ -0,0 +1,225 @@
+/* -*- 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 "mediaevent_impl.hxx"
+#include "mediawindow_impl.hxx"
+#include <osl/mutex.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/event.hxx>
+
+using namespace ::com::sun::star;
+
+/* Definition of MediaWindowImpl class */
+
+namespace avmedia { namespace priv {
+// ---------------------------
+// - MediaEventListenersImpl -
+// ---------------------------
+
+MediaEventListenersImpl::MediaEventListenersImpl( Window& rEventWindow ) :
+ mpNotifyWindow( &rEventWindow )
+{
+}
+
+// ---------------------------------------------------------------------
+
+MediaEventListenersImpl::~MediaEventListenersImpl()
+{
+}
+
+// ---------------------------------------------------------------------
+
+void MediaEventListenersImpl::cleanUp()
+{
+ Application::RemoveMouseAndKeyEvents( reinterpret_cast< ::Window* >( mpNotifyWindow ) );
+ mpNotifyWindow = NULL;
+}
+
+// ---------------------------------------------------------------------
+
+void SAL_CALL MediaEventListenersImpl::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+// ---------------------------------------------------------------------
+
+void SAL_CALL MediaEventListenersImpl::keyPressed( const ::com::sun::star::awt::KeyEvent& e )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::osl::MutexGuard aGuard( maMutex );
+ const SolarMutexGuard aAppGuard;
+
+ if( mpNotifyWindow )
+ {
+ KeyCode aVCLKeyCode( e.KeyCode,
+ ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) |
+ ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) |
+ ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) );
+ KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode );
+
+ Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLKeyEvt );
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void SAL_CALL MediaEventListenersImpl::keyReleased( const ::com::sun::star::awt::KeyEvent& e )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::osl::MutexGuard aGuard( maMutex );
+ const SolarMutexGuard aAppGuard;
+
+ if( mpNotifyWindow )
+ {
+ KeyCode aVCLKeyCode( e.KeyCode,
+ ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) |
+ ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) |
+ ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) );
+ KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode );
+ Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLKeyEvt );
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void SAL_CALL MediaEventListenersImpl::mousePressed( const ::com::sun::star::awt::MouseEvent& e )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::osl::MutexGuard aGuard( maMutex );
+ const SolarMutexGuard aAppGuard;
+
+ if( mpNotifyWindow )
+ {
+ MouseEvent aVCLMouseEvt( Point( e.X, e.Y ),
+ sal::static_int_cast< sal_uInt16 >(e.ClickCount),
+ 0,
+ ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) |
+ ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) |
+ ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ),
+ e.Modifiers );
+ Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt );
+ }
+}
+
+// ----------------------------------------------gvd-----------------------
+
+void SAL_CALL MediaEventListenersImpl::mouseReleased( const ::com::sun::star::awt::MouseEvent& e )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::osl::MutexGuard aGuard( maMutex );
+ const SolarMutexGuard aAppGuard;
+
+ if( mpNotifyWindow )
+ {
+ MouseEvent aVCLMouseEvt( Point( e.X, e.Y ),
+ sal::static_int_cast< sal_uInt16 >(e.ClickCount),
+ 0,
+ ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) |
+ ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) |
+ ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ),
+ e.Modifiers );
+ Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt );
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void SAL_CALL MediaEventListenersImpl::mouseEntered( const ::com::sun::star::awt::MouseEvent& /* e */ )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::osl::MutexGuard aGuard( maMutex );
+ const SolarMutexGuard aAppGuard;
+
+ if( mpNotifyWindow )
+ {
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void SAL_CALL MediaEventListenersImpl::mouseExited( const ::com::sun::star::awt::MouseEvent& /* e */ )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::osl::MutexGuard aGuard( maMutex );
+ const SolarMutexGuard aAppGuard;
+
+ if( mpNotifyWindow )
+ {
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void SAL_CALL MediaEventListenersImpl::mouseDragged( const ::com::sun::star::awt::MouseEvent& e )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::osl::MutexGuard aGuard( maMutex );
+ const SolarMutexGuard aAppGuard;
+
+ if( mpNotifyWindow )
+ {
+ MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, 0, e.Buttons, e.Modifiers );
+ Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt );
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void SAL_CALL MediaEventListenersImpl::mouseMoved( const ::com::sun::star::awt::MouseEvent& e )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::osl::MutexGuard aGuard( maMutex );
+ const SolarMutexGuard aAppGuard;
+
+ if( mpNotifyWindow )
+ {
+ MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, 0, e.Buttons, e.Modifiers );
+ Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt );
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void SAL_CALL MediaEventListenersImpl::focusGained( const ::com::sun::star::awt::FocusEvent& /* e */ )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+// ---------------------------------------------------------------------
+
+void SAL_CALL MediaEventListenersImpl::focusLost( const ::com::sun::star::awt::FocusEvent& /* e */ )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+} // namespace priv
+} // namespace avemdia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/viewer/mediaevent_impl.hxx b/avmedia/source/viewer/mediaevent_impl.hxx
new file mode 100644
index 000000000000..9f282a90688f
--- /dev/null
+++ b/avmedia/source/viewer/mediaevent_impl.hxx
@@ -0,0 +1,92 @@
+/* -*- 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 _AVMEDIA_MEDIAEVENT_IMPL_HXX
+#define _AVMEDIA_MEDIAEVENT_IMPL_HXX
+
+#include <avmedia/mediawindow.hxx>
+#include <cppuhelper/compbase4.hxx>
+#include <com/sun/star/awt/XKeyListener.hpp>
+#include <com/sun/star/awt/XMouseListener.hpp>
+#include <com/sun/star/awt/XMouseMotionListener.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+
+namespace avmedia
+{
+ namespace priv
+ {
+ // ---------------------------
+ // - MediaEventListenersImpl -
+ // ---------------------------
+
+ class MediaWindowImpl;
+
+ class MediaEventListenersImpl : public ::cppu::WeakImplHelper4< ::com::sun::star::awt::XKeyListener,
+ ::com::sun::star::awt::XMouseListener,
+ ::com::sun::star::awt::XMouseMotionListener,
+ ::com::sun::star::awt::XFocusListener >
+ {
+ public:
+
+ MediaEventListenersImpl( Window& rNotifyWindow );
+ ~MediaEventListenersImpl();
+
+ void cleanUp();
+
+ protected:
+
+ // XKeyListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XMouseListener
+ virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XMouseMotionListener
+ virtual void SAL_CALL mouseDragged( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL mouseMoved( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XFocusListener
+ virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+
+ Window* mpNotifyWindow;
+ mutable ::osl::Mutex maMutex;
+ };
+ }
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx
new file mode 100644
index 000000000000..415c1fa216dd
--- /dev/null
+++ b/avmedia/source/viewer/mediawindow.cxx
@@ -0,0 +1,574 @@
+/* -*- 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 <stdio.h>
+
+#include <avmedia/mediawindow.hxx>
+#include "mediawindow_impl.hxx"
+#include "mediamisc.hxx"
+#include "mediawindow.hrc"
+#include <tools/urlobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/pathoptions.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/media/XManager.hpp>
+#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+
+#define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME_MEDIATIME 3.0
+
+using namespace ::com::sun::star;
+
+namespace avmedia {
+
+// ---------------
+// - MediaWindow -
+// ---------------
+
+MediaWindow::MediaWindow( Window* parent, bool bInternalMediaControl ) :
+ mpImpl( new priv::MediaWindowImpl( parent, this, bInternalMediaControl ) )
+{
+ mpImpl->Show();
+}
+
+// -------------------------------------------------------------------------
+
+MediaWindow::~MediaWindow()
+{
+ mpImpl->cleanUp();
+ delete mpImpl;
+ mpImpl = NULL;
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::setURL( const ::rtl::OUString& rURL )
+{
+ if( mpImpl )
+ mpImpl->setURL( rURL );
+}
+
+// -------------------------------------------------------------------------
+
+const ::rtl::OUString& MediaWindow::getURL() const
+{
+ return mpImpl->getURL();
+}
+
+// -------------------------------------------------------------------------
+
+bool MediaWindow::isValid() const
+{
+ return( mpImpl != NULL && mpImpl->isValid() );
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::MouseMove( const MouseEvent& /* rMEvt */ )
+{
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindow::MouseButtonDown( const MouseEvent& /* rMEvt */ )
+{
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindow::MouseButtonUp( const MouseEvent& /* rMEvt */ )
+{
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::KeyInput( const KeyEvent& /* rKEvt */ )
+{
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::KeyUp( const KeyEvent& /* rKEvt */ )
+{
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::Command( const CommandEvent& /* rCEvt */ )
+{
+}
+
+// -------------------------------------------------------------------------
+
+sal_Int8 MediaWindow::AcceptDrop( const AcceptDropEvent& /* rEvt */ )
+{
+ return 0;
+}
+
+// -------------------------------------------------------------------------
+
+sal_Int8 MediaWindow::ExecuteDrop( const ExecuteDropEvent& /* rEvt */ )
+{
+ return 0;
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::StartDrag( sal_Int8 /* nAction */, const Point& /* rPosPixel */ )
+{
+}
+
+// -------------------------------------------------------------------------
+
+bool MediaWindow::hasPreferredSize() const
+{
+ return( mpImpl != NULL && mpImpl->hasPreferredSize() );
+}
+
+// -------------------------------------------------------------------------
+
+Size MediaWindow::getPreferredSize() const
+{
+ return mpImpl->getPreferredSize();
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::setPosSize( const Rectangle& rNewRect )
+{
+ if( mpImpl )
+ {
+ mpImpl->setPosSize( rNewRect );
+ }
+}
+
+// -------------------------------------------------------------------------
+
+Rectangle MediaWindow::getPosSize() const
+{
+ return Rectangle( mpImpl->GetPosPixel(), mpImpl->GetSizePixel() );
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::setPointer( const Pointer& rPointer )
+{
+ if( mpImpl )
+ mpImpl->setPointer( rPointer );
+}
+
+// -------------------------------------------------------------------------
+
+const Pointer& MediaWindow::getPointer() const
+{
+ return mpImpl->getPointer();
+}
+
+// -------------------------------------------------------------------------
+
+bool MediaWindow::setZoom( ::com::sun::star::media::ZoomLevel eLevel )
+{
+ return( mpImpl != NULL && mpImpl->setZoom( eLevel ) );
+}
+
+// -------------------------------------------------------------------------
+
+::com::sun::star::media::ZoomLevel MediaWindow::getZoom() const
+{
+ return mpImpl->getZoom();
+}
+
+// -------------------------------------------------------------------------
+
+bool MediaWindow::start()
+{
+ return( mpImpl != NULL && mpImpl->start() );
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::stop()
+{
+ if( mpImpl )
+ mpImpl->stop();
+}
+
+// -------------------------------------------------------------------------
+
+bool MediaWindow::isPlaying() const
+{
+ return( mpImpl != NULL && mpImpl->isPlaying() );
+}
+
+// -------------------------------------------------------------------------
+
+double MediaWindow::getDuration() const
+{
+ return mpImpl->getDuration();
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::setMediaTime( double fTime )
+{
+ if( mpImpl )
+ mpImpl->setMediaTime( fTime );
+}
+
+// -------------------------------------------------------------------------
+
+double MediaWindow::getMediaTime() const
+{
+ return mpImpl->getMediaTime();
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::setStopTime( double fTime )
+{
+ if( mpImpl )
+ mpImpl->setStopTime( fTime );
+}
+
+// -------------------------------------------------------------------------
+
+double MediaWindow::getStopTime() const
+{
+ return mpImpl->getStopTime();
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::setRate( double fRate )
+{
+ if( mpImpl )
+ mpImpl->setRate( fRate );
+}
+
+// -------------------------------------------------------------------------
+
+double MediaWindow::getRate() const
+{
+ return mpImpl->getRate();
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::setPlaybackLoop( bool bSet )
+{
+ if( mpImpl )
+ mpImpl->setPlaybackLoop( bSet );
+}
+
+// -------------------------------------------------------------------------
+
+bool MediaWindow::isPlaybackLoop() const
+{
+ return mpImpl->isPlaybackLoop();
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::setMute( bool bSet )
+{
+ if( mpImpl )
+ mpImpl->setMute( bSet );
+}
+
+// -------------------------------------------------------------------------
+
+bool MediaWindow::isMute() const
+{
+ return mpImpl->isMute();
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::updateMediaItem( MediaItem& rItem ) const
+{
+ if( mpImpl )
+ mpImpl->updateMediaItem( rItem );
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::executeMediaItem( const MediaItem& rItem )
+{
+ if( mpImpl )
+ mpImpl->executeMediaItem( rItem );
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::show()
+{
+ if( mpImpl )
+ mpImpl->Show();
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::hide()
+{
+ if( mpImpl )
+ mpImpl->Hide();
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::enable()
+{
+ if( mpImpl )
+ mpImpl->Enable();
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::disable()
+{
+ if( mpImpl )
+ mpImpl->Disable();
+}
+
+// -------------------------------------------------------------------------
+
+Window* MediaWindow::getWindow() const
+{
+ return mpImpl;
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::getMediaFilters( FilterNameVector& rFilterNameVector )
+{
+ static const char* pFilters[] = { "AIF Audio", "aif;aiff",
+ "AU Audio", "au",
+ "AVI", "avi",
+ "CD Audio", "cda",
+ "FLAC Audio", "flac",
+ "Matroska Media", "mkv",
+ "MIDI Audio", "mid;midi",
+ "MPEG Audio", "mp2;mp3;mpa",
+ "MPEG Video", "mpg;mpeg;mpv;mp4",
+ "Ogg bitstream", "ogg",
+ "Quicktime Video", "mov",
+ "Vivo Video", "viv",
+ "WAVE Audio", "wav",
+ "WebM Video", "webm" };
+
+ for( size_t i = 0; i < SAL_N_ELEMENTS(pFilters); i += 2 )
+ {
+ rFilterNameVector.push_back( ::std::make_pair< ::rtl::OUString, ::rtl::OUString >(
+ ::rtl::OUString::createFromAscii(pFilters[i]),
+ ::rtl::OUString::createFromAscii(pFilters[i+1]) ) );
+ }
+}
+
+// -------------------------------------------------------------------------
+
+bool MediaWindow::executeMediaURLDialog( Window* /* pParent */, ::rtl::OUString& rURL, bool bInsertDialog )
+{
+ ::sfx2::FileDialogHelper aDlg( com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
+ static const ::rtl::OUString aWildcard( RTL_CONSTASCII_USTRINGPARAM( "*." ) );
+ FilterNameVector aFilters;
+ const ::rtl::OUString aSeparator( RTL_CONSTASCII_USTRINGPARAM( ";" ) );
+ ::rtl::OUString aAllTypes;
+
+ aDlg.SetTitle( AVMEDIA_RESID( bInsertDialog ? AVMEDIA_STR_INSERTMEDIA_DLG : AVMEDIA_STR_OPENMEDIA_DLG ) );
+
+ getMediaFilters( aFilters );
+
+ unsigned int i;
+ for( i = 0; i < aFilters.size(); ++i )
+ {
+ for( sal_Int32 nIndex = 0; nIndex >= 0; )
+ {
+ if( aAllTypes.getLength() )
+ aAllTypes += aSeparator;
+
+ ( aAllTypes += aWildcard ) += aFilters[ i ].second.getToken( 0, ';', nIndex );
+ }
+ }
+
+ // add filter for all media types
+ aDlg.AddFilter( AVMEDIA_RESID( AVMEDIA_STR_ALL_MEDIAFILES ), aAllTypes );
+
+ for( i = 0; i < aFilters.size(); ++i )
+ {
+ ::rtl::OUString aTypes;
+
+ for( sal_Int32 nIndex = 0; nIndex >= 0; )
+ {
+ if( aTypes.getLength() )
+ aTypes += aSeparator;
+
+ ( aTypes += aWildcard ) += aFilters[ i ].second.getToken( 0, ';', nIndex );
+ }
+
+ // add single filters
+ aDlg.AddFilter( aFilters[ i ].first, aTypes );
+ }
+
+ // add filter for all types
+ aDlg.AddFilter( AVMEDIA_RESID( AVMEDIA_STR_ALL_FILES ), String( RTL_CONSTASCII_USTRINGPARAM( "*.*" ) ) );
+
+ if( aDlg.Execute() == ERRCODE_NONE )
+ {
+ const INetURLObject aURL( aDlg.GetPath() );
+ rURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+ }
+ else if( rURL.getLength() )
+ rURL = ::rtl::OUString();
+
+ return( rURL.getLength() > 0 );
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindow::executeFormatErrorBox( Window* pParent )
+{
+ ErrorBox aErrBox( pParent, AVMEDIA_RESID( AVMEDIA_ERR_URL ) );
+
+ aErrBox.Execute();
+}
+
+// -------------------------------------------------------------------------
+
+bool MediaWindow::isMediaURL( const ::rtl::OUString& rURL, bool bDeep, Size* pPreferredSizePixel )
+{
+ const INetURLObject aURL( rURL );
+ bool bRet = false;
+
+ if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ {
+ if( bDeep || pPreferredSizePixel )
+ {
+ try
+ {
+ uno::Reference< media::XPlayer > xPlayer( priv::MediaWindowImpl::createPlayer(
+ aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) );
+
+ if( xPlayer.is() )
+ {
+ bRet = true;
+
+ if( pPreferredSizePixel )
+ {
+ const awt::Size aAwtSize( xPlayer->getPreferredPlayerWindowSize() );
+
+ pPreferredSizePixel->Width() = aAwtSize.Width;
+ pPreferredSizePixel->Height() = aAwtSize.Height;
+ }
+ }
+ }
+ catch( ... )
+ {
+ }
+ }
+ else
+ {
+ FilterNameVector aFilters;
+ const ::rtl::OUString aExt( aURL.getExtension() );
+
+ getMediaFilters( aFilters );
+
+ unsigned int i;
+ for( i = 0; ( i < aFilters.size() ) && !bRet; ++i )
+ {
+ for( sal_Int32 nIndex = 0; nIndex >= 0 && !bRet; )
+ {
+ if( aExt.equalsIgnoreAsciiCase( aFilters[ i ].second.getToken( 0, ';', nIndex ) ) )
+ bRet = true;
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+
+// -------------------------------------------------------------------------
+
+uno::Reference< media::XPlayer > MediaWindow::createPlayer( const ::rtl::OUString& rURL )
+{
+ return priv::MediaWindowImpl::createPlayer( rURL );
+}
+
+// -------------------------------------------------------------------------
+
+uno::Reference< graphic::XGraphic > MediaWindow::grabFrame( const ::rtl::OUString& rURL,
+ bool bAllowToCreateReplacementGraphic,
+ double fMediaTime )
+{
+ uno::Reference< media::XPlayer > xPlayer( createPlayer( rURL ) );
+ uno::Reference< graphic::XGraphic > xRet;
+ ::std::auto_ptr< Graphic > apGraphic;
+
+ if( xPlayer.is() )
+ {
+ uno::Reference< media::XFrameGrabber > xGrabber( xPlayer->createFrameGrabber() );
+
+ if( xGrabber.is() )
+ {
+ if( AVMEDIA_FRAMEGRABBER_DEFAULTFRAME == fMediaTime )
+ fMediaTime = AVMEDIA_FRAMEGRABBER_DEFAULTFRAME_MEDIATIME;
+
+ if( fMediaTime >= xPlayer->getDuration() )
+ fMediaTime = ( xPlayer->getDuration() * 0.5 );
+
+ xRet = xGrabber->grabFrame( fMediaTime );
+ }
+
+ if( !xRet.is() && bAllowToCreateReplacementGraphic )
+ {
+ awt::Size aPrefSize( xPlayer->getPreferredPlayerWindowSize() );
+
+ if( !aPrefSize.Width && !aPrefSize.Height )
+ {
+ const BitmapEx aBmpEx( AVMEDIA_RESID( AVMEDIA_BMP_AUDIOLOGO ) );
+ apGraphic.reset( new Graphic( aBmpEx ) );
+ }
+ }
+ }
+
+ if( !xRet.is() && !apGraphic.get() && bAllowToCreateReplacementGraphic )
+ {
+ const BitmapEx aBmpEx( AVMEDIA_RESID( AVMEDIA_BMP_EMPTYLOGO ) );
+ apGraphic.reset( new Graphic( aBmpEx ) );
+ }
+
+ if( apGraphic.get() )
+ xRet = apGraphic->GetXGraphic();
+
+ return xRet;
+}
+
+} // namespace avemdia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/viewer/mediawindow.hrc b/avmedia/source/viewer/mediawindow.hrc
new file mode 100755
index 000000000000..67036e300c13
--- /dev/null
+++ b/avmedia/source/viewer/mediawindow.hrc
@@ -0,0 +1,9 @@
+#define AVMEDIA_STR_OPENMEDIA_DLG 16384
+#define AVMEDIA_STR_INSERTMEDIA_DLG 16385
+#define AVMEDIA_STR_ALL_MEDIAFILES 16386
+#define AVMEDIA_STR_ALL_FILES 16387
+
+#define AVMEDIA_BMP_AUDIOLOGO 20000
+#define AVMEDIA_BMP_EMPTYLOGO 20001
+
+#define AVMEDIA_ERR_URL 21000
diff --git a/avmedia/source/viewer/mediawindow.src b/avmedia/source/viewer/mediawindow.src
new file mode 100644
index 000000000000..1c92b4d913af
--- /dev/null
+++ b/avmedia/source/viewer/mediawindow.src
@@ -0,0 +1,77 @@
+ /*************************************************************************
+ *
+ * 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 "mediawindow.hrc"
+
+String AVMEDIA_STR_INSERTMEDIA_DLG
+{
+ Text[en-US] = "Insert Movie and Sound";
+};
+
+// ------------------------------------------------------------------------------
+
+STRING AVMEDIA_STR_OPENMEDIA_DLG
+{
+ Text[en-US] = "Open Movie and Sound";
+};
+
+// ------------------------------------------------------------------------------
+
+String AVMEDIA_STR_ALL_MEDIAFILES
+{
+ Text[en-US] = "All movie and sound files";
+};
+
+// ------------------------------------------------------------------------------
+
+String AVMEDIA_STR_ALL_FILES
+{
+ Text[en-US] = "All files (*.*)";
+};
+
+// ------------------------------------------------------------------------------
+
+Bitmap AVMEDIA_BMP_AUDIOLOGO
+{
+ file = "avaudiologo.png";
+};
+
+// ------------------------------------------------------------------------------
+
+Bitmap AVMEDIA_BMP_EMPTYLOGO
+{
+ file = "avemptylogo.png";
+};
+
+// ------------------------------------------------------------------------------
+
+ErrorBox AVMEDIA_ERR_URL
+{
+ BUTTONS = WB_OK ;
+ DEFBUTTON = WB_DEF_OK ;
+ Message[en-US] = "The format of the selected file is not supported.";
+};
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx
new file mode 100644
index 000000000000..c79fea8c033f
--- /dev/null
+++ b/avmedia/source/viewer/mediawindow_impl.cxx
@@ -0,0 +1,546 @@
+/* -*- 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 "mediawindow_impl.hxx"
+#include "mediaevent_impl.hxx"
+#include "mediamisc.hxx"
+#include "mediawindow.hrc"
+#include "helpids.hrc"
+
+#include <algorithm>
+#include <cmath>
+#include <osl/mutex.hxx>
+#include <tools/time.hxx>
+#include <vcl/svapp.hxx>
+#ifdef UNX
+#include <vcl/sysdata.hxx>
+#endif
+
+#include <com/sun/star/awt/SystemPointer.hdl>
+#include <com/sun/star/lang/XComponent.hdl>
+
+#define AVMEDIA_TOOLBOXITEM_PREV 0x0001
+#define AVMEDIA_TOOLBOXITEM_PLAY 0x0002
+#define AVMEDIA_TOOLBOXITEM_PAUSE 0x0004
+#define AVMEDIA_TOOLBOXITEM_STOP 0x0008
+#define AVMEDIA_TOOLBOXITEM_NEXT 0x0010
+#define AVMEDIA_TOOLBOXITEM_MUTE 0x0100
+
+#define AVMEDIA_FFW_PLAYRATE 4
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace priv {
+
+// ----------------------
+// - MediaWindowControl -
+// ----------------------
+
+MediaWindowControl::MediaWindowControl( Window* pParent ) :
+ MediaControl( pParent, MEDIACONTROLSTYLE_MULTILINE )
+{
+}
+
+// ---------------------------------------------------------------------
+
+MediaWindowControl::~MediaWindowControl()
+{
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowControl::update()
+{
+ MediaItem aItem;
+
+ static_cast< MediaWindowImpl* >( GetParent() )->updateMediaItem( aItem );
+ setState( aItem );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowControl::execute( const MediaItem& rItem )
+{
+ static_cast< MediaWindowImpl* >( GetParent() )->executeMediaItem( rItem );
+}
+
+// --------------------
+// - MediaChildWindow -
+// --------------------
+
+MediaChildWindow::MediaChildWindow( Window* pParent ) :
+ SystemChildWindow( pParent, WB_CLIPCHILDREN )
+{
+}
+
+// ---------------------------------------------------------------------
+
+MediaChildWindow::~MediaChildWindow()
+{
+}
+
+// ---------------------------------------------------------------------
+
+void MediaChildWindow::MouseMove( const MouseEvent& rMEvt )
+{
+ const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
+ rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
+
+ SystemChildWindow::MouseMove( rMEvt );
+ GetParent()->MouseMove( aTransformedEvent );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaChildWindow::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
+ rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
+
+ SystemChildWindow::MouseButtonDown( rMEvt );
+ GetParent()->MouseButtonDown( aTransformedEvent );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaChildWindow::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
+ rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
+
+ SystemChildWindow::MouseButtonUp( rMEvt );
+ GetParent()->MouseButtonUp( aTransformedEvent );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaChildWindow::KeyInput( const KeyEvent& rKEvt )
+{
+ SystemChildWindow::KeyInput( rKEvt );
+ GetParent()->KeyInput( rKEvt );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaChildWindow::KeyUp( const KeyEvent& rKEvt )
+{
+ SystemChildWindow::KeyUp( rKEvt );
+ GetParent()->KeyUp( rKEvt );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaChildWindow::Command( const CommandEvent& rCEvt )
+{
+ const CommandEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ),
+ rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetData() );
+
+ SystemChildWindow::Command( rCEvt );
+ GetParent()->Command( aTransformedEvent );
+}
+
+// ----------------------
+// - MediaWindowImpl -
+// ----------------------
+
+MediaWindowImpl::MediaWindowImpl( Window* pParent, MediaWindow* pMediaWindow, bool bInternalMediaControl ) :
+ Control( pParent ),
+ MediaWindowBaseImpl( pMediaWindow ),
+ DropTargetHelper( this ),
+ DragSourceHelper( this ),
+ mxEventsIf( static_cast< ::cppu::OWeakObject* >( mpEvents = new MediaEventListenersImpl( maChildWindow ) ) ),
+ maChildWindow( this ),
+ mpMediaWindowControl( bInternalMediaControl ? new MediaWindowControl( this ) : NULL ),
+ mpEmptyBmpEx( NULL ),
+ mpAudioBmpEx( NULL )
+{
+ maChildWindow.SetBackground( Color( COL_BLACK ) );
+ maChildWindow.SetHelpId( HID_AVMEDIA_PLAYERWINDOW );
+ maChildWindow.Hide();
+
+ if( mpMediaWindowControl )
+ {
+ mpMediaWindowControl->SetSizePixel( mpMediaWindowControl->getMinSizePixel() );
+ mpMediaWindowControl->Show();
+ }
+}
+
+// ---------------------------------------------------------------------
+
+MediaWindowImpl::~MediaWindowImpl()
+{
+ delete mpEmptyBmpEx;
+ delete mpAudioBmpEx;
+ delete mpMediaWindowControl;
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::cleanUp()
+{
+ uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() );
+
+ mpEvents->cleanUp();
+
+ if( xPlayerWindow.is() )
+ {
+ xPlayerWindow->removeKeyListener( uno::Reference< awt::XKeyListener >( mxEventsIf, uno::UNO_QUERY ) );
+ xPlayerWindow->removeMouseListener( uno::Reference< awt::XMouseListener >( mxEventsIf, uno::UNO_QUERY ) );
+ xPlayerWindow->removeMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( mxEventsIf, uno::UNO_QUERY ) );
+
+ uno::Reference< lang::XComponent > xComponent( xPlayerWindow, uno::UNO_QUERY );
+
+ if( xComponent.is() )
+ xComponent->dispose();
+
+ setPlayerWindow( NULL );
+ }
+
+ MediaWindowBaseImpl::cleanUp();
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::onURLChanged()
+{
+ if( getPlayer().is() )
+ {
+ uno::Sequence< uno::Any > aArgs( 3 );
+ uno::Reference< media::XPlayerWindow > xPlayerWindow;
+ const Point aPoint;
+ const Size aSize( maChildWindow.GetSizePixel() );
+ const sal_Int32 nWndHandle = 0;
+
+ aArgs[ 0 ] = uno::makeAny( nWndHandle );
+ aArgs[ 1 ] = uno::makeAny( awt::Rectangle( aPoint.X(), aPoint.Y(), aSize.Width(), aSize.Height() ) );
+ aArgs[ 2 ] = uno::makeAny( reinterpret_cast< sal_IntPtr >( &maChildWindow ) );
+
+ try
+ {
+ xPlayerWindow = getPlayer()->createPlayerWindow( aArgs );
+ }
+ catch( uno::RuntimeException )
+ {
+ // happens eg, on MacOSX where Java frames cannot be created from X11 window handles
+ }
+
+ setPlayerWindow( xPlayerWindow );
+
+ if( xPlayerWindow.is() )
+ {
+ xPlayerWindow->addKeyListener( uno::Reference< awt::XKeyListener >( mxEventsIf, uno::UNO_QUERY ) );
+ xPlayerWindow->addMouseListener( uno::Reference< awt::XMouseListener >( mxEventsIf, uno::UNO_QUERY ) );
+ xPlayerWindow->addMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( mxEventsIf, uno::UNO_QUERY ) );
+ xPlayerWindow->addFocusListener( uno::Reference< awt::XFocusListener >( mxEventsIf, uno::UNO_QUERY ) );
+ }
+ }
+ else
+ setPlayerWindow( NULL );
+
+ if( getPlayerWindow().is() )
+ maChildWindow.Show();
+ else
+ maChildWindow.Hide();
+
+ if( mpMediaWindowControl )
+ {
+ MediaItem aItem;
+
+ updateMediaItem( aItem );
+ mpMediaWindowControl->setState( aItem );
+ }
+
+ Invalidate();
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::update()
+{
+ uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() );
+
+ if( xPlayerWindow.is() )
+ xPlayerWindow->update();
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::setPosSize( const Rectangle& rRect )
+{
+ SetPosSizePixel( rRect.TopLeft(), rRect.GetSize() );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::setPointer( const Pointer& rPointer )
+{
+ uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() );
+
+ SetPointer( rPointer );
+ maChildWindow.SetPointer( rPointer );
+
+ if( xPlayerWindow.is() )
+ {
+ long nPointer;
+
+ switch( rPointer.GetStyle() )
+ {
+ case( POINTER_CROSS ): nPointer = awt::SystemPointer::CROSS; break;
+ case( POINTER_HAND ): nPointer = awt::SystemPointer::HAND; break;
+ case( POINTER_MOVE ): nPointer = awt::SystemPointer::MOVE; break;
+ case( POINTER_WAIT ): nPointer = awt::SystemPointer::WAIT; break;
+
+ default: nPointer = awt::SystemPointer::ARROW; break;
+ }
+
+ xPlayerWindow->setPointerType( nPointer );
+ }
+}
+
+// ---------------------------------------------------------------------
+
+const Pointer& MediaWindowImpl::getPointer() const
+{
+ return GetPointer();
+}
+
+// ---------------------------------------------------------------------
+
+bool MediaWindowImpl::hasInternalMediaControl() const
+{
+ return( mpMediaWindowControl != NULL );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::Resize()
+{
+ uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() );
+ const Size aCurSize( GetOutputSizePixel() );
+ const sal_Int32 nOffset( mpMediaWindowControl ? AVMEDIA_CONTROLOFFSET : 0 );
+ Size aPlayerWindowSize( aCurSize.Width() - ( nOffset << 1 ),
+ aCurSize.Height() - ( nOffset << 1 ) );
+
+ if( mpMediaWindowControl )
+ {
+ const sal_Int32 nControlHeight = mpMediaWindowControl->GetSizePixel().Height();
+ const sal_Int32 nControlY = ::std::max( aCurSize.Height() - nControlHeight - nOffset, 0L );
+
+ aPlayerWindowSize.Height() = ( nControlY - ( nOffset << 1 ) );
+ mpMediaWindowControl->SetPosSizePixel( Point( nOffset, nControlY ), Size( aCurSize.Width() - ( nOffset << 1 ), nControlHeight ) );
+ }
+
+ if( xPlayerWindow.is() )
+ xPlayerWindow->setPosSize( 0, 0, aPlayerWindowSize.Width(), aPlayerWindowSize.Height(), 0 );
+
+ maChildWindow.SetPosSizePixel( Point( nOffset, nOffset ), aPlayerWindowSize );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::StateChanged( StateChangedType eType )
+{
+ uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() );
+
+ if( xPlayerWindow.is() )
+ {
+ // stop playing when going disabled or hidden
+ switch( eType )
+ {
+ case STATE_CHANGE_VISIBLE:
+ {
+ stopPlayingInternal( !IsVisible() );
+ xPlayerWindow->setVisible( IsVisible() );
+ }
+ break;
+
+ case STATE_CHANGE_ENABLE:
+ {
+ stopPlayingInternal( !IsEnabled() );
+ xPlayerWindow->setEnable( IsEnabled() );
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::Paint( const Rectangle& )
+{
+ BitmapEx* pLogo = NULL;
+
+ if( !getPlayer().is() )
+ {
+ if( !mpEmptyBmpEx )
+ mpEmptyBmpEx = new BitmapEx( AVMEDIA_RESID( AVMEDIA_BMP_EMPTYLOGO ) );
+
+ pLogo = mpEmptyBmpEx;
+ }
+ else if( !getPlayerWindow().is() )
+ {
+ if( !mpAudioBmpEx )
+ mpAudioBmpEx = new BitmapEx( AVMEDIA_RESID( AVMEDIA_BMP_AUDIOLOGO ) );
+
+ pLogo = mpAudioBmpEx;
+ }
+
+ const Point aBasePos( maChildWindow.GetPosPixel() );
+ const Rectangle aVideoRect( aBasePos, maChildWindow.GetSizePixel() );
+
+ if( pLogo && !pLogo->IsEmpty() && ( aVideoRect.GetWidth() > 0 ) && ( aVideoRect.GetHeight() > 0 ) )
+ {
+ Size aLogoSize( pLogo->GetSizePixel() );
+ const Color aBackgroundColor( 67, 67, 67 );
+
+ SetLineColor( aBackgroundColor );
+ SetFillColor( aBackgroundColor );
+ DrawRect( aVideoRect );
+
+ if( ( aLogoSize.Width() > aVideoRect.GetWidth() || aLogoSize.Height() > aVideoRect.GetHeight() ) &&
+ ( aLogoSize.Height() > 0 ) )
+ {
+ const double fLogoWH = (double) aLogoSize.Width() / aLogoSize.Height();
+
+ if( fLogoWH < ( (double) aVideoRect.GetWidth() / aVideoRect.GetHeight() ) )
+ {
+ aLogoSize.Width() = (long) ( aVideoRect.GetHeight() * fLogoWH );
+ aLogoSize.Height()= aVideoRect.GetHeight();
+ }
+ else
+ {
+ aLogoSize.Width() = aVideoRect.GetWidth();
+ aLogoSize.Height()= (long) ( aVideoRect.GetWidth() / fLogoWH );
+ }
+ }
+
+ DrawBitmapEx( Point( aBasePos.X() + ( ( aVideoRect.GetWidth() - aLogoSize.Width() ) >> 1 ),
+ aBasePos.Y() + ( ( aVideoRect.GetHeight() - aLogoSize.Height() ) >> 1 ) ),
+ aLogoSize, *pLogo );
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::GetFocus()
+{
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::MouseMove( const MouseEvent& rMEvt )
+{
+ MediaWindow* pMediaWindow = getMediaWindow();
+
+ if( pMediaWindow )
+ pMediaWindow->MouseMove( rMEvt );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ MediaWindow* pMediaWindow = getMediaWindow();
+
+ if( pMediaWindow )
+ pMediaWindow->MouseButtonDown( rMEvt );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ MediaWindow* pMediaWindow = getMediaWindow();
+
+ if( pMediaWindow )
+ pMediaWindow->MouseButtonUp( rMEvt );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::KeyInput( const KeyEvent& rKEvt )
+{
+ MediaWindow* pMediaWindow = getMediaWindow();
+
+ if( pMediaWindow )
+ pMediaWindow->KeyInput( rKEvt );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::KeyUp( const KeyEvent& rKEvt )
+{
+ MediaWindow* pMediaWindow = getMediaWindow();
+
+ if( pMediaWindow )
+ pMediaWindow->KeyUp( rKEvt );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::Command( const CommandEvent& rCEvt )
+{
+ MediaWindow* pMediaWindow = getMediaWindow();
+
+ if( pMediaWindow )
+ pMediaWindow->Command( rCEvt );
+}
+
+// ---------------------------------------------------------------------
+
+sal_Int8 MediaWindowImpl::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ MediaWindow* pMediaWindow = getMediaWindow();
+ return( pMediaWindow ? pMediaWindow->AcceptDrop( rEvt ) : 0 );
+}
+
+// ---------------------------------------------------------------------
+
+sal_Int8 MediaWindowImpl::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ MediaWindow* pMediaWindow = getMediaWindow();
+ return( pMediaWindow ? pMediaWindow->ExecuteDrop( rEvt ) : 0 );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowImpl::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
+{
+ MediaWindow* pMediaWindow = getMediaWindow();
+
+ if( pMediaWindow )
+ pMediaWindow->StartDrag( nAction, rPosPixel );
+}
+
+} // namespace priv
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/viewer/mediawindow_impl.hxx b/avmedia/source/viewer/mediawindow_impl.hxx
new file mode 100644
index 000000000000..fa44d2158863
--- /dev/null
+++ b/avmedia/source/viewer/mediawindow_impl.hxx
@@ -0,0 +1,151 @@
+/* -*- 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 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mediawindow_impl.hxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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 _AVMEDIA_MEDIAWINDOW_IMPL_HXX
+#define _AVMEDIA_MEDIAWINDOW_IMPL_HXX
+
+#include <svtools/transfer.hxx>
+#include <vcl/syschild.hxx>
+
+#include "mediawindowbase_impl.hxx"
+#include "mediacontrol.hxx"
+
+class BitmapEx;
+
+namespace avmedia
+{
+ namespace priv
+ {
+ // ----------------------
+ // - MediaWindowControl -
+ // ----------------------
+
+ class MediaWindowControl : public MediaControl
+ {
+ public:
+
+ MediaWindowControl( Window* pParent );
+ ~MediaWindowControl();
+
+ protected:
+
+ void update();
+ void execute( const MediaItem& rItem );
+ };
+
+ // --------------------
+ // - MediaChildWindow -
+ // --------------------
+
+ class MediaChildWindow : public SystemChildWindow
+ {
+ public:
+
+ MediaChildWindow( Window* pParent );
+ ~MediaChildWindow();
+
+ protected:
+
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void KeyUp( const KeyEvent& rKEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+ };
+
+ // ------------------.
+ // - MediaWindowImpl -
+ // -------------------
+
+ class MediaEventListenersImpl;
+
+ class MediaWindowImpl : public Control,
+ public MediaWindowBaseImpl,
+ public DropTargetHelper,
+ public DragSourceHelper
+
+ {
+ public:
+
+ MediaWindowImpl( Window* parent, MediaWindow* pMediaWindow, bool bInternalMediaControl );
+ virtual ~MediaWindowImpl();
+
+ virtual void cleanUp();
+ virtual void onURLChanged();
+
+ public:
+
+ void update();
+
+ void setPosSize( const Rectangle& rRect );
+
+ void setPointer( const Pointer& rPointer );
+ const Pointer& getPointer() const;
+
+ bool hasInternalMediaControl() const;
+
+ protected:
+
+ // Window
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void KeyUp( const KeyEvent& rKEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void Resize();
+ virtual void StateChanged( StateChangedType );
+ virtual void Paint( const Rectangle& ); // const
+ virtual void GetFocus();
+
+ // DropTargetHelper
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+ // DragSourceHelper
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+ private:
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxEventsIf;
+ MediaEventListenersImpl* mpEvents;
+ MediaChildWindow maChildWindow;
+ MediaWindowControl* mpMediaWindowControl;
+ BitmapEx* mpEmptyBmpEx;
+ BitmapEx* mpAudioBmpEx;
+ };
+ }
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/viewer/mediawindowbase_impl.cxx b/avmedia/source/viewer/mediawindowbase_impl.cxx
new file mode 100644
index 000000000000..6c2db96b16a3
--- /dev/null
+++ b/avmedia/source/viewer/mediawindowbase_impl.cxx
@@ -0,0 +1,435 @@
+/* -*- 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 "mediawindowbase_impl.hxx"
+#include <avmedia/mediaitem.hxx>
+#include "mediamisc.hxx"
+#include "mediawindow.hrc"
+#include <tools/urlobj.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/media/XManager.hpp>
+#include <com/sun/star/lang/XComponent.hdl>
+
+#define MEDIA_TIMER_TIMEOUT 100
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace priv {
+
+// -----------------------
+// - MediaWindowBaseImpl -
+// -----------------------
+
+
+MediaWindowBaseImpl::MediaWindowBaseImpl( MediaWindow* pMediaWindow ) :
+ mpMediaWindow( pMediaWindow )
+{
+}
+
+// ---------------------------------------------------------------------
+
+MediaWindowBaseImpl::~MediaWindowBaseImpl()
+{
+ uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
+}
+
+// -------------------------------------------------------------------------
+
+uno::Reference< media::XPlayer > MediaWindowBaseImpl::createPlayer( const ::rtl::OUString& rURL )
+{
+ uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
+ uno::Reference< media::XPlayer > xPlayer;
+
+ if( xFactory.is() )
+ {
+ try
+ {
+
+ uno::Reference< ::com::sun::star::media::XManager > xManager(
+ xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_MANAGER_SERVICE_NAME )) ),
+ uno::UNO_QUERY );
+
+ if( xManager.is() )
+ {
+ xPlayer = uno::Reference< ::com::sun::star::media::XPlayer >(
+ xManager->createPlayer( rURL ), uno::UNO_QUERY );
+ }
+ }
+ catch( ... )
+ {
+ }
+ }
+
+ return xPlayer;
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowBaseImpl::setURL( const ::rtl::OUString& rURL )
+{
+ if( rURL != getURL() )
+ {
+ INetURLObject aURL( maFileURL = rURL );
+
+ if( mxPlayer.is() )
+ mxPlayer->stop();
+
+ if( mxPlayerWindow.is() )
+ {
+ mxPlayerWindow->setVisible( false );
+ mxPlayerWindow.clear();
+ }
+
+ mxPlayer.clear();
+
+ if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ maFileURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+
+ mxPlayer = createPlayer( maFileURL );
+ onURLChanged();
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowBaseImpl::onURLChanged()
+{
+}
+
+// ---------------------------------------------------------------------
+
+const ::rtl::OUString& MediaWindowBaseImpl::getURL() const
+{
+ return maFileURL;
+}
+
+// ---------------------------------------------------------------------
+
+bool MediaWindowBaseImpl::isValid() const
+{
+ return( getPlayer().is() );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowBaseImpl::stopPlayingInternal( bool bStop )
+{
+ if( isPlaying() )
+ {
+ bStop ? mxPlayer->stop() : mxPlayer->start();
+ }
+}
+
+// ---------------------------------------------------------------------
+
+MediaWindow* MediaWindowBaseImpl::getMediaWindow() const
+{
+ return mpMediaWindow;
+}
+
+// ---------------------------------------------------------------------
+
+uno::Reference< media::XPlayer > MediaWindowBaseImpl::getPlayer() const
+{
+ return mxPlayer;
+}
+
+// ---------------------------------------------------------------------
+
+uno::Reference< media::XPlayerWindow > MediaWindowBaseImpl::getPlayerWindow() const
+{
+ return mxPlayerWindow;
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowBaseImpl::setPlayerWindow( const uno::Reference< media::XPlayerWindow >& rxPlayerWindow )
+{
+ mxPlayerWindow = rxPlayerWindow;
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowBaseImpl::cleanUp()
+{
+ if( mxPlayer.is() )
+ {
+ mxPlayer->stop();
+
+ uno::Reference< lang::XComponent > xComponent( mxPlayer, uno::UNO_QUERY );
+
+ if( xComponent.is() )
+ xComponent->dispose();
+
+ mxPlayer.clear();
+ }
+
+ mpMediaWindow = NULL;
+}
+
+// ---------------------------------------------------------------------
+
+bool MediaWindowBaseImpl::hasPreferredSize() const
+{
+ return( mxPlayerWindow.is() );
+}
+
+// ---------------------------------------------------------------------
+
+Size MediaWindowBaseImpl::getPreferredSize() const
+{
+ Size aRet;
+
+ if( mxPlayer.is() )
+ {
+ awt::Size aPrefSize( mxPlayer->getPreferredPlayerWindowSize() );
+
+ aRet.Width() = aPrefSize.Width;
+ aRet.Height() = aPrefSize.Height;
+ }
+
+ return aRet;
+}
+
+// ---------------------------------------------------------------------
+
+bool MediaWindowBaseImpl::setZoom( ::com::sun::star::media::ZoomLevel eLevel )
+{
+ return( mxPlayerWindow.is() ? mxPlayerWindow->setZoomLevel( eLevel ) : false );
+}
+
+// -------------------------------------------------------------------------
+
+::com::sun::star::media::ZoomLevel MediaWindowBaseImpl::getZoom() const
+{
+ return( mxPlayerWindow.is() ? mxPlayerWindow->getZoomLevel() : ::com::sun::star::media::ZoomLevel_NOT_AVAILABLE );
+}
+
+// ---------------------------------------------------------------------
+
+bool MediaWindowBaseImpl::start()
+{
+ return( mxPlayer.is() ? ( mxPlayer->start(), true ) : false );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowBaseImpl::stop()
+{
+ if( mxPlayer.is() )
+ mxPlayer->stop();
+}
+
+// ---------------------------------------------------------------------
+
+bool MediaWindowBaseImpl::isPlaying() const
+{
+ return( mxPlayer.is() && mxPlayer->isPlaying() );
+}
+
+// ---------------------------------------------------------------------
+
+double MediaWindowBaseImpl::getDuration() const
+{
+ return( mxPlayer.is() ? mxPlayer->getDuration() : 0.0 );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowBaseImpl::setMediaTime( double fTime )
+{
+ if( mxPlayer.is() )
+ mxPlayer->setMediaTime( fTime );
+}
+
+// ---------------------------------------------------------------------
+
+double MediaWindowBaseImpl::getMediaTime() const
+{
+ return( mxPlayer.is() ? mxPlayer->getMediaTime() : 0.0 );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowBaseImpl::setStopTime( double fTime )
+{
+ if( mxPlayer.is() )
+ mxPlayer->setStopTime( fTime );
+}
+
+// ---------------------------------------------------------------------
+
+double MediaWindowBaseImpl::getStopTime() const
+{
+ return( mxPlayer.is() ? mxPlayer->getStopTime() : 0.0 );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowBaseImpl::setRate( double fRate )
+{
+ if( mxPlayer.is() )
+ mxPlayer->setRate( fRate );
+}
+
+// ---------------------------------------------------------------------
+
+double MediaWindowBaseImpl::getRate() const
+{
+ return( mxPlayer.is() ? mxPlayer->getRate() : 0.0 );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowBaseImpl::setPlaybackLoop( bool bSet )
+{
+ if( mxPlayer.is() )
+ mxPlayer->setPlaybackLoop( bSet );
+}
+
+// ---------------------------------------------------------------------
+
+bool MediaWindowBaseImpl::isPlaybackLoop() const
+{
+ return( mxPlayer.is() ? mxPlayer->isPlaybackLoop() : false );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowBaseImpl::setMute( bool bSet )
+{
+ if( mxPlayer.is() )
+ mxPlayer->setMute( bSet );
+}
+
+// ---------------------------------------------------------------------
+
+bool MediaWindowBaseImpl::isMute() const
+{
+ return( mxPlayer.is() ? mxPlayer->isMute() : false );
+}
+
+// ---------------------------------------------------------------------
+
+void MediaWindowBaseImpl::setVolumeDB( sal_Int16 nVolumeDB )
+{
+ if( mxPlayer.is() )
+ mxPlayer->setVolumeDB( nVolumeDB );
+}
+
+// ---------------------------------------------------------------------
+
+sal_Int16 MediaWindowBaseImpl::getVolumeDB() const
+{
+ return( mxPlayer.is() ? mxPlayer->getVolumeDB() : 0 );
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindowBaseImpl::updateMediaItem( MediaItem& rItem ) const
+{
+ if( isPlaying() )
+ rItem.setState( ( getRate() > 1.0 ) ? MEDIASTATE_PLAYFFW : MEDIASTATE_PLAY );
+ else
+ rItem.setState( ( 0.0 == getMediaTime() ) ? MEDIASTATE_STOP : MEDIASTATE_PAUSE );
+
+ rItem.setDuration( getDuration() );
+ rItem.setTime( getMediaTime() );
+ rItem.setLoop( isPlaybackLoop() );
+ rItem.setMute( isMute() );
+ rItem.setVolumeDB( getVolumeDB() );
+ rItem.setZoom( getZoom() );
+ rItem.setURL( getURL() );
+}
+
+// -------------------------------------------------------------------------
+
+void MediaWindowBaseImpl::executeMediaItem( const MediaItem& rItem )
+{
+ const sal_uInt32 nMaskSet = rItem.getMaskSet();
+
+ // set URL first
+ if( nMaskSet & AVMEDIA_SETMASK_URL )
+ setURL( rItem.getURL() );
+
+ // set different states next
+ if( nMaskSet & AVMEDIA_SETMASK_TIME )
+ setMediaTime( ::std::min( rItem.getTime(), getDuration() ) );
+
+ if( nMaskSet & AVMEDIA_SETMASK_LOOP )
+ setPlaybackLoop( rItem.isLoop() );
+
+ if( nMaskSet & AVMEDIA_SETMASK_MUTE )
+ setMute( rItem.isMute() );
+
+ if( nMaskSet & AVMEDIA_SETMASK_VOLUMEDB )
+ setVolumeDB( rItem.getVolumeDB() );
+
+ if( nMaskSet & AVMEDIA_SETMASK_ZOOM )
+ setZoom( rItem.getZoom() );
+
+ // set play state at last
+ if( nMaskSet & AVMEDIA_SETMASK_STATE )
+ {
+ switch( rItem.getState() )
+ {
+ case( MEDIASTATE_PLAY ):
+ case( MEDIASTATE_PLAYFFW ):
+ {
+
+ if( !isPlaying() )
+ start();
+ }
+ break;
+
+ case( MEDIASTATE_PAUSE ):
+ {
+ if( isPlaying() )
+ stop();
+ }
+ break;
+
+ case( MEDIASTATE_STOP ):
+ {
+ if( isPlaying() )
+ {
+ setMediaTime( 0.0 );
+ stop();
+ setMediaTime( 0.0 );
+ }
+ }
+ break;
+ }
+ }
+}
+
+} // namespace priv
+} // namespace avemdia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/viewer/mediawindowbase_impl.hxx b/avmedia/source/viewer/mediawindowbase_impl.hxx
new file mode 100644
index 000000000000..1aa615a5986f
--- /dev/null
+++ b/avmedia/source/viewer/mediawindowbase_impl.hxx
@@ -0,0 +1,136 @@
+/* -*- 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 _AVMEDIA_MEDIAWINDOWBASE_IMPL_HXX
+#define _AVMEDIA_MEDIAWINDOWBASE_IMPL_HXX
+
+#include <avmedia/mediawindow.hxx>
+#include <com/sun/star/media/XPlayer.hpp>
+#include <com/sun/star/media/XPlayerWindow.hpp>
+
+namespace avmedia
+{
+ namespace priv
+ {
+ // --------------
+ // - UpdateMode -
+ // --------------
+
+ enum UpdateMode
+ {
+ UPDATEMODE_SYNC_STATUSBAR = 0,
+ UPDATEMODE_SYNC_PLAYER = 1,
+ UPDATEMODE_SYNC_NONE = 2
+ };
+
+ // -----------------------
+ // - MediaWindowBaseImpl -
+ // -----------------------
+
+ class MediaWindowBaseImpl
+ {
+ public:
+
+ MediaWindowBaseImpl( MediaWindow* pMediaWindow );
+ virtual ~MediaWindowBaseImpl();
+
+ virtual void cleanUp();
+ virtual void onURLChanged();
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const ::rtl::OUString& rURL);
+
+ public:
+
+ void setURL( const ::rtl::OUString& rURL );
+ const ::rtl::OUString& getURL() const;
+
+ bool isValid() const;
+
+ bool hasPreferredSize() const;
+ Size getPreferredSize() const;
+
+ bool setZoom( ::com::sun::star::media::ZoomLevel eLevel );
+ ::com::sun::star::media::ZoomLevel getZoom() const;
+
+ bool start();
+ void stop();
+
+ bool isPlaying() const;
+
+ double getDuration() const;
+
+ void setMediaTime( double fTime );
+ double getMediaTime() const;
+
+ void setStopTime( double fTime );
+ double getStopTime() const;
+
+ void setRate( double fRate );
+ double getRate() const;
+
+ void setPlaybackLoop( bool bSet );
+ bool isPlaybackLoop() const;
+
+ void setFixedAspectRatio( bool bSet );
+ bool isFixedAspectRatio() const;
+
+ void setMute( bool bSet );
+ bool isMute() const;
+
+ void setVolumeDB( sal_Int16 nVolumeDB );
+ sal_Int16 getVolumeDB() const;
+
+ void updateMediaItem( MediaItem& rItem ) const;
+ void executeMediaItem( const MediaItem& rItem );
+
+ protected:
+
+ void stopPlayingInternal( bool );
+
+ MediaWindow* getMediaWindow() const;
+ inline sal_Bool isMediaWindowJavaBased() const { return( mbIsMediaWindowJavaBased ); }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > getPlayer() const;
+
+ void setPlayerWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow >& rxPlayerWindow );
+ ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > getPlayerWindow() const;
+
+ private:
+
+ ::rtl::OUString maFileURL;
+ ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > mxPlayerWindow;
+ MediaWindow* mpMediaWindow;
+ sal_Bool mbIsMediaWindowJavaBased;
+ };
+ }
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/win/avmediawin.component b/avmedia/source/win/avmediawin.component
new file mode 100755
index 000000000000..c80c19bff0d9
--- /dev/null
+++ b/avmedia/source/win/avmediawin.component
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* 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.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.SharedLibrary"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.avmedia.Manager_DirectX">
+ <service name="com.sun.star.media.Manager_DirectX"/>
+ </implementation>
+</component>
diff --git a/avmedia/source/win/exports.dxp b/avmedia/source/win/exports.dxp
new file mode 100755
index 000000000000..926e49f5f1a5
--- /dev/null
+++ b/avmedia/source/win/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_getFactory
+
diff --git a/avmedia/source/win/framegrabber.cxx b/avmedia/source/win/framegrabber.cxx
new file mode 100644
index 000000000000..9743d1230e62
--- /dev/null
+++ b/avmedia/source/win/framegrabber.cxx
@@ -0,0 +1,249 @@
+/* -*- 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.
+ *
+ ************************************************************************/
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable: 4917)
+#endif
+#include <prewin.h>
+#include <postwin.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 "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..314a9356c9f0
--- /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,
+ 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(
+ 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(
+ 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 100755
index 000000000000..7c6c9e14da6e
--- /dev/null
+++ b/avmedia/source/win/makefile.mk
@@ -0,0 +1,88 @@
+#*************************************************************************
+#
+# 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
+
+ALLTAR : $(MISC)/avmediawin.component
+
+$(MISC)/avmediawin.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ avmediawin.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt avmediawin.component
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..c2dea25f22c0
--- /dev/null
+++ b/avmedia/source/win/player.cxx
@@ -0,0 +1,495 @@
+/* -*- 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.
+ *
+ ************************************************************************/
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable: 4917)
+#endif
+#include <objbase.h>
+#include <strmif.h>
+#include <control.h>
+#include <uuids.h>
+#include <evcode.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#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..c1b543d2a9a3
--- /dev/null
+++ b/avmedia/source/win/window.cxx
@@ -0,0 +1,707 @@
+/* -*- 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.
+ *
+ ************************************************************************/
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable: 4917)
+#endif
+#include <objbase.h>
+#include <strmif.h>
+#include <control.h>
+#include <dshow.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#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 );
+
+ 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();
+ }
+ }
+
+ 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::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..90fc361b24de
--- /dev/null
+++ b/avmedia/source/win/winuno.cxx
@@ -0,0 +1,80 @@
+/* -*- 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_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.avmedia.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.avmedia.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: */
diff --git a/avmedia/util/avmedia.component b/avmedia/util/avmedia.component
new file mode 100755
index 000000000000..fa01dc03eb9c
--- /dev/null
+++ b/avmedia/util/avmedia.component
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* 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.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.SharedLibrary"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.framework.SoundHandler">
+ <service name="com.sun.star.frame.ContentHandler"/>
+ </implementation>
+</component>
diff --git a/avmedia/util/hidother.src b/avmedia/util/hidother.src
new file mode 100644
index 000000000000..c6d5dc07c9a5
--- /dev/null
+++ b/avmedia/util/hidother.src
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * 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 "../inc/helpids.hrc"
+
+hidspecial HID_AVMEDIA_TOOLBOXITEM_PLAY { HelpId = HID_AVMEDIA_TOOLBOXITEM_PLAY; };
+hidspecial HID_AVMEDIA_TOOLBOXITEM_PAUSE { HelpId = HID_AVMEDIA_TOOLBOXITEM_PAUSE; };
+hidspecial HID_AVMEDIA_TOOLBOXITEM_STOP { HelpId = HID_AVMEDIA_TOOLBOXITEM_STOP; };
+hidspecial HID_AVMEDIA_TOOLBOXITEM_MUTE { HelpId = HID_AVMEDIA_TOOLBOXITEM_MUTE; };
+hidspecial HID_AVMEDIA_TOOLBOXITEM_LOOP { HelpId = HID_AVMEDIA_TOOLBOXITEM_LOOP; };
+hidspecial HID_AVMEDIA_TOOLBOXITEM_OPEN { HelpId = HID_AVMEDIA_TOOLBOXITEM_OPEN; };
+hidspecial HID_AVMEDIA_TOOLBOXITEM_INSERT { HelpId = HID_AVMEDIA_TOOLBOXITEM_INSERT; };
+hidspecial HID_AVMEDIA_ZOOMLISTBOX { HelpId = HID_AVMEDIA_ZOOMLISTBOX; };
+hidspecial HID_AVMEDIA_TIMESLIDER { HelpId = HID_AVMEDIA_TIMESLIDER; };
+hidspecial HID_AVMEDIA_TIMEEDIT { HelpId = HID_AVMEDIA_TIMEEDIT; };
+hidspecial HID_AVMEDIA_VOLUMESLIDER { HelpId = HID_AVMEDIA_VOLUMESLIDER; };
+hidspecial HID_AVMEDIA_PLAYERWINDOW { HelpId = HID_AVMEDIA_PLAYERWINDOW; };
diff --git a/avmedia/util/makefile.mk b/avmedia/util/makefile.mk
new file mode 100755
index 000000000000..6d12706a265d
--- /dev/null
+++ b/avmedia/util/makefile.mk
@@ -0,0 +1,87 @@
+#*************************************************************************
+#
+# 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=avmedia
+GEN_HID=TRUE
+GEN_HID_OTHER=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Resources ---------------------------------
+
+RESLIB1NAME=$(TARGET)
+RESLIB1IMAGES=$(PRJ)$/res
+RESLIB1SRSFILES= \
+ $(SRS)$/viewer.srs \
+ $(SRS)$/framework.srs
+
+# --- Files -------------------------------------
+
+LIB1TARGET=$(SLB)$/$(TARGET).lib
+LIB1FILES=\
+ $(SLB)$/viewer.lib \
+ $(SLB)$/framework.lib
+
+# ==========================================================================
+
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+SHL1IMPLIB=i$(TARGET)
+SHL1STDLIBS=$(UNOTOOLSLIB) $(TOOLSLIB) $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(SVTOOLLIB) $(SVLLIB) $(SFXLIB)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+SHL1LIBS=$(SLB)$/$(TARGET).lib
+
+DEF1NAME=$(SHL1TARGET)
+DEF1DEPN=$(MISC)$/$(SHL1TARGET).flt $(LIB1TARGET)
+DEF1DES=Avmedia
+DEFLIB1NAME =$(TARGET)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+.IF "$(depend)"==""
+$(MISC)$/$(SHL1TARGET).flt: makefile.mk
+ @echo ------------------------------
+ @echo Making: $@
+ @echo _Impl>$@
+ @echo WEP>>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+ @echo CT>>$@
+.ENDIF
+
+ALLTAR : $(MISC)/avmedia.component
+
+$(MISC)/avmedia.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ avmedia.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt avmedia.component