Fixed horrible input parameter bug
This commit is contained in:
parent
90f80f1a8d
commit
b6f606bf87
1 changed files with 24 additions and 21 deletions
|
@ -173,34 +173,36 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
||||||
DTSC::Scan input;
|
DTSC::Scan input;
|
||||||
unsigned int input_size = inputs.getSize();
|
unsigned int input_size = inputs.getSize();
|
||||||
for (unsigned int i = 0; i < input_size; ++i){
|
for (unsigned int i = 0; i < input_size; ++i){
|
||||||
input = inputs.getIndice(i);
|
DTSC::Scan tmp_input = inputs.getIndice(i);
|
||||||
|
|
||||||
//if match voor current stream && priority is hoger dan wat we al hebben
|
//if match voor current stream && priority is hoger dan wat we al hebben
|
||||||
if (input.getMember("source_match") && curPrio < input.getMember("priority").asInt()){
|
if (tmp_input.getMember("source_match") && curPrio < tmp_input.getMember("priority").asInt()){
|
||||||
if (input.getMember("source_match").getSize()){
|
if (tmp_input.getMember("source_match").getSize()){
|
||||||
for(unsigned int j = 0; j < input.getMember("source_match").getSize(); ++j){
|
for(unsigned int j = 0; j < tmp_input.getMember("source_match").getSize(); ++j){
|
||||||
std::string source = input.getMember("source_match").getIndice(j).asString();
|
std::string source = tmp_input.getMember("source_match").getIndice(j).asString();
|
||||||
std::string front = source.substr(0,source.find('*'));
|
std::string front = source.substr(0,source.find('*'));
|
||||||
std::string back = source.substr(source.find('*')+1);
|
std::string back = source.substr(source.find('*')+1);
|
||||||
MEDIUM_MSG("Checking input %s: %s (%s)", inputs.getIndiceName(i).c_str(), input.getMember("name").asString().c_str(), source.c_str());
|
MEDIUM_MSG("Checking input %s: %s (%s)", inputs.getIndiceName(i).c_str(), tmp_input.getMember("name").asString().c_str(), source.c_str());
|
||||||
|
|
||||||
if (filename.substr(0,front.size()) == front && filename.substr(filename.size()-back.size()) == back){
|
if (filename.substr(0,front.size()) == front && filename.substr(filename.size()-back.size()) == back){
|
||||||
player_bin = Util::getMyPath() + "MistIn" + input.getMember("name").asString();
|
player_bin = Util::getMyPath() + "MistIn" + tmp_input.getMember("name").asString();
|
||||||
curPrio = input.getMember("priority").asInt();
|
curPrio = tmp_input.getMember("priority").asInt();
|
||||||
selected = true;
|
selected = true;
|
||||||
|
input = tmp_input;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
std::string source = input.getMember("source_match").asString();
|
std::string source = tmp_input.getMember("source_match").asString();
|
||||||
std::string front = source.substr(0,source.find('*'));
|
std::string front = source.substr(0,source.find('*'));
|
||||||
std::string back = source.substr(source.find('*')+1);
|
std::string back = source.substr(source.find('*')+1);
|
||||||
DEBUG_MSG(DLVL_MEDIUM, "Checking input %s: %s (%s)", inputs.getIndiceName(i).c_str(), input.getMember("name").asString().c_str(), source.c_str());
|
MEDIUM_MSG("Checking input %s: %s (%s)", inputs.getIndiceName(i).c_str(), tmp_input.getMember("name").asString().c_str(), source.c_str());
|
||||||
|
|
||||||
if (filename.substr(0,front.size()) == front && filename.substr(filename.size()-back.size()) == back){
|
if (filename.substr(0,front.size()) == front && filename.substr(filename.size()-back.size()) == back){
|
||||||
player_bin = Util::getMyPath() + "MistIn" + input.getMember("name").asString();
|
player_bin = Util::getMyPath() + "MistIn" + tmp_input.getMember("name").asString();
|
||||||
curPrio = input.getMember("priority").asInt();
|
curPrio = tmp_input.getMember("priority").asInt();
|
||||||
selected = true;
|
selected = true;
|
||||||
}
|
input = tmp_input;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -212,7 +214,7 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//copy the neccessary arguments to separate storage so we can unlock the config semaphore safely
|
//copy the necessary arguments to separate storage so we can unlock the config semaphore safely
|
||||||
std::map<std::string, std::string> str_args;
|
std::map<std::string, std::string> str_args;
|
||||||
//check required parameters
|
//check required parameters
|
||||||
DTSC::Scan required = input.getMember("required");
|
DTSC::Scan required = input.getMember("required");
|
||||||
|
@ -231,7 +233,7 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
||||||
unsigned int opt_size = optional.getSize();
|
unsigned int opt_size = optional.getSize();
|
||||||
for (unsigned int i = 0; i < opt_size; ++i){
|
for (unsigned int i = 0; i < opt_size; ++i){
|
||||||
std::string opt = optional.getIndiceName(i);
|
std::string opt = optional.getIndiceName(i);
|
||||||
DEBUG_MSG(DLVL_VERYHIGH, "Checking optional %u: %s", i, opt.c_str());
|
VERYHIGH_MSG("Checking optional %u: %s", i, opt.c_str());
|
||||||
if (stream_cfg.getMember(opt)){
|
if (stream_cfg.getMember(opt)){
|
||||||
str_args[optional.getIndice(i).getMember("option").asString()] = stream_cfg.getMember(opt).asString();
|
str_args[optional.getIndice(i).getMember("option").asString()] = stream_cfg.getMember(opt).asString();
|
||||||
}
|
}
|
||||||
|
@ -240,7 +242,7 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
||||||
//finally, unlock the config semaphore
|
//finally, unlock the config semaphore
|
||||||
configLock.post();
|
configLock.post();
|
||||||
|
|
||||||
DEBUG_MSG(DLVL_MEDIUM, "Starting %s -s %s %s", player_bin.c_str(), streamname.c_str(), filename.c_str());
|
INFO_MSG("Starting %s -s %s %s", player_bin.c_str(), streamname.c_str(), filename.c_str());
|
||||||
char * argv[30] = {(char *)player_bin.c_str(), (char *)"-s", (char *)streamname.c_str(), (char *)filename.c_str()};
|
char * argv[30] = {(char *)player_bin.c_str(), (char *)"-s", (char *)streamname.c_str(), (char *)filename.c_str()};
|
||||||
int argNum = 3;
|
int argNum = 3;
|
||||||
std::string debugLvl;
|
std::string debugLvl;
|
||||||
|
@ -252,6 +254,7 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
||||||
for (std::map<std::string, std::string>::iterator it = str_args.begin(); it != str_args.end(); ++it){
|
for (std::map<std::string, std::string>::iterator it = str_args.begin(); it != str_args.end(); ++it){
|
||||||
argv[++argNum] = (char *)it->first.c_str();
|
argv[++argNum] = (char *)it->first.c_str();
|
||||||
argv[++argNum] = (char *)it->second.c_str();
|
argv[++argNum] = (char *)it->second.c_str();
|
||||||
|
INFO_MSG(" Option %s = %s", it->first.c_str(), it->second.c_str());
|
||||||
}
|
}
|
||||||
argv[++argNum] = (char *)0;
|
argv[++argNum] = (char *)0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue