From 36ed8cc4c33e3b69bb0f84f1b5b593ae46aff08f Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 26 Feb 2010 13:42:58 +0100 Subject: [mgcp] Patch the rtp payload depending on the direction. The RTP header code is taken from the rtp_proxy, we will need to figure out how to unite these properly in the long run. --- openbsc/src/mgcp/mgcp_network.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'openbsc/src') diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c index e92b0742e..c61f0a858 100644 --- a/openbsc/src/mgcp/mgcp_network.c +++ b/openbsc/src/mgcp/mgcp_network.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -37,6 +38,28 @@ #warning "Make use of the rtp proxy code" +/* according to rtp_proxy.c RFC 3550 */ +struct rtp_hdr { +#if __BYTE_ORDER == __LITTLE_ENDIAN + u_int8_t csrc_count:4, + extension:1, + padding:1, + version:2; + u_int8_t payload_type:7, + marker:1; +#elif __BYTE_ORDER == __BIG_ENDIAN + u_int8_t version:2, + padding:1, + extension:1, + csrc_count:4; + u_int8_t marker:1, + payload_type:7; +#endif + u_int16_t sequence; + u_int32_t timestamp; + u_int32_t ssrc; +} __attribute__((packed)); + enum { DEST_NETWORK = 0, @@ -59,6 +82,17 @@ static int udp_send(int fd, struct in_addr *addr, int port, char *buf, int len) return sendto(fd, buf, len, 0, (struct sockaddr *)&out, sizeof(out)); } +static void patch_payload(int payload, char *data, int len) +{ + struct rtp_hdr *rtp_hdr; + + if (len < sizeof(*rtp_hdr)) + return; + + rtp_hdr = (struct rtp_hdr *) data; + rtp_hdr->payload_type = payload; +} + /* * There is data coming. We will have to figure out if it * came from the BTS or the MediaGateway of the MSC. On top @@ -129,10 +163,12 @@ static int rtp_data_cb(struct bsc_fd *fd, unsigned int what) dest = !dest; if (dest == DEST_NETWORK) { + patch_payload(endp->net_payload_type, buf, rc); return udp_send(fd->fd, &endp->remote, proto == PROTO_RTP ? endp->net_rtp : endp->net_rtcp, buf, rc); } else { + patch_payload(endp->bts_payload_type, buf, rc); return udp_send(fd->fd, &endp->bts, proto == PROTO_RTP ? endp->bts_rtp : endp->bts_rtcp, buf, rc); -- cgit v1.2.3