3 * gstv4lcolorbalance.c: color balance interface implementation for V4L
5 * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
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.
28 #include "gstv4lcolorbalance.h"
29 #include "gstv4lelement.h"
32 gst_v4l_color_balance_channel_class_init (GstV4lColorBalanceChannelClass *
34 static void gst_v4l_color_balance_channel_init (GstV4lColorBalanceChannel *
37 static const GList *gst_v4l_color_balance_list_channels (GstColorBalance *
39 static void gst_v4l_color_balance_set_value (GstColorBalance * balance,
40 GstColorBalanceChannel * channel, gint value);
41 static gint gst_v4l_color_balance_get_value (GstColorBalance * balance,
42 GstColorBalanceChannel * channel);
44 static GstColorBalanceChannelClass *parent_class = NULL;
47 gst_v4l_color_balance_channel_get_type (void)
49 static GType gst_v4l_color_balance_channel_type = 0;
51 if (!gst_v4l_color_balance_channel_type) {
52 static const GTypeInfo v4l_tuner_channel_info = {
53 sizeof (GstV4lColorBalanceChannelClass),
56 (GClassInitFunc) gst_v4l_color_balance_channel_class_init,
59 sizeof (GstV4lColorBalanceChannel),
61 (GInstanceInitFunc) gst_v4l_color_balance_channel_init,
65 gst_v4l_color_balance_channel_type =
66 g_type_register_static (GST_TYPE_COLOR_BALANCE_CHANNEL,
67 "GstV4lColorBalanceChannel", &v4l_tuner_channel_info, 0);
70 return gst_v4l_color_balance_channel_type;
74 gst_v4l_color_balance_channel_class_init (GstV4lColorBalanceChannelClass *
77 parent_class = g_type_class_peek_parent (klass);
81 gst_v4l_color_balance_channel_init (GstV4lColorBalanceChannel * channel)
87 gst_v4l_color_balance_interface_init (GstColorBalanceClass * klass)
89 GST_COLOR_BALANCE_TYPE (klass) = GST_COLOR_BALANCE_HARDWARE;
91 /* default virtual functions */
92 klass->list_channels = gst_v4l_color_balance_list_channels;
93 klass->set_value = gst_v4l_color_balance_set_value;
94 klass->get_value = gst_v4l_color_balance_get_value;
97 static G_GNUC_UNUSED gboolean
98 gst_v4l_color_balance_contains_channel (GstV4lElement * v4lelement,
99 GstV4lColorBalanceChannel * v4lchannel)
103 for (item = v4lelement->colors; item != NULL; item = item->next)
104 if (item->data == v4lchannel)
111 gst_v4l_color_balance_list_channels (GstColorBalance * balance)
113 return GST_V4LELEMENT (balance)->colors;
117 gst_v4l_color_balance_set_value (GstColorBalance * balance,
118 GstColorBalanceChannel * channel, gint value)
120 GstV4lElement *v4lelement = GST_V4LELEMENT (balance);
121 GstV4lColorBalanceChannel *v4lchannel =
122 GST_V4L_COLOR_BALANCE_CHANNEL (channel);
124 /* assert that we're opened and that we're using a known item */
125 g_return_if_fail (GST_V4L_IS_OPEN (v4lelement));
126 g_return_if_fail (gst_v4l_color_balance_contains_channel (v4lelement,
129 gst_v4l_set_picture (v4lelement, v4lchannel->index, value);
133 gst_v4l_color_balance_get_value (GstColorBalance * balance,
134 GstColorBalanceChannel * channel)
136 GstV4lElement *v4lelement = GST_V4LELEMENT (balance);
137 GstV4lColorBalanceChannel *v4lchannel =
138 GST_V4L_COLOR_BALANCE_CHANNEL (channel);
141 /* assert that we're opened and that we're using a known item */
142 g_return_val_if_fail (GST_V4L_IS_OPEN (v4lelement), 0);
143 g_return_val_if_fail (gst_v4l_color_balance_contains_channel (v4lelement,
146 if (!gst_v4l_get_picture (v4lelement, v4lchannel->index, &value))