From 168ca00b02685edea650aa2a4c62481a75926125 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 17 Mar 2014 12:40:07 +0100 Subject: [PATCH] mgcp: Add a function to get media info for MGCP responses This patch adds the get_net_downlink_format_cb() callback to provide payload_type, subtype_name, and fmtp_extra suitable for use in a MGCP response sent to the network. Per default, the BTS side values are returned since these must be honoured by the net peer when sending audio to the media gateway (unless transcoding is done). Sponsored-by: On-Waves ehf --- openbsc/include/openbsc/mgcp.h | 8 ++++++++ openbsc/include/openbsc/mgcp_internal.h | 5 +++++ openbsc/src/libmgcp/mgcp_network.c | 13 +++++++++++++ openbsc/src/libmgcp/mgcp_protocol.c | 19 ++++++++++++++----- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h index 34eb42955..002dd7c6e 100644 --- a/openbsc/include/openbsc/mgcp.h +++ b/openbsc/include/openbsc/mgcp.h @@ -92,6 +92,12 @@ typedef int (*mgcp_processing)(struct mgcp_rtp_end *dst_end, typedef int (*mgcp_processing_setup)(struct mgcp_endpoint *endp, struct mgcp_rtp_end *dst_end, struct mgcp_rtp_end *src_end); + +typedef void (*mgcp_get_format)(struct mgcp_endpoint *endp, + int *payload_type, + const char**subtype_name, + const char**fmtp_extra); + #define PORT_ALLOC_STATIC 0 #define PORT_ALLOC_DYNAMIC 1 @@ -166,6 +172,8 @@ struct mgcp_config { mgcp_processing rtp_processing_cb; mgcp_processing_setup setup_rtp_processing_cb; + mgcp_get_format get_net_downlink_format_cb; + struct osmo_wqueue gw_fd; struct mgcp_port_range bts_ports; diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h index dbdc1d9d9..ac136a377 100644 --- a/openbsc/include/openbsc/mgcp_internal.h +++ b/openbsc/include/openbsc/mgcp_internal.h @@ -217,6 +217,11 @@ int mgcp_setup_rtp_processing_default(struct mgcp_endpoint *endp, struct mgcp_rtp_end *dst_end, struct mgcp_rtp_end *src_end); +void mgcp_get_net_downlink_format_default(struct mgcp_endpoint *endp, + int *payload_type, + const char**subtype_name, + const char**fmtp_extra); + enum { MGCP_DEST_NET = 0, MGCP_DEST_BTS, diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index 393a9e52a..05c3e7749 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -353,6 +353,19 @@ int mgcp_setup_rtp_processing_default(struct mgcp_endpoint *endp, return 0; } +void mgcp_get_net_downlink_format_default(struct mgcp_endpoint *endp, + int *payload_type, + const char**audio_name, + const char**fmtp_extra) +{ + /* Use the BTS side parameters when passing the SDP data (for + * downlink) to the net peer. + */ + *payload_type = endp->bts_end.payload_type; + *audio_name = endp->bts_end.audio_name; + *fmtp_extra = endp->bts_end.fmtp_extra; +} + /** * The RFC 3550 Appendix A assumes there are multiple sources but * some of the supported endpoints (e.g. the nanoBTS) can only handle diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index 862bf175d..7837378f3 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -245,12 +245,15 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp, const char *msg, const char *trans_id) { const char *addr = endp->cfg->local_ip; - const char *fmtp_extra = endp->bts_end.fmtp_extra; - const char *audio_name = endp->bts_end.audio_name; - int payload_type = endp->bts_end.payload_type; + const char *fmtp_extra; + const char *audio_name; + int payload_type; char sdp_record[4096]; int len; + endp->cfg->get_net_downlink_format_cb(endp, &payload_type, + &audio_name, &fmtp_extra); + if (!addr) addr = endp->cfg->source_addr; @@ -1268,6 +1271,8 @@ struct mgcp_config *mgcp_config_alloc(void) cfg->rtp_processing_cb = &mgcp_rtp_processing_default; cfg->setup_rtp_processing_cb = &mgcp_setup_rtp_processing_default; + cfg->get_net_downlink_format_cb = &mgcp_get_net_downlink_format_default; + /* default trunk handling */ cfg->trunk.cfg = cfg; cfg->trunk.trunk_nr = 0; @@ -1424,8 +1429,12 @@ static void send_msg(struct mgcp_endpoint *endp, int endpoint, int port, { char buf[2096]; int len; - const char *audio_name = endp->bts_end.audio_name; - int payload_type = endp->bts_end.payload_type; + const char *fmtp_extra; + const char *audio_name; + int payload_type; + + endp->cfg->get_net_downlink_format_cb(endp, &payload_type, + &audio_name, &fmtp_extra); /* hardcoded to AMR right now, we do not know the real type at this point */ len = snprintf(buf, sizeof(buf),