[0.11] gst-plugins-good: rtpssrccdemux: Factor out getting dpad by pad

Olivier Crête tester at kemper.freedesktop.org
Sat Jan 28 08:56:40 PST 2012


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

Author: Olivier Crête <olivier.crete at collabora.com>
Date:   Fri Jan 27 11:59:08 2012 +0100

rtpssrccdemux: Factor out getting dpad by pad

---

 gst/rtpmanager/gstrtpssrcdemux.c |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/gst/rtpmanager/gstrtpssrcdemux.c b/gst/rtpmanager/gstrtpssrcdemux.c
index 257cb9d..4e9affa 100644
--- a/gst/rtpmanager/gstrtpssrcdemux.c
+++ b/gst/rtpmanager/gstrtpssrcdemux.c
@@ -636,6 +636,22 @@ create_failed:
   }
 }
 
+static GstRtpSsrcDemuxPad *
+find_demux_pad_for_pad (GstRtpSsrcDemux * demux, GstPad * pad)
+{
+  GSList *walk;
+
+  for (walk = demux->srcpads; walk; walk = g_slist_next (walk)) {
+    GstRtpSsrcDemuxPad *dpad = (GstRtpSsrcDemuxPad *) walk->data;
+    if (dpad->rtp_pad == pad || dpad->rtcp_pad == pad) {
+      return dpad;
+    }
+  }
+
+  return NULL;
+}
+
+
 static gboolean
 gst_rtp_ssrc_demux_src_event (GstPad * pad, GstObject * parent,
     GstEvent * event)
@@ -651,21 +667,14 @@ gst_rtp_ssrc_demux_src_event (GstPad * pad, GstObject * parent,
     case GST_EVENT_CUSTOM_BOTH_OOB:
       s = gst_event_get_structure (event);
       if (s && !gst_structure_has_field (s, "ssrc")) {
-        GSList *walk;
-
-        for (walk = demux->srcpads; walk; walk = g_slist_next (walk)) {
-          GstRtpSsrcDemuxPad *dpad = (GstRtpSsrcDemuxPad *) walk->data;
+        GstRtpSsrcDemuxPad *dpad = find_demux_pad_for_pad (demux, pad);
 
-          if (dpad->rtp_pad == pad || dpad->rtcp_pad == pad) {
-            GstStructure *ws;
+        if (dpad) {
+          GstStructure *ws;
 
-            event =
-                GST_EVENT_CAST (gst_mini_object_make_writable
-                (GST_MINI_OBJECT_CAST (event)));
-            ws = gst_event_writable_structure (event);
-            gst_structure_set (ws, "ssrc", G_TYPE_UINT, dpad->ssrc, NULL);
-            break;
-          }
+          event = gst_event_make_writable (event);
+          ws = gst_event_writable_structure (event);
+          gst_structure_set (ws, "ssrc", G_TYPE_UINT, dpad->ssrc, NULL);
         }
       }
       break;



More information about the gstreamer-commits mailing list