mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 16:21:17 +00:00
fpsdisplaysink: add "frames-dropped" and "frames-rendered" properties
https://bugzilla.gnome.org/show_bug.cgi?id=643469
This commit is contained in:
parent
bdf51f12d2
commit
8c48375817
2 changed files with 28 additions and 9 deletions
|
@ -83,7 +83,9 @@ enum
|
||||||
ARG_FPS_UPDATE_INTERVAL,
|
ARG_FPS_UPDATE_INTERVAL,
|
||||||
ARG_MAX_FPS,
|
ARG_MAX_FPS,
|
||||||
ARG_MIN_FPS,
|
ARG_MIN_FPS,
|
||||||
ARG_SIGNAL_FPS_MEASUREMENTS
|
ARG_SIGNAL_FPS_MEASUREMENTS,
|
||||||
|
ARG_FRAMES_DROPPED,
|
||||||
|
ARG_FRAMES_RENDERED
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -150,6 +152,17 @@ fps_display_sink_class_init (GstFPSDisplaySinkClass * klass)
|
||||||
"-1 means no measurement has yet been done", -1, G_MAXDOUBLE, -1,
|
"-1 means no measurement has yet been done", -1, G_MAXDOUBLE, -1,
|
||||||
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
|
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, ARG_FRAMES_DROPPED,
|
||||||
|
g_param_spec_uint ("frames-dropped", "dropped frames",
|
||||||
|
"Number of frames dropped by the sink", 0, G_MAXUINT, 0,
|
||||||
|
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, ARG_FRAMES_RENDERED,
|
||||||
|
g_param_spec_uint ("frames-rendered", "rendered frames",
|
||||||
|
"Number of frames rendered", 0, G_MAXUINT, 0,
|
||||||
|
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
|
||||||
|
|
||||||
|
|
||||||
g_object_class_install_property (gobject_klass, ARG_SIGNAL_FPS_MEASUREMENTS,
|
g_object_class_install_property (gobject_klass, ARG_SIGNAL_FPS_MEASUREMENTS,
|
||||||
g_param_spec_boolean ("signal-fps-measurements",
|
g_param_spec_boolean ("signal-fps-measurements",
|
||||||
"Signal fps measurements",
|
"Signal fps measurements",
|
||||||
|
@ -219,9 +232,9 @@ on_video_sink_data_flow (GstPad * pad, GstMiniObject * mini_obj,
|
||||||
|
|
||||||
gst_event_parse_qos (ev, NULL, &diff, &ts);
|
gst_event_parse_qos (ev, NULL, &diff, &ts);
|
||||||
if (diff <= 0.0) {
|
if (diff <= 0.0) {
|
||||||
self->frames_rendered++;
|
g_atomic_int_inc (&self->frames_rendered);
|
||||||
} else {
|
} else {
|
||||||
self->frames_dropped++;
|
g_atomic_int_inc (&self->frames_dropped);
|
||||||
}
|
}
|
||||||
|
|
||||||
ts = gst_util_get_timestamp ();
|
ts = gst_util_get_timestamp ();
|
||||||
|
@ -334,8 +347,8 @@ display_current_fps (gpointer data)
|
||||||
gdouble time_diff, time_elapsed;
|
gdouble time_diff, time_elapsed;
|
||||||
GstClockTime current_ts = gst_util_get_timestamp ();
|
GstClockTime current_ts = gst_util_get_timestamp ();
|
||||||
|
|
||||||
frames_rendered = self->frames_rendered;
|
frames_rendered = g_atomic_int_get (&self->frames_rendered);
|
||||||
frames_dropped = self->frames_dropped;
|
frames_dropped = g_atomic_int_get (&self->frames_dropped);
|
||||||
|
|
||||||
if ((frames_rendered + frames_dropped) == 0) {
|
if ((frames_rendered + frames_dropped) == 0) {
|
||||||
/* in case timer fired and we didn't yet get any QOS events */
|
/* in case timer fired and we didn't yet get any QOS events */
|
||||||
|
@ -404,8 +417,8 @@ fps_display_sink_start (GstFPSDisplaySink * self)
|
||||||
GstPad *target_pad = NULL;
|
GstPad *target_pad = NULL;
|
||||||
|
|
||||||
/* Init counters */
|
/* Init counters */
|
||||||
self->frames_rendered = G_GUINT64_CONSTANT (0);
|
self->frames_rendered = 0;
|
||||||
self->frames_dropped = G_GUINT64_CONSTANT (0);
|
self->frames_dropped = 0;
|
||||||
self->last_frames_rendered = G_GUINT64_CONSTANT (0);
|
self->last_frames_rendered = G_GUINT64_CONSTANT (0);
|
||||||
self->last_frames_dropped = G_GUINT64_CONSTANT (0);
|
self->last_frames_dropped = G_GUINT64_CONSTANT (0);
|
||||||
self->max_fps = -1;
|
self->max_fps = -1;
|
||||||
|
@ -554,6 +567,12 @@ fps_display_sink_get_property (GObject * object, guint prop_id,
|
||||||
case ARG_MIN_FPS:
|
case ARG_MIN_FPS:
|
||||||
g_value_set_double (value, self->min_fps);
|
g_value_set_double (value, self->min_fps);
|
||||||
break;
|
break;
|
||||||
|
case ARG_FRAMES_DROPPED:
|
||||||
|
g_value_set_uint (value, g_atomic_int_get (&self->frames_dropped));
|
||||||
|
break;
|
||||||
|
case ARG_FRAMES_RENDERED:
|
||||||
|
g_value_set_uint (value, g_atomic_int_get (&self->frames_rendered));
|
||||||
|
break;
|
||||||
case ARG_SIGNAL_FPS_MEASUREMENTS:
|
case ARG_SIGNAL_FPS_MEASUREMENTS:
|
||||||
g_value_set_boolean (value, self->signal_measurements);
|
g_value_set_boolean (value, self->signal_measurements);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -51,8 +51,8 @@ struct _GstFPSDisplaySink
|
||||||
GstPad *ghost_pad;
|
GstPad *ghost_pad;
|
||||||
|
|
||||||
/* statistics */
|
/* statistics */
|
||||||
guint64 frames_rendered, last_frames_rendered;
|
gint frames_rendered, frames_dropped; /* ATOMIC */
|
||||||
guint64 frames_dropped, last_frames_dropped;
|
guint64 last_frames_rendered, last_frames_dropped;
|
||||||
|
|
||||||
GstClockTime start_ts;
|
GstClockTime start_ts;
|
||||||
GstClockTime last_ts;
|
GstClockTime last_ts;
|
||||||
|
|
Loading…
Reference in a new issue