Added global configuration mechanism and defaultStream support

This commit is contained in:
Thulinma 2019-10-29 17:15:08 +01:00
parent 50d1d0e944
commit 7bffdfe644
9 changed files with 130 additions and 3 deletions

View file

@ -494,6 +494,9 @@ void Controller::handleAPICommands(JSON::Value & Request, JSON::Value & Response
out["prometheus"] = in["prometheus"];
Controller::prometheus = out["prometheus"].asStringRef();
}
if (in.isMember("defaultStream")){
out["defaultStream"] = in["defaultStream"];
}
}
if (Request.isMember("bandwidth")){
if (Request["bandwidth"].isObject()){

View file

@ -160,6 +160,13 @@ namespace Controller {
trgs["LIVE_BANDWIDTH"]["response"] = "always";
trgs["LIVE_BANDWIDTH"]["response_action"] = "If false, shuts down the stream buffer.";
trgs["LIVE_BANDWIDTH"]["argument"] = "Triggers only if current bytes per second exceeds this amount (integer)";
trgs["DEFAULT_STREAM"]["when"] = "When any user attempts to open a stream that cannot be opened (because it is either offline or not configured), allows rewriting the stream to a different one as fallback. Supports variable substitution.";
trgs["DEFAULT_STREAM"]["stream_specific"] = true;
trgs["DEFAULT_STREAM"]["payload"] = "current defaultStream setting (string)\nrequested stream name (string)\nviewer host (string)\noutput type (string)\nfull request URL (string, may be blank for non-URL-based requests!)";
trgs["DEFAULT_STREAM"]["response"] = "always";
trgs["DEFAULT_STREAM"]["response_action"] = "Overrides the default stream setting (for this view) to the response value. If empty, fails loading the stream and returns an error to the viewer/user.";
}
///Aquire list of available protocols, storing in global 'capabilities' JSON::Value.

View file

@ -334,6 +334,27 @@ namespace Controller{
writeStream(it.key(), *it);
}
{
//Global configuration options, if any
IPC::sharedPage globCfg;
globCfg.init(SHM_GLOBAL_CONF, 4096, false, false);
if (!globCfg.mapped){
globCfg.init(SHM_GLOBAL_CONF, 4096, true, false);
}
if (globCfg.mapped){
Util::RelAccX globAccX(globCfg.mapped, false);
if (!globAccX.isReady()){
globAccX.addField("defaultStream", RAX_128STRING);
globAccX.setRCount(1);
globAccX.setEndPos(1);
globAccX.setReady();
}
globAccX.setString("defaultStream", Storage["config"]["defaultStream"].asStringRef());
globCfg.master = false;//leave the page after closing
}
}
/*LTS-START*/
static std::map<std::string, IPC::sharedPage> pageForType; // should contain one page for every trigger type
static JSON::Value writtenTrigs;