tizen 2.3 release
[framework/multimedia/gst-plugins-base0.10.git] / sys / v4l / v4l_calls.h
1 /* GStreamer
2  *
3  * v4l_calls.h: header for generic V4L calls
4  *
5  * Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
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 __V4L_CALLS_H__
24 #define __V4L_CALLS_H__
25
26 #include "gstv4lelement.h"
27 #include "gst/gst-i18n-plugin.h"
28
29
30 G_BEGIN_DECLS
31
32
33 /* simple check whether the device is open */
34 #define GST_V4L_IS_OPEN(element) \
35   (GST_V4LELEMENT (element)->video_fd > 0)
36
37 /* check whether the device is 'active' */
38 #define GST_V4L_IS_ACTIVE(element) \
39   (GST_V4LELEMENT (element)->buffer != NULL)
40
41 #define GST_V4L_IS_OVERLAY(element) \
42   (GST_V4LELEMENT (element)->vcap.type & VID_TYPE_OVERLAY)
43
44 /* checks whether the current v4lelement has already been open()'ed or not */
45 #define GST_V4L_CHECK_OPEN(element)                             \
46   if (!GST_V4L_IS_OPEN (element))                               \
47   {                                                             \
48     GST_ELEMENT_ERROR (element, RESOURCE, TOO_LAZY,             \
49       (_("Device is not open.")), (NULL));                      \
50     return FALSE;                                               \
51   }
52
53 /* checks whether the current v4lelement is close()'ed or whether it is still open */
54 #define GST_V4L_CHECK_NOT_OPEN(element)                         \
55   if (GST_V4L_IS_OPEN (element))                                \
56   {                                                             \
57     GST_ELEMENT_ERROR (element, RESOURCE, TOO_LAZY,             \
58       (_("Device is open.")), (NULL));                          \
59     return FALSE;                                               \
60   }
61
62 /* checks whether the current v4lelement does video overlay */
63 #define GST_V4L_CHECK_OVERLAY(element)                          \
64   if (!(element->vcap.type & VID_TYPE_OVERLAY))                 \
65   {                                                             \
66     GST_ELEMENT_ERROR (element, RESOURCE, TOO_LAZY,             \
67       (NULL), ("Device cannot handle overlay"));                \
68     return FALSE;                                               \
69   }
70
71 /* checks whether we're in capture mode or not */
72 #define GST_V4L_CHECK_ACTIVE(element)                           \
73   if (!GST_V4L_IS_ACTIVE (element))                             \
74   {                                                             \
75     GST_ELEMENT_ERROR (element, RESOURCE, SETTINGS,             \
76       (NULL), ("Device is not in streaming mode"));             \
77     return FALSE;                                               \
78   }
79
80 /* checks whether we're out of capture mode or not */
81 #define GST_V4L_CHECK_NOT_ACTIVE(element)                       \
82   if (GST_V4L_IS_ACTIVE (element))                              \
83   {                                                             \
84     GST_ELEMENT_ERROR (element, RESOURCE, SETTINGS,             \
85       (NULL), ("Device is in streaming mode"));                 \
86     return FALSE;                                               \
87   }
88
89
90 typedef enum {
91   V4L_PICTURE_HUE = 0,
92   V4L_PICTURE_BRIGHTNESS,
93   V4L_PICTURE_CONTRAST,
94   V4L_PICTURE_SATURATION,
95 } GstV4lPictureType;
96
97 typedef enum {
98   V4L_AUDIO_VOLUME = 0,
99   V4L_AUDIO_MUTE,
100   V4L_AUDIO_MODE, /* stereo, mono, ... (see videodev.h) */
101 } GstV4lAudioType;
102
103
104 /* open/close the device */
105 gboolean gst_v4l_open           (GstV4lElement *v4lelement);
106 gboolean gst_v4l_close          (GstV4lElement *v4lelement);
107
108 /* norm control (norm = VIDEO_MODE_{PAL|NTSC|SECAM|AUTO}) */
109 gboolean gst_v4l_get_chan_norm  (GstV4lElement *v4lelement,
110                                  gint          *channel,
111                                  gint          *norm);
112 gboolean gst_v4l_set_chan_norm  (GstV4lElement *v4lelement,
113                                  gint           channel,
114                                  gint           norm);
115 GList   *gst_v4l_get_chan_names (GstV4lElement *v4lelement);
116
117 /* frequency control */
118 gboolean gst_v4l_get_signal     (GstV4lElement *v4lelement,
119                                  gint           tunernum,
120                                  guint         *signal);
121 gboolean gst_v4l_get_frequency  (GstV4lElement *v4lelement,
122                                  gint           tunernum,
123                                  gulong        *frequency);
124 gboolean gst_v4l_set_frequency  (GstV4lElement *v4lelement,
125                                  gint           tunernum,
126                                  gulong         frequency);
127
128 /* picture control */
129 gboolean gst_v4l_get_picture    (GstV4lElement *v4lelement,
130                                  GstV4lPictureType type,
131                                  gint          *value);
132 gboolean gst_v4l_set_picture    (GstV4lElement *v4lelement,
133                                  GstV4lPictureType type,
134                                  gint           value);
135
136 /* audio control */
137 gboolean gst_v4l_get_audio      (GstV4lElement *v4lelement,
138                                  gint           audionum,
139                                  GstV4lAudioType type,
140                                  gint          *value);
141 gboolean gst_v4l_set_audio      (GstV4lElement *v4lelement,
142                                  gint           audionum,
143                                  GstV4lAudioType type,
144                                  gint           value);
145
146 /* functions that v4lsrc needs */
147 gboolean gst_v4l_set_window_properties (GstV4lElement * v4lelement);
148 gboolean gst_v4l_get_capabilities (GstV4lElement * v4lelement);
149
150
151 G_END_DECLS
152
153
154 #endif /* __V4L_CALLS_H__ */