flvmux: use GstCollectPads2 event callback
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Thu, 15 Dec 2011 15:40:21 +0000 (16:40 +0100)
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Thu, 15 Dec 2011 15:49:41 +0000 (16:49 +0100)
... in stead of local HACK.

gst/flv/gstflvmux.c
gst/flv/gstflvmux.h

index fc4cf76..8a2201e 100644 (file)
@@ -100,6 +100,9 @@ GST_BOILERPLATE_FULL (GstFlvMux, gst_flv_mux, GstElement, GST_TYPE_ELEMENT,
 static void gst_flv_mux_finalize (GObject * object);
 static GstFlowReturn
 gst_flv_mux_collected (GstCollectPads2 * pads, gpointer user_data);
+static gboolean
+gst_flv_mux_handle_sink_event (GstCollectPads2 * pads, GstCollectData2 * data,
+    GstEvent * event, gpointer user_data);
 
 static gboolean gst_flv_mux_handle_src_event (GstPad * pad, GstEvent * event);
 static GstPad *gst_flv_mux_request_new_pad (GstElement * element,
@@ -200,6 +203,9 @@ gst_flv_mux_init (GstFlvMux * mux, GstFlvMuxClass * g_class)
   mux->collect = gst_collect_pads2_new ();
   gst_collect_pads2_set_function (mux->collect,
       (GstCollectPads2Function) GST_DEBUG_FUNCPTR (gst_flv_mux_collected), mux);
+  gst_collect_pads2_set_event_function (mux->collect,
+      (GstCollectPads2EventFunction)
+      GST_DEBUG_FUNCPTR (gst_flv_mux_handle_sink_event), mux);
 
   gst_flv_mux_reset (GST_ELEMENT (mux));
 }
@@ -260,10 +266,10 @@ gst_flv_mux_handle_src_event (GstPad * pad, GstEvent * event)
 }
 
 static gboolean
-gst_flv_mux_handle_sink_event (GstPad * pad, GstEvent * event)
+gst_flv_mux_handle_sink_event (GstCollectPads2 * pads, GstCollectData2 * data,
+    GstEvent * event, gpointer user_data)
 {
-  GstFlvMux *mux = GST_FLV_MUX (gst_pad_get_parent (pad));
-  gboolean ret = TRUE;
+  GstFlvMux *mux = GST_FLV_MUX (user_data);
 
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_TAG:{
@@ -281,11 +287,7 @@ gst_flv_mux_handle_sink_event (GstPad * pad, GstEvent * event)
   }
 
   /* now GstCollectPads2 can take care of the rest, e.g. EOS */
-  if (ret)
-    ret = mux->collect_event (pad, event);
-  gst_object_unref (mux);
-
-  return ret;
+  return FALSE;
 }
 
 static gboolean
@@ -542,14 +544,6 @@ gst_flv_mux_request_new_pad (GstElement * element,
   cpad->video_codec_data = NULL;
   gst_flv_mux_reset_pad (mux, cpad, video);
 
-  /* 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.
-   */
-  mux->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (pad);
-  gst_pad_set_event_function (pad,
-      GST_DEBUG_FUNCPTR (gst_flv_mux_handle_sink_event));
-
   gst_pad_set_setcaps_function (pad, setcapsfunc);
   gst_pad_set_active (pad, TRUE);
   gst_element_add_pad (element, pad);
index ad38abe..b0e10ea 100644 (file)
@@ -68,8 +68,6 @@ typedef struct _GstFlvMux {
   GstCollectPads2 *collect;
 
   /* <private> */
-  GstPadEventFunction collect_event;
-
   GstFlvMuxState state;
   gboolean have_audio;
   gboolean have_video;