gst-indent
[platform/upstream/gst-plugins-good.git] / sys / v4l2 / v4l2_calls.h
1 /* G-Streamer generic V4L2 element - generic V4L2 calls handling
2  * Copyright (C) 2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __V4L2_CALLS_H__
21 #define __V4L2_CALLS_H__
22
23 #include "gstv4l2element.h"
24 #include "gst/gst-i18n-plugin.h"
25
26
27 /* simple check whether the device is open */
28 #define GST_V4L2_IS_OPEN(element) \
29   (element->video_fd > 0)
30
31 /* check whether the device is 'active' */
32 #define GST_V4L2_IS_ACTIVE(element) \
33   (element->buffer != NULL)
34
35 #define GST_V4L2_IS_OVERLAY(element) \
36   (element->vcap.capabilities & V4L2_CAP_VIDEO_OVERLAY)
37
38 /* checks whether the current v4lelement has already been open()'ed or not */
39 #define GST_V4L2_CHECK_OPEN(element)                            \
40   if (!GST_V4L2_IS_OPEN(element))                               \
41   {                                                             \
42     GST_ELEMENT_ERROR (element, RESOURCE, TOO_LAZY,             \
43       (_("Device is not open.")), (NULL));                      \
44     return FALSE;                                               \
45   }
46
47 /* checks whether the current v4lelement is close()'ed or whether it is still open */
48 #define GST_V4L2_CHECK_NOT_OPEN(element)                        \
49   if (GST_V4L2_IS_OPEN(element))                                \
50   {                                                             \
51     GST_ELEMENT_ERROR (element, RESOURCE, TOO_LAZY,             \
52       (_("Device is open.")), (NULL));                          \
53     return FALSE;                                               \
54   }
55
56 /* checks whether the current v4lelement does video overlay */
57 #define GST_V4L2_CHECK_OVERLAY(element)                         \
58   if (!GST_V4L2_IS_OVERLAY(element))                            \
59   {                                                             \
60     GST_ELEMENT_ERROR (element, RESOURCE, TOO_LAZY,             \
61       (NULL), ("Device cannot handle overlay"));                \
62     return FALSE;                                               \
63   }
64
65 /* checks whether we're in capture mode or not */
66 #define GST_V4L2_CHECK_ACTIVE(element)                          \
67   if (!GST_V4L2_IS_ACTIVE(element))                             \
68   {                                                             \
69     GST_ELEMENT_ERROR (element, RESOURCE, SETTINGS,             \
70       (NULL), ("Device is not in streaming mode"));             \
71     return FALSE;                                               \
72   }
73
74 /* checks whether we're out of capture mode or not */
75 #define GST_V4L2_CHECK_NOT_ACTIVE(element)                      \
76   if (GST_V4L2_IS_ACTIVE(element))                              \
77   {                                                             \
78     GST_ELEMENT_ERROR (element, RESOURCE, SETTINGS,             \
79       (NULL), ("Device is in streaming mode"));                 \
80     return FALSE;                                               \
81   }
82
83
84 /* open/close the device */
85 gboolean gst_v4l2_open (GstV4l2Element * v4l2element);
86 gboolean gst_v4l2_close (GstV4l2Element * v4l2element);
87
88 /* norm/input/output */
89 gboolean gst_v4l2_get_norm (GstV4l2Element * v4l2element, v4l2_std_id * norm);
90 gboolean gst_v4l2_set_norm (GstV4l2Element * v4l2element, v4l2_std_id norm);
91 gboolean gst_v4l2_get_input (GstV4l2Element * v4l2element, gint * input);
92 gboolean gst_v4l2_set_input (GstV4l2Element * v4l2element, gint input);
93 gboolean gst_v4l2_get_output (GstV4l2Element * v4l2element, gint * output);
94 gboolean gst_v4l2_set_output (GstV4l2Element * v4l2element, gint output);
95
96 /* frequency control */
97 gboolean gst_v4l2_get_frequency (GstV4l2Element * v4l2element,
98     gint tunernum, gulong * frequency);
99 gboolean gst_v4l2_set_frequency (GstV4l2Element * v4l2element,
100     gint tunernum, gulong frequency);
101 gboolean gst_v4l2_signal_strength (GstV4l2Element * v4l2element,
102     gint tunernum, gulong * signal);
103
104 /* attribute control */
105 gboolean gst_v4l2_get_attribute (GstV4l2Element * v4l2element,
106     int attribute, int *value);
107 gboolean gst_v4l2_set_attribute (GstV4l2Element * v4l2element,
108     int attribute, const int value);
109
110 /* overlay */
111 gboolean gst_v4l2_set_display (GstV4l2Element * v4l2element);
112 gboolean gst_v4l2_set_window (GstElement * element,
113     gint x, gint y, gint w, gint h, struct v4l2_clip *clips, gint num_clips);
114 gboolean gst_v4l2_enable_overlay (GstV4l2Element * v4l2element,
115     gboolean enable);
116
117 #endif /* __V4L2_CALLS_H__ */