@@ -100,6 +100,7 @@ namespace Mist{
100100 config = cfg;
101101 standAlone = true;
102102 Util::Config::binaryType = Util::INPUT;
103+ inputTimeout = INPUT_TIMEOUT;
103104
104105 JSON::Value option;
105106 option["long"] = "json";
@@ -131,6 +132,19 @@ namespace Mist{
131132 option["value"].append(0u);
132133 option["help"] = "Generate .dtsh, then exit";
133134 config->addOption("headeronly", option);
135+ option.null();
136+ option["short"] = "i";
137+ option["arg"] = "integer";
138+ option["long"] = "inputtimeout";
139+ option["value"].append(inputTimeout);
140+ option["help"] = "Time in seconds to keep the input process loaded without activity";
141+ config->addOption("inputtimeout", option);
142+ capa["optional"]["inputtimeout"]["name"] = "Input inactivity timeout";
143+ capa["optional"]["inputtimeout"]["help"] = "How long the input should remain loaded without activity";
144+ capa["optional"]["inputtimeout"]["default"] = inputTimeout;
145+ capa["optional"]["inputtimeout"]["unit"] = "s";
146+ capa["optional"]["inputtimeout"]["type"] = "uint";
147+ capa["optional"]["inputtimeout"]["option"] = "--inputtimeout";
134148
135149 /*LTS-START*/
136150 /*
@@ -368,6 +382,7 @@ namespace Mist{
368382 int Input::boot(int argc, char *argv[]){
369383 if (!(config->parseArgs(argc, argv))){return 1;}
370384 streamName = config->getString("streamname");
385+ inputTimeout = config->getInteger("inputtimeout");
371386 Util::setStreamName(streamName);
372387
373388 if (config->getBool("json")){
@@ -923,7 +938,7 @@ namespace Mist{
923938 // We keep running in serve mode if the config is still active AND either
924939 // - INPUT_TIMEOUT seconds haven't passed yet,
925940 // - this is a live stream and at least two of the biggest fragment haven't passed yet,
926- bool ret = config->is_active && ((Util::bootSecs() - activityCounter) < INPUT_TIMEOUT );
941+ bool ret = config->is_active && ((Util::bootSecs() - activityCounter) < inputTimeout );
927942 /*LTS-START*/
928943 if (!ret){
929944 if (Triggers::shouldTrigger("STREAM_UNLOAD", config->getString("streamname"))){
@@ -936,8 +951,8 @@ namespace Mist{
936951 }
937952 }
938953 /*LTS-END*/
939- if (!ret && ((Util::bootSecs() - activityCounter) >= INPUT_TIMEOUT )){
940- Util::logExitReason(ER_CLEAN_INACTIVE, "no activity for %u seconds" , Util::bootSecs() - activityCounter);
954+ if (!ret && ((Util::bootSecs() - activityCounter) >= inputTimeout )){
955+ Util::logExitReason(ER_CLEAN_INACTIVE, "no activity for %us (> %" PRIu64 "s)" , Util::bootSecs() - activityCounter, inputTimeout );
941956 }
942957 return ret;
943958 }
0 commit comments