This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
osmith gerrit-no-reply at lists.osmocom.orgosmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/mncc-python/+/17979 ) Change subject: rtpsource: CTRL call rtp_create: add codec arg ...................................................................... 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 --- M mncc_mt_loadgen.py M rtpsource/ctrl_if.c M rtpsource/internal.h M rtpsource/rtpsource.c 4 files changed, 39 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/mncc-python refs/changes/79/17979/1 diff --git a/mncc_mt_loadgen.py b/mncc_mt_loadgen.py index 021d619..fcae13f 100755 --- a/mncc_mt_loadgen.py +++ b/mncc_mt_loadgen.py @@ -80,7 +80,8 @@ def on_receive(self, message): if message['type'] == 'rtp_create': - (res, var, val) = self._set_var('rtp_create', message['cname']) + val = '%s,%u' % (message['cname'], message['codec']) + (res, var, val) = self._set_var('rtp_create', val) v = val.split(',') # input looks like '1,127.23.23.23,37723' return {'cname': v[0], 'remote_host': v[1], 'remote_port': int(v[2])} elif message['type'] == 'rtp_connect': @@ -113,7 +114,8 @@ self.msisdn_called = msisdn_called self.msisdn_calling = msisdn_calling # allocate a RTP connection @ rtpsource - r = self.ctrl_act.ask({'type':'rtp_create', 'cname':self.callref}) + codec = 2 # FR, FIXME: make configurable + r = self.ctrl_act.ask({'type':'rtp_create', 'cname':self.callref, 'codec':codec}) self.ext_rtp_host = r['remote_host'] self.ext_rtp_port = r['remote_port'] # start the MNCC call FSM diff --git a/rtpsource/ctrl_if.c b/rtpsource/ctrl_if.c index 708fb02..520ff4a 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; } - conn = create_connection(g_rss, cname); + codec = atoi(codec_str); + if (codec < 0 || codec >= _NUM_CODECS) { + cmd->reply = "Invalid codec"; + goto error; + } + + 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"); diff --git a/rtpsource/internal.h b/rtpsource/internal.h index a4501a2..35f12d0 100644 --- a/rtpsource/internal.h +++ b/rtpsource/internal.h @@ -4,6 +4,8 @@ #include <osmocom/trau/osmo_ortp.h> #include <osmocom/ctrl/control_if.h> +enum codec_type; + enum { DMAIN, }; @@ -36,7 +38,7 @@ struct rtp_connection *find_connection_by_cname(struct rtpsource_state *rss, const char *cname); -struct rtp_connection *create_connection(struct rtpsource_state *rss, const char *cname); +struct rtp_connection *create_connection(struct rtpsource_state *rss, const char *cname, enum codec_type codec); int connect_connection(struct rtp_connection *conn, const char *remote_host, uint16_t remote_port, uint8_t pt); diff --git a/rtpsource/rtpsource.c b/rtpsource/rtpsource.c index 3087262..4af8899 100644 --- a/rtpsource/rtpsource.c +++ b/rtpsource/rtpsource.c @@ -63,11 +63,10 @@ } /* create a new RTP connection for given CNAME; includes binding of local RTP port */ -struct rtp_connection *create_connection(struct rtpsource_state *rss, const char *cname) +struct rtp_connection *create_connection(struct rtpsource_state *rss, const char *cname, enum codec_type codec) { const struct rtp_provider *rtp_prov; struct rtp_connection *conn; - enum codec_type codec = CODEC_GSM_FR; // TODO: configurable const char *host; int port; int rc; @@ -101,8 +100,8 @@ llist_add_tail(&conn->list, &rss->connections); - CLOGP(conn, DMAIN, LOGL_INFO, "Created RTP connection; local=%s:%u\n", - conn->local_host, conn->local_port); + CLOGP(conn, DMAIN, LOGL_INFO, "Created RTP connection; local=%s:%u; codec=%u\n", + conn->local_host, conn->local_port, codec); return conn; -- To view, visit https://gerrit.osmocom.org/c/mncc-python/+/17979 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: mncc-python Gerrit-Branch: master Gerrit-Change-Id: If75e902b451d7e202a03e93afcd55bd24f517813 Gerrit-Change-Number: 17979 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200429/d57c10b3/attachment.htm>