[farsight2/master] Move more code to the base class

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


---
 gst/fsrtpconference/fs-rtp-dtmf-event-source.c |   53 +----------------------
 gst/fsrtpconference/fs-rtp-special-source.c    |   51 ++++++++++++++++++++++-
 2 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-dtmf-event-source.c b/gst/fsrtpconference/fs-rtp-dtmf-event-source.c
index cd27630..c846ca7 100644
--- a/gst/fsrtpconference/fs-rtp-dtmf-event-source.c
+++ b/gst/fsrtpconference/fs-rtp-dtmf-event-source.c
@@ -238,8 +238,6 @@ fs_rtp_dtmf_event_source_build (FsRtpSpecialSource *source,
   GstElement *capsfilter = NULL;
   GstPad *ghostpad = NULL;
   GstElement *bin = NULL;
-  GstElement *outer_bin = NULL;
-  GstElement *rtpmuxer = NULL;
 
   telephony_codec = get_telephone_event_codec (negotiated_codecs,
       selected_codec->clock_rate);
@@ -248,34 +246,10 @@ fs_rtp_dtmf_event_source_build (FsRtpSpecialSource *source,
   {
     g_set_error (error, FS_ERROR, FS_ERROR_INTERNAL,
         "Could not find a telephone-event for the current codec's clock-rate");
-    goto done;
-  }
-
-  g_object_get (source, "bin", &outer_bin, "rtpmuxer", &rtpmuxer, NULL);
-
-  if (!outer_bin)
-  {
-    g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
-        "Invalid bin set");
-    goto done;
-  }
-
-  if (!rtpmuxer)
-  {
-    g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
-        "Invalid rtpmuxer set");
-    goto done;
+    return NULL;
   }
 
   bin = gst_bin_new (NULL);
-  if (!gst_bin_add (GST_BIN (outer_bin), bin))
-  {
-    g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
-        "Could not add bin to outer bin");
-    gst_object_unref (bin);
-    bin = NULL;
-    goto done;
-  }
 
   dtmfsrc = gst_element_factory_make ("rtpdtmfsrc", NULL);
   if (!dtmfsrc)
@@ -346,32 +320,11 @@ fs_rtp_dtmf_event_source_build (FsRtpSpecialSource *source,
   }
   gst_object_unref (pad);
 
-  if (!gst_element_link_pads (bin, "src",
-          rtpmuxer, NULL))
-  {
-    g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
-        "Could not link rtpdtmfsrc src to muxer sink");
-    goto error;
-  }
-
-  if (!gst_element_sync_state_with_parent (bin))
-  {
-    g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
-        "Could not sync capsfilter state with its parent");
-    goto error;
-  }
-
- done:
-  if (rtpmuxer)
-    gst_object_unref (rtpmuxer);
-  if (outer_bin)
-    gst_object_unref (outer_bin);
-
   return bin;
 
  error:
-  gst_bin_remove (GST_BIN (outer_bin), bin);
+  gst_object_unref (bin);
 
-  goto done;
+  return NULL;
 }
 
diff --git a/gst/fsrtpconference/fs-rtp-special-source.c b/gst/fsrtpconference/fs-rtp-special-source.c
index 630d586..a6a1d29 100644
--- a/gst/fsrtpconference/fs-rtp-special-source.c
+++ b/gst/fsrtpconference/fs-rtp-special-source.c
@@ -472,16 +472,63 @@ fs_rtp_special_source_new (FsRtpSpecialSourceClass *klass,
       NULL);
   g_assert (source);
 
+
+  if (!source->priv->outer_bin)
+  {
+    g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
+        "Invalid bin set");
+    goto error;
+  }
+
+  if (!source->priv->rtpmuxer)
+  {
+    g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
+        "Invalid rtpmuxer set");
+    goto error;
+  }
+
   source->priv->src = klass->build (source, negotiated_codecs, selected_codec,
       error);
 
   if (!source->priv->src)
+    goto error;
+
+  if (!gst_bin_add (GST_BIN (source->priv->outer_bin), source->priv->src))
   {
-    g_object_unref (source);
-    return NULL;
+    g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
+        "Could not add bin to outer bin");
+    gst_object_unref (source->priv->src);
+    source->priv->src = NULL;
+    goto error;
+  }
+
+  if (!gst_element_link_pads (source->priv->src, "src",
+          rtpmuxer, NULL))
+  {
+    g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
+        "Could not link rtpdtmfsrc src to muxer sink");
+    goto error_added;
+
+  }
+
+  if (!gst_element_sync_state_with_parent (source->priv->src))
+  {
+    g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
+        "Could not sync capsfilter state with its parent");
+    goto error_added;
   }
 
   return source;
+
+ error_added:
+  gst_element_set_state (source->priv->src, GST_STATE_NULL);
+  gst_bin_remove (GST_BIN (source->priv->outer_bin), source->priv->src);
+  source->priv->src = NULL;
+
+ error:
+  g_object_unref (source);
+
+  return NULL;
 }
 
 static gboolean
-- 
1.5.6.5




More information about the farsight-commits mailing list