aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-09-03 00:07:39 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-12-16 13:18:08 +0100
commit5ea1bc77a3947f541d576f95e7ecc7249fc65b9b (patch)
treeb8a507d08730963050c8af3a884dffdce04d97a8
parent7e7ee5f8c6904a607e7505021c16de4c26dadbe0 (diff)
mgcp: Allow to freely control the a=fmtp line for experiments
In case of AMR one can specify the available codecs out-of-band. Allow to configure this line statically in the configuration file.
-rw-r--r--openbsc/include/openbsc/mgcp.h1
-rw-r--r--openbsc/include/openbsc/mgcp_internal.h2
-rw-r--r--openbsc/src/libmgcp/mgcp_protocol.c11
-rw-r--r--openbsc/src/libmgcp/mgcp_vty.c36
4 files changed, 48 insertions, 2 deletions
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index 858a29dd9..7a416ddd1 100644
--- a/openbsc/include/openbsc/mgcp.h
+++ b/openbsc/include/openbsc/mgcp.h
@@ -111,6 +111,7 @@ struct mgcp_trunk_config {
int trunk_nr;
int trunk_type;
+ char *audio_fmtp_extra;
char *audio_name;
int audio_payload;
int audio_loop;
diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h
index bcef8724e..455bb53df 100644
--- a/openbsc/include/openbsc/mgcp_internal.h
+++ b/openbsc/include/openbsc/mgcp_internal.h
@@ -67,7 +67,9 @@ struct mgcp_rtp_end {
/* in network byte order */
int rtp_port, rtcp_port;
+ /* per endpoint data */
int payload_type;
+ char *fmtp_extra;
/*
* Each end has a socket...
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c
index 63fee5ff7..6919a591d 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -190,6 +190,7 @@ 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;
char sdp_record[4096];
if (!addr)
@@ -202,10 +203,12 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
"c=IN IP4 %s\r\n"
"t=0 0\r\n"
"m=audio %d RTP/AVP %d\r\n"
- "a=rtpmap:%d %s\r\n",
+ "a=rtpmap:%d %s\r\n"
+ "%s%s",
endp->ci, endp->ci, addr, addr,
endp->net_end.local_port, endp->bts_end.payload_type,
- endp->bts_end.payload_type, endp->tcfg->audio_name);
+ endp->bts_end.payload_type, endp->tcfg->audio_name,
+ fmtp_extra ? fmtp_extra : "", fmtp_extra ? "\r\n" : "");
return create_resp(endp, 200, " OK", msg, trans_id, NULL, sdp_record);
}
@@ -587,6 +590,8 @@ static struct msgb *handle_create_con(struct mgcp_parse_data *p)
endp->allocated = 1;
endp->bts_end.payload_type = tcfg->audio_payload;
+ endp->bts_end.fmtp_extra = talloc_strdup(tcfg->endpoints,
+ tcfg->audio_fmtp_extra);
/* policy CB */
if (p->cfg->policy_cb) {
@@ -958,6 +963,8 @@ static void mgcp_rtp_end_reset(struct mgcp_rtp_end *end)
end->rtp_port = end->rtcp_port = 0;
end->payload_type = -1;
end->local_alloc = -1;
+ talloc_free(end->fmtp_extra);
+ end->fmtp_extra = NULL;
}
static void mgcp_rtp_end_init(struct mgcp_rtp_end *end)
diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c
index 122fa8437..88d793f1a 100644
--- a/openbsc/src/libmgcp/mgcp_vty.c
+++ b/openbsc/src/libmgcp/mgcp_vty.c
@@ -94,6 +94,9 @@ static int config_write_mgcp(struct vty *vty)
if (g_cfg->trunk.audio_name)
vty_out(vty, " sdp audio-payload name %s%s",
g_cfg->trunk.audio_name, VTY_NEWLINE);
+ if (g_cfg->trunk.audio_fmtp_extra)
+ vty_out(vty, " sdp audio fmtp-extra %s%s",
+ g_cfg->trunk.audio_fmtp_extra, VTY_NEWLINE);
vty_out(vty, " loop %u%s", !!g_cfg->trunk.audio_loop, VTY_NEWLINE);
vty_out(vty, " number endpoints %u%s", g_cfg->trunk.number_endpoints - 1, VTY_NEWLINE);
if (g_cfg->call_agent_addr)
@@ -321,6 +324,19 @@ ALIAS_DEPRECATED(cfg_mgcp_rtp_ip_dscp, cfg_mgcp_rtp_ip_tos_cmd,
RTP_STR
"Apply IP_TOS to the audio stream\n" "The DSCP value\n")
+DEFUN(cfg_mgcp_sdp_fmtp_extra,
+ cfg_mgcp_sdp_fmtp_extra_cmd,
+ "sdp audio fmtp-extra .NAME",
+ "Add extra fmtp for the SDP file\n")
+{
+ char *txt = argv_concat(argv, argc, 0);
+ if (!txt)
+ return CMD_WARNING;
+
+ bsc_replace_string(g_cfg, &g_cfg->trunk.audio_fmtp_extra, txt);
+ talloc_free(txt);
+ return CMD_SUCCESS;
+}
#define SDP_STR "SDP File related options\n"
#define AUDIO_STR "Audio payload options\n"
@@ -481,11 +497,29 @@ static int config_write_trunk(struct vty *vty)
vty_out(vty, " rtcp-omit%s", VTY_NEWLINE);
else
vty_out(vty, " no rtcp-omit%s", VTY_NEWLINE);
+ if (trunk->audio_fmtp_extra)
+ vty_out(vty, " sdp audio fmtp-extra %s%s",
+ trunk->audio_fmtp_extra, VTY_NEWLINE);
}
return CMD_SUCCESS;
}
+DEFUN(cfg_trunk_sdp_fmtp_extra,
+ cfg_trunk_sdp_fmtp_extra_cmd,
+ "sdp audio fmtp-extra .NAME",
+ "Add extra fmtp for the SDP file\n")
+{
+ struct mgcp_trunk_config *trunk = vty->index;
+ char *txt = argv_concat(argv, argc, 0);
+ if (!txt)
+ return CMD_WARNING;
+
+ bsc_replace_string(g_cfg, &trunk->audio_fmtp_extra, txt);
+ talloc_free(txt);
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_trunk_payload_number,
cfg_trunk_payload_number_cmd,
"sdp audio-payload number <1-255>",
@@ -780,6 +814,7 @@ int mgcp_vty_init(void)
install_element(MGCP_NODE, &cfg_mgcp_number_endp_cmd);
install_element(MGCP_NODE, &cfg_mgcp_omit_rtcp_cmd);
install_element(MGCP_NODE, &cfg_mgcp_no_omit_rtcp_cmd);
+ install_element(MGCP_NODE, &cfg_mgcp_sdp_fmtp_extra_cmd);
install_element(MGCP_NODE, &cfg_mgcp_trunk_cmd);
install_node(&trunk_node, config_write_trunk);
@@ -793,6 +828,7 @@ int mgcp_vty_init(void)
install_element(TRUNK_NODE, &cfg_trunk_loop_cmd);
install_element(TRUNK_NODE, &cfg_trunk_omit_rtcp_cmd);
install_element(TRUNK_NODE, &cfg_trunk_no_omit_rtcp_cmd);
+ install_element(TRUNK_NODE, &cfg_trunk_sdp_fmtp_extra_cmd);
return 0;
}