From dc8f1dbb3ece510008e4539e300b498257bd8efc Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Thu, 24 Jun 2010 10:23:02 -0300 Subject: [PATCH] fpsdisplaysink: Add fps-update-interval property Use a property to set/get the fps update interval instead of having a hardcoded value. --- gst/debugutils/fpsdisplaysink.c | 23 ++++++++++++++++++----- gst/debugutils/fpsdisplaysink.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gst/debugutils/fpsdisplaysink.c b/gst/debugutils/fpsdisplaysink.c index 7c97dfb135..cc0ce0d3ec 100644 --- a/gst/debugutils/fpsdisplaysink.c +++ b/gst/debugutils/fpsdisplaysink.c @@ -43,7 +43,6 @@ * * IDEAS: * - do we want to gather min/max fps and show in GST_STATE_CHANGE_READY_TO_NULL - * - add another property for the FPS_DISPLAY_INTERVAL_MS */ #ifdef HAVE_CONFIG_H @@ -53,7 +52,7 @@ #include "fpsdisplaysink.h" #include -#define FPS_DISPLAY_INTERVAL_MS 500 /* 500 ms */ +#define DEFAULT_FPS_UPDATE_INTERVAL_MS 500 /* 500 ms */ #define DEFAULT_FONT "Sans 20" /* generic templates */ @@ -72,7 +71,8 @@ enum ARG_SYNC, ARG_TEXT_OVERLAY, ARG_VIDEO_SINK, - /* FILL ME */ + ARG_FPS_UPDATE_INTERVAL + /* FILL ME */ }; static GstBinClass *parent_class = NULL; @@ -115,6 +115,12 @@ fps_display_sink_class_init (GstFPSDisplaySinkClass * klass) "Video sink to use (Must only be called on NULL state)", GST_TYPE_ELEMENT, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_klass, ARG_FPS_UPDATE_INTERVAL, + g_param_spec_int ("fps-update-interval", "Fps update interval", + "Time between consecutive frames per second measures and update " + " (in ms). Should be set on NULL state", 1, G_MAXINT, + DEFAULT_FPS_UPDATE_INTERVAL_MS, G_PARAM_READWRITE)); + gstelement_klass->change_state = fps_display_sink_change_state; gst_element_class_add_pad_template (gstelement_klass, @@ -247,6 +253,7 @@ fps_display_sink_init (GstFPSDisplaySink * self, { self->sync = FALSE; self->use_text_overlay = TRUE; + self->fps_update_interval = DEFAULT_FPS_UPDATE_INTERVAL_MS; self->video_sink = NULL; self->ghost_pad = gst_ghost_pad_new_no_target ("sink", GST_PAD_SINK); @@ -347,8 +354,8 @@ no_text_overlay: /* Set a timeout for the fps display */ self->timeout_id = - g_timeout_add (FPS_DISPLAY_INTERVAL_MS, - display_current_fps, (gpointer) self); + g_timeout_add (self->fps_update_interval, display_current_fps, + (gpointer) self); } static void @@ -426,6 +433,9 @@ fps_display_sink_set_property (GObject * object, guint prop_id, } update_video_sink (self, (GstElement *) g_value_get_object (value)); break; + case ARG_FPS_UPDATE_INTERVAL: + self->fps_update_interval = g_value_get_int (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -448,6 +458,9 @@ fps_display_sink_get_property (GObject * object, guint prop_id, case ARG_VIDEO_SINK: g_value_set_object (value, self->video_sink); break; + case ARG_FPS_UPDATE_INTERVAL: + g_value_set_int (value, self->fps_update_interval); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/gst/debugutils/fpsdisplaysink.h b/gst/debugutils/fpsdisplaysink.h index a9ca3307a0..4cfd9f1cf1 100644 --- a/gst/debugutils/fpsdisplaysink.h +++ b/gst/debugutils/fpsdisplaysink.h @@ -63,6 +63,7 @@ struct _GstFPSDisplaySink /* properties */ gboolean sync; gboolean use_text_overlay; + gint fps_update_interval; }; struct _GstFPSDisplaySinkClass