From 2ce2017650bed25e1b090933b79b845276023964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 16 Dec 2013 11:51:00 +0100 Subject: id3tag: Write image-type into the APIC tag --- gst/id3tag/id3tag.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'gst/id3tag') diff --git a/gst/id3tag/id3tag.c b/gst/id3tag/id3tag.c index ea322d17d..62bf7dd23 100644 --- a/gst/id3tag/id3tag.c +++ b/gst/id3tag/id3tag.c @@ -749,11 +749,28 @@ add_image_tag (GstId3v2Tag * id3v2tag, const GstTagList * list, id3v2_frame_write_string (&frame, encoding, mime_type, TRUE); - /* FIXME set image type properly from caps */ - if (strcmp (tag, GST_TAG_PREVIEW_IMAGE) == 0) + if (strcmp (tag, GST_TAG_PREVIEW_IMAGE) == 0) { id3v2_frame_write_uint8 (&frame, ID3V2_APIC_PICTURE_FILE_ICON); - else - id3v2_frame_write_uint8 (&frame, ID3V2_APIC_PICTURE_OTHER); + } else { + const GstStructure *info_struct; + int image_type; + + info_struct = gst_sample_get_info (sample); + if (info_struct + && gst_structure_has_name (info_struct, "GstTagImageInfo")) { + if (gst_structure_get (info_struct, "image-type", + GST_TYPE_TAG_IMAGE_TYPE, &image_type, NULL)) { + if (image_type > 0 && image_type <= 18) { + image_type += 2; + } else { + image_type = ID3V2_APIC_PICTURE_OTHER; + } + } else { + image_type = ID3V2_APIC_PICTURE_OTHER; + } + } + id3v2_frame_write_uint8 (&frame, image_type); + } id3v2_frame_write_string (&frame, encoding, desc, TRUE); -- cgit v1.2.1