1 /* GStreamer Color Balance
2 * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
4 * colorbalance.c: image color balance interface design
5 * virtual class function wrappers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
27 #include "colorbalance.h"
28 #include "interfaces-marshal.h"
36 static void gst_color_balance_class_init (GstColorBalanceClass * klass);
38 static guint gst_color_balance_signals[LAST_SIGNAL] = { 0 };
41 gst_color_balance_get_type (void)
43 static GType gst_color_balance_type = 0;
45 if (!gst_color_balance_type) {
46 static const GTypeInfo gst_color_balance_info = {
47 sizeof (GstColorBalanceClass),
48 (GBaseInitFunc) gst_color_balance_class_init,
58 gst_color_balance_type = g_type_register_static (G_TYPE_INTERFACE,
59 "GstColorBalance", &gst_color_balance_info, 0);
60 g_type_interface_add_prerequisite (gst_color_balance_type,
61 GST_TYPE_IMPLEMENTS_INTERFACE);
64 return gst_color_balance_type;
68 gst_color_balance_class_init (GstColorBalanceClass * klass)
70 static gboolean initialized = FALSE;
73 gst_color_balance_signals[VALUE_CHANGED] =
74 g_signal_new ("value-changed",
75 GST_TYPE_COLOR_BALANCE, G_SIGNAL_RUN_LAST,
76 G_STRUCT_OFFSET (GstColorBalanceClass, value_changed),
78 gst_interfaces_marshal_VOID__OBJECT_INT,
79 G_TYPE_NONE, 2, GST_TYPE_COLOR_BALANCE_CHANNEL, G_TYPE_INT);
84 klass->balance_type = GST_COLOR_BALANCE_SOFTWARE;
86 /* default virtual functions */
87 klass->list_channels = NULL;
88 klass->set_value = NULL;
89 klass->get_value = NULL;
93 gst_color_balance_list_channels (GstColorBalance * balance)
95 GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
97 if (klass->list_channels) {
98 return klass->list_channels (balance);
105 gst_color_balance_set_value (GstColorBalance * balance,
106 GstColorBalanceChannel * channel, gint value)
108 GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
110 if (klass->set_value) {
111 klass->set_value (balance, channel, value);
116 gst_color_balance_get_value (GstColorBalance * balance,
117 GstColorBalanceChannel * channel)
119 GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
121 if (klass->get_value) {
122 return klass->get_value (balance, channel);
125 return channel->min_value;
129 gst_color_balance_value_changed (GstColorBalance * balance,
130 GstColorBalanceChannel * channel, gint value)
132 g_signal_emit (G_OBJECT (balance),
133 gst_color_balance_signals[VALUE_CHANGED], 0, channel, value);
135 g_signal_emit_by_name (G_OBJECT (channel), "value_changed", value);