gnomemm r1437 - in gstreamermm/trunk: . gstreamer/src gstreamerbase/src



Author: jaalburqu
Date: Wed Apr  2 01:34:14 2008
New Revision: 1437
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1437&view=rev

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

	* gstreamer/src/bus.ccg:
	* gstreamer/src/bus.hg: Renamed SlotWatch to SlotMessage; Added
	SlotMessageSync; Added set_sync_handler() and clear_sync_handler();
	Added docs for hand-written methods;

	* gstreamer/src/pipeline.hg: Added class docs

	* gstreamerbase/src/xoverlay.hg: Added TODO to insert code example in
	class docs

Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/gstreamer/src/bus.ccg
   gstreamermm/trunk/gstreamer/src/bus.hg
   gstreamermm/trunk/gstreamer/src/pipeline.hg
   gstreamermm/trunk/gstreamerbase/src/xoverlay.hg

Modified: gstreamermm/trunk/gstreamer/src/bus.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/bus.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/bus.ccg	Wed Apr  2 01:34:14 2008
@@ -21,9 +21,9 @@
 
 #include <gst/gstenumtypes.h>
 
-static gboolean Bus_Watch_gstreamermm_callback(GstBus* bus, GstMessage* message, void* data)
+static gboolean Bus_Message_gstreamermm_callback(GstBus* bus, GstMessage* message, void* data)
 {
-  Gst::Bus::SlotWatch* the_slot = static_cast<Gst::Bus::SlotWatch*>(data);
+  Gst::Bus::SlotMessage* the_slot = static_cast<Gst::Bus::SlotMessage*>(data);
 
   #ifdef GLIBMM_EXCEPTIONS_ENABLED
   try
@@ -41,9 +41,29 @@
   #endif //GLIBMM_EXCEPTIONS_ENABLED
 }
 
-static void Bus_Watch_gstreamermm_callback_destroy(void* data)
+static void Bus_Message_gstreamermm_callback_destroy(void* data)
 {
-  delete static_cast<Gst::Bus::SlotWatch*>(data);
+  delete static_cast<Gst::Bus::SlotMessage*>(data);
+}
+
+static GstBusSyncReply Bus_Message_Sync_gstreamermm_callback(GstBus* bus, GstMessage* message, void* data)
+{
+  Gst::Bus::SlotMessageSync* the_slot = static_cast<Gst::Bus::SlotMessageSync*>(data);
+
+  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  try
+  {
+  #endif //GLIBMM_EXCEPTIONS_ENABLED
+    return (GstBusSyncReply)((*the_slot)(Glib::wrap(bus, true), Gst::Message::wrap(message, true)));
+  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  }
+  catch(...)
+  {
+    Glib::exception_handlers_invoke();
+  }
+
+  return GST_BUS_PASS; // pass message to async queue
+  #endif //GLIBMM_EXCEPTIONS_ENABLED
 }
 
 namespace Gst
@@ -55,14 +75,14 @@
   return Glib::wrap(bus, false);
 }
 
-guint Bus::add_watch(const SlotWatch& slot, int priority)
+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.
-  //It will be deleted when Bus_Watch_gstreamermm_callback_destroy() is called.
-  SlotWatch* slot_copy = new SlotWatch(slot);
+  //It will be deleted when Bus_Message_gstreamermm_callback_destroy() is called.
+  SlotMessage* slot_copy = new SlotMessage(slot);
   return gst_bus_add_watch_full(gobj(), priority,
-    &Bus_Watch_gstreamermm_callback, slot_copy,
-    &Bus_Watch_gstreamermm_callback_destroy);
+    &Bus_Message_gstreamermm_callback, slot_copy,
+    &Bus_Message_gstreamermm_callback_destroy);
 }
 
 bool Bus::remove_watch(guint id)
@@ -70,4 +90,18 @@
   return g_source_remove(id);
 }
 
+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)
+  gst_bus_set_sync_handler(gobj(), NULL, NULL);
+}
+
 } //namespace Gst

Modified: gstreamermm/trunk/gstreamer/src/bus.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/bus.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/bus.hg	Wed Apr  2 01:34:14 2008
@@ -87,40 +87,79 @@
 
 public:
   /** For example,
-   * bool on_bus_watch(const Glib::RefPtr<Bus>& bus, const
+   * bool on_bus_message(const Glib::RefPtr<Bus>& bus, const
    * Glib::RefPtr<Message>& message);
    */
-  typedef sigc::slot< bool, const Glib::RefPtr<Bus>&, const Glib::RefPtr<Message>& > SlotWatch;
+  typedef sigc::slot< bool, const Glib::RefPtr<Bus>&, const Glib::RefPtr<Message>& > SlotMessage;
+
+  /** For example,
+   * BusSyncReply on_bus_sync_message(const Glib::RefPtr<Bus>& bus, const
+   * Glib::RefPtr<Message>& message);
+   */
+  typedef sigc::slot< BusSyncReply, const Glib::RefPtr<Bus>&, const Glib::RefPtr<Message>& > SlotMessageSync;
 
   static Glib::RefPtr<Bus> create();
+
   _WRAP_METHOD(bool post(const Glib::RefPtr<Message>& message), gst_bus_post)
   _WRAP_METHOD(bool have_pending() const, gst_bus_have_pending)
-
   _WRAP_METHOD(Glib::RefPtr<Message> peek(), gst_bus_peek)
   _WRAP_METHOD(Glib::RefPtr<const Message> peek() const, gst_bus_peek)
-
   _WRAP_METHOD(Glib::RefPtr<Message> pop(), gst_bus_pop)
   _WRAP_METHOD(Glib::RefPtr<Message> pop(MessageType message_type), gst_bus_pop_filtered)
   _WRAP_METHOD(Glib::RefPtr<Message> pop(ClockTime timeout), gst_bus_timed_pop)
   _WRAP_METHOD(Glib::RefPtr<Message> pop(ClockTime timeout, MessageType message_type), gst_bus_timed_pop_filtered)
-
   _WRAP_METHOD(void set_flushing(bool flushing = true), gst_bus_set_flushing)
 
-  guint add_watch(const SlotWatch& slot, int priority = Glib::PRIORITY_DEFAULT);
+  /** Adds a bus watch to the default main context with the given priority.
+   * The slot is used to receive asynchronous messages in the main loop.
+   *
+   * The watch can be removed using remove_watch() or by returning FALSE from
+   * slot.
+   *
+   * @param slot The slot to call when a message is received.
+   * @param priority The priority of the watch.
+   * @return The event source id. MT safe.
+   */
+  guint add_watch(const SlotMessage& slot, int priority = Glib::PRIORITY_DEFAULT);
+
+  /** Removes bus watch with event source id from main context.
+   *
+   * @param The event source id.
+   * @return true if removal was succesful, false otherwise.
+   */
   bool remove_watch(guint watch_id);
-  _IGNORE(gst_bus_add_watch, gst_bus_add_watch_full)
+
+  /** Sets the synchronous handler on the bus. The slot will be called every
+   * time a new message is posted on the bus. Note that the function will be
+   * called in the same thread context as the posting object (synchronously).
+   * This function is usually only called by the creator of the bus.
+   * 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)
   _WRAP_METHOD(void remove_signal_watch(), gst_bus_remove_signal_watch)
   _WRAP_METHOD(Glib::RefPtr<Message> poll(MessageType message_type, ClockTimeDiff timeout), gst_bus_poll)
-  _IGNORE(gst_bus_add_signal_watch)
 
 #m4 _CONVERSION(`GstMessage*',`const Glib::RefPtr<Message>&', `Gst::Message::wrap($3, true)')
   _WRAP_SIGNAL(void message(const Glib::RefPtr<Message>& message), "message")
   _WRAP_SIGNAL(void sync_message(const Glib::RefPtr<Message>& message), "sync-message")
+
+  _IGNORE(gst_bus_add_watch,
+          gst_bus_add_watch_full,
+          gst_bus_add_signal_watch)
 };
 
 } //namespace Gst

Modified: gstreamermm/trunk/gstreamer/src/pipeline.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/pipeline.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/pipeline.hg	Wed Apr  2 01:34:14 2008
@@ -32,6 +32,51 @@
 
 class Bus;
 
+/** A Pipeline is a special Bin used as the toplevel container for the filter
+ * graph. The Pipeline will manage the selection and distribution of a global
+ * Clock as well as provide a Bus to the application. It will also implement a
+ * default behavour for managing seek events (see Element::seek()).
+ *
+ * create() is used to create a pipeline. when the pipeline is destroyed all
+ * its resources including all added Element objects are destroyed.
+ *
+ * Elements are added and removed from the pipeline using the Bin methods like
+ * Bin::add() and Bin::remove() (see Bin).
+ *
+ * Before changing the state of the Pipeline (see Element) a Bus can be
+ * retrieved with get_bus(). This bus can then be used to receive Message from
+ * the elements in the pipeline.
+ *
+ * By default, a Pipeline will automatically flush the pending Bus messages
+ * when going to the NULL state to ensure that no circular references exist
+ * when no messages are read from the Bus. This behaviour can be changed with
+ * set_auto_flush_bus().
+ *
+ * When the Pipeline performs the PAUSED to PLAYING state change it will select
+ * a clock for the elements. The clock selection algorithm will by default
+ * select a clock provided by an element that is most upstream (closest to the
+ * source). For live pipelines (ones that return STATE_CHANGE_NO_PREROLL from
+ * the Element::set_state() call) this will select the clock provided by the
+ * live source. For normal pipelines this will select a clock provided by the
+ * sinks (most likely the audio sink). If no element provides a clock, a
+ * default SystemClock is used.
+ *
+ * The clock selection can be controlled with the use_clock() method, which will enforce a given clock on the pipeline. With auto_clock() the default clock selection algorithm can be restored.
+ *
+ * A Pipeline maintains a stream time for the elements. The stream time is
+ * defined as the difference between the current clock time and the base time.
+ * When the pipeline goes to READY or a flushing seek is performed on it, the
+ * stream time is reset to 0. When the pipeline is set from PLAYING to PAUSED,
+ * the current clock time is sampled and used to configure the base time for
+ * the elements when the pipeline is set to PLAYING again. This default
+ * behaviour can be changed with the set_new_stream_time() method.
+ *
+ * When sending a flushing seek event to a Pipeline (see Element::seek()), it
+ * will make sure that the pipeline is properly PAUSED and resumed as well as
+ * set the new stream time to 0 when the seek succeeded.
+ *
+ * Last reviewed on 2006-03-12 (0.10.5)
+ */
 class Pipeline : public Bin 
 {
   _CLASS_GOBJECT(Pipeline, GstPipeline, GST_PIPELINE, Bin, GstBin)

Modified: gstreamermm/trunk/gstreamerbase/src/xoverlay.hg
==============================================================================
--- gstreamermm/trunk/gstreamerbase/src/xoverlay.hg	(original)
+++ gstreamermm/trunk/gstreamerbase/src/xoverlay.hg	Wed Apr  2 01:34:14 2008
@@ -35,6 +35,7 @@
  * render. This is achieved by either being informed about the Window
  * identifier that the video sink element generated, or by forcing the video
  * sink element to use a specific Window identifier for rendering.
+ *
  * - To force a redrawing of the latest video frame the video sink element
  * displayed on the Window. Indeed if the Pipeline is in STATE_PAUSED state,
  * moving the Window around will damage its content. Application developers
@@ -52,6 +53,8 @@
  * creation from the video sink element. To solve this issue a Message is
  * posted on the bus to inform the application that it should set the Window
  * identifier immediately. Here is an example on how to do that correctly:
+ *
+ * TODO: Insert translated example code from C API
  */
 class XOverlay : public Glib::Interface
 {



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