Egalized output for both ffprobe and AnalyserDTSC output, also, conversion is now working (though without much status checking)

This commit is contained in:
Erik Zandvliet 2013-03-06 11:51:47 +01:00 committed by Thulinma
parent 5f625a89b8
commit 623a30a8b1
2 changed files with 39 additions and 20 deletions

View file

@ -102,6 +102,9 @@ namespace Controller {
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++){
if (jit->first == "version" || jit->first == "time"){
continue;
@ -215,6 +218,9 @@ int main(int argc, char ** argv){
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_host = "";
@ -256,6 +262,7 @@ int main(int argc, char ** argv){
Controller::CheckProtocols(Controller::Storage["config"]["protocols"]);
Controller::CheckAllStreams(Controller::Storage["streams"]);
Controller::CheckStats(Controller::Storage["statistics"]);
myConverter.updateStatus();
}
if (uplink_port && Util::epoch() - lastuplink > UPLINK_INTERVAL){
lastuplink = Util::epoch();
@ -456,9 +463,27 @@ int main(int argc, char ** argv){
Controller::checkCapable(Response["capabilities"]);
}
if (Request.isMember("conversion")){
if (Request["conversion"].isMember("encoders")) {
if (Request["conversion"].isMember("encoders")){
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")){
Controller::WriteFile(conf.getString("configFile"), Controller::Storage.toString());

View file

@ -18,7 +18,7 @@ namespace Info {
JSON::Value fileSpecs = F.getMeta();
if( !fileSpecs ) {
char ** cmd = (char**)malloc(3*sizeof(char*));
cmd[0] = "ffprobe";
cmd[0] = (char*)"ffprobe";
cmd[1] = argv[1];
cmd[2] = NULL;
int outFD = -1;
@ -30,13 +30,12 @@ namespace Info {
while ( !(feof(outFile) || ferror(outFile)) && (getline(&fileBuf, &fileBufLen, outFile) != -1)){
std::string line = fileBuf;
if (line.find("Input") != std::string::npos){
std::string tmp = line.substr(line.find("'") + 1);
fileSpecs["fileName"] = tmp.substr(0, tmp.find("'"));
std::string tmp = line.substr(line.find(", ") + 2);
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);
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());
fileSpecs["length"] = length;
length *= 100;
@ -51,16 +50,10 @@ namespace Info {
std::string tmp = line.substr(line.find(" ", line.find("Stream")) + 1);
int strmIdx = fileSpecs["streams"].size();
int curPos = 0;
fileSpecs["streams"][strmIdx]["name"] = tmp.substr(curPos, tmp.find(": ", curPos) - curPos);
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);
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;
if (fileSpecs["streams"][strmIdx]["type"] == "Video"){
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;
curPos = tmp.find(",", curPos) + 2;
fileSpecs["streams"][strmIdx]["fpks"] = (int)(atof(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str()) * 1000);
curPos = tmp.find(",", curPos) + 2;
fileSpecs["streams"][strmIdx]["tbr"] = (int)(atof(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str()) + 0.5);
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());
fileSpecs["streams"][strmIdx].removeMember( "type" );
fileSpecs["video"] = fileSpecs["streams"][strmIdx];
}else if (fileSpecs["streams"][strmIdx]["type"] == "Audio"){
fileSpecs["streams"][strmIdx]["samplerate"] = atoi(tmp.substr(curPos, tmp.find(" ", curPos) - curPos).c_str());
curPos = tmp.find(",", curPos) + 2;
@ -92,10 +81,15 @@ namespace Info {
fileSpecs["streams"][strmIdx]["samplewidth"] = tmp.substr(curPos, tmp.find(",", curPos) - curPos);
curPos = tmp.find(",", curPos) + 2;
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 );
fileSpecs.removeMember( "streams" );
} else {
fileSpecs["format"] = "dtsc";
}
if (fileSpecs.isMember("video")){
fileSpecs["video"].removeMember("init");