diff --git a/plugins/elements/gstidentity.c b/plugins/elements/gstidentity.c index 66ad97edf1938360cba03bfe60cd2e9cdb1fc12d..1577d97d555da5aa8b76392d5ae9f3d5f2fa8bde 100644 --- a/plugins/elements/gstidentity.c +++ b/plugins/elements/gstidentity.c @@ -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 diff --git a/plugins/elements/gstidentity.h b/plugins/elements/gstidentity.h index 81cacbf08d61aa28959ff6bea50c403cdc2d4898..19bf29ffabfa711e8de37090e87b2f1db11d3965 100644 --- a/plugins/elements/gstidentity.h +++ b/plugins/elements/gstidentity.h @@ -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 {