GstClockTime current_rstart;
GstClockTime current_rstop;
GstClockTimeDiff current_jitter;
+ /* the running time of the previous buffer */
+ GstClockTime prev_rstart;
/* EOS sync time in running time */
GstClockTime eos_rtime;
/* last buffer that arrived in time, running time */
- GstClockTime last_in_time;
+ GstClockTime last_render_time;
/* when the last buffer left the sink, running time */
GstClockTime last_left;
GstClockTime avg_pt;
GstClockTime avg_duration;
gdouble avg_rate;
+ GstClockTime avg_in_diff;
/* these are done on system time. avg_jitter and avg_render are
* compared to eachother to see if the rendering time takes a
/* Cached GstClockID */
GstClockID cached_clock_id;
+
+ /* for throttling and QoS */
+ GstClockTime earliest_in_time;
+ GstClockTime throttle_time;
};
#define DO_RUNNING_AVG(avg,val,size) (((val) + ((size)-1) * (avg)) / (size))
#define DEFAULT_BLOCKSIZE 4096
#define DEFAULT_RENDER_DELAY 0
#define DEFAULT_ENABLE_LAST_BUFFER TRUE
+#define DEFAULT_THROTTLE_TIME 0
enum
{
PROP_LAST_BUFFER,
PROP_BLOCKSIZE,
PROP_RENDER_DELAY,
+ PROP_THROTTLE_TIME,
PROP_LAST
};
/* check if an object was too late */
static gboolean gst_base_sink_is_too_late (GstBaseSink * basesink,
- GstMiniObject * obj, GstClockTime start, GstClockTime stop,
+ GstMiniObject * obj, GstClockTime rstart, GstClockTime rstop,
GstClockReturn status, GstClockTimeDiff jitter);
static GstFlowReturn gst_base_sink_preroll_object (GstBaseSink * basesink,
guint8 obj_type, GstMiniObject * obj);
* Since: 0.10.15
*/
g_object_class_install_property (gobject_class, PROP_LAST_BUFFER,
- gst_param_spec_mini_object ("last-buffer", "Last Buffer",
+ g_param_spec_boxed ("last-buffer", "Last Buffer",
"The last buffer received in the sink", GST_TYPE_BUFFER,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
*
* Since: 0.10.22
*/
+ /* FIXME 0.11: blocksize property should be int, otherwise min>max.. */
g_object_class_install_property (gobject_class, PROP_BLOCKSIZE,
g_param_spec_uint ("blocksize", "Block size",
"Size in bytes to pull per buffer (0 = default)", 0, G_MAXUINT,
g_param_spec_uint64 ("render-delay", "Render Delay",
"Additional render delay of the sink in nanoseconds", 0, G_MAXUINT64,
DEFAULT_RENDER_DELAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ /**
+ * GstBaseSink:throttle-time
+ *
+ * The time to insert between buffers. This property can be used to control
+ * the maximum amount of buffers per second to render. Setting this property
+ * to a value bigger than 0 will make the sink create THROTTLE QoS events.
+ *
+ * Since: 0.10.33
+ */
+ g_object_class_install_property (gobject_class, PROP_THROTTLE_TIME,
+ g_param_spec_uint64 ("throttle-time", "Throttle time",
+ "The time to keep between rendered buffers (unused)", 0, G_MAXUINT64,
+ DEFAULT_THROTTLE_TIME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_base_sink_change_state);
GstFlowReturn result = GST_FLOW_OK;
bsink = GST_BASE_SINK (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (bsink == NULL))
+ return GST_FLOW_WRONG_STATE;
bclass = GST_BASE_SINK_GET_CLASS (bsink);
if (bclass->buffer_alloc)
gst_element_add_pad (GST_ELEMENT_CAST (basesink), basesink->sinkpad);
basesink->pad_mode = GST_ACTIVATE_NONE;
+ basesink->preroll_lock = g_mutex_new ();
+ basesink->preroll_cond = g_cond_new ();
basesink->preroll_queue = g_queue_new ();
- basesink->abidata.ABI.clip_segment = gst_segment_new ();
+ basesink->clip_segment = gst_segment_new ();
priv->have_latency = FALSE;
basesink->can_activate_push = DEFAULT_CAN_ACTIVATE_PUSH;
basesink->can_activate_pull = DEFAULT_CAN_ACTIVATE_PULL;
basesink->sync = DEFAULT_SYNC;
- basesink->abidata.ABI.max_lateness = DEFAULT_MAX_LATENESS;
+ basesink->max_lateness = DEFAULT_MAX_LATENESS;
g_atomic_int_set (&priv->qos_enabled, DEFAULT_QOS);
priv->async_enabled = DEFAULT_ASYNC;
priv->ts_offset = DEFAULT_TS_OFFSET;
priv->blocksize = DEFAULT_BLOCKSIZE;
priv->cached_clock_id = NULL;
g_atomic_int_set (&priv->enable_last_buffer, DEFAULT_ENABLE_LAST_BUFFER);
+ priv->throttle_time = DEFAULT_THROTTLE_TIME;
GST_OBJECT_FLAG_SET (basesink, GST_ELEMENT_IS_SINK);
}
basesink = GST_BASE_SINK (object);
+ g_mutex_free (basesink->preroll_lock);
+ g_cond_free (basesink->preroll_cond);
g_queue_free (basesink->preroll_queue);
- gst_segment_free (basesink->abidata.ABI.clip_segment);
+ gst_segment_free (basesink->clip_segment);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
g_return_if_fail (GST_IS_BASE_SINK (sink));
GST_OBJECT_LOCK (sink);
- sink->abidata.ABI.max_lateness = max_lateness;
+ sink->max_lateness = max_lateness;
GST_OBJECT_UNLOCK (sink);
}
g_return_val_if_fail (GST_IS_BASE_SINK (sink), -1);
GST_OBJECT_LOCK (sink);
- res = sink->abidata.ABI.max_lateness;
+ res = sink->max_lateness;
GST_OBJECT_UNLOCK (sink);
return res;
{
g_return_if_fail (GST_IS_BASE_SINK (sink));
- GST_PAD_PREROLL_LOCK (sink->sinkpad);
+ GST_BASE_SINK_PREROLL_LOCK (sink);
g_atomic_int_set (&sink->priv->async_enabled, enabled);
GST_LOG_OBJECT (sink, "set async enabled to %d", enabled);
- GST_PAD_PREROLL_UNLOCK (sink->sinkpad);
+ GST_BASE_SINK_PREROLL_UNLOCK (sink);
}
/**
*
* Since: 0.10.22
*/
+/* FIXME 0.11: blocksize property should be int, otherwise min>max.. */
void
gst_base_sink_set_blocksize (GstBaseSink * sink, guint blocksize)
{
*
* Since: 0.10.22
*/
+/* FIXME 0.11: blocksize property should be int, otherwise min>max.. */
guint
gst_base_sink_get_blocksize (GstBaseSink * sink)
{
return res;
}
+/**
+ * gst_base_sink_set_throttle_time:
+ * @sink: a #GstBaseSink
+ * @throttle: the throttle time in nanoseconds
+ *
+ * Set the time that will be inserted between rendered buffers. This
+ * can be used to control the maximum buffers per second that the sink
+ * will render.
+ *
+ * Since: 0.10.33
+ */
+void
+gst_base_sink_set_throttle_time (GstBaseSink * sink, guint64 throttle)
+{
+ g_return_if_fail (GST_IS_BASE_SINK (sink));
+
+ GST_OBJECT_LOCK (sink);
+ sink->priv->throttle_time = throttle;
+ GST_LOG_OBJECT (sink, "set throttle_time to %" G_GUINT64_FORMAT, throttle);
+ GST_OBJECT_UNLOCK (sink);
+}
+
+/**
+ * gst_base_sink_get_throttle_time:
+ * @sink: a #GstBaseSink
+ *
+ * Get the time that will be inserted between frames to control the
+ * maximum buffers per second.
+ *
+ * Returns: the number of nanoseconds @sink will put between frames.
+ *
+ * Since: 0.10.33
+ */
+guint64
+gst_base_sink_get_throttle_time (GstBaseSink * sink)
+{
+ guint64 res;
+
+ g_return_val_if_fail (GST_IS_BASE_SINK (sink), 0);
+
+ GST_OBJECT_LOCK (sink);
+ res = sink->priv->throttle_time;
+ GST_OBJECT_UNLOCK (sink);
+
+ return res;
+}
+
static void
gst_base_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
switch (prop_id) {
case PROP_PREROLL_QUEUE_LEN:
/* preroll lock necessary to serialize with finish_preroll */
- GST_PAD_PREROLL_LOCK (sink->sinkpad);
+ GST_BASE_SINK_PREROLL_LOCK (sink);
g_atomic_int_set (&sink->preroll_queue_max_len, g_value_get_uint (value));
- GST_PAD_PREROLL_UNLOCK (sink->sinkpad);
+ GST_BASE_SINK_PREROLL_UNLOCK (sink);
break;
case PROP_SYNC:
gst_base_sink_set_sync (sink, g_value_get_boolean (value));
case PROP_ENABLE_LAST_BUFFER:
gst_base_sink_set_last_buffer_enabled (sink, g_value_get_boolean (value));
break;
+ case PROP_THROTTLE_TIME:
+ gst_base_sink_set_throttle_time (sink, g_value_get_uint64 (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_RENDER_DELAY:
g_value_set_uint64 (value, gst_base_sink_get_render_delay (sink));
break;
+ case PROP_THROTTLE_TIME:
+ g_value_set_uint64 (value, gst_base_sink_get_throttle_time (sink));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
GST_OBJECT_UNLOCK (basesink);
}
/* and signal any waiters now */
- GST_PAD_PREROLL_SIGNAL (pad);
+ GST_BASE_SINK_PREROLL_SIGNAL (basesink);
}
/* with STREAM_LOCK, configures given segment with the event information. */
case GST_STATE_PLAYING:
{
GstBaseSinkClass *bclass;
- GstStateChangeReturn ret;
bclass = GST_BASE_SINK_GET_CLASS (basesink);
if (current == GST_STATE_READY) {
post_paused = TRUE;
}
-
- /* make sure we notify the subclass of async playing */
- if (bclass->async_play) {
- GST_WARNING_OBJECT (basesink, "deprecated async_play");
- ret = bclass->async_play (basesink);
- if (ret == GST_STATE_CHANGE_FAILURE)
- goto async_failed;
- }
break;
}
case GST_STATE_PAUSED:
GST_OBJECT_UNLOCK (basesink);
return FALSE;
}
-async_failed:
- {
- GST_DEBUG_OBJECT (basesink, "async commit failed");
- GST_STATE_RETURN (basesink) = GST_STATE_CHANGE_FAILURE;
- GST_OBJECT_UNLOCK (basesink);
- return FALSE;
- }
}
static void
segment->start = current->start_start;
/* the clip segment is used for position report in paused... */
- memcpy (sink->abidata.ABI.clip_segment, segment, sizeof (GstSegment));
+ memcpy (sink->clip_segment, segment, sizeof (GstSegment));
/* post the step done when we know the stepped duration in TIME */
message =
}
/* set last stop position */
- if (G_LIKELY (cstop != GST_CLOCK_TIME_NONE))
+ if (G_LIKELY (stop != GST_CLOCK_TIME_NONE && cstop != GST_CLOCK_TIME_NONE))
gst_segment_set_last_stop (segment, GST_FORMAT_TIME, cstop);
else
gst_segment_set_last_stop (segment, GST_FORMAT_TIME, cstart);
* return and is not adjusted with any latency or offset configured in the
* sink.
*
- * Since 0.10.20
+ * Since: 0.10.20
*
* Returns: #GstClockReturn
*/
* entry. */
sink->clock_id = sink->priv->cached_clock_id;
/* release the preroll lock while waiting */
- GST_PAD_PREROLL_UNLOCK (sink->sinkpad);
+ GST_BASE_SINK_PREROLL_UNLOCK (sink);
ret = gst_clock_id_wait (sink->priv->cached_clock_id, jitter);
- GST_PAD_PREROLL_LOCK (sink->sinkpad);
+ GST_BASE_SINK_PREROLL_LOCK (sink);
sink->clock_id = NULL;
return ret;
sink->have_preroll = TRUE;
GST_DEBUG_OBJECT (sink, "waiting in preroll for flush or PLAYING");
/* block until the state changes, or we get a flush, or something */
- GST_PAD_PREROLL_WAIT (sink->sinkpad);
+ GST_BASE_SINK_PREROLL_WAIT (sink);
sink->have_preroll = FALSE;
if (G_UNLIKELY (sink->flushing))
goto stopping;
}
}
+static inline guint8
+get_object_type (GstMiniObject * obj)
+{
+ guint8 obj_type;
+
+ if (G_LIKELY (GST_IS_BUFFER (obj)))
+ obj_type = _PR_IS_BUFFER;
+ else if (GST_IS_EVENT (obj))
+ obj_type = _PR_IS_EVENT;
+ else if (GST_IS_BUFFER_LIST (obj))
+ obj_type = _PR_IS_BUFFERLIST;
+ else
+ obj_type = _PR_IS_NOTHING;
+
+ return obj_type;
+}
+
/**
* gst_base_sink_do_preroll:
* @sink: the sink
* Returns: #GST_FLOW_OK if the preroll completed and processing can
* continue. Any other return value should be returned from the render vmethod.
*
- * Since 0.10.22
+ * Since: 0.10.22
*/
GstFlowReturn
gst_base_sink_do_preroll (GstBaseSink * sink, GstMiniObject * obj)
GstFlowReturn ret;
while (G_UNLIKELY (sink->need_preroll)) {
- guint8 obj_type = _PR_IS_NOTHING;
+ guint8 obj_type;
GST_DEBUG_OBJECT (sink, "prerolling object %p", obj);
- if (G_LIKELY (GST_IS_BUFFER (obj)))
- obj_type = _PR_IS_BUFFER;
- else if (GST_IS_EVENT (obj))
- obj_type = _PR_IS_EVENT;
- else if (GST_IS_BUFFER_LIST (obj))
- obj_type = _PR_IS_BUFFERLIST;
+ obj_type = get_object_type (obj);
ret = gst_base_sink_preroll_object (sink, obj_type, obj);
if (ret != GST_FLOW_OK)
/* ERRORS */
preroll_failed:
{
- GST_DEBUG_OBJECT (sink, "preroll failed %d", ret);
+ GST_DEBUG_OBJECT (sink, "preroll failed: %s", gst_flow_get_name (ret));
return ret;
}
}
*
* Returns: #GstFlowReturn
*
- * Since 0.10.15
+ * Since: 0.10.15
*/
GstFlowReturn
gst_base_sink_wait_eos (GstBaseSink * sink, GstClockTime time,
/* save sync time for eos when the previous object needed sync */
priv->eos_rtime = (do_sync ? priv->current_rstop : GST_CLOCK_TIME_NONE);
+ /* calculate inter frame spacing */
+ if (G_UNLIKELY (priv->prev_rstart != -1 && priv->prev_rstart < rstart)) {
+ GstClockTime in_diff;
+
+ in_diff = rstart - priv->prev_rstart;
+
+ if (priv->avg_in_diff == -1)
+ priv->avg_in_diff = in_diff;
+ else
+ priv->avg_in_diff = UPDATE_RUNNING_AVG (priv->avg_in_diff, in_diff);
+
+ GST_LOG_OBJECT (basesink, "avg frame diff %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (priv->avg_in_diff));
+
+ }
+ priv->prev_rstart = rstart;
+
+ if (G_UNLIKELY (priv->earliest_in_time != -1
+ && rstart < priv->earliest_in_time))
+ goto qos_dropped;
+
again:
/* first do preroll, this makes sure we commit our state
* to PAUSED and can continue to PLAYING. We cannot perform
GST_DEBUG_OBJECT (basesink, "non syncable object %p", obj);
return GST_FLOW_OK;
}
+qos_dropped:
+ {
+ GST_DEBUG_OBJECT (basesink, "dropped because of QoS %p", obj);
+ *late = TRUE;
+ return GST_FLOW_OK;
+ }
flushing:
{
GST_DEBUG_OBJECT (basesink, "we are flushing");
}
static gboolean
-gst_base_sink_send_qos (GstBaseSink * basesink,
+gst_base_sink_send_qos (GstBaseSink * basesink, GstQOSType type,
gdouble proportion, GstClockTime time, GstClockTimeDiff diff)
{
GstEvent *event;
/* generate Quality-of-Service event */
GST_CAT_DEBUG_OBJECT (GST_CAT_QOS, basesink,
- "qos: proportion: %lf, diff %" G_GINT64_FORMAT ", timestamp %"
- GST_TIME_FORMAT, proportion, diff, GST_TIME_ARGS (time));
+ "qos: type %d, proportion: %lf, diff %" G_GINT64_FORMAT ", timestamp %"
+ GST_TIME_FORMAT, type, proportion, diff, GST_TIME_ARGS (time));
- event = gst_event_new_qos (proportion, diff, time);
+ event = gst_event_new_qos_full (type, proportion, diff, time);
/* send upstream */
res = gst_pad_push_event (basesink->sinkpad, event);
}
/* calculate duration of the buffer */
- if (GST_CLOCK_TIME_IS_VALID (stop))
+ if (GST_CLOCK_TIME_IS_VALID (stop) && stop != start)
duration = stop - start;
else
- duration = GST_CLOCK_TIME_NONE;
+ duration = priv->avg_in_diff;
/* if we have the time when the last buffer left us, calculate
* processing time */
}
GST_CAT_DEBUG_OBJECT (GST_CAT_QOS, sink, "start: %" GST_TIME_FORMAT
- ", entered %" GST_TIME_FORMAT ", left %" GST_TIME_FORMAT ", pt: %"
- GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT ",jitter %"
- G_GINT64_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (entered),
- GST_TIME_ARGS (left), GST_TIME_ARGS (pt), GST_TIME_ARGS (duration),
- jitter);
+ ", stop %" GST_TIME_FORMAT ", entered %" GST_TIME_FORMAT ", left %"
+ GST_TIME_FORMAT ", pt: %" GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT
+ ",jitter %" G_GINT64_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (stop),
+ GST_TIME_ARGS (entered), GST_TIME_ARGS (left), GST_TIME_ARGS (pt),
+ GST_TIME_ARGS (duration), jitter);
GST_CAT_DEBUG_OBJECT (GST_CAT_QOS, sink, "avg_duration: %" GST_TIME_FORMAT
", avg_pt: %" GST_TIME_FORMAT ", avg_rate: %g",
gst_guint64_to_gdouble (priv->avg_pt) /
gst_guint64_to_gdouble (priv->avg_duration);
else
- rate = 0.0;
+ rate = 1.0;
if (GST_CLOCK_TIME_IS_VALID (priv->last_left)) {
if (dropped || priv->avg_rate < 0.0) {
if (priv->avg_rate >= 0.0) {
+ GstQOSType type;
+ GstClockTimeDiff diff;
+
/* if we have a valid rate, start sending QoS messages */
if (priv->current_jitter < 0) {
/* make sure we never go below 0 when adding the jitter to the
if (priv->current_rstart < -priv->current_jitter)
priv->current_jitter = -priv->current_rstart;
}
- gst_base_sink_send_qos (sink, priv->avg_rate, priv->current_rstart,
- priv->current_jitter);
+
+ if (priv->throttle_time > 0) {
+ diff = priv->throttle_time;
+ type = GST_QOS_TYPE_THROTTLE;
+ } else {
+ diff = priv->current_jitter;
+ if (diff <= 0)
+ type = GST_QOS_TYPE_OVERFLOW;
+ else
+ type = GST_QOS_TYPE_UNDERFLOW;
+ }
+
+ gst_base_sink_send_qos (sink, type, priv->avg_rate, priv->current_rstart,
+ diff);
}
/* record when this buffer will leave us */
priv = sink->priv;
- priv->last_in_time = GST_CLOCK_TIME_NONE;
+ priv->last_render_time = GST_CLOCK_TIME_NONE;
+ priv->prev_rstart = GST_CLOCK_TIME_NONE;
+ priv->earliest_in_time = GST_CLOCK_TIME_NONE;
priv->last_left = GST_CLOCK_TIME_NONE;
priv->avg_duration = GST_CLOCK_TIME_NONE;
priv->avg_pt = GST_CLOCK_TIME_NONE;
priv->avg_rate = -1.0;
priv->avg_render = GST_CLOCK_TIME_NONE;
+ priv->avg_in_diff = GST_CLOCK_TIME_NONE;
priv->rendered = 0;
priv->dropped = 0;
/* Checks if the object was scheduled too late.
*
- * start/stop contain the raw timestamp start and stop values
+ * rstart/rstop contain the running_time start and stop values
* of the object.
*
* status and jitter contain the return values from the clock wait.
*/
static gboolean
gst_base_sink_is_too_late (GstBaseSink * basesink, GstMiniObject * obj,
- GstClockTime start, GstClockTime stop,
+ GstClockTime rstart, GstClockTime rstop,
GstClockReturn status, GstClockTimeDiff jitter)
{
gboolean late;
if (G_LIKELY (status != GST_CLOCK_EARLY))
goto in_time;
- max_lateness = basesink->abidata.ABI.max_lateness;
+ max_lateness = basesink->max_lateness;
/* check if frame dropping is enabled */
if (max_lateness == -1)
goto not_buffer;
/* can't do check if we don't have a timestamp */
- if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (start)))
+ if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (rstart)))
goto no_timestamp;
/* we can add a valid stop time */
- if (GST_CLOCK_TIME_IS_VALID (stop))
- max_lateness += stop;
- else
- max_lateness += start;
+ if (GST_CLOCK_TIME_IS_VALID (rstop))
+ max_lateness += rstop;
+ else {
+ max_lateness += rstart;
+ /* no stop time, use avg frame diff */
+ if (priv->avg_in_diff != -1)
+ max_lateness += priv->avg_in_diff;
+ }
/* if the jitter bigger than duration and lateness we are too late */
- if ((late = start + jitter > max_lateness)) {
+ if ((late = rstart + jitter > max_lateness)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_PERFORMANCE, basesink,
"buffer is too late %" GST_TIME_FORMAT
- " > %" GST_TIME_FORMAT, GST_TIME_ARGS (start + jitter),
+ " > %" GST_TIME_FORMAT, GST_TIME_ARGS (rstart + jitter),
GST_TIME_ARGS (max_lateness));
/* !!emergency!!, if we did not receive anything valid for more than a
* second, render it anyway so the user sees something */
- if (GST_CLOCK_TIME_IS_VALID (priv->last_in_time) &&
- start - priv->last_in_time > GST_SECOND) {
+ if (GST_CLOCK_TIME_IS_VALID (priv->last_render_time) &&
+ rstart - priv->last_render_time > GST_SECOND) {
late = FALSE;
GST_ELEMENT_WARNING (basesink, CORE, CLOCK,
(_("A lot of buffers are being dropped.")),
("There may be a timestamping problem, or this computer is too slow."));
GST_CAT_DEBUG_OBJECT (GST_CAT_PERFORMANCE, basesink,
"**emergency** last buffer at %" GST_TIME_FORMAT " > GST_SECOND",
- GST_TIME_ARGS (priv->last_in_time));
+ GST_TIME_ARGS (priv->last_render_time));
}
}
done:
- if (!late || !GST_CLOCK_TIME_IS_VALID (priv->last_in_time)) {
- priv->last_in_time = start;
+ if (!late || !GST_CLOCK_TIME_IS_VALID (priv->last_render_time)) {
+ priv->last_render_time = rstart;
+ /* the next allowed input timestamp */
+ if (priv->throttle_time > 0)
+ priv->earliest_in_time = rstart + priv->throttle_time;
}
return late;
* If buffer list, use the first group buffer within the list
* for syncing
*/
- sync_obj = gst_buffer_list_get (GST_BUFFER_LIST_CAST (obj), 0, 0);
+ sync_obj = gst_buffer_list_get (GST_BUFFER_LIST_CAST (obj), 0);
g_assert (NULL != sync_obj);
} else {
sync_obj = obj;
GstClockTime timestamp;
if (OBJ_IS_BUFFERLIST (obj_type)) {
- buf = gst_buffer_list_get (GST_BUFFER_LIST_CAST (obj), 0, 0);
+ buf = gst_buffer_list_get (GST_BUFFER_LIST_CAST (obj), 0);
g_assert (NULL != buf);
} else {
buf = GST_BUFFER_CAST (obj);
q = basesink->preroll_queue;
while (G_UNLIKELY (!g_queue_is_empty (q))) {
GstMiniObject *o;
+ guint8 ot;
o = g_queue_pop_head (q);
GST_DEBUG_OBJECT (basesink, "rendering queued object %p", o);
+ ot = get_object_type (o);
+
/* do something with the return value */
- ret =
- gst_base_sink_render_object (basesink, pad,
- GST_IS_BUFFER (o) ? _PR_IS_BUFFER : _PR_IS_EVENT, o);
+ ret = gst_base_sink_render_object (basesink, pad, ot, o);
if (ret != GST_FLOW_OK)
goto dequeue_failed;
}
{
GstFlowReturn ret;
- GST_PAD_PREROLL_LOCK (pad);
+ GST_BASE_SINK_PREROLL_LOCK (basesink);
if (G_UNLIKELY (basesink->flushing))
goto flushing;
ret =
gst_base_sink_queue_object_unlocked (basesink, pad, _PR_IS_EVENT, obj,
prerollable);
- GST_PAD_PREROLL_UNLOCK (pad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
return ret;
flushing:
{
GST_DEBUG_OBJECT (basesink, "sink is flushing");
- GST_PAD_PREROLL_UNLOCK (pad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
gst_mini_object_unref (obj);
return GST_FLOW_WRONG_STATE;
}
{
GST_DEBUG_OBJECT (basesink,
"we are EOS, dropping object, return UNEXPECTED");
- GST_PAD_PREROLL_UNLOCK (pad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
gst_mini_object_unref (obj);
return GST_FLOW_UNEXPECTED;
}
* anymore */
GST_PAD_STREAM_LOCK (pad);
gst_base_sink_reset_qos (basesink);
+ /* and we need to commit our state again on the next
+ * prerolled buffer */
+ basesink->playing_async = TRUE;
if (basesink->priv->async_enabled) {
- /* and we need to commit our state again on the next
- * prerolled buffer */
- basesink->playing_async = TRUE;
gst_element_lost_state (GST_ELEMENT_CAST (basesink));
} else {
basesink->priv->have_latency = TRUE;
/* we need new segment info after the flush. */
basesink->have_newsegment = FALSE;
gst_segment_init (&basesink->segment, GST_FORMAT_UNDEFINED);
- gst_segment_init (basesink->abidata.ABI.clip_segment, GST_FORMAT_UNDEFINED);
+ gst_segment_init (basesink->clip_segment, GST_FORMAT_UNDEFINED);
}
GST_OBJECT_UNLOCK (basesink);
}
GstBaseSinkClass *bclass;
basesink = GST_BASE_SINK (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (basesink == NULL)) {
+ gst_event_unref (event);
+ return FALSE;
+ }
bclass = GST_BASE_SINK_GET_CLASS (basesink);
- GST_DEBUG_OBJECT (basesink, "reveived event %p %" GST_PTR_FORMAT, event,
+ GST_DEBUG_OBJECT (basesink, "received event %p %" GST_PTR_FORMAT, event,
event);
switch (GST_EVENT_TYPE (event)) {
{
GstFlowReturn ret;
- GST_PAD_PREROLL_LOCK (pad);
+ GST_BASE_SINK_PREROLL_LOCK (basesink);
if (G_UNLIKELY (basesink->flushing))
goto flushing;
if (G_UNLIKELY (ret != GST_FLOW_OK))
result = FALSE;
}
- GST_PAD_PREROLL_UNLOCK (pad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
break;
}
case GST_EVENT_NEWSEGMENT:
GST_DEBUG_OBJECT (basesink, "newsegment %p", event);
- GST_PAD_PREROLL_LOCK (pad);
+ GST_BASE_SINK_PREROLL_LOCK (basesink);
if (G_UNLIKELY (basesink->flushing))
goto flushing;
* we need to configure the current clipping segment and insert the event
* in the queue to serialize it with the buffers for rendering. */
gst_base_sink_configure_segment (basesink, pad, event,
- basesink->abidata.ABI.clip_segment);
+ basesink->clip_segment);
ret =
gst_base_sink_queue_object_unlocked (basesink, pad,
GST_OBJECT_UNLOCK (basesink);
}
}
- GST_PAD_PREROLL_UNLOCK (pad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
break;
}
case GST_EVENT_FLUSH_START:
flushing:
{
GST_DEBUG_OBJECT (basesink, "we are flushing");
- GST_PAD_PREROLL_UNLOCK (pad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
result = FALSE;
gst_event_unref (event);
goto done;
goto was_eos;
if (OBJ_IS_BUFFERLIST (obj_type)) {
- time_buf = gst_buffer_list_get (GST_BUFFER_LIST_CAST (obj), 0, 0);
+ time_buf = gst_buffer_list_get (GST_BUFFER_LIST_CAST (obj), 0);
g_assert (NULL != time_buf);
} else {
time_buf = GST_BUFFER_CAST (obj);
}
/* for code clarity */
- clip_segment = basesink->abidata.ABI.clip_segment;
+ clip_segment = basesink->clip_segment;
if (G_UNLIKELY (!basesink->have_newsegment)) {
gboolean sync;
if (G_UNLIKELY (basesink->pad_mode != GST_ACTIVATE_PUSH))
goto wrong_mode;
- GST_PAD_PREROLL_LOCK (pad);
+ GST_BASE_SINK_PREROLL_LOCK (basesink);
result = gst_base_sink_chain_unlocked (basesink, pad, obj_type, obj);
- GST_PAD_PREROLL_UNLOCK (pad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
done:
return result;
if (G_LIKELY (bclass->render_list)) {
result = gst_base_sink_chain_main (basesink, pad, _PR_IS_BUFFERLIST, list);
} else {
- GstBufferListIterator *it;
- GstBuffer *group;
+ guint i, len;
+ GstBuffer *buffer;
GST_INFO_OBJECT (pad, "chaining each group in list as a merged buffer");
- it = gst_buffer_list_iterate (list);
+ len = gst_buffer_list_len (list);
- if (gst_buffer_list_iterator_next_group (it)) {
- do {
- group = gst_buffer_list_iterator_merge_group (it);
- if (group == NULL) {
- group = gst_buffer_new ();
- GST_CAT_INFO_OBJECT (GST_CAT_SCHEDULING, pad, "chaining empty group");
- } else {
- GST_CAT_INFO_OBJECT (GST_CAT_SCHEDULING, pad, "chaining group");
- }
- result = gst_base_sink_chain_main (basesink, pad, _PR_IS_BUFFER, group);
- } while (result == GST_FLOW_OK
- && gst_buffer_list_iterator_next_group (it));
- } else {
- GST_CAT_INFO_OBJECT (GST_CAT_SCHEDULING, pad, "chaining empty group");
- result =
- gst_base_sink_chain_main (basesink, pad, _PR_IS_BUFFER,
- gst_buffer_new ());
+ result = GST_FLOW_OK;
+ for (i = 0; i < len; i++) {
+ buffer = gst_buffer_list_get (list, 0);
+ result = gst_base_sink_chain_main (basesink, pad, _PR_IS_BUFFER,
+ gst_buffer_ref (buffer));
+ if (result != GST_FLOW_OK)
+ break;
}
- gst_buffer_list_iterator_free (it);
gst_buffer_list_unref (list);
}
return result;
GST_DEBUG_OBJECT (sink, "stop flushing upstream");
gst_pad_push_event (pad, gst_event_new_flush_stop ());
gst_base_sink_flush_stop (sink, pad);
- } else if (res && sink->abidata.ABI.running) {
+ } else if (res && sink->running) {
/* we are running the current segment and doing a non-flushing seek,
* close the segment first based on the last_stop. */
GST_DEBUG_OBJECT (sink, "closing running segment %" G_GINT64_FORMAT
}
sink->priv->discont = TRUE;
- sink->abidata.ABI.running = TRUE;
+ sink->running = TRUE;
GST_PAD_STREAM_UNLOCK (pad);
if (bclass->unlock)
bclass->unlock (sink);
- GST_PAD_PREROLL_LOCK (sink->sinkpad);
+ GST_BASE_SINK_PREROLL_LOCK (sink);
/* now that we have the PREROLL lock, clear our unlock request */
if (bclass->unlock_stop)
bclass->unlock_stop (sink);
if (sink->have_preroll) {
GST_DEBUG_OBJECT (sink, "signal waiter");
priv->step_unlock = TRUE;
- GST_PAD_PREROLL_SIGNAL (sink->sinkpad);
+ GST_BASE_SINK_PREROLL_SIGNAL (sink);
}
- GST_PAD_PREROLL_UNLOCK (sink->sinkpad);
+ GST_BASE_SINK_PREROLL_UNLOCK (sink);
} else {
/* update the stepinfo and make it valid */
set_step_info (sink, current, pending, seqnum, format, amount, rate, flush,
if (G_UNLIKELY (buf == NULL))
goto no_buffer;
- offset += GST_BUFFER_SIZE (buf);
+ offset += gst_buffer_get_size (buf);
gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_BYTES, offset);
- GST_PAD_PREROLL_LOCK (pad);
+ GST_BASE_SINK_PREROLL_LOCK (basesink);
result = gst_base_sink_chain_unlocked (basesink, pad, _PR_IS_BUFFER, buf);
- GST_PAD_PREROLL_UNLOCK (pad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
if (G_UNLIKELY (result != GST_FLOW_OK))
goto paused;
bclass->unlock (basesink);
}
- GST_PAD_PREROLL_LOCK (pad);
+ GST_BASE_SINK_PREROLL_LOCK (basesink);
basesink->flushing = flushing;
if (flushing) {
/* step 1, now that we have the PREROLL lock, clear our unlock request */
"flushing out data thread, need preroll to TRUE");
gst_base_sink_preroll_queue_flush (basesink, pad);
}
- GST_PAD_PREROLL_UNLOCK (pad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
return TRUE;
}
format = GST_FORMAT_BYTES;
gst_segment_init (&basesink->segment, format);
- gst_segment_init (basesink->abidata.ABI.clip_segment, format);
+ gst_segment_init (basesink->clip_segment, format);
GST_OBJECT_LOCK (basesink);
basesink->have_newsegment = TRUE;
GST_OBJECT_UNLOCK (basesink);
if (result) {
GST_DEBUG_OBJECT (basesink,
"setting duration in bytes to %" G_GINT64_FORMAT, duration);
- gst_segment_set_duration (basesink->abidata.ABI.clip_segment, format,
- duration);
+ gst_segment_set_duration (basesink->clip_segment, format, duration);
gst_segment_set_duration (&basesink->segment, format, duration);
} else {
GST_DEBUG_OBJECT (basesink, "unknown duration");
* main segment directly with the new segment values without it having to be
* activated by the rendering after preroll */
if (basesink->pad_mode == GST_ACTIVATE_PUSH)
- segment = basesink->abidata.ABI.clip_segment;
+ segment = basesink->clip_segment;
else
segment = &basesink->segment;
case GST_STATE_CHANGE_READY_TO_PAUSED:
/* need to complete preroll before this state change completes, there
* is no data flow in READY so we can safely assume we need to preroll. */
- GST_PAD_PREROLL_LOCK (basesink->sinkpad);
+ GST_BASE_SINK_PREROLL_LOCK (basesink);
GST_DEBUG_OBJECT (basesink, "READY to PAUSED");
basesink->have_newsegment = FALSE;
gst_segment_init (&basesink->segment, GST_FORMAT_UNDEFINED);
- gst_segment_init (basesink->abidata.ABI.clip_segment,
- GST_FORMAT_UNDEFINED);
+ gst_segment_init (basesink->clip_segment, GST_FORMAT_UNDEFINED);
basesink->offset = 0;
basesink->have_preroll = FALSE;
priv->step_unlock = FALSE;
} else {
priv->have_latency = TRUE;
}
- GST_PAD_PREROLL_UNLOCK (basesink->sinkpad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
- GST_PAD_PREROLL_LOCK (basesink->sinkpad);
+ GST_BASE_SINK_PREROLL_LOCK (basesink);
if (!gst_base_sink_needs_preroll (basesink)) {
GST_DEBUG_OBJECT (basesink, "PAUSED to PLAYING, don't need preroll");
/* no preroll needed anymore now. */
gst_element_post_message (GST_ELEMENT_CAST (basesink), message);
} else {
GST_DEBUG_OBJECT (basesink, "signal preroll");
- GST_PAD_PREROLL_SIGNAL (basesink->sinkpad);
+ GST_BASE_SINK_PREROLL_SIGNAL (basesink);
}
} else {
GST_DEBUG_OBJECT (basesink, "PAUSED to PLAYING, we are not prerolled");
gst_message_new_async_start (GST_OBJECT_CAST (basesink), FALSE));
}
}
- GST_PAD_PREROLL_UNLOCK (basesink->sinkpad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
break;
default:
break;
if (bclass->unlock)
bclass->unlock (basesink);
- GST_PAD_PREROLL_LOCK (basesink->sinkpad);
+ GST_BASE_SINK_PREROLL_LOCK (basesink);
GST_DEBUG_OBJECT (basesink, "got preroll lock");
/* now that we have the PREROLL lock, clear our unlock request */
if (bclass->unlock_stop)
", dropped: %" G_GUINT64_FORMAT, priv->rendered, priv->dropped);
gst_base_sink_reset_qos (basesink);
- GST_PAD_PREROLL_UNLOCK (basesink->sinkpad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
- GST_PAD_PREROLL_LOCK (basesink->sinkpad);
+ GST_BASE_SINK_PREROLL_LOCK (basesink);
/* start by reseting our position state with the object lock so that the
* position query gets the right idea. We do this before we post the
* messages so that the message handlers pick this up. */
} else {
GST_DEBUG_OBJECT (basesink, "PAUSED to READY, don't need_preroll");
}
- GST_PAD_PREROLL_UNLOCK (basesink->sinkpad);
+ GST_BASE_SINK_PREROLL_UNLOCK (basesink);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
if (bclass->stop) {