Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:13.1
frogr
frogr-port-to-gst_1.0.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File frogr-port-to-gst_1.0.patch of Package frogr
From 6de141ff9ee8014df26d67d8de4e6d62826f5d5c Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger <dimstar@opensuse.org> Date: Wed, 6 Feb 2013 00:20:55 +0100 Subject: [PATCH] Port to GStreamer 1.0 https://bugzilla.gnome.org/show_bug.cgi?id=693230 --- configure.ac | 4 ++-- src/frogr-util.c | 56 ++++++++++---------------------------------------------- 2 files changed, 12 insertions(+), 48 deletions(-) diff --git a/configure.ac b/configure.ac index 5b1622c..a520f60 100644 --- a/configure.ac +++ b/configure.ac @@ -38,8 +38,8 @@ PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_MIN_VERSION) FROGR_CFLAGS="$FROGR_CFLAGS $LIBXML2_CFLAGS" FROGR_LIBS="$FROGR_LIBS $LIBXML2_LIBS" -GSTREAMER_MIN_VERSION=0.10 -PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10 >= $GSTREAMER_MIN_VERSION) +GSTREAMER_MIN_VERSION=1.0 +PKG_CHECK_MODULES(GSTREAMER, gstreamer-1.0 >= $GSTREAMER_MIN_VERSION) FROGR_CFLAGS="$FROGR_CFLAGS $GSTREAMER_CFLAGS" FROGR_LIBS="$FROGR_LIBS $GSTREAMER_LIBS" diff --git a/src/frogr-util.c b/src/frogr-util.c index 8d59b84..d10bd98 100644 --- a/src/frogr-util.c +++ b/src/frogr-util.c @@ -28,6 +28,7 @@ #include <glib/gi18n.h> #include <gtk/gtk.h> #include <gst/gst.h> +#include <gst/base/gstbasesink.h> #include <libexif/exif-byte-order.h> #include <libexif/exif-data.h> #include <libexif/exif-entry.h> @@ -35,7 +36,8 @@ #include <libexif/exif-loader.h> #include <libexif/exif-tag.h> -#define CAPS "video/x-raw-rgb,width=160,pixel-aspect-ratio=1/1,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)0xff0000, green_mask=(int)0x00ff00, blue_mask=(int)0x0000ff" +#define CAPS "video/x-raw,format=RGB,width=160,pixel-aspect-ratio=1/1" +#define PREROLL_TIMEOUT (5*GST_SECOND) static gboolean _spawn_command (const gchar* cmd) @@ -370,20 +372,16 @@ _get_pixbuf_from_video_file (GFile *file, GError **out_error) { GdkPixbuf *pixbuf = NULL; GstElement *pipeline, *sink; - GstBuffer *buffer; - GstFormat format; - GstStateChangeReturn ret; + GstStateChangeReturn ret, sret; gchar *file_uri; gchar *descr; - gint width, height; gint64 duration, position; GError *error = NULL; - gboolean res; /* create a new pipeline */ file_uri = g_file_get_uri (file); - descr = g_strdup_printf ("uridecodebin uri=%s ! ffmpegcolorspace ! videoscale ! " - " appsink name=sink caps=\"" CAPS "\"", file_uri); + descr = g_strdup_printf ("uridecodebin uri=%s ! videoconvert ! videoscale " + " ! " CAPS " ! gdkpixbufsink name=sink", file_uri); g_free (file_uri); pipeline = gst_parse_launch (descr, &error); @@ -423,8 +421,7 @@ _get_pixbuf_from_video_file (GFile *file, GError **out_error) } /* get the duration */ - format = GST_FORMAT_TIME; - gst_element_query_duration (pipeline, &format, &duration); + gst_element_query_duration (pipeline, GST_FORMAT_TIME, &duration); if (duration != -1) /* we have a duration, seek to 50% */ @@ -439,43 +436,10 @@ _get_pixbuf_from_video_file (GFile *file, GError **out_error) gst_element_seek_simple (pipeline, GST_FORMAT_TIME, GST_SEEK_FLAG_KEY_UNIT | GST_SEEK_FLAG_FLUSH, position); - /* get the preroll buffer from appsink, this block untils appsink really prerolls */ - g_signal_emit_by_name (sink, "pull-preroll", &buffer, NULL); - - /* if we have a buffer now, convert it to a pixbuf. It's possible that we - * don't have a buffer because we went EOS right away or had an error. */ - if (buffer) { - GstCaps *caps; - GstStructure *s; - - /* get the snapshot buffer format now. We set the caps on the appsink so - * that it can only be an rgb buffer. The only thing we have not specified - * on the caps is the height, which is dependant on the pixel-aspect-ratio - * of the source material */ - caps = GST_BUFFER_CAPS (buffer); - if (!caps) { - DEBUG ("could not get snapshot format\n"); - return NULL; - } - s = gst_caps_get_structure (caps, 0); - /* we need to get the final caps on the buffer to get the size */ - res = gst_structure_get_int (s, "width", &width); - res |= gst_structure_get_int (s, "height", &height); - if (!res) { - DEBUG ("could not get snapshot dimension\n"); - return NULL; - } - - /* create pixmap from buffer and save, gstreamer video buffers have a stride - * that is rounded up to the nearest multiple of 4 */ - pixbuf = gdk_pixbuf_new_from_data (GST_BUFFER_DATA (buffer), - GDK_COLORSPACE_RGB, FALSE, 8, width, height, - GST_ROUND_UP_4 (width * 3), NULL, NULL); - - } else { - DEBUG ("could not make snapshot\n"); - } + sret = gst_element_get_state (pipeline, NULL, NULL, PREROLL_TIMEOUT); + if (sret == GST_STATE_CHANGE_SUCCESS) + g_object_get (sink, "last-pixbuf", &pixbuf, NULL); /* cleanup and exit */ gst_element_set_state (pipeline, GST_STATE_NULL); -- 1.8.1.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor