Egalized output for both ffprobe and AnalyserDTSC output, also, conversion is now working (though without much status checking)
This commit is contained in:
parent
5f625a89b8
commit
623a30a8b1
2 changed files with 39 additions and 20 deletions
|
@ -102,6 +102,9 @@ namespace Controller {
|
||||||
Log("CONF", std::string("New configuration value ") + jit->first);
|
Log("CONF", std::string("New configuration value ") + jit->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (out["config"]["basepath"].asString()[out["config"]["basepath"].asString().size() - 1] == '/'){
|
||||||
|
out["config"]["basepath"] = out["config"]["basepath"].asString().substr(0, out["config"]["basepath"].asString().size() - 1);
|
||||||
|
}
|
||||||
for (JSON::ObjIter jit = out.ObjBegin(); jit != out.ObjEnd(); jit++){
|
for (JSON::ObjIter jit = out.ObjBegin(); jit != out.ObjEnd(); jit++){
|
||||||
if (jit->first == "version" || jit->first == "time"){
|
if (jit->first == "version" || jit->first == "time"){
|
||||||
continue;
|
continue;
|
||||||
|
@ -215,6 +218,9 @@ int main(int argc, char ** argv){
|
||||||
Controller::Storage["account"][uname]["password"] = Secure::md5(pword);
|
Controller::Storage["account"][uname]["password"] = Secure::md5(pword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( !Controller::Storage["config"].isMember("basePath")){
|
||||||
|
Controller::Storage["config"]["basePath"] = Util::getMyPath();
|
||||||
|
}
|
||||||
|
|
||||||
std::string uplink_addr = conf.getString("uplink");
|
std::string uplink_addr = conf.getString("uplink");
|
||||||
std::string uplink_host = "";
|
std::string uplink_host = "";
|
||||||
|
@ -256,6 +262,7 @@ int main(int argc, char ** argv){
|
||||||
Controller::CheckProtocols(Controller::Storage["config"]["protocols"]);
|
Controller::CheckProtocols(Controller::Storage["config"]["protocols"]);
|
||||||
Controller::CheckAllStreams(Controller::Storage["streams"]);
|
Controller::CheckAllStreams(Controller::Storage["streams"]);
|
||||||
Controller::CheckStats(Controller::Storage["statistics"]);
|
Controller::CheckStats(Controller::Storage["statistics"]);
|
||||||
|
myConverter.updateStatus();
|
||||||
}
|
}
|
||||||
if (uplink_port && Util::epoch() - lastuplink > UPLINK_INTERVAL){
|
if (uplink_port && Util::epoch() - lastuplink > UPLINK_INTERVAL){
|
||||||
lastuplink = Util::epoch();
|
lastuplink = Util::epoch();
|
||||||
|
@ -459,6 +466,24 @@ int main(int argc, char ** argv){
|
||||||
if (Request["conversion"].isMember("encoders")){
|
if (Request["conversion"].isMember("encoders")){
|
||||||
Response["conversion"]["encoders"] = myConverter.getEncoders();
|
Response["conversion"]["encoders"] = myConverter.getEncoders();
|
||||||
}
|
}
|
||||||
|
if (Request["conversion"].isMember("query")){
|
||||||
|
if (Request["conversion"]["query"].isMember("path")){
|
||||||
|
Response["conversion"]["query"] = myConverter.queryPath(Request["conversion"]["query"]["path"].asString());
|
||||||
|
}else{
|
||||||
|
Response["conversion"]["query"] = myConverter.queryPath("./");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Request["conversion"].isMember("convert")){
|
||||||
|
for (JSON::ObjIter it = Request["conversion"]["convert"].ObjBegin(); it != Request["conversion"]["convert"].ObjEnd(); it++){
|
||||||
|
myConverter.startConversion(it->first,it->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Request["conversion"].isMember("status") || Request["conversion"].isMember("convert")){
|
||||||
|
Response["conversion"]["status"] = myConverter.getStatus();
|
||||||
|
if (Request["conversion"].isMember("clear")){
|
||||||
|
myConverter.clearStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (Request.isMember("save")){
|
if (Request.isMember("save")){
|
||||||
Controller::WriteFile(conf.getString("configFile"), Controller::Storage.toString());
|
Controller::WriteFile(conf.getString("configFile"), Controller::Storage.toString());
|
||||||
|
|
28
src/info.cpp
28
src/info.cpp
|
@ -18,7 +18,7 @@ namespace Info {
|
||||||
JSON::Value fileSpecs = F.getMeta();
|
JSON::Value fileSpecs = F.getMeta();
|
||||||
if( !fileSpecs ) {
|
if( !fileSpecs ) {
|
||||||
char ** cmd = (char**)malloc(3*sizeof(char*));
|
char ** cmd = (char**)malloc(3*sizeof(char*));
|
||||||
cmd[0] = "ffprobe";
|
cmd[0] = (char*)"ffprobe";
|
||||||
cmd[1] = argv[1];
|
cmd[1] = argv[1];
|
||||||
cmd[2] = NULL;
|
cmd[2] = NULL;
|
||||||
int outFD = -1;
|
int outFD = -1;
|
||||||
|
@ -30,13 +30,12 @@ namespace Info {
|
||||||
while ( !(feof(outFile) || ferror(outFile)) && (getline(&fileBuf, &fileBufLen, outFile) != -1)){
|
while ( !(feof(outFile) || ferror(outFile)) && (getline(&fileBuf, &fileBufLen, outFile) != -1)){
|
||||||
std::string line = fileBuf;
|
std::string line = fileBuf;
|
||||||
if (line.find("Input") != std::string::npos){
|
if (line.find("Input") != std::string::npos){
|
||||||
std::string tmp = line.substr(line.find("'") + 1);
|
std::string tmp = line.substr(line.find(", ") + 2);
|
||||||
fileSpecs["fileName"] = tmp.substr(0, tmp.find("'"));
|
fileSpecs["format"] = tmp.substr(0, tmp.find(","));
|
||||||
}
|
}
|
||||||
if (line.find("Duration") != std::string::npos){
|
if (line.find("Duration") != std::string::npos){
|
||||||
std::string tmp = line.substr(line.find(": ", line.find("Duration")) + 2);
|
std::string tmp = line.substr(line.find(": ", line.find("Duration")) + 2);
|
||||||
tmp = tmp.substr(0, tmp.find(","));
|
tmp = tmp.substr(0, tmp.find(","));
|
||||||
fileSpecs["duration"] = tmp;
|
|
||||||
int length = (((atoi(tmp.substr(0,2).c_str()) * 60) + atoi(tmp.substr(3,2).c_str())) * 60) + atoi(tmp.substr(6,2).c_str());
|
int length = (((atoi(tmp.substr(0,2).c_str()) * 60) + atoi(tmp.substr(3,2).c_str())) * 60) + atoi(tmp.substr(6,2).c_str());
|
||||||
fileSpecs["length"] = length;
|
fileSpecs["length"] = length;
|
||||||
length *= 100;
|
length *= 100;
|
||||||
|
@ -51,16 +50,10 @@ namespace Info {
|
||||||
std::string tmp = line.substr(line.find(" ", line.find("Stream")) + 1);
|
std::string tmp = line.substr(line.find(" ", line.find("Stream")) + 1);
|
||||||
int strmIdx = fileSpecs["streams"].size();
|
int strmIdx = fileSpecs["streams"].size();
|
||||||
int curPos = 0;
|
int curPos = 0;
|
||||||
fileSpecs["streams"][strmIdx]["name"] = tmp.substr(curPos, tmp.find(": ", curPos) - curPos);
|
|
||||||
curPos = tmp.find(": ", curPos) + 2;
|
curPos = tmp.find(": ", curPos) + 2;
|
||||||
|
|
||||||
//curPos = tmp.find("(", curPos) + 1;
|
|
||||||
//fileSpecs["streams"][strmIdx]["language"] = tmp.substr(curPos, tmp.find(")", curPos) - curPos);
|
|
||||||
//curPos = tmp.find(")", curPos) + 3;
|
|
||||||
|
|
||||||
fileSpecs["streams"][strmIdx]["type"] = tmp.substr(curPos, tmp.find(":", curPos) - curPos);
|
fileSpecs["streams"][strmIdx]["type"] = tmp.substr(curPos, tmp.find(":", curPos) - curPos);
|
||||||
curPos = tmp.find(":", curPos) + 2;
|
curPos = tmp.find(":", curPos) + 2;
|
||||||
fileSpecs["streams"][strmIdx]["codec"] = tmp.substr(curPos, tmp.find(" ", curPos) - curPos);
|
fileSpecs["streams"][strmIdx]["codec"] = tmp.substr(curPos, tmp.find_first_of(", ", curPos) - curPos);
|
||||||
curPos = tmp.find(",", curPos) + 2;
|
curPos = tmp.find(",", curPos) + 2;
|
||||||
if (fileSpecs["streams"][strmIdx]["type"] == "Video"){
|
if (fileSpecs["streams"][strmIdx]["type"] == "Video"){
|
||||||
fileSpecs["streams"][strmIdx]["encoding"] = tmp.substr(curPos, tmp.find(",", curPos) - curPos);
|
fileSpecs["streams"][strmIdx]["encoding"] = tmp.substr(curPos, tmp.find(",", curPos) - curPos);
|
||||||
|
@ -72,12 +65,8 @@ namespace Info {
|
||||||
fileSpecs["streams"][strmIdx]["bps"] = atoi(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str()) * 128;
|
fileSpecs["streams"][strmIdx]["bps"] = atoi(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str()) * 128;
|
||||||
curPos = tmp.find(",", curPos) + 2;
|
curPos = tmp.find(",", curPos) + 2;
|
||||||
fileSpecs["streams"][strmIdx]["fpks"] = (int)(atof(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str()) * 1000);
|
fileSpecs["streams"][strmIdx]["fpks"] = (int)(atof(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str()) * 1000);
|
||||||
curPos = tmp.find(",", curPos) + 2;
|
fileSpecs["streams"][strmIdx].removeMember( "type" );
|
||||||
fileSpecs["streams"][strmIdx]["tbr"] = (int)(atof(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str()) + 0.5);
|
fileSpecs["video"] = fileSpecs["streams"][strmIdx];
|
||||||
curPos = tmp.find(",", curPos) + 2;
|
|
||||||
fileSpecs["streams"][strmIdx]["tbn"] = atoi(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str());
|
|
||||||
curPos = tmp.find(",", curPos) + 2;
|
|
||||||
fileSpecs["streams"][strmIdx]["tbc"] = atoi(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str());
|
|
||||||
}else if (fileSpecs["streams"][strmIdx]["type"] == "Audio"){
|
}else if (fileSpecs["streams"][strmIdx]["type"] == "Audio"){
|
||||||
fileSpecs["streams"][strmIdx]["samplerate"] = atoi(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str());
|
fileSpecs["streams"][strmIdx]["samplerate"] = atoi(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str());
|
||||||
curPos = tmp.find(",", curPos) + 2;
|
curPos = tmp.find(",", curPos) + 2;
|
||||||
|
@ -92,10 +81,15 @@ namespace Info {
|
||||||
fileSpecs["streams"][strmIdx]["samplewidth"] = tmp.substr(curPos, tmp.find(",", curPos) - curPos);
|
fileSpecs["streams"][strmIdx]["samplewidth"] = tmp.substr(curPos, tmp.find(",", curPos) - curPos);
|
||||||
curPos = tmp.find(",", curPos) + 2;
|
curPos = tmp.find(",", curPos) + 2;
|
||||||
fileSpecs["streams"][strmIdx]["bps"] = atoi(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str()) * 128;
|
fileSpecs["streams"][strmIdx]["bps"] = atoi(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str()) * 128;
|
||||||
|
fileSpecs["streams"][strmIdx].removeMember( "type" );
|
||||||
|
fileSpecs["audio"] = fileSpecs["streams"][strmIdx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose( outFile );
|
fclose( outFile );
|
||||||
|
fileSpecs.removeMember( "streams" );
|
||||||
|
} else {
|
||||||
|
fileSpecs["format"] = "dtsc";
|
||||||
}
|
}
|
||||||
if (fileSpecs.isMember("video")){
|
if (fileSpecs.isMember("video")){
|
||||||
fileSpecs["video"].removeMember("init");
|
fileSpecs["video"].removeMember("init");
|
||||||
|
|
Loading…
Add table
Reference in a new issue