* @see_also: #GstDevice, #GstDeviceMonitor
*
* A #GstDeviceProvider subclass is provided by a plugin that handles devices
- * if there is a way to programatically list connected devices. It can also
+ * if there is a way to programmatically list connected devices. It can also
* optionally provide updates to the list of connected devices.
*
* Each #GstDeviceProvider subclass is a singleton, a plugin should
static void gst_device_provider_finalize (GObject * object);
static gpointer gst_device_provider_parent_class = NULL;
+static gint private_offset = 0;
GType
gst_device_provider_get_type (void)
_type = g_type_register_static (GST_TYPE_OBJECT, "GstDeviceProvider",
&element_info, G_TYPE_FLAG_ABSTRACT);
+ private_offset =
+ g_type_add_instance_private (_type, sizeof (GstDeviceProviderPrivate));
+
__gst_deviceproviderclass_factory =
g_quark_from_static_string ("GST_DEVICEPROVIDERCLASS_FACTORY");
g_once_init_leave (&gst_device_provider_type, _type);
return gst_device_provider_type;
}
+static inline gpointer
+gst_device_provider_get_instance_private (GstDeviceProvider * self)
+{
+ return (G_STRUCT_MEMBER_P (self, private_offset));
+}
+
static void
gst_device_provider_base_class_init (gpointer g_class)
{
gst_device_provider_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (GstDeviceProviderPrivate));
+ if (private_offset != 0)
+ g_type_class_adjust_private_offset (klass, &private_offset);
gobject_class->dispose = gst_device_provider_dispose;
gobject_class->finalize = gst_device_provider_finalize;
static void
gst_device_provider_init (GstDeviceProvider * provider)
{
- provider->priv = G_TYPE_INSTANCE_GET_PRIVATE (provider,
- GST_TYPE_DEVICE_PROVIDER, GstDeviceProviderPrivate);
+ provider->priv = gst_device_provider_get_instance_private (provider);
g_mutex_init (&provider->priv->start_lock);
*
* Get metadata with @key in @klass.
*
- * Returns: the metadata for @key.
+ * Returns: (nullable): the metadata for @key.
*
* Since: 1.4
*/
}
/**
+ * gst_device_provider_get_metadata:
+ * @provider: provider to get metadata for
+ * @key: the key to get
+ *
+ * Get metadata with @key in @provider.
+ *
+ * Returns: the metadata for @key.
+ *
+ * Since: 1.14
+ */
+const gchar *
+gst_device_provider_get_metadata (GstDeviceProvider * provider,
+ const gchar * key)
+{
+ g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), NULL);
+ g_return_val_if_fail (key != NULL, NULL);
+
+ return
+ gst_device_provider_class_get_metadata (GST_DEVICE_PROVIDER_GET_CLASS
+ (provider), key);
+}
+
+/**
* gst_device_provider_get_devices:
* @provider: A #GstDeviceProvider
*
g_mutex_lock (&provider->priv->start_lock);
if (provider->priv->started_count > 0) {
+ provider->priv->started_count++;
ret = TRUE;
goto started;
}
gchar *unhidden_name = NULL;
g_return_if_fail (GST_IS_DEVICE_PROVIDER (provider));
- g_return_if_fail (unhidden_name != NULL);
+ g_return_if_fail (name != NULL);
GST_OBJECT_LOCK (provider);
find =
g_free (unhidden_name);
}
}
+
+/**
+ * gst_device_provider_device_changed:
+ * @device: (transfer none): the new version of @changed_device
+ * @changed_device: (transfer floating): the old version of the device that has been udpated
+ *
+ * This function is used when @changed_device was modified into its new form
+ * @device. This will post a `DEVICE_CHANGED` message on the bus to let
+ * the application know that the device was modified. #GstDevice is immutable
+ * for MT. safety purposes so this is an "atomic" way of letting the application
+ * know when a device was modified.
+ *
+ * Since: 1.16
+ */
+void
+gst_device_provider_device_changed (GstDeviceProvider * provider,
+ GstDevice * device, GstDevice * changed_device)
+{
+ GList *dev_lst;
+ GstMessage *message;
+
+ g_return_if_fail (GST_IS_DEVICE_PROVIDER (provider));
+ g_return_if_fail (GST_IS_DEVICE (device));
+ g_return_if_fail (GST_IS_DEVICE (changed_device));
+
+ GST_OBJECT_LOCK (provider);
+ dev_lst = g_list_find (provider->devices, changed_device);
+ if (!dev_lst) {
+ GST_ERROR_OBJECT (provider,
+ "Trying to update a device we do not have in our own list!");
+
+ GST_OBJECT_UNLOCK (provider);
+ return;
+ }
+
+ if (!gst_object_set_parent (GST_OBJECT (device), GST_OBJECT (provider))) {
+ GST_OBJECT_UNLOCK (provider);
+ GST_WARNING_OBJECT (provider, "Could not parent device %p to provider,"
+ " it already has a parent", device);
+ return;
+ }
+ dev_lst->data = device;
+ GST_OBJECT_UNLOCK (provider);
+
+ message =
+ gst_message_new_device_changed (GST_OBJECT (provider), device,
+ changed_device);
+ gst_bus_post (provider->priv->bus, message);
+ gst_object_unparent (GST_OBJECT (changed_device));
+}