[pinpoint] Simplify thumbnailing



commit 2be1d96c87ad031bef422599aab0217b62072142
Author: Nicolas Dufresne <nicolas dufresne collabora com>
Date:   Thu Oct 24 06:46:44 2013 -0400

    Simplify thumbnailing
    
    Make use of gdkpixbufsink rather then own our convertion code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732700

 configure.ac            |    6 ++--
 gst-video-thumbnailer.c |   52 ++++------------------------------------------
 2 files changed, 8 insertions(+), 50 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9927094..bc99f0b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,16 +49,16 @@ AC_ARG_ENABLE([cluttergst],
 AC_MSG_CHECKING([for the stuff needed to show media files])
 AS_CASE([$enable_cluttergst],
        [no], [have_cluttergst="no (disabled)"],
-       [yes], [PKG_CHECK_EXISTS([clutter-gst-2.0 >= 2.0 gstreamer-app-1.0],
+       [yes], [PKG_CHECK_EXISTS([clutter-gst-2.0 >= 2.0],
                                  have_cluttergst="yes",
                                  AC_MSG_ERROR([Oh no!]))],
-       [auto], [PKG_CHECK_EXISTS([clutter-gst-2.0 >= 2.0 gstreamer-app-1.0],
+       [auto], [PKG_CHECK_EXISTS([clutter-gst-2.0 >= 2.0],
                                  have_cluttergst="yes",
                                  have_cluttergst="no")],
        AC_MSG_ERROR([invalid argumented passed to --enable-cluttergst]))
 AC_MSG_RESULT([$have_cluttergst])
 AS_IF([test "x$have_cluttergst" = "xyes"], [
-       PINPOINT_DEPS="$PINPOINT_DEPS clutter-gst-2.0 >= 2.0 gstreamer-app-1.0"
+       PINPOINT_DEPS="$PINPOINT_DEPS clutter-gst-2.0 >= 2.0"
        AC_DEFINE([USE_CLUTTER_GST], [1], [Whether pinpoint will display media files using ClutterGst])])
 AM_CONDITIONAL([USE_CLUTTER_GST], [test "x$have_cluttergst" = "xyes"])
 
diff --git a/gst-video-thumbnailer.c b/gst-video-thumbnailer.c
index cd8d85e..2d1a36f 100644
--- a/gst-video-thumbnailer.c
+++ b/gst-video-thumbnailer.c
@@ -26,39 +26,10 @@
 
 #include <gio/gio.h>
 #include <gst/gst.h>
-#include <gst/app/app.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 #include "gst-video-thumbnailer.h"
 
-GdkPixbuf *
-convert_buffer_to_pixbuf (GstCaps      *caps,
-                          GstBuffer    *buffer,
-                          GCancellable *cancellable)
-{
-    GstMapInfo info;
-    int dw, dh;
-    GstStructure *s;
-
-    s = gst_caps_get_structure (caps, 0);
-    gst_structure_get_int (s, "width", &dw);
-    gst_structure_get_int (s, "height", &dh);
-
-    if (gst_buffer_map (buffer, &info, GST_MAP_READ)) {
-        gchar *data = g_memdup (info.data, info.size);
-        GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data ((guchar *) data,
-                                                      GDK_COLORSPACE_RGB, FALSE,
-                                                      8, dw, dh, GST_ROUND_UP_4 (dw * 3),
-                                                      (GdkPixbufDestroyNotify) g_free,
-                                                      NULL);
-
-        gst_buffer_unmap (buffer, &info);
-
-        return pixbuf;
-    }
-
-    return NULL;
-}
 
 GdkPixbuf *
 gst_video_thumbnailer_get_shot (const gchar  *location,
@@ -75,13 +46,7 @@ gst_video_thumbnailer_get_shot (const gchar  *location,
 
     playbin = gst_element_factory_make ("playbin", "playbin");
     audio_sink = gst_element_factory_make ("fakesink", "audiosink");
-    video_sink = gst_element_factory_make ("appsink", "videosink");
-
-    gst_app_sink_set_caps (GST_APP_SINK (video_sink),
-                           gst_caps_new_simple ("video/x-raw",
-                                                "format", G_TYPE_STRING, "RGB",
-                                                "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
-                                                NULL));
+    video_sink = gst_element_factory_make ("gdkpixbufsink", "videosink");
 
     g_object_set (playbin,
                   "uri", uri,
@@ -115,7 +80,6 @@ gst_video_thumbnailer_get_shot (const gchar  *location,
 
         if (gst_element_query_duration (playbin, GST_FORMAT_TIME, &duration)) {
             gint64 seekpos;
-            GstSample *sample;
 
             if (duration > 0) {
                 if (duration / (3 * GST_SECOND) > 90) {
@@ -142,18 +106,12 @@ gst_video_thumbnailer_get_shot (const gchar  *location,
                 count++;
             }
 
-            sample = gst_base_sink_get_last_sample (GST_BASE_SINK (video_sink));
-            if (sample == NULL) {
-                g_warning ("No frame for %s", uri);
-                shot = NULL;
+            g_object_get (video_sink, "last-pixbuf", &shot, NULL);
+
+            if (shot == NULL) {
+                g_warning ("Could not get screenshot for %s", uri);
                 goto finish;
             }
-
-            shot = convert_buffer_to_pixbuf (gst_sample_get_caps (sample),
-                                             gst_sample_get_buffer (sample),
-                                             cancellable);
-
-            gst_sample_unref (sample);
         }
     }
 


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