Added configurable input timeout for all inputs
This commit is contained in:
		
							parent
							
								
									72ce091f67
								
							
						
					
					
						commit
						720f4b5d05
					
				
					 3 changed files with 26 additions and 5 deletions
				
			
		| 
						 | 
					@ -100,6 +100,7 @@ namespace Mist{
 | 
				
			||||||
    config = cfg;
 | 
					    config = cfg;
 | 
				
			||||||
    standAlone = true;
 | 
					    standAlone = true;
 | 
				
			||||||
    Util::Config::binaryType = Util::INPUT;
 | 
					    Util::Config::binaryType = Util::INPUT;
 | 
				
			||||||
 | 
					    inputTimeout = INPUT_TIMEOUT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    JSON::Value option;
 | 
					    JSON::Value option;
 | 
				
			||||||
    option["long"] = "json";
 | 
					    option["long"] = "json";
 | 
				
			||||||
| 
						 | 
					@ -131,6 +132,19 @@ namespace Mist{
 | 
				
			||||||
    option["value"].append(0u);
 | 
					    option["value"].append(0u);
 | 
				
			||||||
    option["help"] = "Generate .dtsh, then exit";
 | 
					    option["help"] = "Generate .dtsh, then exit";
 | 
				
			||||||
    config->addOption("headeronly", option);
 | 
					    config->addOption("headeronly", option);
 | 
				
			||||||
 | 
					    option.null();
 | 
				
			||||||
 | 
					    option["short"] = "i";
 | 
				
			||||||
 | 
					    option["arg"] = "integer";
 | 
				
			||||||
 | 
					    option["long"] = "inputtimeout";
 | 
				
			||||||
 | 
					    option["value"].append(inputTimeout);
 | 
				
			||||||
 | 
					    option["help"] = "Time in seconds to keep the input process loaded without activity";
 | 
				
			||||||
 | 
					    config->addOption("inputtimeout", option);
 | 
				
			||||||
 | 
					    capa["optional"]["inputtimeout"]["name"] = "Input inactivity timeout";
 | 
				
			||||||
 | 
					    capa["optional"]["inputtimeout"]["help"] = "How long the input should remain loaded without activity";
 | 
				
			||||||
 | 
					    capa["optional"]["inputtimeout"]["default"] = inputTimeout;
 | 
				
			||||||
 | 
					    capa["optional"]["inputtimeout"]["unit"] = "s";
 | 
				
			||||||
 | 
					    capa["optional"]["inputtimeout"]["type"] = "uint";
 | 
				
			||||||
 | 
					    capa["optional"]["inputtimeout"]["option"] = "--inputtimeout";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*LTS-START*/
 | 
					    /*LTS-START*/
 | 
				
			||||||
    /*
 | 
					    /*
 | 
				
			||||||
| 
						 | 
					@ -368,6 +382,7 @@ namespace Mist{
 | 
				
			||||||
  int Input::boot(int argc, char *argv[]){
 | 
					  int Input::boot(int argc, char *argv[]){
 | 
				
			||||||
    if (!(config->parseArgs(argc, argv))){return 1;}
 | 
					    if (!(config->parseArgs(argc, argv))){return 1;}
 | 
				
			||||||
    streamName = config->getString("streamname");
 | 
					    streamName = config->getString("streamname");
 | 
				
			||||||
 | 
					    inputTimeout = config->getInteger("inputtimeout");
 | 
				
			||||||
    Util::setStreamName(streamName);
 | 
					    Util::setStreamName(streamName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (config->getBool("json")){
 | 
					    if (config->getBool("json")){
 | 
				
			||||||
| 
						 | 
					@ -923,7 +938,7 @@ namespace Mist{
 | 
				
			||||||
    // We keep running in serve mode if the config is still active AND either
 | 
					    // We keep running in serve mode if the config is still active AND either
 | 
				
			||||||
    // - INPUT_TIMEOUT seconds haven't passed yet,
 | 
					    // - INPUT_TIMEOUT seconds haven't passed yet,
 | 
				
			||||||
    // - this is a live stream and at least two of the biggest fragment haven't passed yet,
 | 
					    // - this is a live stream and at least two of the biggest fragment haven't passed yet,
 | 
				
			||||||
    bool ret = config->is_active && ((Util::bootSecs() - activityCounter) < INPUT_TIMEOUT);
 | 
					    bool ret = config->is_active && ((Util::bootSecs() - activityCounter) < inputTimeout);
 | 
				
			||||||
    /*LTS-START*/
 | 
					    /*LTS-START*/
 | 
				
			||||||
    if (!ret){
 | 
					    if (!ret){
 | 
				
			||||||
      if (Triggers::shouldTrigger("STREAM_UNLOAD", config->getString("streamname"))){
 | 
					      if (Triggers::shouldTrigger("STREAM_UNLOAD", config->getString("streamname"))){
 | 
				
			||||||
| 
						 | 
					@ -936,8 +951,8 @@ namespace Mist{
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /*LTS-END*/
 | 
					    /*LTS-END*/
 | 
				
			||||||
    if (!ret && ((Util::bootSecs() - activityCounter) >= INPUT_TIMEOUT)){
 | 
					    if (!ret && ((Util::bootSecs() - activityCounter) >= inputTimeout)){
 | 
				
			||||||
      Util::logExitReason(ER_CLEAN_INACTIVE, "no activity for %u seconds", Util::bootSecs() - activityCounter);
 | 
					      Util::logExitReason(ER_CLEAN_INACTIVE, "no activity for %us (> %" PRIu64 "s)", Util::bootSecs() - activityCounter, inputTimeout);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return ret;
 | 
					    return ret;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,6 +57,7 @@ namespace Mist{
 | 
				
			||||||
    Comms::Connections statComm;
 | 
					    Comms::Connections statComm;
 | 
				
			||||||
    uint64_t startTime;
 | 
					    uint64_t startTime;
 | 
				
			||||||
    uint64_t lastStats;
 | 
					    uint64_t lastStats;
 | 
				
			||||||
 | 
					    uint64_t inputTimeout;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    virtual bool checkArguments() = 0;
 | 
					    virtual bool checkArguments() = 0;
 | 
				
			||||||
    virtual bool readHeader();
 | 
					    virtual bool readHeader();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -557,7 +557,13 @@ namespace Mist{
 | 
				
			||||||
      bufferTime = tmpNum;
 | 
					      bufferTime = tmpNum;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*LTS-START*/
 | 
					    //Check if input timeout setting is correct
 | 
				
			||||||
 | 
					    tmpNum = retrieveSetting(streamCfg, "inputtimeout");
 | 
				
			||||||
 | 
					    if (inputTimeout != tmpNum){
 | 
				
			||||||
 | 
					      DEVEL_MSG("Setting input timeout from %" PRIu64 " to new value of %" PRIu64, inputTimeout, tmpNum);
 | 
				
			||||||
 | 
					      inputTimeout = tmpNum;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //Check if cutTime setting is correct
 | 
					    //Check if cutTime setting is correct
 | 
				
			||||||
    tmpNum = retrieveSetting(streamCfg, "cut");
 | 
					    tmpNum = retrieveSetting(streamCfg, "cut");
 | 
				
			||||||
    // if the new value is different, print a message and apply it
 | 
					    // if the new value is different, print a message and apply it
 | 
				
			||||||
| 
						 | 
					@ -594,7 +600,6 @@ namespace Mist{
 | 
				
			||||||
      meta.setMaxKeepAway(tmpNum);
 | 
					      meta.setMaxKeepAway(tmpNum);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*LTS-END*/
 | 
					 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue