/**
* SECTION:gstdeviceprovider
+ * @title: GstDeviceProvider
* @short_description: A device provider
* @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_class_init (GstDeviceProviderClass * klass);
static void gst_device_provider_init (GstDeviceProvider * element);
static void gst_device_provider_base_class_init (gpointer g_class);
-static void gst_device_provider_base_class_finalize (gpointer g_class);
static void gst_device_provider_dispose (GObject * object);
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)
static const GTypeInfo element_info = {
sizeof (GstDeviceProviderClass),
gst_device_provider_base_class_init,
- gst_device_provider_base_class_finalize,
+ NULL, /* base_class_finalize */
(GClassInitFunc) gst_device_provider_class_init,
NULL,
NULL,
_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)
{
}
static void
-gst_device_provider_base_class_finalize (gpointer g_class)
-{
- GstDeviceProviderClass *klass = GST_DEVICE_PROVIDER_CLASS (g_class);
-
- gst_structure_free (klass->metadata);
-}
-
-static void
gst_device_provider_class_init (GstDeviceProviderClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
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);
* multiple author metadata. E.g: "Joe Bloggs <joe.blogs at foo.com>"
*
* Sets the detailed information for a #GstDeviceProviderClass.
- * <note>This function is for use in _class_init functions only.</note>
+ *
+ * > This function is for use in _class_init functions only.
*
* Since: 1.4
*/
* foo.com>"
*
* Sets the detailed information for a #GstDeviceProviderClass.
- * <note>This function is for use in _class_init functions only.</note>
+ *
+ * > This function is for use in _class_init functions only.
*
* Same as gst_device_provider_class_set_metadata(), but @longname, @classification,
* @description, and @author must be static strings or inlined strings, as
*
* 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;
}
/**
* gst_device_provider_device_add:
* @provider: a #GstDeviceProvider
- * @device: (transfer full): a #GstDevice that has been added
+ * @device: (transfer floating): a #GstDevice that has been added
*
* Posts a message on the provider's #GstBus to inform applications that
* a new device has been added.
*
* This is for use by subclasses.
*
+ * @device's reference count will be incremented, and any floating reference
+ * will be removed (see gst_object_ref_sink()).
+ *
* Since: 1.4
*/
void
}
GST_OBJECT_LOCK (provider);
- provider->devices = g_list_prepend (provider->devices,
- gst_object_ref (device));
+ /* Take an additional reference so we can be sure nobody removed it from the
+ * provider in the meantime and we can safely emit the message */
+ gst_object_ref (device);
+ provider->devices = g_list_prepend (provider->devices, device);
GST_OBJECT_UNLOCK (provider);
message = gst_message_new_device_added (GST_OBJECT (provider), device);
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 =