Admin dummy

This commit is contained in:
Erik Zandvliet 2010-06-25 22:26:28 +02:00
parent 975be07720
commit af64e27b54
2 changed files with 183 additions and 0 deletions

174
Admin/main.cpp Normal file
View file

@ -0,0 +1,174 @@
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <cstdio>
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;
}
void readpreset( unsigned int values[] ) {
std::ifstream presetfile ("preset");
for (int i = 0; i < 9; i++ ) { presetfile >> values[i]; }
presetfile.close();
}
void writepreset( unsigned int values[] ) {
std::ofstream presetfile ("preset");
for (int i = 0; i < 9; i++ ) {
presetfile << values[i];
presetfile << "\n";
}
presetfile.close();
}
void writesh( unsigned int values[] ) {
std::ofstream shfile ("run.sh");
shfile << "ffmpeg -i ../ts.mov -f flv -sameq -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 << "out.flv";
shfile.close();
}
int main() {
unsigned int values[9];
std::string inputcommand = "";
bool connection = true;
int tempresult;
readpreset(values);
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;
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;
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); break;
case 'S': std::cout << "OK\n"; writepreset(values); break;
case 'A': std::cout << "OK\n"; writesh(values); break;
default: std::cout << "ER\n"; break;
}
break;
default: std::cout << "ER\n"; break;
}
break;
default: std::cout << "ER\n"; break;
}
}
return 0;
}

9
Admin/preset Normal file
View file

@ -0,0 +1,9 @@
0
0
0
0
0
0
11025
20
20