Changes proposed by Wingo in bug #338818.
[platform/upstream/gst-plugins-good.git] / sys / v4l2 / gstv4l2tuner.h
1 /* G-Streamer generic V4L2 element - Tuner interface implementation
2  * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  * Copyright (C) 2006 Edgard Lima <edgard.lima@indt.org.br>
4  *
5  * gstv4l2tuner.h: tuner interface implementation for V4L2
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 #ifndef __GST_V4L2_TUNER_H__
24 #define __GST_V4L2_TUNER_H__
25
26 #include <gst/gst.h>
27 #include <gst/interfaces/tuner.h>
28
29 #include "gstv4l2object.h"
30
31 G_BEGIN_DECLS
32
33 #define GST_TYPE_V4L2_TUNER_CHANNEL \
34   (gst_v4l2_tuner_channel_get_type ())
35 #define GST_V4L2_TUNER_CHANNEL(obj) \
36   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2_TUNER_CHANNEL, \
37           GstV4l2TunerChannel))
38 #define GST_V4L2_TUNER_CHANNEL_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_V4L2_TUNER_CHANNEL, \
40        GstV4l2TunerChannelClass))
41 #define GST_IS_V4L2_TUNER_CHANNEL(obj) \
42   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_TUNER_CHANNEL))
43 #define GST_IS_V4L2_TUNER_CHANNEL_CLASS(klass) \
44   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_TUNER_CHANNEL))
45
46 typedef struct _GstV4l2TunerChannel {
47   GstTunerChannel parent;
48
49   guint32         index;
50   guint32         tuner;
51   guint32         audio;
52 } GstV4l2TunerChannel;
53
54 typedef struct _GstV4l2TunerChannelClass {
55   GstTunerChannelClass parent;
56 } GstV4l2TunerChannelClass;
57
58 #define GST_TYPE_V4L2_TUNER_NORM \
59   (gst_v4l2_tuner_norm_get_type ())
60 #define GST_V4L2_TUNER_NORM(obj) \
61   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2_TUNER_NORM, \
62           GstV4l2TunerNorm))
63 #define GST_V4L2_TUNER_NORM_CLASS(klass) \
64   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_V4L2_TUNER_NORM, \
65        GstV4l2TunerNormClass))
66 #define GST_IS_V4L2_TUNER_NORM(obj) \
67   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_TUNER_NORM))
68 #define GST_IS_V4L2_TUNER_NORM_CLASS(klass) \
69   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_TUNER_NORM))
70
71 typedef struct _GstV4l2TunerNorm {
72   GstTunerNorm parent;
73
74   v4l2_std_id  index;
75 } GstV4l2TunerNorm;
76
77 typedef struct _GstV4l2TunerNormClass {
78   GstTunerNormClass parent;
79 } GstV4l2TunerNormClass;
80
81 extern gboolean
82 gst_v4l2_tuner_set_channel (GstV4l2Object * v4l2object, GstTunerChannel * channel);
83 extern gboolean
84 gst_v4l2_tuner_set_norm (GstV4l2Object * v4l2object, GstTunerNorm * norm);
85 extern gboolean
86 gst_v4l2_tuner_set_frequency (GstV4l2Object * v4l2object,
87                               GstTunerChannel * channel, gulong frequency);
88
89 GType gst_v4l2_tuner_channel_get_type (void);
90 GType gst_v4l2_tuner_norm_get_type (void);
91
92 extern const GList *
93 gst_v4l2_tuner_list_channels (GstV4l2Object * v4l2object);
94 extern void
95 gst_v4l2_tuner_set_channel_and_notify (GstV4l2Object * v4l2object, GstTunerChannel * channel);
96 extern GstTunerChannel *
97 gst_v4l2_tuner_get_channel (GstV4l2Object * v4l2object);
98
99 extern const GList *
100 gst_v4l2_tuner_list_norms (GstV4l2Object * v4l2object);
101 extern void
102 gst_v4l2_tuner_set_norm_and_notify (GstV4l2Object * v4l2object, GstTunerNorm * norm);
103 extern GstTunerNorm *
104 gst_v4l2_tuner_get_norm (GstV4l2Object * v4l2object);
105
106 extern void
107 gst_v4l2_tuner_set_frequency_and_notify (GstV4l2Object * v4l2object,
108                                          GstTunerChannel * channel, gulong frequency);
109 extern gulong
110 gst_v4l2_tuner_get_frequency (GstV4l2Object * v4l2object, GstTunerChannel * channel);
111 extern gint
112 gst_v4l2_tuner_signal_strength (GstV4l2Object * v4l2object, GstTunerChannel * channel);
113
114 #define GST_IMPLEMENT_V4L2_TUNER_METHODS(Type, interface_as_function)                 \
115                                                                                       \
116 static const GList *                                                                  \
117 interface_as_function ## _tuner_list_channels (GstTuner * mixer)                      \
118 {                                                                                     \
119   Type *this = (Type*) mixer;                                                         \
120   return gst_v4l2_tuner_list_channels (this->v4l2object);                             \
121 }                                                                                     \
122                                                                                       \
123 static void                                                                           \
124 interface_as_function ## _tuner_set_channel_and_notify (GstTuner * mixer,             \
125                                                         GstTunerChannel * channel)    \
126 {                                                                                     \
127   Type *this = (Type*) mixer;                                                         \
128   gst_v4l2_tuner_set_channel_and_notify (this->v4l2object, channel);                  \
129 }                                                                                     \
130 static GstTunerChannel *                                                              \
131 interface_as_function ## _tuner_get_channel (GstTuner * mixer)                        \
132 {                                                                                     \
133   Type *this = (Type*) mixer;                                                         \
134   return gst_v4l2_tuner_get_channel (this->v4l2object);                               \
135 }                                                                                     \
136 static const GList *                                                                  \
137 interface_as_function ## _tuner_list_norms (GstTuner * mixer)                         \
138 {                                                                                     \
139   Type *this = (Type*) mixer;                                                         \
140   return gst_v4l2_tuner_list_norms (this->v4l2object);                                \
141 }                                                                                     \
142 static void                                                                           \
143 interface_as_function ## _tuner_set_norm_and_notify (GstTuner * mixer,                \
144                                                      GstTunerNorm * norm)             \
145 {                                                                                     \
146   Type *this = (Type*) mixer;                                                         \
147   gst_v4l2_tuner_set_norm_and_notify (this->v4l2object, norm);                        \
148 }                                                                                     \
149 static GstTunerNorm *                                                                 \
150 interface_as_function ## _tuner_get_norm (GstTuner * mixer)                           \
151 {                                                                                     \
152   Type *this = (Type*) mixer;                                                         \
153   return gst_v4l2_tuner_get_norm (this->v4l2object);                                  \
154 }                                                                                     \
155                                                                                       \
156 static void                                                                           \
157 interface_as_function ## _tuner_set_frequency_and_notify (GstTuner * mixer,           \
158                                                           GstTunerChannel * channel,  \
159                                                           gulong frequency)           \
160 {                                                                                     \
161   Type *this = (Type*) mixer;                                                         \
162   gst_v4l2_tuner_set_frequency_and_notify (this->v4l2object, channel, frequency);     \
163 }                                                                                     \
164                                                                                       \
165 static gulong                                                                         \
166 interface_as_function ## _tuner_get_frequency (GstTuner * mixer,                      \
167                                                GstTunerChannel * channel)             \
168 {                                                                                     \
169   Type *this = (Type*) mixer;                                                         \
170   return gst_v4l2_tuner_get_frequency (this->v4l2object, channel);                    \
171 }                                                                                     \
172                                                                                       \
173 static gint                                                                           \
174 interface_as_function ## _tuner_signal_strength (GstTuner * mixer,                    \
175                                                  GstTunerChannel * channel)           \
176 {                                                                                     \
177   Type *this = (Type*) mixer;                                                         \
178   return gst_v4l2_tuner_signal_strength (this->v4l2object, channel);                  \
179 }                                                                                     \
180                                                                                       \
181 void                                                                                  \
182 interface_as_function ## _tuner_interface_init (GstTunerClass * klass)                \
183 {                                                                                     \
184   /* default virtual functions */                                                     \
185   klass->list_channels = interface_as_function ## _tuner_list_channels;               \
186   klass->set_channel = interface_as_function ## _tuner_set_channel_and_notify;        \
187   klass->get_channel = interface_as_function ## _tuner_get_channel;                   \
188                                                                                       \
189   klass->list_norms = interface_as_function ## _tuner_list_norms;                     \
190   klass->set_norm = interface_as_function ## _tuner_set_norm_and_notify;              \
191   klass->get_norm = interface_as_function ## _tuner_get_norm;                         \
192                                                                                       \
193   klass->set_frequency = interface_as_function ## _tuner_set_frequency_and_notify;    \
194   klass->get_frequency = interface_as_function ## _tuner_get_frequency;               \
195   klass->signal_strength = interface_as_function ## _tuner_signal_strength;           \
196 }                                                                                     \
197
198 #endif /* __GST_V4L2_TUNER_H__ */