From 184f7ad6c84b1ff40a4ddaac172e317e85e9a414 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Thu, 16 Apr 2015 12:21:33 +0200 Subject: [PATCH] Removed old MistInfo binary and dependencies on it. --- CMakeLists.txt | 10 --- src/analysers/info.cpp | 108 -------------------------- src/controller/controller_streams.cpp | 80 +++++++------------ 3 files changed, 28 insertions(+), 170 deletions(-) delete mode 100644 src/analysers/info.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 08a380e2..2aad4e9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,16 +203,6 @@ makeAnalyser(DTSC dtsc) makeAnalyser(AMF amf) makeAnalyser(MP4 mp4) makeAnalyser(OGG ogg) -add_executable(MistInfo - src/analysers/info.cpp -) -target_link_libraries(MistInfo - mist -) -install( - TARGETS MistInfo - DESTINATION bin -) ######################################## # MistServer - Inputs # diff --git a/src/analysers/info.cpp b/src/analysers/info.cpp deleted file mode 100644 index 4b01a9c9..00000000 --- a/src/analysers/info.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace Info { - int getInfo(int argc, char* argv[]) { - if (argc < 2){ - fprintf( stderr, "Usage: %s \n", argv[0] ); - return 1; - } - DTSC::File F(argv[1]); - JSON::Value fileSpecs = F.getMeta().toJSON(); - if( !fileSpecs ) { - char ** cmd = (char**)malloc(3*sizeof(char*)); - cmd[0] = (char*)"ffprobe"; - cmd[1] = argv[1]; - cmd[2] = NULL; - int outFD = -1; - Util::Procs::StartPiped("FFProbe", cmd, 0, 0, &outFD); - while( Util::Procs::isActive("FFProbe")){ Util::sleep(100); } - FILE * outFile = fdopen( outFD, "r" ); - char * fileBuf = 0; - size_t fileBufLen = 0; - 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(", ") + 2); - fileSpecs["format"] = tmp.substr(0, tmp.find(",")); - } - if (line.find("Duration") != std::string::npos){ - std::string tmp = line.substr(line.find(": ", line.find("Duration")) + 2); - tmp = tmp.substr(0, tmp.find(",")); - 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; - length += atoi(tmp.substr(9,2).c_str()); - fileSpecs["lastms"] = length * 10; - } - if (line.find("bitrate") != std::string::npos ){ - std::string tmp = line.substr(line.find(": ", line.find("bitrate")) + 2); - fileSpecs["bps"] = atoi(tmp.substr(0, tmp.find(" ")).c_str()) * 128; - } - if (line.find("Stream") != std::string::npos ){ - std::string tmp = line.substr(line.find(" ", line.find("Stream")) + 1); - int strmIdx = fileSpecs["streams"].size(); - int curPos = 0; - curPos = tmp.find(": ", curPos) + 2; - 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_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); - curPos = tmp.find(",", curPos) + 2; - fileSpecs["streams"][strmIdx]["width"] = atoi(tmp.substr(curPos, tmp.find("x", curPos) - curPos).c_str()); - curPos = tmp.find("x", curPos) + 1; - fileSpecs["streams"][strmIdx]["height"] = atoi(tmp.substr(curPos, tmp.find(",", curPos) - curPos).c_str()); - curPos = tmp.find(",", curPos) + 2; - 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); - 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; - if (tmp.substr(curPos, tmp.find(",", curPos) - curPos) == "stereo"){ - fileSpecs["streams"][strmIdx]["channels"] = 2; - }else if (tmp.substr(curPos, tmp.find(",", curPos) - curPos) == "mono"){ - fileSpecs["streams"][strmIdx]["channels"] = 1; - }else{ - fileSpecs["streams"][strmIdx]["channels"] = tmp.substr(curPos, tmp.find(",", curPos) - curPos); - } - curPos = tmp.find(",", curPos) + 2; - 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"; - JSON::Value tracks = fileSpecs["tracks"]; - for(JSON::ObjIter trackIt = tracks.ObjBegin(); trackIt != tracks.ObjEnd(); trackIt++){ - fileSpecs["tracks"][trackIt->first].removeMember("fragments"); - fileSpecs["tracks"][trackIt->first].removeMember("keys"); - fileSpecs["tracks"][trackIt->first].removeMember("keysizes"); - fileSpecs["tracks"][trackIt->first].removeMember("parts"); - } - } - printf( "%s", fileSpecs.toString().c_str() ); - return 0; - } -} - -int main(int argc, char* argv[]) { - return Info::getInfo(argc, argv); -} diff --git a/src/controller/controller_streams.cpp b/src/controller/controller_streams.cpp index 3ea14fc2..f7d42e20 100644 --- a/src/controller/controller_streams.cpp +++ b/src/controller/controller_streams.cpp @@ -125,60 +125,35 @@ namespace Controller { // if the file isn't dtsc and there's no dtsh file, run getStream on it // this guarantees that if the stream is playable, it now has a valid header. DEBUG_MSG(DLVL_INSANE, "(re)loading metadata for stream %s", name.c_str()); - if ((URL.substr(URL.size() - 5) != ".dtsc") && (stat((URL+".dtsh").c_str(), &fileinfo) != 0)){ - DEBUG_MSG(DLVL_INSANE, "Stream %s is non-DTSC file without DTSH. Opening stream to generate DTSH...", name.c_str()); - Util::startInput(name); - DEBUG_MSG(DLVL_INSANE, "Waiting for stream %s to open...", name.c_str()); - //wait for the stream - { - char streamPageName[NAME_BUFFER_SIZE]; - snprintf(streamPageName, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, name.c_str()); - IPC::sharedPage streamIndex(streamPageName, DEFAULT_META_PAGE_SIZE, false, false); - if (!streamIndex.mapped){ - DEBUG_MSG(DLVL_INSANE, "Stream %s opening failed! Cancelling and marking as corrupt.", name.c_str()); - data["meta"].null(); - data["meta"]["tracks"].null(); - data["error"] = "Stream offline: Corrupt file?"; - if (data["error"].asStringRef() != prevState){ - Log("WARN", "Source file " + URL + " seems to be corrupt."); - } - data["online"] = 0; - return; + Util::startInput(name); + DEBUG_MSG(DLVL_INSANE, "Waiting for stream %s to open...", name.c_str()); + //wait for the stream + { + char streamPageName[NAME_BUFFER_SIZE]; + snprintf(streamPageName, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, name.c_str()); + IPC::sharedPage streamIndex(streamPageName, DEFAULT_META_PAGE_SIZE, false, false); + if (!streamIndex.mapped){ + DEBUG_MSG(DLVL_INSANE, "Stream %s opening failed! Cancelling and marking as corrupt.", name.c_str()); + data["meta"].null(); + data["meta"]["tracks"].null(); + data["error"] = "Stream offline: Corrupt file?"; + if (data["error"].asStringRef() != prevState){ + Log("WARN", "Source file " + URL + " seems to be corrupt."); } - unsigned int i = 0; - JSON::fromDTMI((const unsigned char*)streamIndex.mapped + 8, streamIndex.len - 8, i, data["meta"]); - if (data["meta"].isMember("tracks") && data["meta"]["tracks"].size()){ - for(JSON::ObjIter trackIt = data["meta"]["tracks"].ObjBegin(); trackIt != data["meta"]["tracks"].ObjEnd(); trackIt++){ - trackIt->second.removeMember("fragments"); - trackIt->second.removeMember("keys"); - trackIt->second.removeMember("keysizes"); - trackIt->second.removeMember("parts"); - trackIt->second.removeMember("ivecs");/*LTS*/ - } - } - if ( !data["meta"] || !data["meta"].isMember("tracks") || !data["meta"]["tracks"]){ - data["error"] = "Stream offline: Corrupt file?"; - if (data["error"].asStringRef() != prevState){ - Log("WARN", "Source file " + URL + " seems to be corrupt."); - } - data["online"] = 0; - return; - } - DEBUG_MSG(DLVL_INSANE, "Metadata for stream %s (re)loaded", name.c_str()); + data["online"] = 0; + return; } - DEBUG_MSG(DLVL_INSANE, "Stream %s opened", name.c_str()); - }else{ - //now, run mistinfo on the source - or on the accompanying dtsh file, if it exists - if (stat((URL+".dtsh").c_str(), &fileinfo) == 0){ - DEBUG_MSG(DLVL_INSANE, "Stream %s has a DTSH - opening DTSH instead of main stream file", name.c_str()); - URL += ".dtsh"; + unsigned int i = 0; + JSON::fromDTMI((const unsigned char*)streamIndex.mapped + 8, streamIndex.len - 8, i, data["meta"]); + if (data["meta"].isMember("tracks") && data["meta"]["tracks"].size()){ + for(JSON::ObjIter trackIt = data["meta"]["tracks"].ObjBegin(); trackIt != data["meta"]["tracks"].ObjEnd(); trackIt++){ + trackIt->second.removeMember("fragments"); + trackIt->second.removeMember("keys"); + trackIt->second.removeMember("keysizes"); + trackIt->second.removeMember("parts"); + trackIt->second.removeMember("ivecs"); + } } - char * tmp_cmd[3] = {0, 0, 0}; - std::string mistinfo = Util::getMyPath() + "MistInfo"; - tmp_cmd[0] = (char*)mistinfo.c_str(); - tmp_cmd[1] = (char*)URL.c_str(); - DEBUG_MSG(DLVL_INSANE, "Running MistInfo for stream %s on file %s", name.c_str(), tmp_cmd[1]); - data["meta"] = JSON::fromString(Util::Procs::getOutputOf(tmp_cmd)); if ( !data["meta"] || !data["meta"].isMember("tracks") || !data["meta"]["tracks"]){ data["error"] = "Stream offline: Corrupt file?"; if (data["error"].asStringRef() != prevState){ @@ -187,8 +162,9 @@ namespace Controller { data["online"] = 0; return; } - DEBUG_MSG(DLVL_INSANE, "Metadata for stream %s succesfully (re)loaded", name.c_str()); + DEBUG_MSG(DLVL_INSANE, "Metadata for stream %s (re)loaded", name.c_str()); } + DEBUG_MSG(DLVL_INSANE, "Stream %s opened", name.c_str()); } if (!hasViewers(name)){ if ( !data.isMember("error")){