From 2e9eb51bafddb175413fd549e051df2f8402e5d4 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 20 Jan 2017 00:04:00 +0100 Subject: [PATCH] Added -N option to not start input if not already running --- src/output/output.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/output/output.cpp b/src/output/output.cpp index eb985351..06acd751 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -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,10 +167,19 @@ namespace Mist{ /// Finally, calls updateMeta() void Output::reconnect(){ thisPacket.null(); - if (!Util::startInput(streamName)){ - FAIL_MSG("Opening stream %s failed - aborting initialization", streamName.c_str()); - onFail(); - return; + 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();