mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
harness: Add event stress test functions with callback
Similar to the stress test functions for buffers that has a callback to create the buffer to be pushed, it's useful to have functions that use a callback to create the event to be pushed. API: gst_harness_stress_push_event_with_cb_start() API: gst_harness_stress_push_event_with_cb_start_full() API: gst_harness_stress_send_upstream_event_with_cb_start() API: gst_harness_stress_push_upstream_event_with_cb_start_full() https://bugzilla.gnome.org/show_bug.cgi?id=761932
This commit is contained in:
parent
668b3215b8
commit
778160be08
4 changed files with 117 additions and 6 deletions
|
@ -1313,9 +1313,16 @@ gst_harness_stress_push_buffer_with_cb_start_full
|
|||
gst_harness_stress_push_event_start
|
||||
gst_harness_stress_push_event_start_full
|
||||
|
||||
GstHarnessPrepareEventFunc
|
||||
gst_harness_stress_push_event_with_cb_start
|
||||
gst_harness_stress_push_event_with_cb_start_full
|
||||
|
||||
gst_harness_stress_send_upstream_event_start
|
||||
gst_harness_stress_push_upstream_event_start_full
|
||||
|
||||
gst_harness_stress_send_upstream_event_with_cb_start
|
||||
gst_harness_stress_push_upstream_event_with_cb_start_full
|
||||
|
||||
gst_harness_stress_property_start
|
||||
gst_harness_stress_property_start_full
|
||||
|
||||
|
|
|
@ -158,7 +158,9 @@ LIBGSTCHECK_EXPORTED_FUNCS = \
|
|||
gst_harness_stress_push_buffer_start_full \
|
||||
gst_harness_stress_push_buffer_with_cb_start_full \
|
||||
gst_harness_stress_push_event_start_full \
|
||||
gst_harness_stress_push_event_with_cb_start_full \
|
||||
gst_harness_stress_push_upstream_event_start_full \
|
||||
gst_harness_stress_push_upstream_event_with_cb_start_full \
|
||||
gst_harness_stress_requestpad_start_full \
|
||||
gst_harness_stress_statechange_start_full \
|
||||
gst_harness_stress_thread_stop \
|
||||
|
|
|
@ -2543,7 +2543,9 @@ typedef struct
|
|||
{
|
||||
GstHarnessThread t;
|
||||
|
||||
GstEvent *event;
|
||||
GstHarnessPrepareEventFunc func;
|
||||
gpointer data;
|
||||
GDestroyNotify notify;
|
||||
} GstHarnessPushEventThread;
|
||||
|
||||
typedef struct
|
||||
|
@ -2604,7 +2606,8 @@ static void
|
|||
gst_harness_push_event_thread_free (GstHarnessPushEventThread * t)
|
||||
{
|
||||
if (t != NULL) {
|
||||
gst_event_replace (&t->event, NULL);
|
||||
if (t->notify != NULL)
|
||||
t->notify (t->data);
|
||||
g_slice_free (GstHarnessPushEventThread, t);
|
||||
}
|
||||
}
|
||||
|
@ -2775,7 +2778,7 @@ gst_harness_stress_event_func (GstHarnessThread * t)
|
|||
guint count = 0;
|
||||
|
||||
while (t->running) {
|
||||
gst_harness_push_event (t->h, gst_event_ref (pet->event));
|
||||
gst_harness_push_event (t->h, pet->func (t->h, pet->data));
|
||||
|
||||
count++;
|
||||
g_usleep (t->sleep);
|
||||
|
@ -2790,7 +2793,7 @@ gst_harness_stress_upstream_event_func (GstHarnessThread * t)
|
|||
guint count = 0;
|
||||
|
||||
while (t->running) {
|
||||
gst_harness_push_upstream_event (t->h, gst_event_ref (pet->event));
|
||||
gst_harness_push_upstream_event (t->h, pet->func (t->h, pet->data));
|
||||
|
||||
count++;
|
||||
g_usleep (t->sleep);
|
||||
|
@ -2934,6 +2937,13 @@ gst_harness_ref_buffer (GstHarness * h, gpointer data)
|
|||
return gst_buffer_ref (GST_BUFFER_CAST (data));
|
||||
}
|
||||
|
||||
static GstEvent *
|
||||
gst_harness_ref_event (GstHarness * h, gpointer data)
|
||||
{
|
||||
(void) h;
|
||||
return gst_event_ref (GST_EVENT_CAST (data));
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_harness_stress_push_buffer_start_full: (skip)
|
||||
* @h: a #GstHarness
|
||||
|
@ -3019,12 +3029,44 @@ gst_harness_stress_push_buffer_with_cb_start_full (GstHarness * h,
|
|||
GstHarnessThread *
|
||||
gst_harness_stress_push_event_start_full (GstHarness * h,
|
||||
GstEvent * event, gulong sleep)
|
||||
{
|
||||
return gst_harness_stress_push_event_with_cb_start_full (h,
|
||||
gst_harness_ref_event, gst_event_ref (event),
|
||||
(GDestroyNotify) gst_event_unref, sleep);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_harness_stress_push_event_with_cb_start_full: (skip)
|
||||
* @h: a #GstHarness
|
||||
* @func: a #GstHarnessPrepareEventFunc function called before every iteration
|
||||
* to prepare / create a #GstEvent for pushing
|
||||
* @data: a #gpointer with data to the #GstHarnessPrepareEventFunc function
|
||||
* @notify: a #GDestroyNotify that is called when thread is stopped
|
||||
* @sleep: a #gulong specifying how long to sleep in (microseconds) for
|
||||
* each call to gst_pad_push
|
||||
*
|
||||
* Push a #GstEvent returned by @func onto the harnessed #GstElement sinkpad
|
||||
* in intervals of @sleep microseconds.
|
||||
*
|
||||
* MT safe.
|
||||
*
|
||||
* Returns: a #GstHarnessThread
|
||||
*
|
||||
* Since: 1.8
|
||||
*/
|
||||
GstHarnessThread *
|
||||
gst_harness_stress_push_event_with_cb_start_full (GstHarness * h,
|
||||
GstHarnessPrepareEventFunc func, gpointer data, GDestroyNotify notify,
|
||||
gulong sleep)
|
||||
{
|
||||
GstHarnessPushEventThread *t = g_slice_new0 (GstHarnessPushEventThread);
|
||||
gst_harness_thread_init (&t->t,
|
||||
(GDestroyNotify) gst_harness_push_event_thread_free, h, sleep);
|
||||
|
||||
t->event = gst_event_ref (event);
|
||||
t->func = func;
|
||||
t->data = data;
|
||||
t->notify = notify;
|
||||
|
||||
GST_HARNESS_THREAD_START (event, t);
|
||||
return &t->t;
|
||||
}
|
||||
|
@ -3048,12 +3090,44 @@ gst_harness_stress_push_event_start_full (GstHarness * h,
|
|||
GstHarnessThread *
|
||||
gst_harness_stress_push_upstream_event_start_full (GstHarness * h,
|
||||
GstEvent * event, gulong sleep)
|
||||
{
|
||||
return gst_harness_stress_push_upstream_event_with_cb_start_full (h,
|
||||
gst_harness_ref_event, gst_event_ref (event),
|
||||
(GDestroyNotify) gst_event_unref, sleep);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_harness_stress_push_upstream_event_with_cb_start_full: (skip)
|
||||
* @h: a #GstHarness
|
||||
* @func: a #GstHarnessPrepareEventFunc function called before every iteration
|
||||
* to prepare / create a #GstEvent for pushing
|
||||
* @data: a #gpointer with data to the #GstHarnessPrepareEventFunc function
|
||||
* @notify: a #GDestroyNotify that is called when thread is stopped
|
||||
* @sleep: a #gulong specifying how long to sleep in (microseconds) for
|
||||
* each call to gst_pad_push
|
||||
*
|
||||
* Push a #GstEvent returned by @func onto the harnessed #GstElement srcpad
|
||||
* in intervals of @sleep microseconds.
|
||||
*
|
||||
* MT safe.
|
||||
*
|
||||
* Returns: a #GstHarnessThread
|
||||
*
|
||||
* Since: 1.8
|
||||
*/
|
||||
GstHarnessThread *
|
||||
gst_harness_stress_push_upstream_event_with_cb_start_full (GstHarness * h,
|
||||
GstHarnessPrepareEventFunc func, gpointer data, GDestroyNotify notify,
|
||||
gulong sleep)
|
||||
{
|
||||
GstHarnessPushEventThread *t = g_slice_new0 (GstHarnessPushEventThread);
|
||||
gst_harness_thread_init (&t->t,
|
||||
(GDestroyNotify) gst_harness_push_event_thread_free, h, sleep);
|
||||
|
||||
t->event = gst_event_ref (event);
|
||||
t->func = func;
|
||||
t->data = data;
|
||||
t->notify = notify;
|
||||
|
||||
GST_HARNESS_THREAD_START (upstream_event, t);
|
||||
return &t->t;
|
||||
}
|
||||
|
|
|
@ -316,6 +316,24 @@ GstHarnessThread * gst_harness_stress_push_event_start_full (GstHarness * h,
|
|||
GstEvent * event,
|
||||
gulong sleep);
|
||||
|
||||
/**
|
||||
* GstHarnessPrepareEventFunc:
|
||||
* @h: a #GstHarness
|
||||
* @data: user data
|
||||
*
|
||||
* Since: 1.8
|
||||
*/
|
||||
typedef GstEvent * (*GstHarnessPrepareEventFunc) (GstHarness * h, gpointer data);
|
||||
|
||||
#define gst_harness_stress_push_event_with_cb_start(h, f, d, n) \
|
||||
gst_harness_stress_push_event_with_cb_start_full (h, f, d, n, 0)
|
||||
|
||||
GstHarnessThread * gst_harness_stress_push_event_with_cb_start_full (GstHarness * h,
|
||||
GstHarnessPrepareEventFunc func,
|
||||
gpointer data,
|
||||
GDestroyNotify notify,
|
||||
gulong sleep);
|
||||
|
||||
#define gst_harness_stress_send_upstream_event_start(h, e) \
|
||||
gst_harness_stress_push_upstream_event_start_full (h, e, 0)
|
||||
|
||||
|
@ -323,6 +341,16 @@ GstHarnessThread * gst_harness_stress_push_upstream_event_start_full (GstHarness
|
|||
GstEvent * event,
|
||||
gulong sleep);
|
||||
|
||||
#define gst_harness_stress_send_upstream_event_with_cb_start(h, f, d, n) \
|
||||
gst_harness_stress_push_upstream_event_with_cb_start_full (h, f, d, n, 0)
|
||||
|
||||
GstHarnessThread * gst_harness_stress_push_upstream_event_with_cb_start_full (GstHarness * h,
|
||||
GstHarnessPrepareEventFunc func,
|
||||
gpointer data,
|
||||
GDestroyNotify notify,
|
||||
gulong sleep);
|
||||
|
||||
|
||||
#define gst_harness_stress_property_start(h, n, v) \
|
||||
gst_harness_stress_property_start_full (h, n, v, G_USEC_PER_SEC / 1000)
|
||||
|
||||
|
|
Loading…
Reference in a new issue