Added -N option to not start input if not already running

This commit is contained in:
Thulinma 2017-01-20 00:04:00 +01:00
parent 40a06701bf
commit 2e9eb51baf

View file

@ -29,6 +29,13 @@ namespace Mist{
capa["optional"]["debug"]["help"] = "The debug level at which messages need to be printed.";
capa["optional"]["debug"]["option"] = "--debug";
capa["optional"]["debug"]["type"] = "debug";
JSON::Value option;
option["long"] = "noinput";
option["short"] = "N";
option["help"] = "Do not start input if not already started";
option["value"].append(0ll);
cfg->addOption("noinput", option);
}
Output::Output(Socket::Connection & conn) : myConn(conn){
@ -160,11 +167,20 @@ namespace Mist{
/// Finally, calls updateMeta()
void Output::reconnect(){
thisPacket.null();
if (config->hasOption("noinput") && config->getBool("noinput")){
Util::sanitizeName(streamName);
if (!Util::streamAlive(streamName)){
FAIL_MSG("Stream %s not already active - aborting initialization", streamName.c_str());
onFail();
return;
}
}else{
if (!Util::startInput(streamName)){
FAIL_MSG("Opening stream %s failed - aborting initialization", streamName.c_str());
onFail();
return;
}
}
if (statsPage.getData()){
statsPage.finish();
}