Skip to content

Commit 763089e

Browse files
committed
main: valildate some params
Issue a warning eg. when -c option used without -t, in which case the compression does nothing. This avoids either omitting an option by mistake (here `-t`) or vice versa passing an extra parameter (either by accident or not knowing that not usable in the context).
1 parent 849929b commit 763089e

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

src/main.cpp

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,43 @@ static int adjust_params(struct ug_options *opt) {
12771277
opt->bitrate = opt->bitrate == RATE_DEFAULT ? RATE_DYNAMIC : opt->bitrate;
12781278
}
12791279

1280+
return 0;
1281+
}
1282+
1283+
/// warn about unused options or not recommended options or agruments
1284+
static void
1285+
validate_params(struct ug_options *opt)
1286+
{
1287+
if (opt->vidcap_params_head == opt->vidcap_params_tail) {
1288+
if (opt->requested_compression != nullptr) {
1289+
MSG(WARNING,
1290+
"Video compression set but no vidcap given!\n");
1291+
}
1292+
if (vidcap_params_get_capture_filter(opt->vidcap_params_tail) != nullptr) {
1293+
MSG(WARNING, "Video capture filter specified but not capturing!\n");
1294+
}
1295+
if (strcmp(opt->requested_video_fec, "none") != 0) {
1296+
MSG(WARNING, "Video FEC specified but not capturing!\n");
1297+
}
1298+
}
1299+
1300+
if (strcmp(opt->requested_display, "none") == 0) {
1301+
if (opt->postprocess != nullptr) {
1302+
MSG(WARNING, "Video postprocess specified without a display!\n");
1303+
}
1304+
}
1305+
1306+
if (strcmp(opt->audio.send_cfg, ug_options().audio.send_cfg) == 0) {
1307+
if (strcmp(opt->audio.fec_cfg, ug_options().audio.fec_cfg) != 0) {
1308+
MSG(WARNING,
1309+
"Audio FEC specified but not capturing!\n");
1310+
}
1311+
if (opt->audio.codec_cfg != nullptr) {
1312+
MSG(WARNING,
1313+
"Audio compression specified but not capturing!\n");
1314+
}
1315+
}
1316+
12801317
if((strcmp("none", opt->audio.send_cfg) != 0 || strcmp("none", opt->audio.recv_cfg) != 0) && strcmp(opt->video_protocol, "rtsp") == 0){
12811318
//TODO: to implement a high level rxtx struct to manage different standards (i.e.:H264_STD, VP8_STD,...)
12821319
if (strcmp(opt->audio.proto, "rtsp") != 0) {
@@ -1286,10 +1323,9 @@ static int adjust_params(struct ug_options *opt) {
12861323
if (strcmp(opt->audio.proto, "rtsp") == 0 && strcmp(opt->video_protocol, "rtsp") != 0) {
12871324
LOG(LOG_LEVEL_WARNING) << "Using RTSP for audio but not for video is not recommended and might not work.\n";
12881325
}
1289-
1290-
return 0;
12911326
}
12921327

1328+
12931329
#define EXIT(expr) { int rc = expr; common_cleanup(init); return rc; }
12941330

12951331
int main(int argc, char *argv[])
@@ -1337,6 +1373,9 @@ int main(int argc, char *argv[])
13371373
EXIT(ret < 0 ? -ret : EXIT_SUCCESS);
13381374
}
13391375

1376+
if (!show_help) {
1377+
validate_params(&opt);
1378+
}
13401379
if (int ret = adjust_params(&opt)) {
13411380
EXIT(ret);
13421381
}

0 commit comments

Comments
 (0)