Updated Input class with preRun() and checkArguments() instead of single setup() function
This commit is contained in:
parent
169830bd15
commit
45e4cddec9
14 changed files with 36 additions and 21 deletions
|
@ -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){
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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("+ ")));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -183,7 +183,7 @@ namespace Mist {
|
|||
srcConn.close();
|
||||
}
|
||||
|
||||
bool inputDTSC::setup() {
|
||||
bool inputDTSC::checkArguments() {
|
||||
if (!needsLock()) {
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue