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
|
//check in curConf for capabilities-inputs-<naam>-priority/source_match
|
||||||
std::string player_bin;
|
std::string player_bin;
|
||||||
bool pullMode = false;
|
|
||||||
bool selected = false;
|
bool selected = false;
|
||||||
long long int curPrio = -1;
|
long long int curPrio = -1;
|
||||||
DTSC::Scan inputs = config.getMember("capabilities").getMember("inputs");
|
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);
|
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 (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 source = 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);
|
||||||
|
@ -225,20 +238,8 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
||||||
curPrio = input.getMember("priority").asInt();
|
curPrio = input.getMember("priority").asInt();
|
||||||
selected = true;
|
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
|
//finally, unlock the config semaphore
|
||||||
configLock.post();
|
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());
|
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()};
|
char * argv[30] = {(char *)player_bin.c_str(), (char *)"-s", (char *)streamname.c_str(), (char *)filename.c_str()};
|
||||||
int argNum = 3;
|
int argNum = 3;
|
||||||
if (pullMode){
|
|
||||||
argv[++argNum] = (char*)"--pull";
|
|
||||||
}
|
|
||||||
std::string debugLvl;
|
std::string debugLvl;
|
||||||
if (Util::Config::printDebugLevel != DEBUG && !str_args.count("--debug")){
|
if (Util::Config::printDebugLevel != DEBUG && !str_args.count("--debug")){
|
||||||
debugLvl = JSON::Value((long long)Util::Config::printDebugLevel).asString();
|
debugLvl = JSON::Value((long long)Util::Config::printDebugLevel).asString();
|
||||||
|
|
|
@ -83,7 +83,6 @@ namespace Mist {
|
||||||
|
|
||||||
singleton = this;
|
singleton = this;
|
||||||
isBuffer = false;
|
isBuffer = false;
|
||||||
streamMode = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::checkHeaderTimes(std::string streamFile) {
|
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() {
|
int Input::run() {
|
||||||
if (config->getBool("json")) {
|
if (config->getBool("json")) {
|
||||||
std::cout << capa.toString() << std::endl;
|
std::cout << capa.toString() << std::endl;
|
||||||
|
@ -132,11 +127,6 @@ namespace Mist {
|
||||||
streamName = config->getString("streamname");
|
streamName = config->getString("streamname");
|
||||||
nProxy.streamName = 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()) {
|
if (!setup()) {
|
||||||
std::cerr << config->getString("cmd") << " setup failed." << std::endl;
|
std::cerr << config->getString("cmd") << " setup failed." << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -151,7 +141,7 @@ namespace Mist {
|
||||||
|
|
||||||
if (!streamName.size()) {
|
if (!streamName.size()) {
|
||||||
convert();
|
convert();
|
||||||
} else if (streamMode) {
|
} else if (!needsLock()) {
|
||||||
stream();
|
stream();
|
||||||
}else{
|
}else{
|
||||||
serve();
|
serve();
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Mist {
|
||||||
virtual void argumentsParsed(){}
|
virtual void argumentsParsed(){}
|
||||||
virtual ~Input() {};
|
virtual ~Input() {};
|
||||||
|
|
||||||
virtual bool needsLock();
|
virtual bool needsLock(){return true;}
|
||||||
protected:
|
protected:
|
||||||
static void callbackWrapper(char * data, size_t len, unsigned int id);
|
static void callbackWrapper(char * data, size_t len, unsigned int id);
|
||||||
virtual bool setup() = 0;
|
virtual bool setup() = 0;
|
||||||
|
@ -46,7 +46,6 @@ namespace Mist {
|
||||||
virtual void convert();
|
virtual void convert();
|
||||||
virtual void serve();
|
virtual void serve();
|
||||||
virtual void stream();
|
virtual void stream();
|
||||||
bool streamMode;
|
|
||||||
|
|
||||||
|
|
||||||
virtual void parseHeader();
|
virtual void parseHeader();
|
||||||
|
|
|
@ -17,8 +17,8 @@ namespace Mist {
|
||||||
capa["name"] = "DTSC";
|
capa["name"] = "DTSC";
|
||||||
capa["desc"] = "Enables DTSC Input";
|
capa["desc"] = "Enables DTSC Input";
|
||||||
capa["priority"] = 9ll;
|
capa["priority"] = 9ll;
|
||||||
capa["source_match"] = "/*.dtsc";
|
capa["source_match"].append("/*.dtsc");
|
||||||
capa["stream_match"] = "dtsc://*";
|
capa["source_match"].append("dtsc://*");
|
||||||
capa["codecs"][0u][0u].append("H264");
|
capa["codecs"][0u][0u].append("H264");
|
||||||
capa["codecs"][0u][0u].append("H263");
|
capa["codecs"][0u][0u].append("H263");
|
||||||
capa["codecs"][0u][0u].append("VP6");
|
capa["codecs"][0u][0u].append("VP6");
|
||||||
|
@ -26,16 +26,11 @@ namespace Mist {
|
||||||
capa["codecs"][0u][1u].append("AAC");
|
capa["codecs"][0u][1u].append("AAC");
|
||||||
capa["codecs"][0u][1u].append("MP3");
|
capa["codecs"][0u][1u].append("MP3");
|
||||||
capa["codecs"][0u][1u].append("vorbis");
|
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) {
|
void parseDTSCURI(const std::string & src, std::string & host, uint16_t & port, std::string & password, std::string & streamName) {
|
||||||
host = "";
|
host = "";
|
||||||
|
@ -166,7 +161,7 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inputDTSC::setup() {
|
bool inputDTSC::setup() {
|
||||||
if (streamMode) {
|
if (!needsLock()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (config->getString("input") == "-") {
|
if (config->getString("input") == "-") {
|
||||||
|
@ -195,7 +190,7 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inputDTSC::readHeader() {
|
bool inputDTSC::readHeader() {
|
||||||
if (streamMode) {
|
if (!needsLock()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!inFile) {
|
if (!inFile) {
|
||||||
|
@ -217,7 +212,7 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputDTSC::getNext(bool smart) {
|
void inputDTSC::getNext(bool smart) {
|
||||||
if (streamMode){
|
if (!needsLock()){
|
||||||
thisPacket.reInit(srcConn);
|
thisPacket.reInit(srcConn);
|
||||||
if (thisPacket.getVersion() == DTSC::DTCM){
|
if (thisPacket.getVersion() == DTSC::DTCM){
|
||||||
std::string cmd;
|
std::string cmd;
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace Mist {
|
||||||
class inputDTSC : public Input {
|
class inputDTSC : public Input {
|
||||||
public:
|
public:
|
||||||
inputDTSC(Util::Config * cfg);
|
inputDTSC(Util::Config * cfg);
|
||||||
|
bool needsLock();
|
||||||
protected:
|
protected:
|
||||||
//Private Functions
|
//Private Functions
|
||||||
bool openStreamSource();
|
bool openStreamSource();
|
||||||
|
|
Loading…
Add table
Reference in a new issue