Search
SailfishOS Open Build Service
>
Projects
>
home:plfiorini
:
maui:devel
:
armv6l
>
gst-plugins-bad-free
> _service:tar_git:0005-camerabin-add-performance-timestamping-Maemo-specifi.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File _service:tar_git:0005-camerabin-add-performance-timestamping-Maemo-specifi.patch of Package gst-plugins-bad-free
From a31cce6883fbc37a3660911cfec393ab9d8d42a6 Mon Sep 17 00:00:00 2001 From: Teemu Katajisto <ext-teemu.katajisto@nokia.com> Date: Thu, 26 Nov 2009 14:36:20 +0200 Subject: [PATCH 05/23] camerabin: add performance timestamping (Maemo-specific) --- configure.ac | 1 + gst/camerabin/Makefile.am | 3 +- gst/camerabin/camerabinimage.c | 4 ++- gst/camerabin/camerabinpreview.c | 4 +++ gst/camerabin/camerabinvideo.c | 2 ++ gst/camerabin/gstcamerabin-performance.h | 50 +++++++++++++++++++++++++++ gst/camerabin/gstcamerabin.c | 54 +++++++++++++++++++++++++++++- m4/gst-timestamps.m4 | 13 +++++++ 8 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 gst/camerabin/gstcamerabin-performance.h create mode 100644 m4/gst-timestamps.m4 diff --git a/configure.ac b/configure.ac index b28e413..d7af4e1 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,7 @@ AG_GST_ARG_DEBUG AG_GST_ARG_PROFILING AG_GST_ARG_VALGRIND AG_GST_ARG_GCOV +AG_GST_TIMESTAMPS AG_GST_ARG_EXAMPLES diff --git a/gst/camerabin/Makefile.am b/gst/camerabin/Makefile.am index b29a54d..a891753 100644 --- a/gst/camerabin/Makefile.am +++ b/gst/camerabin/Makefile.am @@ -44,7 +44,8 @@ noinst_HEADERS = gstcamerabin.h \ camerabindebug.h \ camerabingeneral.h \ camerabinpreview.h \ - gstcamerabin-enum.h + gstcamerabin-enum.h \ + gstcamerabin-performance.h Android.mk: Makefile.am $(BUILT_SOURCES) androgenizer \ diff --git a/gst/camerabin/camerabinimage.c b/gst/camerabin/camerabinimage.c index c69a5c3..88766fa 100644 --- a/gst/camerabin/camerabinimage.c +++ b/gst/camerabin/camerabinimage.c @@ -47,7 +47,7 @@ /* * includes */ - +#include "gstcamerabin-performance.h" #include <gst/gst.h> #include "camerabinimage.h" @@ -659,6 +659,8 @@ done: GST_DEBUG_OBJECT (imagebin, "linking finished %s", ret ? "OK" : "NOK"); + CP ("IMAGEBIN ELEMENTS CREATED"); + return ret; } diff --git a/gst/camerabin/camerabinpreview.c b/gst/camerabin/camerabinpreview.c index e7e5fe4..8ffab77 100644 --- a/gst/camerabin/camerabinpreview.c +++ b/gst/camerabin/camerabinpreview.c @@ -21,6 +21,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include "gstcamerabin-performance.h" #include <gst/gst.h> #include <string.h> @@ -213,6 +214,8 @@ gst_camerabin_preview_convert (GstCameraBinPreviewPipelineData * data, goto no_pipeline; } + CP ("CAMERABIN PREVIEW IMAGE CREATE"); + src = gst_bin_get_by_name (GST_BIN (data->pipeline), "prev_src"); sink = gst_bin_get_by_name (GST_BIN (data->pipeline), "prev_sink"); @@ -288,6 +291,7 @@ done: if (sink) gst_object_unref (sink); + CP ("CAMERABIN PREVIEW IMAGE CREATED"); return result; /* ERRORS */ diff --git a/gst/camerabin/camerabinvideo.c b/gst/camerabin/camerabinvideo.c index 06ce8ba..07fde65 100644 --- a/gst/camerabin/camerabinvideo.c +++ b/gst/camerabin/camerabinvideo.c @@ -55,6 +55,7 @@ #include "config.h" #endif +#include "gstcamerabin-performance.h" #include <gst/gst.h> #include "camerabindebug.h" #include "camerabingeneral.h" @@ -641,6 +642,7 @@ gst_camerabin_video_create_elements (GstCameraBinVideo * vid) g_object_set (vid->aud_src, "provide-clock", FALSE, NULL); } + CP ("VIDEOBIN ELEMENTS CREATED"); GST_DEBUG ("created video elements"); return TRUE; diff --git a/gst/camerabin/gstcamerabin-performance.h b/gst/camerabin/gstcamerabin-performance.h new file mode 100644 index 0000000..f9924e6 --- /dev/null +++ b/gst/camerabin/gstcamerabin-performance.h @@ -0,0 +1,50 @@ +/* + * GStreamer + * Copyright (C) 2009 Nokia Corporation <multimedia@maemo.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#ifndef __GST_CAMERABIN_PERFORMANCE_H__ +#define __GST_CAMERABIN_PERFORMANCE_H__ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +/* + * performance timestamping + */ +#ifdef GST_TIMESTAMPS +# ifndef ENTER +# include <stdio.h> +# include <sys/time.h> +# include <time.h> +# define TIMESTAMP struct timeval timestamp_for_time_tracking; gettimeofday(×tamp_for_time_tracking,NULL); +# define TIMESTAMPLONG (timestamp_for_time_tracking.tv_sec*1000000ll+timestamp_for_time_tracking.tv_usec) +# define ENTER { TIMESTAMP; fprintf(stderr,"ENTERING:%s:%lli:\n",__func__,TIMESTAMPLONG); }; +# define LEAVE { TIMESTAMP; fprintf(stderr,"LEAVING:%s:%i:%lli:\n",__func__,__LINE__,TIMESTAMPLONG); }; +# define CP(name) { TIMESTAMP; fprintf(stderr,"CHECKPOINT:%s:%s:%i:%lli:\n",name,__func__,__LINE__,TIMESTAMPLONG); }; +# endif +#else +# define TIMESTAMP +# define TIMESTAMPLONG +# define ENTER +# define LEAVE +# define CP(name) +#endif + + +#endif /* #ifndef __CAMERABIN_PERFORMANCE_H__ */ diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index 7405dc3..2a5c8d0 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -151,6 +151,7 @@ # include <config.h> #endif +#include "gstcamerabin-performance.h" #include <string.h> #include <stdlib.h> @@ -848,6 +849,7 @@ camerabin_create_elements (GstCameraBin * camera) ret = TRUE; done: + CP ("CAMERABIN ELEMENTS CREATED"); if (FALSE == ret) camerabin_destroy_elements (camera); @@ -1040,6 +1042,7 @@ gst_camerabin_change_mode (GstCameraBin * camera, gint mode) { if (camera->mode != mode || !camera->active_bin) { GstState state, pending_state; + CP ("CAMERABIN MODE CHANGE"); GST_DEBUG_OBJECT (camera, "setting mode: %d (old_mode=%d)", mode, camera->mode); @@ -1080,6 +1083,7 @@ gst_camerabin_change_mode (GstCameraBin * camera, gint mode) gst_camerabin_image_prepare_elements (GST_CAMERABIN_IMAGE (camera->imgbin)); } + CP ("CAMERABIN MODE CHANGED"); } } @@ -1668,6 +1672,7 @@ gst_camerabin_start_video_recording (GstCameraBin * camera) * use a queue overrun signal? */ GST_INFO_OBJECT (camera, "starting video capture"); + CP ("CAMERABIN START VIDEO RECORDING"); /* check if need to update video capture caps */ if (camera->video_capture_caps_update) { @@ -1719,6 +1724,7 @@ gst_camerabin_start_video_recording (GstCameraBin * camera) } else { gst_element_set_locked_state (camera->vidbin, TRUE); } + CP ("CAMERABIN VIDEO RECORDING STARTED"); } else { GST_WARNING_OBJECT (camera, "videobin state change failed"); gst_element_set_state (camera->vidbin, GST_STATE_NULL); @@ -1801,6 +1807,8 @@ gst_camerabin_send_preview (GstCameraBin * camera, GstBuffer * buffer) GST_DEBUG_OBJECT (camera, "creating preview"); + CP ("CAMERABIN CREATE PREVIEW"); + data = (camera->mode == MODE_IMAGE) ? camera->preview_pipeline : camera->video_preview_pipeline; prev = gst_camerabin_preview_convert (data, buffer); @@ -1820,6 +1828,8 @@ gst_camerabin_send_preview (GstCameraBin * camera, GstBuffer * buffer) GST_WARNING_OBJECT (camera, "This element has no bus, therefore no message sent!"); } + + CP ("CAMERABIN PREVIEW SENT"); ret = TRUE; } @@ -1965,6 +1975,7 @@ gst_camerabin_have_src_buffer (GstPad * pad, GstBuffer * buffer, g_cond_signal (camera->cond); g_mutex_unlock (camera->capture_mutex); + CP ("CAMERABIN SEND IMAGE CAPTURED"); msg = gst_message_new_element (GST_OBJECT (camera), gst_structure_new (IMG_CAPTURED_MESSAGE_NAME, NULL)); @@ -2478,6 +2489,7 @@ gst_camerabin_finish_image_capture (GstCameraBin * camera) camera->base_crop_bottom = 0; gst_camerabin_set_capsfilter_caps (camera, camera->view_finder_caps); } + CP ("CAMERABIN IMAGE CAPTURE FINISHED"); } /* @@ -3336,7 +3348,7 @@ static void gst_camerabin_init (GstCameraBin * camera, GstCameraBinClass * gclass) { /* GstElementClass *klass = GST_ELEMENT_GET_CLASS (camera); */ - + ENTER; camera->filename = g_string_new (""); camera->mode = DEFAULT_MODE; camera->flags = DEFAULT_FLAGS; @@ -3451,6 +3463,7 @@ static void gst_camerabin_finalize (GObject * object) { G_OBJECT_CLASS (parent_class)->finalize (object); + LEAVE; } static void @@ -3883,6 +3896,10 @@ gst_camerabin_change_state (GstElement * element, GstStateChange transition) GstCameraBin *camera = GST_CAMERABIN (element); GstStateChangeReturn ret; +#ifdef GST_TIMESTAMPS + gboolean measure = FALSE; +#endif + GST_DEBUG_OBJECT (element, "changing state: %s -> %s", gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)), gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition))); @@ -3904,6 +3921,10 @@ gst_camerabin_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_PAUSED_TO_PLAYING: /* If using autovideosink, set view finder sink properties now that actual sink has been created. */ +#ifdef GST_TIMESTAMPS + CP ("CAMERABIN STARTING VIEWFINDER"); + measure = TRUE; +#endif camerabin_setup_view_elements (camera); break; case GST_STATE_CHANGE_PAUSED_TO_READY: @@ -3979,6 +4000,12 @@ done: gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)), gst_element_state_change_return_get_name (ret)); +#ifdef GST_TIMESTAMPS + if (measure) { + CP ("CAMERABIN VIEWFINDER STARTED"); + } +#endif + return ret; } @@ -4055,6 +4082,7 @@ gst_camerabin_imgbin_finished (gpointer u_data) GST_STATE_UNLOCK (camera); /* Send image-done signal */ + CP ("CAMERABIN IMAGE ENCODING FINISHED"); gst_camerabin_image_capture_continue (camera, filename); g_free (filename); @@ -4073,12 +4101,18 @@ gst_camerabin_handle_message_func (GstBin * bin, GstMessage * msg) { GstCameraBin *camera = GST_CAMERABIN (bin); +#ifdef GST_TIMESTAMPS + const GstStructure *st; + gint status; +#endif + switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_EOS: if (GST_MESSAGE_SRC (msg) == GST_OBJECT (camera->vidbin)) { /* Video eos */ GST_DEBUG_OBJECT (camera, "got video eos message, stopping video capture"); + CP ("CAMERABIN VIDEO RECORDING STOPPED"); g_mutex_lock (camera->capture_mutex); camera->capturing = FALSE; g_cond_signal (camera->cond); @@ -4117,6 +4151,22 @@ gst_camerabin_handle_message_func (GstBin * bin, GstMessage * msg) g_mutex_unlock (camera->capture_mutex); break; default: +#ifdef GST_TIMESTAMPS + st = gst_message_get_structure (msg); + if (st) { + if (gst_structure_has_name (st, "photo-capture-start")) { + CP ("CAMERABIN SOURCE CAPTURE START"); + } else if (gst_structure_has_name (st, "photo-capture-end")) { + CP ("CAMERABIN SOURCE CAPTURE END"); + } else if (gst_structure_has_name (st, "autofocus-done")) { + if (gst_structure_get_int (st, "status", &status)) { + if (status == GST_PHOTOGRAPHY_FOCUS_STATUS_SUCCESS) { + CP ("CAMERABIN AUTOFOCUS DONE"); + } + } + } + } +#endif break; } GST_BIN_CLASS (parent_class)->handle_message (bin, msg); @@ -4131,6 +4181,7 @@ gst_camerabin_capture_start (GstCameraBin * camera) { GST_INFO_OBJECT (camera, "starting capture"); + CP ("CAMERABIN CAPTURE START"); if (camera->paused) { gst_camerabin_capture_pause (camera); return; @@ -4189,6 +4240,7 @@ gst_camerabin_capture_start (GstCameraBin * camera) static void gst_camerabin_capture_stop (GstCameraBin * camera) { + CP ("CAMERABIN CAPTURE STOP"); if (camera->active_bin == camera->vidbin) { GST_INFO_OBJECT (camera, "stopping video capture"); gst_camerabin_do_stop (camera); diff --git a/m4/gst-timestamps.m4 b/m4/gst-timestamps.m4 new file mode 100644 index 0000000..ec2c9fb --- /dev/null +++ b/m4/gst-timestamps.m4 @@ -0,0 +1,13 @@ +AC_DEFUN([AG_GST_TIMESTAMPS], [ +AC_ARG_ENABLE(timestamps, +AC_HELP_STRING([--enable-timestamps],[enable printing timestamp information to stderr]), +[case "${enableval}" in + yes) USE_TIMESTAMPS=yes ;; + no) USE_TIMESTAMPS=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-timestamps) ;; +esac], +[USE_TIMESTAMPS=no]) dnl Default value +if test x$USE_TIMESTAMPS = xyes; then + AC_DEFINE(GST_TIMESTAMPS, 1, [Define if TIMESTAMPS statements should be compiled in]) +fi +]) -- 1.7.10.4