aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-video-src.c
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-03-04 01:34:44 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-03-04 01:34:44 +0800
commitc6546b498b5c4528aa182651243f20b40e6ad2e7 (patch)
treeebd94bdc1064603917d1e48cf772ee66589db685 /libempathy-gtk/empathy-video-src.c
parent937bed8acb966613630e10ae83aebfacb1a52af0 (diff)
downloadgsoc2013-empathy-c6546b498b5c4528aa182651243f20b40e6ad2e7.tar
gsoc2013-empathy-c6546b498b5c4528aa182651243f20b40e6ad2e7.tar.gz
gsoc2013-empathy-c6546b498b5c4528aa182651243f20b40e6ad2e7.tar.bz2
gsoc2013-empathy-c6546b498b5c4528aa182651243f20b40e6ad2e7.tar.lz
gsoc2013-empathy-c6546b498b5c4528aa182651243f20b40e6ad2e7.tar.xz
gsoc2013-empathy-c6546b498b5c4528aa182651243f20b40e6ad2e7.tar.zst
gsoc2013-empathy-c6546b498b5c4528aa182651243f20b40e6ad2e7.zip
Add support for changing various color channels of the video device
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> svn path=/trunk/; revision=2562
Diffstat (limited to 'libempathy-gtk/empathy-video-src.c')
-rw-r--r--libempathy-gtk/empathy-video-src.c125
1 files changed, 125 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-video-src.c b/libempathy-gtk/empathy-video-src.c
index 8614b6b43..d2d03026b 100644
--- a/libempathy-gtk/empathy-video-src.c
+++ b/libempathy-gtk/empathy-video-src.c
@@ -22,10 +22,16 @@
#include <stdio.h>
#include <stdlib.h>
+#include <gst/interfaces/colorbalance.h>
+
#include "empathy-video-src.h"
G_DEFINE_TYPE(EmpathyGstVideoSrc, empathy_video_src, GST_TYPE_BIN)
+/* Keep in sync with EmpathyGstVideoSrcChannel */
+static gchar *channel_names[NR_EMPATHY_GST_VIDEO_SRC_CHANNELS] = { "contrast",
+ "brightness", "gamma" };
+
/* signal enum */
#if 0
enum
@@ -43,6 +49,8 @@ struct _EmpathyGstVideoSrcPrivate
{
gboolean dispose_has_run;
GstElement *src;
+ /* Element implementing a ColorBalance interface */
+ GstElement *balance;
};
#define EMPATHY_GST_VIDEO_SRC_GET_PRIVATE(o) \
@@ -131,3 +139,120 @@ empathy_video_src_new (void)
{
return GST_ELEMENT (g_object_new (EMPATHY_TYPE_GST_VIDEO_SRC, NULL));
}
+
+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)
+ return;
+
+ balance = GST_COLOR_BALANCE (color);
+
+ channels = gst_color_balance_list_channels (balance);
+
+ for (l = (GList *)channels; l != NULL; l = g_list_next (l))
+ {
+ GstColorBalanceChannel *c = GST_COLOR_BALANCE_CHANNEL (l->data);
+
+ if (g_ascii_strcasecmp (c->label, channel_names[channel]) == 0)
+ {
+ gst_color_balance_set_value (balance, c,
+ ((c->max_value - c->min_value) * percent)/100
+ + c->min_value);
+ break;
+ }
+ }
+
+ g_object_unref (color);
+}
+
+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)
+ 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))
+ {
+ GstColorBalanceChannel *c = GST_COLOR_BALANCE_CHANNEL (l->data);
+
+ if (g_ascii_strcasecmp (c->label, channel_names[channel]) == 0)
+ {
+ percent =
+ ((gst_color_balance_get_value (balance, c)
+ - c->min_value) * 100) /
+ (c->max_value - c->min_value);
+
+ break;
+ }
+ }
+
+ g_object_unref (color);
+
+ return percent;
+}
+
+
+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)
+ 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))
+ {
+ GstColorBalanceChannel *channel = GST_COLOR_BALANCE_CHANNEL (l->data);
+ int i;
+
+ for (i = 0; i < NR_EMPATHY_GST_VIDEO_SRC_CHANNELS; i++)
+ {
+ if (g_ascii_strcasecmp (channel->label, channel_names[i]) == 0)
+ {
+ result |= (1 << i);
+ break;
+ }
+ }
+ }
+
+ g_object_unref (color);
+
+out:
+ return result;
+}
+