diff options
author | Wim Taymans <wtaymans@redhat.com> | 2015-07-27 15:37:40 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2015-08-04 13:24:10 +0200 |
commit | 7c9c9c0279bc29cde1813308abb23adf29ac6c7e (patch) | |
tree | cb629347bcf8dcea3e02e424cbd650da13bec6cd | |
parent | 235771e4f9c0dcb1137638a69c8cfd6f57702d2b (diff) |
devicemonitor: add method to enable all devicesdevice-monitor-obsoleted
Add a property to see all devices, even duplicate ones from superseded
providers.
-rw-r--r-- | gst/gstdevicemonitor.c | 94 | ||||
-rw-r--r-- | gst/gstdevicemonitor.h | 4 | ||||
-rw-r--r-- | win32/common/libgstreamer.def | 2 |
3 files changed, 100 insertions, 0 deletions
diff --git a/gst/gstdevicemonitor.c b/gst/gstdevicemonitor.c index 7155b39e0..da0a67622 100644 --- a/gst/gstdevicemonitor.c +++ b/gst/gstdevicemonitor.c @@ -109,8 +109,15 @@ struct _GstDeviceMonitorPrivate guint last_id; GList *obsoleted; + gboolean show_all; }; +#define DEFAULT_SHOW_ALL FALSE + +enum +{ + PROP_SHOW_ALL = 1, +}; G_DEFINE_TYPE (GstDeviceMonitor, gst_device_monitor, GST_TYPE_OBJECT); @@ -134,13 +141,53 @@ 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 (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 (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 superseded providers", + DEFAULT_SHOW_ALL, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE)); } /* must be called with monitor lock */ @@ -229,6 +276,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); @@ -796,3 +845,48 @@ done: return res; } + +/** + * gst_device_monitor_set_show_all: + * @monitor: a #GstDeviceMonitor + * @show_all: show all devices + * + * Set if all devices should be visible, even those devices from superseded + * providers. Setting @show_all to true might show some devices multiple times. + * + * Since: 1.6 + */ +void +gst_device_monitor_set_show_all (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: + * @monitor: a #GstDeviceMonitor + * + * Get if @monitor is curretly showing all devices, even those from superseded + * providers. + * + * Returns: %TRUE when all devices will be shown. + * + * Since: 1.6 + */ +gboolean +gst_device_monitor_get_show_all (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..311cf660a 100644 --- a/gst/gstdevicemonitor.h +++ b/gst/gstdevicemonitor.h @@ -97,6 +97,10 @@ gboolean gst_device_monitor_remove_filter (GstDeviceMonitor * monitor, gchar ** gst_device_monitor_get_providers (GstDeviceMonitor * monitor); + +void gst_device_monitor_set_show_all (GstDeviceMonitor * monitor, gboolean show_all); +gboolean gst_device_monitor_get_show_all (GstDeviceMonitor * monitor); + G_END_DECLS #endif /* __GST_DEVICE_MONITOR_H__ */ diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index f9c2d4b4b..038be07ba 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 gst_device_monitor_get_type gst_device_monitor_new gst_device_monitor_remove_filter + gst_device_monitor_set_show_all gst_device_monitor_start gst_device_monitor_stop gst_device_provider_add_obsoleted |