From 81d46b82779e8672b48d5cc3e94d59e54838afd8 Mon Sep 17 00:00:00 2001 From: Tim-Philipp Müller Date: Wed, 16 Aug 2006 13:01:32 +0000 Subject: configure.ac: Require CVS of GStreamer core and -base (for Original commit message from CVS: * configure.ac: Require CVS of GStreamer core and -base (for GST_TAG_EXTENDED_COMMENT and gst_tag_parse_extended_comment()). * ext/taglib/gstid3v2mux.cc: Write extended comment tags properly (#348762). * gst/id3demux/id3v2frames.c: (id3demux_id3v2_parse_frame), (parse_comment_frame): Extract COMM frames into extended comments, which makes it easier to properly retain the description bit of the tag and maintain this information when re-tagging (#348762). --- gst/id3demux/id3v2frames.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'gst/id3demux') diff --git a/gst/id3demux/id3v2frames.c b/gst/id3demux/id3v2frames.c index b2e3353b..4e98a5eb 100644 --- a/gst/id3demux/id3v2frames.c +++ b/gst/id3demux/id3v2frames.c @@ -37,7 +37,7 @@ GST_DEBUG_CATEGORY_EXTERN (id3demux_debug); #define GST_CAT_DEFAULT (id3demux_debug) -static gchar *parse_comment_frame (ID3TagsWorking * work); +static gboolean parse_comment_frame (ID3TagsWorking * work); static GArray *parse_text_identification_frame (ID3TagsWorking * work); static gchar *parse_user_text_identification_frame (ID3TagsWorking * work, const gchar ** tag_name); @@ -156,7 +156,7 @@ id3demux_id3v2_parse_frame (ID3TagsWorking * work) } } else if (!strcmp (work->frame_id, "COMM")) { /* Comment */ - tag_str = parse_comment_frame (work); + result = parse_comment_frame (work); } else if (!strcmp (work->frame_id, "APIC")) { /* Attached picture */ result = parse_picture_frame (work); @@ -195,17 +195,17 @@ id3demux_id3v2_parse_frame (ID3TagsWorking * work) return result; } -static gchar * +static gboolean parse_comment_frame (ID3TagsWorking * work) { + guint dummy; guint8 encoding; gchar language[4]; GArray *fields = NULL; - gchar *out_str = NULL; gchar *description, *text; if (work->parse_size < 6) - return NULL; + return FALSE; encoding = work->parse_data[0]; language[0] = work->parse_data[1]; @@ -226,19 +226,37 @@ parse_comment_frame (ID3TagsWorking * work) if (!g_utf8_validate (text, -1, NULL)) { GST_WARNING ("Converted string is not valid utf-8"); goto fail; - } else { - if (strlen (description) > 0 && g_utf8_validate (description, -1, NULL)) { - out_str = g_strdup_printf ("Description: %s\nComment: %s", - description, text); + } + + /* skip our own dummy descriptions (from id3v2mux) */ + if (strlen (description) > 0 && g_utf8_validate (description, -1, NULL) && + sscanf (description, "c%u", &dummy) != 1) { + gchar *s; + + if (language[0] != '\0') { + s = g_strdup_printf ("%s[%s]=%s", description, language, text); } else { - out_str = g_strdup (text); + s = g_strdup_printf ("%s=%s", description, text); } + gst_tag_list_add (work->tags, GST_TAG_MERGE_APPEND, + GST_TAG_EXTENDED_COMMENT, s, NULL); + g_free (s); + } else if (text != NULL && *text != '\0') { + gst_tag_list_add (work->tags, GST_TAG_MERGE_APPEND, + GST_TAG_COMMENT, text, NULL); + } else { + goto fail; } -fail: free_tag_strings (fields); + return TRUE; - return out_str; +fail: + { + GST_WARNING ("failed to parse COMM frame"); + free_tag_strings (fields); + return FALSE; + } } static GArray * -- cgit