Added ability to disable resume support for live streams.

This commit is contained in:
Thulinma 2015-11-27 14:51:15 +01:00
parent bf180a2a35
commit ed5440e382
3 changed files with 49 additions and 1 deletions

View file

@ -279,7 +279,9 @@ namespace Mist {
} }
} }
/*LTS-END*/ /*LTS-END*/
Util::sleep(1000); if (config->is_active){
Util::sleep(1000);
}
} }
#endif #endif
finish(); finish();

View file

@ -60,6 +60,23 @@ namespace Mist {
capa["optional"]["cut"]["default"] = 0LL; capa["optional"]["cut"]["default"] = 0LL;
option.null(); option.null();
option["arg"] = "integer";
option["long"] = "resume";
option["short"] = "R";
option["help"] = "Enable resuming support (1, default) or disable resuming support (0)";
option["value"].append(1LL);
config->addOption("resume", option);
capa["optional"]["resume"]["name"] = "Resume support";
capa["optional"]["resume"]["help"] = "If enabled, the buffer will linger after source disconnect to allow resuming the stream later. If disabled, the buffer will instantly close on source disconnect.";
capa["optional"]["resume"]["option"] = "--resume";
capa["optional"]["resume"]["type"] = "select";
capa["optional"]["resume"]["select"][0u][0u] = "1";
capa["optional"]["resume"]["select"][0u][1u] = "Enabled";
capa["optional"]["resume"]["select"][1u][0u] = "0";
capa["optional"]["resume"]["select"][1u][1u] = "Disabled";
capa["optional"]["resume"]["default"] = 1LL;
option.null();
option["arg"] = "integer"; option["arg"] = "integer";
option["long"] = "segment-size"; option["long"] = "segment-size";
option["short"] = "S"; option["short"] = "S";
@ -95,6 +112,7 @@ namespace Mist {
bufferTime = 50000; bufferTime = 50000;
cutTime = 0; cutTime = 0;
segmentSize = 5000; segmentSize = 5000;
hasPush = false;
} }
inputBuffer::~inputBuffer(){ inputBuffer::~inputBuffer(){
@ -438,6 +456,14 @@ namespace Mist {
} }
} }
updateMeta(); updateMeta();
static bool everHadPush = false;
if (hasPush){
hasPush = false;
everHadPush = true;
}else if(everHadPush && !resumeMode && config->is_active){
INFO_MSG("Shutting down buffer because resume mode is disabled and the source disconnected");
config->is_active = false;
}
} }
/// \triggers /// \triggers
@ -637,6 +663,7 @@ namespace Mist {
if (metaPages[value].mapped){ if (metaPages[value].mapped){
//Update the metadata for this track //Update the metadata for this track
updateTrackMeta(value); updateTrackMeta(value);
hasPush = true;
} }
} }
} }
@ -775,6 +802,23 @@ namespace Mist {
cutTime = tmpNum; cutTime = tmpNum;
} }
//if stream is configured and setting is present, use it, always
if (streamCfg && streamCfg.getMember("resume")){
tmpNum = streamCfg.getMember("resume").asInt();
} else {
if (streamCfg){
//otherwise, if stream is configured use the default
tmpNum = config->getOption("resume", true)[0u].asInt();
} else {
//if not, use the commandline argument
tmpNum = config->getOption("resume").asInt();
}
}
//if the new value is different, print a message and apply it
if (resumeMode != (bool)tmpNum){
DEBUG_MSG(DLVL_DEVEL, "Setting resume mode from %s to new value of %s", resumeMode?"enabled":"disabled", tmpNum?"enabled":"disabled");
resumeMode = tmpNum;
}
//if stream is configured and setting is present, use it, always //if stream is configured and setting is present, use it, always
if (streamCfg && streamCfg.getMember("segmentsize")){ if (streamCfg && streamCfg.getMember("segmentsize")){

View file

@ -14,6 +14,8 @@ namespace Mist {
unsigned int cutTime; unsigned int cutTime;
unsigned int segmentSize; /*LTS*/ unsigned int segmentSize; /*LTS*/
unsigned int lastReTime; /*LTS*/ unsigned int lastReTime; /*LTS*/
bool hasPush; /*LTS*/
bool resumeMode; /*LTS*/
protected: protected:
//Private Functions //Private Functions
bool setup(); bool setup();