e46b24402c2f8f2fe5ebdab92e75e4dc4ce0b705
[platform/upstream/gst-plugins-good.git] / sys / v4l2 / gstv4l2element.h
1 /* G-Streamer generic V4L2 element
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 __GST_V4L2ELEMENT_H__
21 #define __GST_V4L2ELEMENT_H__
22
23 #include <gst/gst.h>
24 #include <gst/xwindowlistener/xwindowlistener.h>
25
26 /* Because of some really cool feature in video4linux1, also known as
27  * 'not including sys/types.h and sys/time.h', we had to include it
28  * ourselves. In all their intelligence, these people decided to fix
29  * this in the next version (video4linux2) in such a cool way that it
30  * breaks all compilations of old stuff...
31  * The real problem is actually that linux/time.h doesn't use proper
32  * macro checks before defining types like struct timeval. The proper
33  * fix here is to either fuck the kernel header (which is what we do
34  * by defining _LINUX_TIME_H, an innocent little hack) or by fixing it
35  * upstream, which I'll consider doing later on. If you get compiler
36  * errors here, check your linux/time.h && sys/time.h header setup.
37  */
38 #include <sys/types.h>
39 #include <linux/types.h>
40 #define _LINUX_TIME_H
41 #include <linux/videodev2.h>
42
43
44 #define GST_TYPE_V4L2ELEMENT \
45                 (gst_v4l2element_get_type())
46 #define GST_V4L2ELEMENT(obj) \
47                 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_V4L2ELEMENT, GstV4l2Element))
48 #define GST_V4L2ELEMENT_CLASS(klass) \
49                 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_V4L2ELEMENT, GstV4l2ElementClass))
50 #define GST_IS_V4L2ELEMENT(obj) \
51                 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_V4L2ELEMENT))
52 #define GST_IS_V4L2ELEMENT_CLASS(obj) \
53                 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_V4L2ELEMENT))
54 #define GST_V4L2ELEMENT_GET_CLASS(obj) \
55                 (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_V4L2ELEMENT, GstV4l2ElementClass))
56
57
58 typedef struct _GstV4l2Element          GstV4l2Element;
59 typedef struct _GstV4l2ElementClass     GstV4l2ElementClass;
60
61 struct _GstV4l2Element {
62         GstElement element;
63
64         /* the video device */
65         char *device;
66
67         /* the video-device's file descriptor */
68         gint video_fd;
69
70         /* the video buffer (mmap()'ed) */
71         guint8 **buffer;
72
73         /* the video-device's capabilities */
74         struct v4l2_capability vcap;
75
76         /* the toys available to us */
77         GList *channels;
78         GList *norms;
79         GList *colors;
80
81         /* X-overlay */
82         GstXWindowListener *overlay;
83         XID xwindow_id;
84
85         /* properties */
86         gchar *norm;
87         gchar *channel;
88         gulong frequency;
89
90         /* caching values */
91         gchar *display;
92 };
93
94 struct _GstV4l2ElementClass {
95         GstElementClass parent_class;
96
97         /* probed devices */
98         GList *devices;
99
100         /* signals */
101         void     (*open)            (GstElement  *element,
102                                      const gchar *device);
103         void     (*close)           (GstElement  *element,
104                                      const gchar *device);
105 };
106
107
108 GType gst_v4l2element_get_type (void);
109
110 #endif /* __GST_V4L2ELEMENT_H__ */