gnomemm r1802 - in gstreamermm/trunk: . gstreamer gstreamer/gstreamermm gstreamerbase/gstreamerbasemm tests



Author: jaalburqu
Date: Tue Nov 18 22:49:23 2008
New Revision: 1802
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1802&view=rev

Log:
2008-11-18  Josà Alburquerque  <jaalburqu svn gnome org>

	* gstreamer/gstreamermm-0.10.pc.in:
	* gstreamer/gstreamermm/init.cc:
	* gstreamer/gstreamermm/init.h: Removed gstreamermm dependency on
	gstreamerbasemm by not using GstBase::wrap_init() in gstreamermm
	initialization.  Modified init() and init_check() methods so that they
	only call gst_init() or gst_init_check() only once regardless of how
	many times the methods are used.
	* gstreamerbase/gstreamerbasemm/init.cc:
	* gstreamerbase/gstreamerbasemm/init.h: Added init() and init_check()
	methods.  Modifed docs to explain that GstBase::init() and
	GstBase::init_check() methods can be used to initialize gsteamermm.
	* gstreamerbase/gstreamerbasemm/wrap_init.h:
	* gstreamerbase/gstreamerbasemm/gst_wrap_init.h: Modified docs to
	suggest to use GstBase::init() or GstBase::init_check() methods
	instead of GstBase::wrap_init() or GstBase::gst_wrap_init().
	* tests/test-init-check.cc:
	* tests/test-init.cc: Modified two tests to ensure that
	GstBase::init() and GstBase::init_check() initialize both gstreamermm
	and gstreamerbasemm.

Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/gstreamer/gstreamermm-0.10.pc.in
   gstreamermm/trunk/gstreamer/gstreamermm/init.cc
   gstreamermm/trunk/gstreamer/gstreamermm/init.h
   gstreamermm/trunk/gstreamerbase/gstreamerbasemm/gst_wrap_init.h
   gstreamermm/trunk/gstreamerbase/gstreamerbasemm/init.cc
   gstreamermm/trunk/gstreamerbase/gstreamerbasemm/init.h
   gstreamermm/trunk/gstreamerbase/gstreamerbasemm/wrap_init.h
   gstreamermm/trunk/tests/test-init-check.cc
   gstreamermm/trunk/tests/test-init.cc

Modified: gstreamermm/trunk/gstreamer/gstreamermm-0.10.pc.in
==============================================================================
--- gstreamermm/trunk/gstreamer/gstreamermm-0.10.pc.in	(original)
+++ gstreamermm/trunk/gstreamer/gstreamermm-0.10.pc.in	Tue Nov 18 22:49:23 2008
@@ -7,5 +7,5 @@
 Description: C++ wrapper for GStreamer 
 Requires: glibmm-2.4 gstreamer-0.10 gstreamer-base-0.10 libxml++-2.6
 Version: @VERSION@
-Libs: -L${libdir} -lgstreamermm-0.10 -lgstreamerbasemm-0.10
+Libs: -L${libdir} -lgstreamermm-0.10
 Cflags: -I${includedir}/gstreamermm-0.10 -I${libdir}/gstreamermm-0.10/include

Modified: gstreamermm/trunk/gstreamer/gstreamermm/init.cc
==============================================================================
--- gstreamermm/trunk/gstreamer/gstreamermm/init.cc	(original)
+++ gstreamermm/trunk/gstreamer/gstreamermm/init.cc	Tue Nov 18 22:49:23 2008
@@ -21,14 +21,13 @@
 #include <gstreamermm/wrap.h>
 #include <gstreamermm/wrap_init.h>
 #include <gstreamermm/gst_wrap_init.h>
-#include <gstreamerbasemm/wrap_init.h>
 #include <glibmm/init.h>
 #include <gst/gst.h>
 
 namespace Gst
 {
 
-void initialize_wrap_system()
+static void initialize_wrap_system()
 {
   static bool s_init = false;
   if(!s_init)
@@ -40,9 +39,6 @@
     Gst::wrap_register_init();
     Gst::gst_wrap_init();
 
-    //Initialize wraping for gstreamerbasemm co-library
-    GstBase::wrap_init();
-
     s_init = true;
   }
 }
@@ -80,23 +76,23 @@
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 {
   static bool s_init = false;
+  static bool result = false;
 
   if(!s_init)
+  {
     Glib::init();
 
-  GError* gerror = 0;
-  bool result = gst_init_check(&argc, &argv, &gerror);
+    GError* gerror = 0;
+    result = gst_init_check(&argc, &argv, &gerror);
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-  if(gerror)
-    ::Glib::Error::throw_exception(gerror);
+    if(gerror)
+      ::Glib::Error::throw_exception(gerror);
 #else
-  if(gerror)
-    error = ::Glib::Error::throw_exception(gerror);
+    if(gerror)
+      error = ::Glib::Error::throw_exception(gerror);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 
-  if(!s_init)
-  {
     initialize_wrap_system();
     s_init = true;
   }
@@ -111,23 +107,23 @@
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 {
   static bool s_init = false;
+  static bool result = false;
 
   if(!s_init)
+  {
     Glib::init();
 
-  GError* gerror = 0;
-  bool result = gst_init_check(NULL, NULL, &gerror);
+    GError* gerror = 0;
+    result = gst_init_check(NULL, NULL, &gerror);
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-  if(gerror)
-    ::Glib::Error::throw_exception(gerror);
+    if(gerror)
+      ::Glib::Error::throw_exception(gerror);
 #else
-  if(gerror)
-    error = ::Glib::Error::throw_exception(gerror);
+    if(gerror)
+      error = ::Glib::Error::throw_exception(gerror);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 
-  if(!s_init)
-  {
     initialize_wrap_system();
     s_init = true;
   }

Modified: gstreamermm/trunk/gstreamer/gstreamermm/init.h
==============================================================================
--- gstreamermm/trunk/gstreamer/gstreamermm/init.h	(original)
+++ gstreamermm/trunk/gstreamer/gstreamermm/init.h	Tue Nov 18 22:49:23 2008
@@ -34,9 +34,12 @@
  * be called to initialize gstreamermm before calling any other GLib functions.
  * If this is not an option, your program must initialize the GLib thread
  * system using Glib::thread_init() before any other GLib functions are called
- * and use either Gst::init() or Gst::init_check() with no arguments before
- * calling any gstreamermm functions.  GLib thread initialization can be done
- * as follows:
+ * and use either Gst::init(), or Gst::init_check() without the command line
+ * arguments before calling any gstreamermm functions.  The GstBase::init()
+ * function with the command line arguments calls this function if it has not
+ * been called already so that function may be used instead of this one to
+ * initialize both gstreamermm and gstreamerbasemm.  GLib thread initialization
+ * can be done as follows:
  *
  * @code
  * if (!Glib::thread_supported ())
@@ -53,20 +56,23 @@
  * functions in other glib-style libraries, such as gtk_init(). In particular,
  * unknown command line options cause this function to abort program execution.
  *
- * @param argc Pointer to application's argc.
- * @param argv Pointer to application's argv.
+ * @param argc Reference to application's argc.
+ * @param argv Reference to application's argv.
  */
 void init(int& argc, char**& argv);
 
 /** Initializes gstreamermm without parsing command line options.
  *
  * Either the Gst::init() or Gst::init_check() functions with command line
- * parsing should be called to initalize gstreamermm before calling any other
+ * parsing should be called to initialize gstreamermm before calling any other
  * GLib functions. If this is not an option, your program must initialize the
  * GLib thread system using Glib::thread_init() before any other GLib functions
- * are called and use either this function or Gst::init_check() with no
- * arguments before calling any gstreamermm functions.  GLib thread
- * initialization can be done as follows:
+ * are called and use either this function or Gst::init_check() without the
+ * command line arguments before calling any gstreamermm functions.  The
+ * GstBase::init() function without the command line arguments calls this
+ * function if it has not been called already so that function may be used
+ * instead of this one to initialize both gstreamermm and gstreamerbasemm.
+ * GLib thread initialization can be done as follows:
  *
  * @code
  * if (!Glib::thread_supported ())
@@ -75,7 +81,7 @@
  * @endcode
  *
  * Note: This function will terminate your program if it was unable to
- * initialize gstreamermm for some reason. If you want your program to fall
+ * initialize GStreamer for some reason. If you want your program to fall
  * back, use Gst::init_check() instead.
  */
 void init();
@@ -86,9 +92,12 @@
  * called to initialize gstreamermm before calling any other GLib functions.
  * If this is not an option, your program must initialize the GLib thread
  * system using Glib::thread_init() before any other GLib functions are called
- * and use either Gst::init() or Gst::init_check() with no arguments before
- * calling any gstreamermm functions.  GLib thread initialization can be done
- * as follows:
+ * and use either Gst::init() or Gst::init_check() without the command line
+ * arguments before calling any gstreamermm functions.  The
+ * GstBase::init_check() function with the command line arguments calls this
+ * function if it has not been called already so that function may be used
+ * instead of this one to initialize both gstreamermm and gstreamerbasemm.
+ * GLib thread initialization can be done as follows:
  *
  * @code
  * if (!Glib::thread_supported ())
@@ -96,13 +105,13 @@
  * ...
  * @endcode
  * 
- * This function will return false if gstreamermm could not be initialized for
+ * This function will return false if GStreamer could not be initialized for
  * some reason. If you want your program to fail fatally, use Gst::init()
  * instead.
  *
- * @param argc Pointer to application's argc.
- * @param argv Pointer to application's argv.
- * @return true if gstreamermm could be initialized.
+ * @param argc Reference to application's argc.
+ * @param argv Reference to application's argv.
+ * @return true if GStreamer could be initialized.
  * @throw Glib::Error
  */
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -114,12 +123,15 @@
 /** Initializes gstreamermm gracefully without parsing command line arguments.
  *
  * Either the Gst::init() or Gst::init_check() functions with command line
- * parsing should be called to initalize gstreamermm before calling any other
+ * parsing should be called to initialize gstreamermm before calling any other
  * GLib functions. If this is not an option, your program must initialize the
  * GLib thread system using Glib::thread_init() before any other GLib functions
- * are called and use either this function or Gst::init() with no arguments
- * before calling any gstreamermm functions.  GLib thread initialization can be
- * done as follows:
+ * are called and use either this function or Gst::init() without the command
+ * line arguments before calling any gstreamermm functions.  The
+ * GstBase::init_check() function without the command line arguments calls
+ * this function if it has not been called already so that function may be used
+ * instead of this one to initialize both gstreamermm and gstreamerbasemm.
+ * GLib thread initialization can be done as follows:
  *
  * @code
  * if (!Glib::thread_supported ())
@@ -127,11 +139,11 @@
  * ...
  * @endcode
  * 
- * This function will return false if gstreamermm could not be initialized for
+ * This function will return false if GStreamer could not be initialized for
  * some reason. If you want your program to fail fatally, use Gst::init()
  * instead.
  *
- * @return true if gstreamermm could be initialized.
+ * @return true if GStreamer could be initialized.
  * @throw Glib::Error
  */
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -154,7 +166,7 @@
  * @return A pointer to GStreamer's option group.
  */
 Glib::OptionGroup get_option_group();
-  
+
 }//end namespace Gst
 
 #endif //_GSTREAMERMM_INIT_H

Modified: gstreamermm/trunk/gstreamerbase/gstreamerbasemm/gst_wrap_init.h
==============================================================================
--- gstreamermm/trunk/gstreamerbase/gstreamerbasemm/gst_wrap_init.h	(original)
+++ gstreamermm/trunk/gstreamerbase/gstreamerbasemm/gst_wrap_init.h	Tue Nov 18 22:49:23 2008
@@ -27,8 +27,8 @@
 namespace GstBase
 {
   /** Initializes wrapping system of Gst::MiniObject derrived classes.
-   * There is no need to use this function directly; instead use
-   * GstBase::init(). 
+   * There is no need to use this function directly; instead use one of the
+   * GstBase::init() or GstBase::init_check() functions.
    */
   void gst_wrap_init();
 }

Modified: gstreamermm/trunk/gstreamerbase/gstreamerbasemm/init.cc
==============================================================================
--- gstreamermm/trunk/gstreamerbase/gstreamerbasemm/init.cc	(original)
+++ gstreamermm/trunk/gstreamerbase/gstreamerbasemm/init.cc	Tue Nov 18 22:49:23 2008
@@ -20,16 +20,31 @@
 #include <glibmm/init.h>
 #include <gstreamerbasemm/init.h>
 #include <gstreamerbasemm/wrap_init.h>
+#include <gstreamermm/init.h>
 
 namespace GstBase
 {
 
+void init(int& argc, char**& argv)
+{
+  static bool s_init = false;
+  if(!s_init)
+  {
+    Gst::init(argc, argv);
+
+    //For Glib::wrap(), for Glib::Object-derived classes.
+    GstBase::wrap_init(); 
+
+    s_init = true;
+  }
+}
+
 void init()
 {
   static bool s_init = false;
   if(!s_init)
   {
-    Glib::init();
+    Gst::init();
 
     //For Glib::wrap(), for Glib::Object-derived classes.
     GstBase::wrap_init(); 
@@ -38,4 +53,57 @@
   }
 }
 
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+bool init_check(int& argc, char**& argv)
+#else
+bool init_check(int& argc, char**& argv, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  static bool s_init = false;
+  static bool result = false;
+
+  if(!s_init)
+  {
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+    result = Gst::init_check(argc, argv);
+#else
+    result = Gst::init_check(argc, argv, error);
+#endif
+
+    //For Glib::wrap(), for Glib::Object-derived classes.
+    GstBase::wrap_init(); 
+
+    s_init = true;
+  }
+
+  return result;
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+bool init_check()
+#else
+bool init_check(std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  static bool s_init = false;
+  static bool result = false;
+
+  if(!s_init)
+  {
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+    result = Gst::init_check();
+#else
+    result = Gst::init_check(error);
+#endif
+
+    //For Glib::wrap(), for Glib::Object-derived classes.
+    GstBase::wrap_init(); 
+
+    s_init = true;
+  }
+
+  return result;
+}
+
 } //namespace GstBase

Modified: gstreamermm/trunk/gstreamerbase/gstreamerbasemm/init.h
==============================================================================
--- gstreamermm/trunk/gstreamerbase/gstreamerbasemm/init.h	(original)
+++ gstreamermm/trunk/gstreamerbase/gstreamerbasemm/init.h	Tue Nov 18 22:49:23 2008
@@ -22,15 +22,125 @@
 #ifndef _GSTREAMERBASEMM_INIT_H
 #define _GSTREAMERBASEMM_INIT_H
 
+#include <glibmm/error.h>
+
 namespace GstBase
 {
 
-/** Initialize gstreamerbasemm.  This function may be called more than once.
- * There's no no need to use this function if Gst::init() or Gst::init_check()
- * is used because they already call this function.
+/** Initializes gstreamerbasemm and gstreamermm, if it is not already
+ * initialized, parsing command line arguments.
+ *
+ * One of the GstBase::init() or GstBase::init_check() functions should be used
+ * to initialize gstreamerbasemm before using it.  This function calls
+ * Gst::init() with the command line arguments if it has not been called
+ * already so this function may be used instead of that one to initialize both
+ * gstreamermm and gstreamerbasemm.  If this function is used to initialize
+ * gstreamermm it must be used before any other GLib functions.  If this is not
+ * an option, and you want you initialize gstreamermm along with
+ * gstreamerbasemm, your program must initialize the GLib thread system using
+ * Glib::thread_init() before any other GLib functions are called and use
+ * either GstBase::init(), or GstBase::init_check() without the command line
+ * arguments before calling any gstreamermm or gstreamerbasemm functions.  GLib
+ * thread initialization can be done as follows:
+ *
+ * @code
+ * if (!Glib::thread_supported ())
+ *   Glib::thread_init ();
+ * ...
+ * @endcode
+ * 
+ * @param argc Reference to application's argc.
+ * @param argv Reference to application's argv.
+ */
+void init(int& argc, char**& argv);
+
+/** Initializes gstreamerbasemm and gstreamermm, if it is not already
+ * initialized, without parsing command line options.
+ *
+ * One of the GstBase::init() or GstBase::init_check() functions should be used
+ * to initialize gstreamerbasemm before using it.  This function calls
+ * Gst::init() if it has not been called already so this function may be used
+ * instead of that one to initialize both gstreamermm and gstreamerbasemm.  If
+ * this function is used to initialize gstreamermm it must be used before any
+ * other GLib functions.  If this is not an option, and you want to initialize
+ * gstreamermm along with gstreamerbasemm, your program must initialize the
+ * GLib thread system using Glib::thread_init() before any other GLib functions
+ * are called and use either this function or GstBase::init_check() without the
+ * command line arguments before calling any gstreamermm or gstreamerbasemm
+ * functions.  GLib thread initialization can be done as follows:
+ *
+ * @code
+ * if (!Glib::thread_supported ())
+ *   Glib::thread_init ();
+ * ...
+ * @endcode
  */
 void init();
-  
+
+/** Initializes gstreamerbasemm and gstreamermm gracefully, if it is not
+ * already initialized, parsing command line options.
+ *
+ * One of the GstBase::init() or GstBase::init_check() functions should be used
+ * to initialize gstreamerbasemm before using it.  This function calls
+ * Gst::init_check() with the command line arguments if it has not been called
+ * already so this function may be used instead of that one to initialize both
+ * gstreamermm and gstreamerbasemm.  If this function is used to initialize
+ * gstreamermm it must be used before any other GLib functions.  If this is not
+ * an option, and you want to initialize gstreamermm along with
+ * gstreamerbasemm, your program must initialize the GLib thread system using
+ * Glib::thread_init() before any other GLib functions are called and use
+ * either GstBase::init() or GstBase::init_check() without the command line
+ * arguments before calling any gstreamermm or gstreamerbasemm functions.  GLib
+ * thread initialization can be done as follows:
+ *
+ * @code
+ * if (!Glib::thread_supported ())
+ *   Glib::thread_init ();
+ * ...
+ * @endcode
+ * 
+ * @param argc Reference to application's argc.
+ * @param argv Reference to application's argv.
+ * @return true if initialization was successful.
+ * @throw Glib::Error
+ */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  bool init_check(int& argc, char**& argv);
+#else
+  bool init_check(int& argc, char**& argv, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+/** Initializes gstreamerbasemm and gstreamermm gracefully, if it is not
+ * already initialized, without parsing command line options.
+ *
+ * One of the GstBase::init() or GstBase::init_check() functions should be used
+ * to initialize gstreamerbasemm before using it.  This function calls
+ * Gst::init_check() if it has not been called already so this function may be
+ * used instead of that one to initialize both gstreamermm and gstreamerbasemm.
+ * If this function is used to initialize gstreamermm it must be used before
+ * any other GLib functions.  If this is not an option, and you want to
+ * initialize gstreamermm along with gstreamerbasemm, your program must
+ * initialize the GLib thread system using Glib::thread_init() before any other
+ * GLib functions are called and use either this function or GstBase::init()
+ * without the command line arguments before calling any gstreamermm or
+ * gstreamerbasemm functions.  GLib thread initialization can be done as
+ * follows:
+ *
+ * @code
+ * if (!Glib::thread_supported ())
+ *   Glib::thread_init ();
+ * ...
+ * @endcode
+ * 
+ * @return true if initialization was successful.
+ * @throw Glib::Error
+ */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  bool init_check();
+#else
+  bool init_check(std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
 } //namespace GstBase
 
 #endif //_GSTREAMERBASEMM_INIT_H

Modified: gstreamermm/trunk/gstreamerbase/gstreamerbasemm/wrap_init.h
==============================================================================
--- gstreamermm/trunk/gstreamerbase/gstreamerbasemm/wrap_init.h	(original)
+++ gstreamermm/trunk/gstreamerbase/gstreamerbasemm/wrap_init.h	Tue Nov 18 22:49:23 2008
@@ -26,9 +26,9 @@
 
 namespace GstBase
 {
-  /** Initializes the main gstreamerbasemm wrapping system.
-   * There's no need to use this function directly; instead use
-   * GstBase::init().
+  /** Initializes the main gstreamerbasemm wrapping system.  There's no need to
+   * use this function directly; instead use one of the GstBase::init() or
+   * GstBase::init_check() functions.
    */
   void wrap_init();
 }

Modified: gstreamermm/trunk/tests/test-init-check.cc
==============================================================================
--- gstreamermm/trunk/tests/test-init-check.cc	(original)
+++ gstreamermm/trunk/tests/test-init-check.cc	Tue Nov 18 22:49:23 2008
@@ -22,23 +22,19 @@
 #include <gstreamermm.h>
 #include <gstreamerbasemm.h>
 #include <iostream>
+#include <gst/audio/gstaudioclock.h>
 
 int main (int argc, char* argv[])
 {
   try
   {
-    bool success = Gst::init_check(argc, argv);
+    bool success = GstBase::init_check(argc, argv);
 
     if (!success)
     {
       std::cout << "Error initializing gstreamermm." << std::endl;
       return -1;
     }
-
-    success = Gst::init_check(argc, argv);
-
-    std::cout << "Second call to Gst::init_check() success = " << success <<
-      "." << std::endl;
   }
   catch (const Glib::Error& error)
   {
@@ -63,5 +59,13 @@
     xoverlay->handle_events(false);
   }
 
+  GstClock* gst_clock = gst_audio_clock_new("clock", NULL, NULL);
+  Glib::RefPtr<GstBase::AudioClock> clock = Glib::wrap(GST_AUDIO_CLOCK(gst_clock));
+
+  if (clock)
+    std::cout << "Successfully wrapped a GstAudioClock in a GStBase::AudioClock." << std::endl;
+  else
+    std::cout << "Did not successfully wrap a GstAudioClock in a GstBase::AudioClock." << std::endl;
+
   return 0;
 }

Modified: gstreamermm/trunk/tests/test-init.cc
==============================================================================
--- gstreamermm/trunk/tests/test-init.cc	(original)
+++ gstreamermm/trunk/tests/test-init.cc	Tue Nov 18 22:49:23 2008
@@ -22,10 +22,11 @@
 #include <gstreamermm.h>
 #include <gstreamerbasemm.h>
 #include <iostream>
+#include <gst/audio/gstaudioclock.h>
 
 int main (int argc, char* argv[])
 {
-  Gst::init(argc, argv);
+  GstBase::init(argc, argv);
 
   Glib::RefPtr<Gst::Element> element = Gst::ElementFactory::create_element("ximagesink", "videosink");
 
@@ -44,5 +45,13 @@
     xoverlay->handle_events(false);
   }
 
+  GstClock* gst_clock = gst_audio_clock_new("clock", NULL, NULL);
+  Glib::RefPtr<GstBase::AudioClock> clock = Glib::wrap(GST_AUDIO_CLOCK(gst_clock));
+
+  if (clock)
+    std::cout << "Successfully wrapped a GstAudioClock in a GStBase::AudioClock." << std::endl;
+  else
+    std::cout << "Did not successfully wrap a GstAudioClock in a GstBase::AudioClock." << std::endl;
+
   return 0;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]