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, |
---|
90 | v4l2_std_id *norm); |
---|
91 | gboolean gst_v4l2_set_norm (GstV4l2Element *v4l2element, |
---|
92 | v4l2_std_id norm); |
---|
93 | gboolean gst_v4l2_get_input (GstV4l2Element *v4l2element, |
---|
94 | gint *input); |
---|
95 | gboolean gst_v4l2_set_input (GstV4l2Element *v4l2element, |
---|
96 | gint input); |
---|
97 | gboolean gst_v4l2_get_output (GstV4l2Element *v4l2element, |
---|
98 | gint *output); |
---|
99 | gboolean gst_v4l2_set_output (GstV4l2Element *v4l2element, |
---|
100 | gint output); |
---|
101 | |
---|
102 | /* frequency control */ |
---|
103 | gboolean gst_v4l2_get_frequency (GstV4l2Element *v4l2element, |
---|
104 | gint tunernum, |
---|
105 | gulong *frequency); |
---|
106 | gboolean gst_v4l2_set_frequency (GstV4l2Element *v4l2element, |
---|
107 | gint tunernum, |
---|
108 | gulong frequency); |
---|
109 | gboolean gst_v4l2_signal_strength (GstV4l2Element *v4l2element, |
---|
110 | gint tunernum, |
---|
111 | gulong *signal); |
---|
112 | |
---|
113 | /* attribute control */ |
---|
114 | gboolean gst_v4l2_get_attribute (GstV4l2Element *v4l2element, |
---|
115 | int attribute, |
---|
116 | int *value); |
---|
117 | gboolean gst_v4l2_set_attribute (GstV4l2Element *v4l2element, |
---|
118 | int attribute, |
---|
119 | const int value); |
---|
120 | |
---|
121 | #endif /* __V4L2_CALLS_H__ */ |
---|