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 "video-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'
44 /* FIXME 0.11: check if we need to add API for sometimes-supportedness
45 * (aka making up for GstImplementsInterface removal) */
47 /* FIXME 0.11: replace signals with messages (+ make API thread-safe) */
55 static void gst_color_balance_class_init (GstColorBalanceInterface * iface);
57 static guint gst_color_balance_signals[LAST_SIGNAL] = { 0 };
60 gst_color_balance_get_type (void)
62 static GType gst_color_balance_type = 0;
64 if (!gst_color_balance_type) {
65 static const GTypeInfo gst_color_balance_info = {
66 sizeof (GstColorBalanceInterface),
67 (GBaseInitFunc) gst_color_balance_class_init,
77 gst_color_balance_type = g_type_register_static (G_TYPE_INTERFACE,
78 "GstColorBalance", &gst_color_balance_info, 0);
81 return gst_color_balance_type;
85 gst_color_balance_class_init (GstColorBalanceInterface * iface)
87 static gboolean initialized = FALSE;
91 * GstColorBalance::value-changed:
92 * @colorbalance: The GstColorBalance instance
93 * @channel: The #GstColorBalanceChannel
94 * @value: The new value
96 * Fired when the value of the indicated channel has changed.
98 gst_color_balance_signals[VALUE_CHANGED] =
99 g_signal_new ("value-changed",
100 GST_TYPE_COLOR_BALANCE, G_SIGNAL_RUN_LAST,
101 G_STRUCT_OFFSET (GstColorBalanceInterface, value_changed),
103 gst_video_marshal_VOID__OBJECT_INT,
104 G_TYPE_NONE, 2, GST_TYPE_COLOR_BALANCE_CHANNEL, G_TYPE_INT);
109 iface->balance_type = GST_COLOR_BALANCE_SOFTWARE;
111 /* default virtual functions */
112 iface->list_channels = NULL;
113 iface->set_value = NULL;
114 iface->get_value = NULL;
118 * gst_color_balance_list_channels:
119 * @balance: A #GstColorBalance instance
121 * Retrieve a list of the available channels.
123 * Returns: A GList containing pointers to #GstColorBalanceChannel objects.
124 * The list is owned by the #GstColorBalance instance and must not
128 gst_color_balance_list_channels (GstColorBalance * balance)
130 GstColorBalanceInterface *iface;
132 g_return_val_if_fail (GST_IS_COLOR_BALANCE (balance), NULL);
134 iface = GST_COLOR_BALANCE_GET_INTERFACE (balance);
136 if (iface->list_channels) {
137 return iface->list_channels (balance);
144 * gst_color_balance_set_value:
145 * @balance: A #GstColorBalance instance
146 * @channel: A #GstColorBalanceChannel instance
147 * @value: The new value for the channel.
149 * Sets the current value of the channel to the passed value, which must
150 * be between min_value and max_value.
152 * See Also: The #GstColorBalanceChannel.min_value and
153 * #GstColorBalanceChannel.max_value members of the
154 * #GstColorBalanceChannel object.
157 gst_color_balance_set_value (GstColorBalance * balance,
158 GstColorBalanceChannel * channel, gint value)
160 GstColorBalanceInterface *iface = GST_COLOR_BALANCE_GET_INTERFACE (balance);
162 if (iface->set_value) {
163 iface->set_value (balance, channel, value);
168 * gst_color_balance_get_value:
169 * @balance: A #GstColorBalance instance
170 * @channel: A #GstColorBalanceChannel instance
172 * Retrieve the current value of the indicated channel, between min_value
175 * See Also: The #GstColorBalanceChannel.min_value and
176 * #GstColorBalanceChannel.max_value members of the
177 * #GstColorBalanceChannel object.
179 * Returns: The current value of the channel.
182 gst_color_balance_get_value (GstColorBalance * balance,
183 GstColorBalanceChannel * channel)
185 GstColorBalanceInterface *iface;
187 g_return_val_if_fail (GST_IS_COLOR_BALANCE (balance), 0);
189 iface = GST_COLOR_BALANCE_GET_INTERFACE (balance);
191 if (iface->get_value) {
192 return iface->get_value (balance, channel);
195 return channel->min_value;
199 * gst_color_balance_get_balance_type:
200 * @balance: The #GstColorBalance implementation
202 * Get the #GstColorBalanceType of this implementation.
204 * Returns: A the #GstColorBalanceType.
209 gst_color_balance_get_balance_type (GstColorBalance * balance)
211 GstColorBalanceInterface *iface;
213 g_return_val_if_fail (GST_IS_COLOR_BALANCE (balance),
214 GST_COLOR_BALANCE_SOFTWARE);
216 iface = GST_COLOR_BALANCE_GET_INTERFACE (balance);
218 return iface->balance_type;
222 * gst_color_balance_value_changed:
223 * @balance: A #GstColorBalance instance
224 * @channel: A #GstColorBalanceChannel whose value has changed
225 * @value: The new value of the channel
227 * A helper function called by implementations of the GstColorBalance
228 * interface. It fires the #GstColorBalance::value-changed signal on the
229 * instance, and the #GstColorBalanceChannel::value-changed signal on the
233 gst_color_balance_value_changed (GstColorBalance * balance,
234 GstColorBalanceChannel * channel, gint value)
237 g_return_if_fail (GST_IS_COLOR_BALANCE (balance));
239 g_signal_emit (G_OBJECT (balance),
240 gst_color_balance_signals[VALUE_CHANGED], 0, channel, value);
242 g_signal_emit_by_name (G_OBJECT (channel), "value_changed", value);