From: Tim-Philipp Müller Date: Sun, 30 Oct 2011 09:58:16 +0000 (+0000) Subject: taglist: add to_string and new_from_string functions X-Git-Tag: RELEASE-0.10.36~97 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=606c53fc94a62e46443a8115adf0387d19972c6b;p=platform%2Fupstream%2Fgstreamer.git taglist: add to_string and new_from_string functions We want to make GstTagList opaque and not have people use GstStructure API on it. API: gst_tag_list_to_string() API: gst_tag_list_new_from_string() --- diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 5373972..b9500b7 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -2366,6 +2366,8 @@ gst_tag_is_fixed gst_tag_list_new gst_tag_list_new_full gst_tag_list_new_full_valist +gst_tag_list_new_from_string +gst_tag_list_to_string gst_is_tag_list gst_tag_list_is_empty gst_tag_list_is_equal diff --git a/gst/gsttaglist.c b/gst/gsttaglist.c index 0de5a64..566a4e0 100644 --- a/gst/gsttaglist.c +++ b/gst/gsttaglist.c @@ -698,6 +698,44 @@ gst_tag_list_new_full_valist (va_list var_args) } /** + * gst_tag_list_to_string: + * @list: a #GstTagList + * + * Serializes a tag list to a string. + * + * Returns: a newly-allocated string, or NULL in case of an error. The + * string must be freed with g_free() when no longer needed. + * + * Since: 0.10.36 + */ +gchar * +gst_tag_list_to_string (const GstTagList * list) +{ + g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL); + + return gst_structure_to_string (GST_STRUCTURE (list)); +} + +/** + * gst_tag_list_new_from_string: + * @str: a string created with gst_tag_list_to_string() + * + * Deserializes a tag list. + * + * Returns: a new #GstTagList, or NULL in case of an error. + * + * Since: 0.10.36 + */ +GstTagList * +gst_tag_list_new_from_string (const gchar * str) +{ + 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)); +} + +/** * gst_tag_list_is_empty: * @list: A #GstTagList. * diff --git a/gst/gsttaglist.h b/gst/gsttaglist.h index cc0601f..92b9388 100644 --- a/gst/gsttaglist.h +++ b/gst/gsttaglist.h @@ -215,6 +215,9 @@ GstTagList * gst_tag_list_new (void); GstTagList * gst_tag_list_new_full (const gchar * tag, ...); GstTagList * gst_tag_list_new_full_valist (va_list var_args); +gchar * gst_tag_list_to_string (const GstTagList * list); +GstTagList * gst_tag_list_new_from_string (const gchar * str); + gboolean gst_is_tag_list (gconstpointer p); GstTagList * gst_tag_list_copy (const GstTagList * list); gboolean gst_tag_list_is_empty (const GstTagList * list); diff --git a/tests/check/gst/gsttag.c b/tests/check/gst/gsttag.c index 7efcf2c..30a352e 100644 --- a/tests/check/gst/gsttag.c +++ b/tests/check/gst/gsttag.c @@ -274,11 +274,11 @@ GST_START_TEST (test_date_tags) tag_list = gst_tag_list_new (); gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, GST_TAG_DATE, date, NULL); - str = gst_structure_to_string (tag_list); + str = gst_tag_list_to_string (tag_list); fail_if (str == NULL); fail_if (strstr (str, "2005-10-14") == NULL); - tag_list2 = gst_structure_from_string (str, NULL); + tag_list2 = gst_tag_list_new_from_string (str); fail_if (tag_list2 == NULL); fail_if (!gst_tag_list_get_date (tag_list2, GST_TAG_DATE, &date2)); fail_unless (gst_tag_list_is_equal (tag_list2, tag_list)); diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index e0f60af..3c3084a 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -1086,10 +1086,12 @@ EXPORTS gst_tag_list_is_equal gst_tag_list_merge gst_tag_list_new + gst_tag_list_new_from_string gst_tag_list_new_full gst_tag_list_new_full_valist gst_tag_list_peek_string_index gst_tag_list_remove_tag + gst_tag_list_to_string gst_tag_merge_mode_get_type gst_tag_merge_strings_with_comma gst_tag_merge_use_first