- if (is_pic_uri) {
- gchar *uri;
-
- uri = g_strndup ((gchar *) work->parse_data, work->parse_size);
- GST_DEBUG ("image URI: %s", uri);
-
- image = gst_buffer_new ();
- GST_BUFFER_MALLOCDATA (image) = (guint8 *) uri; /* take ownership */
- GST_BUFFER_DATA (image) = (guint8 *) uri;
- GST_BUFFER_SIZE (image) = work->parse_size;
-
- image_caps = gst_caps_new_simple ("text/uri-list", NULL);
- } else {
- image = gst_buffer_new_and_alloc (work->parse_size);
- memcpy (GST_BUFFER_DATA (image), work->parse_data, work->parse_size);
-
- /* if possible use GStreamer media type rather than declared type */
- image_caps = gst_type_find_helper_for_buffer (NULL, image, NULL);
- if (image_caps) {
- GST_DEBUG ("Found GStreamer media type: %" GST_PTR_FORMAT, image_caps);
- } else if (mime_str && *mime_str) {
- GST_DEBUG ("No GStreamer media type found, using declared type");
- image_caps = gst_caps_new_simple (mime_str, NULL);
- } else {
- GST_DEBUG ("Empty declared mime type, ignoring image frame");
- image = NULL;
- image_caps = NULL;
- goto error;
- }
- }
-
- if (image && image_caps) {
-
- if (pic_type == 0x01 || pic_type == 0x02) {
- /* file icon for preview. Don't add image-type to caps, since there
- * is only supposed to be one of these. */
- gst_buffer_set_caps (image, image_caps);
- gst_tag_list_add (work->tags, GST_TAG_MERGE_APPEND,
- GST_TAG_PREVIEW_IMAGE, image, NULL);
- } else {
- GstTagImageType gst_tag_pic_type = GST_TAG_IMAGE_TYPE_UNDEFINED;
-
- /* Remap the ID3v2 APIC type our ImageType enum */
- if (pic_type >= 0x3 && pic_type <= 0x14)
- gst_tag_pic_type = (GstTagImageType) (pic_type - 2);
-
- gst_structure_set (gst_caps_get_structure (image_caps, 0),
- "image-type", GST_TYPE_TAG_IMAGE_TYPE, gst_tag_pic_type, NULL);
-
- gst_buffer_set_caps (image, image_caps);
- gst_tag_list_add (work->tags, GST_TAG_MERGE_APPEND,
- GST_TAG_IMAGE, image, NULL);
- }
-
- gst_caps_unref (image_caps);
- gst_buffer_unref (image);