diff --git a/src/input/input.cpp b/src/input/input.cpp index b991cae3..f6833e40 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -100,7 +100,7 @@ namespace Mist { return 0; } - if (!setup()) { + if (!checkArguments()) { FAIL_MSG("Setup failed - exiting"); return 0; } @@ -125,6 +125,7 @@ namespace Mist { pid_t pid = fork(); if (pid == 0){ if (needsLock()){playerLock.close();} + if (!preRun()){return 0;} return run(); } if (pid == -1){ diff --git a/src/input/input.h b/src/input/input.h index de117e83..e274e086 100644 --- a/src/input/input.h +++ b/src/input/input.h @@ -27,17 +27,18 @@ namespace Mist { virtual bool needsLock(){return true;} protected: static void callbackWrapper(char * data, size_t len, unsigned int id); - virtual bool setup() = 0; + virtual bool checkArguments() = 0; virtual bool readHeader() = 0; + virtual bool preRun(){return true;} virtual bool readExistingHeader(); virtual bool atKeyFrame(); - virtual void getNext(bool smart = true) {}; + virtual void getNext(bool smart = true) {} virtual void seek(int seekTime){}; virtual void finish(); virtual bool keepRunning(); - virtual bool openStreamSource() { return false; }; - virtual void closeStreamSource() {}; - virtual void parseStreamHeader() {}; + virtual bool openStreamSource() { return false; } + virtual void closeStreamSource() {} + virtual void parseStreamHeader() {} void play(int until = 0); void playOnce(); void quitPlay(); diff --git a/src/input/input_buffer.cpp b/src/input/input_buffer.cpp index 53a714cc..ff6c6272 100644 --- a/src/input/input_buffer.cpp +++ b/src/input/input_buffer.cpp @@ -720,7 +720,7 @@ namespace Mist { } } - bool inputBuffer::setup() { + bool inputBuffer::preRun() { std::string strName = config->getString("streamname"); Util::sanitizeName(strName); strName = strName.substr(0, (strName.find_first_of("+ "))); diff --git a/src/input/input_buffer.h b/src/input/input_buffer.h index 21ff4446..96cc8898 100644 --- a/src/input/input_buffer.h +++ b/src/input/input_buffer.h @@ -16,7 +16,8 @@ namespace Mist { IPC::semaphore * liveMeta; protected: //Private Functions - bool setup(); + bool preRun(); + bool checkArguments(){return true;} void updateMeta(); bool readHeader(); void getNext(bool smart = true); diff --git a/src/input/input_dtsc.cpp b/src/input/input_dtsc.cpp index 5cd5e52a..7836487e 100644 --- a/src/input/input_dtsc.cpp +++ b/src/input/input_dtsc.cpp @@ -183,7 +183,7 @@ namespace Mist { srcConn.close(); } - bool inputDTSC::setup() { + bool inputDTSC::checkArguments() { if (!needsLock()) { return true; } else { diff --git a/src/input/input_dtsc.h b/src/input/input_dtsc.h index 8d1e5991..496d6b5a 100644 --- a/src/input/input_dtsc.h +++ b/src/input/input_dtsc.h @@ -11,7 +11,7 @@ namespace Mist { bool openStreamSource(); void closeStreamSource(); void parseStreamHeader(); - bool setup(); + bool checkArguments(); bool readHeader(); void getNext(bool smart = true); void seek(int seekTime); diff --git a/src/input/input_flv.cpp b/src/input/input_flv.cpp index 01163471..a60f3b60 100644 --- a/src/input/input_flv.cpp +++ b/src/input/input_flv.cpp @@ -27,7 +27,7 @@ namespace Mist { capa["codecs"][0u][1u].append("MP3"); } - bool inputFLV::setup() { + bool inputFLV::checkArguments() { if (config->getString("input") == "-") { std::cerr << "Input from stdin not yet supported" << std::endl; return false; @@ -43,7 +43,10 @@ namespace Mist { return false; } } + return true; + } + bool inputFLV::preRun() { //open File inFile = fopen(config->getString("input").c_str(), "r"); if (!inFile) { diff --git a/src/input/input_flv.h b/src/input/input_flv.h index d2c438f1..8d36d0db 100644 --- a/src/input/input_flv.h +++ b/src/input/input_flv.h @@ -8,7 +8,8 @@ namespace Mist { inputFLV(Util::Config * cfg); protected: //Private Functions - bool setup(); + bool checkArguments(); + bool preRun(); bool readHeader(); void getNext(bool smart = true); void seek(int seekTime); diff --git a/src/input/input_h264.cpp b/src/input/input_h264.cpp index 0068008d..eb3995b1 100644 --- a/src/input/input_h264.cpp +++ b/src/input/input_h264.cpp @@ -16,7 +16,7 @@ namespace Mist{ inputProcess = 0; } - int InputH264::run(){ + bool InputH264::preRun(){ if (config->getString("input") != "-"){ std::string input = config->getString("input"); const char *argv[2]; @@ -55,10 +55,10 @@ namespace Mist{ myMeta.tracks[1].codec = "H264"; myMeta.tracks[1].trackID = 1; waitsSinceData = 0; - return Input::run(); + return true; } - bool InputH264::setup(){ + bool InputH264::checkArguments(){ std::string input = config->getString("input"); if (input != "-" && input.substr(0, 10) != "h264-exec:"){ FAIL_MSG("Unsupported input type: %s", input.c_str()); diff --git a/src/input/input_h264.h b/src/input/input_h264.h index 7b2f7b3c..43956314 100644 --- a/src/input/input_h264.h +++ b/src/input/input_h264.h @@ -6,10 +6,10 @@ namespace Mist{ class InputH264 : public Input{ public: InputH264(Util::Config *cfg); - int run(); protected: - bool setup(); + bool checkArguments(); + bool preRun(); void getNext(bool smart = true); Socket::Connection myConn; std::string ppsInfo; diff --git a/src/input/input_mp3.cpp b/src/input/input_mp3.cpp index c59c924e..ebeb89ef 100644 --- a/src/input/input_mp3.cpp +++ b/src/input/input_mp3.cpp @@ -21,7 +21,7 @@ namespace Mist { timestamp = 0; } - bool inputMP3::setup() { + bool inputMP3::checkArguments() { if (config->getString("input") == "-") { std::cerr << "Input from stdin not yet supported" << std::endl; return false; @@ -37,7 +37,10 @@ namespace Mist { return false; } } + return true; + } + bool inputMP3::preRun() { //open File inFile = fopen(config->getString("input").c_str(), "r"); if (!inFile) { diff --git a/src/input/input_mp3.h b/src/input/input_mp3.h index bd2afa1d..14bc7e4f 100644 --- a/src/input/input_mp3.h +++ b/src/input/input_mp3.h @@ -16,7 +16,8 @@ namespace Mist { inputMP3(Util::Config * cfg); protected: //Private Functions - bool setup(); + bool checkArguments(); + bool preRun(); bool readHeader(); void getNext(bool smart = true); void seek(int seekTime); diff --git a/src/input/input_ogg.cpp b/src/input/input_ogg.cpp index 56a364ce..9725cccf 100644 --- a/src/input/input_ogg.cpp +++ b/src/input/input_ogg.cpp @@ -53,12 +53,15 @@ namespace Mist { capa["codecs"][0u][1u].append("opus"); } - bool inputOGG::setup(){ + bool inputOGG::checkArguments(){ if (config->getString("input") == "-"){ std::cerr << "Input from stream not yet supported" << std::endl; return false; } + return true; + } + bool inputOGG::preRun(){ //open File inFile = fopen(config->getString("input").c_str(), "r"); if (!inFile){ diff --git a/src/input/input_ogg.h b/src/input/input_ogg.h index 2d9960d6..c03b11b0 100644 --- a/src/input/input_ogg.h +++ b/src/input/input_ogg.h @@ -70,7 +70,8 @@ namespace Mist { inputOGG(Util::Config * cfg); protected: //Private Functions - bool setup(); + bool checkArguments(); + bool preRun(); bool readHeader(); position seekFirstData(long long unsigned int tid); void getNext(bool smart = true);