element/deviceprovider: Add instance getter functions for class properties
[platform/upstream/gstreamer.git] / gst / gstdeviceprovider.c
1 /* GStreamer
2  * Copyright (C) 2012 Olivier Crete <olivier.crete@collabora.com>
3  *
4  * gstdeviceprovider.c: 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  * SECTION:gstdeviceprovider
24  * @title: GstDeviceProvider
25  * @short_description: A device provider
26  * @see_also: #GstDevice, #GstDeviceMonitor
27  *
28  * A #GstDeviceProvider subclass is provided by a plugin that handles devices
29  * if there is a way to programatically list connected devices. It can also
30  * optionally provide updates to the list of connected devices.
31  *
32  * Each #GstDeviceProvider subclass is a singleton, a plugin should
33  * normally provide a single subclass for all devices.
34  *
35  * Applications would normally use a #GstDeviceMonitor to monitor devices
36  * from all relevant providers.
37  *
38  * Since: 1.4
39  */
40
41 #ifdef HAVE_CONFIG_H
42 #include "config.h"
43 #endif
44
45 #include "gst_private.h"
46
47 #include "gstdeviceprovider.h"
48
49 #include "gstelementmetadata.h"
50 #include "gstquark.h"
51
52 struct _GstDeviceProviderPrivate
53 {
54   GstBus *bus;
55
56   GMutex start_lock;
57
58   gboolean started_count;
59
60   GList *hidden_providers;
61 };
62
63 enum
64 {
65   PROVIDER_HIDDEN,
66   PROVIDER_UNHIDDEN,
67   LAST_SIGNAL
68 };
69
70 static guint gst_device_provider_signals[LAST_SIGNAL] = { 0 };
71
72 /* this is used in gstelementfactory.c:gst_element_register() */
73 GQuark __gst_deviceproviderclass_factory = 0;
74
75 static void gst_device_provider_class_init (GstDeviceProviderClass * klass);
76 static void gst_device_provider_init (GstDeviceProvider * element);
77 static void gst_device_provider_base_class_init (gpointer g_class);
78 static void gst_device_provider_dispose (GObject * object);
79 static void gst_device_provider_finalize (GObject * object);
80
81 static gpointer gst_device_provider_parent_class = NULL;
82
83 GType
84 gst_device_provider_get_type (void)
85 {
86   static volatile gsize gst_device_provider_type = 0;
87
88   if (g_once_init_enter (&gst_device_provider_type)) {
89     GType _type;
90     static const GTypeInfo element_info = {
91       sizeof (GstDeviceProviderClass),
92       gst_device_provider_base_class_init,
93       NULL,                     /* base_class_finalize */
94       (GClassInitFunc) gst_device_provider_class_init,
95       NULL,
96       NULL,
97       sizeof (GstDeviceProvider),
98       0,
99       (GInstanceInitFunc) gst_device_provider_init,
100       NULL
101     };
102
103     _type = g_type_register_static (GST_TYPE_OBJECT, "GstDeviceProvider",
104         &element_info, G_TYPE_FLAG_ABSTRACT);
105
106     __gst_deviceproviderclass_factory =
107         g_quark_from_static_string ("GST_DEVICEPROVIDERCLASS_FACTORY");
108     g_once_init_leave (&gst_device_provider_type, _type);
109   }
110   return gst_device_provider_type;
111 }
112
113 static void
114 gst_device_provider_base_class_init (gpointer g_class)
115 {
116   GstDeviceProviderClass *klass = GST_DEVICE_PROVIDER_CLASS (g_class);
117
118   /* Copy the element details here so elements can inherit the
119    * details from their base class and classes only need to set
120    * the details in class_init instead of base_init */
121   klass->metadata =
122       klass->metadata ? gst_structure_copy (klass->metadata) :
123       gst_structure_new_empty ("metadata");
124
125   klass->factory = g_type_get_qdata (G_TYPE_FROM_CLASS (klass),
126       __gst_deviceproviderclass_factory);
127 }
128
129 static void
130 gst_device_provider_class_init (GstDeviceProviderClass * klass)
131 {
132   GObjectClass *gobject_class = (GObjectClass *) klass;
133
134   gst_device_provider_parent_class = g_type_class_peek_parent (klass);
135
136   g_type_class_add_private (klass, sizeof (GstDeviceProviderPrivate));
137
138   gobject_class->dispose = gst_device_provider_dispose;
139   gobject_class->finalize = gst_device_provider_finalize;
140
141   gst_device_provider_signals[PROVIDER_HIDDEN] =
142       g_signal_new ("provider-hidden", G_TYPE_FROM_CLASS (klass),
143       G_SIGNAL_RUN_FIRST, 0, NULL,
144       NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, G_TYPE_STRING);
145
146   gst_device_provider_signals[PROVIDER_UNHIDDEN] =
147       g_signal_new ("provider-unhidden", G_TYPE_FROM_CLASS (klass),
148       G_SIGNAL_RUN_FIRST, 0, NULL,
149       NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, G_TYPE_STRING);
150 }
151
152 static void
153 gst_device_provider_init (GstDeviceProvider * provider)
154 {
155   provider->priv = G_TYPE_INSTANCE_GET_PRIVATE (provider,
156       GST_TYPE_DEVICE_PROVIDER, GstDeviceProviderPrivate);
157
158   g_mutex_init (&provider->priv->start_lock);
159
160   provider->priv->bus = gst_bus_new ();
161   gst_bus_set_flushing (provider->priv->bus, TRUE);
162 }
163
164
165 static void
166 gst_device_provider_dispose (GObject * object)
167 {
168   GstDeviceProvider *provider = GST_DEVICE_PROVIDER (object);
169
170   gst_object_replace ((GstObject **) & provider->priv->bus, NULL);
171
172   GST_OBJECT_LOCK (provider);
173   g_list_free_full (provider->devices, (GDestroyNotify) gst_object_unparent);
174   provider->devices = NULL;
175   GST_OBJECT_UNLOCK (provider);
176
177   G_OBJECT_CLASS (gst_device_provider_parent_class)->dispose (object);
178 }
179
180 static void
181 gst_device_provider_finalize (GObject * object)
182 {
183   GstDeviceProvider *provider = GST_DEVICE_PROVIDER (object);
184
185   g_mutex_clear (&provider->priv->start_lock);
186
187   G_OBJECT_CLASS (gst_device_provider_parent_class)->finalize (object);
188 }
189
190 /**
191  * gst_device_provider_class_add_metadata:
192  * @klass: class to set metadata for
193  * @key: the key to set
194  * @value: the value to set
195  *
196  * Set @key with @value as metadata in @klass.
197  *
198  * Since: 1.4
199  */
200 void
201 gst_device_provider_class_add_metadata (GstDeviceProviderClass * klass,
202     const gchar * key, const gchar * value)
203 {
204   g_return_if_fail (GST_IS_DEVICE_PROVIDER_CLASS (klass));
205   g_return_if_fail (key != NULL);
206   g_return_if_fail (value != NULL);
207
208   gst_structure_set ((GstStructure *) klass->metadata,
209       key, G_TYPE_STRING, value, NULL);
210 }
211
212 /**
213  * gst_device_provider_class_add_static_metadata:
214  * @klass: class to set metadata for
215  * @key: the key to set
216  * @value: (transfer full): the value to set
217  *
218  * Set @key with @value as metadata in @klass.
219  *
220  * Same as gst_device_provider_class_add_metadata(), but @value must be a static string
221  * or an inlined string, as it will not be copied. (GStreamer plugins will
222  * be made resident once loaded, so this function can be used even from
223  * dynamically loaded plugins.)
224  *
225  * Since: 1.4
226  */
227 void
228 gst_device_provider_class_add_static_metadata (GstDeviceProviderClass * klass,
229     const gchar * key, const gchar * value)
230 {
231   GValue val = G_VALUE_INIT;
232
233   g_return_if_fail (GST_IS_DEVICE_PROVIDER_CLASS (klass));
234   g_return_if_fail (key != NULL);
235   g_return_if_fail (value != NULL);
236
237   g_value_init (&val, G_TYPE_STRING);
238   g_value_set_static_string (&val, value);
239   gst_structure_take_value ((GstStructure *) klass->metadata, key, &val);
240 }
241
242 /**
243  * gst_device_provider_class_set_metadata:
244  * @klass: class to set metadata for
245  * @longname: The long English name of the device provider. E.g. "File Sink"
246  * @classification: String describing the type of device provider, as an
247  *  unordered list separated with slashes ('/'). See draft-klass.txt of the
248  *  design docs
249  * for more details and common types. E.g: "Sink/File"
250  * @description: Sentence describing the purpose of the device provider.
251  * E.g: "Write stream to a file"
252  * @author: Name and contact details of the author(s). Use \n to separate
253  * multiple author metadata. E.g: "Joe Bloggs &lt;joe.blogs at foo.com&gt;"
254  *
255  * Sets the detailed information for a #GstDeviceProviderClass.
256  *
257  * > This function is for use in _class_init functions only.
258  *
259  * Since: 1.4
260  */
261 void
262 gst_device_provider_class_set_metadata (GstDeviceProviderClass * klass,
263     const gchar * longname, const gchar * classification,
264     const gchar * description, const gchar * author)
265 {
266   g_return_if_fail (GST_IS_DEVICE_PROVIDER_CLASS (klass));
267   g_return_if_fail (longname != NULL && *longname != '\0');
268   g_return_if_fail (classification != NULL && *classification != '\0');
269   g_return_if_fail (description != NULL && *description != '\0');
270   g_return_if_fail (author != NULL && *author != '\0');
271
272   gst_structure_id_set ((GstStructure *) klass->metadata,
273       GST_QUARK (ELEMENT_METADATA_LONGNAME), G_TYPE_STRING, longname,
274       GST_QUARK (ELEMENT_METADATA_KLASS), G_TYPE_STRING, classification,
275       GST_QUARK (ELEMENT_METADATA_DESCRIPTION), G_TYPE_STRING, description,
276       GST_QUARK (ELEMENT_METADATA_AUTHOR), G_TYPE_STRING, author, NULL);
277 }
278
279 /**
280  * gst_device_provider_class_set_static_metadata:
281  * @klass: class to set metadata for
282  * @longname: (transfer full): The long English name of the element. E.g. "File Sink"
283  * @classification: (transfer full): String describing the type of element, as
284  * an unordered list separated with slashes ('/'). See draft-klass.txt of the
285  * design docs for more details and common types. E.g: "Sink/File"
286  * @description: (transfer full): Sentence describing the purpose of the
287  * element.  E.g: "Write stream to a file"
288  * @author: (transfer full): Name and contact details of the author(s). Use \n
289  * to separate multiple author metadata. E.g: "Joe Bloggs &lt;joe.blogs at
290  * foo.com&gt;"
291  *
292  * Sets the detailed information for a #GstDeviceProviderClass.
293  *
294  * > This function is for use in _class_init functions only.
295  *
296  * Same as gst_device_provider_class_set_metadata(), but @longname, @classification,
297  * @description, and @author must be static strings or inlined strings, as
298  * they will not be copied. (GStreamer plugins will be made resident once
299  * loaded, so this function can be used even from dynamically loaded plugins.)
300  *
301  * Since: 1.4
302  */
303 void
304 gst_device_provider_class_set_static_metadata (GstDeviceProviderClass * klass,
305     const gchar * longname, const gchar * classification,
306     const gchar * description, const gchar * author)
307 {
308   GstStructure *s = (GstStructure *) klass->metadata;
309   GValue val = G_VALUE_INIT;
310
311   g_return_if_fail (GST_IS_DEVICE_PROVIDER_CLASS (klass));
312   g_return_if_fail (longname != NULL && *longname != '\0');
313   g_return_if_fail (classification != NULL && *classification != '\0');
314   g_return_if_fail (description != NULL && *description != '\0');
315   g_return_if_fail (author != NULL && *author != '\0');
316
317   g_value_init (&val, G_TYPE_STRING);
318
319   g_value_set_static_string (&val, longname);
320   gst_structure_id_set_value (s, GST_QUARK (ELEMENT_METADATA_LONGNAME), &val);
321
322   g_value_set_static_string (&val, classification);
323   gst_structure_id_set_value (s, GST_QUARK (ELEMENT_METADATA_KLASS), &val);
324
325   g_value_set_static_string (&val, description);
326   gst_structure_id_set_value (s, GST_QUARK (ELEMENT_METADATA_DESCRIPTION),
327       &val);
328
329   g_value_set_static_string (&val, author);
330   gst_structure_id_take_value (s, GST_QUARK (ELEMENT_METADATA_AUTHOR), &val);
331 }
332
333 /**
334  * gst_device_provider_class_get_metadata:
335  * @klass: class to get metadata for
336  * @key: the key to get
337  *
338  * Get metadata with @key in @klass.
339  *
340  * Returns: the metadata for @key.
341  *
342  * Since: 1.4
343  */
344 const gchar *
345 gst_device_provider_class_get_metadata (GstDeviceProviderClass * klass,
346     const gchar * key)
347 {
348   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER_CLASS (klass), NULL);
349   g_return_val_if_fail (key != NULL, NULL);
350
351   return gst_structure_get_string ((GstStructure *) klass->metadata, key);
352 }
353
354 /**
355  * gst_device_provider_get_metadata:
356  * @provider: provider to get metadata for
357  * @key: the key to get
358  *
359  * Get metadata with @key in @provider.
360  *
361  * Returns: the metadata for @key.
362  *
363  * Since: 1.14
364  */
365 const gchar *
366 gst_device_provider_get_metadata (GstDeviceProvider * provider,
367     const gchar * key)
368 {
369   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), NULL);
370   g_return_val_if_fail (key != NULL, NULL);
371
372   return
373       gst_device_provider_class_get_metadata (GST_DEVICE_PROVIDER_GET_CLASS
374       (provider), key);
375 }
376
377 /**
378  * gst_device_provider_get_devices:
379  * @provider: A #GstDeviceProvider
380  *
381  * Gets a list of devices that this provider understands. This may actually
382  * probe the hardware if the provider is not currently started.
383  *
384  * Returns: (transfer full) (element-type GstDevice): a #GList of
385  *   #GstDevice
386  *
387  * Since: 1.4
388  */
389
390 GList *
391 gst_device_provider_get_devices (GstDeviceProvider * provider)
392 {
393   GstDeviceProviderClass *klass;
394   GList *devices = NULL;
395   gboolean started;
396   GList *item;
397
398   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), NULL);
399   klass = GST_DEVICE_PROVIDER_GET_CLASS (provider);
400
401   g_mutex_lock (&provider->priv->start_lock);
402   started = (provider->priv->started_count > 0);
403
404   if (started) {
405     GST_OBJECT_LOCK (provider);
406     for (item = provider->devices; item; item = item->next)
407       devices = g_list_prepend (devices, gst_object_ref (item->data));
408     GST_OBJECT_UNLOCK (provider);
409   } else if (klass->probe)
410     devices = klass->probe (provider);
411
412   g_mutex_unlock (&provider->priv->start_lock);
413
414   return devices;
415 }
416
417 /**
418  * gst_device_provider_start:
419  * @provider: A #GstDeviceProvider
420  *
421  * Starts providering the devices. This will cause #GST_MESSAGE_DEVICE_ADDED
422  * and #GST_MESSAGE_DEVICE_REMOVED messages to be posted on the provider's bus
423  * when devices are added or removed from the system.
424  *
425  * Since the #GstDeviceProvider is a singleton,
426  * gst_device_provider_start() may already have been called by another
427  * user of the object, gst_device_provider_stop() needs to be called the same
428  * number of times.
429  *
430  * Returns: %TRUE if the device providering could be started
431  *
432  * Since: 1.4
433  */
434
435 gboolean
436 gst_device_provider_start (GstDeviceProvider * provider)
437 {
438   GstDeviceProviderClass *klass;
439   gboolean ret = FALSE;
440
441   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), FALSE);
442   klass = GST_DEVICE_PROVIDER_GET_CLASS (provider);
443
444   g_mutex_lock (&provider->priv->start_lock);
445
446   if (provider->priv->started_count > 0) {
447     ret = TRUE;
448     goto started;
449   }
450
451   if (klass->start)
452     ret = klass->start (provider);
453
454   if (ret) {
455     provider->priv->started_count++;
456     gst_bus_set_flushing (provider->priv->bus, FALSE);
457   }
458
459 started:
460
461   g_mutex_unlock (&provider->priv->start_lock);
462
463   return ret;
464 }
465
466 /**
467  * gst_device_provider_stop:
468  * @provider: A #GstDeviceProvider
469  *
470  * Decreases the use-count by one. If the use count reaches zero, this
471  * #GstDeviceProvider will stop providering the devices. This needs to be
472  * called the same number of times that gst_device_provider_start() was called.
473  *
474  * Since: 1.4
475  */
476
477 void
478 gst_device_provider_stop (GstDeviceProvider * provider)
479 {
480   GstDeviceProviderClass *klass;
481
482   g_return_if_fail (GST_IS_DEVICE_PROVIDER (provider));
483   klass = GST_DEVICE_PROVIDER_GET_CLASS (provider);
484
485   g_mutex_lock (&provider->priv->start_lock);
486
487   if (provider->priv->started_count == 1) {
488     gst_bus_set_flushing (provider->priv->bus, TRUE);
489     if (klass->stop)
490       klass->stop (provider);
491     GST_OBJECT_LOCK (provider);
492     g_list_free_full (provider->devices, (GDestroyNotify) gst_object_unparent);
493     provider->devices = NULL;
494     GST_OBJECT_UNLOCK (provider);
495   } else if (provider->priv->started_count < 1) {
496     g_critical
497         ("Trying to stop a GstDeviceProvider %s which is already stopped",
498         GST_OBJECT_NAME (provider));
499   }
500
501   provider->priv->started_count--;
502   g_mutex_unlock (&provider->priv->start_lock);
503 }
504
505
506 /**
507  * gst_device_provider_get_factory:
508  * @provider: a #GstDeviceProvider to request the device provider factory of.
509  *
510  * Retrieves the factory that was used to create this device provider.
511  *
512  * Returns: (transfer none): the #GstDeviceProviderFactory used for
513  *     creating this device provider. no refcounting is needed.
514  *
515  * Since: 1.4
516  */
517 GstDeviceProviderFactory *
518 gst_device_provider_get_factory (GstDeviceProvider * provider)
519 {
520   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), NULL);
521
522   return GST_DEVICE_PROVIDER_GET_CLASS (provider)->factory;
523 }
524
525 /**
526  * gst_device_provider_can_provider:
527  * @provider: a #GstDeviceProvider
528  *
529  * If this function returns %TRUE, then the device provider can provider if
530  * devices are added or removed. Otherwise, it can only do static probing.
531  *
532  * Returns: %TRUE if the #GstDeviceProvider support providering, %FALSE otherwise
533  */
534 gboolean
535 gst_device_provider_can_monitor (GstDeviceProvider * provider)
536 {
537   GstDeviceProviderClass *klass;
538
539   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), FALSE);
540   klass = GST_DEVICE_PROVIDER_GET_CLASS (provider);
541
542   if (klass->start)
543     return TRUE;
544   else
545     return FALSE;
546 }
547
548 /**
549  * gst_device_provider_get_bus:
550  * @provider: a #GstDeviceProvider
551  *
552  * Gets the #GstBus of this #GstDeviceProvider
553  *
554  * Returns: (transfer full): a #GstBus
555  *
556  * Since: 1.4
557  */
558 GstBus *
559 gst_device_provider_get_bus (GstDeviceProvider * provider)
560 {
561   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), NULL);
562
563   return gst_object_ref (provider->priv->bus);
564 }
565
566 /**
567  * gst_device_provider_device_add:
568  * @provider: a #GstDeviceProvider
569  * @device: (transfer floating): a #GstDevice that has been added
570  *
571  * Posts a message on the provider's #GstBus to inform applications that
572  * a new device has been added.
573  *
574  * This is for use by subclasses.
575  *
576  * @device's reference count will be incremented, and any floating reference
577  * will be removed (see gst_object_ref_sink()).
578  *
579  * Since: 1.4
580  */
581 void
582 gst_device_provider_device_add (GstDeviceProvider * provider,
583     GstDevice * device)
584 {
585   GstMessage *message;
586
587   g_return_if_fail (GST_IS_DEVICE_PROVIDER (provider));
588   g_return_if_fail (GST_IS_DEVICE (device));
589
590   if (!gst_object_set_parent (GST_OBJECT (device), GST_OBJECT (provider))) {
591     GST_WARNING_OBJECT (provider, "Could not parent device %p to provider,"
592         " it already has a parent", device);
593     return;
594   }
595
596   GST_OBJECT_LOCK (provider);
597   /* Take an additional reference so we can be sure nobody removed it from the
598    * provider in the meantime and we can safely emit the message */
599   gst_object_ref (device);
600   provider->devices = g_list_prepend (provider->devices, device);
601   GST_OBJECT_UNLOCK (provider);
602
603   message = gst_message_new_device_added (GST_OBJECT (provider), device);
604   gst_bus_post (provider->priv->bus, message);
605   gst_object_unref (device);
606 }
607
608
609 /**
610  * gst_device_provider_device_remove:
611  * @provider: a #GstDeviceProvider
612  * @device: a #GstDevice that has been removed
613  *
614  * Posts a message on the provider's #GstBus to inform applications that
615  * a device has been removed.
616  *
617  * This is for use by subclasses.
618  *
619  * Since: 1.4
620  */
621 void
622 gst_device_provider_device_remove (GstDeviceProvider * provider,
623     GstDevice * device)
624 {
625   GstMessage *message;
626   GList *item;
627
628   g_return_if_fail (GST_IS_DEVICE_PROVIDER (provider));
629   g_return_if_fail (GST_IS_DEVICE (device));
630
631   GST_OBJECT_LOCK (provider);
632   item = g_list_find (provider->devices, device);
633   if (item) {
634     provider->devices = g_list_delete_link (provider->devices, item);
635   }
636   GST_OBJECT_UNLOCK (provider);
637
638   message = gst_message_new_device_removed (GST_OBJECT (provider), device);
639   g_signal_emit_by_name (device, "removed");
640   gst_bus_post (provider->priv->bus, message);
641   if (item)
642     gst_object_unparent (GST_OBJECT (device));
643 }
644
645 /**
646  * gst_device_provider_get_hidden_providers:
647  * @provider: a #GstDeviceProvider
648  *
649  * Get the provider factory names of the #GstDeviceProvider instances that
650  * are hidden by @provider.
651  *
652  * Returns: (transfer full) (array zero-terminated=1) (element-type gchar*):
653  *   a list of hidden providers factory names or %NULL when
654  *   nothing is hidden by @provider. Free with g_strfreev.
655  *
656  * Since: 1.6
657  */
658 gchar **
659 gst_device_provider_get_hidden_providers (GstDeviceProvider * provider)
660 {
661   GList *walk;
662   guint i, len;
663   gchar **res = NULL;
664
665   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), NULL);
666
667   GST_OBJECT_LOCK (provider);
668   len = g_list_length (provider->priv->hidden_providers);
669   if (len == 0)
670     goto done;
671
672   res = g_new (gchar *, len + 1);
673   for (i = 0, walk = provider->priv->hidden_providers; walk;
674       walk = g_list_next (walk), i++)
675     res[i] = g_strdup (walk->data);
676   res[i] = NULL;
677
678 done:
679   GST_OBJECT_UNLOCK (provider);
680
681   return res;
682 }
683
684 /**
685  * gst_device_provider_hide_provider:
686  * @provider: a #GstDeviceProvider
687  * @name: a provider factory name
688  *
689  * Make @provider hide the devices from the factory with @name.
690  *
691  * This function is used when @provider will also provide the devices reported
692  * by provider factory @name. A monitor should stop monitoring the
693  * device provider with @name to avoid duplicate devices.
694  *
695  * Since: 1.6
696  */
697 void
698 gst_device_provider_hide_provider (GstDeviceProvider * provider,
699     const gchar * name)
700 {
701   GList *find;
702   const gchar *hidden_name = NULL;
703
704   g_return_if_fail (GST_IS_DEVICE_PROVIDER (provider));
705   g_return_if_fail (name != NULL);
706
707   GST_OBJECT_LOCK (provider);
708   find =
709       g_list_find_custom (provider->priv->hidden_providers, name,
710       (GCompareFunc) g_strcmp0);
711   if (find == NULL) {
712     hidden_name = name;
713     provider->priv->hidden_providers =
714         g_list_prepend (provider->priv->hidden_providers, g_strdup (name));
715   }
716   GST_OBJECT_UNLOCK (provider);
717
718   if (hidden_name)
719     g_signal_emit (provider, gst_device_provider_signals[PROVIDER_HIDDEN],
720         0, hidden_name);
721 }
722
723 /**
724  * gst_device_provider_unhide_provider:
725  * @provider: a #GstDeviceProvider
726  * @name: a provider factory name
727  *
728  * Make @provider unhide the devices from factory @name.
729  *
730  * This function is used when @provider will no longer provide the devices
731  * reported by provider factory @name. A monitor should start
732  * monitoring the devices from provider factory @name in order to see
733  * all devices again.
734  *
735  * Since: 1.6
736  */
737 void
738 gst_device_provider_unhide_provider (GstDeviceProvider * provider,
739     const gchar * name)
740 {
741   GList *find;
742   gchar *unhidden_name = NULL;
743
744   g_return_if_fail (GST_IS_DEVICE_PROVIDER (provider));
745   g_return_if_fail (unhidden_name != NULL);
746
747   GST_OBJECT_LOCK (provider);
748   find =
749       g_list_find_custom (provider->priv->hidden_providers, name,
750       (GCompareFunc) g_strcmp0);
751   if (find) {
752     unhidden_name = find->data;
753     provider->priv->hidden_providers =
754         g_list_delete_link (provider->priv->hidden_providers, find);
755   }
756   GST_OBJECT_UNLOCK (provider);
757
758   if (unhidden_name) {
759     g_signal_emit (provider,
760         gst_device_provider_signals[PROVIDER_UNHIDDEN], 0, unhidden_name);
761     g_free (unhidden_name);
762   }
763 }