From bce0cda879b3b8ef69106941963258fd942a8927 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Thu, 20 Oct 2011 22:02:45 +0200 Subject: [PATCH] Cleanup --- Admin/data_collect.cpp | 276 ------------------ Admin/preset | 10 - PLS | 27 -- {ABST_Parser => tools/ABST_Parser}/Makefile | 0 {ABST_Parser => tools/ABST_Parser}/main.cpp | 2 +- {AMF_Tester => tools/AMF_Tester}/Makefile | 2 +- {AMF_Tester => tools/AMF_Tester}/main.cpp | 2 +- .../HTTP_Box_Parser}/Makefile | 2 +- .../HTTP_Box_Parser}/main.cpp | 6 +- {RTMP_Parser => tools/RTMP_Parser}/Makefile | 2 +- {RTMP_Parser => tools/RTMP_Parser}/main.cpp | 6 +- {RTP_Parser => tools/RTP_Parser}/main.cpp | 0 {TS_Analyser => tools/TS_Analyser}/main.cpp | 0 {spawntest => tools/spawntest}/Makefile | 2 +- {spawntest => tools/spawntest}/main.cpp | 2 +- {spawntest => tools/spawntest}/test.sh | 0 {spawntest => tools/spawntest}/testpipein.sh | 0 {spawntest => tools/spawntest}/testpipeout.sh | 0 18 files changed, 13 insertions(+), 326 deletions(-) delete mode 100644 Admin/data_collect.cpp delete mode 100644 Admin/preset delete mode 100644 PLS rename {ABST_Parser => tools/ABST_Parser}/Makefile (100%) rename {ABST_Parser => tools/ABST_Parser}/main.cpp (99%) rename {AMF_Tester => tools/AMF_Tester}/Makefile (91%) rename {AMF_Tester => tools/AMF_Tester}/main.cpp (96%) rename {HTTP_Box_Parser => tools/HTTP_Box_Parser}/Makefile (80%) rename {HTTP_Box_Parser => tools/HTTP_Box_Parser}/main.cpp (95%) rename {RTMP_Parser => tools/RTMP_Parser}/Makefile (74%) rename {RTMP_Parser => tools/RTMP_Parser}/main.cpp (98%) rename {RTP_Parser => tools/RTP_Parser}/main.cpp (100%) rename {TS_Analyser => tools/TS_Analyser}/main.cpp (100%) rename {spawntest => tools/spawntest}/Makefile (92%) rename {spawntest => tools/spawntest}/main.cpp (94%) rename {spawntest => tools/spawntest}/test.sh (100%) rename {spawntest => tools/spawntest}/testpipein.sh (100%) rename {spawntest => tools/spawntest}/testpipeout.sh (100%) diff --git a/Admin/data_collect.cpp b/Admin/data_collect.cpp deleted file mode 100644 index c0e7ec6b..00000000 --- a/Admin/data_collect.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/// \file Admin/main.cpp -/// Attempted administration tool for DDVTECH Clients. -/// Never finished - perhaps now obsolete...? -/// \todo This could serve as a basis for a new, more robust, control method for gearbox / the API. - -#include -#include -#include -#include -#include -#include -#include - -int getparam (std::string input) { - if(input.size() <= 3) { return -1;} - int result = 0; - for (int i = 3; i < input.size(); i++) { - if ( input[i] < '0' || input[i] > '9') { return -2; } - result = result * 10; - result += input[i] - '0'; - } - return result; -} - -std::string getstringparam(std::string input) { - std::string result; - for (int i = 3; i < input.size(); i++) { - result.push_back(input[i]); - } - return result; -} - -void GetThroughPut(int * Down, int * Up){ - //deze file bevat o.a. totaal bytes verstuurd/ontvangen sinds de interface up ging, voor alle interfaces. - //voor een snelheidsmeting moet je dus 2X lezen en het verschil gebruiken... - std::ifstream netdev ("/proc/net/dev"); - std::string line; - int tmpDown, tmpUp; - int ret = 0; - *Down = 0; - *Up = 0; - while (netdev.good()){ - getline(netdev, line); - //probeer een geldige interface te parsen - 2 = 2 matches, en dus goed geparsed. - ret = sscanf(line.c_str(), " %*[^:]: %i %*i %*i %*i %*i %*i %*i %*i %i %*i %*i %*i %*i %*i %*i %*i", &tmpDown, &tmpUp); - if (ret == 2){*Down += tmpDown;*Up += tmpUp;} - } - netdev.close(); -}//GetThroughPut - -std::string MeasureThroughPut(){ - std::stringstream output; - int frstDown, frstUp; - int totDown, totUp; - GetThroughPut(&frstDown, &frstUp); - sleep(5); - GetThroughPut(&totDown, &totUp); - //return totaal bytes down, up, gemiddelde bytes per seconde over de afgelopen 5 secs down, up. - output << "BYTES=" << totDown + totUp << " BYTES_D=" << ((totDown - frstDown)/5) + ((totUp - frstUp)/5); - return output.str(); -}//MeasureThroughPut - -std::string GetConnectedUsers(){ - std::string output; - //laat ps aux de processen Client_PLS opvragen, zonder de grep zelf, en tel het aantal lines. - system("ps aux | grep Client_PLS | grep -v grep | wc -l > ./tmpfile"); - //lees de file, en return de inhoud - std::ifstream tmpfile ("./tmpfile"); - tmpfile >> output; - tmpfile.close(); - return output; -}//GetConnectedUsers - -std::string GetStreamAmount(){ - std::string output; - //laat ps aux de processen Buffer opvragen, zonder de grep zelf, en tel het aantal lines. - system("ps aux | grep Buffer | grep -v grep | wc -l > ./tmpfile"); - //lees de file, en return de inhoud - std::ifstream tmpfile ("./tmpfile"); - tmpfile >> output; - tmpfile.close(); - return output; -}//GetStreamAmount - -void readpreset( unsigned int values[], std::string & filename ) { - std::ifstream presetfile ("preset"); - presetfile >> filename; - for (int i = 0; i < 9; i++ ) { presetfile >> values[i]; } - presetfile.close(); -} - -void writepreset( unsigned int values[], std::string filename ) { - std::ofstream presetfile ("preset"); - presetfile << filename; - for (int i = 0; i < 9; i++ ) { - presetfile << values[i]; - presetfile << "\n"; - } - presetfile.close(); -} - -void writesh( unsigned int values[], std::string filename ) { - std::ofstream shfile ("run.sh"); - shfile << "ffmpeg -i " << filename << " -f flv -re "; - if (values[0] != 0 && values[1] != 0) { shfile << "-s " << values[0] << "x" << values[1] << " "; } - if (values[2] != 0) { shfile << "-b " << values[2] << " "; } - if (values[3] != 0) { shfile << "-gop " << values[3] << " "; } - if (values[4] != 0) { shfile << "-r " << values[4] << " "; } - if (values[5] != 0) { shfile << "-ab " << values[5] << " "; } - if (values[6] != 0) { shfile << "-ar " << values[6] << " "; } - shfile << "rtmp://projectlivestream.com/oflaDemo/test &"; - shfile.close(); - system("sh ./run.sh"); -} - - -int main( ) { - std::cout << "USERS=" << GetConnectedUsers( ) << " "; - std::cout << MeasureThroughPut( ) << " "; - std::cout << "STREAMS=" << GetStreamAmount( ) << " "; -} - - -/* -- OLD Main, wss doen we hier niets meer mee -- -int main() { - unsigned int values[9]; - std::string inputcommand = ""; - bool connection = true; - int tempresult; - std::string filename = ""; - readpreset(values, filename); - while (connection) { - std::cin >> inputcommand; - switch (inputcommand[0]) { - case 'G': - switch (inputcommand[1]) { - case 'S': - switch(inputcommand[2]) { - case 'H': std::cout << "OK" << values[0] << "\n"; break; - case 'W': std::cout << "OK" << values[1] << "\n"; break; - default: std::cout << "ER\n"; break; - } - break; - case 'V': - switch(inputcommand[2]) { - case 'B': std::cout << "OK" << values[2] << "\n"; break; - case 'G': std::cout << "OK" << values[3] << "\n"; break; - case 'R': std::cout << "OK" << values[4] << "\n"; break; - default: std::cout << "ER\n"; break; - } - break; - case 'A': - switch(inputcommand[2]) { - case 'B': std::cout << "OK" << values[5] << "\n"; break; - case 'R': std::cout << "OK" << values[6] << "\n"; break; - default: std::cout << "ER\n"; break; - } - break; - case 'U': - switch(inputcommand[2]) { - case 'F': std::cout << "OK" << values[7] << "\n"; break; - case 'P': std::cout << "OK" << values[8] << "\n"; break; - case 'C': std::cout << "OK" << GetConnectedUsers() << "\n"; break; - default: std::cout << "ER\n"; break; - } - break; - case 'F': - switch(inputcommand[2]) { - case 'N': std::cout << "OK" << filename << "\n"; break; - default: std::cout << "ER\n"; break; - } - break; - case 'G': - switch(inputcommand[2]) { - case 'T': std::cout << "OK" << MeasureThroughPut() << "\n"; break; - default: std::cout << "ER\n"; break; - } - break; - default: std::cout << "ER\n"; break; - } - break; - case 'S': - switch (inputcommand[1]) { - case 'S': - switch(inputcommand[2]) { - case 'H': - tempresult = getparam(inputcommand); - if (tempresult < 0) { std::cout << "ER\n"; } else { values[0] = tempresult; std::cout << "OK\n"; } - break; - case 'W': - tempresult = getparam(inputcommand); - tempresult = getparam(inputcommand); - if (tempresult < 0) { std::cout << "ER\n"; } else { values[1] = tempresult; std::cout << "OK\n"; } - break; - default: std::cout << "ER\n"; break; - } - break; - case 'V': - switch(inputcommand[2]) { - case 'B': - tempresult = getparam(inputcommand); - if (tempresult < 0) { std::cout << "ER\n"; } else { values[2] = tempresult; std::cout << "OK\n"; } - break; - case 'G': - tempresult = getparam(inputcommand); - if (tempresult < 0) { std::cout << "ER\n"; } else { values[3] = tempresult; std::cout << "OK\n"; } - break; - case 'R': - tempresult = getparam(inputcommand); - if (tempresult < 0) { std::cout << "ER\n"; } else { values[4] = tempresult; std::cout << "OK\n"; } - break; - default: std::cout << "ER\n"; break; - } - break; - case 'A': - switch(inputcommand[2]) { - case 'B': - tempresult = getparam(inputcommand); - if (tempresult < 0) { std::cout << "ER\n"; } else { values[5] = tempresult; std::cout << "OK\n"; } - break; - case 'R': - tempresult = getparam(inputcommand); - if (tempresult < 0) { std::cout << "ER\n"; } else { values[6] = tempresult; std::cout << "OK\n"; } - break; - default: std::cout << "ER\n"; break; - } - break; - case 'U': - switch(inputcommand[2]) { - case 'F': - tempresult = getparam(inputcommand); - if (tempresult < 0) { std::cout << "ER\n"; } else { values[7] = tempresult; std::cout << "OK\n"; } - break; - case 'P': - tempresult = getparam(inputcommand); - if (tempresult < 0) { std::cout << "ER\n"; } else { values[8] = tempresult; std::cout << "OK\n"; } - break; - default: std::cout << "ER\n"; break; - } - break; - case 'F': - switch(inputcommand[2]) { - case 'N': - filename = getstringparam(inputcommand); std::cout << "OK\n"; - break; - default: std::cout << "ER\n"; break; - } - break; - default: std::cout << "ER\n"; break; - } - break; - case 'C': - switch (inputcommand[1] ) { - case 'C': - switch (inputcommand[2]) { - case 'D': std::cout << "OK\n"; connection = false; break; - default: std::cout << "ER\n"; break; - } - break; - case 'S': - switch (inputcommand[2]) { - case 'R': std::cout << "OK\n"; readpreset(values, filename); break; - case 'S': std::cout << "OK\n"; writepreset(values, filename); break; - case 'A': std::cout << "OK\n"; writesh(values, filename); break; - default: std::cout << "ER\n"; break; - } - break; - default: std::cout << "ER\n"; break; - } - break; - default: std::cout << "ER\n"; break; - } - } - return 0; -} -*/ diff --git a/Admin/preset b/Admin/preset deleted file mode 100644 index 419367aa..00000000 --- a/Admin/preset +++ /dev/null @@ -1,10 +0,0 @@ -../ts.mov -0 -0 -0 -0 -0 -0 -11025 -20 -20 diff --git a/PLS b/PLS deleted file mode 100644 index 94001b0c..00000000 --- a/PLS +++ /dev/null @@ -1,27 +0,0 @@ -service ddvtechhttp -{ - disable = no - type = UNLISTED - protocol = tcp - socket_type = stream - user = root - server = /usr/bin/Connector_HTTP - port = 7337 - wait = no - per_source = 10 - cps = 100 5 -} - -service ddvtechraw -{ - disable = no - type = UNLISTED - protocol = tcp - socket_type = stream - user = root - server = /usr/bin/Connector_RAW - port = 3773 - wait = no - per_source = 10 - cps = 100 5 -} diff --git a/ABST_Parser/Makefile b/tools/ABST_Parser/Makefile similarity index 100% rename from ABST_Parser/Makefile rename to tools/ABST_Parser/Makefile diff --git a/ABST_Parser/main.cpp b/tools/ABST_Parser/main.cpp similarity index 99% rename from ABST_Parser/main.cpp rename to tools/ABST_Parser/main.cpp index bcc649b5..49d1d9dc 100644 --- a/ABST_Parser/main.cpp +++ b/tools/ABST_Parser/main.cpp @@ -6,7 +6,7 @@ #include #include #include -#include "../util/MP4/box_includes.h" +#include "../../util/MP4/box_includes.h" void Parse( Box * source ,std::string PrintOffset ) { if( source->header.BoxType == 0x61627374 ) { diff --git a/AMF_Tester/Makefile b/tools/AMF_Tester/Makefile similarity index 91% rename from AMF_Tester/Makefile rename to tools/AMF_Tester/Makefile index 6695539c..afefa38c 100644 --- a/AMF_Tester/Makefile +++ b/tools/AMF_Tester/Makefile @@ -1,4 +1,4 @@ -SRC = main.cpp ../util/amf.cpp +SRC = main.cpp ../../util/amf.cpp OBJ = $(SRC:.cpp=.o) OUT = AMFtest INCLUDES = diff --git a/AMF_Tester/main.cpp b/tools/AMF_Tester/main.cpp similarity index 96% rename from AMF_Tester/main.cpp rename to tools/AMF_Tester/main.cpp index bf5ae674..e58d7def 100644 --- a/AMF_Tester/main.cpp +++ b/tools/AMF_Tester/main.cpp @@ -7,7 +7,7 @@ #include #include #include -#include "../util/amf.h" +#include "../../util/amf.h" /// Debugging tool for AMF data. /// Expects AMF data through stdin, outputs human-readable information to stderr. diff --git a/HTTP_Box_Parser/Makefile b/tools/HTTP_Box_Parser/Makefile similarity index 80% rename from HTTP_Box_Parser/Makefile rename to tools/HTTP_Box_Parser/Makefile index 97900497..3a44d0cd 100644 --- a/HTTP_Box_Parser/Makefile +++ b/tools/HTTP_Box_Parser/Makefile @@ -1,4 +1,4 @@ -SRC = main.cpp ../util/flv_tag.cpp ../util/http_parser.cpp ../util/ddv_socket.cpp +SRC = main.cpp ../../util/flv_tag.cpp ../../util/http_parser.cpp ../../util/socket.cpp OBJ = $(SRC:.cpp=.o) OUT = Box_Parser INCLUDES = diff --git a/HTTP_Box_Parser/main.cpp b/tools/HTTP_Box_Parser/main.cpp similarity index 95% rename from HTTP_Box_Parser/main.cpp rename to tools/HTTP_Box_Parser/main.cpp index e430e3de..c78c694d 100644 --- a/HTTP_Box_Parser/main.cpp +++ b/tools/HTTP_Box_Parser/main.cpp @@ -10,9 +10,9 @@ #include #include #include -#include "../util/http_parser.h" -#include "../util/MP4/box_includes.h" -#include "../util/flv_tag.h" +#include "../../util/http_parser.h" +#include "../../util/MP4/box_includes.h" +#include "../../util/flv_tag.h" /// Debugging tool for F4M HTTP streaming data. /// Expects raw TCP data through stdin, outputs human-readable information to stderr. diff --git a/RTMP_Parser/Makefile b/tools/RTMP_Parser/Makefile similarity index 74% rename from RTMP_Parser/Makefile rename to tools/RTMP_Parser/Makefile index 442e9db2..07b148b5 100644 --- a/RTMP_Parser/Makefile +++ b/tools/RTMP_Parser/Makefile @@ -1,4 +1,4 @@ -SRC = main.cpp ../util/amf.cpp ../util/rtmpchunks.cpp ../util/crypto.cpp ../util/flv_tag.cpp ../util/socket.cpp +SRC = main.cpp ../../util/amf.cpp ../../util/rtmpchunks.cpp ../../util/crypto.cpp ../../util/flv_tag.cpp ../../util/socket.cpp OBJ = $(SRC:.cpp=.o) OUT = RTMP_Parser INCLUDES = diff --git a/RTMP_Parser/main.cpp b/tools/RTMP_Parser/main.cpp similarity index 98% rename from RTMP_Parser/main.cpp rename to tools/RTMP_Parser/main.cpp index 9ab21b35..98aca820 100644 --- a/RTMP_Parser/main.cpp +++ b/tools/RTMP_Parser/main.cpp @@ -14,9 +14,9 @@ #include #include #include -#include "../util/flv_tag.h" -#include "../util/amf.h" -#include "../util/rtmpchunks.h" +#include "../../util/flv_tag.h" +#include "../../util/amf.h" +#include "../../util/rtmpchunks.h" int Detail = 0; #define DETAIL_RECONSTRUCT 1 diff --git a/RTP_Parser/main.cpp b/tools/RTP_Parser/main.cpp similarity index 100% rename from RTP_Parser/main.cpp rename to tools/RTP_Parser/main.cpp diff --git a/TS_Analyser/main.cpp b/tools/TS_Analyser/main.cpp similarity index 100% rename from TS_Analyser/main.cpp rename to tools/TS_Analyser/main.cpp diff --git a/spawntest/Makefile b/tools/spawntest/Makefile similarity index 92% rename from spawntest/Makefile rename to tools/spawntest/Makefile index 505b1eef..f18a81c4 100644 --- a/spawntest/Makefile +++ b/tools/spawntest/Makefile @@ -1,4 +1,4 @@ -SRC = main.cpp ../util/proc.cpp +SRC = main.cpp ../../util/util.cpp OBJ = $(SRC:.cpp=.o) OUT = spawntest INCLUDES = diff --git a/spawntest/main.cpp b/tools/spawntest/main.cpp similarity index 94% rename from spawntest/main.cpp rename to tools/spawntest/main.cpp index d06bff34..c1aa9468 100644 --- a/spawntest/main.cpp +++ b/tools/spawntest/main.cpp @@ -3,7 +3,7 @@ #include #include -#include "../util/proc.h" //Process utility +#include "../../util/util.h" //Process utility /// Sleeps a maximum of five seconds, each second being interruptable by a signal. void sleepFive(){ diff --git a/spawntest/test.sh b/tools/spawntest/test.sh similarity index 100% rename from spawntest/test.sh rename to tools/spawntest/test.sh diff --git a/spawntest/testpipein.sh b/tools/spawntest/testpipein.sh similarity index 100% rename from spawntest/testpipein.sh rename to tools/spawntest/testpipein.sh diff --git a/spawntest/testpipeout.sh b/tools/spawntest/testpipeout.sh similarity index 100% rename from spawntest/testpipeout.sh rename to tools/spawntest/testpipeout.sh