aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libtrau/rtp_proxy.c
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2012-02-17 15:20:59 +0100
committerIvan Kluchnikov <kluchnikovi@gmail.com>2015-05-26 15:55:12 +0300
commit39494b875165848fa16d3e7b328677dd8d26163b (patch)
tree450f7767215a70a300c17b8625132614511e93f5 /openbsc/src/libtrau/rtp_proxy.c
parentbc1aaacf7412e7a042e28be75139a72de3324c93 (diff)
Allow dynamic RTP payload types between application and MNCC interface
Since EFR/AMR/HR codecs use dynamic RTP payload, the payload type can be set. If it is set, the frame type must be set also, so OpenBSC knows what frame types are received via RTP. This modification only affects traffic beween application and MNCC interface, not the RTP traffic between OpenBSC and BTS. Conflicts: openbsc/src/libtrau/rtp_proxy.c
Diffstat (limited to 'openbsc/src/libtrau/rtp_proxy.c')
-rw-r--r--openbsc/src/libtrau/rtp_proxy.c58
1 files changed, 40 insertions, 18 deletions
diff --git a/openbsc/src/libtrau/rtp_proxy.c b/openbsc/src/libtrau/rtp_proxy.c
index 65ac4094b..d8fde15d1 100644
--- a/openbsc/src/libtrau/rtp_proxy.c
+++ b/openbsc/src/libtrau/rtp_proxy.c
@@ -68,7 +68,7 @@ enum rtp_bfd_priv {
#define MAX_RTP_PAYLOAD_LEN 33
/* decode an rtp frame and create a new buffer with payload */
-static int rtp_decode(struct msgb *msg, uint32_t callref, struct msgb **data)
+static int rtp_decode(struct msgb *msg, uint32_t callref, struct msgb **data, int msg_type)
{
struct msgb *new_msg;
struct gsm_data_frame *frame;
@@ -76,7 +76,6 @@ static int rtp_decode(struct msgb *msg, uint32_t callref, struct msgb **data)
struct rtp_x_hdr *rtpxh;
uint8_t *payload, *payload_out;
int payload_len;
- int msg_type;
int x_len;
if (msg->len < 12) {
@@ -126,9 +125,31 @@ static int rtp_decode(struct msgb *msg, uint32_t callref, struct msgb **data)
}
}
- switch (rtph->payload_type) {
- case RTP_PT_GSM_FULL:
- msg_type = GSM_TCHF_FRAME;
+ /* If no explicit frame type is given, select frame type from
+ * payload type. */
+ if (!msg_type) {
+ switch (rtph->payload_type) {
+ case RTP_PT_GSM_FULL:
+ msg_type = GSM_TCHF_FRAME;
+ break;
+ case RTP_PT_GSM_EFR:
+ msg_type = GSM_TCHF_FRAME_EFR;
+ break;
+ case RTP_PT_GSM_HALF:
+ msg_type = GSM_TCHH_FRAME;
+ break;
+ case RTP_PT_AMR:
+ msg_type = GSM_TCH_FRAME_AMR;
+ break;
+ default:
+ DEBUGPC(DLMUX, "received RTP frame with unknown "
+ "payload type %d\n", rtph->payload_type);
+ return -EINVAL;
+ }
+ }
+
+ switch (msg_type) {
+ case GSM_TCHF_FRAME:
if (payload_len != RTP_LEN_GSM_FULL) {
DEBUGPC(DLMUX, "received RTP full rate frame with "
"payload length != %d (len = %d)\n",
@@ -136,8 +157,7 @@ static int rtp_decode(struct msgb *msg, uint32_t callref, struct msgb **data)
return -EINVAL;
}
break;
- case RTP_PT_GSM_EFR:
- msg_type = GSM_TCHF_FRAME_EFR;
+ case GSM_TCHF_FRAME_EFR:
if (payload_len != RTP_LEN_GSM_EFR) {
DEBUGPC(DLMUX, "received RTP extended full rate frame "
"with payload length != %d (len = %d)\n",
@@ -145,8 +165,7 @@ static int rtp_decode(struct msgb *msg, uint32_t callref, struct msgb **data)
return -EINVAL;
}
break;
- case RTP_PT_GSM_HALF:
- msg_type = GSM_TCHH_FRAME;
+ case GSM_TCHH_FRAME:
if (payload_len != RTP_LEN_GSM_HALF) {
DEBUGPC(DLMUX, "received RTP half rate frame with "
"payload length != %d (len = %d)\n",
@@ -154,12 +173,10 @@ static int rtp_decode(struct msgb *msg, uint32_t callref, struct msgb **data)
return -EINVAL;
}
break;
- case RTP_PT_AMR:
- msg_type = GSM_TCH_FRAME_AMR;
+ case GSM_TCH_FRAME_AMR:
break;
default:
- DEBUGPC(DLMUX, "received RTP frame with unknown payload "
- "type %d\n", rtph->payload_type);
+ DEBUGPC(DLMUX, "Forced message type %x unknown\n", msg_type);
return -EINVAL;
}
@@ -207,6 +224,10 @@ int rtp_send_frame(struct rtp_socket *rs, struct gsm_data_frame *frame)
int payload_len;
int duration; /* in samples */
int is_bfi = 0;
+ uint8_t dynamic_pt = 0;
+
+ if (rs->rx_action == RTP_RECV_APP)
+ dynamic_pt = rs->receive.payload_type;
if (rs->tx_action != RTP_SEND_DOWNSTREAM) {
/* initialize sequences */
@@ -223,17 +244,17 @@ int rtp_send_frame(struct rtp_socket *rs, struct gsm_data_frame *frame)
duration = RTP_GSM_DURATION;
break;
case GSM_TCHF_FRAME_EFR:
- payload_type = RTP_PT_GSM_EFR;
+ payload_type = (dynamic_pt) ? : RTP_PT_GSM_EFR;
payload_len = RTP_LEN_GSM_EFR;
duration = RTP_GSM_DURATION;
break;
case GSM_TCHH_FRAME:
- payload_type = RTP_PT_GSM_HALF;
+ payload_type = (dynamic_pt) ? : RTP_PT_GSM_HALF;
payload_len = RTP_LEN_GSM_HALF;
duration = RTP_GSM_DURATION;
break;
case GSM_TCH_FRAME_AMR:
- payload_type = RTP_PT_AMR;
+ payload_type = (dynamic_pt) ? : RTP_PT_AMR;
payload_len = frame->data[0];
duration = RTP_GSM_DURATION;
break;
@@ -452,7 +473,7 @@ static int rtp_socket_read(struct rtp_socket *rs, struct rtp_sub_socket *rss)
rc = -EINVAL;
goto out_free;
}
- rc = rtp_decode(msg, rs->receive.callref, &new_msg);
+ rc = rtp_decode(msg, rs->receive.callref, &new_msg, 0);
if (rc < 0)
goto out_free;
msgb_free(msg);
@@ -468,7 +489,8 @@ static int rtp_socket_read(struct rtp_socket *rs, struct rtp_sub_socket *rss)
rc = ENOTSUP;
goto out_free;
}
- rc = rtp_decode(msg, rs->receive.callref, &new_msg);
+ rc = rtp_decode(msg, rs->receive.callref, &new_msg,
+ rs->receive.msg_type);
if (rc < 0)
goto out_free;
msgb_free(msg);