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"
31 * SECTION:gstcolorbalance
32 * @short_description: Interface for adjusting color balance settings
35 * This interface is implemented by elements which can perform some color
36 * balance operation on video frames they process. For example, modifying
37 * the brightness, contrast, hue or saturation.
39 * Example elements are 'xvimagesink' and 'colorbalance'
50 static void gst_color_balance_class_init (GstColorBalanceClass * klass);
52 static guint gst_color_balance_signals[LAST_SIGNAL] = { 0 };
55 gst_color_balance_get_type (void)
57 static GType gst_color_balance_type = 0;
59 if (!gst_color_balance_type) {
60 static const GTypeInfo gst_color_balance_info = {
61 sizeof (GstColorBalanceClass),
62 (GBaseInitFunc) gst_color_balance_class_init,
72 gst_color_balance_type = g_type_register_static (G_TYPE_INTERFACE,
73 "GstColorBalance", &gst_color_balance_info, 0);
74 g_type_interface_add_prerequisite (gst_color_balance_type,
75 GST_TYPE_IMPLEMENTS_INTERFACE);
78 return gst_color_balance_type;
82 gst_color_balance_class_init (GstColorBalanceClass * klass)
84 static gboolean initialized = FALSE;
88 * GstColorBalance::value-changed:
89 * @colorbalance: The GstColorBalance instance
90 * @channel: The #GstColorBalanceChannel
91 * @value: The new value
93 * Fired when the value of the indicated channel has changed.
95 gst_color_balance_signals[VALUE_CHANGED] =
96 g_signal_new ("value-changed",
97 GST_TYPE_COLOR_BALANCE, G_SIGNAL_RUN_LAST,
98 G_STRUCT_OFFSET (GstColorBalanceClass, value_changed),
100 gst_interfaces_marshal_VOID__OBJECT_INT,
101 G_TYPE_NONE, 2, GST_TYPE_COLOR_BALANCE_CHANNEL, G_TYPE_INT);
106 klass->balance_type = GST_COLOR_BALANCE_SOFTWARE;
108 /* default virtual functions */
109 klass->list_channels = NULL;
110 klass->set_value = NULL;
111 klass->get_value = NULL;
115 * gst_color_balance_list_channels:
116 * @balance: A #GstColorBalance instance
118 * Retrieve a list of the available channels.
120 * Returns: A GList containing pointers to #GstColorBalanceChannel objects.
121 * The list is owned by the #GstColorBalance instance and must not
125 gst_color_balance_list_channels (GstColorBalance * balance)
127 GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
129 if (klass->list_channels) {
130 return klass->list_channels (balance);
137 * gst_color_balance_set_value:
138 * @balance: A #GstColorBalance instance
139 * @channel: A #GstColorBalanceChannel instance
140 * @value: The new value for the channel.
142 * Sets the current value of the channel to the passed value, which must
143 * be between min_value and max_value.
145 * See Also: The #GstColorBalanceChannel::min_value and
146 * #GstColorBalanceChannel::max_value members of the
147 * #GstColorBalanceChannel object.
150 gst_color_balance_set_value (GstColorBalance * balance,
151 GstColorBalanceChannel * channel, gint value)
153 GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
155 if (klass->set_value) {
156 klass->set_value (balance, channel, value);
161 * gst_color_balance_get_value:
162 * @balance: A #GstColorBalance instance
163 * @channel: A #GstColorBalanceChannel instance
165 * Retrieve the current value of the indicated channel, between min_value
168 * See Also: The #GstColorBalanceChannel::min_value and
169 * #GstColorBalanceChannel::max_value members of the
170 * #GstColorBalanceChannel object.
172 * Returns: The current value of the channel.
175 gst_color_balance_get_value (GstColorBalance * balance,
176 GstColorBalanceChannel * channel)
178 GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
180 if (klass->get_value) {
181 return klass->get_value (balance, channel);
184 return channel->min_value;
188 * gst_color_balance_get_balance_type:
189 * @balance: The #GstColorBalance implementation
191 * Get the #GstColorBalanceType of this implementation.
193 * Returns: A the #GstColorBalanceType.
198 gst_color_balance_get_balance_type (GstColorBalance * balance)
200 GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
202 return klass->balance_type;
206 * gst_color_balance_value_changed:
207 * @balance: A #GstColorBalance instance
208 * @channel: A #GstColorBalanceChannel whose value has changed
209 * @value: The new value of the channel
211 * A helper function called by implementations of the GstColorBalance
212 * interface. It fires the #GstColorBalance::value-changed signal on the
213 * instance, and the #GstColorBalanceChannel::value-changed signal on the
217 gst_color_balance_value_changed (GstColorBalance * balance,
218 GstColorBalanceChannel * channel, gint value)
220 g_signal_emit (G_OBJECT (balance),
221 gst_color_balance_signals[VALUE_CHANGED], 0, channel, value);
223 g_signal_emit_by_name (G_OBJECT (channel), "value_changed", value);