empathy r2562 - trunk/libempathy-gtk
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r2562 - trunk/libempathy-gtk
- Date: Tue, 3 Mar 2009 17:34:44 +0000 (UTC)
Author: xclaesse
Date: Tue Mar 3 17:34:44 2009
New Revision: 2562
URL: http://svn.gnome.org/viewvc/empathy?rev=2562&view=rev
Log:
Add support for changing various color channels of the video device
Signed-off-by: Sjoerd Simons <sjoerd simons collabora co uk>
Modified:
trunk/libempathy-gtk/empathy-video-src.c
trunk/libempathy-gtk/empathy-video-src.h
Modified: trunk/libempathy-gtk/empathy-video-src.c
==============================================================================
--- trunk/libempathy-gtk/empathy-video-src.c (original)
+++ trunk/libempathy-gtk/empathy-video-src.c Tue Mar 3 17:34:44 2009
@@ -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 @@
{
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 @@
{
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;
+}
+
Modified: trunk/libempathy-gtk/empathy-video-src.h
==============================================================================
--- trunk/libempathy-gtk/empathy-video-src.h (original)
+++ trunk/libempathy-gtk/empathy-video-src.h Tue Mar 3 17:34:44 2009
@@ -29,6 +29,20 @@
typedef struct _EmpathyGstVideoSrc EmpathyGstVideoSrc;
typedef struct _EmpathyGstVideoSrcClass EmpathyGstVideoSrcClass;
+typedef enum {
+ EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST = 0,
+ EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS = 1,
+ EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA = 2,
+ NR_EMPATHY_GST_VIDEO_SRC_CHANNELS
+} EmpathyGstVideoSrcChannel;
+
+#define EMPATHY_GST_VIDEO_SRC_SUPPORTS_CONTRAST \
+ (1 << EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST)
+#define EMPATHY_GST_VIDEO_SRC_SUPPORTS_BRIGHTNESS \
+ (1 << EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS)
+#define EMPATHY_GST_VIDEO_SRC_SUPPORTS_GAMMA \
+ (1 << EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA)
+
struct _EmpathyGstVideoSrcClass {
GstBinClass parent_class;
};
@@ -58,6 +72,16 @@
GstElement *empathy_video_src_new (void);
+guint
+empathy_video_src_get_supported_channels (GstElement *src);
+
+void empathy_video_src_set_channel (GstElement *src,
+ EmpathyGstVideoSrcChannel channel, guint percent);
+
+guint empathy_video_src_get_channel (GstElement *src,
+ EmpathyGstVideoSrcChannel channel);
+
+
G_END_DECLS
#endif /* #ifndef __EMPATHY_GST_VIDEO_SRC_H__*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]