1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _GSTPLAYER_HXX 29 #define _GSTPLAYER_HXX 30 31 #include "gstcommon.hxx" 32 #include <glib.h> 33 #include <glib/gatomic.h> 34 35 // necessary for mixed environments with GStreamer-0.10 and GLib versions < 2.8 36 #ifndef G_GNUC_NULL_TERMINATED 37 #if __GNUC__ >= 4 38 #define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) 39 #else 40 #define G_GNUC_NULL_TERMINATED 41 #endif 42 #endif 43 44 struct _GOptionGroup; 45 typedef struct _GOptionGroup GOptionGroup; 46 47 #include <gst/gst.h> 48 #include "com/sun/star/media/XPlayer.hdl" 49 #include <cppuhelper/compbase2.hxx> 50 #include <cppuhelper/basemutex.hxx> 51 52 namespace avmedia 53 { 54 namespace gst 55 { 56 class Window; 57 58 // --------------- 59 // - Player_Impl - 60 // --------------- 61 typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::media::XPlayer, 62 ::com::sun::star::lang::XServiceInfo > Player_BASE; 63 64 class Player : public cppu::BaseMutex, 65 public Player_BASE 66 { 67 public: 68 69 // static create method instead of public Ctor 70 static Player* create( const ::rtl::OUString& rURL ); 71 72 ~Player(); 73 //protected: 74 // XPlayer 75 virtual void SAL_CALL start() 76 throw( ::com::sun::star::uno::RuntimeException ); 77 78 virtual void SAL_CALL stop() 79 throw( ::com::sun::star::uno::RuntimeException ); 80 81 virtual sal_Bool SAL_CALL isPlaying() 82 throw( ::com::sun::star::uno::RuntimeException ); 83 84 virtual double SAL_CALL getDuration() 85 throw( ::com::sun::star::uno::RuntimeException ); 86 87 virtual void SAL_CALL setMediaTime( double fTime ) 88 throw( ::com::sun::star::uno::RuntimeException ); 89 90 virtual double SAL_CALL getMediaTime() 91 throw( ::com::sun::star::uno::RuntimeException ); 92 93 virtual void SAL_CALL setStopTime( double fTime ) 94 throw( ::com::sun::star::uno::RuntimeException ); 95 96 virtual double SAL_CALL getStopTime() 97 throw( ::com::sun::star::uno::RuntimeException ); 98 99 virtual void SAL_CALL setRate( double fRate ) 100 throw( ::com::sun::star::uno::RuntimeException ); 101 102 virtual double SAL_CALL getRate() 103 throw( ::com::sun::star::uno::RuntimeException ); 104 105 virtual void SAL_CALL setPlaybackLoop( sal_Bool bSet ) 106 throw( ::com::sun::star::uno::RuntimeException ); 107 108 virtual sal_Bool SAL_CALL isPlaybackLoop() 109 throw( ::com::sun::star::uno::RuntimeException ); 110 111 virtual void SAL_CALL setMute( sal_Bool bSet ) 112 throw( ::com::sun::star::uno::RuntimeException ); 113 114 virtual sal_Bool SAL_CALL isMute() 115 throw( ::com::sun::star::uno::RuntimeException ); 116 117 virtual void SAL_CALL setVolumeDB( sal_Int16 nVolumeDB ) 118 throw( ::com::sun::star::uno::RuntimeException ); 119 120 virtual sal_Int16 SAL_CALL getVolumeDB() 121 throw( ::com::sun::star::uno::RuntimeException ); 122 123 virtual ::com::sun::star::awt::Size SAL_CALL getPreferredPlayerWindowSize() 124 throw( ::com::sun::star::uno::RuntimeException ); 125 126 virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > SAL_CALL createPlayerWindow( 127 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 128 throw( ::com::sun::star::uno::RuntimeException ); 129 130 virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XFrameGrabber > SAL_CALL createFrameGrabber() 131 throw( ::com::sun::star::uno::RuntimeException ); 132 133 // XServiceInfo 134 virtual ::rtl::OUString SAL_CALL getImplementationName() 135 throw( ::com::sun::star::uno::RuntimeException ); 136 137 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 138 throw( ::com::sun::star::uno::RuntimeException ); 139 140 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 141 throw( ::com::sun::star::uno::RuntimeException ); 142 143 // these are public because the C callbacks call them 144 145 virtual gboolean busCallback( GstBus* pBus, 146 GstMessage* pMsg ); 147 148 virtual gboolean idle(); 149 150 virtual gpointer run(); 151 152 virtual GstBusSyncReply handleCreateWindow( GstBus* pBus, 153 GstMessage* pMsg ); 154 155 protected: 156 157 // ::cppu::OComponentHelper 158 virtual void SAL_CALL disposing(void); 159 160 Player( GString* pURI = NULL ); 161 162 void implQuitThread(); 163 164 bool implInitPlayer(); 165 166 bool implIsInitialized() const 167 { 168 return( g_atomic_int_get( &mnInitialized ) > 0 ); 169 } 170 171 static gpointer implThreadFunc( gpointer pData ); 172 173 private: 174 175 Player( const Player& ); 176 177 Player& operator=( const Player& ); 178 179 static void implHandleNewElementFunc( GstBin* pBin, 180 GstElement* pElement, 181 gpointer pData ); 182 183 static void implHandleNewPadFunc( GstElement* pElem, 184 GstPad* pPad, 185 gpointer pData ); 186 187 protected: 188 189 GMutex* mpMutex; 190 GCond* mpCond; 191 GThread* mpThread; 192 GMainContext* mpContext; 193 GMainLoop* mpLoop; 194 GstElement* mpPlayer; 195 GString* mpURI; 196 197 private: 198 199 ::avmedia::gst::Window* mpPlayerWindow; 200 gint mnIsVideoSource; 201 gint mnVideoWidth; 202 gint mnVideoHeight; 203 gint mnInitialized; 204 gint mnVolumeDB; 205 gint mnLooping; 206 gint mnQuit; 207 gint mnVideoWindowSet; 208 gint mnInitFail; 209 }; 210 } // namespace gst 211 } // namespace avmedia 212 213 #endif // _GSTPLAYER_HXX 214