aboutsummaryrefslogtreecommitdiffstats
path: root/tests/osmux
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2017-04-25 17:20:38 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2017-04-27 08:50:01 +0000
commite98afe5808176efb60298a2f764e8e11efaf580b (patch)
treecb53aebb0bacd93ca77a21ae9152502a6ebf7692 /tests/osmux
parenta67c47cab412b631c19e3f32167b9f5a0edc39ba (diff)
osmux: Add RTP marker bit support
According to RFC4867 (RTP payload format for AMR): "The RTP header marker bit (M) SHALL be set to 1 if the first frameblock carried in the packet contains a speech frame which is the first in a talkspurt. For all other packets the marker bit SHALL be set to zero (M=0)." This information bit provides a way for the receiver to better synchronize the delay with ther sender. This is specially useful if AMR DTX features are supported and enabled on the sender. Change-Id: I0315658159429603f1d80a168718b026015060e9
Diffstat (limited to 'tests/osmux')
-rw-r--r--tests/osmux/osmux_test.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c
index 2f5a6cd..9941ce3 100644
--- a/tests/osmux/osmux_test.c
+++ b/tests/osmux/osmux_test.c
@@ -55,6 +55,7 @@ static uint8_t rtp_pkt[] = {
};
static int rtp_pkts;
+static int mark_pkts;
#if OSMUX_TEST_USE_TIMING
static struct timeval last;
#endif
@@ -62,6 +63,7 @@ static struct timeval last;
static void tx_cb(struct msgb *msg, void *data)
{
char buf[4096];
+ struct rtp_hdr *rtph = (struct rtp_hdr *)msg->data;
#if OSMUX_TEST_USE_TIMING
struct timeval now, diff;
@@ -87,6 +89,8 @@ static void tx_cb(struct msgb *msg, void *data)
exit(EXIT_FAILURE);
}
+ if (rtph->marker)
+ mark_pkts--;
rtp_pkts--;
msgb_free(msg);
}
@@ -124,6 +128,48 @@ static void sigalarm_handler(int foo)
exit(EXIT_FAILURE);
}
+static void osmux_test_marker(int ccid) {
+ struct msgb *msg;
+ struct rtp_hdr *rtph = (struct rtp_hdr *)rtp_pkt;
+ struct rtp_hdr *cpy_rtph;
+ uint16_t seq;
+ int i, j;
+
+ for (i = 0; i < 64; i++) {
+
+ seq = ntohs(rtph->sequence);
+ seq++;
+ rtph->sequence = htons(seq);
+
+ for (j=0; j<4; j++) {
+ msg = msgb_alloc(1500, "test");
+ if (!msg)
+ exit(EXIT_FAILURE);
+
+ memcpy(msg->data, rtp_pkt, sizeof(rtp_pkt));
+ cpy_rtph = (struct rtp_hdr *) msgb_put(msg, sizeof(rtp_pkt));
+
+ if ((i+j) % 7 == 0) {
+ cpy_rtph->marker = 1;
+ mark_pkts++;
+ }
+
+ rtp_pkts++;
+ while (osmux_xfrm_input(&h_input, msg, j + ccid) > 0) {
+ osmux_xfrm_input_deliver(&h_input);
+ }
+ }
+ }
+
+ while (rtp_pkts)
+ osmo_select_main(0);
+
+ if (mark_pkts) {
+ fprintf(stdout, "RTP M bit (marker) mismatch! %d\n", mark_pkts);
+ exit(EXIT_FAILURE);
+ }
+}
+
static void osmux_test_loop(int ccid)
{
struct msgb *msg;
@@ -177,6 +223,11 @@ static void osmux_test_loop(int ccid)
k = 0;
}
}
+
+ if (mark_pkts) {
+ fprintf(stdout, "RTP M bit (marker) mismatch! %d\n", mark_pkts);
+ exit(EXIT_FAILURE);
+ }
}
int main(void)
@@ -192,12 +243,24 @@ int main(void)
osmo_init_logging(&osmux_test_log_info);
log_set_log_level(osmo_stderr_target, LOGL_DEBUG);
- osmux_xfrm_input_init(&h_input);
osmux_xfrm_output_init(&h_output, 0x7000000);
/* If the test takes longer than 10 seconds, abort it */
alarm(10);
+#if !OSMUX_TEST_USE_TIMING
+ /* Check if marker bit features work correctly */
+ osmux_xfrm_input_init(&h_input);
+ for (i = 0; i < 4; i++)
+ osmux_xfrm_input_open_circuit(&h_input, i, 0);
+ osmux_test_marker(0);
+ for (i = 0; i < 4; i++)
+ osmux_xfrm_input_close_circuit(&h_input, i);
+ osmux_xfrm_input_fini(&h_input);
+#endif
+
+ osmux_xfrm_input_init(&h_input);
+
for (i = 0; i < 2; i++)
osmux_xfrm_input_open_circuit(&h_input, i, 0);