[0.11] gst-plugins-good: qtmux: use GstCollectPads2 event callback

Sebastian Dröge slomo at kemper.freedesktop.org
Tue Jan 10 05:33:18 PST 2012


Module: gst-plugins-good
Branch: 0.11
Commit: 7480b4407e3a987ef7c2fec0ae87f7de832d984e
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=7480b4407e3a987ef7c2fec0ae87f7de832d984e

Author: Mark Nauwelaerts <mark.nauwelaerts at collabora.co.uk>
Date:   Thu Dec 15 16:15:22 2011 +0100

qtmux: use GstCollectPads2 event callback

... in stead of local HACK.

---

 gst/isomp4/gstqtmux.c |   27 +++++++++++----------------
 gst/isomp4/gstqtmux.h |    3 ---
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c
index b83e853..5c4de2e 100644
--- a/gst/isomp4/gstqtmux.c
+++ b/gst/isomp4/gstqtmux.c
@@ -224,7 +224,8 @@ static GstPad *gst_qt_mux_request_new_pad (GstElement * element,
 static void gst_qt_mux_release_pad (GstElement * element, GstPad * pad);
 
 /* event */
-static gboolean gst_qt_mux_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_qt_mux_sink_event (GstCollectPads2 * pads,
+    GstCollectData2 * data, GstEvent * event, gpointer user_data);
 
 static GstFlowReturn gst_qt_mux_collected (GstCollectPads2 * pads,
     gpointer user_data);
@@ -486,6 +487,9 @@ gst_qt_mux_init (GstQTMux * qtmux, GstQTMuxClass * qtmux_klass)
   gst_collect_pads2_set_function (qtmux->collect,
       (GstCollectPads2Function) GST_DEBUG_FUNCPTR (gst_qt_mux_collected),
       qtmux);
+  gst_collect_pads2_set_event_function (qtmux->collect,
+      (GstCollectPads2EventFunction) GST_DEBUG_FUNCPTR (gst_qt_mux_sink_event),
+      qtmux);
 
   /* properties set to default upon construction */
 
@@ -3258,13 +3262,14 @@ refuse_renegotiation:
 }
 
 static gboolean
-gst_qt_mux_sink_event (GstPad * pad, GstEvent * event)
+gst_qt_mux_sink_event (GstCollectPads2 * pads, GstCollectData2 * data,
+    GstEvent * event, gpointer user_data)
 {
-  gboolean ret;
   GstQTMux *qtmux;
   guint32 avg_bitrate = 0, max_bitrate = 0;
+  GstPad *pad = data->pad;
 
-  qtmux = GST_QT_MUX_CAST (gst_pad_get_parent (pad));
+  qtmux = GST_QT_MUX_CAST (user_data);
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_TAG:{
       GstTagList *list;
@@ -3298,10 +3303,8 @@ gst_qt_mux_sink_event (GstPad * pad, GstEvent * event)
       break;
   }
 
-  ret = qtmux->collect_event (pad, event);
-  gst_object_unref (qtmux);
-
-  return ret;
+  /* now GstCollectPads2 can take care of the rest, e.g. EOS */
+  return FALSE;
 }
 
 static void
@@ -3375,14 +3378,6 @@ gst_qt_mux_request_new_pad (GstElement * element,
     gst_pad_set_setcaps_function (newpad,
         GST_DEBUG_FUNCPTR (gst_qt_mux_video_sink_set_caps));
 
-  /* FIXME: hacked way to override/extend the event function of
-   * GstCollectPads2; because it sets its own event function giving the
-   * element no access to events.
-   */
-  qtmux->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (newpad);
-  gst_pad_set_event_function (newpad,
-      GST_DEBUG_FUNCPTR (gst_qt_mux_sink_event));
-
   gst_pad_set_active (newpad, TRUE);
   gst_element_add_pad (element, newpad);
 
diff --git a/gst/isomp4/gstqtmux.h b/gst/isomp4/gstqtmux.h
index 0295d4d..b23982b 100644
--- a/gst/isomp4/gstqtmux.h
+++ b/gst/isomp4/gstqtmux.h
@@ -191,9 +191,6 @@ struct _GstQTMux
   guint32 fragment_duration;
   gboolean streamable;
 
-  /* for collect pads event handling function */
-  GstPadEventFunction collect_event;
-
   /* for request pad naming */
   guint video_pads, audio_pads;
 };



More information about the gstreamer-commits mailing list