Fix fallback stream, added support for stream variables in fallback stream

This commit is contained in:
Thulinma 2021-10-27 15:39:34 +02:00
parent aa77d86df1
commit f8251cc115
2 changed files with 22 additions and 2 deletions

View file

@ -326,9 +326,12 @@ namespace Mist{
// 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();
std::string defStrm = strCnf["fallback_stream"].asStringRef();
std::string newStrm = defStrm;
Util::streamVariables(newStrm, streamName, "");
INFO_MSG("Switching to configured fallback stream '%s' -> '%s'", defStrm.c_str(), newStrm.c_str());
streamName = newStrm;
Util::setStreamName(streamName);
INFO_MSG("Switching to configured fallback stream '%s'", streamName.c_str());
reconnect();
return;
}

View file

@ -433,6 +433,23 @@ namespace Mist{
if (streamStatus != STRMSTAT_READY){
// If we haven't rewritten the stream name yet to a fallback, attempt to do so
if (origStreamName == streamName){
// If stream is configured, use fallback stream setting, if set.
JSON::Value strCnf = Util::getStreamConfig(streamName);
if (strCnf && strCnf["fallback_stream"].asStringRef().size()){
std::string defStrm = strCnf["fallback_stream"].asStringRef();
std::string newStrm = defStrm;
Util::streamVariables(newStrm, streamName, "");
if (streamName != newStrm){
INFO_MSG("Switching to configured fallback stream '%s' -> '%s'", defStrm.c_str(), newStrm.c_str());
origStreamName = streamName;
streamName = newStrm;
Util::setStreamName(streamName);
reconnect();
return getStatusJSON(reqHost, useragent);
}
}
//global fallback stream
JSON::Value defStrmJson = Util::getGlobalConfig("defaultStream");
std::string defStrm = defStrmJson.asString();
if (Triggers::shouldTrigger("DEFAULT_STREAM", streamName)){