[calls] tests: media: Test pipeline
- From: Evangelos Ribeiro Tzaras <devrtz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [calls] tests: media: Test pipeline
- Date: Sun, 6 Mar 2022 00:28:32 +0000 (UTC)
commit acfd185e9e4ca36ebef34739d13b28659bbb54a5
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date: Tue Mar 1 18:00:52 2022 +0100
tests: media: Test pipeline
Run some basic tests on the pipeline
tests/test-media.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 110 insertions(+), 1 deletion(-)
---
diff --git a/tests/test-media.c b/tests/test-media.c
index c02f9654..48ee752e 100644
--- a/tests/test-media.c
+++ b/tests/test-media.c
@@ -6,6 +6,7 @@
* Author: Evangelos Ribeiro Tzaras <evangelos tzaras puri sm>
*/
+#include "calls-sip-call.h"
#include "calls-sip-media-manager.h"
#include "gst-rfc3551.h"
@@ -37,7 +38,7 @@ find_string_in_sdp_message (const char *sdp,
static void
test_sip_media_manager_caps (void)
{
- g_autoptr (CallsSipMediaManager) manager = calls_sip_media_manager_default ();
+ CallsSipMediaManager *manager = calls_sip_media_manager_default ();
char *sdp_message = NULL;
GList *codecs = NULL;
@@ -151,10 +152,112 @@ test_sip_media_manager_caps (void)
}
+static void
+test_media_pipeline_states (void)
+{
+ CallsSipMediaPipeline *pipeline = calls_sip_media_pipeline_new (NULL);
+ MediaCodecInfo *codec = media_codec_by_name ("PCMA");
+
+ g_assert_cmpint (calls_sip_media_pipeline_get_state (pipeline), ==,
+ CALLS_MEDIA_PIPELINE_STATE_NEED_CODEC);
+
+ calls_sip_media_pipeline_set_codec (pipeline, codec);
+
+ g_assert_cmpint (calls_sip_media_pipeline_get_state (pipeline), ==,
+ CALLS_MEDIA_PIPELINE_STATE_READY);
+
+ calls_sip_media_pipeline_start (pipeline);
+ g_assert_cmpint (calls_sip_media_pipeline_get_state (pipeline), ==,
+ CALLS_MEDIA_PIPELINE_STATE_PLAY_PENDING);
+
+ calls_sip_media_pipeline_pause (pipeline, TRUE);
+ g_assert_cmpint (calls_sip_media_pipeline_get_state (pipeline), ==,
+ CALLS_MEDIA_PIPELINE_STATE_PAUSE_PENDING);
+
+ calls_sip_media_pipeline_pause (pipeline, FALSE);
+ g_assert_cmpint (calls_sip_media_pipeline_get_state (pipeline), ==,
+ CALLS_MEDIA_PIPELINE_STATE_PLAY_PENDING);
+
+ calls_sip_media_pipeline_stop (pipeline);
+ g_assert_cmpint (calls_sip_media_pipeline_get_state (pipeline), ==,
+ CALLS_MEDIA_PIPELINE_STATE_STOP_PENDING);
+
+ g_assert_finalize_object (pipeline);
+}
+
+
+static void
+test_media_pipeline_setup_codecs (void)
+{
+ const char * const codec_names[] = {"PCMA", "PCMU", "GSM", "G722"};
+
+ for (uint i = 0; i < G_N_ELEMENTS (codec_names); i++) {
+ g_autoptr (CallsSipMediaPipeline) pipeline = calls_sip_media_pipeline_new (NULL);
+ MediaCodecInfo *codec = media_codec_by_name ("PCMA");
+
+ g_assert_cmpint (calls_sip_media_pipeline_get_state (pipeline), ==,
+ CALLS_MEDIA_PIPELINE_STATE_NEED_CODEC);
+
+ calls_sip_media_pipeline_set_codec (pipeline, codec);
+
+ g_assert_cmpint (calls_sip_media_pipeline_get_state (pipeline), ==,
+ CALLS_MEDIA_PIPELINE_STATE_READY);
+ }
+}
+
+
+static void
+test_media_pipeline_start_no_codec (void)
+{
+ g_autoptr (CallsSipMediaPipeline) pipeline = calls_sip_media_pipeline_new (NULL);
+
+ g_assert_cmpint (calls_sip_media_pipeline_get_state (pipeline), ==,
+ CALLS_MEDIA_PIPELINE_STATE_NEED_CODEC);
+
+ g_test_expect_message ("CallsSipMediaPipeline", G_LOG_LEVEL_WARNING,
+ "Cannot start pipeline because it's not ready");
+
+ calls_sip_media_pipeline_start (pipeline);
+ g_test_assert_expected_messages ();
+
+ g_test_expect_message ("CallsSipMediaPipeline", G_LOG_LEVEL_WARNING,
+ "Cannot pause or unpause pipeline because it's not currently active");
+
+ calls_sip_media_pipeline_pause (pipeline, TRUE);
+ g_test_assert_expected_messages ();
+}
+
+
+static void
+test_media_pipeline_finalized_in_call (void)
+{
+ CallsSipMediaManager *manager = calls_sip_media_manager_default ();
+ CallsSipMediaPipeline *pipeline = calls_sip_media_pipeline_new (NULL);
+ CallsSipCall *call = calls_sip_call_new ("sip:alice example org",
+ TRUE,
+ "127.0.0.1",
+ pipeline,
+ NULL);
+
+ g_object_unref (call);
+ g_assert_finalize_object (pipeline);
+
+ pipeline = calls_sip_media_manager_get_pipeline (manager);
+ call = calls_sip_call_new ("sip:bob example org",
+ TRUE,
+ "127.0.0.1",
+ pipeline,
+ NULL);
+ g_object_unref (call);
+ g_assert_finalize_object (pipeline);
+}
+
+
int
main (int argc,
char *argv[])
{
+ CallsSipMediaManager *manager = calls_sip_media_manager_default ();
int ret;
gtk_test_init (&argc, &argv, NULL);
@@ -162,9 +265,15 @@ main (int argc,
gst_init (NULL, NULL);
g_test_add_func ("/Calls/SIP/media_manager/capabilities", test_sip_media_manager_caps);
+ g_test_add_func ("/Calls/SIP/pipeline/states", test_media_pipeline_states);
+ g_test_add_func ("/Calls/SIP/pipeline/setup_codecs", test_media_pipeline_setup_codecs);
+ g_test_add_func ("/Calls/SIP/pipeline/start_no_codec", test_media_pipeline_start_no_codec);
+ g_test_add_func ("/Calls/SIP/pipeline/finalized_in_call", test_media_pipeline_finalized_in_call);
ret = g_test_run();
+ g_assert_finalize_object (manager);
+
gst_deinit ();
return ret;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]