2 * Copyright (C) 2012 Olivier Crete <olivier.crete@collabora.com>
4 * gstdeviceprovider.h: Device probing and monitoring
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.
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.
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.
22 #ifndef __GST_DEVICE_PROVIDER_H__
23 #define __GST_DEVICE_PROVIDER_H__
25 #include <gst/gstelement.h>
28 * GST_DEVICE_PROVIDER_REGISTER_DEFINE_CUSTOM:
29 * @d_p: The device provider name in lower case, with words separated by '_'.
30 * Used to generate `gst_device_provider_register_*(GstPlugin* plugin)`.
31 * @register_func: pointer to a method with the format: `gboolean register_func (GstPlugin* plugin);`
33 * A convenience macro to define the entry point of a
34 * device provider `gst_device_provider_register_*(GstPlugin* plugin)` which uses
35 * register_func as the main registration method for the device provider.
36 * As an example, you may define the device provider named "device-provider"
37 * with the namespace `my` as following using `device_provider_register_custom`:
41 * gboolean my_device_provider_register_custom (GstPlugin * plugin)
43 * gboolean ret = FALSE;
44 * ret |= gst_device_provider_register (plugin, "my-device-provider",
45 GST_RANK_PRIMARY, GST_TYPE_MY_DEVICE_PROVIDER);
49 * GST_DEVICE_PROVIDER_REGISTER_DEFINE_CUSTOM (my_device_provider, my_device_provider_register_custom)
54 #define GST_DEVICE_PROVIDER_REGISTER_DEFINE_CUSTOM(d_p, register_func) \
56 gboolean G_PASTE (gst_device_provider_register_, d_p) (GstPlugin * plugin) \
58 return register_func (plugin); \
63 * GST_DEVICE_PROVIDER_REGISTER_DEFINE:
64 * @d_p: The device provider name in lower case, with words separated by '_'.
65 * Used to generate `gst_device_provider_register_*(GstPlugin* plugin)`.
66 * @d_p_n: The public name of the device provider
67 * @r: The #GstRank of the device provider (higher rank means more importance when autoplugging, see #GstRank)
68 * @t: The #GType of the device provider.
70 * A convenience macro to define the entry point of a
71 * device provider `gst_device_provider_register_*(GstPlugin* plugin)`.
75 #define GST_DEVICE_PROVIDER_REGISTER_DEFINE(d_p, d_p_n, r, t) \
77 gboolean G_PASTE (gst_device_provider_register_, d_p) (GstPlugin * plugin) \
79 return gst_device_provider_register (plugin, d_p_n, r, t); \
84 * GST_DEVICE_PROVIDER_REGISTER_DECLARE:
85 * @d_p: The device provider name in lower case, with words separated by '_'.
87 * This macro can be used to declare a new device provider.
88 * It has to be used in combination with #GST_DEVICE_PROVIDER_REGISTER_DEFINE macro
89 * and must be placed outside any block to declare the device provider registration
94 #define GST_DEVICE_PROVIDER_REGISTER_DECLARE(d_p) \
96 gboolean G_PASTE(gst_device_provider_register_, d_p) (GstPlugin * plugin); \
100 * GST_DEVICE_PROVIDER_REGISTER:
101 * @d_p: The device provider name in lower case, with words separated by '_'.
102 * @plugin: The #GstPlugin where to register the device provider.
104 * This macro can be used to register a device provider into a #GstPlugin.
105 * This method will be usually called in the plugin init function
106 * but can also be called with a NULL plugin.
110 #define GST_DEVICE_PROVIDER_REGISTER(d_p, plugin) G_PASTE(gst_device_provider_register_, d_p) (plugin)
114 typedef struct _GstDeviceProvider GstDeviceProvider;
115 typedef struct _GstDeviceProviderClass GstDeviceProviderClass;
116 typedef struct _GstDeviceProviderPrivate GstDeviceProviderPrivate;
118 #include <gst/gstdeviceproviderfactory.h>
120 #define GST_TYPE_DEVICE_PROVIDER (gst_device_provider_get_type())
121 #define GST_IS_DEVICE_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEVICE_PROVIDER))
122 #define GST_IS_DEVICE_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEVICE_PROVIDER))
123 #define GST_DEVICE_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEVICE_PROVIDER, GstDeviceProviderClass))
124 #define GST_DEVICE_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEVICE_PROVIDER, GstDeviceProvider))
125 #define GST_DEVICE_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEVICE_PROVIDER, GstDeviceProviderClass))
126 #define GST_DEVICE_PROVIDER_CAST(obj) ((GstDeviceProvider *)(obj))
131 * @parent: The parent #GstObject
132 * @devices: a #GList of the #GstDevice objects
134 * The structure of the base #GstDeviceProvider
138 struct _GstDeviceProvider {
141 /* Protected by the Object lock */
146 GstDeviceProviderPrivate *priv;
148 gpointer _gst_reserved[GST_PADDING];
152 * GstDeviceProviderClass:
153 * @parent_class: the parent #GstObjectClass structure
154 * @factory: a pointer to the #GstDeviceProviderFactory that creates this
156 * @probe: Returns a list of devices that are currently available.
157 * This should never block. The devices should not have a parent and should
159 * @start: Starts monitoring for new devices. Only subclasses that can know
160 * that devices have been added or remove need to implement this method.
161 * @stop: Stops monitoring for new devices. Only subclasses that implement
162 * the start() method need to implement this method.
164 * The structure of the base #GstDeviceProviderClass
169 struct _GstDeviceProviderClass {
170 GstObjectClass parent_class;
172 GstDeviceProviderFactory *factory;
174 GList* (*probe) (GstDeviceProvider * provider);
176 gboolean (*start) (GstDeviceProvider * provider);
177 void (*stop) (GstDeviceProvider * provider);
183 gpointer _gst_reserved[GST_PADDING];
187 GType gst_device_provider_get_type (void);
191 GList * gst_device_provider_get_devices (GstDeviceProvider * provider);
194 gboolean gst_device_provider_start (GstDeviceProvider * provider);
197 void gst_device_provider_stop (GstDeviceProvider * provider);
200 gboolean gst_device_provider_can_monitor (GstDeviceProvider * provider);
203 GstBus * gst_device_provider_get_bus (GstDeviceProvider * provider);
206 void gst_device_provider_device_add (GstDeviceProvider * provider,
209 void gst_device_provider_device_remove (GstDeviceProvider * provider,
212 gchar ** gst_device_provider_get_hidden_providers (GstDeviceProvider * provider);
215 void gst_device_provider_hide_provider (GstDeviceProvider * provider,
218 void gst_device_provider_unhide_provider (GstDeviceProvider * provider,
222 const gchar * gst_device_provider_get_metadata (GstDeviceProvider * provider,
226 gboolean gst_device_provider_is_started (GstDeviceProvider * provider);
228 /* device provider class meta data */
231 void gst_device_provider_class_set_metadata (GstDeviceProviderClass *klass,
232 const gchar *longname,
233 const gchar *classification,
234 const gchar *description,
235 const gchar *author);
237 void gst_device_provider_class_set_static_metadata (GstDeviceProviderClass *klass,
238 const gchar *longname,
239 const gchar *classification,
240 const gchar *description,
241 const gchar *author);
243 void gst_device_provider_class_add_metadata (GstDeviceProviderClass * klass,
244 const gchar * key, const gchar * value);
246 void gst_device_provider_class_add_static_metadata (GstDeviceProviderClass * klass,
247 const gchar * key, const gchar * value);
249 const gchar * gst_device_provider_class_get_metadata (GstDeviceProviderClass * klass,
253 void gst_device_provider_device_changed (GstDeviceProvider * provider,
255 GstDevice *changed_device);
257 /* factory management */
260 GstDeviceProviderFactory * gst_device_provider_get_factory (GstDeviceProvider * provider);
262 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDeviceProvider, gst_object_unref)
266 #endif /* __GST_DEVICE_PROVIDER_H__ */