gst_aggregator_push (GstAggregator *aggregator, GstPad *pad, GstBuffer *buf, guchar *debug)
{
if (!aggregator->silent)
- g_print("aggregator: %10.10s ******* (%s:%s)a (%d bytes, %llu) \n",
+ gst_element_info (GST_ELEMENT (aggregator), "%10.10s ******* (%s:%s)a (%d bytes, %llu) \n",
debug, GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
gst_pad_push (aggregator->srcpad, buf);
*/
+#include <stdlib.h>
#include <gstidentity.h>
ARG_SLEEP_TIME,
ARG_DUPLICATE,
ARG_ERROR_AFTER,
+ ARG_DROP_PROBABILITY,
ARG_SILENT,
};
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_AFTER,
g_param_spec_int ("error_after", "Error After", "Error after N buffers",
G_MININT, G_MAXINT, -1, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_PROBABILITY,
+ g_param_spec_float ("drop_probability", "Drop Probability", "The Probability a buffer is dropped",
+ 0.0, 1.0, 0.0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "silent", "silent",
TRUE,G_PARAM_READWRITE));
identity->sleep_time = 0;
identity->duplicate = 1;
identity->error_after = -1;
+ identity->drop_probability = 0.0;
identity->silent = FALSE;
}
}
}
- for (i=identity->duplicate; i; i--) {
+ if (identity->drop_probability > 0.0) {
+ if ((gfloat)(1.0*rand()/(RAND_MAX)) < identity->drop_probability) {
+ gst_element_info (GST_ELEMENT (identity), "dropping ******* (%s:%s)i (%d bytes, %llu)",
+ GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
+ gst_buffer_unref (buf);
+ return;
+ }
+ }
+
+ for (i = identity->duplicate; i; i--) {
if (!identity->silent)
- g_print("identity: chain ******* (%s:%s)i (%d bytes, %llu) \n",
+ gst_element_info (GST_ELEMENT (identity), "chain ******* (%s:%s)i (%d bytes, %llu)",
GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
gst_pad_event_default (identity->sinkpad, GST_EVENT (buf));
}
- if (identity->error_after >= 0) {
- identity->error_after--;
- if (identity->error_after == 0) {
- gst_buffer_unref (buf);
- gst_element_error (element, "errored after iterations as requested");
- return;
- }
- }
-
- for (i=identity->duplicate; i; i--) {
- if (!identity->silent)
- g_print("identity: loop ******* (%s:%s)i (%d bytes, %llu) \n",
- GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
-
- g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
- buf);
-
- if (i>1)
- gst_buffer_ref (buf);
-
- gst_pad_push (identity->srcpad, buf);
-
- if (identity->sleep_time)
- usleep (identity->sleep_time);
- }
+ gst_identity_chain (identity->sinkpad, buf);
}
static void
case ARG_ERROR_AFTER:
identity->error_after = g_value_get_uint (value);
break;
+ case ARG_DROP_PROBABILITY:
+ identity->drop_probability = g_value_get_float (value);
+ break;
default:
break;
}
case ARG_ERROR_AFTER:
g_value_set_uint (value, identity->error_after);
break;
+ case ARG_DROP_PROBABILITY:
+ g_value_set_float (value, identity->drop_probability);
+ break;
case ARG_SILENT:
g_value_set_boolean (value, identity->silent);
break;
gboolean loop_based;
guint duplicate;
gint error_after;
+ gfloat drop_probability;
guint sleep_time;
gboolean silent;
};
gst_aggregator_push (GstAggregator *aggregator, GstPad *pad, GstBuffer *buf, guchar *debug)
{
if (!aggregator->silent)
- g_print("aggregator: %10.10s ******* (%s:%s)a (%d bytes, %llu) \n",
+ gst_element_info (GST_ELEMENT (aggregator), "%10.10s ******* (%s:%s)a (%d bytes, %llu) \n",
debug, GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
gst_pad_push (aggregator->srcpad, buf);
*/
+#include <stdlib.h>
#include <gstidentity.h>
ARG_SLEEP_TIME,
ARG_DUPLICATE,
ARG_ERROR_AFTER,
+ ARG_DROP_PROBABILITY,
ARG_SILENT,
};
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_AFTER,
g_param_spec_int ("error_after", "Error After", "Error after N buffers",
G_MININT, G_MAXINT, -1, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_PROBABILITY,
+ g_param_spec_float ("drop_probability", "Drop Probability", "The Probability a buffer is dropped",
+ 0.0, 1.0, 0.0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "silent", "silent",
TRUE,G_PARAM_READWRITE));
identity->sleep_time = 0;
identity->duplicate = 1;
identity->error_after = -1;
+ identity->drop_probability = 0.0;
identity->silent = FALSE;
}
}
}
- for (i=identity->duplicate; i; i--) {
+ if (identity->drop_probability > 0.0) {
+ if ((gfloat)(1.0*rand()/(RAND_MAX)) < identity->drop_probability) {
+ gst_element_info (GST_ELEMENT (identity), "dropping ******* (%s:%s)i (%d bytes, %llu)",
+ GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
+ gst_buffer_unref (buf);
+ return;
+ }
+ }
+
+ for (i = identity->duplicate; i; i--) {
if (!identity->silent)
- g_print("identity: chain ******* (%s:%s)i (%d bytes, %llu) \n",
+ gst_element_info (GST_ELEMENT (identity), "chain ******* (%s:%s)i (%d bytes, %llu)",
GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
gst_pad_event_default (identity->sinkpad, GST_EVENT (buf));
}
- if (identity->error_after >= 0) {
- identity->error_after--;
- if (identity->error_after == 0) {
- gst_buffer_unref (buf);
- gst_element_error (element, "errored after iterations as requested");
- return;
- }
- }
-
- for (i=identity->duplicate; i; i--) {
- if (!identity->silent)
- g_print("identity: loop ******* (%s:%s)i (%d bytes, %llu) \n",
- GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
-
- g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
- buf);
-
- if (i>1)
- gst_buffer_ref (buf);
-
- gst_pad_push (identity->srcpad, buf);
-
- if (identity->sleep_time)
- usleep (identity->sleep_time);
- }
+ gst_identity_chain (identity->sinkpad, buf);
}
static void
case ARG_ERROR_AFTER:
identity->error_after = g_value_get_uint (value);
break;
+ case ARG_DROP_PROBABILITY:
+ identity->drop_probability = g_value_get_float (value);
+ break;
default:
break;
}
case ARG_ERROR_AFTER:
g_value_set_uint (value, identity->error_after);
break;
+ case ARG_DROP_PROBABILITY:
+ g_value_set_float (value, identity->drop_probability);
+ break;
case ARG_SILENT:
g_value_set_boolean (value, identity->silent);
break;
gboolean loop_based;
guint duplicate;
gint error_after;
+ gfloat drop_probability;
guint sleep_time;
gboolean silent;
};