[farsight2/master] Add tests for the codec profiles
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:25:49 PST 2008
---
tests/check/rtp/conference.c | 132 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 130 insertions(+), 2 deletions(-)
diff --git a/tests/check/rtp/conference.c b/tests/check/rtp/conference.c
index 84d356b..4f30034 100644
--- a/tests/check/rtp/conference.c
+++ b/tests/check/rtp/conference.c
@@ -973,8 +973,6 @@ GST_START_TEST (test_rtpconference_no_rtcp)
}
GST_END_TEST;
-
-
GST_START_TEST (test_rtpconference_three_way_no_source_assoc)
{
GParameter param = {0};
@@ -988,6 +986,128 @@ GST_START_TEST (test_rtpconference_three_way_no_source_assoc)
GST_END_TEST;
+static void
+_simple_profile_init (void)
+{
+ struct SimpleTestStream *st1 = dats[0]->streams->data;
+ struct SimpleTestStream *st2 = dats[1]->streams->data;
+ GList *prefs = NULL;
+ FsCodec *codec = NULL;
+ gboolean ret;
+
+ codec = fs_codec_new (0, "PCMU", FS_MEDIA_TYPE_AUDIO, 8000);
+ fs_codec_add_optional_parameter (codec, "farsight_send_profile",
+ "audioconvert ! audioresample ! audioconvert ! mulawenc ! rtppcmupay");
+ prefs = g_list_append (NULL, codec);
+
+ ret = fs_session_set_codec_preferences (st1->dat->session, prefs,
+ NULL);
+ ts_fail_unless (ret, "set codec prefs");
+ ret = fs_session_set_codec_preferences (st2->dat->session, prefs,
+ NULL);
+ ts_fail_unless (ret, "set codec prefs");
+
+ fs_codec_list_destroy (prefs);
+
+}
+
+
+GST_START_TEST (test_rtpconference_simple_profile)
+{
+ nway_test (2, _simple_profile_init, 0, NULL);
+}
+GST_END_TEST;
+
+
+static void
+_double_codec_handoff_handler (GstElement *element, GstBuffer *buffer,
+ GstPad *pad, gpointer user_data)
+{
+ static int buffer_count [2][2] = {{0,0},{0,0}};
+ static gpointer sts[2] = {NULL, NULL};
+ GstPad *peer = gst_pad_get_peer (pad);
+ gchar *name;
+ gint session, ssrc, pt;
+ guint id = 0xFFFFFF;
+
+ if (!(sts[0] == user_data || sts[1] == user_data))
+ {
+ if (!sts[0])
+ sts[0] = user_data;
+ else if (!sts[1])
+ sts[1] = user_data;
+ else
+ ts_fail ("Already have two streams");
+ }
+
+ if (sts[0] == user_data)
+ id = 0;
+ else if (sts[1] == user_data)
+ id = 1;
+ else
+ ts_fail ("Should not be here");
+
+ ts_fail_if (peer == NULL);
+ name = gst_pad_get_name (peer);
+ ts_fail_if (name == NULL);
+ gst_object_unref (peer);
+
+ ts_fail_unless (sscanf (name, "src_%d_%d_%d", &session, &ssrc, &pt) == 3);
+ g_free (name);
+
+ if (pt == 0)
+ buffer_count[0][id]++;
+ else if (pt == 8)
+ buffer_count[1][id]++;
+ else
+ ts_fail ("Wrong PT: %d", pt);
+
+ if (buffer_count[0][0] > 20 &&
+ buffer_count[0][1] > 20 &&
+ buffer_count[1][0] > 20 &&
+ buffer_count[1][1] > 20 )
+ {
+ g_main_loop_quit (loop);
+ }
+}
+
+static void
+_double_profile_init (void)
+{
+ struct SimpleTestStream *st1 = dats[0]->streams->data;
+ struct SimpleTestStream *st2 = dats[1]->streams->data;
+ GList *prefs = NULL;
+ FsCodec *codec = NULL;
+ gboolean ret;
+
+ st1->handoff_handler = G_CALLBACK (_double_codec_handoff_handler);
+ st2->handoff_handler = G_CALLBACK (_double_codec_handoff_handler);
+
+ codec = fs_codec_new (0, "PCMU", FS_MEDIA_TYPE_AUDIO, 8000);
+ fs_codec_add_optional_parameter (codec, "farsight_send_profile",
+ "tee name=t "
+ "t. ! audioconvert ! audioresample ! audioconvert ! mulawenc ! rtppcmupay "
+ "t. ! audioconvert ! audioresample ! audioconvert ! alawenc ! rtppcmapay");
+ prefs = g_list_append (NULL, codec);
+
+ ret = fs_session_set_codec_preferences (st1->dat->session, prefs,
+ NULL);
+ ts_fail_unless (ret, "set codec prefs");
+
+ ret = fs_session_set_codec_preferences (st2->dat->session, prefs,
+ NULL);
+ ts_fail_unless (ret, "set codec prefs");
+
+ fs_codec_list_destroy (prefs);
+}
+
+GST_START_TEST (test_rtpconference_double_codec_profile)
+{
+ nway_test (2, _double_profile_init, 0, NULL);
+}
+GST_END_TEST;
+
+
static Suite *
fsrtpconference_suite (void)
{
@@ -1051,6 +1171,14 @@ fsrtpconference_suite (void)
tcase_add_test (tc_chain, test_rtpconference_three_way_no_source_assoc);
suite_add_tcase (s, tc_chain);
+ tc_chain = tcase_create ("fsrtpconference_simple_profile");
+ tcase_add_test (tc_chain, test_rtpconference_simple_profile);
+ suite_add_tcase (s, tc_chain);
+
+ tc_chain = tcase_create ("fsrtpconference_double_codec_profile");
+ tcase_add_test (tc_chain, test_rtpconference_double_codec_profile);
+ suite_add_tcase (s, tc_chain);
+
return s;
}
--
1.5.6.5
More information about the farsight-commits
mailing list