diff options
author | Bastien Nocera <hadess@hadess.net> | 2014-06-02 16:15:40 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2014-06-02 16:15:40 +0200 |
commit | 7212e3c691d6b0f652d422829583ab2ca80ff0fe (patch) | |
tree | 855666a4a2b69fbbd652d5c9eb638d54ff8f0b8c | |
parent | 6b2fa346045a990f6dc2283e9fa755fbf66a7619 (diff) | |
download | totem-7212e3c691d6b0f652d422829583ab2ca80ff0fe.tar.gz |
thumbnailer: Add support for rotated thumbnails
Similar to what we did in the movie player itself, but for thumbnails.
-rw-r--r-- | 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 1edef46e7..99cdae97e 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; } |