1*9ea84ac5SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9ea84ac5SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9ea84ac5SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9ea84ac5SAndrew Rist * distributed with this work for additional information 6*9ea84ac5SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9ea84ac5SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9ea84ac5SAndrew Rist * "License"); you may not use this file except in compliance 9*9ea84ac5SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9ea84ac5SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9ea84ac5SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9ea84ac5SAndrew Rist * software distributed under the License is distributed on an 15*9ea84ac5SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9ea84ac5SAndrew Rist * KIND, either express or implied. See the License for the 17*9ea84ac5SAndrew Rist * specific language governing permissions and limitations 18*9ea84ac5SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9ea84ac5SAndrew Rist *************************************************************/ 21*9ea84ac5SAndrew Rist 22*9ea84ac5SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _GSTPLAYER_HXX 25cdf0e10cSrcweir #define _GSTPLAYER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "gstcommon.hxx" 28cdf0e10cSrcweir #include <glib.h> 29cdf0e10cSrcweir 30cdf0e10cSrcweir // necessary for mixed environments with GStreamer-0.10 and GLib versions < 2.8 31cdf0e10cSrcweir #ifndef G_GNUC_NULL_TERMINATED 32cdf0e10cSrcweir #if __GNUC__ >= 4 33cdf0e10cSrcweir #define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) 34cdf0e10cSrcweir #else 35cdf0e10cSrcweir #define G_GNUC_NULL_TERMINATED 36cdf0e10cSrcweir #endif 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir 39cdf0e10cSrcweir struct _GOptionGroup; 40cdf0e10cSrcweir typedef struct _GOptionGroup GOptionGroup; 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include <gst/gst.h> 43cdf0e10cSrcweir #include "com/sun/star/media/XPlayer.hdl" 44cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 45cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx> 46cdf0e10cSrcweir 47cdf0e10cSrcweir namespace avmedia 48cdf0e10cSrcweir { 49cdf0e10cSrcweir namespace gst 50cdf0e10cSrcweir { 51cdf0e10cSrcweir class Window; 52cdf0e10cSrcweir 53cdf0e10cSrcweir // --------------- 54cdf0e10cSrcweir // - Player_Impl - 55cdf0e10cSrcweir // --------------- 56cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::media::XPlayer, 57cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo > Player_BASE; 58cdf0e10cSrcweir 59cdf0e10cSrcweir class Player : public cppu::BaseMutex, 60cdf0e10cSrcweir public Player_BASE 61cdf0e10cSrcweir { 62cdf0e10cSrcweir public: 63cdf0e10cSrcweir 64cdf0e10cSrcweir // static create method instead of public Ctor 65cdf0e10cSrcweir static Player* create( const ::rtl::OUString& rURL ); 66cdf0e10cSrcweir 67cdf0e10cSrcweir ~Player(); 68cdf0e10cSrcweir //protected: 69cdf0e10cSrcweir // XPlayer 70cdf0e10cSrcweir virtual void SAL_CALL start() 71cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 72cdf0e10cSrcweir 73cdf0e10cSrcweir virtual void SAL_CALL stop() 74cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 75cdf0e10cSrcweir 76cdf0e10cSrcweir virtual sal_Bool SAL_CALL isPlaying() 77cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 78cdf0e10cSrcweir 79cdf0e10cSrcweir virtual double SAL_CALL getDuration() 80cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir virtual void SAL_CALL setMediaTime( double fTime ) 83cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 84cdf0e10cSrcweir 85cdf0e10cSrcweir virtual double SAL_CALL getMediaTime() 86cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir virtual void SAL_CALL setStopTime( double fTime ) 89cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 90cdf0e10cSrcweir 91cdf0e10cSrcweir virtual double SAL_CALL getStopTime() 92cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir virtual void SAL_CALL setRate( double fRate ) 95cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 96cdf0e10cSrcweir 97cdf0e10cSrcweir virtual double SAL_CALL getRate() 98cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 99cdf0e10cSrcweir 100cdf0e10cSrcweir virtual void SAL_CALL setPlaybackLoop( sal_Bool bSet ) 101cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 102cdf0e10cSrcweir 103cdf0e10cSrcweir virtual sal_Bool SAL_CALL isPlaybackLoop() 104cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 105cdf0e10cSrcweir 106cdf0e10cSrcweir virtual void SAL_CALL setMute( sal_Bool bSet ) 107cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 108cdf0e10cSrcweir 109cdf0e10cSrcweir virtual sal_Bool SAL_CALL isMute() 110cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir virtual void SAL_CALL setVolumeDB( sal_Int16 nVolumeDB ) 113cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 114cdf0e10cSrcweir 115cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getVolumeDB() 116cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 117cdf0e10cSrcweir 118cdf0e10cSrcweir virtual ::com::sun::star::awt::Size SAL_CALL getPreferredPlayerWindowSize() 119cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 120cdf0e10cSrcweir 121cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > SAL_CALL createPlayerWindow( 122cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 123cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XFrameGrabber > SAL_CALL createFrameGrabber() 126cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 127cdf0e10cSrcweir 128cdf0e10cSrcweir // XServiceInfo 129cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() 130cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 131cdf0e10cSrcweir 132cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 133cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 134cdf0e10cSrcweir 135cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 136cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 137cdf0e10cSrcweir 138cdf0e10cSrcweir // these are public because the C callbacks call them 139cdf0e10cSrcweir 140cdf0e10cSrcweir virtual gboolean busCallback( GstBus* pBus, 141cdf0e10cSrcweir GstMessage* pMsg ); 142cdf0e10cSrcweir 143cdf0e10cSrcweir virtual gboolean idle(); 144cdf0e10cSrcweir 145cdf0e10cSrcweir virtual gpointer run(); 146cdf0e10cSrcweir 147cdf0e10cSrcweir virtual GstBusSyncReply handleCreateWindow( GstBus* pBus, 148cdf0e10cSrcweir GstMessage* pMsg ); 149cdf0e10cSrcweir 150cdf0e10cSrcweir protected: 151cdf0e10cSrcweir 152cdf0e10cSrcweir // ::cppu::OComponentHelper 153cdf0e10cSrcweir virtual void SAL_CALL disposing(void); 154cdf0e10cSrcweir 155cdf0e10cSrcweir Player( GString* pURI = NULL ); 156cdf0e10cSrcweir 157cdf0e10cSrcweir void implQuitThread(); 158cdf0e10cSrcweir 159cdf0e10cSrcweir bool implInitPlayer(); 160cdf0e10cSrcweir implIsInitialized() const161cdf0e10cSrcweir bool implIsInitialized() const 162cdf0e10cSrcweir { 163cdf0e10cSrcweir return( g_atomic_int_get( &mnInitialized ) > 0 ); 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir private: 167cdf0e10cSrcweir 168cdf0e10cSrcweir Player( const Player& ); 169cdf0e10cSrcweir 170cdf0e10cSrcweir Player& operator=( const Player& ); 171cdf0e10cSrcweir 172cdf0e10cSrcweir static void implHandleNewElementFunc( GstBin* pBin, 173cdf0e10cSrcweir GstElement* pElement, 174cdf0e10cSrcweir gpointer pData ); 175cdf0e10cSrcweir 176cdf0e10cSrcweir static void implHandleNewPadFunc( GstElement* pElem, 177cdf0e10cSrcweir GstPad* pPad, 178cdf0e10cSrcweir gpointer pData ); 179cdf0e10cSrcweir 180cdf0e10cSrcweir protected: 181cdf0e10cSrcweir 182cdf0e10cSrcweir GMutex* mpMutex; 183cdf0e10cSrcweir GCond* mpCond; 184cdf0e10cSrcweir GThread* mpThread; 185cdf0e10cSrcweir GMainContext* mpContext; 186cdf0e10cSrcweir GMainLoop* mpLoop; 187cdf0e10cSrcweir GstElement* mpPlayer; 188cdf0e10cSrcweir GString* mpURI; 189cdf0e10cSrcweir 190cdf0e10cSrcweir private: 191cdf0e10cSrcweir 192cdf0e10cSrcweir ::avmedia::gst::Window* mpPlayerWindow; 193cdf0e10cSrcweir gint mnIsVideoSource; 194cdf0e10cSrcweir gint mnVideoWidth; 195cdf0e10cSrcweir gint mnVideoHeight; 196cdf0e10cSrcweir gint mnInitialized; 197cdf0e10cSrcweir gint mnVolumeDB; 198cdf0e10cSrcweir gint mnLooping; 199cdf0e10cSrcweir gint mnQuit; 200cdf0e10cSrcweir gint mnVideoWindowSet; 201cdf0e10cSrcweir gint mnInitFail; 202cdf0e10cSrcweir }; 203cdf0e10cSrcweir } // namespace gst 204cdf0e10cSrcweir } // namespace avmedia 205cdf0e10cSrcweir 206cdf0e10cSrcweir #endif // _GSTPLAYER_HXX 207