Commit 63170d52 authored by Jonny Lamb's avatar Jonny Lamb Committed by Olivier Crête

identity: fixes to the eos-after and error-after properties

I copied `error-after` to make the `eos-after` property, but it turned
out there were some problems with that one, so this patch: adds
separate counters (so setting to NULL and reusing the element will
still work); clarifies the properties' min values; and reports an
error when both are set.
parent 23c1a815
Pipeline #12934 passed with stages
in 27 minutes and 57 seconds
......@@ -161,7 +161,7 @@ gst_identity_class_init (GstIdentityClass * klass)
DEFAULT_SLEEP_TIME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_ERROR_AFTER,
g_param_spec_int ("error-after", "Error After", "Error after N buffers",
G_MININT, G_MAXINT, DEFAULT_ERROR_AFTER,
-1, G_MAXINT, DEFAULT_ERROR_AFTER,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_DROP_PROBABILITY,
g_param_spec_float ("drop-probability", "Drop Probability",
......@@ -248,7 +248,7 @@ gst_identity_class_init (GstIdentityClass * klass)
**/
g_object_class_install_property (gobject_class, PROP_EOS_AFTER,
g_param_spec_int ("eos-after", "EOS After", "EOS after N buffers",
G_MININT, G_MAXINT, DEFAULT_ERROR_AFTER,
-1, G_MAXINT, DEFAULT_EOS_AFTER,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
......@@ -292,6 +292,7 @@ gst_identity_init (GstIdentity * identity)
{
identity->sleep_time = DEFAULT_SLEEP_TIME;
identity->error_after = DEFAULT_ERROR_AFTER;
identity->error_after_counter = DEFAULT_ERROR_AFTER;
identity->drop_probability = DEFAULT_DROP_PROBABILITY;
identity->drop_buffer_flags = DEFAULT_DROP_BUFFER_FLAGS;
identity->datarate = DEFAULT_DATARATE;
......@@ -306,6 +307,7 @@ gst_identity_init (GstIdentity * identity)
identity->ts_offset = DEFAULT_TS_OFFSET;
g_cond_init (&identity->blocked_cond);
identity->eos_after = DEFAULT_EOS_AFTER;
identity->eos_after_counter = DEFAULT_EOS_AFTER;
gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM_CAST (identity), TRUE);
}
......@@ -639,15 +641,15 @@ gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
identity->prev_offset_end = GST_BUFFER_OFFSET_END (buf);
identity->prev_offset = GST_BUFFER_OFFSET (buf);
if (identity->error_after >= 0) {
identity->error_after--;
if (identity->error_after == 0)
if (identity->error_after_counter >= 0) {
identity->error_after_counter--;
if (identity->error_after_counter == 0)
goto error_after;
}
if (identity->eos_after >= 0) {
identity->eos_after--;
if (identity->eos_after == 0)
if (identity->eos_after_counter >= 0) {
identity->eos_after_counter--;
if (identity->eos_after_counter == 0)
goto eos_after;
}
......@@ -880,13 +882,27 @@ gst_identity_start (GstBaseTransform * trans)
identity = GST_IDENTITY (trans);
if (identity->eos_after != DEFAULT_EOS_AFTER
&& identity->error_after != DEFAULT_ERROR_AFTER)
goto both_afters_defined;
identity->offset = 0;
identity->prev_timestamp = GST_CLOCK_TIME_NONE;
identity->prev_duration = GST_CLOCK_TIME_NONE;
identity->prev_offset_end = GST_BUFFER_OFFSET_NONE;
identity->prev_offset = GST_BUFFER_OFFSET_NONE;
identity->error_after_counter = identity->error_after;
identity->eos_after_counter = identity->eos_after;
return TRUE;
/* ERROR */
both_afters_defined:
{
GST_ELEMENT_ERROR (identity, CORE, FAILED,
(_("eos-after and error-after can't both be defined.")), (NULL));
return FALSE;
}
}
static gboolean
......
......@@ -56,7 +56,8 @@ struct _GstIdentity {
/*< private >*/
GstClockID clock_id;
gboolean flushing;
gint error_after;
gint error_after;
gint error_after_counter;
gfloat drop_probability;
gint datarate;
guint sleep_time;
......@@ -80,6 +81,7 @@ struct _GstIdentity {
GstClockTimeDiff ts_offset;
gboolean drop_allocation;
gint eos_after;
gint eos_after_counter;
};
struct _GstIdentityClass {
......
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