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 *klass);
33 gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *channel);
36 gst_v4l2_color_balance_list_channels (GstColorBalance *balance);
38 gst_v4l2_color_balance_set_value (GstColorBalance *balance,
39 GstColorBalanceChannel *channel,
42 gst_v4l2_color_balance_get_value (GstColorBalance *balance,
43 GstColorBalanceChannel *channel);
45 static GstColorBalanceChannelClass *parent_class = NULL;
48 gst_v4l2_color_balance_channel_get_type (void)
50 static GType gst_v4l2_color_balance_channel_type = 0;
52 if (!gst_v4l2_color_balance_channel_type) {
53 static const GTypeInfo v4l2_tuner_channel_info = {
54 sizeof (GstV4l2ColorBalanceChannelClass),
57 (GClassInitFunc) gst_v4l2_color_balance_channel_class_init,
60 sizeof (GstV4l2ColorBalanceChannel),
62 (GInstanceInitFunc) gst_v4l2_color_balance_channel_init,
66 gst_v4l2_color_balance_channel_type =
67 g_type_register_static (GST_TYPE_COLOR_BALANCE_CHANNEL,
68 "GstV4l2ColorBalanceChannel",
69 &v4l2_tuner_channel_info, 0);
72 return gst_v4l2_color_balance_channel_type;
76 gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *klass)
78 parent_class = g_type_class_ref (GST_TYPE_COLOR_BALANCE_CHANNEL);
82 gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *channel)
88 gst_v4l2_color_balance_interface_init (GstColorBalanceClass *klass)
90 GST_COLOR_BALANCE_TYPE (klass) = GST_COLOR_BALANCE_HARDWARE;
92 /* default virtual functions */
93 klass->list_channels = gst_v4l2_color_balance_list_channels;
94 klass->set_value = gst_v4l2_color_balance_set_value;
95 klass->get_value = gst_v4l2_color_balance_get_value;
99 gst_v4l2_color_balance_contains_channel (GstV4l2Element *v4l2element,
100 GstV4l2ColorBalanceChannel *v4l2channel)
104 for (item = v4l2element->colors; item != NULL; item = item->next)
105 if (item->data == v4l2channel)
112 gst_v4l2_color_balance_list_channels (GstColorBalance *balance)
114 return GST_V4L2ELEMENT (balance)->colors;
118 gst_v4l2_color_balance_set_value (GstColorBalance *balance,
119 GstColorBalanceChannel *channel,
122 GstV4l2Element *v4l2element = GST_V4L2ELEMENT (balance);
123 GstV4l2ColorBalanceChannel *v4l2channel =
124 GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
126 /* assert that we're opened and that we're using a known item */
127 g_return_if_fail (GST_V4L2_IS_OPEN (v4l2element));
128 g_return_if_fail (gst_v4l2_color_balance_contains_channel (v4l2element,
131 gst_v4l2_set_attribute (v4l2element, v4l2channel->index, value);
135 gst_v4l2_color_balance_get_value (GstColorBalance *balance,
136 GstColorBalanceChannel *channel)
138 GstV4l2Element *v4l2element = GST_V4L2ELEMENT (balance);
139 GstV4l2ColorBalanceChannel *v4l2channel =
140 GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
143 /* assert that we're opened and that we're using a known item */
144 g_return_val_if_fail (GST_V4L2_IS_OPEN (v4l2element), 0);
145 g_return_val_if_fail (gst_v4l2_color_balance_contains_channel (v4l2element,
149 if (!gst_v4l2_get_attribute (v4l2element, v4l2channel->index, &value))