summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gst/gstdevicemonitor.c127
-rw-r--r--gst/gstdevicemonitor.h3
-rw-r--r--win32/common/libgstreamer.def2
3 files changed, 119 insertions, 13 deletions
diff --git a/gst/gstdevicemonitor.c b/gst/gstdevicemonitor.c
index 5d3c3ee7d..2f62c806f 100644
--- a/gst/gstdevicemonitor.c
+++ b/gst/gstdevicemonitor.c
@@ -109,8 +109,15 @@ struct _GstDeviceMonitorPrivate
guint last_id;
GList *hidden;
+ gboolean show_all;
};
+#define DEFAULT_SHOW_ALL FALSE
+
+enum
+{
+ PROP_SHOW_ALL = 1,
+};
G_DEFINE_TYPE (GstDeviceMonitor, gst_device_monitor, GST_TYPE_OBJECT);
@@ -134,21 +141,67 @@ device_filter_free (struct DeviceFilter *filter)
}
static void
+gst_device_monitor_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstDeviceMonitor *monitor = GST_DEVICE_MONITOR (object);
+
+ switch (prop_id) {
+ case PROP_SHOW_ALL:
+ g_value_set_boolean (value,
+ gst_device_monitor_get_show_all_devices (monitor));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_device_monitor_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstDeviceMonitor *monitor = GST_DEVICE_MONITOR (object);
+
+ switch (prop_id) {
+ case PROP_SHOW_ALL:
+ gst_device_monitor_set_show_all_devices (monitor,
+ g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+static void
gst_device_monitor_class_init (GstDeviceMonitorClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (GstDeviceMonitorPrivate));
+ object_class->get_property = gst_device_monitor_get_property;
+ object_class->set_property = gst_device_monitor_set_property;
object_class->dispose = gst_device_monitor_dispose;
+
+ g_object_class_install_property (object_class, PROP_SHOW_ALL,
+ g_param_spec_boolean ("show-all", "Show All",
+ "Show all devices, even those from hidden providers",
+ DEFAULT_SHOW_ALL, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
}
/* must be called with monitor lock */
static gboolean
-is_provider_hidden (GList * hidden, GstDeviceProvider * provider)
+is_provider_hidden (GstDeviceMonitor * monitor, GList * hidden,
+ GstDeviceProvider * provider)
{
GstDeviceProviderFactory *factory;
+ if (monitor->priv->show_all)
+ return FALSE;
+
factory = gst_device_provider_get_factory (provider);
if (g_list_find_custom (hidden, GST_OBJECT_NAME (factory),
(GCompareFunc) g_strcmp0))
@@ -159,11 +212,11 @@ is_provider_hidden (GList * hidden, GstDeviceProvider * provider)
/* must be called with monitor lock */
static void
-update_hidden_list (GList ** hidden, GstDeviceProvider * provider)
+update_hidden_providers_list (GList ** hidden, GstDeviceProvider * provider)
{
gchar **obs;
- obs = gst_device_provider_get_hidden (provider);
+ obs = gst_device_provider_get_hidden_providers (provider);
if (obs) {
gint i;
@@ -193,7 +246,7 @@ bus_sync_message (GstBus * bus, GstMessage * message,
GST_OBJECT_LOCK (monitor);
provider =
GST_DEVICE_PROVIDER (gst_object_get_parent (GST_OBJECT (device)));
- if (is_provider_hidden (monitor->priv->hidden, provider)) {
+ if (is_provider_hidden (monitor, monitor->priv->hidden, provider)) {
matches = FALSE;
} else if (monitor->priv->filters->len) {
guint i;
@@ -229,6 +282,8 @@ gst_device_monitor_init (GstDeviceMonitor * self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
GST_TYPE_DEVICE_MONITOR, GstDeviceMonitorPrivate);
+ self->priv->show_all = DEFAULT_SHOW_ALL;
+
self->priv->bus = gst_bus_new ();
gst_bus_set_flushing (self->priv->bus, TRUE);
@@ -330,13 +385,13 @@ again:
gst_object_ref (g_ptr_array_index (monitor->priv->providers, i));
GList *item;
- if (!is_provider_hidden (hidden, provider)) {
+ if (!is_provider_hidden (monitor, hidden, provider)) {
GST_OBJECT_UNLOCK (monitor);
tmpdev = gst_device_provider_get_devices (provider);
GST_OBJECT_LOCK (monitor);
- update_hidden_list (&hidden, provider);
+ update_hidden_providers_list (&hidden, provider);
} else {
tmpdev = NULL;
}
@@ -525,7 +580,7 @@ gst_device_monitor_stop (GstDeviceMonitor * monitor)
}
static void
-hidden_added (GstDeviceProvider * provider, const gchar * hidden,
+hidden_provider_added (GstDeviceProvider * provider, const gchar * hidden,
GstDeviceMonitor * monitor)
{
GST_OBJECT_LOCK (monitor);
@@ -535,7 +590,7 @@ hidden_added (GstDeviceProvider * provider, const gchar * hidden,
}
static void
-hidden_removed (GstDeviceProvider * provider, const gchar * hidden,
+hidden_provider_removed (GstDeviceProvider * provider, const gchar * hidden,
GstDeviceMonitor * monitor)
{
GList *find;
@@ -616,11 +671,11 @@ gst_device_monitor_add_filter (GstDeviceMonitor * monitor,
if (provider) {
GstBus *bus = gst_device_provider_get_bus (provider);
- update_hidden_list (&monitor->priv->hidden, provider);
- g_signal_connect (provider, "hidden-added",
- (GCallback) hidden_added, monitor);
- g_signal_connect (provider, "hidden-removed",
- (GCallback) hidden_removed, monitor);
+ update_hidden_providers_list (&monitor->priv->hidden, provider);
+ g_signal_connect (provider, "hidden-provider-added",
+ (GCallback) hidden_provider_added, monitor);
+ g_signal_connect (provider, "hidden-provider-removed",
+ (GCallback) hidden_provider_removed, monitor);
matched = TRUE;
gst_bus_enable_sync_message_emission (bus);
@@ -795,3 +850,49 @@ done:
return res;
}
+
+/**
+ * gst_device_monitor_set_show_all_devices:
+ * @monitor: a #GstDeviceMonitor
+ * @show_all: show all devices
+ *
+ * Set if all devices should be visible, even those devices from hidden
+ * providers. Setting @show_all to true might show some devices multiple times.
+ *
+ * Since: 1.6
+ */
+void
+gst_device_monitor_set_show_all_devices (GstDeviceMonitor * monitor,
+ gboolean show_all)
+{
+ g_return_if_fail (GST_IS_DEVICE_MONITOR (monitor));
+
+ GST_OBJECT_LOCK (monitor);
+ monitor->priv->show_all = show_all;
+ GST_OBJECT_UNLOCK (monitor);
+}
+
+/**
+ * gst_device_monitor_get_show_all_devices:
+ * @monitor: a #GstDeviceMonitor
+ *
+ * Get if @monitor is curretly showing all devices, even those from hidden
+ * providers.
+ *
+ * Returns: %TRUE when all devices will be shown.
+ *
+ * Since: 1.6
+ */
+gboolean
+gst_device_monitor_get_show_all_devices (GstDeviceMonitor * monitor)
+{
+ gboolean res;
+
+ g_return_val_if_fail (GST_IS_DEVICE_MONITOR (monitor), FALSE);
+
+ GST_OBJECT_LOCK (monitor);
+ res = monitor->priv->show_all;
+ GST_OBJECT_UNLOCK (monitor);
+
+ return res;
+}
diff --git a/gst/gstdevicemonitor.h b/gst/gstdevicemonitor.h
index 5fe4677ad..4d9c014b7 100644
--- a/gst/gstdevicemonitor.h
+++ b/gst/gstdevicemonitor.h
@@ -97,6 +97,9 @@ gboolean gst_device_monitor_remove_filter (GstDeviceMonitor * monitor,
gchar ** gst_device_monitor_get_providers (GstDeviceMonitor * monitor);
+void gst_device_monitor_set_show_all_devices (GstDeviceMonitor * monitor, gboolean show_all);
+gboolean gst_device_monitor_get_show_all_devices (GstDeviceMonitor * monitor);
+
G_END_DECLS
#endif /* __GST_DEVICE_MONITOR_H__ */
diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def
index c280600dc..cce6f4447 100644
--- a/win32/common/libgstreamer.def
+++ b/win32/common/libgstreamer.def
@@ -436,9 +436,11 @@ EXPORTS
gst_device_monitor_get_bus
gst_device_monitor_get_devices
gst_device_monitor_get_providers
+ gst_device_monitor_get_show_all_devices
gst_device_monitor_get_type
gst_device_monitor_new
gst_device_monitor_remove_filter
+ gst_device_monitor_set_show_all_devices
gst_device_monitor_start
gst_device_monitor_stop
gst_device_provider_add_hidden_provider