/* a tag list is basically a structure, but we don't make this fact public */
struct _GstTagList
{
- GstStructure structure;
+ GType type;
+ GstStructure *structure;
};
/* FIXME 0.11: use GParamSpecs or something similar for tag registrations,
return info->merge_func == NULL;
}
+/* takes ownership of the structure */
+static GstTagList *
+gst_tag_list_new_internal (GstStructure * s)
+{
+ GstTagList *tag_list;
+
+ g_assert (s != NULL);
+
+ tag_list = g_slice_new0 (GstTagList);
+ tag_list->type = GST_TYPE_TAG_LIST;
+ tag_list->structure = s;
+ return tag_list;
+}
+
/**
* gst_tag_list_new_empty:
*
GstTagList *
gst_tag_list_new_empty (void)
{
- return GST_TAG_LIST (gst_structure_new_id_empty (GST_QUARK (TAGLIST)));
+ GstStructure *s;
+ GstTagList *tag_list;
+
+ s = gst_structure_new_id_empty (GST_QUARK (TAGLIST));
+ tag_list = gst_tag_list_new_internal (s);
+ return tag_list;
}
/**
{
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
- return gst_structure_to_string (GST_STRUCTURE (list));
+ return gst_structure_to_string (list->structure);
}
/**
GstTagList *
gst_tag_list_new_from_string (const gchar * str)
{
+ GstTagList *tag_list;
+
g_return_val_if_fail (str != NULL, NULL);
g_return_val_if_fail (g_str_has_prefix (str, "taglist"), NULL);
- return GST_TAG_LIST (gst_structure_from_string (str, NULL));
+ tag_list = gst_tag_list_new_internal (gst_structure_from_string (str, NULL));
+ return tag_list;
}
/**
g_return_val_if_fail (list != NULL, 0);
g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
- return gst_structure_n_fields ((GstStructure *) list);
+ return gst_structure_n_fields (list->structure);
}
/**
g_return_val_if_fail (list != NULL, 0);
g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
- return gst_structure_nth_field_name ((GstStructure *) list, index);
+ return gst_structure_nth_field_name (list->structure, index);
}
/**
g_return_val_if_fail (list != NULL, FALSE);
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
- return (gst_structure_n_fields ((GstStructure *) list) == 0);
+ return (gst_structure_n_fields (list->structure) == 0);
}
static gboolean
/* we don't just use gst_structure_is_equal() here so we can add some
* tolerance for doubles, though maybe we should just add that to
* gst_value_compare_double() as well? */
- s1 = (const GstStructure *) list1;
- s2 = (const GstStructure *) list2;
+ s1 = list1->structure;
+ s2 = list2->structure;
num_fields1 = gst_structure_n_fields (s1);
num_fields2 = gst_structure_n_fields (s2);
/**
* gst_is_tag_list:
- * @p: Object that might be a taglist
+ * @taglist: Object that might be a taglist
*
* Checks if the given pointer is a taglist.
*
* Returns: TRUE, if the given pointer is a taglist
*/
gboolean
-gst_is_tag_list (gconstpointer p)
+gst_is_tag_list (GstTagList * taglist)
{
- GstStructure *s = (GstStructure *) p;
+ g_return_val_if_fail (taglist != NULL, FALSE);
- g_return_val_if_fail (p != NULL, FALSE);
-
- return (GST_IS_STRUCTURE (s) && s->name == GST_QUARK (TAGLIST));
+ return taglist->type == GST_TYPE_TAG_LIST;
}
typedef struct
gst_tag_list_add_value_internal (GstTagList * tag_list, GstTagMergeMode mode,
const gchar * tag, const GValue * value, GstTagInfo * info)
{
- GstStructure *list = GST_STRUCTURE (tag_list);
+ GstStructure *list = tag_list->structure;
const GValue *value2;
GQuark tag_quark;
data.list = into;
data.mode = mode;
if (mode == GST_TAG_MERGE_REPLACE_ALL) {
- gst_structure_remove_all_fields (GST_STRUCTURE (data.list));
+ gst_structure_remove_all_fields (into->structure);
}
- gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach,
- &data);
+ gst_structure_foreach (from->structure, gst_tag_list_copy_foreach, &data);
}
/**
{
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
- return GST_TAG_LIST (gst_structure_copy ((GstStructure *) list));
+
+ return gst_tag_list_new_internal (gst_structure_copy (list->structure));
}
/**
gst_tag_list_free (GstTagList * list)
{
g_return_if_fail (GST_IS_TAG_LIST (list));
- gst_structure_free ((GstStructure *) list);
+ gst_structure_free (list->structure);
+ g_slice_free (GstTagList, list);
}
/**
g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
- value = gst_structure_get_value ((GstStructure *) list, tag);
+ value = gst_structure_get_value (list->structure, tag);
if (value == NULL)
return 0;
if (G_VALUE_TYPE (value) != GST_TYPE_LIST)
g_return_if_fail (tag != NULL);
if (mode == GST_TAG_MERGE_REPLACE_ALL) {
- gst_structure_remove_all_fields (GST_STRUCTURE (list));
+ gst_structure_remove_all_fields (list->structure);
}
while (tag != NULL) {
g_return_if_fail (tag != NULL);
if (mode == GST_TAG_MERGE_REPLACE_ALL) {
- gst_structure_remove_all_fields (GST_STRUCTURE (list));
+ gst_structure_remove_all_fields (list->structure);
}
while (tag != NULL) {
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (tag != NULL);
- gst_structure_remove_field ((GstStructure *) list, tag);
+ gst_structure_remove_field (list->structure, tag);
}
typedef struct
data.func = func;
data.tag_list = list;
data.data = user_data;
- gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper,
- &data);
+ gst_structure_foreach (list->structure, structure_foreach_wrapper, &data);
}
/**
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
g_return_val_if_fail (tag != NULL, NULL);
- value = gst_structure_get_value ((GstStructure *) list, tag);
+ value = gst_structure_get_value (list->structure, tag);
if (value == NULL)
return NULL;
g_return_val_if_fail (dest != NULL, FALSE);
g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE);
- src = gst_structure_get_value ((GstStructure *) list, tag);
+ src = gst_structure_get_value (list->structure, tag);
if (!src)
return FALSE;