[farsight2/master] Make src funnels into a table (one per component)

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:19:36 PST 2008


---
 tests/check/transmitter/rawudp.c            |    2 -
 transmitters/rawudp/fs-rawudp-transmitter.c |   76 +++++++++++----------------
 2 files changed, 30 insertions(+), 48 deletions(-)

diff --git a/tests/check/transmitter/rawudp.c b/tests/check/transmitter/rawudp.c
index 252dfd1..f132a39 100644
--- a/tests/check/transmitter/rawudp.c
+++ b/tests/check/transmitter/rawudp.c
@@ -115,8 +115,6 @@ _new_local_candidate (FsStreamTransmitter *st, FsCandidate *candidate,
   }
 
   if (is_local) {
-    if (strcmp (candidate->ip, "127.0.0.1"))
-      G_BREAKPOINT ();
     fail_unless (!strcmp (candidate->ip, "127.0.0.1"),
       "IP is wrong, it is %s but should be 127.0.0.1 when local candidate set",
       candidate->ip);
diff --git a/transmitters/rawudp/fs-rawudp-transmitter.c b/transmitters/rawudp/fs-rawudp-transmitter.c
index fef51f2..db1bc7a 100644
--- a/transmitters/rawudp/fs-rawudp-transmitter.c
+++ b/transmitters/rawudp/fs-rawudp-transmitter.c
@@ -71,8 +71,8 @@ struct _FsRawUdpTransmitterPrivate
 
   /* We don't hold a reference to these elements, they are owned
      by the bins */
-  GstElement *udpsrc_funnel;
-  GstElement *udprtcpsrc_funnel;
+  /* They are tables of elements, one per component */
+  GstElement **udpsrc_funnels;
   GstElement *udpsink_tee;
   GstElement *udprtcpsink_tee;
 
@@ -177,6 +177,7 @@ fs_rawudp_transmitter_init (FsRawUdpTransmitter *self)
   FsTransmitter *trans = FS_TRANSMITTER_CAST (self);
   GstPad *pad = NULL;
   GstPad *ghostpad = NULL;
+  int c; /* component_id */
 
   /* member init */
   self->priv = FS_RAWUDP_TRANSMITTER_GET_PRIVATE (self);
@@ -184,6 +185,9 @@ fs_rawudp_transmitter_init (FsRawUdpTransmitter *self)
 
   self->components = 2;
 
+  /* We waste one space in order to have the index be the component_id */
+  self->priv->udpsrc_funnels = g_new0 (GstElement*, self->components+1);
+
   /* First we need the src elemnet */
 
   self->priv->gst_src = gst_bin_new (NULL);
@@ -199,54 +203,34 @@ fs_rawudp_transmitter_init (FsRawUdpTransmitter *self)
 
   /* Lets create the RTP source funnel */
 
-  self->priv->udpsrc_funnel = gst_element_factory_make ("fsfunnel", NULL);
-
-  if (!self->priv->udpsrc_funnel) {
-    trans->construction_error = g_error_new (FS_ERROR,
-      FS_ERROR_CONSTRUCTION,
-      "Could not make the fsfunnel element");
-    return;
-  }
+  for (c = 1; c <= self->components; c++) {
+    self->priv->udpsrc_funnels[c] = gst_element_factory_make ("fsfunnel", NULL);
 
-  if (!gst_bin_add (GST_BIN (self->priv->gst_src), self->priv->udpsrc_funnel)) {
-    trans->construction_error = g_error_new (FS_ERROR,
-      FS_ERROR_CONSTRUCTION,
-      "Could not add the fsfunnel element to the transmitter src bin");
-  }
-
-  pad = gst_element_get_static_pad (self->priv->udpsrc_funnel, "src");
-  ghostpad = gst_ghost_pad_new ("src", pad);
-  gst_object_unref (pad);
-
-  gst_pad_set_active (ghostpad, TRUE);
-  gst_element_add_pad (self->priv->gst_src, ghostpad);
-
-  /* Lets create the RTCP source funnel*/
+    if (!self->priv->udpsrc_funnels[c]) {
+      trans->construction_error = g_error_new (FS_ERROR,
+        FS_ERROR_CONSTRUCTION,
+        "Could not make the fsfunnel element");
+      return;
+    }
 
-  self->priv->udprtcpsrc_funnel = gst_element_factory_make ("fsfunnel", NULL);
+    if (!gst_bin_add (GST_BIN (self->priv->gst_src),
+        self->priv->udpsrc_funnels[c])) {
+      trans->construction_error = g_error_new (FS_ERROR,
+        FS_ERROR_CONSTRUCTION,
+        "Could not add the fsfunnel element to the transmitter src bin");
+    }
 
-  if (!self->priv->udprtcpsrc_funnel) {
-    trans->construction_error = g_error_new (FS_ERROR,
-      FS_ERROR_CONSTRUCTION,
-      "Could not make the fsfunnnel element");
-    return;
-  }
+    pad = gst_element_get_static_pad (self->priv->udpsrc_funnels[c], "src");
+    if (c == FS_COMPONENT_RTP)
+      ghostpad = gst_ghost_pad_new ("src", pad);
+    else if (c == FS_COMPONENT_RTCP)
+      ghostpad = gst_ghost_pad_new ("rtcpsrc", pad);
+    gst_object_unref (pad);
 
-  if (!gst_bin_add (GST_BIN (self->priv->gst_src),
-      self->priv->udprtcpsrc_funnel)) {
-    trans->construction_error = g_error_new (FS_ERROR,
-      FS_ERROR_CONSTRUCTION,
-      "Could not add the rtcp fsfunnel element to the transmitter src bin");
+    gst_pad_set_active (ghostpad, TRUE);
+    gst_element_add_pad (self->priv->gst_src, ghostpad);
   }
 
-  pad = gst_element_get_static_pad (self->priv->udprtcpsrc_funnel, "src");
-  ghostpad = gst_ghost_pad_new ("rtcpsrc", pad);
-  gst_object_unref (pad);
-
-  gst_pad_set_active (ghostpad, TRUE);
-  gst_element_add_pad (self->priv->gst_src, ghostpad);
-
-
   /* Second, we do the sink element */
 
   self->priv->gst_sink = gst_bin_new (NULL);
@@ -615,12 +599,12 @@ fs_rawudp_transmitter_get_udpport (FsRawUdpTransmitter *trans,
 
   if (component_id == FS_COMPONENT_RTP) {
     udpport->tee = trans->priv->udpsink_tee;
-    udpport->funnel = trans->priv->udpsrc_funnel;
   } else if (component_id == FS_COMPONENT_RTCP) {
     udpport->tee = trans->priv->udprtcpsink_tee;
-    udpport->funnel = trans->priv->udprtcpsrc_funnel;
   }
 
+  udpport->funnel = trans->priv->udpsrc_funnels[component_id];
+
   udpport->udpsrc = _create_sinksource ("udpsrc",
     GST_BIN (trans->priv->gst_src), udpport->funnel, udpport->fd, GST_PAD_SRC,
     &udpport->udpsrc_requested_pad, error);
-- 
1.5.6.5




More information about the farsight-commits mailing list