1 /* GStreamer Color Balance interface implementation
2 * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
4 * gstv4l2colorbalance.c: color balance interface implementation for V4L2
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
27 #include "gstv4l2colorbalance.h"
28 #include "gstv4l2element.h"
31 gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
33 static void gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *
36 static const GList *gst_v4l2_color_balance_list_channels (GstColorBalance *
38 static void gst_v4l2_color_balance_set_value (GstColorBalance * balance,
39 GstColorBalanceChannel * channel, gint value);
40 static gint gst_v4l2_color_balance_get_value (GstColorBalance * balance,
41 GstColorBalanceChannel * channel);
43 static GstColorBalanceChannelClass *parent_class = NULL;
46 gst_v4l2_color_balance_channel_get_type (void)
48 static GType gst_v4l2_color_balance_channel_type = 0;
50 if (!gst_v4l2_color_balance_channel_type) {
51 static const GTypeInfo v4l2_tuner_channel_info = {
52 sizeof (GstV4l2ColorBalanceChannelClass),
55 (GClassInitFunc) gst_v4l2_color_balance_channel_class_init,
58 sizeof (GstV4l2ColorBalanceChannel),
60 (GInstanceInitFunc) gst_v4l2_color_balance_channel_init,
64 gst_v4l2_color_balance_channel_type =
65 g_type_register_static (GST_TYPE_COLOR_BALANCE_CHANNEL,
66 "GstV4l2ColorBalanceChannel", &v4l2_tuner_channel_info, 0);
69 return gst_v4l2_color_balance_channel_type;
73 gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
76 parent_class = g_type_class_ref (GST_TYPE_COLOR_BALANCE_CHANNEL);
80 gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel * channel)
86 gst_v4l2_color_balance_interface_init (GstColorBalanceClass * klass)
88 GST_COLOR_BALANCE_TYPE (klass) = GST_COLOR_BALANCE_HARDWARE;
90 /* default virtual functions */
91 klass->list_channels = gst_v4l2_color_balance_list_channels;
92 klass->set_value = gst_v4l2_color_balance_set_value;
93 klass->get_value = gst_v4l2_color_balance_get_value;
97 gst_v4l2_color_balance_contains_channel (GstV4l2Element * v4l2element,
98 GstV4l2ColorBalanceChannel * v4l2channel)
102 for (item = v4l2element->colors; item != NULL; item = item->next)
103 if (item->data == v4l2channel)
110 gst_v4l2_color_balance_list_channels (GstColorBalance * balance)
112 return GST_V4L2ELEMENT (balance)->colors;
116 gst_v4l2_color_balance_set_value (GstColorBalance * balance,
117 GstColorBalanceChannel * channel, gint value)
119 GstV4l2Element *v4l2element = GST_V4L2ELEMENT (balance);
120 GstV4l2ColorBalanceChannel *v4l2channel =
121 GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
123 /* assert that we're opened and that we're using a known item */
124 g_return_if_fail (GST_V4L2_IS_OPEN (v4l2element));
125 g_return_if_fail (gst_v4l2_color_balance_contains_channel (v4l2element,
128 gst_v4l2_set_attribute (v4l2element, v4l2channel->index, value);
132 gst_v4l2_color_balance_get_value (GstColorBalance * balance,
133 GstColorBalanceChannel * channel)
135 GstV4l2Element *v4l2element = GST_V4L2ELEMENT (balance);
136 GstV4l2ColorBalanceChannel *v4l2channel =
137 GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
140 /* assert that we're opened and that we're using a known item */
141 g_return_val_if_fail (GST_V4L2_IS_OPEN (v4l2element), 0);
142 g_return_val_if_fail (gst_v4l2_color_balance_contains_channel (v4l2element,
145 if (!gst_v4l2_get_attribute (v4l2element, v4l2channel->index, &value))