From: Andy Wingo Date: Wed, 21 Sep 2005 13:11:22 +0000 (+0000) Subject: check/gst/gstutils.c (test_buffer_probe_n_times): Add tests for data and event probes... X-Git-Tag: RELEASE-0_9_3~84 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dbeb99cc277bbb74937698e4975926cd4e9599c7;p=platform%2Fupstream%2Fgstreamer.git 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 * check/gst/gstutils.c (test_buffer_probe_n_times): Add tests for data and event probes on the same pad. --- diff --git a/ChangeLog b/ChangeLog index 9088b6d..0a13ffd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2005-09-21 Andy Wingo + + * 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 + + * 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 * gst/base/gstbasetransform.c: (gst_base_transform_transform_size): diff --git a/check/gst/gstutils.c b/check/gst/gstutils.c index 7fa339e..b740c4d 100644 --- a/check/gst/gstutils.c +++ b/check/gst/gstutils.c @@ -21,14 +21,36 @@ #include -#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 * diff --git a/tests/check/gst/gstutils.c b/tests/check/gst/gstutils.c index 7fa339e..b740c4d 100644 --- a/tests/check/gst/gstutils.c +++ b/tests/check/gst/gstutils.c @@ -21,14 +21,36 @@ #include -#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 *