From 8ac16a90e4d0cc05a5c1c84c0c04bded901795bb Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Mon, 20 Jul 2009 16:39:42 +0300 Subject: camerabin: add code in test to store snapshots for manual verification Use gdk_pixbuf to save the image in perf-test. Also remove some obsolute commented out code. --- tests/examples/camerabin/gst-camera-perf.c | 38 +++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/examples/camerabin/gst-camera-perf.c b/tests/examples/camerabin/gst-camera-perf.c index 56d8b401..2337321d 100644 --- a/tests/examples/camerabin/gst-camera-perf.c +++ b/tests/examples/camerabin/gst-camera-perf.c @@ -32,7 +32,7 @@ * gcc `pkg-config --cflags --libs gstreamer-0.10` gst-camera-perf.c -ogst-camera-perf * * plain linux: - * ./gst-camera-perf --src-colorspace=YUY2 --image-width=320 --image-height=240 --view-framerate-num=15 --view-framerate-den=1 + * ./gst-camera-perf --src-colorspace=YUY2 --image-width=640 --image-height=480 --view-framerate-num=15 --view-framerate-den=1 * * maemo: * ./gst-camera-perf --src-colorspace=UYVY --image-width=640 --image-height=480 --view-framerate-num=1491 --view-framerate-den=100 --video-src=v4l2camsrc --audio-enc=nokiaaacenc --video-enc=omx_mpeg4enc --video-mux=hantromp4mux @@ -50,11 +50,18 @@ # include "config.h" #endif +/* save the snapshot images + * gcc `pkg-config --cflags --libs gstreamer-0.10 gdk-pixbuf-2.0` gst-camera-perf.c -ogst-camera-perf + * +#define SAVE_SNAPSHOT 1 + **/ #include +#ifdef SAVE_SNAPSHOT +#include +#endif #include #include #include - /* * debug logging */ @@ -422,6 +429,29 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data) g_object_set (camera_bin, "preview-caps", NULL, NULL); break; } +#ifdef SAVE_SNAPSHOT + { + const GValue *value = gst_structure_get_value (st, "buffer"); + GstBuffer *buf = gst_value_get_buffer (value); + GstCaps *caps = GST_BUFFER_CAPS (buf); + GstStructure *buf_st = gst_caps_get_structure (caps, 0); + guchar *data = GST_BUFFER_DATA (buf); + gint width, height, rowstride; + GdkPixbuf *pixbuf; + + GST_INFO ("preview : buf=%p, size=%d, format=%" GST_PTR_FORMAT, + buf, GST_BUFFER_SIZE (buf), caps); + gst_structure_get_int (buf_st, "width", &width); + gst_structure_get_int (buf_st, "height", &height); + rowstride = GST_ROUND_UP_4 (width * 3); + //GST_INFO ("rowstride : %d, %d", rowstride, width*3); + pixbuf = gdk_pixbuf_new_from_data (data, GDK_COLORSPACE_RGB, FALSE, + 8, width, height, rowstride, NULL, NULL); + gdk_pixbuf_save (pixbuf, "/tmp/gst-camerabin-preview.png", "png", + NULL, NULL); + gdk_pixbuf_unref (pixbuf); + } +#endif } } /* unhandled message */ @@ -632,10 +662,6 @@ test_01 (void) GET_TIME (t_initial); if (setup_pipeline ()) { - /* MAKE SURE THE PIPELINE IS IN PLAYING STATE BEFORE START TAKING PICTURES - AND SO ON (otherwise it will deadlock) */ - - //gst_element_get_state (camera_bin, NULL, NULL, GST_CLOCK_TIME_NONE); /* the actual results are fetched in bus_callback::state-changed */ res = FALSE; } else { -- cgit v1.2.1