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
This commit is contained in:
parent
845d0054b4
commit
168ca00b02
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue