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 | GstAtomicInt refcount; /* number of users: 1 for every buffer, 1 for element */ |
---|
49 | gint video_fd; |
---|
50 | guint buffer_count; |
---|
51 | GstV4l2Buffer * buffers; |
---|
52 | }; |
---|
53 | |
---|
54 | struct _GstV4l2Buffer { |
---|
55 | struct v4l2_buffer buffer; |
---|
56 | guint8 * start; |
---|
57 | guint length; |
---|
58 | GstAtomicInt refcount; /* add 1 if in use by element, add 1 if in use by GstBuffer */ |
---|
59 | GstV4l2BufferPool * pool; |
---|
60 | }; |
---|
61 | |
---|
62 | struct _GstV4l2Src { |
---|
63 | GstV4l2Element v4l2element; |
---|
64 | |
---|
65 | /* pads */ |
---|
66 | GstPad *srcpad; |
---|
67 | |
---|
68 | /* internal lists */ |
---|
69 | GSList *formats; /* list of available capture formats */ |
---|
70 | |
---|
71 | /* buffers */ |
---|
72 | GstV4l2BufferPool *pool; |
---|
73 | |
---|
74 | struct v4l2_requestbuffers breq; |
---|
75 | struct v4l2_format format; |
---|
76 | |
---|
77 | /* True if we want to stop */ |
---|
78 | gboolean quit, is_capturing; |
---|
79 | |
---|
80 | /* A/V sync... frame counter and internal cache */ |
---|
81 | gulong handled; |
---|
82 | gint need_writes; |
---|
83 | GstBuffer *cached_buffer; |
---|
84 | gulong last_seq; |
---|
85 | |
---|
86 | /* clock */ |
---|
87 | GstClock *clock; |
---|
88 | |
---|
89 | /* time to substract from clock time to get back to timestamp */ |
---|
90 | GstClockTime substract_time; |
---|
91 | |
---|
92 | /* how are we going to push buffers? */ |
---|
93 | gboolean use_fixed_fps; |
---|
94 | }; |
---|
95 | |
---|
96 | struct _GstV4l2SrcClass { |
---|
97 | GstV4l2ElementClass parent_class; |
---|
98 | |
---|
99 | void (*frame_capture) (GObject *object); |
---|
100 | void (*frame_drop) (GObject *object); |
---|
101 | void (*frame_insert) (GObject *object); |
---|
102 | void (*frame_lost) (GObject *object, |
---|
103 | gint num_lost); |
---|
104 | }; |
---|
105 | |
---|
106 | |
---|
107 | GType gst_v4l2src_get_type(void); |
---|
108 | |
---|
109 | #endif /* __GST_V4L2SRC_H__ */ |
---|