From df0ad6c1a4e23a96428e435af7ba54c2f367546b Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 19 Apr 2018 12:29:45 +0200 Subject: osmux: Move examples and tests to use new output APIs Change-Id: Ie69c427308eb7d81aedab7fbb71f1bdaf43f0275 --- examples/osmux-test-output.c | 10 ++++------ tests/jibuf/jibuf_tool.c | 14 +++++++------- tests/osmo-pcap-test/osmux_test.c | 9 +++------ tests/osmux/osmux_test.c | 8 +++----- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/examples/osmux-test-output.c b/examples/osmux-test-output.c index 9b7c113..0ab03a7 100644 --- a/examples/osmux-test-output.c +++ b/examples/osmux-test-output.c @@ -88,7 +88,6 @@ int read_cb(struct osmo_dgram *conn) { struct msgb *msg; struct osmux_hdr *osmuxh; - struct llist_head list; LOGP(DOSMUX_TEST, LOGL_DEBUG, "received message from datagram\n"); @@ -107,10 +106,8 @@ int read_cb(struct osmo_dgram *conn) LOGP(DOSMUX_TEST, LOGL_DEBUG, "received OSMUX message (len=%d) %s\n", msg->len, buf); - while((osmuxh = osmux_xfrm_output_pull(msg)) != NULL) { - osmux_xfrm_output(osmuxh, &h_output, &list); - osmux_tx_sched(&list, tx_cb, NULL); - } + while((osmuxh = osmux_xfrm_output_pull(msg)) != NULL) + osmux_xfrm_output_sched(&h_output, osmuxh); return 0; } @@ -120,6 +117,7 @@ void sighandler(int foo) LOGP(DOSMUX_TEST, LOGL_NOTICE, "closing OSMUX.\n"); osmo_dgram_close(conn); osmo_dgram_destroy(conn); + osmux_xfrm_output_flush(&h_output); osmo_rtp_handle_free(rtp); amr_close(); exit(EXIT_SUCCESS); @@ -158,7 +156,7 @@ int main(int argc, char *argv[]) * initialize OSMUX handlers. */ osmux_xfrm_output_init(&h_output, random()); - + osmux_xfrm_output_set_tx_cb(&h_output, tx_cb, NULL); /* * initialize datagram server. */ diff --git a/tests/jibuf/jibuf_tool.c b/tests/jibuf/jibuf_tool.c index 8fa9f2e..bd444a7 100644 --- a/tests/jibuf/jibuf_tool.c +++ b/tests/jibuf/jibuf_tool.c @@ -114,7 +114,6 @@ static uint32_t packets_too_much_jitter; static struct osmo_pcap osmo_pcap; static bool pcap_finished; static struct osmux_out_handle pcap_osmux_h; -static struct llist_head osmux_list; /* ----------------------------- */ static void sigalarm_handler(int foo) @@ -438,10 +437,8 @@ int pcap_read_osmux(struct msgb *msg) struct osmux_hdr *osmuxh; /* This code below belongs to the osmux receiver */ - while((osmuxh = osmux_xfrm_output_pull(msg)) != NULL) { - osmux_xfrm_output(osmuxh, &pcap_osmux_h, &osmux_list); - osmux_tx_sched(&osmux_list, glue_cb, NULL); - } + while((osmuxh = osmux_xfrm_output_pull(msg)) != NULL) + osmux_xfrm_output_sched(&pcap_osmux_h, osmuxh); msgb_free(msg); return 0; } @@ -520,8 +517,8 @@ void pcap_test() { osmo_pcap.timer.cb = pcap_pkt_timer_cb; if(opt_osmux) { - INIT_LLIST_HEAD(&osmux_list); osmux_xfrm_output_init(&pcap_osmux_h, 0); + osmux_xfrm_output_set_tx_cb(&pcap_osmux_h, glue_cb, NULL); } jb = osmo_jibuf_alloc(NULL); @@ -533,8 +530,11 @@ void pcap_test() { /* first run */ pcap_pkt_timer_cb(NULL); - while(!pcap_finished || !osmo_jibuf_empty(jb)) + while(!pcap_finished || !osmo_jibuf_empty(jb)) { + if (pcap_finished && opt_osmux) /* Flushing once should be enough */ + osmux_xfrm_output_flush(&pcap_osmux_h); osmo_select_main(0); + } osmo_jibuf_delete(jb); diff --git a/tests/osmo-pcap-test/osmux_test.c b/tests/osmo-pcap-test/osmux_test.c index 463b212..7ec78a0 100644 --- a/tests/osmo-pcap-test/osmux_test.c +++ b/tests/osmo-pcap-test/osmux_test.c @@ -52,16 +52,12 @@ static void tx_cb(struct msgb *msg, void *data) static void deliver(struct msgb *batch_msg) { struct osmux_hdr *osmuxh; - struct llist_head list; printf("sending batch (len=%d) [emulated]\n", batch_msg->len); /* This code below belongs to the osmux receiver */ - while((osmuxh = osmux_xfrm_output_pull(batch_msg)) != NULL) { - - osmux_xfrm_output(osmuxh, &h_output, &list); - osmux_tx_sched(&list, tx_cb, NULL); - } + while((osmuxh = osmux_xfrm_output_pull(batch_msg)) != NULL) + osmux_xfrm_output_sched(&h_output, osmuxh); msgb_free(batch_msg); } @@ -194,6 +190,7 @@ int main(int argc, char *argv[]) osmux_xfrm_input_init(&h_input); osmux_xfrm_output_init(&h_output); + osmux_xfrm_output_set_tx_cb(&h_output, tx_cb, NULL); /* first run */ osmo_pcap_pkt_timer_cb(NULL); diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c index 631ade8..704ccbc 100644 --- a/tests/osmux/osmux_test.c +++ b/tests/osmux/osmux_test.c @@ -103,7 +103,6 @@ static struct osmux_out_handle h_output; static void osmux_deliver(struct msgb *batch_msg, void *data) { struct osmux_hdr *osmuxh; - LLIST_HEAD(list); char buf[2048]; osmux_snprintf(buf, sizeof(buf), batch_msg); @@ -112,10 +111,8 @@ static void osmux_deliver(struct msgb *batch_msg, void *data) /* For each OSMUX message, extract the RTP messages and put them * in a list. Then, reconstruct transmission timing. */ - while((osmuxh = osmux_xfrm_output_pull(batch_msg)) != NULL) { - osmux_xfrm_output(osmuxh, &h_output, &list); - osmux_tx_sched(&list, tx_cb, NULL); - } + while((osmuxh = osmux_xfrm_output_pull(batch_msg)) != NULL) + osmux_xfrm_output_sched(&h_output, osmuxh); msgb_free(batch_msg); } @@ -273,6 +270,7 @@ int main(void) log_set_log_level(osmo_stderr_target, LOGL_DEBUG); osmux_xfrm_output_init(&h_output, 0x7000000); + osmux_xfrm_output_set_tx_cb(&h_output, tx_cb, NULL); /* If the test takes longer than 10 seconds, abort it */ alarm(10); -- cgit v1.2.3