aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp/mgcp_network.c
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-04-14 10:31:47 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2014-06-05 14:08:45 +0200
commit42a833e89f443116fb165c35654c9f21ceed6876 (patch)
tree12c99fe7ba58aa888147366a46f04feddf61d903 /openbsc/src/libmgcp/mgcp_network.c
parent136a319e910eec81ea9ff8f8a34c324557109d03 (diff)
mgcp: Add packet size (ptime) conversion
The current transcoder implemenation always does a 1:1 recoding concerning the duration of a packet. So RTP timestamps and sequence numbers are not modified. This is not sufficient in some cases, e.g. when the BTS does only allow for a single fixed ptime. This patch decouples encoding from decoding and moves the decoded samples to the state structure so that samples can be combined or drain according to the packaging of incoming and outgoing packets. This patch incorporates parts of Holger's experimental fixes in 0e669e05^..9eba68f9. Ticket: OW#1111 Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/src/libmgcp/mgcp_network.c')
-rw-r--r--openbsc/src/libmgcp/mgcp_network.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c
index 05c3e7749..219d3f990 100644
--- a/openbsc/src/libmgcp/mgcp_network.c
+++ b/openbsc/src/libmgcp/mgcp_network.c
@@ -340,7 +340,7 @@ static int align_rtp_timestamp_offset(struct mgcp_endpoint *endp,
return timestamp_error;
}
-int mgcp_rtp_processing_default(struct mgcp_rtp_end *dst_end,
+int mgcp_rtp_processing_default(struct mgcp_endpoint *endp, struct mgcp_rtp_end *dst_end,
char *data, int *len, int buf_size)
{
return 0;
@@ -614,12 +614,28 @@ int mgcp_send(struct mgcp_endpoint *endp, int dest, int is_rtp,
if (!rtp_end->output_enabled)
rtp_end->dropped_packets += 1;
else if (is_rtp) {
- mgcp_patch_and_count(endp, rtp_state, rtp_end, addr, buf, rc);
- endp->cfg->rtp_processing_cb(rtp_end, buf, &rc, RTP_BUF_SIZE);
- forward_data(rtp_end->rtp.fd, &endp->taps[tap_idx], buf, rc);
- return mgcp_udp_send(rtp_end->rtp.fd,
- &rtp_end->addr,
- rtp_end->rtp_port, buf, rc);
+ int cont;
+ int nbytes = 0;
+ int len = rc;
+ mgcp_patch_and_count(endp, rtp_state, rtp_end, addr, buf, len);
+ do {
+ cont = endp->cfg->rtp_processing_cb(endp, rtp_end,
+ buf, &len, RTP_BUF_SIZE);
+ if (cont < 0)
+ break;
+
+ forward_data(rtp_end->rtp.fd, &endp->taps[tap_idx],
+ buf, len);
+ rc = mgcp_udp_send(rtp_end->rtp.fd,
+ &rtp_end->addr,
+ rtp_end->rtp_port, buf, len);
+
+ if (rc <= 0)
+ return rc;
+ nbytes += rc;
+ len = cont;
+ } while (len > 0);
+ return nbytes;
} else if (!tcfg->omit_rtcp) {
return mgcp_udp_send(rtp_end->rtcp.fd,
&rtp_end->addr,