Added global configuration mechanism and defaultStream support
This commit is contained in:
parent
50d1d0e944
commit
7bffdfe644
9 changed files with 130 additions and 3 deletions
|
@ -133,6 +133,7 @@ static inline void show_stackframe(){}
|
|||
#define SHM_STREAM_INDEX "MstSTRM%s" //%s stream name
|
||||
#define SHM_STREAM_STATE "MstSTATE%s" //%s stream name
|
||||
#define SHM_STREAM_CONF "MstSCnf%s" //%s stream name
|
||||
#define SHM_GLOBAL_CONF "MstGlobalConfig"
|
||||
#define STRMSTAT_OFF 0
|
||||
#define STRMSTAT_INIT 1
|
||||
#define STRMSTAT_BOOT 2
|
||||
|
|
|
@ -205,12 +205,44 @@ JSON::Value Util::getStreamConfig(const std::string &streamname){
|
|||
Util::DTSCShmReader rStrmConf(tmpBuf);
|
||||
DTSC::Scan stream_cfg = rStrmConf.getScan();
|
||||
if (!stream_cfg){
|
||||
WARN_MSG("Could not get stream '%s' config!", smp.c_str());
|
||||
if (!Util::getGlobalConfig("defaultStream")){
|
||||
WARN_MSG("Could not get stream '%s' config!", smp.c_str());
|
||||
}else{
|
||||
INFO_MSG("Could not get stream '%s' config, not emitting WARN message because fallback is configured", smp.c_str());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return stream_cfg.asJSON();
|
||||
}
|
||||
|
||||
JSON::Value Util::getGlobalConfig(const std::string &optionName){
|
||||
IPC::sharedPage globCfg(SHM_GLOBAL_CONF);
|
||||
if (!globCfg.mapped){
|
||||
FAIL_MSG("Could not open global configuration options to read setting for '%s'", optionName.c_str());
|
||||
return JSON::Value();
|
||||
}
|
||||
Util::RelAccX cfgData(globCfg.mapped);
|
||||
if (!cfgData.isReady()){
|
||||
FAIL_MSG("Global configuration options not ready; cannot read setting for '%s'", optionName.c_str());
|
||||
return JSON::Value();
|
||||
}
|
||||
Util::RelAccXFieldData dataField = cfgData.getFieldData(optionName);
|
||||
switch (dataField.type & 0xF0){
|
||||
case RAX_INT:
|
||||
case RAX_UINT:
|
||||
//Integer types, return JSON::Value integer
|
||||
return JSON::Value(cfgData.getInt(dataField));
|
||||
case RAX_RAW:
|
||||
case RAX_STRING:
|
||||
//String types, return JSON::Value string
|
||||
return JSON::Value(std::string(cfgData.getPointer(dataField), cfgData.getSize(optionName)));
|
||||
default:
|
||||
//Unimplemented types
|
||||
FAIL_MSG("Global configuration setting for '%s' is not an implemented datatype!", optionName.c_str());
|
||||
return JSON::Value();
|
||||
}
|
||||
}
|
||||
|
||||
DTSC::Meta Util::getStreamMeta(const std::string &streamname){
|
||||
DTSC::Meta ret;
|
||||
char pageId[NAME_BUFFER_SIZE];
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace Util {
|
|||
bool startInput(std::string streamname, std::string filename = "", bool forkFirst = true, bool isProvider = false, const std::map<std::string, std::string> & overrides = std::map<std::string, std::string>(), pid_t * spawn_pid = NULL);
|
||||
int startPush(const std::string & streamname, std::string & target);
|
||||
JSON::Value getStreamConfig(const std::string & streamname);
|
||||
JSON::Value getGlobalConfig(const std::string & optionName);
|
||||
JSON::Value getInputBySource(const std::string & filename, bool isProvider = false);
|
||||
DTSC::Meta getStreamMeta(const std::string & streamname);
|
||||
uint8_t getStreamStatus(const std::string & streamname);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue