[farsight2/master] Add bus watch for errors on transmitter tests
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:21:54 PST 2008
---
tests/check/transmitter/generic.c | 40 ++++++++++++++++++++++++++++++++++-
tests/check/transmitter/generic.h | 5 +++-
tests/check/transmitter/multicast.c | 7 +++++-
tests/check/transmitter/rawudp.c | 26 +++++++++-------------
4 files changed, 60 insertions(+), 18 deletions(-)
diff --git a/tests/check/transmitter/generic.c b/tests/check/transmitter/generic.c
index 3e01745..822b264 100644
--- a/tests/check/transmitter/generic.c
+++ b/tests/check/transmitter/generic.c
@@ -39,7 +39,7 @@ _transmitter_error (FsTransmitter *transmitter, gint errorno, gchar *error_msg,
}
void
-_stream_transmitter_error (FsStreamTransmitter *streamtransmitter,
+stream_transmitter_error (FsStreamTransmitter *streamtransmitter,
gint errorno, gchar *error_msg, gchar *debug_msg, gpointer user_data)
{
ts_fail ("StreamTransmitter(%x) error(%d) msg:%s debug:%s", streamtransmitter,
@@ -122,3 +122,41 @@ setup_pipeline (FsTransmitter *trans, GCallback cb)
return pipeline;
}
+
+
+gboolean
+bus_error_callback (GstBus *bus, GstMessage *message, gpointer user_data)
+{
+ switch (GST_MESSAGE_TYPE (message))
+ {
+ case GST_MESSAGE_ERROR:
+ {
+ GError *error = NULL;
+ gchar *debug = NULL;
+ gst_message_parse_error (message, &error, &debug);
+
+ ts_fail ("Got an error on the BUS (%d): %s (%s)", error->code,
+ error->message, debug);
+ g_error_free (error);
+ g_free (debug);
+ }
+ break;
+ case GST_MESSAGE_WARNING:
+ {
+ GError *error = NULL;
+ gchar *debug = NULL;
+ gst_message_parse_warning (message, &error, &debug);
+
+ g_debug ("Got a warning on the BUS (%d): %s (%s)",
+ error->code,
+ error->message, debug);
+ g_error_free (error);
+ g_free (debug);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return TRUE;
+}
diff --git a/tests/check/transmitter/generic.h b/tests/check/transmitter/generic.h
index b0a59a7..1256aaa 100644
--- a/tests/check/transmitter/generic.h
+++ b/tests/check/transmitter/generic.h
@@ -30,8 +30,11 @@ GstElement *setup_pipeline (FsTransmitter *trans, GCallback cb);
void setup_fakesrc (FsTransmitter *trans, GstElement *pipeline,
guint component_id);
-void _stream_transmitter_error (FsStreamTransmitter *streamtransmitter,
+void stream_transmitter_error (FsStreamTransmitter *streamtransmitter,
gint errorno, gchar *error_msg, gchar *debug_msg, gpointer user_data);
+gboolean bus_error_callback (GstBus *bus, GstMessage *message,
+ gpointer user_data);
+
#endif /* __GENERIC_H__ */
diff --git a/tests/check/transmitter/multicast.c b/tests/check/transmitter/multicast.c
index 8f91647..f76dcbd 100644
--- a/tests/check/transmitter/multicast.c
+++ b/tests/check/transmitter/multicast.c
@@ -141,6 +141,7 @@ run_multicast_transmitter_test (gint n_parameters, GParameter *params)
FsTransmitter *trans;
FsStreamTransmitter *st;
FsCandidate *tmpcand = NULL;
+ GstBus *bus = NULL;
loop = g_main_loop_new (NULL, FALSE);
trans = fs_transmitter_new ("multicast", 2, &error);
@@ -164,11 +165,15 @@ run_multicast_transmitter_test (gint n_parameters, GParameter *params)
ts_fail_if (st == NULL, "No stream transmitter created, yet error is NULL");
+ bus = gst_element_get_bus (pipeline);
+ gst_bus_add_watch (bus, bus_error_callback, NULL);
+ gst_object_unref (bus);
+
ts_fail_unless (g_signal_connect (st, "new-active-candidate-pair",
G_CALLBACK (_new_active_candidate_pair), trans),
"Coult not connect new-active-candidate-pair signal");
ts_fail_unless (g_signal_connect (st, "error",
- G_CALLBACK (_stream_transmitter_error), NULL),
+ G_CALLBACK (stream_transmitter_error), NULL),
"Could not connect error signal");
g_idle_add (_start_pipeline, pipeline);
diff --git a/tests/check/transmitter/rawudp.c b/tests/check/transmitter/rawudp.c
index 97d3751..0fa2092 100644
--- a/tests/check/transmitter/rawudp.c
+++ b/tests/check/transmitter/rawudp.c
@@ -215,7 +215,6 @@ _handoff_handler (GstElement *element, GstBuffer *buffer, GstPad *pad,
}
}
-
static void
run_rawudp_transmitter_test (gint n_parameters, GParameter *params,
gint flags)
@@ -223,6 +222,7 @@ run_rawudp_transmitter_test (gint n_parameters, GParameter *params,
GError *error = NULL;
FsTransmitter *trans;
FsStreamTransmitter *st;
+ GstBus *bus = NULL;
loop = g_main_loop_new (NULL, FALSE);
trans = fs_transmitter_new ("rawudp", 2, &error);
@@ -236,6 +236,10 @@ run_rawudp_transmitter_test (gint n_parameters, GParameter *params,
pipeline = setup_pipeline (trans, G_CALLBACK (_handoff_handler));
+ bus = gst_element_get_bus (pipeline);
+ gst_bus_add_watch (bus, bus_error_callback, NULL);
+ gst_object_unref (bus);
+
st = fs_transmitter_new_stream_transmitter (trans, NULL, n_parameters, params,
&error);
@@ -265,7 +269,7 @@ run_rawudp_transmitter_test (gint n_parameters, GParameter *params,
G_CALLBACK (_new_active_candidate_pair), trans),
"Could not connect new-active-candidate-pair signal");
ts_fail_unless (g_signal_connect (st, "error",
- G_CALLBACK (_stream_transmitter_error), NULL),
+ G_CALLBACK (stream_transmitter_error), NULL),
"Could not connect error signal");
g_idle_add (_start_pipeline, pipeline);
@@ -389,11 +393,9 @@ _bus_stop_stream_cb (GstBus *bus, GstMessage *message, gpointer user_data)
FsStreamTransmitter *st = user_data;
GstState oldstate, newstate, pending;
- if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_STATE_CHANGED)
- return TRUE;
-
- if (G_OBJECT_TYPE (GST_MESSAGE_SRC (message)) != GST_TYPE_PIPELINE)
- return TRUE;
+ if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_STATE_CHANGED ||
+ G_OBJECT_TYPE (GST_MESSAGE_SRC (message)) != GST_TYPE_PIPELINE)
+ return bus_error_callback (bus, message, user_data);
gst_message_parse_state_changed (message, &oldstate, &newstate, &pending);
@@ -407,7 +409,7 @@ _bus_stop_stream_cb (GstBus *bus, GstMessage *message, gpointer user_data)
g_main_loop_quit (loop);
- return FALSE;
+ return TRUE;
}
GST_START_TEST (test_rawudptransmitter_stop_stream)
@@ -437,14 +439,8 @@ GST_START_TEST (test_rawudptransmitter_stop_stream)
ts_fail_if (st == NULL, "No stream transmitter created, yet error is NULL");
- ts_fail_unless (g_signal_connect (st, "error",
- G_CALLBACK (_stream_transmitter_error), NULL),
- "Could not connect error signal");
-
bus = gst_element_get_bus (pipeline);
-
gst_bus_add_watch (bus, _bus_stop_stream_cb, st);
-
gst_object_unref (bus);
ts_fail_unless (g_signal_connect (st, "new-local-candidate",
@@ -454,7 +450,7 @@ GST_START_TEST (test_rawudptransmitter_stop_stream)
G_CALLBACK (_new_active_candidate_pair), trans),
"Could not connect new-active-candidate-pair signal");
ts_fail_unless (g_signal_connect (st, "error",
- G_CALLBACK (_stream_transmitter_error), NULL),
+ G_CALLBACK (stream_transmitter_error), NULL),
"Could not connect error signal");
g_idle_add (_start_pipeline, pipeline);
--
1.5.6.5
More information about the farsight-commits
mailing list