[tracker/tracker-0.6] Mime check fixes to the album art extraction in gstreamer and mp3 extractors



commit 1e1f55f6c90fb943ee3762bcb5b4fb1147823b08
Author: Mikael Ottela <mikael ottela ixonos com>
Date:   Wed May 20 16:36:06 2009 +0300

    Mime check fixes to the album art extraction in gstreamer and mp3 extractors
---
 src/tracker-extract/tracker-extract-gstreamer.c |   51 ++++++++++++++++++++++-
 src/tracker-extract/tracker-extract-mp3.c       |    2 +-
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index 444b3b0..4ea5570 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -86,6 +86,7 @@ typedef struct {
 
 	unsigned char  *album_art_data;
 	guint           album_art_size;
+	const gchar    *album_art_mime;
 
 } MetadataExtractor;
 
@@ -236,6 +237,48 @@ get_media_duration (MetadataExtractor *extractor)
 }
 
 static void
+get_embedded_album_art(MetadataExtractor *extractor)
+{
+	const GValue *value;
+	guint         lindex;
+
+	lindex = 0;
+
+	do {
+		value = gst_tag_list_get_value_index (extractor->tagcache, GST_TAG_IMAGE, lindex);
+
+		if (value) {
+			GstBuffer    *buffer;
+			GstCaps      *caps;
+			GstStructure *caps_struct;
+			gint          type;
+
+			buffer = gst_value_get_buffer (value);
+			caps   = gst_buffer_get_caps (buffer);
+			caps_struct = gst_caps_get_structure (buffer->caps, 0);
+
+			gst_structure_get_enum (caps_struct,
+						"image-type",
+						GST_TYPE_TAG_IMAGE_TYPE,
+						&type);
+
+			if ((type == GST_TAG_IMAGE_TYPE_FRONT_COVER)||
+			    ((type == GST_TAG_IMAGE_TYPE_UNDEFINED)&&(extractor->album_art_size == 0))) {
+				extractor->album_art_data = buffer->data;
+				extractor->album_art_size = buffer->size;
+				extractor->album_art_mime = gst_structure_get_name (caps_struct);
+				g_debug ("Mime was %s", extractor->album_art_mime);
+				return;
+			}
+
+			gst_object_unref (caps);
+
+			lindex++;
+		}
+	} while (value);
+}
+
+static void
 extract_metadata (MetadataExtractor *extractor,
 		  GHashTable        *metadata)
 {
@@ -333,6 +376,8 @@ extract_metadata (MetadataExtractor *extractor,
  		if (extractor->duration >= 0) {
  			add_int64_info (metadata, g_strdup ("Audio:Duration"), extractor->duration);
  		}
+
+		get_embedded_album_art (extractor);
  	}
 
 	if (extractor->audiotags) {
@@ -673,6 +718,10 @@ tracker_extract_gstreamer (const gchar *uri,
 	extractor->audiotags    = NULL;
 	extractor->videotags    = NULL;	
 
+	extractor->album_art_data = NULL;
+	extractor->album_art_size = 0;
+	extractor->album_art_mime = NULL;
+
 	extractor->duration = -1;
 	extractor->video_fps_n = extractor->video_fps_d = -1;
 	extractor->video_height = extractor->video_width = -1;
@@ -749,7 +798,7 @@ tracker_extract_gstreamer (const gchar *uri,
 	/* Save embedded art */
 	if (extractor->album_art_data && extractor->album_art_size) {
 #ifdef HAVE_GDKPIXBUF
-		tracker_process_albumart (extractor->album_art_data, extractor->album_art_size, NULL,
+		tracker_process_albumart (extractor->album_art_data, extractor->album_art_size, extractor->album_art_mime,
 					  /* g_hash_table_lookup (metadata, "Audio:Artist") */ NULL,
 					  g_hash_table_lookup (metadata, "Audio:Album"),
 					  g_hash_table_lookup (metadata, "Audio:AlbumTrackCount"),
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index 9b3f62d..9c6265b 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -87,7 +87,7 @@ typedef struct {
 
 	unsigned char *albumartdata;
 	size_t         albumartsize;
-	gchar         *albumartmime
+	gchar         *albumartmime;
 } file_data;
 
 enum {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]