summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2015-07-15 18:21:13 +0200
committerWim Taymans <wtaymans@redhat.com>2015-07-15 18:21:13 +0200
commit661a1947b1693968427d0c828491b0d0b8280d91 (patch)
treed7b00622c3ba3e06400de09e28e34bd43fd5b50f
parenta7ea17a83d7a67205aeeb2ca4eefb14955995075 (diff)
device: add generic struct with properties
Add a generic structure to hold any additional properties about the device.
-rw-r--r--gst/gstdevice.c41
-rw-r--r--gst/gstdevice.h27
-rw-r--r--win32/common/libgstreamer.def1
3 files changed, 55 insertions, 14 deletions
diff --git a/gst/gstdevice.c b/gst/gstdevice.c
index 6274c93af..ee926196c 100644
--- a/gst/gstdevice.c
+++ b/gst/gstdevice.c
@@ -46,7 +46,8 @@ enum
{
PROP_DISPLAY_NAME = 1,
PROP_CAPS,
- PROP_DEVICE_CLASS
+ PROP_DEVICE_CLASS,
+ PROP_PROPERTIES
};
enum
@@ -60,6 +61,7 @@ struct _GstDevicePrivate
GstCaps *caps;
gchar *device_class;
gchar *display_name;
+ GstStructure *properties;
};
@@ -97,6 +99,10 @@ gst_device_class_init (GstDeviceClass * klass)
g_param_spec_string ("device-class", "Device Class",
"The Class of the device", "",
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_PROPERTIES,
+ g_param_spec_boxed ("properties", "Properties",
+ "The extra properties of the device", GST_TYPE_STRUCTURE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
signals[REMOVED] = g_signal_new ("removed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
@@ -116,6 +122,8 @@ gst_device_finalize (GObject * object)
gst_caps_replace (&device->priv->caps, NULL);
+ if (device->priv->properties)
+ gst_structure_free (device->priv->properties);
g_free (device->priv->display_name);
g_free (device->priv->device_class);
@@ -141,6 +149,10 @@ gst_device_get_property (GObject * object, guint prop_id,
case PROP_DEVICE_CLASS:
g_value_take_string (value, gst_device_get_device_class (gstdevice));
break;
+ case PROP_PROPERTIES:
+ if (gstdevice->priv->properties)
+ g_value_take_boxed (value, gst_device_get_properties (gstdevice));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -166,6 +178,11 @@ gst_device_set_property (GObject * object, guint prop_id,
case PROP_DEVICE_CLASS:
gstdevice->priv->device_class = g_value_dup_string (value);
break;
+ case PROP_PROPERTIES:
+ if (gstdevice->priv->properties)
+ gst_structure_free (gstdevice->priv->properties);
+ gstdevice->priv->properties = g_value_dup_boxed (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -263,6 +280,28 @@ gst_device_get_device_class (GstDevice * device)
}
/**
+ * gst_device_get_properties:
+ * @device: a #GstDevice
+ *
+ * Gets the extra properties of a device.
+ *
+ * Returns: The extra properties or %NULL when there are none.
+ * Free with gst_structure_free() after use.
+ *
+ * Since: 1.6
+ */
+GstStructure *
+gst_device_get_properties (GstDevice * device)
+{
+ g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
+
+ if (device->priv->properties != NULL)
+ return gst_structure_copy (device->priv->properties);
+ else
+ return NULL;
+}
+
+/**
* gst_device_reconfigure_element:
* @device: a #GstDevice
* @element: a #GstElement
diff --git a/gst/gstdevice.h b/gst/gstdevice.h
index b055aa09b..79eb90860 100644
--- a/gst/gstdevice.h
+++ b/gst/gstdevice.h
@@ -77,28 +77,29 @@ struct _GstDevice {
struct _GstDeviceClass {
GstObjectClass parent_class;
- GstElement * (*create_element) (GstDevice * device, const gchar * name);
- gboolean (*reconfigure_element) (GstDevice * device, GstElement * element);
+ GstElement * (*create_element) (GstDevice * device, const gchar * name);
+ gboolean (*reconfigure_element) (GstDevice * device, GstElement * element);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_device_get_type (void);
+GType gst_device_get_type (void);
-GstElement * gst_device_create_element (GstDevice * device, const gchar * name);
+GstElement * gst_device_create_element (GstDevice * device, const gchar * name);
-GstCaps * gst_device_get_caps (GstDevice * device);
-gchar * gst_device_get_display_name (GstDevice * device);
-gchar * gst_device_get_device_class (GstDevice * device);
-gboolean gst_device_reconfigure_element (GstDevice * device,
- GstElement * element);
+GstCaps * gst_device_get_caps (GstDevice * device);
+gchar * gst_device_get_display_name (GstDevice * device);
+gchar * gst_device_get_device_class (GstDevice * device);
+GstStructure * gst_device_get_properties (GstDevice * device);
+gboolean gst_device_reconfigure_element (GstDevice * device,
+ GstElement * element);
-gboolean gst_device_has_classesv (GstDevice * device,
- gchar ** classes);
+gboolean gst_device_has_classesv (GstDevice * device,
+ gchar ** classes);
-gboolean gst_device_has_classes (GstDevice * device,
- const gchar * classes);
+gboolean gst_device_has_classes (GstDevice * device,
+ const gchar * classes);
G_END_DECLS
diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def
index 7f02bae81..f5edbda7f 100644
--- a/win32/common/libgstreamer.def
+++ b/win32/common/libgstreamer.def
@@ -428,6 +428,7 @@ EXPORTS
gst_device_get_caps
gst_device_get_device_class
gst_device_get_display_name
+ gst_device_get_properties
gst_device_get_type
gst_device_has_classes
gst_device_has_classesv