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: If75e902b451d7e202a03e93afcd55bd24f517813changes/79/17979/3
parent
fb046ebc9e
commit
2d24cd48c9
|
@ -80,7 +80,8 @@ class RtpSourceCtrlActor(pykka.ThreadingActor):
|
|||
|
||||
def on_receive(self, message):
|
||||
if message['type'] == 'rtp_create':
|
||||
(res, var, val) = self._set_var('rtp_create', message['cname'])
|
||||
val = '%s,%s' % (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 @@ class MTCallRtpsource(pykka.ThreadingActor):
|
|||
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 = "GSM_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
|
||||
|
|
|
@ -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 = 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, 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");
|
||||
|
|
|
@ -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 @@ extern struct rtpsource_state *g_rss;
|
|||
|
||||
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);
|
||||
|
|
|
@ -9,6 +9,24 @@
|
|||
static LLIST_HEAD(g_providers);
|
||||
static LLIST_HEAD(g_prov_instances);
|
||||
|
||||
const struct value_string codec_type_names[] = {
|
||||
{ CODEC_ULAW, "ULAW" },
|
||||
{ CODEC_ALAW, "ALAW" },
|
||||
{ CODEC_GSM_FR, "GSM_FR" },
|
||||
{ CODEC_GSM_EFR, "GSM_EFR" },
|
||||
{ CODEC_GSM_HR, "GSM_HR" },
|
||||
{ CODEC_AMR_4_75, "AMR_4_75" },
|
||||
{ CODEC_AMR_5_15, "AMR_5_15" },
|
||||
{ CODEC_AMR_5_90, "AMR_5_90" },
|
||||
{ CODEC_AMR_6_70, "AMR_6_70" },
|
||||
{ CODEC_AMR_7_40, "AMR_7_40" },
|
||||
{ CODEC_AMR_7_95, "AMR_7_95" },
|
||||
{ CODEC_AMR_10_2, "AMR_10_2" },
|
||||
{ CODEC_AMR_12_2, "AMR_12_2" },
|
||||
{ CODEC_AMR_SID, "AMR_SID" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
void rtp_provider_register(struct rtp_provider *prov)
|
||||
{
|
||||
llist_add_tail(&prov->list, &g_providers);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <osmocom/core/linuxlist.h>
|
||||
#include <osmocom/core/utils.h>
|
||||
|
||||
enum codec_type {
|
||||
CODEC_ULAW,
|
||||
|
@ -20,6 +21,8 @@ enum codec_type {
|
|||
_NUM_CODECS
|
||||
};
|
||||
|
||||
extern const struct value_string codec_type_names[];
|
||||
|
||||
struct rtp_provider_instance;
|
||||
|
||||
struct rtp_provider {
|
||||
|
|
|
@ -63,11 +63,10 @@ struct rtp_connection *find_connection_by_cname(struct rtpsource_state *rss, con
|
|||
}
|
||||
|
||||
/* 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 @@ struct rtp_connection *create_connection(struct rtpsource_state *rss, const char
|
|||
|
||||
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=%s\n",
|
||||
conn->local_host, conn->local_port, get_value_string(codec_type_names, codec));
|
||||
|
||||
|
||||
return conn;
|
||||
|
|
Loading…
Reference in New Issue