diff options
Diffstat (limited to 'avmedia/source')
-rw-r--r-- | avmedia/source/gstreamer/gstframegrabber.cxx | 3 | ||||
-rw-r--r-- | avmedia/source/gstreamer/gstplayer.cxx | 198 | ||||
-rw-r--r-- | avmedia/source/gstreamer/gstplayer.hxx | 32 | ||||
-rw-r--r-- | avmedia/source/gstreamer/makefile.mk | 2 |
4 files changed, 117 insertions, 118 deletions
diff --git a/avmedia/source/gstreamer/gstframegrabber.cxx b/avmedia/source/gstreamer/gstframegrabber.cxx index 432054e95ae9..daf64d80ed25 100644 --- a/avmedia/source/gstreamer/gstframegrabber.cxx +++ b/avmedia/source/gstreamer/gstframegrabber.cxx @@ -31,6 +31,9 @@ #include <vcl/graph.hxx> #include <vcl/bmpacc.hxx> +#include <string> + + using namespace ::com::sun::star; namespace avmedia { namespace gst { diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx index 0e5ffcac0f01..a056b14b2b99 100644 --- a/avmedia/source/gstreamer/gstplayer.cxx +++ b/avmedia/source/gstreamer/gstplayer.cxx @@ -66,6 +66,92 @@ struct GstBusSource : public GSource {} }; + +// ----------------------------------------------------------------------- +extern "C" +{ + +static gpointer +lcl_implThreadFunc( gpointer pData ) +{ + return( pData ? static_cast< Player* >( pData )->run() : NULL ); +} + +static gboolean +lcl_implBusCheck( GSource* pSource ) +{ + GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); + + return( pBusSource && + GST_IS_BUS( pBusSource->mpBus ) && + gst_bus_have_pending( GST_BUS_CAST( pBusSource->mpBus ) ) ); +} + + +static gboolean +lcl_implBusPrepare( GSource* pSource, gint* pTimeout ) +{ + if (pTimeout) + { + *pTimeout = 0; + } + + return lcl_implBusCheck(pSource); +} + +static gboolean +lcl_implBusDispatch( GSource* pSource, + GSourceFunc /*aCallback*/, + gpointer pData ) +{ + GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); + gboolean bRet = false; + + if( pData && pBusSource && GST_IS_BUS( pBusSource->mpBus ) ) + { + GstMessage* pMsg = gst_bus_pop( pBusSource->mpBus ); + + if( pMsg ) + { + bRet = static_cast< Player* >( pData )->busCallback( + pBusSource->mpBus, pMsg ); + gst_message_unref( pMsg ); + } + } + + return( bRet ); +} + +static void +lcl_implBusFinalize( GSource* pSource ) +{ + GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); + + if( pBusSource && pBusSource->mpBus ) + { + gst_object_unref( pBusSource->mpBus ); + pBusSource->mpBus = NULL; + } +} + +static gboolean +lcl_implIdleFunc( gpointer pData ) +{ + return( pData ? static_cast< Player* >( pData )->idle() : true ); +} + +static GstBusSyncReply +lcl_implHandleCreateWindowFunc( GstBus* pBus, GstMessage* pMsg, gpointer pData ) +{ + return (pData) + ? static_cast< Player* >( pData )->handleCreateWindow( pBus, pMsg ) + : GST_BUS_PASS; +} + +} // extern "C" + + + // --------------- // - Player - // --------------- @@ -103,7 +189,7 @@ Player::Player( GString* pURI ) : OSL_TRACE( ">>> --------------------------------" ); OSL_TRACE( ">>> Creating Player object with URL: %s", pURI->str ); - mpThread = g_thread_create( Player::implThreadFunc, this, true, NULL ); + mpThread = g_thread_create( &lcl_implThreadFunc, this, true, NULL ); } } @@ -335,10 +421,14 @@ void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet ) throw( uno::RuntimeException ) { ::osl::MutexGuard aGuard(m_aMutex); - if( bSet && !isPlaybackLoop() ) - g_atomic_int_inc( &mnLooping ); - else if( !bSet && isPlaybackLoop() ) - g_atomic_int_dec_and_test( &mnLooping ); + if (bSet) + { + g_atomic_int_compare_and_exchange(&mnLooping, 0, 1); + } + else + { + g_atomic_int_compare_and_exchange(&mnLooping, 1, 0); + } } // ------------------------------------------------------------------------------ @@ -577,62 +667,6 @@ bool Player::implInitPlayer() } // ------------------------------------------------------------------------------ -gboolean Player::implBusPrepare( GSource* pSource, - gint* pTimeout ) -{ - if( pTimeout ) - { - *pTimeout = 0; - } - - return( implBusCheck( pSource ) ); -} - -// ------------------------------------------------------------------------------ -gboolean Player::implBusCheck( GSource* pSource ) -{ - GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); - - return( pBusSource && - GST_IS_BUS( pBusSource->mpBus ) && - gst_bus_have_pending( GST_BUS_CAST( pBusSource->mpBus ) ) ); -} - -// ------------------------------------------------------------------------------ -gboolean Player::implBusDispatch( GSource* pSource, - GSourceFunc /*aCallback*/, - gpointer pData ) -{ - GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); - gboolean bRet = false; - - if( pData && pBusSource && GST_IS_BUS( pBusSource->mpBus ) ) - { - GstMessage* pMsg = gst_bus_pop( pBusSource->mpBus ); - - if( pMsg ) - { - bRet = static_cast< Player* >( pData )->busCallback( pBusSource->mpBus, pMsg ); - gst_message_unref( pMsg ); - } - } - - return( bRet ); -} - -// ------------------------------------------------------------------------------ -void Player::implBusFinalize( GSource* pSource ) -{ - GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); - - if( pBusSource && pBusSource->mpBus ) - { - gst_object_unref( pBusSource->mpBus ); - pBusSource->mpBus = NULL; - } -} - -// ------------------------------------------------------------------------------ gboolean Player::busCallback( GstBus* /*pBus*/, GstMessage* pMsg ) { @@ -678,26 +712,6 @@ gboolean Player::busCallback( GstBus* /*pBus*/, } // ------------------------------------------------------------------------------ -gboolean Player::implIdleFunc( gpointer pData ) -{ - return( pData ? static_cast< Player* >( pData )->idle() : true ); -} - -// ------------------------------------------------------------------------------ -gpointer Player::implThreadFunc( gpointer pData ) -{ - return( pData ? static_cast< Player* >( pData )->run() : NULL ); -} - -// ------------------------------------------------------------------------------ -GstBusSyncReply Player::implHandleCreateWindowFunc( GstBus* pBus, - GstMessage* pMsg, - gpointer pData ) -{ - return( pData ? static_cast< Player* >( pData )->handleCreateWindow( pBus, pMsg ) : GST_BUS_PASS ); -} - -// ------------------------------------------------------------------------------ void Player::implHandleNewElementFunc( GstBin* /* pBin */, GstElement* pElement, gpointer pData ) @@ -804,16 +818,12 @@ void Player::implHandleNewPadFunc( GstElement* pElement, // ------------------------------------------------------------------------------ gboolean Player::idle() { - // test if main loop should quit and set flag mnQuit to 1 - bool bQuit = g_atomic_int_compare_and_exchange( &mnQuit, 1, 1 ); + // test if main loop should quit by comparing with 1 + // and set flag mnQuit to 0 so we call g_main_loop_quit exactly once + bool const bQuit = g_atomic_int_compare_and_exchange( &mnQuit, 1, 0 ); if( bQuit ) { - // set mnQuit back to 0 to avoid mutiple g_main_loop_quit calls - // in case Player::idle() is called again later; - // the flag should have been set only once within Ctor called from - // the application thread - g_atomic_int_dec_and_test( &mnQuit ); g_main_loop_quit( mpLoop ); } @@ -828,10 +838,10 @@ gpointer Player::run() { static GSourceFuncs aSourceFuncs = { - Player::implBusPrepare, - Player::implBusCheck, - Player::implBusDispatch, - Player::implBusFinalize, + &lcl_implBusPrepare, + &lcl_implBusCheck, + &lcl_implBusDispatch, + &lcl_implBusFinalize, NULL, NULL }; @@ -846,7 +856,7 @@ gpointer Player::run() // add idle callback GSource* pIdleSource = g_idle_source_new(); - g_source_set_callback( pIdleSource, Player::implIdleFunc, this, NULL ); + g_source_set_callback( pIdleSource, &lcl_implIdleFunc, this, NULL ); g_source_attach( pIdleSource, mpContext ); // add bus callback @@ -857,7 +867,7 @@ gpointer Player::run() // add bus sync handler to intercept video window creation for setting our own window gst_bus_set_sync_handler( static_cast< GstBusSource* >( pBusSource )->mpBus, - Player::implHandleCreateWindowFunc, this ); + &lcl_implHandleCreateWindowFunc, this ); // watch for all elements (and pads) that will be added to the playbin, // in order to retrieve properties like video width and height diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx index 7d40728840a6..2127e87a93ec 100644 --- a/avmedia/source/gstreamer/gstplayer.hxx +++ b/avmedia/source/gstreamer/gstplayer.hxx @@ -140,12 +140,7 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); - - - // ::cppu::OComponentHelper - virtual void SAL_CALL disposing(void); - - Player( GString* pURI = NULL ); +// these are public because the C callbacks call them virtual gboolean busCallback( GstBus* pBus, GstMessage* pMsg ); @@ -157,6 +152,13 @@ public: virtual GstBusSyncReply handleCreateWindow( GstBus* pBus, GstMessage* pMsg ); +protected: + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + + Player( GString* pURI = NULL ); + void implQuitThread(); bool implInitPlayer(); @@ -174,24 +176,6 @@ private: Player& operator=( const Player& ); - static gboolean implBusPrepare( GSource* pSource, - gint* pTimeout ); - - static gboolean implBusCheck( GSource* pSource ); - - static gboolean implBusDispatch( GSource* pSource, - GSourceFunc aCallback, - gpointer pData ); - - static void implBusFinalize( GSource* pSource ); - - static gboolean implIdleFunc( gpointer pData ); - - - static GstBusSyncReply implHandleCreateWindowFunc( GstBus* pBus, - GstMessage* pMsg, - gpointer pDData ); - static void implHandleNewElementFunc( GstBin* pBin, GstElement* pElement, gpointer pData ); diff --git a/avmedia/source/gstreamer/makefile.mk b/avmedia/source/gstreamer/makefile.mk index c648fcc77f89..857c5914b094 100644 --- a/avmedia/source/gstreamer/makefile.mk +++ b/avmedia/source/gstreamer/makefile.mk @@ -62,6 +62,8 @@ SHL1STDLIBS+=$(PKGCONFIG_LIBS) SHL1IMPLIB=i$(TARGET) SHL1LIBS=$(SLB)$/$(TARGET).lib SHL1DEF=$(MISC)$/$(SHL1TARGET).def +# on Solaris checkdll does not work: LD_LIBRARY_PATH breaks the 2 libxml2.so.2 +SHL1NOCHECK=t DEF1NAME=$(SHL1TARGET) DEF1EXPORTFILE=exports.dxp |