[farsight2/master] Add beggining of test that runs the transmitter
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:19:32 PST 2008
---
tests/check/transmitter/generic.c | 8 +++
tests/check/transmitter/generic.h | 3 +
tests/check/transmitter/rawudp.c | 101 +++++++++++++++++++++++++++++++++++++
3 files changed, 112 insertions(+), 0 deletions(-)
diff --git a/tests/check/transmitter/generic.c b/tests/check/transmitter/generic.c
index 82ab6cc..ba55e20 100644
--- a/tests/check/transmitter/generic.c
+++ b/tests/check/transmitter/generic.c
@@ -38,6 +38,14 @@ _transmitter_error (FsTransmitter *transmitter, gint errorno, gchar *error_msg,
error_msg, debug_msg);
}
+void
+_stream_transmitter_error (FsStreamTransmitter *streamtransmitter,
+ gint errorno, gchar *error_msg, gchar *debug_msg, gpointer user_data)
+{
+ fail ("StreamTransmitter(%x) error(%d) msg:%s debug:%s", streamtransmitter,
+ errorno, error_msg, debug_msg);
+}
+
GstElement *
setup_pipeline (FsTransmitter *trans, GstElement **fakesrc)
{
diff --git a/tests/check/transmitter/generic.h b/tests/check/transmitter/generic.h
index 423f385..ddf22a2 100644
--- a/tests/check/transmitter/generic.h
+++ b/tests/check/transmitter/generic.h
@@ -28,5 +28,8 @@
GstElement * setup_pipeline (FsTransmitter *trans, GstElement **fakesrc);
+void _stream_transmitter_error (FsStreamTransmitter *streamtransmitter,
+ gint errorno, gchar *error_msg, gchar *debug_msg, gpointer user_data);
+
#endif /* __GENERIC_H__ */
diff --git a/tests/check/transmitter/rawudp.c b/tests/check/transmitter/rawudp.c
index 5c16e5b..a88e562 100644
--- a/tests/check/transmitter/rawudp.c
+++ b/tests/check/transmitter/rawudp.c
@@ -58,6 +58,106 @@ GST_START_TEST (test_rawudptransmitter_new)
}
GST_END_TEST;
+gint candidates[2] = {0,0};
+
+static void
+_new_local_candidate (FsStreamTransmitter *st, FsCandidate *candidate,
+ gpointer user_data)
+{
+ gboolean has_stun = GPOINTER_TO_INT (user_data);
+
+ fail_if (candidate == NULL, "Passed NULL candidate");
+ fail_unless (candidate->ip != NULL, "Null IP in candidate");
+ fail_if (candidate->port == 0, "Candidate has port 0");
+ fail_unless (candidate->proto == FS_NETWORK_PROTOCOL_UDP,
+ "Protocol is not UDP");
+
+ if (candidate->component_id == FS_COMPONENT_RTP)
+ fail_unless (strcmp (candidate->proto_subtype, "RTP") == 0,
+ "Proto subtype %s does not match component %d", candidate->proto_subtype,
+ candidate->component_id);
+ else if (candidate->component_id == FS_COMPONENT_RTCP)
+ fail_unless (strcmp (candidate->proto_subtype, "RTP") == 0,
+ "Proto subtype %s does not match component %d", candidate->proto_subtype,
+ candidate->component_id);
+ else
+ fail ("Invalid component %d", candidate->component_id);
+
+ if (has_stun)
+ fail_unless (candidate->type == FS_CANDIDATE_TYPE_SRFLX,
+ "Has stun, but candidate is not server reflexive");
+ else
+ fail_unless (candidate->type == FS_CANDIDATE_TYPE_HOST,
+ "Has stun, but candidate is not host");
+
+ candidates[candidate->component_id-1] = 1;
+}
+
+GST_START_TEST (test_rawudptransmitter_run_nostun)
+{
+ GError *error = NULL;
+ FsTransmitter *trans;
+ FsStreamTransmitter *st;
+ GstElement *pipeline;
+ GstElement *fakesrc;
+ GstElement *trans_sink, *trans_src;
+
+ const gint N_PARAMS = 0;
+ GParameter params[N_PARAMS];
+
+ trans = fs_transmitter_new ("rawudp", &error);
+
+ if (error) {
+ fail("Error creating transmitter: %s", error->message);
+ }
+
+ fail_if (trans == NULL, "No transmitter create, yet error is still NULL");
+
+ pipeline = setup_pipeline (trans, &fakesrc);
+
+ g_object_get (trans, "gst-sink", &trans_sink, "gst-src", &trans_src, NULL);
+
+
+ fail_if (gst_element_set_state (pipeline, GST_STATE_PLAYING) ==
+ GST_STATE_CHANGE_FAILURE, "Could not set the pipeline to playing");
+
+ g_debug ("PRE-ALLO");
+
+ /*
+ params[0].name = "stun-ip";
+ g_value_set_static_string (params[0].value, "192.245.12.229");
+ params[1].name = "stun-port";
+ g_value_set_uint (params[0].value, 3478);
+ */
+ st = fs_transmitter_new_stream_transmitter (trans, NULL, N_PARAMS, params,
+ &error);
+
+ g_debug ("ALLO");
+
+ if (error) {
+ fail("Error creating stream transmitter: %s", error->message);
+ }
+
+ fail_if (st == NULL, "No stream transmitter created, yet error is NULL");
+
+ g_debug ("ALLO2");
+
+ g_signal_connect (st, "new-local-candidate",
+ G_CALLBACK (_new_local_candidate), GINT_TO_POINTER (0));
+ g_debug ("ALLO2.5");
+ g_signal_connect (st, "error", G_CALLBACK (_stream_transmitter_error), NULL);
+
+ g_debug ("ALLO3");
+
+ g_object_unref (st);
+
+ g_object_unref (trans);
+
+ gst_object_unref (pipeline);
+
+}
+GST_END_TEST;
+
static Suite *
@@ -69,6 +169,7 @@ rawudptransmitter_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_rawudptransmitter_new);
+ tcase_add_test (tc_chain, test_rawudptransmitter_run_nostun);
return s;
}
--
1.5.6.5
More information about the farsight-commits
mailing list