Added basic stream fallback feature, allowing to redirect to a different stream name on stream source load errors
This commit is contained in:
parent
6e125707f1
commit
7beea43d31
4 changed files with 22 additions and 1 deletions
|
@ -363,6 +363,7 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
|||
// check required parameters
|
||||
if (input.isMember("required")){
|
||||
jsonForEachConst(input["required"], prm){
|
||||
if (!prm->isMember("option")){continue;}
|
||||
const std::string opt = (*prm)["option"].asStringRef();
|
||||
// check for overrides
|
||||
if (overrides.count(opt)){
|
||||
|
@ -379,6 +380,7 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
|||
// check optional parameters
|
||||
if (input.isMember("optional")){
|
||||
jsonForEachConst(input["optional"], prm){
|
||||
if (!prm->isMember("option")){continue;}
|
||||
const std::string opt = (*prm)["option"].asStringRef();
|
||||
// check for overrides
|
||||
if (overrides.count(opt)){
|
||||
|
|
|
@ -82,6 +82,11 @@ namespace Mist {
|
|||
capa["optional"]["segmentsize"]["option"] = "--segment-size";
|
||||
capa["optional"]["segmentsize"]["type"] = "uint";
|
||||
capa["optional"]["segmentsize"]["default"] = 1900;
|
||||
|
||||
capa["optional"]["fallback_stream"]["name"] = "Fallback stream";
|
||||
capa["optional"]["fallback_stream"]["help"] = "Alternative stream to load for playback when there is no active broadcast";
|
||||
capa["optional"]["fallback_stream"]["type"] = "str";
|
||||
capa["optional"]["fallback_stream"]["default"] = "";
|
||||
option.null();
|
||||
/*LTS-end*/
|
||||
|
||||
|
|
|
@ -372,6 +372,19 @@ namespace Mist{
|
|||
}
|
||||
}else{
|
||||
if (!Util::startInput(streamName, "", true, isPushing())){
|
||||
//If stream is configured, use fallback stream setting, if set.
|
||||
JSON::Value strCnf = Util::getStreamConfig(streamName);
|
||||
if (strCnf && strCnf["fallback_stream"].asStringRef().size()){
|
||||
streamName = strCnf["fallback_stream"].asStringRef();
|
||||
Util::Config::streamName = streamName;
|
||||
INFO_MSG("Switching to configured fallback stream '%s'", streamName.c_str());
|
||||
reconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
//Not configured or no fallback stream? Use the default stream handler instead
|
||||
//Note: Since fallback stream is handled recursively, the defaultStream handler
|
||||
//may still be triggered for the fallback stream! This is intentional.
|
||||
JSON::Value defStrmJson = Util::getGlobalConfig("defaultStream");
|
||||
std::string defStrm = defStrmJson.asString();
|
||||
if(Triggers::shouldTrigger("DEFAULT_STREAM", streamName)){
|
||||
|
|
|
@ -433,7 +433,8 @@ namespace Mist {
|
|||
H.Clean(); //clean for any possible next requests
|
||||
return;
|
||||
}else if (HTTP::URL(H.url).getExt().substr(0, 3) != "m3u") {
|
||||
std::string tmpStr = H.getUrl().substr(5 + streamName.size());
|
||||
size_t slashPos = H.getUrl().find('/', 5);
|
||||
std::string tmpStr = H.getUrl().substr(slashPos);
|
||||
long long unsigned int from;
|
||||
if (sscanf(tmpStr.c_str(), "/%u_%u/%llu_%llu.ts", &vidTrack, &audTrack, &from, &until) != 4) {
|
||||
if (sscanf(tmpStr.c_str(), "/%u/%llu_%llu.ts", &vidTrack, &from, &until) != 3) {
|
||||
|
|
Loading…
Add table
Reference in a new issue