aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Chemeris <Alexander.Chemeris@gmail.com>2015-11-24 21:09:27 -0500
committerAlexander Chemeris <Alexander.Chemeris@gmail.com>2015-11-24 21:09:27 -0500
commitccdd23317062d7e94f5eb40f025ab21c9bdaa50f (patch)
tree5b7787dcfd9ce893622b65991004b1f222483f8f
parente85e7910d22374ba33a347839aa17289f4b9a077 (diff)
rtp_proxy: Pass RTP message type to rtp_socket_upstream().
This allows us to decode incoming RTP packet based on the codec instead of relying on payload type. Payload type is dynamic for HR, EFR and AMR, so we can't rely on it.
-rw-r--r--openbsc/include/openbsc/rtp_proxy.h2
-rw-r--r--openbsc/src/libmsc/gsm_04_08.c39
-rw-r--r--openbsc/src/libtrau/rtp_proxy.c3
3 files changed, 40 insertions, 4 deletions
diff --git a/openbsc/include/openbsc/rtp_proxy.h b/openbsc/include/openbsc/rtp_proxy.h
index 61ad325c9..12b74fae3 100644
--- a/openbsc/include/openbsc/rtp_proxy.h
+++ b/openbsc/include/openbsc/rtp_proxy.h
@@ -91,7 +91,7 @@ struct rtp_socket *rtp_socket_create(void);
int rtp_socket_bind(struct rtp_socket *rs, uint32_t ip);
int rtp_socket_connect(struct rtp_socket *rs, uint32_t ip, uint16_t port);
int rtp_socket_proxy(struct rtp_socket *this, struct rtp_socket *other);
-int rtp_socket_upstream(struct rtp_socket *this, struct gsm_network *net, uint32_t callref);
+int rtp_socket_upstream(struct rtp_socket *this, struct gsm_network *net, uint32_t callref, uint32_t msg_type);
int rtp_socket_free(struct rtp_socket *rs);
int rtp_send_frame(struct rtp_socket *rs, struct gsm_data_frame *frame);
diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index 5a9e1ecc6..9d4741d7d 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -1638,6 +1638,41 @@ static int tch_bridge(struct gsm_network *net, uint32_t *refs)
return tch_map(trans1->conn->lchan, trans2->conn->lchan);
}
+
+static uint32_t tch_msg_type_for_lchan(struct gsm_lchan *lchan)
+{
+ switch (lchan->tch_mode) {
+ case GSM48_CMODE_SPEECH_V1:
+ switch (lchan->type) {
+ case GSM_LCHAN_TCH_F:
+ return GSM_TCHF_FRAME;
+ case GSM_LCHAN_TCH_H:
+ return GSM_TCHH_FRAME;
+ default:
+ break;
+ }
+ break;
+ case GSM48_CMODE_SPEECH_EFR:
+ switch (lchan->type) {
+ case GSM_LCHAN_TCH_F:
+ return GSM_TCHF_FRAME_EFR;
+ /* there's no half-rate EFR */
+ default:
+ break;
+ }
+ break;
+ case GSM48_CMODE_SPEECH_AMR:
+ return GSM_TCH_FRAME_AMR;
+ break;
+ default:
+ break;
+ }
+ LOGP(DCC, LOGL_ERROR, "Cannot determine MNCC codec type speech mode for "
+ "tch_mode == 0x%02x lchan->type=0x%02x\n", lchan->tch_mode, lchan->type);
+ return 0;
+}
+
+
/* enable receive of channels to MNCC upqueue */
static int tch_recv_mncc(struct gsm_network *net, uint32_t callref, int enable)
{
@@ -1683,10 +1718,10 @@ static int tch_recv_mncc(struct gsm_network *net, uint32_t callref, int enable)
return rc;
/* assign socket to application interface */
rtp_socket_upstream(lchan->abis_ip.rtp_socket,
- net, callref);
+ net, callref, tch_msg_type_for_lchan(lchan));
} else
rtp_socket_upstream(lchan->abis_ip.rtp_socket,
- net, 0);
+ net, 0, 0);
break;
case GSM_BTS_TYPE_BS11:
case GSM_BTS_TYPE_RBS2000:
diff --git a/openbsc/src/libtrau/rtp_proxy.c b/openbsc/src/libtrau/rtp_proxy.c
index dfb3635ad..4cdab3de3 100644
--- a/openbsc/src/libtrau/rtp_proxy.c
+++ b/openbsc/src/libtrau/rtp_proxy.c
@@ -761,7 +761,7 @@ int rtp_socket_proxy(struct rtp_socket *this, struct rtp_socket *other)
* \param[in] callref callref argument to trau_tx_to_mncc()
*/
int rtp_socket_upstream(struct rtp_socket *this, struct gsm_network *net,
- uint32_t callref)
+ uint32_t callref, uint32_t msg_type)
{
DEBUGP(DLMUX, "rtp_socket_proxy(this=%p, callref=%u)\n",
this, callref);
@@ -770,6 +770,7 @@ int rtp_socket_upstream(struct rtp_socket *this, struct gsm_network *net,
this->rx_action = RTP_RECV_UPSTREAM;
this->receive.net = net;
this->receive.callref = callref;
+ this->receive.msg_type = msg_type;
} else
this->rx_action = RTP_NONE;