source: trunk/third/gst-plugins/sys/v4l2/gstv4l2colorbalance.c @ 21011

Revision 21011, 4.6 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21010, which included commits to RCS files with non-trunk default branches.
Line 
1/* GStreamer Color Balance interface implementation
2 * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3 *
4 * gstv4l2colorbalance.c: color balance interface implementation for V4L2
5 *
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.
10 *
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.
15 *
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.
20 */
21
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
25
26#include <gst/gst.h>
27#include "gstv4l2colorbalance.h"
28#include "gstv4l2element.h"
29
30static void
31gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
32    klass);
33static void gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *
34    channel);
35
36static const GList *gst_v4l2_color_balance_list_channels (GstColorBalance *
37    balance);
38static void gst_v4l2_color_balance_set_value (GstColorBalance * balance,
39    GstColorBalanceChannel * channel, gint value);
40static gint gst_v4l2_color_balance_get_value (GstColorBalance * balance,
41    GstColorBalanceChannel * channel);
42
43static GstColorBalanceChannelClass *parent_class = NULL;
44
45GType
46gst_v4l2_color_balance_channel_get_type (void)
47{
48  static GType gst_v4l2_color_balance_channel_type = 0;
49
50  if (!gst_v4l2_color_balance_channel_type) {
51    static const GTypeInfo v4l2_tuner_channel_info = {
52      sizeof (GstV4l2ColorBalanceChannelClass),
53      NULL,
54      NULL,
55      (GClassInitFunc) gst_v4l2_color_balance_channel_class_init,
56      NULL,
57      NULL,
58      sizeof (GstV4l2ColorBalanceChannel),
59      0,
60      (GInstanceInitFunc) gst_v4l2_color_balance_channel_init,
61      NULL
62    };
63
64    gst_v4l2_color_balance_channel_type =
65        g_type_register_static (GST_TYPE_COLOR_BALANCE_CHANNEL,
66        "GstV4l2ColorBalanceChannel", &v4l2_tuner_channel_info, 0);
67  }
68
69  return gst_v4l2_color_balance_channel_type;
70}
71
72static void
73gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
74    klass)
75{
76  parent_class = g_type_class_ref (GST_TYPE_COLOR_BALANCE_CHANNEL);
77}
78
79static void
80gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel * channel)
81{
82  channel->index = 0;
83}
84
85void
86gst_v4l2_color_balance_interface_init (GstColorBalanceClass * klass)
87{
88  GST_COLOR_BALANCE_TYPE (klass) = GST_COLOR_BALANCE_HARDWARE;
89
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;
94}
95
96static G_GNUC_UNUSED gboolean
97gst_v4l2_color_balance_contains_channel (GstV4l2Element * v4l2element,
98    GstV4l2ColorBalanceChannel * v4l2channel)
99{
100  const GList *item;
101
102  for (item = v4l2element->colors; item != NULL; item = item->next)
103    if (item->data == v4l2channel)
104      return TRUE;
105
106  return FALSE;
107}
108
109static const GList *
110gst_v4l2_color_balance_list_channels (GstColorBalance * balance)
111{
112  return GST_V4L2ELEMENT (balance)->colors;
113}
114
115static void
116gst_v4l2_color_balance_set_value (GstColorBalance * balance,
117    GstColorBalanceChannel * channel, gint value)
118{
119  GstV4l2Element *v4l2element = GST_V4L2ELEMENT (balance);
120  GstV4l2ColorBalanceChannel *v4l2channel =
121      GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
122
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,
126          v4l2channel));
127
128  gst_v4l2_set_attribute (v4l2element, v4l2channel->index, value);
129}
130
131static gint
132gst_v4l2_color_balance_get_value (GstColorBalance * balance,
133    GstColorBalanceChannel * channel)
134{
135  GstV4l2Element *v4l2element = GST_V4L2ELEMENT (balance);
136  GstV4l2ColorBalanceChannel *v4l2channel =
137      GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
138  gint value;
139
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,
143          v4l2channel), 0);
144
145  if (!gst_v4l2_get_attribute (v4l2element, v4l2channel->index, &value))
146    return 0;
147
148  return value;
149}
Note: See TracBrowser for help on using the repository browser.