summaryrefslogtreecommitdiff
path: root/gst/debugutils
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-06-24 12:37:36 -0300
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-06-24 13:53:08 -0300
commit57b9ce71b43505e459639ae11c3939f65a34da8c (patch)
tree4b4076fd9ca88242f96479f7f346a855e6cf9449 /gst/debugutils
parentf78bf26951e7fbf952a47138c8b7b7e90d2d38c3 (diff)
downloadgstreamer-plugins-bad-57b9ce71b43505e459639ae11c3939f65a34da8c.tar.gz
fpsdisplaysink: Adds a signal to inform measurements to apps
Adds a signal for applications to receive the fps measurements made instead of only printing them to the frame/stdout. This signal is only emited if the signal-fps-measurements property is set to TRUE
Diffstat (limited to 'gst/debugutils')
-rw-r--r--gst/debugutils/.gitignore2
-rw-r--r--gst/debugutils/Makefile.am15
-rw-r--r--gst/debugutils/debugutils-marshal.list2
-rw-r--r--gst/debugutils/fpsdisplaysink.c53
-rw-r--r--gst/debugutils/fpsdisplaysink.h1
5 files changed, 72 insertions, 1 deletions
diff --git a/gst/debugutils/.gitignore b/gst/debugutils/.gitignore
new file mode 100644
index 000000000..69e91a92c
--- /dev/null
+++ b/gst/debugutils/.gitignore
@@ -0,0 +1,2 @@
+debugutils-marshal.c
+debugutils-marshal.h
diff --git a/gst/debugutils/Makefile.am b/gst/debugutils/Makefile.am
index 3b93fa911..70e8400cb 100644
--- a/gst/debugutils/Makefile.am
+++ b/gst/debugutils/Makefile.am
@@ -1,6 +1,21 @@
+glib_gen_prefix = __gst_debugutils
+glib_gen_basename = debugutils
+
+include $(top_srcdir)/common/gst-glib-gen.mak
+
+built_sources = debugutils-marshal.c
+built_headers = debugutils-marshal.h
+
+BUILT_SOURCES = $(built_sources) $(built_headers)
+
+CLEANFILES = $(BUILT_SOURCES)
+
+EXTRA_DIST = debugutils-marshal.list
+
plugin_LTLIBRARIES = libgstdebugutilsbad.la
libgstdebugutilsbad_la_SOURCES = fpsdisplaysink.c debugutilsbad.c
+nodist_libgstdebugutilsbad_la_SOURCES = $(BUILT_SOURCES)
libgstdebugutilsbad_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
libgstdebugutilsbad_la_LIBADD = $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-$(GST_MAJORMINOR)
libgstdebugutilsbad_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
diff --git a/gst/debugutils/debugutils-marshal.list b/gst/debugutils/debugutils-marshal.list
new file mode 100644
index 000000000..8073fd3fe
--- /dev/null
+++ b/gst/debugutils/debugutils-marshal.list
@@ -0,0 +1,2 @@
+VOID:DOUBLE,DOUBLE,DOUBLE
+
diff --git a/gst/debugutils/fpsdisplaysink.c b/gst/debugutils/fpsdisplaysink.c
index ea6e8a295..89199b47b 100644
--- a/gst/debugutils/fpsdisplaysink.c
+++ b/gst/debugutils/fpsdisplaysink.c
@@ -46,9 +46,11 @@
#include "config.h"
#endif
+#include "debugutils-marshal.h"
#include "fpsdisplaysink.h"
#include <gst/interfaces/xoverlay.h>
+#define DEFAULT_SIGNAL_FPS_MEASUREMENTS FALSE
#define DEFAULT_FPS_UPDATE_INTERVAL_MS 500 /* 500 ms */
#define DEFAULT_FONT "Sans 20"
@@ -64,13 +66,21 @@ GST_DEBUG_CATEGORY_STATIC (fps_display_sink_debug);
enum
{
+ /* FILL ME */
+ SIGNAL_FPS_MEASUREMENTS,
+ LAST_SIGNAL
+};
+
+enum
+{
ARG_0,
ARG_SYNC,
ARG_TEXT_OVERLAY,
ARG_VIDEO_SINK,
ARG_FPS_UPDATE_INTERVAL,
ARG_MAX_FPS,
- ARG_MIN_FPS
+ ARG_MIN_FPS,
+ ARG_SIGNAL_FPS_MEASUREMENTS
/* FILL ME */
};
@@ -84,6 +94,8 @@ static void fps_display_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void fps_display_sink_dispose (GObject * object);
+static guint fpsdisplaysink_signals[LAST_SIGNAL] = { 0 };
+
static void
fps_display_sink_class_init (GstFPSDisplaySinkClass * klass)
{
@@ -120,17 +132,43 @@ fps_display_sink_class_init (GstFPSDisplaySinkClass * klass)
" (in ms). Should be set on NULL state", 1, G_MAXINT,
DEFAULT_FPS_UPDATE_INTERVAL_MS,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
+
g_object_class_install_property (gobject_klass, ARG_MAX_FPS,
g_param_spec_double ("max-fps", "Max fps",
"Maximum fps rate measured. Reset when going from NULL to READY."
"-1 means no measurement has yet been done", -1, G_MAXDOUBLE, -1,
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+
g_object_class_install_property (gobject_klass, ARG_MIN_FPS,
g_param_spec_double ("min-fps", "Min fps",
"Minimum fps rate measured. Reset when going from NULL to READY."
"-1 means no measurement has yet been done", -1, G_MAXDOUBLE, -1,
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+ g_object_class_install_property (gobject_klass, ARG_SIGNAL_FPS_MEASUREMENTS,
+ g_param_spec_boolean ("signal-fps-measurements",
+ "Signal fps measurements",
+ "If the fps-measurements signal should be emited.",
+ DEFAULT_SIGNAL_FPS_MEASUREMENTS,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+
+ /**
+ * GstFPSDisplaySink::fps-measurements:
+ * @fpsdisplaysink: a #GstFPSDisplaySink
+ * @fps: The current measured fps
+ * @droprate: The rate at which buffers are being dropped
+ * @avgfps: The average fps
+ *
+ * Signals the application about the measured fps
+ *
+ * Since: 0.10.20
+ */
+ fpsdisplaysink_signals[SIGNAL_FPS_MEASUREMENTS] =
+ g_signal_new ("fps-measurements", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ __gst_debugutils_marshal_VOID__DOUBLE_DOUBLE_DOUBLE,
+ G_TYPE_NONE, 3, G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
+
gstelement_klass->change_state = fps_display_sink_change_state;
gst_element_class_add_pad_template (gstelement_klass,
@@ -262,6 +300,7 @@ fps_display_sink_init (GstFPSDisplaySink * self,
GstFPSDisplaySinkClass * g_class)
{
self->sync = FALSE;
+ self->signal_measurements = DEFAULT_SIGNAL_FPS_MEASUREMENTS;
self->use_text_overlay = TRUE;
self->fps_update_interval = DEFAULT_FPS_UPDATE_INTERVAL_MS;
self->video_sink = NULL;
@@ -307,6 +346,12 @@ display_current_fps (gpointer data)
GST_DEBUG_OBJECT (self, "Updated min-fps to %f", rr);
}
+ if (self->signal_measurements) {
+ g_signal_emit (G_OBJECT (self),
+ fpsdisplaysink_signals[SIGNAL_FPS_MEASUREMENTS], 0, rr, dr,
+ average_fps);
+ }
+
if (dr == 0.0) {
g_snprintf (fps_message, 255, "current: %.2f\naverage: %.2f", rr,
average_fps);
@@ -462,6 +507,9 @@ fps_display_sink_set_property (GObject * object, guint prop_id,
case ARG_FPS_UPDATE_INTERVAL:
self->fps_update_interval = g_value_get_int (value);
break;
+ case ARG_SIGNAL_FPS_MEASUREMENTS:
+ self->signal_measurements = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -493,6 +541,9 @@ fps_display_sink_get_property (GObject * object, guint prop_id,
case ARG_MIN_FPS:
g_value_set_double (value, self->min_fps);
break;
+ case ARG_SIGNAL_FPS_MEASUREMENTS:
+ g_value_set_boolean (value, self->signal_measurements);
+ 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 b2cc50ff1..590b6d9d5 100644
--- a/gst/debugutils/fpsdisplaysink.h
+++ b/gst/debugutils/fpsdisplaysink.h
@@ -63,6 +63,7 @@ struct _GstFPSDisplaySink
/* properties */
gboolean sync;
gboolean use_text_overlay;
+ gboolean signal_measurements;
gint fps_update_interval;
gdouble max_fps;
gdouble min_fps;