Commit fa99a885 authored by Aaron Boxer's avatar Aaron Boxer

gstbasesink: add stats getter method

fixes #355
parent cfca53ce
...@@ -401,6 +401,7 @@ gst_base_sink_set_last_sample_enabled ...@@ -401,6 +401,7 @@ gst_base_sink_set_last_sample_enabled
gst_base_sink_is_last_sample_enabled gst_base_sink_is_last_sample_enabled
gst_base_sink_get_drop_out_of_segment gst_base_sink_get_drop_out_of_segment
gst_base_sink_set_drop_out_of_segment gst_base_sink_set_drop_out_of_segment
gst_base_sink_get_stats
GST_BASE_SINK_PAD GST_BASE_SINK_PAD
GST_BASE_SINK_GET_PREROLL_COND GST_BASE_SINK_GET_PREROLL_COND
......
...@@ -305,6 +305,7 @@ enum ...@@ -305,6 +305,7 @@ enum
PROP_THROTTLE_TIME, PROP_THROTTLE_TIME,
PROP_MAX_BITRATE, PROP_MAX_BITRATE,
PROP_PROCESSING_DEADLINE, PROP_PROCESSING_DEADLINE,
PROP_STATS,
PROP_LAST PROP_LAST
}; };
...@@ -554,6 +555,24 @@ gst_base_sink_class_init (GstBaseSinkClass * klass) ...@@ -554,6 +555,24 @@ gst_base_sink_class_init (GstBaseSinkClass * klass)
DEFAULT_PROCESSING_DEADLINE, DEFAULT_PROCESSING_DEADLINE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstBaseSink::stats:
*
* Various #GstBaseSink statistics. This property returns a #GstStructure
* with name `application/x-gst-base-sink-stats` with the following fields:
*
* - "average-rate" G_TYPE_DOUBLE average frame rate
* - "dropped" G_TYPE_UINT64 Number of dropped frames
* - "rendered" G_TYPE_UINT64 Number of rendered frames
*
* Since: 1.18
*/
g_object_class_install_property (gobject_class, PROP_STATS,
g_param_spec_boxed ("stats", "Statistics",
"Sink Statistics", GST_TYPE_STRUCTURE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
gstelement_class->change_state = gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_base_sink_change_state); GST_DEBUG_FUNCPTR (gst_base_sink_change_state);
gstelement_class->send_event = GST_DEBUG_FUNCPTR (gst_base_sink_send_event); gstelement_class->send_event = GST_DEBUG_FUNCPTR (gst_base_sink_send_event);
...@@ -1600,6 +1619,9 @@ gst_base_sink_get_property (GObject * object, guint prop_id, GValue * value, ...@@ -1600,6 +1619,9 @@ gst_base_sink_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_PROCESSING_DEADLINE: case PROP_PROCESSING_DEADLINE:
g_value_set_uint64 (value, gst_base_sink_get_processing_deadline (sink)); g_value_set_uint64 (value, gst_base_sink_get_processing_deadline (sink));
break; break;
case PROP_STATS:
g_value_take_boxed (value, gst_base_sink_get_stats (sink));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
...@@ -5375,3 +5397,31 @@ activate_failed: ...@@ -5375,3 +5397,31 @@ activate_failed:
return GST_STATE_CHANGE_FAILURE; return GST_STATE_CHANGE_FAILURE;
} }
} }
/**
* gst_base_sink_get_stats:
* @sink: #GstBaseSink
*
* Return various #GstBaseSink statistics. This function returns a #GstStructure
* with name `application/x-gst-base-sink-stats` with the following fields:
*
* - "average-rate" G_TYPE_DOUBLE average frame rate
* - "dropped" G_TYPE_UINT64 Number of dropped frames
* - "rendered" G_TYPE_UINT64 Number of rendered frames
*
* Returns: (transfer full) pointer to #GstStructure
*
* Since: 1.18
*/
GstStructure *
gst_base_sink_get_stats (GstBaseSink * sink)
{
GstBaseSinkPrivate *priv = NULL;
g_return_val_if_fail (sink != NULL, NULL);
priv = sink->priv;
return gst_structure_new ("application/x-gst-base-sink-stats",
"average-rate", G_TYPE_DOUBLE, priv->avg_rate,
"dropped", G_TYPE_UINT64, priv->dropped,
"rendered", G_TYPE_UINT64, priv->rendered, NULL);
}
...@@ -324,6 +324,9 @@ GST_BASE_API ...@@ -324,6 +324,9 @@ GST_BASE_API
GstFlowReturn gst_base_sink_wait (GstBaseSink *sink, GstClockTime time, GstFlowReturn gst_base_sink_wait (GstBaseSink *sink, GstClockTime time,
GstClockTimeDiff *jitter); GstClockTimeDiff *jitter);
GST_BASE_API
GstStructure *gst_base_sink_get_stats (GstBaseSink * sink);
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstBaseSink, gst_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstBaseSink, gst_object_unref)
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment