From e142ddfd7714cb067fa15216a432e758218027bf Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sat, 7 Jul 2012 17:37:26 +0200 Subject: rtp: split osmo_rtp_parse in two functions This patch splits osmo_rtp_parse in two functions: osmo_rtp_get_hdr osmo_rtp_get_payload So we can validate corrent RTP header to access its fields. Then, obtain the payload. --- examples/rtp-udp-test-client.c | 11 ++++++----- examples/rtp-udp-test-server.c | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'examples') diff --git a/examples/rtp-udp-test-client.c b/examples/rtp-udp-test-client.c index 4163703..97ec6ff 100644 --- a/examples/rtp-udp-test-client.c +++ b/examples/rtp-udp-test-client.c @@ -39,7 +39,7 @@ static struct osmo_rtp_handle *rtp; static int read_cb(struct osmo_dgram_conn *conn) { struct msgb *msg; - int payload_type; + struct rtp_hdr *rtph; LOGP(DLINP, LOGL_DEBUG, "received message\n"); @@ -53,15 +53,16 @@ static int read_cb(struct osmo_dgram_conn *conn) LOGP(DRTP_TEST, LOGL_ERROR, "cannot receive message\n"); return -1; } - payload_type = osmo_rtp_parse(msg); - if (payload_type < 0) { + + rtph = osmo_rtp_get_hdr(msg); + if (rtph == NULL) { msgb_free(msg); LOGP(DRTP_TEST, LOGL_ERROR, "cannot parse RTP message\n"); return -1; } - LOGP(DLINP, LOGL_DEBUG, "received message with payload type: %d " - "and size: %d (%s)\n", payload_type, msg->len, msg->data); + LOGP(DLINP, LOGL_DEBUG, "received message with payload type: %d\n", + rtph->payload_type); msgb_free(msg); return 0; diff --git a/examples/rtp-udp-test-server.c b/examples/rtp-udp-test-server.c index 5efd920..2f7f291 100644 --- a/examples/rtp-udp-test-server.c +++ b/examples/rtp-udp-test-server.c @@ -38,7 +38,7 @@ int read_cb(struct osmo_dgram_conn *conn) { struct msgb *msg; char dummy_data[RTP_PT_GSM_FULL_PAYLOAD_LEN] = "payload test"; - int payload_type; + struct rtp_hdr *rtph; LOGP(DRTP_TEST, LOGL_DEBUG, "received message from datagram\n"); @@ -51,14 +51,14 @@ int read_cb(struct osmo_dgram_conn *conn) LOGP(DRTP_TEST, LOGL_ERROR, "cannot receive message\n"); return -1; } - payload_type = osmo_rtp_parse(msg); - if (payload_type < 0) { + rtph = osmo_rtp_get_hdr(msg); + if (rtph == NULL) { msgb_free(msg); LOGP(DRTP_TEST, LOGL_ERROR, "cannot parse RTP message\n"); return -1; } - LOGP(DLINP, LOGL_DEBUG, "received message with RTP payload type: %d " - "and size: %d (%s)\n", payload_type, msg->len, msg->data); + LOGP(DLINP, LOGL_DEBUG, "received message with RTP payload type: %d\n", + rtph->payload_type); /* * ... now build gsm_data_frame, set callref and msg_type based -- cgit v1.2.3