summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2012-02-17 15:20:59 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2015-12-27 20:16:57 +0100
commitfa032ac8b3c1f49c908dcd5380b48f198439494e (patch)
tree79869c647c4c92552cbcd163cf4831c6bf8dfcb4
parent990b41308770426eec50cbee6ac5f270f93afee2 (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.
-rw-r--r--openbsc/include/openbsc/rtp_proxy.h2
-rw-r--r--openbsc/src/libtrau/rtp_proxy.c58
2 files changed, 42 insertions, 18 deletions
diff --git a/openbsc/include/openbsc/rtp_proxy.h b/openbsc/include/openbsc/rtp_proxy.h
index a5f6a2b..61ad325 100644
--- a/openbsc/include/openbsc/rtp_proxy.h
+++ b/openbsc/include/openbsc/rtp_proxy.h
@@ -74,6 +74,8 @@ struct rtp_socket {
struct {
struct gsm_network *net;
uint32_t callref;
+ uint8_t payload_type; /* dynamic PT */
+ int msg_type; /* message type for dynamic PT */
} receive;
};
enum rtp_tx_action tx_action;
diff --git a/openbsc/src/libtrau/rtp_proxy.c b/openbsc/src/libtrau/rtp_proxy.c
index 65ac409..d8fde15 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);