summaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c78
1 files changed, 68 insertions, 10 deletions
diff --git a/src/config.c b/src/config.c
index ce748d3..6c336d9 100644
--- a/src/config.c
+++ b/src/config.c
@@ -43,7 +43,7 @@ static struct config core_config = {
/** Audio */
{
- PREFIX "/share/baresip",
+ SHARE_PATH,
"","",
"","",
"","",
@@ -58,6 +58,8 @@ static struct config core_config = {
false,
AUFMT_S16LE,
AUFMT_S16LE,
+ AUFMT_S16LE,
+ AUFMT_S16LE,
},
#ifdef USE_VIDEO
@@ -69,6 +71,7 @@ static struct config core_config = {
500000,
25,
true,
+ VID_FMT_YUV420P,
},
#endif
@@ -178,6 +181,36 @@ static int conf_get_aufmt(const struct conf *conf, const char *name,
}
+#ifdef USE_VIDEO
+static int conf_get_vidfmt(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;
+
+ for (fmt=0; fmt<VID_FMT_N; fmt++) {
+
+ const char *str = vidfmt_name(fmt);
+
+ if (0 == pl_strcasecmp(&pl, str)) {
+
+ *fmtp = fmt;
+ return 0;
+ }
+ }
+
+ warning("config: %s: pixel format not supported (%r)\n", name, &pl);
+
+ return ENOENT;
+}
+#endif
+
+
/**
* Parse the core configuration file and update baresip core config
*
@@ -270,6 +303,8 @@ int config_parse_conf(struct config *cfg, const struct conf *conf)
conf_get_aufmt(conf, "ausrc_format", &cfg->audio.src_fmt);
conf_get_aufmt(conf, "auplay_format", &cfg->audio.play_fmt);
+ conf_get_aufmt(conf, "auenc_format", &cfg->audio.enc_fmt);
+ conf_get_aufmt(conf, "audec_format", &cfg->audio.dec_fmt);
#ifdef USE_VIDEO
/* Video */
@@ -284,8 +319,10 @@ int config_parse_conf(struct config *cfg, const struct conf *conf)
cfg->video.height = size.h;
}
(void)conf_get_u32(conf, "video_bitrate", &cfg->video.bitrate);
- (void)conf_get_u32(conf, "video_fps", &cfg->video.fps);
+ (void)conf_get_float(conf, "video_fps", &cfg->video.fps);
(void)conf_get_bool(conf, "video_fullscreen", &cfg->video.fullscreen);
+
+ conf_get_vidfmt(conf, "videnc_format", &cfg->video.enc_fmt);
#else
(void)size;
#endif
@@ -352,7 +389,7 @@ int config_print(struct re_printf *pf, const struct config *cfg)
"\n"
"# Call\n"
"call_local_timeout\t%u\n"
- "call_max_calls\t%u\n"
+ "call_max_calls\t\t%u\n"
"\n"
"# Audio\n"
"audio_path\t\t%s\n"
@@ -373,7 +410,9 @@ int config_print(struct re_printf *pf, const struct config *cfg)
"video_display\t\t%s,%s\n"
"video_size\t\t\"%ux%u\"\n"
"video_bitrate\t\t%u\n"
- "video_fps\t\t%u\n"
+ "video_fps\t\t%.2f\n"
+ "video_fullscreen\t%s\n"
+ "videnc_format\t\t%s\n"
"\n"
#endif
"# AVT\n"
@@ -416,6 +455,8 @@ int config_print(struct re_printf *pf, const struct config *cfg)
cfg->video.disp_mod, cfg->video.disp_dev,
cfg->video.width, cfg->video.height,
cfg->video.bitrate, cfg->video.fps,
+ cfg->video.fullscreen ? "yes" : "no",
+ vidfmt_name(cfg->video.enc_fmt),
#endif
cfg->avt.rtp_tos,
@@ -467,6 +508,8 @@ static const char *default_video_device(void)
return "avcapture,nil";
#endif
+#elif defined (WIN32)
+ return "dshow,nil";
#else
return "v4l2,/dev/video0";
#endif
@@ -477,6 +520,8 @@ static const char *default_video_display(void)
{
#ifdef DARWIN
return "opengl,nil";
+#elif defined (WIN32)
+ return "sdl2,nil";
#else
return "x11,nil";
#endif
@@ -520,10 +565,12 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg)
"\n"
"# Call\n"
"call_local_timeout\t%u\n"
- "call_max_calls\t%u\n"
+ "call_max_calls\t\t%u\n"
"\n"
"# Audio\n"
-#if defined (PREFIX)
+#if defined (SHARE_PATH)
+ "#audio_path\t\t" SHARE_PATH "\n"
+#elif defined (PREFIX)
"#audio_path\t\t" PREFIX "/share/baresip\n"
#else
"#audio_path\t\t/usr/share/baresip\n"
@@ -541,6 +588,8 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg)
"audio_level\t\tno\n"
"ausrc_format\t\ts16\t\t# s16, float, ..\n"
"auplay_format\t\ts16\t\t# s16, float, ..\n"
+ "auenc_format\t\ts16\t\t# s16, float, ..\n"
+ "audec_format\t\ts16\t\t# s16, float, ..\n"
,
poll_method_name(poll_method_best()),
cfg->call.local_timeout,
@@ -559,12 +608,15 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg)
"#video_display\t\t%s\n"
"video_size\t\t%dx%d\n"
"video_bitrate\t\t%u\n"
- "video_fps\t\t%u\n"
- "video_fullscreen\tyes\n",
+ "video_fps\t\t%.2f\n"
+ "video_fullscreen\tyes\n"
+ "videnc_format\t\t%s\n"
+ ,
default_video_device(),
default_video_display(),
cfg->video.width, cfg->video.height,
- cfg->video.bitrate, cfg->video.fps);
+ cfg->video.bitrate, cfg->video.fps,
+ vidfmt_name(cfg->video.enc_fmt));
#endif
err |= re_hprintf(pf,
@@ -624,7 +676,9 @@ static uint32_t count_modules(const char *path)
static const char *detect_module_path(bool *valid)
{
static const char * const pathv[] = {
-#if defined (PREFIX)
+#if defined (MOD_PATH)
+ MOD_PATH,
+#elif defined (PREFIX)
"" PREFIX "/lib/baresip/modules",
#else
"/usr/local/lib/baresip/modules",
@@ -853,6 +907,7 @@ int config_write_template(const char *file, const struct config *cfg)
(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");
+ (void)re_fprintf(f, "#module_app\t\t" MOD_PRE "ctrl_tcp" MOD_EXT "\n");
#ifdef USE_VIDEO
(void)re_fprintf(f, "module_app\t\t" MOD_PRE "vidloop"MOD_EXT"\n");
#endif
@@ -870,6 +925,9 @@ int config_write_template(const char *file, const struct config *cfg)
(void)re_fprintf(f, "http_listen\t\t0.0.0.0:8000\n");
(void)re_fprintf(f, "\n");
+ (void)re_fprintf(f, "ctrl_tcp_listen\t\t0.0.0.0:4444\n");
+
+ (void)re_fprintf(f, "\n");
(void)re_fprintf(f, "evdev_device\t\t/dev/input/event0\n");
(void)re_fprintf(f, "\n# Speex codec parameters\n");