From a5b0ad8834a7f3c227232a05c3d33d3d5947339e Mon Sep 17 00:00:00 2001 From: Tim-Philipp Müller Date: Mon, 15 May 2006 09:00:42 +0000 Subject: ext/taglib/gstid3v2mux.cc: Add support for writing images (APIC frames) into ID3v2 tags (picture type always set to '... Original commit message from CVS: * ext/taglib/gstid3v2mux.cc: Add support for writing images (APIC frames) into ID3v2 tags (picture type always set to 'other' for now though). --- ChangeLog | 6 ++++++ common | 2 +- ext/taglib/gstid3v2mux.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cf15e40a..e5e0841b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-05-15 Tim-Philipp Müller + + * ext/taglib/gstid3v2mux.cc: + Add support for writing images (APIC frames) into ID3v2 + tags (picture type always set to 'other' for now though). + 2006-05-14 Michael Smith * gst/wavparse/gstwavparse.c: diff --git a/common b/common index e41606ab..3062df90 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit e41606ab2c6a31be473de511b5fd776bd2593b56 +Subproject commit 3062df90281144cbdb55bd58ee9f0714ab346c23 diff --git a/ext/taglib/gstid3v2mux.cc b/ext/taglib/gstid3v2mux.cc index a1e4537e..e77cb749 100644 --- a/ext/taglib/gstid3v2mux.cc +++ b/ext/taglib/gstid3v2mux.cc @@ -59,6 +59,7 @@ #include #include +#include #include #include @@ -316,6 +317,49 @@ add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data) id3v2tag->addFrame (frame); g_free (id_str); } + } else if (strcmp (tag, GST_TAG_IMAGE) == 0) { + const GValue *val; + GstBuffer *image; + + GST_LOG ("image tag"); + val = gst_tag_list_get_value_index (list, tag, 0); + image = (GstBuffer *) gst_value_get_mini_object (val); + if (GST_IS_BUFFER (image) && GST_BUFFER_SIZE (image) > 0 && + GST_BUFFER_CAPS (image) != NULL && + !gst_caps_is_empty (GST_BUFFER_CAPS (image))) { + const gchar *mime_type; + GstStructure *s; + + s = gst_caps_get_structure (GST_BUFFER_CAPS (image), 0); + mime_type = gst_structure_get_name (s); + if (mime_type != NULL) { + ID3v2::AttachedPictureFrame * frame; + const gchar *desc; + + if (strcmp (mime_type, "text/uri-list") == 0) + mime_type = "-->"; + + frame = new ID3v2::AttachedPictureFrame (); + + GST_DEBUG ("Attaching picture of %u bytes and mime type %s", + GST_BUFFER_SIZE (image), mime_type); + + id3v2tag->addFrame (frame); + frame->setPicture (ByteVector ((const char *) GST_BUFFER_DATA (image), + GST_BUFFER_SIZE (image))); + frame->setTextEncoding (String::UTF8); + frame->setMimeType (mime_type); + + desc = gst_structure_get_string (s, "image-description"); + frame->setDescription ((desc) ? desc : ""); + + /* FIXME */ + frame->setType (ID3v2::AttachedPictureFrame::Other); + } + } else { + GST_WARNING ("NULL image or no caps on image buffer (%p, caps=%" + GST_PTR_FORMAT ")", image, (image) ? GST_BUFFER_CAPS (image) : NULL); + } } else { GST_WARNING ("Unsupported tag: %s", tag); } -- cgit