summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-11-01 22:38:25 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-11-02 19:08:09 +0100
commit8b19dee437cdd73f75413d5f936e768939e3db71 (patch)
tree107881508da43f7e408674e519fdba380a74f83e
parent5f2cd842818a8809865d1caacc78bdf92c823e40 (diff)
mgcp: Send data from the network to the transcoder too
We now should be able to transcode in both directions.
-rw-r--r--openbsc/src/mgcp/mgcp_network.c24
-rw-r--r--openbsc/src/mgcp/mgcp_protocol.c4
2 files changed, 12 insertions, 16 deletions
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c
index f8c552c..8a73e37 100644
--- a/openbsc/src/mgcp/mgcp_network.c
+++ b/openbsc/src/mgcp/mgcp_network.c
@@ -168,29 +168,22 @@ static int forward_data(int fd, struct mgcp_rtp_tap *tap, const char *buf, int l
(struct sockaddr *)&tap->forward, sizeof(tap->forward));
}
-static int send_transcoder(struct mgcp_endpoint *endp, int is_rtp,
- const char *buf, int len)
+static int send_transcoder(struct mgcp_rtp_end *end, struct mgcp_config *cfg,
+ int is_rtp, const char *buf, int len)
{
int rc;
int port;
- struct mgcp_config *cfg = endp->cfg;
struct sockaddr_in addr;
- if (endp->trans_net.rtp_port == 0) {
- LOGP(DMGCP, LOGL_ERROR, "Transcoder port not known on 0x%x\n",
- ENDPOINT_NUMBER(endp));
- return -1;
- }
-
- port = is_rtp ? endp->trans_bts.rtp_port : endp->trans_bts.rtcp_port;
+ port = is_rtp ? end->rtp_port : end->rtcp_port;
addr.sin_family = AF_INET;
addr.sin_addr = cfg->transcoder_in;
addr.sin_port = port;
rc = sendto(is_rtp ?
- endp->trans_bts.rtp.fd :
- endp->trans_bts.rtcp.fd, buf, len, 0,
+ end->rtp.fd :
+ end->rtcp.fd, buf, len, 0,
(struct sockaddr *) &addr, sizeof(addr));
if (rc != len)
@@ -304,7 +297,10 @@ static int rtp_data_net(struct bsc_fd *fd, unsigned int what)
endp->net_end.packets += 1;
forward_data(fd->fd, &endp->taps[MGCP_TAP_NET_IN], buf, rc);
- return send_to(endp, DEST_BTS, proto == PROTO_RTP, &addr, &buf[0], rc);
+ if (endp->is_transcoded)
+ return send_transcoder(&endp->trans_net, endp->cfg, proto == PROTO_RTP, &buf[0], rc);
+ else
+ return send_to(endp, DEST_BTS, proto == PROTO_RTP, &addr, &buf[0], rc);
}
static void discover_bts(struct mgcp_endpoint *endp, int proto, struct sockaddr_in *addr)
@@ -382,7 +378,7 @@ static int rtp_data_bts(struct bsc_fd *fd, unsigned int what)
forward_data(fd->fd, &endp->taps[MGCP_TAP_BTS_IN], buf, rc);
if (endp->is_transcoded)
- return send_transcoder(endp, proto == PROTO_RTP, &buf[0], rc);
+ return send_transcoder(&endp->trans_bts, endp->cfg, proto == PROTO_RTP, &buf[0], rc);
else
return send_to(endp, DEST_NETWORK, proto == PROTO_RTP, &addr, &buf[0], rc);
}
diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c
index 84fd155..f8f7067 100644
--- a/openbsc/src/mgcp/mgcp_protocol.c
+++ b/openbsc/src/mgcp/mgcp_protocol.c
@@ -942,8 +942,8 @@ static void create_transcoder(struct mgcp_endpoint *endp)
if (!endp->is_transcoded)
return;
- send_msg(endp, in_endp, endp->trans_bts.local_port, "CRCX", "recvonly");
- send_msg(endp, in_endp, endp->trans_bts.local_port, "MDCX", "recvonly");
+ send_msg(endp, in_endp, endp->trans_bts.local_port, "CRCX", "sendrecv");
+ send_msg(endp, in_endp, endp->trans_bts.local_port, "MDCX", "sendrecv");
send_msg(endp, out_endp, endp->trans_net.local_port, "CRCX", "sendrecv");
send_msg(endp, out_endp, endp->trans_net.local_port, "MDCX", "sendrecv");