Changed pull mode detection to be internal to each input, made DTSC input compliant with JSON output styling guidelines.
This commit is contained in:
parent
7e82673a13
commit
6386060c10
5 changed files with 31 additions and 52 deletions
|
@ -204,7 +204,6 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
|||
|
||||
//check in curConf for capabilities-inputs-<naam>-priority/source_match
|
||||
std::string player_bin;
|
||||
bool pullMode = false;
|
||||
bool selected = false;
|
||||
long long int curPrio = -1;
|
||||
DTSC::Scan inputs = config.getMember("capabilities").getMember("inputs");
|
||||
|
@ -214,7 +213,21 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
|||
input = inputs.getIndice(i);
|
||||
|
||||
//if match voor current stream && priority is hoger dan wat we al hebben
|
||||
if (curPrio < input.getMember("priority").asInt()){
|
||||
if (input.getMember("source_match") && curPrio < input.getMember("priority").asInt()){
|
||||
if (input.getMember("source_match").getSize()){
|
||||
for(unsigned int j = 0; j < input.getMember("source_match").getSize(); ++j){
|
||||
std::string source = input.getMember("source_match").getIndice(j).asString();
|
||||
std::string front = source.substr(0,source.find('*'));
|
||||
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());
|
||||
|
||||
if (filename.substr(0,front.size()) == front && filename.substr(filename.size()-back.size()) == back){
|
||||
player_bin = Util::getMyPath() + "MistIn" + input.getMember("name").asString();
|
||||
curPrio = input.getMember("priority").asInt();
|
||||
selected = true;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
std::string source = input.getMember("source_match").asString();
|
||||
std::string front = source.substr(0,source.find('*'));
|
||||
std::string back = source.substr(source.find('*')+1);
|
||||
|
@ -225,20 +238,8 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
|||
curPrio = input.getMember("priority").asInt();
|
||||
selected = true;
|
||||
}
|
||||
|
||||
if (input.hasMember("stream_match")){
|
||||
source = input.getMember("stream_match").asString();
|
||||
front = source.substr(0,source.find('*'));
|
||||
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());
|
||||
|
||||
if (filename.substr(0,front.size()) == front && filename.substr(filename.size()-back.size()) == back){
|
||||
player_bin = Util::getMyPath() + "MistIn" + input.getMember("name").asString();
|
||||
curPrio = input.getMember("priority").asInt();
|
||||
pullMode = true;
|
||||
selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,16 +277,9 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
|||
//finally, unlock the config semaphore
|
||||
configLock.post();
|
||||
|
||||
if (pullMode){
|
||||
DEBUG_MSG(DLVL_MEDIUM, "Starting %s -p -s %s %s", player_bin.c_str(), streamname.c_str(), filename.c_str());
|
||||
}else{
|
||||
DEBUG_MSG(DLVL_MEDIUM, "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()};
|
||||
int argNum = 3;
|
||||
if (pullMode){
|
||||
argv[++argNum] = (char*)"--pull";
|
||||
}
|
||||
std::string debugLvl;
|
||||
if (Util::Config::printDebugLevel != DEBUG && !str_args.count("--debug")){
|
||||
debugLvl = JSON::Value((long long)Util::Config::printDebugLevel).asString();
|
||||
|
|
|
@ -83,7 +83,6 @@ namespace Mist {
|
|||
|
||||
singleton = this;
|
||||
isBuffer = false;
|
||||
streamMode = false;
|
||||
}
|
||||
|
||||
void Input::checkHeaderTimes(std::string streamFile) {
|
||||
|
@ -116,10 +115,6 @@ namespace Mist {
|
|||
}
|
||||
}
|
||||
|
||||
bool Input::needsLock() {
|
||||
return !(config->hasOption("pull") && config->getBool("pull"));
|
||||
}
|
||||
|
||||
int Input::run() {
|
||||
if (config->getBool("json")) {
|
||||
std::cout << capa.toString() << std::endl;
|
||||
|
@ -132,11 +127,6 @@ namespace Mist {
|
|||
streamName = config->getString("streamname");
|
||||
nProxy.streamName = streamName;
|
||||
|
||||
|
||||
streamMode = config->hasOption("pull") && config->getBool("pull");
|
||||
INFO_MSG("Stream %s in %s mode", streamName.c_str(), streamMode ? "stream" : "non-stream");
|
||||
|
||||
|
||||
if (!setup()) {
|
||||
std::cerr << config->getString("cmd") << " setup failed." << std::endl;
|
||||
return 0;
|
||||
|
@ -151,7 +141,7 @@ namespace Mist {
|
|||
|
||||
if (!streamName.size()) {
|
||||
convert();
|
||||
} else if (streamMode) {
|
||||
} else if (!needsLock()) {
|
||||
stream();
|
||||
}else{
|
||||
serve();
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Mist {
|
|||
virtual void argumentsParsed(){}
|
||||
virtual ~Input() {};
|
||||
|
||||
virtual bool needsLock();
|
||||
virtual bool needsLock(){return true;}
|
||||
protected:
|
||||
static void callbackWrapper(char * data, size_t len, unsigned int id);
|
||||
virtual bool setup() = 0;
|
||||
|
@ -46,7 +46,6 @@ namespace Mist {
|
|||
virtual void convert();
|
||||
virtual void serve();
|
||||
virtual void stream();
|
||||
bool streamMode;
|
||||
|
||||
|
||||
virtual void parseHeader();
|
||||
|
|
|
@ -17,8 +17,8 @@ namespace Mist {
|
|||
capa["name"] = "DTSC";
|
||||
capa["desc"] = "Enables DTSC Input";
|
||||
capa["priority"] = 9ll;
|
||||
capa["source_match"] = "/*.dtsc";
|
||||
capa["stream_match"] = "dtsc://*";
|
||||
capa["source_match"].append("/*.dtsc");
|
||||
capa["source_match"].append("dtsc://*");
|
||||
capa["codecs"][0u][0u].append("H264");
|
||||
capa["codecs"][0u][0u].append("H263");
|
||||
capa["codecs"][0u][0u].append("VP6");
|
||||
|
@ -26,16 +26,11 @@ namespace Mist {
|
|||
capa["codecs"][0u][1u].append("AAC");
|
||||
capa["codecs"][0u][1u].append("MP3");
|
||||
capa["codecs"][0u][1u].append("vorbis");
|
||||
|
||||
|
||||
JSON::Value option;
|
||||
option["long"] = "pull";
|
||||
option["short"] = "p";
|
||||
option["help"] = "Start this input in pull mode.";
|
||||
option["value"].append(0ll);
|
||||
config->addOption("pull", option);
|
||||
}
|
||||
|
||||
bool inputDTSC::needsLock(){
|
||||
return config->getString("input").substr(0, 7) != "dtsc://";
|
||||
}
|
||||
|
||||
void parseDTSCURI(const std::string & src, std::string & host, uint16_t & port, std::string & password, std::string & streamName) {
|
||||
host = "";
|
||||
|
@ -166,7 +161,7 @@ namespace Mist {
|
|||
}
|
||||
|
||||
bool inputDTSC::setup() {
|
||||
if (streamMode) {
|
||||
if (!needsLock()) {
|
||||
return true;
|
||||
} else {
|
||||
if (config->getString("input") == "-") {
|
||||
|
@ -195,7 +190,7 @@ namespace Mist {
|
|||
}
|
||||
|
||||
bool inputDTSC::readHeader() {
|
||||
if (streamMode) {
|
||||
if (!needsLock()) {
|
||||
return true;
|
||||
}
|
||||
if (!inFile) {
|
||||
|
@ -217,7 +212,7 @@ namespace Mist {
|
|||
}
|
||||
|
||||
void inputDTSC::getNext(bool smart) {
|
||||
if (streamMode){
|
||||
if (!needsLock()){
|
||||
thisPacket.reInit(srcConn);
|
||||
if (thisPacket.getVersion() == DTSC::DTCM){
|
||||
std::string cmd;
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Mist {
|
|||
class inputDTSC : public Input {
|
||||
public:
|
||||
inputDTSC(Util::Config * cfg);
|
||||
bool needsLock();
|
||||
protected:
|
||||
//Private Functions
|
||||
bool openStreamSource();
|
||||
|
|
Loading…
Add table
Reference in a new issue