goom: post QoS messages when dropping frames due to QoS

This commit is contained in:
Tim-Philipp Müller 2014-11-02 19:29:52 +00:00
parent 85c3c36712
commit b03056eede
2 changed files with 33 additions and 6 deletions

View file

@ -97,6 +97,7 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
static void gst_goom_finalize (GObject * object); static void gst_goom_finalize (GObject * object);
static void gst_goom_reset (GstGoom * goom);
static GstStateChangeReturn gst_goom_change_state (GstElement * element, static GstStateChangeReturn gst_goom_change_state (GstElement * element,
GstStateChange transition); GstStateChange transition);
@ -168,6 +169,8 @@ gst_goom_init (GstGoom * goom)
goom->duration = 0; goom->duration = 0;
goom->plugin = goom_init (goom->width, goom->height); goom->plugin = goom_init (goom->width, goom->height);
gst_goom_reset (goom);
} }
static void static void
@ -193,8 +196,11 @@ gst_goom_reset (GstGoom * goom)
GST_OBJECT_LOCK (goom); GST_OBJECT_LOCK (goom);
goom->proportion = 1.0; goom->proportion = 1.0;
goom->earliest_time = -1; goom->earliest_time = GST_CLOCK_TIME_NONE;
GST_OBJECT_UNLOCK (goom); GST_OBJECT_UNLOCK (goom);
goom->dropped = 0;
goom->processed = 0;
} }
static gboolean static gboolean
@ -547,26 +553,44 @@ gst_goom_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
timestamp += gst_util_uint64_scale_int (dist, GST_SECOND, goom->rate); timestamp += gst_util_uint64_scale_int (dist, GST_SECOND, goom->rate);
} }
/* check for QoS, don't compute buffers that are known to be late */
if (GST_CLOCK_TIME_IS_VALID (timestamp)) { if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
GstClockTime earliest_time;
gdouble proportion;
gint64 qostime; gint64 qostime;
gboolean need_skip;
qostime = gst_segment_to_running_time (&goom->segment, GST_FORMAT_TIME, qostime = gst_segment_to_running_time (&goom->segment, GST_FORMAT_TIME,
timestamp) + goom->duration; timestamp) + goom->duration;
GST_OBJECT_LOCK (goom); GST_OBJECT_LOCK (goom);
/* check for QoS, don't compute buffers that are known to be late */ earliest_time = goom->earliest_time;
need_skip = goom->earliest_time != -1 && qostime <= goom->earliest_time; proportion = goom->proportion;
GST_OBJECT_UNLOCK (goom); GST_OBJECT_UNLOCK (goom);
if (need_skip) { if (GST_CLOCK_TIME_IS_VALID (earliest_time) && qostime <= earliest_time) {
GstClockTime stream_time, jitter;
GstMessage *qos_msg;
GST_WARNING_OBJECT (goom, GST_WARNING_OBJECT (goom,
"QoS: skip ts: %" GST_TIME_FORMAT ", earliest: %" GST_TIME_FORMAT, "QoS: skip ts: %" GST_TIME_FORMAT ", earliest: %" GST_TIME_FORMAT,
GST_TIME_ARGS (qostime), GST_TIME_ARGS (goom->earliest_time)); GST_TIME_ARGS (qostime), GST_TIME_ARGS (earliest_time));
goom->dropped++;
stream_time = gst_segment_to_stream_time (&goom->segment,
GST_FORMAT_TIME, timestamp);
jitter = GST_CLOCK_DIFF (qostime, earliest_time);
qos_msg = gst_message_new_qos (GST_OBJECT (goom), FALSE, qostime,
stream_time, timestamp, GST_BUFFER_DURATION (buffer));
gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
goom->processed, goom->dropped);
gst_element_post_message (GST_ELEMENT (goom), qos_msg);
goto skip; goto skip;
} }
} }
goom->processed++;
/* get next GOOM_SAMPLES, we have at least this amount of samples */ /* get next GOOM_SAMPLES, we have at least this amount of samples */
data = data =
(const guint16 *) gst_adapter_map (goom->adapter, (const guint16 *) gst_adapter_map (goom->adapter,

View file

@ -59,6 +59,9 @@ struct _GstGoom
guint outsize; guint outsize;
GstBufferPool *pool; GstBufferPool *pool;
guint dropped; /* frames dropped / not dropped */
guint processed;
/* samples per frame */ /* samples per frame */
guint spf; guint spf;
/* bytes per frame */ /* bytes per frame */