check/gst/gstutils.c (test_buffer_probe_n_times): Add tests for data and event probes on the same pad.

Original commit message from CVS:
2005-09-21  Andy Wingo  <wingo@pobox.com>

* check/gst/gstutils.c (test_buffer_probe_n_times): Add tests for
data and event probes on the same pad.
This commit is contained in:
Andy Wingo 2005-09-21 13:11:22 +00:00
parent 5b77a67125
commit dbeb99cc27
3 changed files with 89 additions and 12 deletions

View file

@ -1,3 +1,30 @@
2005-09-21 Andy Wingo <wingo@pobox.com>
* check/gst/gstutils.c (test_buffer_probe_n_times): Add tests for
data and event probes on the same pad.
2005-09-21 Andy Wingo <wingo@pobox.com>
* check/gst/gstutils.c: New file.
(test_buffer_probe_n_times): A simple buffer probe test. More to
come, foolios.
* gst/gstutils.c (gst_pad_add_buffer_probe): Connect to
have-data::buffer, not have-data.
(gst_pad_add_event_probe): Likewise for have-data::event.
(gst_pad_add_data_probe): More docs. The part about 'resolving the
peer' isn't quite right yet though.
(gst_pad_remove_buffer_probe, gst_pad_remove_event_probe)
(gst_pad_remove_data_probe): Change to take the guint handler_id
as their arg, not the function+data, which is more glib-like.
* gst/gstpad.c (gst_pad_emit_have_data_signal): Add a detail to
the signal emission to indicate if the data is a buffer or an
event.
(gst_pad_get_type): Initialize buffer and event quarks.
(gst_pad_class_init): have-data is now a detailed signal, yes it
is.
2005-09-21 Tim-Philipp Müller <tim at centricular dot net>
* gst/base/gstbasetransform.c: (gst_base_transform_transform_size):

View file

@ -21,14 +21,36 @@
#include <gst/check/gstcheck.h>
#define SPECIAL_POINTER (void*)19283847
#define SPECIAL_POINTER(x) ((void*)(19283847+(x)))
static int n_data_probes = 0;
static int n_buffer_probes = 0;
static int n_event_probes = 0;
static gboolean
data_probe (GstPad * pad, GstMiniObject * obj, gpointer data)
{
n_data_probes++;
g_assert (GST_IS_MINI_OBJECT (obj));
g_assert (data == SPECIAL_POINTER (0));
return TRUE;
}
static gboolean
buffer_probe (GstPad * pad, GstBuffer * obj, gpointer data)
{
n_buffer_probes++;
g_assert (data == SPECIAL_POINTER);
g_assert (GST_IS_BUFFER (obj));
g_assert (data == SPECIAL_POINTER (1));
return TRUE;
}
static gboolean
event_probe (GstPad * pad, GstEvent * obj, gpointer data)
{
n_event_probes++;
g_assert (GST_IS_EVENT (obj));
g_assert (data == SPECIAL_POINTER (2));
return TRUE;
}
@ -38,7 +60,6 @@ GST_START_TEST (test_buffer_probe_n_times)
GstBus *bus;
GstMessage *message;
GstPad *pad;
guint id;
pipeline = gst_element_factory_make ("pipeline", NULL);
fakesrc = gst_element_factory_make ("fakesrc", NULL);
@ -50,8 +71,10 @@ GST_START_TEST (test_buffer_probe_n_times)
gst_element_link (fakesrc, fakesink);
pad = gst_element_get_pad (fakesink, "sink");
id = gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe),
SPECIAL_POINTER);
gst_pad_add_data_probe (pad, G_CALLBACK (data_probe), SPECIAL_POINTER (0));
gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe),
SPECIAL_POINTER (1));
gst_pad_add_event_probe (pad, G_CALLBACK (event_probe), SPECIAL_POINTER (2));
gst_object_unref (pad);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
@ -64,7 +87,9 @@ GST_START_TEST (test_buffer_probe_n_times)
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
g_assert (n_buffer_probes == 10);
g_assert (n_buffer_probes == 10); /* one for every buffer */
g_assert (n_event_probes == 2); /* new segment and eos */
g_assert (n_data_probes == 12); /* duh */
} GST_END_TEST;
Suite *

View file

@ -21,14 +21,36 @@
#include <gst/check/gstcheck.h>
#define SPECIAL_POINTER (void*)19283847
#define SPECIAL_POINTER(x) ((void*)(19283847+(x)))
static int n_data_probes = 0;
static int n_buffer_probes = 0;
static int n_event_probes = 0;
static gboolean
data_probe (GstPad * pad, GstMiniObject * obj, gpointer data)
{
n_data_probes++;
g_assert (GST_IS_MINI_OBJECT (obj));
g_assert (data == SPECIAL_POINTER (0));
return TRUE;
}
static gboolean
buffer_probe (GstPad * pad, GstBuffer * obj, gpointer data)
{
n_buffer_probes++;
g_assert (data == SPECIAL_POINTER);
g_assert (GST_IS_BUFFER (obj));
g_assert (data == SPECIAL_POINTER (1));
return TRUE;
}
static gboolean
event_probe (GstPad * pad, GstEvent * obj, gpointer data)
{
n_event_probes++;
g_assert (GST_IS_EVENT (obj));
g_assert (data == SPECIAL_POINTER (2));
return TRUE;
}
@ -38,7 +60,6 @@ GST_START_TEST (test_buffer_probe_n_times)
GstBus *bus;
GstMessage *message;
GstPad *pad;
guint id;
pipeline = gst_element_factory_make ("pipeline", NULL);
fakesrc = gst_element_factory_make ("fakesrc", NULL);
@ -50,8 +71,10 @@ GST_START_TEST (test_buffer_probe_n_times)
gst_element_link (fakesrc, fakesink);
pad = gst_element_get_pad (fakesink, "sink");
id = gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe),
SPECIAL_POINTER);
gst_pad_add_data_probe (pad, G_CALLBACK (data_probe), SPECIAL_POINTER (0));
gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe),
SPECIAL_POINTER (1));
gst_pad_add_event_probe (pad, G_CALLBACK (event_probe), SPECIAL_POINTER (2));
gst_object_unref (pad);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
@ -64,7 +87,9 @@ GST_START_TEST (test_buffer_probe_n_times)
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
g_assert (n_buffer_probes == 10);
g_assert (n_buffer_probes == 10); /* one for every buffer */
g_assert (n_event_probes == 2); /* new segment and eos */
g_assert (n_data_probes == 12); /* duh */
} GST_END_TEST;
Suite *