Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 #include <QtGui>
00043 #include "audioinput.h"
00044 #include "soundserver.h"
00045 
00046 int main(int argc, char **argv)
00047 {
00048     QApplication app(argc, argv);
00049     app.setApplicationName("Audio Monitor");
00050 
00051     int port = 0;
00052     QString epdHost;
00053     QStringList args = app.arguments();
00054     for (int i = 1; i < args.count(); i++){
00055         if (args[i] == "-filename"){
00056             i++;
00057             if (i < args.count()){
00058                 AudioInfo::setFileName(args[i]);
00059             }
00060         }
00061         else if (args[i] == "-port"){
00062             i++;
00063             if (i < args.count()){
00064                 port = args[i].toInt();
00065             }
00066         }
00067         else if (args[i] == "-epd"){
00068             i++;
00069             if (i < args.count()){
00070                 QStringList epdArgs = args[i].split(":");
00071                 if (epdArgs.count() == 2){
00072                     epdHost = epdArgs[0];
00073                     _epdPort = epdArgs[1].toInt();
00074                 }
00075                 else{
00076                     _epdPort = args[i].toInt();
00077                 }
00078             }
00079         }
00080     }
00081 
00082     SoundServer server;
00083     if (port > 0){
00084         if (!server.listen(QHostAddress::Any, port)) {
00085             QMessageBox::critical(NULL, "Sound Server",
00086                 QString("Unable to start the server: %1.").arg(server.errorString()));
00087             return -1;
00088         }
00089     }
00090     _atrasrClient.socket = NULL;
00091     if (!epdHost.isEmpty() && _epdPort > 0){
00092         if ( AtrasrConnect( &_atrasrClient, epdHost.toLatin1(), _epdPort ) != -1 ){
00093             AtrasrSendTOF( &_atrasrClient );
00094             AtrasrSendSTARTPU( &_atrasrClient );
00095         }      
00096     }
00097 
00098     SoundServerApp input(&server);
00099     input.resize(240,240);
00100     input.show();
00101 
00102     int ret = app.exec();
00103     if (port > 0){
00104         server.close();
00105     }
00106     if (_epdPort > 0){
00107         AtrasrSendEOF( &_atrasrClient );
00108         AtrasrClose( &_atrasrClient );
00109     }
00110     return ret;
00111 }