[farsight2/master] Add test to verify that the configuration data is properly discovered
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:22:53 PST 2008
---
tests/check/main/rtpcodecs.c | 72 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 71 insertions(+), 1 deletions(-)
diff --git a/tests/check/main/rtpcodecs.c b/tests/check/main/rtpcodecs.c
index 0c7c668..b9e4d0c 100644
--- a/tests/check/main/rtpcodecs.c
+++ b/tests/check/main/rtpcodecs.c
@@ -28,6 +28,8 @@
#include "generic.h"
+GMainLoop *loop = NULL;
+
void
_notify_local_codecs (GObject *object, GParamSpec *param, gpointer user_data)
{
@@ -395,17 +397,63 @@ GST_START_TEST (test_rtpcodecs_reserved_pt)
GST_END_TEST;
+static void
+_bus_message_element (GstBus *bus, GstMessage *message,
+ struct SimpleTestConference *dat)
+{
+ GList *codecs = NULL;
+ GList *item = NULL;
+ FsCodec *codec = NULL;
+ gboolean ready;
+ const GstStructure *s = gst_message_get_structure (message);
+
+ if (!gst_structure_has_name (s, "farsight-codecs-ready"))
+ return;
+
+ g_object_get (dat->session, "codecs-ready", &ready, NULL);
+
+ fail_unless (ready, "Got ready bus message, but codecs aren't ready yet");
+
+ g_object_get (dat->session, "local-codecs", &codecs, NULL);
+ for (item = g_list_first (codecs); item; item = g_list_next (item))
+ {
+ codec = item->data;
+ if (!g_ascii_strcasecmp ("vorbis", codec->encoding_name))
+ break;
+ }
+
+ fail_if (item == NULL, "Could not find Vorbis in local codecs");
+
+ for (item = codec->config_params; item; item = g_list_next (item))
+ {
+ FsCodecParameter *param = item->data;
+
+ if (!g_ascii_strcasecmp (param->name, "configuration"))
+ break;
+ }
+
+ fail_if (item == NULL, "The session claims to have found all configuration"
+ " params, but Vorbis does not have the \"configuration\" parameter");
+
+ fs_codec_list_destroy (codecs);
+
+ g_main_loop_quit (loop);
+}
+
GST_START_TEST (test_rtpcodecs_config_data)
{
struct SimpleTestConference *dat = NULL;
GList *codecs = NULL, *item = NULL;
gboolean ready;
GError *error = NULL;
+ GstBus *bus = NULL;
+
+ loop = g_main_loop_new (NULL, FALSE);
dat = setup_simple_conference (1, "fsrtpconference", "bob at 127.0.0.1");
codecs = g_list_prepend (NULL, fs_codec_new (FS_CODEC_ID_ANY, "VORBIS",
- FS_MEDIA_TYPE_AUDIO, 16000));
+ FS_MEDIA_TYPE_AUDIO, 44100));
fail_unless (fs_session_set_local_codecs_config (dat->session, codecs,
&error),
@@ -436,7 +484,29 @@ GST_START_TEST (test_rtpcodecs_config_data)
fail_if (ready, "Codecs are ready before the pipeline is playing, it does not"
" try to detect vorbis codec data");
+ setup_fakesrc (dat);
+
+ bus = gst_pipeline_get_bus (GST_PIPELINE (dat->pipeline));
+
+ gst_bus_add_signal_watch (bus);
+
+ g_signal_connect (bus, "message::element", G_CALLBACK (_bus_message_element),
+ dat);
+
+ fail_if (gst_element_set_state (dat->pipeline, GST_STATE_PLAYING) ==
+ GST_STATE_CHANGE_FAILURE, "Could not set the pipeline to playing");
+
+ g_main_loop_run (loop);
+
+ gst_bus_remove_signal_watch (bus);
+
+ gst_object_unref (bus);
+
+ fail_if (gst_element_set_state (dat->pipeline, GST_STATE_NULL) ==
+ GST_STATE_CHANGE_FAILURE, "Could not set the pipeline to null");
+
out:
+ g_main_loop_unref (loop);
cleanup_simple_conference (dat);
}
GST_END_TEST;
--
1.5.6.5
More information about the farsight-commits
mailing list