diff options
author | Oliver Smith <osmith@sysmocom.de> | 2020-04-27 16:58:02 +0200 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2020-04-30 10:05:39 +0200 |
commit | 2d24cd48c98ab20c39196eebb722db7c820341e6 (patch) | |
tree | c0cf7694728d003841fa273094a81246efb97835 /rtpsource/ctrl_if.c | |
parent | fb046ebc9ef7ed90d3674d1bc4ce9559aa596316 (diff) |
rtpsource: CTRL call rtp_create: add codec arg
Instead of hardcoding FR in rtpsource, add an argument to set the codec
from mncc_mt_loadgen.py via CTRL call rtp_create. Hardcode FR in
mncc_mt_loadgen.py for now, a follow up patch will make it configurable
there, too.
Related: SYS#4924
Change-Id: If75e902b451d7e202a03e93afcd55bd24f517813
Diffstat (limited to 'rtpsource/ctrl_if.c')
-rw-r--r-- | rtpsource/ctrl_if.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/rtpsource/ctrl_if.c b/rtpsource/ctrl_if.c index 708fb02..b021e26 100644 --- a/rtpsource/ctrl_if.c +++ b/rtpsource/ctrl_if.c @@ -21,27 +21,52 @@ #include <osmocom/ctrl/control_cmd.h> #include "internal.h" +#include "rtp_provider.h" CTRL_CMD_DEFINE_WO_NOVRF(rtp_create, "rtp_create"); static int set_rtp_create(struct ctrl_cmd *cmd, void *data) { struct rtp_connection *conn; - const char *cname = cmd->value; + const char *cname, *codec_str; + char *tmp, *saveptr; + enum codec_type codec; + + tmp = talloc_strdup(cmd, cmd->value); + OSMO_ASSERT(tmp); + + cname = strtok_r(tmp, ",", &saveptr); + codec_str = strtok_r(NULL, ",", &saveptr); + + if (!cname || !codec_str) { + cmd->reply = "Format is cname,codec"; + goto error; + } if (find_connection_by_cname(g_rss, cname)) { cmd->reply = "Connection already exists for cname"; - return CTRL_CMD_ERROR; + goto error; + } + + codec = get_string_value(codec_type_names, codec_str); + if (codec < 0) { + cmd->reply = "Invalid codec name (try GSM_FR, GSM_EFR etc.)"; + goto error; } - conn = create_connection(g_rss, cname); + conn = create_connection(g_rss, cname, codec); if (!conn) { cmd->reply = "Error creating RTP connection"; - return CTRL_CMD_ERROR; + goto error; } /* Respond */ cmd->reply = talloc_asprintf(cmd, "%s,%s,%d", conn->cname, conn->local_host, conn->local_port); + talloc_free(tmp); return CTRL_CMD_REPLY; + +error: + talloc_free(tmp); + return CTRL_CMD_ERROR; } CTRL_CMD_DEFINE_WO_NOVRF(rtp_connect, "rtp_connect"); |