4e3050e44dbb32597f773c2875dc3a1dc512f37f
[platform/upstream/gst-plugins-good.git] / sys / v4l2 / gstv4l2devicemonitor.h
1 /* GStreamer
2  * Copyright (C) 2012 Olivier Crete <olivier.crete@collabora.com>
3  *
4  * gstv4l2devicemonitor.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_MONITOR_H__
24 #define __GST_V4L2_DEVICE_MONITOR_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 _GstV4l2DeviceMonitor GstV4l2DeviceMonitor;
39 typedef struct _GstV4l2DeviceMonitorPrivate GstV4l2DeviceMonitorPrivate;
40 typedef struct _GstV4l2DeviceMonitorClass GstV4l2DeviceMonitorClass;
41
42 #define GST_TYPE_V4L2_DEVICE_MONITOR                 (gst_v4l2_device_monitor_get_type())
43 #define GST_IS_V4L2_DEVICE_MONITOR(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_DEVICE_MONITOR))
44 #define GST_IS_V4L2_DEVICE_MONITOR_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_DEVICE_MONITOR))
45 #define GST_V4L2_DEVICE_MONITOR_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_V4L2_DEVICE_MONITOR, GstV4l2DeviceMonitorClass))
46 #define GST_V4L2_DEVICE_MONITOR(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2_DEVICE_MONITOR, GstV4l2DeviceMonitor))
47 #define GST_V4L2_DEVICE_MONITOR_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEVICE_MONITOR, GstV4l2DeviceMonitorClass))
48 #define GST_V4L2_DEVICE_MONITOR_CAST(obj)            ((GstV4l2DeviceMonitor *)(obj))
49
50 struct _GstV4l2DeviceMonitor {
51   GstDeviceMonitor         parent;
52
53 #ifdef HAVE_GUDEV
54   GMainContext *context;
55   GMainLoop *loop;
56   GThread *thread;
57   gboolean started;
58   GCond started_cond;
59 #endif
60 };
61
62 typedef enum {
63   GST_V4L2_DEVICE_TYPE_INVALID = 0,
64   GST_V4L2_DEVICE_TYPE_SOURCE,
65   GST_V4L2_DEVICE_TYPE_SINK
66 } GstV4l2DeviceType;
67
68 struct _GstV4l2DeviceMonitorClass {
69   GstDeviceMonitorClass    parent_class;
70 };
71
72 GType        gst_v4l2_device_monitor_get_type (void);
73
74
75 typedef struct _GstV4l2Device GstV4l2Device;
76 typedef struct _GstV4l2DevicePrivate GstV4l2DevicePrivate;
77 typedef struct _GstV4l2DeviceClass GstV4l2DeviceClass;
78
79 #define GST_TYPE_V4L2_DEVICE                 (gst_v4l2_device_get_type())
80 #define GST_IS_V4L2_DEVICE(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_DEVICE))
81 #define GST_IS_V4L2_DEVICE_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_DEVICE))
82 #define GST_V4L2_DEVICE_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_V4L2_DEVICE, GstV4l2DeviceClass))
83 #define GST_V4L2_DEVICE(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2_DEVICE, GstV4l2Device))
84 #define GST_V4L2_DEVICE_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEVICE, GstV4l2DeviceClass))
85 #define GST_V4L2_DEVICE_CAST(obj)            ((GstV4l2Device *)(obj))
86
87 struct _GstV4l2Device {
88   GstDevice         parent;
89
90   gchar            *device_path;
91   gchar            *syspath;
92   const gchar      *element;
93 };
94
95 struct _GstV4l2DeviceClass {
96   GstDeviceClass    parent_class;
97 };
98
99 GType        gst_v4l2_device_get_type (void);
100
101 #endif /* __GST_V4L2_DEVICE_MONITOR_H__ */