[gnac/devel] Retrieve and display tag GST_TAG_PREVIEW_IMAGE



commit 2b1ecb809d6a35b60a3b107e8359b9c527b4d6ab
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date:   Sun May 16 22:55:41 2010 +0100

    Retrieve and display tag GST_TAG_PREVIEW_IMAGE

 libgnac/libgnac-metadata.c |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 deletions(-)
---
diff --git a/libgnac/libgnac-metadata.c b/libgnac/libgnac-metadata.c
index 76a053b..5bc94e8 100644
--- a/libgnac/libgnac-metadata.c
+++ b/libgnac/libgnac-metadata.c
@@ -175,6 +175,7 @@ libgnac_metadata_size_prepared_cb(GdkPixbufLoader *loader,
 
 static void
 libgnac_metadata_process_tag_image(const GstTagList *taglist, 
+                                   const gchar      *tag_name,
                                    gint              count,
                                    LibgnacMetadata  *md)
 {
@@ -184,27 +185,33 @@ libgnac_metadata_process_tag_image(const GstTagList *taglist,
     const GValue *val;
     gint image_type;
     GstBuffer *buffer;
-    GstCaps *caps;
-    GstStructure *structure;
 
-    val = gst_tag_list_get_value_index(taglist, GST_TAG_IMAGE, i);
+    val = gst_tag_list_get_value_index(taglist, tag_name, i);
       
     buffer = gst_value_get_buffer(val);
     g_return_if_fail(buffer);
       
-    caps = GST_BUFFER_CAPS(buffer);
-    g_return_if_fail(caps);
+    /* GST_TAG_PREVIEW_IMAGE does not have an "image-type" field */
+    if (g_str_equal(tag_name, GST_TAG_IMAGE))
+    {
+      GstCaps *caps;
+      GstStructure *structure;
+
+      caps = GST_BUFFER_CAPS(buffer);
+      g_return_if_fail(caps);
 
-    structure = gst_caps_get_structure(caps, 0);
-    g_return_if_fail(structure);
+      structure = gst_caps_get_structure(caps, 0);
+      g_return_if_fail(structure);
 
-    gst_structure_get_enum(structure, "image-type", 
-                    GST_TYPE_TAG_IMAGE_TYPE, &image_type);
+      gst_structure_get_enum(structure, "image-type",
+                      GST_TYPE_TAG_IMAGE_TYPE, &image_type);
+    }
 
     /* we are only interested in the front cover (but if there is only
      * one image that has an undefined type, we display it anyway) */
-    if ((image_type == GST_TAG_IMAGE_TYPE_FRONT_COVER) ||
-        (image_type == GST_TAG_IMAGE_TYPE_UNDEFINED && count == 1))
+    if (g_str_equal(tag_name, GST_TAG_PREVIEW_IMAGE) ||
+          (image_type == GST_TAG_IMAGE_TYPE_FRONT_COVER) ||
+          (image_type == GST_TAG_IMAGE_TYPE_UNDEFINED && count == 1))
     {
       GdkPixbuf *pixbuf;
       GdkPixbufLoader *loader;
@@ -310,8 +317,10 @@ libgnac_metadata_process_tag(const GstTagList *taglist,
   count = gst_tag_list_get_tag_size(taglist, tag_name);
   if (count < 1) return;
 
-  if (g_str_equal(tag_name, GST_TAG_IMAGE)) {
-    libgnac_metadata_process_tag_image(taglist, count, md);
+  if (g_str_equal(tag_name, GST_TAG_IMAGE) ||
+      g_str_equal(tag_name, GST_TAG_PREVIEW_IMAGE)) /* used by oga files */
+  {
+    libgnac_metadata_process_tag_image(taglist, tag_name, count, md);
     return;
   }
 



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