Port gtk-doc comments to their equivalent markdown syntax
[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_devices:
356  * @provider: A #GstDeviceProvider
357  *
358  * Gets a list of devices that this provider understands. This may actually
359  * probe the hardware if the provider is not currently started.
360  *
361  * Returns: (transfer full) (element-type GstDevice): a #GList of
362  *   #GstDevice
363  *
364  * Since: 1.4
365  */
366
367 GList *
368 gst_device_provider_get_devices (GstDeviceProvider * provider)
369 {
370   GstDeviceProviderClass *klass;
371   GList *devices = NULL;
372   gboolean started;
373   GList *item;
374
375   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), NULL);
376   klass = GST_DEVICE_PROVIDER_GET_CLASS (provider);
377
378   g_mutex_lock (&provider->priv->start_lock);
379   started = (provider->priv->started_count > 0);
380
381   if (started) {
382     GST_OBJECT_LOCK (provider);
383     for (item = provider->devices; item; item = item->next)
384       devices = g_list_prepend (devices, gst_object_ref (item->data));
385     GST_OBJECT_UNLOCK (provider);
386   } else if (klass->probe)
387     devices = klass->probe (provider);
388
389   g_mutex_unlock (&provider->priv->start_lock);
390
391   return devices;
392 }
393
394 /**
395  * gst_device_provider_start:
396  * @provider: A #GstDeviceProvider
397  *
398  * Starts providering the devices. This will cause #GST_MESSAGE_DEVICE_ADDED
399  * and #GST_MESSAGE_DEVICE_REMOVED messages to be posted on the provider's bus
400  * when devices are added or removed from the system.
401  *
402  * Since the #GstDeviceProvider is a singleton,
403  * gst_device_provider_start() may already have been called by another
404  * user of the object, gst_device_provider_stop() needs to be called the same
405  * number of times.
406  *
407  * Returns: %TRUE if the device providering could be started
408  *
409  * Since: 1.4
410  */
411
412 gboolean
413 gst_device_provider_start (GstDeviceProvider * provider)
414 {
415   GstDeviceProviderClass *klass;
416   gboolean ret = FALSE;
417
418   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), FALSE);
419   klass = GST_DEVICE_PROVIDER_GET_CLASS (provider);
420
421   g_mutex_lock (&provider->priv->start_lock);
422
423   if (provider->priv->started_count > 0) {
424     ret = TRUE;
425     goto started;
426   }
427
428   if (klass->start)
429     ret = klass->start (provider);
430
431   if (ret) {
432     provider->priv->started_count++;
433     gst_bus_set_flushing (provider->priv->bus, FALSE);
434   }
435
436 started:
437
438   g_mutex_unlock (&provider->priv->start_lock);
439
440   return ret;
441 }
442
443 /**
444  * gst_device_provider_stop:
445  * @provider: A #GstDeviceProvider
446  *
447  * Decreases the use-count by one. If the use count reaches zero, this
448  * #GstDeviceProvider will stop providering the devices. This needs to be
449  * called the same number of times that gst_device_provider_start() was called.
450  *
451  * Since: 1.4
452  */
453
454 void
455 gst_device_provider_stop (GstDeviceProvider * provider)
456 {
457   GstDeviceProviderClass *klass;
458
459   g_return_if_fail (GST_IS_DEVICE_PROVIDER (provider));
460   klass = GST_DEVICE_PROVIDER_GET_CLASS (provider);
461
462   g_mutex_lock (&provider->priv->start_lock);
463
464   if (provider->priv->started_count == 1) {
465     gst_bus_set_flushing (provider->priv->bus, TRUE);
466     if (klass->stop)
467       klass->stop (provider);
468     GST_OBJECT_LOCK (provider);
469     g_list_free_full (provider->devices, (GDestroyNotify) gst_object_unparent);
470     provider->devices = NULL;
471     GST_OBJECT_UNLOCK (provider);
472   } else if (provider->priv->started_count < 1) {
473     g_critical
474         ("Trying to stop a GstDeviceProvider %s which is already stopped",
475         GST_OBJECT_NAME (provider));
476   }
477
478   provider->priv->started_count--;
479   g_mutex_unlock (&provider->priv->start_lock);
480 }
481
482
483 /**
484  * gst_device_provider_get_factory:
485  * @provider: a #GstDeviceProvider to request the device provider factory of.
486  *
487  * Retrieves the factory that was used to create this device provider.
488  *
489  * Returns: (transfer none): the #GstDeviceProviderFactory used for
490  *     creating this device provider. no refcounting is needed.
491  *
492  * Since: 1.4
493  */
494 GstDeviceProviderFactory *
495 gst_device_provider_get_factory (GstDeviceProvider * provider)
496 {
497   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), NULL);
498
499   return GST_DEVICE_PROVIDER_GET_CLASS (provider)->factory;
500 }
501
502 /**
503  * gst_device_provider_can_provider:
504  * @provider: a #GstDeviceProvider
505  *
506  * If this function returns %TRUE, then the device provider can provider if
507  * devices are added or removed. Otherwise, it can only do static probing.
508  *
509  * Returns: %TRUE if the #GstDeviceProvider support providering, %FALSE otherwise
510  */
511 gboolean
512 gst_device_provider_can_monitor (GstDeviceProvider * provider)
513 {
514   GstDeviceProviderClass *klass;
515
516   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), FALSE);
517   klass = GST_DEVICE_PROVIDER_GET_CLASS (provider);
518
519   if (klass->start)
520     return TRUE;
521   else
522     return FALSE;
523 }
524
525 /**
526  * gst_device_provider_get_bus:
527  * @provider: a #GstDeviceProvider
528  *
529  * Gets the #GstBus of this #GstDeviceProvider
530  *
531  * Returns: (transfer full): a #GstBus
532  *
533  * Since: 1.4
534  */
535 GstBus *
536 gst_device_provider_get_bus (GstDeviceProvider * provider)
537 {
538   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), NULL);
539
540   return gst_object_ref (provider->priv->bus);
541 }
542
543 /**
544  * gst_device_provider_device_add:
545  * @provider: a #GstDeviceProvider
546  * @device: (transfer full): a #GstDevice that has been added
547  *
548  * Posts a message on the provider's #GstBus to inform applications that
549  * a new device has been added.
550  *
551  * This is for use by subclasses.
552  *
553  * Since: 1.4
554  */
555 void
556 gst_device_provider_device_add (GstDeviceProvider * provider,
557     GstDevice * device)
558 {
559   GstMessage *message;
560
561   g_return_if_fail (GST_IS_DEVICE_PROVIDER (provider));
562   g_return_if_fail (GST_IS_DEVICE (device));
563
564   if (!gst_object_set_parent (GST_OBJECT (device), GST_OBJECT (provider))) {
565     GST_WARNING_OBJECT (provider, "Could not parent device %p to provider,"
566         " it already has a parent", device);
567     return;
568   }
569
570   GST_OBJECT_LOCK (provider);
571   provider->devices = g_list_prepend (provider->devices,
572       gst_object_ref (device));
573   GST_OBJECT_UNLOCK (provider);
574
575   message = gst_message_new_device_added (GST_OBJECT (provider), device);
576   gst_bus_post (provider->priv->bus, message);
577   gst_object_unref (device);
578 }
579
580
581 /**
582  * gst_device_provider_device_remove:
583  * @provider: a #GstDeviceProvider
584  * @device: a #GstDevice that has been removed
585  *
586  * Posts a message on the provider's #GstBus to inform applications that
587  * a device has been removed.
588  *
589  * This is for use by subclasses.
590  *
591  * Since: 1.4
592  */
593 void
594 gst_device_provider_device_remove (GstDeviceProvider * provider,
595     GstDevice * device)
596 {
597   GstMessage *message;
598   GList *item;
599
600   g_return_if_fail (GST_IS_DEVICE_PROVIDER (provider));
601   g_return_if_fail (GST_IS_DEVICE (device));
602
603   GST_OBJECT_LOCK (provider);
604   item = g_list_find (provider->devices, device);
605   if (item) {
606     provider->devices = g_list_delete_link (provider->devices, item);
607   }
608   GST_OBJECT_UNLOCK (provider);
609
610   message = gst_message_new_device_removed (GST_OBJECT (provider), device);
611   g_signal_emit_by_name (device, "removed");
612   gst_bus_post (provider->priv->bus, message);
613   if (item)
614     gst_object_unparent (GST_OBJECT (device));
615 }
616
617 /**
618  * gst_device_provider_get_hidden_providers:
619  * @provider: a #GstDeviceProvider
620  *
621  * Get the provider factory names of the #GstDeviceProvider instances that
622  * are hidden by @provider.
623  *
624  * Returns: (transfer full) (array zero-terminated=1) (element-type gchar*):
625  *   a list of hidden providers factory names or %NULL when
626  *   nothing is hidden by @provider. Free with g_strfreev.
627  *
628  * Since: 1.6
629  */
630 gchar **
631 gst_device_provider_get_hidden_providers (GstDeviceProvider * provider)
632 {
633   GList *walk;
634   guint i, len;
635   gchar **res = NULL;
636
637   g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), NULL);
638
639   GST_OBJECT_LOCK (provider);
640   len = g_list_length (provider->priv->hidden_providers);
641   if (len == 0)
642     goto done;
643
644   res = g_new (gchar *, len + 1);
645   for (i = 0, walk = provider->priv->hidden_providers; walk;
646       walk = g_list_next (walk), i++)
647     res[i] = g_strdup (walk->data);
648   res[i] = NULL;
649
650 done:
651   GST_OBJECT_UNLOCK (provider);
652
653   return res;
654 }
655
656 /**
657  * gst_device_provider_hide_provider:
658  * @provider: a #GstDeviceProvider
659  * @name: a provider factory name
660  *
661  * Make @provider hide the devices from the factory with @name.
662  *
663  * This function is used when @provider will also provide the devices reported
664  * by provider factory @name. A monitor should stop monitoring the
665  * device provider with @name to avoid duplicate devices.
666  *
667  * Since: 1.6
668  */
669 void
670 gst_device_provider_hide_provider (GstDeviceProvider * provider,
671     const gchar * name)
672 {
673   GList *find;
674   const gchar *hidden_name = NULL;
675
676   g_return_if_fail (GST_IS_DEVICE_PROVIDER (provider));
677   g_return_if_fail (name != NULL);
678
679   GST_OBJECT_LOCK (provider);
680   find =
681       g_list_find_custom (provider->priv->hidden_providers, name,
682       (GCompareFunc) g_strcmp0);
683   if (find == NULL) {
684     hidden_name = name;
685     provider->priv->hidden_providers =
686         g_list_prepend (provider->priv->hidden_providers, g_strdup (name));
687   }
688   GST_OBJECT_UNLOCK (provider);
689
690   if (hidden_name)
691     g_signal_emit (provider, gst_device_provider_signals[PROVIDER_HIDDEN],
692         0, hidden_name);
693 }
694
695 /**
696  * gst_device_provider_unhide_provider:
697  * @provider: a #GstDeviceProvider
698  * @name: a provider factory name
699  *
700  * Make @provider unhide the devices from factory @name.
701  *
702  * This function is used when @provider will no longer provide the devices
703  * reported by provider factory @name. A monitor should start
704  * monitoring the devices from provider factory @name in order to see
705  * all devices again.
706  *
707  * Since: 1.6
708  */
709 void
710 gst_device_provider_unhide_provider (GstDeviceProvider * provider,
711     const gchar * name)
712 {
713   GList *find;
714   gchar *unhidden_name = NULL;
715
716   g_return_if_fail (GST_IS_DEVICE_PROVIDER (provider));
717   g_return_if_fail (unhidden_name != NULL);
718
719   GST_OBJECT_LOCK (provider);
720   find =
721       g_list_find_custom (provider->priv->hidden_providers, name,
722       (GCompareFunc) g_strcmp0);
723   if (find) {
724     unhidden_name = find->data;
725     provider->priv->hidden_providers =
726         g_list_delete_link (provider->priv->hidden_providers, find);
727   }
728   GST_OBJECT_UNLOCK (provider);
729
730   if (unhidden_name) {
731     g_signal_emit (provider,
732         gst_device_provider_signals[PROVIDER_UNHIDDEN], 0, unhidden_name);
733     g_free (unhidden_name);
734   }
735 }