Merge branch 'master' into 0.11
[platform/upstream/gst-plugins-good.git] / sys / v4l2 / gstv4l2tuner.h
1 /* GStreamer
2  *
3  * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
4  *               2006 Edgard Lima <edgard.lima@indt.org.br>
5  *
6  * gstv4l2tuner.h: tuner interface implementation for V4L2
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #ifndef __GST_V4L2_TUNER_H__
25 #define __GST_V4L2_TUNER_H__
26
27 #include <gst/gst.h>
28 #include <gst/interfaces/tuner.h>
29
30 #include "gstv4l2object.h"
31
32 G_BEGIN_DECLS
33
34 #define GST_TYPE_V4L2_TUNER_CHANNEL \
35   (gst_v4l2_tuner_channel_get_type ())
36 #define GST_V4L2_TUNER_CHANNEL(obj) \
37   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2_TUNER_CHANNEL, \
38           GstV4l2TunerChannel))
39 #define GST_V4L2_TUNER_CHANNEL_CLASS(klass) \
40   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_V4L2_TUNER_CHANNEL, \
41        GstV4l2TunerChannelClass))
42 #define GST_IS_V4L2_TUNER_CHANNEL(obj) \
43   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_TUNER_CHANNEL))
44 #define GST_IS_V4L2_TUNER_CHANNEL_CLASS(klass) \
45   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_TUNER_CHANNEL))
46
47 typedef struct _GstV4l2TunerChannel {
48   GstTunerChannel parent;
49
50   guint32         index;
51   guint32         tuner;
52   guint32         audio;
53 } GstV4l2TunerChannel;
54
55 typedef struct _GstV4l2TunerChannelClass {
56   GstTunerChannelClass parent;
57 } GstV4l2TunerChannelClass;
58
59 #define GST_TYPE_V4L2_TUNER_NORM \
60   (gst_v4l2_tuner_norm_get_type ())
61 #define GST_V4L2_TUNER_NORM(obj) \
62   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2_TUNER_NORM, \
63           GstV4l2TunerNorm))
64 #define GST_V4L2_TUNER_NORM_CLASS(klass) \
65   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_V4L2_TUNER_NORM, \
66        GstV4l2TunerNormClass))
67 #define GST_IS_V4L2_TUNER_NORM(obj) \
68   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_TUNER_NORM))
69 #define GST_IS_V4L2_TUNER_NORM_CLASS(klass) \
70   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_TUNER_NORM))
71
72 typedef struct _GstV4l2TunerNorm {
73   GstTunerNorm parent;
74
75   v4l2_std_id  index;
76 } GstV4l2TunerNorm;
77
78 typedef struct _GstV4l2TunerNormClass {
79   GstTunerNormClass parent;
80 } GstV4l2TunerNormClass;
81
82 GType gst_v4l2_tuner_channel_get_type (void);
83 GType gst_v4l2_tuner_norm_get_type (void);
84
85 /* channels */
86 const GList*      gst_v4l2_tuner_list_channels            (GstV4l2Object * v4l2object);
87 GstTunerChannel*  gst_v4l2_tuner_get_channel              (GstV4l2Object * v4l2object);
88 gboolean          gst_v4l2_tuner_set_channel              (GstV4l2Object * v4l2object,
89                                                            GstTunerChannel * channel);
90 /* norms */
91 const GList*      gst_v4l2_tuner_list_norms               (GstV4l2Object * v4l2object);
92 void              gst_v4l2_tuner_set_norm_and_notify      (GstV4l2Object * v4l2object,
93                                                            GstTunerNorm * norm);
94 GstTunerNorm*     gst_v4l2_tuner_get_norm                 (GstV4l2Object * v4l2object);
95 gboolean          gst_v4l2_tuner_set_norm                 (GstV4l2Object * v4l2object,
96                                                            GstTunerNorm * norm);
97 GstTunerNorm*     gst_v4l2_tuner_get_norm_by_std_id       (GstV4l2Object * v4l2object,
98                                                v4l2_std_id norm);
99 v4l2_std_id       gst_v4l2_tuner_get_std_id_by_norm       (GstV4l2Object * v4l2object,
100                                                GstTunerNorm * norm);
101
102 /* frequency */
103 void              gst_v4l2_tuner_set_frequency_and_notify (GstV4l2Object * v4l2object,
104                                                            GstTunerChannel * channel, 
105                                                            gulong frequency);
106 gint              gst_v4l2_tuner_signal_strength          (GstV4l2Object * v4l2object,
107                                                            GstTunerChannel * channel);
108 gulong            gst_v4l2_tuner_get_frequency            (GstV4l2Object * v4l2object,
109                                                            GstTunerChannel * channel);
110 gboolean          gst_v4l2_tuner_set_frequency            (GstV4l2Object * v4l2object,
111                                                            GstTunerChannel * channel, 
112                                                            gulong frequency);
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 (GstTuner * mixer,                        \
125                                              GstTunerChannel * channel)               \
126 {                                                                                     \
127   Type *this = (Type*) mixer;                                                         \
128   gst_v4l2_tuner_set_channel (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 static void                                                                           \
182 interface_as_function ## _tuner_interface_init (GstTunerInterface * iface)                \
183 {                                                                                     \
184   /* default virtual functions */                                                     \
185   iface->list_channels = interface_as_function ## _tuner_list_channels;               \
186   iface->set_channel = interface_as_function ## _tuner_set_channel;                   \
187   iface->get_channel = interface_as_function ## _tuner_get_channel;                   \
188                                                                                       \
189   iface->list_norms = interface_as_function ## _tuner_list_norms;                     \
190   iface->set_norm = interface_as_function ## _tuner_set_norm_and_notify;              \
191   iface->get_norm = interface_as_function ## _tuner_get_norm;                         \
192                                                                                       \
193   iface->set_frequency = interface_as_function ## _tuner_set_frequency_and_notify;    \
194   iface->get_frequency = interface_as_function ## _tuner_get_frequency;               \
195   iface->signal_strength = interface_as_function ## _tuner_signal_strength;           \
196 }                                                                                     \
197
198 #endif /* __GST_V4L2_TUNER_H__ */