From c3328094e84eb8dc79eeade22d7e720063be90c7 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Fri, 28 Nov 2003 13:04:21 +0000 Subject: [PATCH] Use new tagging stuff to read and write flac metadata. Only handles vorbiscomment tags, and not (older) id3v2 tags. Original commit message from CVS: Use new tagging stuff to read and write flac metadata. Only handles vorbiscomment tags, and not (older) id3v2 tags. --- ext/vorbis/vorbisenc.c | 1 - gst/tags/gsttagediting.h | 7 ++++++- gst/tags/gstvorbistag.c | 30 ++++++++++++++++++++++++------ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/ext/vorbis/vorbisenc.c b/ext/vorbis/vorbisenc.c index 05c0746b8f..3649e8bb9d 100644 --- a/ext/vorbis/vorbisenc.c +++ b/ext/vorbis/vorbisenc.c @@ -55,7 +55,6 @@ enum ARG_MIN_BITRATE, ARG_QUALITY, ARG_SERIAL, - ARG_METADATA, ARG_MANAGED, ARG_LAST_MESSAGE, }; diff --git a/gst/tags/gsttagediting.h b/gst/tags/gsttagediting.h index be0e298754..7bf968eb29 100644 --- a/gst/tags/gsttagediting.h +++ b/gst/tags/gsttagediting.h @@ -30,7 +30,12 @@ G_BEGIN_DECLS G_CONST_RETURN gchar * gst_tag_from_vorbis_tag (const gchar * vorbis_tag); G_CONST_RETURN gchar * gst_tag_to_vorbis_tag (const gchar * gst_tag); -void gst_vorbis_tag_add (GstTagList *list, const gchar *tag, const gchar *value); +void gst_vorbis_tag_add (GstTagList * list, + const gchar * tag, + const gchar * value); + +GList * gst_tag_to_vorbis_comments (const GstTagList * list, + const gchar * tag); /* functions to convert GstBuffers with vorbiscomment contents to GstTagLists and back */ GstTagList * gst_tag_list_from_vorbiscomment_buffer (const GstBuffer * buffer, diff --git a/gst/tags/gstvorbistag.c b/gst/tags/gstvorbistag.c index f0c8fff18f..d2fbfa81c7 100644 --- a/gst/tags/gstvorbistag.c +++ b/gst/tags/gstvorbistag.c @@ -383,15 +383,16 @@ typedef struct { guint data_count; GList *entries; } MyForEach; -static void -write_one_tag (const GstTagList *list, const gchar *tag, gpointer user_data) + +GList * +gst_tag_to_vorbis_comments (const GstTagList *list, const gchar *tag) { gchar *result; + GList *l = NULL; guint i; const gchar *vorbis_tag = gst_tag_to_vorbis_tag (tag); - MyForEach *data = (MyForEach *) user_data; - if (!vorbis_tag) return; + if (!vorbis_tag) return NULL; for (i = 0; i < gst_tag_list_get_tag_size (list, tag); i++) { switch (gst_tag_get_type (tag)) { case G_TYPE_UINT: @@ -420,11 +421,28 @@ write_one_tag (const GstTagList *list, const gchar *tag, gpointer user_data) } default: GST_DEBUG ("Couldn't write tag %s", tag); - return; + continue; } + l = g_list_prepend (l, result); + } + + return g_list_reverse (l); +} + +static void +write_one_tag (const GstTagList *list, const gchar *tag, gpointer user_data) +{ + MyForEach *data = (MyForEach *) user_data; + GList *comments; + GList *it; + + comments = gst_tag_to_vorbis_comments (list, tag); + + for (it = comments; it != NULL; it = it->next) { + gchar *result = it->data; data->count ++; data->data_count += strlen (result); - data->entries = g_list_prepend (data->entries, result); + data->entries = g_list_prepend (data->entries, result); } } /**