diff options
author | Jonas Smedegaard <dr@jones.dk> | 2018-01-08 14:56:43 +0100 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2018-01-08 14:56:43 +0100 |
commit | b7869a262cbca2241c70549af9c877529706c15f (patch) | |
tree | fbe1cd90489cd71e55a027bc94226d3571b5fedf /src/config.c | |
parent | f8e8b8956370f0f2f161ee917c2a5562ad7a2476 (diff) | |
parent | 917bc4ee372da83381efb381f8f535ca64839173 (diff) |
New upstream version 0.5.7
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 105 |
1 files changed, 103 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c index eb83c67..ce748d3 100644 --- a/src/config.c +++ b/src/config.c @@ -56,6 +56,8 @@ static struct config core_config = { false, AUDIO_MODE_POLL, false, + AUFMT_S16LE, + AUFMT_S16LE, }, #ifdef USE_VIDEO @@ -95,6 +97,11 @@ static struct config core_config = { "" }, #endif + + /* SDP */ + { + false + }, }; @@ -134,11 +141,57 @@ static int dns_server_handler(const struct pl *pl, void *arg) } +static enum aufmt resolve_aufmt(const struct pl *fmt) +{ + if (0 == pl_strcasecmp(fmt, "s16")) return AUFMT_S16LE; + if (0 == pl_strcasecmp(fmt, "float")) return AUFMT_FLOAT; + if (0 == pl_strcasecmp(fmt, "s24_3le")) return AUFMT_S24_3LE; + + /* XXX remove this after librem is fixed */ + if (0 == pl_strcasecmp(fmt, "s16le")) return AUFMT_S16LE; + + return (enum aufmt)-1; +} + + +static int conf_get_aufmt(const struct conf *conf, const char *name, + int *fmtp) +{ + struct pl pl; + int fmt; + int err; + + err = conf_get(conf, name, &pl); + if (err) + return err; + + fmt = resolve_aufmt(&pl); + if (fmt == -1) { + warning("config: %s: sample format not supported" + " (%r)\n", name, &pl); + return EINVAL; + } + + *fmtp = fmt; + + return 0; +} + + +/** + * Parse the core configuration file and update baresip core config + * + * @param cfg Baresip core config to update + * @param conf Configuration file to parse + * + * @return 0 if success, otherwise errorcode + */ int config_parse_conf(struct config *cfg, const struct conf *conf) { struct pl pollm, as, ap; enum poll_method method; struct vidsz size = {0, 0}; + struct pl txmode; uint32_t v; int err = 0; @@ -202,8 +255,22 @@ int config_parse_conf(struct config *cfg, const struct conf *conf) 0 == conf_get(conf, "audio_player", &ap)) cfg->audio.src_first = as.p < ap.p; + if (0 == conf_get(conf, "audio_txmode", &txmode)) { + + if (0 == pl_strcasecmp(&txmode, "poll")) + cfg->audio.txmode = AUDIO_MODE_POLL; + else if (0 == pl_strcasecmp(&txmode, "thread")) + cfg->audio.txmode = AUDIO_MODE_THREAD; + else { + warning("unsupported audio txmode (%r)\n", &txmode); + } + } + (void)conf_get_bool(conf, "audio_level", &cfg->audio.level); + conf_get_aufmt(conf, "ausrc_format", &cfg->audio.src_fmt); + conf_get_aufmt(conf, "auplay_format", &cfg->audio.play_fmt); + #ifdef USE_VIDEO /* Video */ (void)conf_get_csv(conf, "video_source", @@ -254,10 +321,21 @@ int config_parse_conf(struct config *cfg, const struct conf *conf) sizeof(cfg->bfcp.proto)); #endif + /* SDP */ + (void)conf_get_bool(conf, "sdp_ebuacip", &cfg->sdp.ebuacip); + return err; } +/** + * Print the baresip core config + * + * @param pf Print function + * @param cfg Baresip core config + * + * @return 0 if success, otherwise errorcode + */ int config_print(struct re_printf *pf, const struct config *cfg) { int err; @@ -459,7 +537,10 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg) "#auplay_srate\t\t48000\n" "#ausrc_channels\t\t0\n" "#auplay_channels\t\t0\n" + "#audio_txmode\t\tpoll\t\t# poll, thread\n" "audio_level\t\tno\n" + "ausrc_format\t\ts16\t\t# s16, float, ..\n" + "auplay_format\t\ts16\t\t# s16, float, ..\n" , poll_method_name(poll_method_best()), cfg->call.local_timeout, @@ -468,7 +549,8 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg) default_audio_device(), default_audio_device(), cfg->audio.srate.min, cfg->audio.srate.max, - cfg->audio.channels.min, cfg->audio.channels.max); + cfg->audio.channels.min, cfg->audio.channels.max + ); #ifdef USE_VIDEO err |= re_hprintf(pf, @@ -478,7 +560,7 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg) "video_size\t\t%dx%d\n" "video_bitrate\t\t%u\n" "video_fps\t\t%u\n" - "video_fullscreen\t\tyes\n", + "video_fullscreen\tyes\n", default_video_device(), default_video_display(), cfg->video.width, cfg->video.height, @@ -572,6 +654,14 @@ static const char *detect_module_path(bool *valid) } +/** + * Write the baresip core config template to a file + * + * @param file Filename of output file + * @param cfg Baresip core config + * + * @return 0 if success, otherwise errorcode + */ int config_write_template(const char *file, const struct config *cfg) { FILE *f = NULL; @@ -762,6 +852,7 @@ int config_write_template(const char *file, const struct config *cfg) (void)re_fprintf(f, "#module_app\t\t" MOD_PRE "natbd"MOD_EXT"\n"); (void)re_fprintf(f, "#module_app\t\t" MOD_PRE "presence"MOD_EXT"\n"); (void)re_fprintf(f, "#module_app\t\t" MOD_PRE "syslog"MOD_EXT"\n"); + (void)re_fprintf(f, "#module_app\t\t" MOD_PRE "mqtt" MOD_EXT "\n"); #ifdef USE_VIDEO (void)re_fprintf(f, "module_app\t\t" MOD_PRE "vidloop"MOD_EXT"\n"); #endif @@ -807,6 +898,11 @@ int config_write_template(const char *file, const struct config *cfg) "ice_mode\t\tfull\t# {full,lite}\n"); (void)re_fprintf(f, + "\n# ZRTP\n" + "#zrtp_hash\t\tno # Disable SDP zrtp-hash " + "(not recommended)\n"); + + (void)re_fprintf(f, "\n# Menu\n" "#redial_attempts\t\t3 # Num or <inf>\n" "#redial_delay\t\t5 # Delay in seconds\n"); @@ -818,6 +914,11 @@ int config_write_template(const char *file, const struct config *cfg) } +/** + * Get the baresip core config + * + * @return Core config + */ struct config *conf_config(void) { return &core_config; |