gnomemm r1443 - in gstreamermm/trunk: . gstreamer/src tests tools/m4



Author: jaalburqu
Date: Fri Apr  4 23:27:09 2008
New Revision: 1443
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1443&view=rev

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

	* gstreamer/src/bus.ccg:
	* gstreamer/src/bus.hg: Used _WRAP_CREATE to generate create() method;
	Merged clear_sync_handler() into set_sync_handler() because
	clear_sync_hander() would only be used before a call to
	set_sync_handler()

	* gstreamer/src/pad.ccg:
	* gstreamer/src/pad.hg: Used _WRAP_CREATE to generate create()
	methods; Moved SlotBlock to top; Added get_pad_template(); Moved
	set_blocked_async() below set_blocked() and added method docs
	* tools/m4/convert_gst.m4: Added PadTemplate conversions

	* tests/Makefile.am:
	* tests/test-create-bus.cc: Added test to create bus

Added:
   gstreamermm/trunk/tests/test-create-bus.cc
Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/gstreamer/src/bus.ccg
   gstreamermm/trunk/gstreamer/src/bus.hg
   gstreamermm/trunk/gstreamer/src/pad.ccg
   gstreamermm/trunk/gstreamer/src/pad.hg
   gstreamermm/trunk/tests/Makefile.am
   gstreamermm/trunk/tools/m4/convert_gst.m4

Modified: gstreamermm/trunk/gstreamer/src/bus.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/bus.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/bus.ccg	Fri Apr  4 23:27:09 2008
@@ -69,12 +69,6 @@
 namespace Gst
 {
 
-Glib::RefPtr<Bus> Bus::create()
-{
-  GstBus* bus = gst_bus_new();
-  return Glib::wrap(bus, false);
-}
-
 guint Bus::add_watch(const SlotMessage& slot, int priority)
 {
   //Create a copy of the slot. A pointer to this will be passed through the callback's data parameter.
@@ -93,15 +87,13 @@
 void Bus::set_sync_handler(const SlotMessageSync& slot)
 {
   static SlotMessageSync slot_copy;
-  slot_copy = slot;
-  gst_bus_set_sync_handler(gobj(), &Bus_Message_Sync_gstreamermm_callback, &slot_copy);
-}
 
-void Bus::clear_sync_handler()
-{
-  // Clear existing sync handler by calling with NULL (see
-  // gst_bus_set_sync_handler docs)
+  // Clear a possibly existing sync handler by calling with NULL before setting
+  // a new one (see gst_bus_set_sync_handler docs)
   gst_bus_set_sync_handler(gobj(), NULL, NULL);
+
+  slot_copy = slot;
+  gst_bus_set_sync_handler(gobj(), &Bus_Message_Sync_gstreamermm_callback, &slot_copy);
 }
 
 } //namespace Gst

Modified: gstreamermm/trunk/gstreamer/src/bus.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/bus.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/bus.hg	Fri Apr  4 23:27:09 2008
@@ -100,7 +100,7 @@
    */
   typedef sigc::slot< BusSyncReply, const Glib::RefPtr<Bus>&, const Glib::RefPtr<Message>& > SlotMessageSync;
 
-  static Glib::RefPtr<Bus> create();
+  _WRAP_CREATE()
 
   _WRAP_METHOD(bool post(const Glib::RefPtr<Message>& message), gst_bus_post)
   _WRAP_METHOD(bool have_pending() const, gst_bus_have_pending)
@@ -138,17 +138,10 @@
    * Applications should handle messages asynchronously using the watch and
    * poll functions.
    *
-   * You cannot replace an existing sync_handler. You can clear the existing
-   * handler with clear_sync_handler().
-   *
    * @param slot The handler slot to install
    */
   void set_sync_handler(const SlotMessageSync& slot);
 
-  /** Clears the existing synchronous handler from bus.
-   */
-  void clear_sync_handler();
-
   _WRAP_METHOD(void disable_sync_message_emission(), gst_bus_disable_sync_message_emission)
   _WRAP_METHOD(void enable_sync_message_emission(), gst_bus_enable_sync_message_emission)
   _WRAP_METHOD(void add_signal_watch(int priority = Glib::PRIORITY_DEFAULT), gst_bus_add_signal_watch_full)

Modified: gstreamermm/trunk/gstreamer/src/pad.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/pad.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/pad.ccg	Fri Apr  4 23:27:09 2008
@@ -25,19 +25,20 @@
 #include <gstreamermm/caps.h>
 #include <gstreamermm/element.h>
 #include <gstreamermm/event.h>
-#include <gstreamermm/query.h>
+#include <gstreamermm/padtemplate.h>
 
-namespace Gst
+static void Pad_Block_gstreamermm_callback(GstPad* pad, gboolean blocked, void* data)
 {
+  Gst::Pad::SlotBlock * the_slot = static_cast<Gst::Pad::SlotBlock*>(data);
 
-// The C API has gst_pad_new, we just use the very common ::create() here
-Glib::RefPtr<Pad>
-Pad::create(const Glib::ustring& name, PadDirection direction)
-{
-  GstPad * pad = gst_pad_new(name.c_str(), GstPadDirection(direction));
-  return Glib::wrap(pad, false);
+  Glib::RefPtr<Gst::Pad> cpp_pad = Glib::wrap(pad, true);
+  (*the_slot)(cpp_pad, blocked);
+  delete the_slot;
 }
 
+namespace Gst
+{
+
 Glib::RefPtr<Caps> Pad::get_pad_template_caps()
 {
   const GstCaps* caps = gst_pad_get_pad_template_caps(gobj());
@@ -121,16 +122,7 @@
   return FlowReturn(gst_pad_chain(gobj(), buffer->gobj()));
 }
 
-static void Pad_Block_gstreamermm_callback(GstPad* pad, gboolean blocked, void* data)
-{
-  Pad::SlotBlock * the_slot = static_cast<Pad::SlotBlock*>(data);
-
-  Glib::RefPtr<Pad> cpp_pad = Glib::wrap(pad, true);
-  (*the_slot)(cpp_pad, blocked);
-  delete the_slot;
-}
-
-bool Pad::set_blocked_async(bool blocked, const SlotBlock& slot)
+bool Pad::set_blocked_async(const SlotBlock& slot, bool blocked)
 {
   SlotBlock* slot_copy = new SlotBlock(slot);
   return bool(gst_pad_set_blocked_async(GST_PAD(gobj()), gboolean(blocked), &Pad_Block_gstreamermm_callback, slot_copy));

Modified: gstreamermm/trunk/gstreamer/src/pad.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/pad.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/pad.hg	Fri Apr  4 23:27:09 2008
@@ -50,15 +50,22 @@
   _CLASS_GOBJECT(Pad, GstPad, GST_PAD, Object, GstObject)
 
 protected:
-  _CTOR_DEFAULT
+  _WRAP_CTOR(Pad(const Glib::ustring& name, PadDirection dir), gst_pad_new)
+  _WRAP_CTOR(Pad(const Glib::RefPtr<PadTemplate>& pad_template, const Glib::ustring& name), gst_pad_new_from_template)
 
 public:
-  // The C API has gst_pad_new, we just use the very common ::create() here
-  static Glib::RefPtr<Pad> create(const Glib::ustring& name, PadDirection direction);
+  /** For example,
+   * void on_block(const Glib::RefPtr<Pad>& pad, bool blocked);
+   */
+  typedef sigc::slot<void, const Glib::RefPtr<Pad>&, bool> SlotBlock;
+
+  _WRAP_CREATE(const Glib::ustring& name, PadDirection dir)
+  _WRAP_CREATE(const Glib::RefPtr<PadTemplate>& pad_template, const Glib::ustring& name)
 
   _WRAP_METHOD(PadDirection get_direction() const, gst_pad_get_direction)
   _WRAP_METHOD(Glib::RefPtr<Element> get_parent_element(), gst_pad_get_parent_element)
   _WRAP_METHOD(Glib::RefPtr<const Element> get_parent_element() const, gst_pad_get_parent_element, constversion)
+  _WRAP_METHOD(Glib::RefPtr<PadTemplate> get_pad_template() const, gst_pad_get_pad_template)
   _WRAP_METHOD(PadLinkReturn link(const Glib::RefPtr<Pad>& sink_pad), gst_pad_link)
   _WRAP_METHOD(bool unlink(const Glib::RefPtr<Pad>& sink_pad), gst_pad_unlink)
   _WRAP_METHOD(bool is_linked() const, gst_pad_is_linked)
@@ -83,6 +90,24 @@
   _WRAP_METHOD(void use_fixed_caps(), gst_pad_use_fixed_caps)
   _WRAP_METHOD(bool is_active() const, gst_pad_is_active)
   _WRAP_METHOD(bool set_blocked(bool blocked = true), gst_pad_set_blocked)
+
+  /** Blocks or unblocks the dataflow on a pad asynchronously. The provided
+   * slot is called when the operation succeeds; this happens right before the
+   * next attempt at pushing a buffer on the pad.
+   *
+   * This can take a while as the pad can only become blocked when real
+   * dataflow is happening. When the pipeline is stalled, for example in
+   * PAUSED, this can take an indeterminate amount of time. Be careful with
+   * this blocking call as it might not return for reasons stated above.
+   *
+   * @param slot SlotBlock that will be called when the operation succeeds
+   * @param blocked boolean indicating whether the pad should be blocked or
+   * unblocked
+   * @return TRUE if the pad could be blocked. This function can fail if the
+   * pad was already in the requested state. MT safe.
+   */
+  bool set_blocked_async(const SlotBlock& slot, bool blocked = true);
+
   _WRAP_METHOD(bool is_blocked() const, gst_pad_is_blocked)
   _WRAP_METHOD(bool is_blocking() const, gst_pad_is_blocking)
 
@@ -167,13 +192,6 @@
 	  gst_pad_set_fixatecaps_function,gst_pad_set_chain_function,
 	  gst_pad_set_internal_link_function, gst_pad_get_pad_template_caps)
 
-  /** For example,
-   * void on_block(const Glib::RefPtr<Pad>& pad, bool blocked);
-   */
-  typedef sigc::slot<void, const Glib::RefPtr<Pad>&, bool> SlotBlock;
-
-  bool set_blocked_async(bool blocked, const SlotBlock& slot);
-
 #m4 _CONVERSION(`GstMiniObject*',`const Glib::RefPtr<MiniObject>&',`wrap($3, false)')
 
 #m4 _CONVERSION(`const Glib::RefPtr<Gst::MiniObject>&',`GstMiniObject*',`Gst::unwrap($3)')

Modified: gstreamermm/trunk/tests/Makefile.am
==============================================================================
--- gstreamermm/trunk/tests/Makefile.am	(original)
+++ gstreamermm/trunk/tests/Makefile.am	Fri Apr  4 23:27:09 2008
@@ -5,7 +5,8 @@
 noinst_PROGRAMS = test-caps test-create-element test-pipeline-add-element \
                   test-link-elements test-create-bin test-miniobject-wrap \
                   test-message-wrap test-event-wrap test-query-wrap \
-		  test-structure test-caps-structures test-interface
+		  test-structure test-caps-structures test-interface \
+		  test-create-bus
 
 test_caps_SOURCES=test-caps.cc
 test_caps_LDFLAGS= GSTREAMERMM_LIBS@
@@ -43,6 +44,9 @@
 test_interface_SOURCES=test-interface.cc
 test_interface_LDFLAGS= GSTREAMERMM_LIBS@
 
+test_create_bus_SOURCES=test-create-bus.cc
+test_create_bus_LDFLAGS= GSTREAMERMM_LIBS@
+
 #runtestbasic runtestlangs \
 #runtestsearch runtestmimetypes \
 #runtestgetbuffer

Added: gstreamermm/trunk/tests/test-create-bus.cc
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/tests/test-create-bus.cc	Fri Apr  4 23:27:09 2008
@@ -0,0 +1,33 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* gstreamermm - a C++ wrapper for gstreamer
+ *
+ * Copyright 2008 The gstreamermm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gstreamermm.h>
+#include <iostream>
+
+int main (int argc, char* argv[])
+{
+  Gst::init(argc, argv);
+
+  Glib::RefPtr<Gst::Bus> bus = Gst::Bus::create();
+
+  if(bus)
+    std::cout << "Successfully created gst bus." << std::endl;
+}

Modified: gstreamermm/trunk/tools/m4/convert_gst.m4
==============================================================================
--- gstreamermm/trunk/tools/m4/convert_gst.m4	(original)
+++ gstreamermm/trunk/tools/m4/convert_gst.m4	Fri Apr  4 23:27:09 2008
@@ -76,6 +76,10 @@
 #_CONVERSION(`Glib::RefPtr<Pad>',`GstPad*', `Glib::unwrap($3)')
 _CONVERSION(`const Glib::RefPtr<Pad>&',`GstPad*', `Glib::unwrap($3)')
 
+#PadTemplate
+_CONVERSION(`const Glib::RefPtr<PadTemplate>&',`GstPadTemplate*', `Glib::unwrap($3)')
+_CONVERSION(`GstPadTemplate*',`Glib::RefPtr<PadTemplate>', `Glib::wrap($3)')
+
 #Plugin
 _CONVERSION(`const Glib::RefPtr<Plugin>&',`GstPlugin*',`Glib::unwrap($3)')
 _CONVERSION(`GstPlugin*',`Glib::RefPtr<Plugin>',`Glib::wrap($3)')



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