diff options
-rw-r--r-- | tests/jibuf/jibuf_test.c | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/tests/jibuf/jibuf_test.c b/tests/jibuf/jibuf_test.c index 4a09267..0b2da0b 100644 --- a/tests/jibuf/jibuf_test.c +++ b/tests/jibuf/jibuf_test.c @@ -25,6 +25,7 @@ #include <osmocom/core/linuxlist.h> #include <osmocom/netif/jibuf.h> #include <osmocom/netif/rtp.h> +#include <osmocom/netif/osmux.h> #include "../osmo-pcap-test/osmo_pcap.h" @@ -53,6 +54,7 @@ struct rtp_pkt_info_cb { static bool opt_test_rand; static bool opt_debug_human; static bool opt_debug_table; +static bool opt_osmux; static char* opt_pcap_file; /* ----------------------------- */ @@ -108,6 +110,8 @@ static uint32_t packets_too_much_jitter; /* Used for test pcap: */ 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) @@ -310,7 +314,7 @@ struct rtp_pkt_info * msgb_allocate_pinfo(struct msgb *msg) return cb->data; } -void send_rtp_packet() +void rand_send_rtp_packet() { struct rtp_pkt_info *pinfo; @@ -368,7 +372,7 @@ void rand_generate_pkt_cb(void *data) if (!packets_sent) gettimeofday(&last_generated, NULL); - send_rtp_packet(); + rand_send_rtp_packet(); packets_sent++; timeradd(&last_generated, &time_rate, &sched_ts); @@ -401,9 +405,33 @@ static int pcap_generate_pkt_cb(struct msgb *msg) return 0; } +void glue_cb(struct msgb *msg, void *data) +{ + pcap_generate_pkt_cb(msg); +} + +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); + } + msgb_free(msg); + return 0; +} + void pcap_pkt_timer_cb(void *data) { - if (osmo_pcap_test_run(&osmo_pcap, IPPROTO_UDP, pcap_generate_pkt_cb) < 0) { + int (*mycb)(struct msgb *msgb); + if(opt_osmux) + mycb = pcap_read_osmux; + else + mycb = pcap_generate_pkt_cb; + + if (osmo_pcap_test_run(&osmo_pcap, IPPROTO_UDP, mycb) < 0) { osmo_pcap_stats_printf(); osmo_pcap_test_close(osmo_pcap.h); pcap_finished=true; @@ -468,6 +496,11 @@ 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); + } + jb = osmo_jibuf_alloc(); osmo_jibuf_set_dequeue_cb(jb, dequeue_cb, NULL); osmo_jibuf_set_min_delay(jb, 60); @@ -486,10 +519,11 @@ void pcap_test() { static void print_help(void) { - printf("jibuf_test [-r] [-p pcap] [-d] [-g]\n"); + printf("jibuf_test [-r] [-p pcap] [-o] [-d] [-g]\n"); printf(" -h Print this help message\n"); printf(" -r Run test with randomly generated jitter\n"); printf(" -p Run test with specified pcap file\n"); + printf(" -o The pcap contains OSMUX packets isntead of RTP\n"); printf(" -d Enable packet trace debug suitable for humans\n"); printf(" -t Enable packet trace debug suitable for gnuplot\n"); } @@ -498,7 +532,7 @@ static int parse_options(int argc, char **argv) { int opt; - while ((opt = getopt(argc, argv, "hdtrp:")) != -1) { + while ((opt = getopt(argc, argv, "hdtrop:")) != -1) { switch (opt) { case 'h': print_help(); @@ -512,6 +546,9 @@ static int parse_options(int argc, char **argv) case 'r': opt_test_rand = true; break; + case 'o': + opt_osmux = true; + break; case 'p': opt_pcap_file = strdup(optarg); break; |