• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 2012 Olivier Crete <olivier.crete@collabora.com>
3  *
4  * gstv4l2deviceprovider.h: V4l2 device probing and monitoring
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 
23 #ifndef __GST_V4L2_DEVICE_PROVIDER_H__
24 #define __GST_V4L2_DEVICE_PROVIDER_H__
25 
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29 
30 #include <gst/gst.h>
31 
32 #ifdef HAVE_GUDEV
33 #include <gudev/gudev.h>
34 #endif
35 
36 G_BEGIN_DECLS
37 
38 typedef struct _GstV4l2DeviceProvider GstV4l2DeviceProvider;
39 typedef struct _GstV4l2DeviceProviderClass GstV4l2DeviceProviderClass;
40 
41 #define GST_TYPE_V4L2_DEVICE_PROVIDER                 (gst_v4l2_device_provider_get_type())
42 #define GST_IS_V4L2_DEVICE_PROVIDER(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_DEVICE_PROVIDER))
43 #define GST_IS_V4L2_DEVICE_PROVIDER_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_DEVICE_PROVIDER))
44 #define GST_V4L2_DEVICE_PROVIDER_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_V4L2_DEVICE_PROVIDER, GstV4l2DeviceProviderClass))
45 #define GST_V4L2_DEVICE_PROVIDER(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2_DEVICE_PROVIDER, GstV4l2DeviceProvider))
46 #define GST_V4L2_DEVICE_PROVIDER_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEVICE_PROVIDER, GstV4l2DeviceProviderClass))
47 #define GST_V4L2_DEVICE_PROVIDER_CAST(obj)            ((GstV4l2DeviceProvider *)(obj))
48 
49 struct _GstV4l2DeviceProvider {
50   GstDeviceProvider         parent;
51 
52 #ifdef HAVE_GUDEV
53   GMainContext *context;
54   GMainLoop *loop;
55   GThread *thread;
56   gboolean started;
57   GCond started_cond;
58 #endif
59 };
60 
61 typedef enum {
62   GST_V4L2_DEVICE_TYPE_INVALID = 0,
63   GST_V4L2_DEVICE_TYPE_SOURCE,
64   GST_V4L2_DEVICE_TYPE_SINK
65 } GstV4l2DeviceType;
66 
67 struct _GstV4l2DeviceProviderClass {
68   GstDeviceProviderClass    parent_class;
69 };
70 
71 GType        gst_v4l2_device_provider_get_type (void);
72 
73 
74 typedef struct _GstV4l2Device GstV4l2Device;
75 typedef struct _GstV4l2DeviceClass GstV4l2DeviceClass;
76 
77 #define GST_TYPE_V4L2_DEVICE                 (gst_v4l2_device_get_type())
78 #define GST_IS_V4L2_DEVICE(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_DEVICE))
79 #define GST_IS_V4L2_DEVICE_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_DEVICE))
80 #define GST_V4L2_DEVICE_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_V4L2_DEVICE, GstV4l2DeviceClass))
81 #define GST_V4L2_DEVICE(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2_DEVICE, GstV4l2Device))
82 #define GST_V4L2_DEVICE_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEVICE, GstV4l2DeviceClass))
83 #define GST_V4L2_DEVICE_CAST(obj)            ((GstV4l2Device *)(obj))
84 
85 struct _GstV4l2Device {
86   GstDevice         parent;
87 
88   gchar            *device_path;
89   gchar            *syspath;
90   const gchar      *element;
91 };
92 
93 struct _GstV4l2DeviceClass {
94   GstDeviceClass    parent_class;
95 };
96 
97 GType        gst_v4l2_device_get_type (void);
98 
99 G_END_DECLS
100 
101 #endif /* __GST_V4L2_DEVICE_PROVIDER_H__ */
102