Unified all input types into a single flexible type
This commit is contained in:
parent
e352a2fc38
commit
ec240fb1af
4 changed files with 42 additions and 61 deletions
|
@ -322,7 +322,7 @@ makeInput(Buffer buffer)
|
|||
makeInput(ISMV ismv)#LTS
|
||||
makeInput(MP4 mp4)#LTS
|
||||
makeInput(TS ts)#LTS
|
||||
makeInput(Folder folder folder)#LTS
|
||||
makeInput(Folder folder)#LTS
|
||||
|
||||
########################################
|
||||
# MistServer - Outputs #
|
||||
|
|
|
@ -1,19 +1,52 @@
|
|||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <cerrno>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <mist/stream.h>
|
||||
#include <mist/defines.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "input_folder.h"
|
||||
|
||||
namespace Mist {
|
||||
inputFolder::inputFolder(Util::Config * cfg) : Input(cfg) {
|
||||
capa["name"] = "Folder";
|
||||
capa["decs"] = "Folder input, re-starts itself as the appropiate input.";
|
||||
capa["desc"] = "Folder input, re-starts itself as the appropriate input.";
|
||||
capa["source_match"] = "/*/";
|
||||
capa["priority"] = 9ll;
|
||||
capa["morphic"] = 1ll;
|
||||
}
|
||||
|
||||
int inputFolder::boot(int argc, char * argv[]){
|
||||
if (!config->parseArgs(argc, argv)){return 1;}
|
||||
if (config->getBool("json")){return run();}
|
||||
|
||||
streamName = config->getString("streamname");
|
||||
if (streamName.find_first_of("+ ") == std::string::npos){
|
||||
FAIL_MSG("Folder input requires a + or space in the stream name.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string folder = config->getString("input");
|
||||
if (folder[folder.size() - 1] != '/'){
|
||||
FAIL_MSG("Input path must end in a forward slash.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string folder_noslash = folder.substr(0, folder.size() - 1);
|
||||
struct stat fileCheck;
|
||||
if (stat(folder_noslash.c_str(), &fileCheck) != 0 || !S_ISDIR(fileCheck.st_mode)){
|
||||
FAIL_MSG("Folder input requires a folder as input.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string path = folder + streamName.substr(streamName.find_first_of("+ ")+1);
|
||||
if (stat(path.c_str(), &fileCheck) != 0 || S_ISDIR(fileCheck.st_mode)){
|
||||
FAIL_MSG("File not found: %s", path.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
Util::startInput(streamName, path, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Mist {
|
|||
class inputFolder : public Input {
|
||||
public:
|
||||
inputFolder(Util::Config * cfg);
|
||||
int boot(int argc, char * argv[]);
|
||||
protected:
|
||||
bool setup(){return false;};
|
||||
bool readHeader(){return false;};
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#include INPUTTYPE
|
||||
#include <mist/config.h>
|
||||
#include <mist/defines.h>
|
||||
#include <mist/stream.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
Util::Config conf(argv[0]);
|
||||
mistIn conv(&conf);
|
||||
if (conf.parseArgs(argc, argv)) {
|
||||
if (conf.getBool("json")) {
|
||||
conv.run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string strm = conf.getString("streamname");
|
||||
if (strm.find_first_of("+ ") == std::string::npos){
|
||||
FAIL_MSG("Folder input requires a + or space in the stream name.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string folder = conf.getString("input");
|
||||
if (folder[folder.size() - 1] != '/'){
|
||||
FAIL_MSG("Input path must end in a forward slash.");
|
||||
return 1;
|
||||
}
|
||||
std::string folder_noslash = folder.substr(0, folder.size() - 1);
|
||||
struct stat fileCheck;
|
||||
if (stat(folder_noslash.c_str(), &fileCheck) != 0 || !S_ISDIR(fileCheck.st_mode)){
|
||||
FAIL_MSG("Folder input requires a folder as input.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string path = folder + strm.substr(strm.find_first_of("+ ")+1);
|
||||
if (stat(path.c_str(), &fileCheck) != 0 || S_ISDIR(fileCheck.st_mode)){
|
||||
FAIL_MSG("File not found: %s", path.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
Util::startInput(strm, path, false);
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue