From c3232e2f49f5a81e850455b97fefc1f60a4f0483 Mon Sep 17 00:00:00 2001 From: "zeeshan.ali@nokia.com" Date: Thu, 22 Mar 2007 12:41:32 +0000 Subject: [PATCH] [MOVED FROM GST-P-FARSIGHT] Refactorize the RTPMux code 20070322124132-65035-0a3278147546e33f687097a43b775b3f6aa99f93.gz --- gst/rtpmux/gstrtpmux.c | 73 ++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/gst/rtpmux/gstrtpmux.c b/gst/rtpmux/gstrtpmux.c index 391919b0a7..d285c61c02 100644 --- a/gst/rtpmux/gstrtpmux.c +++ b/gst/rtpmux/gstrtpmux.c @@ -187,27 +187,13 @@ gst_rtp_mux_finalize (GObject * object) } static GstPad * -gst_rtp_mux_request_new_pad (GstElement * element, - GstPadTemplate * templ, const gchar * req_name) +gst_rtp_mux_create_sinkpad (GstRTPMux * rtp_mux, GstPadTemplate * templ) { - GstRTPMux *rtp_mux; - GstPad *newpad; - GstRTPMuxClass *klass; + GstPad *newpad = NULL; GstPadTemplate * class_templ; - - g_return_val_if_fail (templ != NULL, NULL); - g_return_val_if_fail (GST_IS_RTP_MUX (element), NULL); - - rtp_mux = GST_RTP_MUX (element); - klass = GST_RTP_MUX_GET_CLASS (rtp_mux); - - if (templ->direction != GST_PAD_SINK) { - GST_WARNING_OBJECT (rtp_mux, "request pad that is not a SINK pad"); - return NULL; - } - - class_templ = - gst_element_class_get_pad_template (GST_ELEMENT_CLASS (klass), "sink_%d"); + + class_templ = gst_element_class_get_pad_template ( + GST_ELEMENT_GET_CLASS (rtp_mux), "sink_%d"); if (templ == class_templ) { gchar *name; @@ -220,18 +206,49 @@ gst_rtp_mux_request_new_pad (GstElement * element, rtp_mux->numpads++; } else { GST_WARNING_OBJECT (rtp_mux, "this is not our template!\n"); + } + + return NULL; +} + +static void +gst_rtp_mux_setup_sinkpad (GstRTPMux * rtp_mux, GstPad * sinkpad) +{ + GstRTPMuxClass *klass; + + klass = GST_RTP_MUX_GET_CLASS (rtp_mux); + + /* setup some pad functions */ + gst_pad_set_setcaps_function (sinkpad, gst_rtp_mux_setcaps); + if (klass->chain_func) + gst_pad_set_chain_function (sinkpad, klass->chain_func); + if (klass->sink_event_func) + gst_pad_set_event_function (sinkpad, klass->sink_event_func); + + /* dd the pad to the element */ + gst_element_add_pad (GST_ELEMENT (rtp_mux), sinkpad); +} + +static GstPad * +gst_rtp_mux_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * req_name) +{ + GstRTPMux *rtp_mux; + GstPad *newpad; + + g_return_val_if_fail (templ != NULL, NULL); + g_return_val_if_fail (GST_IS_RTP_MUX (element), NULL); + + rtp_mux = GST_RTP_MUX (element); + + if (templ->direction != GST_PAD_SINK) { + GST_WARNING_OBJECT (rtp_mux, "request pad that is not a SINK pad"); return NULL; } - /* setup some pad functions */ - gst_pad_set_setcaps_function (newpad, gst_rtp_mux_setcaps); - if (klass->chain_func) - gst_pad_set_chain_function (newpad, klass->chain_func); - if (klass->sink_event_func) - gst_pad_set_event_function (newpad, klass->sink_event_func); - - /* dd the pad to the element */ - gst_element_add_pad (element, newpad); + newpad = gst_rtp_mux_create_sinkpad (rtp_mux, templ); + if (newpad) + gst_rtp_mux_setup_sinkpad (rtp_mux, newpad); return newpad; }