summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2020-03-24 15:59:16 +0100
committerVadim Yanitskiy <axilirator@gmail.com>2020-05-05 12:02:31 +0700
commit785450c4bfdbcde4923b60bcb25b6367c74bb961 (patch)
tree9b4a4f71de36b0eb303e42b7fc87a3157582c34e /src/host/layer23/src
parent3425527fb78a645ba4285c2ac9f4fc66e4c57fa4 (diff)
mobile: add audio config, with unused audio loopback setting
The aim is to add configurable audio loopback to mobile. An existing patch on a branch from fixeria [1] adds the audio config section. Add a reduced version of this audio config to be compatible with the future merge. Add the audio loopback setting, so far without functionality. Subsequent patch adds the actual loopback. [1] osmocom-bb branch fixeria/audio, patch "mobile/vty_interface.c: add new 'audio' section" Change-id I62cd5ef22ca2290fcafe65c78537ddbcb39fb8c6 Change-Id: Ie03e4a6c6f81ea3925266dd22e87506d722a6e1a
Diffstat (limited to 'src/host/layer23/src')
-rw-r--r--src/host/layer23/src/mobile/settings.c8
-rw-r--r--src/host/layer23/src/mobile/vty_interface.c56
2 files changed, 64 insertions, 0 deletions
diff --git a/src/host/layer23/src/mobile/settings.c b/src/host/layer23/src/mobile/settings.c
index 388c7547..9742b1db 100644
--- a/src/host/layer23/src/mobile/settings.c
+++ b/src/host/layer23/src/mobile/settings.c
@@ -41,6 +41,9 @@ int gsm_settings_init(struct osmocom_ms *ms)
strcpy(set->layer2_socket_path, layer2_socket_path);
strcpy(set->sap_socket_path, sap_socket_path);
+ /* Audio settings: drop TCH frames by default */
+ set->audio.io_handler = AUDIO_IOH_NONE;
+
/* network search */
set->plmn_mode = PLMN_MODE_AUTO;
@@ -194,3 +197,8 @@ int gsm_random_imei(struct gsm_settings *set)
return 0;
}
+const struct value_string audio_io_handler_names[] = {
+ { AUDIO_IOH_NONE, "none" },
+ { AUDIO_IOH_LOOPBACK, "loopback" },
+ { 0x00, NULL}
+};
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c
index 70ee7035..073303ca 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -65,6 +65,12 @@ struct cmd_node support_node = {
1
};
+struct cmd_node audio_node = {
+ AUDIO_NODE,
+ "%s(audio)# ",
+ 1
+};
+
static void print_vty(void *priv, const char *fmt, ...)
{
char buffer[1000];
@@ -1526,6 +1532,10 @@ static void config_write_ms(struct vty *vty, struct osmocom_ms *ms)
vty_out(vty, " c7-any-timeout %d%s",
set->any_timeout, VTY_NEWLINE);
+ vty_out(vty, " audio%s", VTY_NEWLINE);
+ if (!hide_default || set->audio.io_handler != AUDIO_IOH_NONE)
+ vty_out(vty, " io-handler %s%s", audio_io_handler_name(set->audio.io_handler), VTY_NEWLINE);
+
/* no shutdown must be written to config, because shutdown is default */
vty_out(vty, " %sshutdown%s", (ms->shutdown != MS_SHUTDOWN_NONE) ? "" : "no ",
VTY_NEWLINE);
@@ -2727,6 +2737,46 @@ DEFUN(cfg_test_hplmn, cfg_test_hplmn_cmd, "hplmn-search (everywhere|foreign-coun
return CMD_SUCCESS;
}
+/* per audio config */
+DEFUN(cfg_ms_audio, cfg_ms_audio_cmd, "audio",
+ "Configure audio settings")
+{
+ vty->node = AUDIO_NODE;
+ return CMD_SUCCESS;
+}
+
+static int set_audio_io_handler(struct vty *vty, enum audio_io_handler val)
+{
+ struct osmocom_ms *ms = (struct osmocom_ms *) vty->index;
+ struct gsm_settings *set = &ms->settings;
+
+ /* Don't restart on unchanged value */
+ if (val == set->audio.io_handler)
+ return CMD_SUCCESS;
+ set->audio.io_handler = val;
+
+ /* Restart required */
+ vty_restart_if_started(vty, ms);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_ms_audio_io_handler, cfg_ms_audio_io_handler_cmd,
+ "io-handler (loopback|none)",
+ "Set TCH frame I/O handler\n"
+ "Return TCH frame payload back to sender\n"
+ "No handler, drop TCH frames (default)")
+{
+ int val = get_string_value(audio_io_handler_names, argv[0]);
+ return set_audio_io_handler(vty, val);
+}
+
+DEFUN(cfg_ms_audio_no_io_handler, cfg_ms_audio_no_io_handler_cmd,
+ "no io-handler", NO_STR "Disable TCH frame processing")
+{
+ return set_audio_io_handler(vty, AUDIO_IOH_NONE);
+}
+
DEFUN(cfg_no_shutdown, cfg_ms_no_shutdown_cmd, "no shutdown",
NO_STR "Activate and run MS")
{
@@ -2807,6 +2857,7 @@ int ms_vty_go_parent(struct vty *vty)
break;
case TESTSIM_NODE:
case SUPPORT_NODE:
+ case AUDIO_NODE:
vty->node = MS_NODE;
break;
default:
@@ -2918,6 +2969,7 @@ int ms_vty_init(void)
install_element(MS_NODE, &cfg_ms_abbrev_cmd);
install_element(MS_NODE, &cfg_ms_no_abbrev_cmd);
install_element(MS_NODE, &cfg_ms_testsim_cmd);
+ install_element(MS_NODE, &cfg_ms_audio_cmd);
install_element(MS_NODE, &cfg_ms_neighbour_cmd);
install_element(MS_NODE, &cfg_ms_no_neighbour_cmd);
install_element(MS_NODE, &cfg_ms_any_timeout_cmd);
@@ -2995,6 +3047,10 @@ int ms_vty_init(void)
install_element(MS_NODE, &cfg_ms_script_load_run_cmd);
install_element(MS_NODE, &cfg_ms_no_script_load_run_cmd);
+ install_node(&audio_node, config_write_dummy);
+ install_element(AUDIO_NODE, &cfg_ms_audio_io_handler_cmd);
+ install_element(AUDIO_NODE, &cfg_ms_audio_no_io_handler_cmd);
+
/* Register the talloc context introspection command */
osmo_talloc_vty_add_cmds();