[totem] thumbnailer: Add support for rotated thumbnails



commit 7212e3c691d6b0f652d422829583ab2ca80ff0fe
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Jun 2 16:15:40 2014 +0200

    thumbnailer: Add support for rotated thumbnails
    
    Similar to what we did in the movie player itself, but for thumbnails.

 src/gst/totem-gst-pixbuf-helpers.c |   38 ++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/gst/totem-gst-pixbuf-helpers.c b/src/gst/totem-gst-pixbuf-helpers.c
index 1edef46..99cdae9 100644
--- a/src/gst/totem-gst-pixbuf-helpers.c
+++ b/src/gst/totem-gst-pixbuf-helpers.c
@@ -52,6 +52,7 @@ totem_gst_playbin_get_frame (GstElement *play)
   gint outheight = 0;
   GstMemory *memory;
   GstMapInfo info;
+  GdkPixbufRotation rotation = GDK_PIXBUF_ROTATE_NONE;
 
   g_return_val_if_fail (play != NULL, NULL);
   g_return_val_if_fail (GST_IS_ELEMENT (play), NULL);
@@ -112,6 +113,43 @@ done:
     gst_sample_unref (sample);
   }
 
+  /* Did we check whether we need to rotate the video? */
+  if (g_object_get_data (G_OBJECT (play), "orientation-checked") == NULL) {
+    GstTagList *tags = NULL;
+
+    g_signal_emit_by_name (G_OBJECT (play), "get-video-tags", 0, &tags);
+    if (tags) {
+      char *orientation_str;
+      gboolean ret;
+
+      ret = gst_tag_list_get_string_index (tags, GST_TAG_IMAGE_ORIENTATION, 0, &orientation_str);
+      if (!ret || !orientation_str)
+        rotation = GDK_PIXBUF_ROTATE_NONE;
+      else if (g_str_equal (orientation_str, "rotate-90"))
+        rotation = GDK_PIXBUF_ROTATE_CLOCKWISE;
+      else if (g_str_equal (orientation_str, "rotate-180"))
+        rotation = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
+      else if (g_str_equal (orientation_str, "rotate-270"))
+        rotation = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
+
+      gst_tag_list_unref (tags);
+    }
+
+    g_object_set_data (G_OBJECT (play), "orientation-checked", GINT_TO_POINTER(1));
+    g_object_set_data (G_OBJECT (play), "orientation", GINT_TO_POINTER(rotation));
+  }
+
+  rotation = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (play), "orientation"));
+  if (rotation != GDK_PIXBUF_ROTATE_NONE) {
+    GdkPixbuf *rotated;
+
+    rotated = gdk_pixbuf_rotate_simple (pixbuf, rotation);
+    if (rotated) {
+      g_object_unref (pixbuf);
+      pixbuf = rotated;
+    }
+  }
+
   return pixbuf;
 }
 


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