static gboolean gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry2);
static GList* gst_props_list_copy (GList *propslist);
+static void
+transform_func (const GValue *src_value,
+ GValue *dest_value)
+{
+ GstProps *props = g_value_peek_pointer (src_value);
+ GString *result = g_string_new ("");
+ GList *propslist = props->properties;
+
+ while (propslist) {
+ GstPropsEntry *entry = (GstPropsEntry *)propslist->data;
+ const gchar *name = g_quark_to_string (entry->propid);
+
+ switch (entry->propstype) {
+ case GST_PROPS_STRING_TYPE:
+ g_string_append_printf (result, "%s='%s'", name, entry->data.string_data.string);
+ default:
+ break;
+ }
+
+ propslist = g_list_next (propslist);
+ if (propslist) {
+ g_string_append (result, "; ");
+ }
+ }
+ dest_value->data[0].v_pointer = result->str;
+}
+
void
_gst_props_initialize (void)
(GBoxedCopyFunc) gst_props_ref,
(GBoxedFreeFunc) gst_props_unref);
+ g_value_register_transform_func (_gst_props_type,
+ G_TYPE_STRING,
+ transform_func);
}
static void
GST_DEBUG (GST_CAT_PROPERTIES, "%s: bool %d", name, entry->data.bool_data);
break;
case GST_PROPS_STRING_TYPE:
- GST_DEBUG (GST_CAT_PROPERTIES, "%s: string %s", name, entry->data.string_data.string);
+ GST_DEBUG (GST_CAT_PROPERTIES, "%s: string \"%s\"", name, entry->data.string_data.string);
break;
case GST_PROPS_INT_RANGE_TYPE:
GST_DEBUG (GST_CAT_PROPERTIES, "%s: int range %d-%d", name, entry->data.int_range_data.min,
/* This is implemented as a huge macro because we cannot pass
* va_list variables by reference on some architectures.
*/
-#define GST_PROPS_ENTRY_FILL(entry, var_args) \
+#define GST_PROPS_ENTRY_FILL(entry, var_args) \
G_STMT_START { \
entry->propstype = va_arg (var_args, GstPropsType); \
\
case GST_PROPS_STRING_TYPE: \
entry->data.string_data.string = g_strdup (va_arg (var_args, gchar*)); \
break; \
+ case GST_PROPS_GLIST_TYPE: \
+ entry->propstype = GST_PROPS_LIST_TYPE; \
+ entry->data.list_data.entries = g_list_copy (va_arg (var_args, GList*)); \
+ break; \
default: \
break; \
} \
entry = gst_props_alloc_entry ();
entry->propid = g_quark_from_string (name);
GST_PROPS_ENTRY_FILL (entry, var_args);
-
+
return entry;
}
va_end (var_args);
}
else {
- g_print("gstprops: no property '%s' to change\n", name);
+ g_warning ("gstprops: no property '%s' to change\n", name);
}
return props;
return result;
}
+static gboolean
+gst_props_getv (GstProps *props, gboolean safe, gchar *first_name, va_list var_args)
+{
+ while (first_name) {
+ const GstPropsEntry *entry = gst_props_get_entry (props, first_name);
+ gboolean result;
+
+ if (!entry) return FALSE;
+ GST_PROPS_ENTRY_READ (entry, var_args, FALSE, &result);
+ if (!result) return FALSE;
+
+ first_name = va_arg (var_args, gchar *);
+ }
+ return TRUE;
+}
+
/**
* gst_props_get:
* @props: the props to query
gst_props_get (GstProps *props, gchar *first_name, ...)
{
va_list var_args;
+ gboolean ret;
va_start (var_args, first_name);
+ ret = gst_props_getv (props, FALSE, first_name, var_args);
+ va_end (var_args);
+
+ return ret;
+}
- while (first_name) {
- const GstPropsEntry *entry = gst_props_get_entry (props, first_name);
- gboolean result;
-
- if (!entry) return FALSE;
- GST_PROPS_ENTRY_READ (entry, var_args, FALSE, &result);
- if (!result) return FALSE;
+/**
+ * gst_props_get_safe:
+ * @props: the props to query
+ * @first_name: the first key
+ * @...: a pointer to a datastructure that can hold the value.
+ *
+ * Gets the contents of the props into given key/value pairs.
+ *
+ * Returns: TRUE is the props entry could be fetched.
+ */
+gboolean
+gst_props_get_safe (GstProps *props, gchar *first_name, ...)
+{
+ va_list var_args;
+ gboolean ret;
- first_name = va_arg (var_args, gchar *);
- }
+ va_start (var_args, first_name);
+ ret = gst_props_getv (props, TRUE, first_name, var_args);
va_end (var_args);
- return TRUE;
+ return ret;
}
/**
if (intersectentry) {
if (intersectentry->propstype == GST_PROPS_LIST_TYPE) {
- intersection = g_list_concat (intersection, intersectentry->data.list_data.entries);
+ intersection = g_list_concat (intersection,
+ g_list_copy (intersectentry->data.list_data.entries));
/* set the list to NULL because the entries are concatenated to the above
* list and we don't want to free them */
intersectentry->data.list_data.entries = NULL;