]> git.0d.be Git - empathy.git/commitdiff
video-src: factor out dup_color_balance()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 9 Sep 2011 11:39:44 +0000 (13:39 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 9 Sep 2011 11:46:02 +0000 (13:46 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=658584

src/empathy-video-src.c

index 25d257f3d22e785e26733e729c8ad264b96025fe..da86eda935b026ad26a6717283efc742d5b8d628 100644 (file)
@@ -245,23 +245,32 @@ empathy_video_src_new (void)
   return gst_element_factory_make ("empathyvideosrc", NULL);
 }
 
+static GstColorBalance *
+dup_color_balance (GstElement *src)
+{
+  GstElement *color;
+
+  /* Find something supporting GstColorBalance */
+  color = gst_bin_get_by_interface (GST_BIN (src), GST_TYPE_COLOR_BALANCE);
+
+  if (color == NULL)
+    return NULL;
+
+  return GST_COLOR_BALANCE (color);
+}
+
 void
 empathy_video_src_set_channel (GstElement *src,
   EmpathyGstVideoSrcChannel channel, guint percent)
 {
-  GstElement *color;
   GstColorBalance *balance;
   const GList *channels;
   GList *l;
 
-  /* Find something supporting GstColorBalance */
-  color = gst_bin_get_by_interface (GST_BIN (src), GST_TYPE_COLOR_BALANCE);
-
-  if (color == NULL)
+  balance = dup_color_balance (src);
+  if (balance == NULL)
     return;
 
-  balance = GST_COLOR_BALANCE (color);
-
   channels = gst_color_balance_list_channels (balance);
 
   for (l = (GList *) channels; l != NULL; l = g_list_next (l))
@@ -277,27 +286,22 @@ empathy_video_src_set_channel (GstElement *src,
         }
     }
 
-  g_object_unref (color);
+  g_object_unref (balance);
 }
 
 guint
 empathy_video_src_get_channel (GstElement *src,
   EmpathyGstVideoSrcChannel channel)
 {
-  GstElement *color;
   GstColorBalance *balance;
   const GList *channels;
   GList *l;
   guint percent = 0;
 
-  /* Find something supporting GstColorBalance */
-  color = gst_bin_get_by_interface (GST_BIN (src), GST_TYPE_COLOR_BALANCE);
-
-  if (color == NULL)
+  balance = dup_color_balance (src);
+  if (balance == NULL)
     return percent;
 
-  balance = GST_COLOR_BALANCE (color);
-
   channels = gst_color_balance_list_channels (balance);
 
   for (l = (GList *) channels; l != NULL; l = g_list_next (l))
@@ -315,7 +319,7 @@ empathy_video_src_get_channel (GstElement *src,
         }
     }
 
-  g_object_unref (color);
+  g_object_unref (balance);
 
   return percent;
 }
@@ -324,20 +328,15 @@ empathy_video_src_get_channel (GstElement *src,
 guint
 empathy_video_src_get_supported_channels (GstElement *src)
 {
-  GstElement *color;
   GstColorBalance *balance;
   const GList *channels;
   GList *l;
   guint result = 0;
 
-  /* Find something supporting GstColorBalance */
-  color = gst_bin_get_by_interface (GST_BIN (src), GST_TYPE_COLOR_BALANCE);
-
-  if (color == NULL)
+  balance = dup_color_balance (src);
+  if (balance == NULL)
     goto out;
 
-  balance = GST_COLOR_BALANCE (color);
-
   channels = gst_color_balance_list_channels (balance);
 
   for (l = (GList *) channels; l != NULL; l = g_list_next (l))
@@ -355,7 +354,7 @@ empathy_video_src_get_supported_channels (GstElement *src)
         }
     }
 
-  g_object_unref (color);
+  g_object_unref (balance);
 
 out:
   return result;