gst-indent
[platform/upstream/gst-plugins-good.git] / sys / v4l2 / gstv4l2src.h
1 /* G-Streamer Video4linux2 video-capture plugin
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_V4L2SRC_H__
21 #define __GST_V4L2SRC_H__
22
23 #include <gstv4l2element.h>
24
25 GST_DEBUG_CATEGORY_EXTERN (v4l2src_debug);
26
27 #define GST_V4L2_MAX_BUFFERS 16
28 #define GST_V4L2_MIN_BUFFERS 2
29
30 #define GST_TYPE_V4L2SRC \
31                 (gst_v4l2src_get_type())
32 #define GST_V4L2SRC(obj) \
33                 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_V4L2SRC,GstV4l2Src))
34 #define GST_V4L2SRC_CLASS(klass) \
35                 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_V4L2SRC,GstV4l2SrcClass))
36 #define GST_IS_V4L2SRC(obj) \
37                 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_V4L2SRC))
38 #define GST_IS_V4L2SRC_CLASS(obj) \
39                 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_V4L2SRC))
40
41 typedef struct _GstV4l2BufferPool GstV4l2BufferPool;
42 typedef struct _GstV4l2Buffer GstV4l2Buffer;
43 typedef struct _GstV4l2Src GstV4l2Src;
44 typedef struct _GstV4l2SrcClass GstV4l2SrcClass;
45
46 /* global info */
47 struct _GstV4l2BufferPool
48 {
49   GstAtomicInt refcount;        /* number of users: 1 for every buffer, 1 for element */
50   gint video_fd;
51   guint buffer_count;
52   GstV4l2Buffer *buffers;
53 };
54
55 struct _GstV4l2Buffer
56 {
57   struct v4l2_buffer buffer;
58   guint8 *start;
59   guint length;
60   GstAtomicInt refcount;        /* add 1 if in use by element, add 1 if in use by GstBuffer */
61   GstV4l2BufferPool *pool;
62 };
63
64 struct _GstV4l2Src
65 {
66   GstV4l2Element v4l2element;
67
68   /* pads */
69   GstPad *srcpad;
70
71   /* internal lists */
72   GSList *formats;              /* list of available capture formats */
73
74   /* buffers */
75   GstV4l2BufferPool *pool;
76
77   struct v4l2_requestbuffers breq;
78   struct v4l2_format format;
79
80   /* True if we want to stop */
81   gboolean quit;
82
83   /* A/V sync... frame counter and internal cache */
84   gulong handled;
85   gint need_writes;
86   GstBuffer *cached_buffer;
87   gulong last_seq;
88
89   /* clock */
90   GstClock *clock;
91
92   /* time to substract from clock time to get back to timestamp */
93   GstClockTime substract_time;
94
95   /* how are we going to push buffers? */
96   gboolean use_fixed_fps;
97 };
98
99 struct _GstV4l2SrcClass
100 {
101   GstV4l2ElementClass parent_class;
102
103   void (*frame_capture) (GObject * object);
104   void (*frame_drop) (GObject * object);
105   void (*frame_insert) (GObject * object);
106   void (*frame_lost) (GObject * object, gint num_lost);
107 };
108
109
110 GType gst_v4l2src_get_type (void);
111
112 #endif /* __GST_V4L2SRC_H__ */