]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[unit-tests] add basic RTP unit-test 187/head
authorDragos Oancea <dragos@signalwire.com>
Tue, 26 Nov 2019 14:20:52 +0000 (14:20 +0000)
committerAndrey Volk <andywolk@gmail.com>
Thu, 19 Dec 2019 20:04:06 +0000 (00:04 +0400)
tests/unit/Makefile.am
tests/unit/switch_rtp.c [new file with mode: 0644]

index f3e9a7d234e12048dc13d26724a88ebf580ea2f1..2b5f9539971d11aa1d5d795c6f27ae46725935f6 100644 (file)
@@ -1,7 +1,7 @@
 include $(top_srcdir)/build/modmake.rulesam
 
 noinst_PROGRAMS = switch_event switch_hash switch_ivr_originate switch_utils switch_core switch_console switch_vpx switch_core_file \
-                          switch_ivr_play_say switch_core_codec
+                          switch_ivr_play_say switch_core_codec switch_rtp
 noinst_PROGRAMS+= switch_core_video
 AM_LDFLAGS  = -avoid-version -no-undefined $(SWITCH_AM_LDFLAGS) $(openssl_LIBS)
 AM_LDFLAGS += $(FREESWITCH_LIBS) $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS)
diff --git a/tests/unit/switch_rtp.c b/tests/unit/switch_rtp.c
new file mode 100644 (file)
index 0000000..8c41764
--- /dev/null
@@ -0,0 +1,59 @@
+
+#include <switch.h>
+#include <test/switch_test.h>
+
+static const char *rx_host = "127.0.0.1";
+static switch_port_t rx_port = 12346;
+static const char *tx_host = "127.0.0.1";
+static switch_port_t tx_port = 54320;
+static switch_memory_pool_t *pool = NULL;
+static switch_rtp_t *rtp_session = NULL;
+static switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID] = {0};
+const char *err = NULL;
+static const switch_payload_t TEST_PT = 8;
+switch_rtp_packet_t rtp_packet;
+switch_frame_flag_t *frame_flags;
+switch_io_flag_t io_flags;
+switch_payload_t read_pt;
+uint datalen;
+
+FST_CORE_BEGIN("./conf")
+{
+FST_SUITE_BEGIN(switch_rtp)
+{
+FST_SETUP_BEGIN()
+{
+}
+FST_SETUP_END()
+
+FST_TEARDOWN_BEGIN()
+{
+}
+FST_TEARDOWN_END()
+
+FST_TEST_BEGIN(test_rtp)
+{
+       switch_core_new_memory_pool(&pool);
+       
+       rtp_session = switch_rtp_new(rx_host, rx_port, tx_host, tx_port, TEST_PT, 8000, 20 * 1000, flags, "soft", &err, pool, 0, 0);
+       fst_xcheck(rtp_session != NULL, "get RTP session");
+       fst_requires(rtp_session);
+       fst_requires(switch_rtp_ready(rtp_session));
+       switch_rtp_activate_rtcp(rtp_session, 5, rx_port + 1, 0);
+       switch_rtp_set_default_payload(rtp_session, TEST_PT);
+       fst_xcheck(switch_rtp_get_default_payload(rtp_session) == TEST_PT, "get Payload Type")
+       switch_rtp_set_ssrc(rtp_session, 0xabcd);
+       switch_rtp_set_remote_ssrc(rtp_session, 0xcdef);
+       fst_xcheck(switch_rtp_get_ssrc(rtp_session) == 0xabcd, "get SSRC");
+       switch_rtp_stats_t *stats = switch_rtp_get_stats(rtp_session, pool);
+       fst_requires(stats);
+       switch_rtp_destroy(&rtp_session);
+
+       switch_core_destroy_memory_pool(&pool);
+}
+FST_TEST_END()
+}
+FST_SUITE_END()
+}
+FST_CORE_END()
+