diff --git a/Jamulus.pro b/Jamulus.pro index 501922ea..b9fbd0dd 100755 --- a/Jamulus.pro +++ b/Jamulus.pro @@ -10,10 +10,15 @@ CONFIG += qt \ thread \ release -QT += widgets \ - network \ +QT += network \ xml +!contains(CONFIG, "headless") { + QT += widgets +} else { + QT -= gui +} + TRANSLATIONS = src/res/translation/translation_de_DE.ts \ src/res/translation/translation_fr_FR.ts \ src/res/translation/translation_pt_PT.ts \ @@ -324,25 +329,18 @@ win32 { RCC_DIR = src/res RESOURCES += src/resources.qrc -FORMS += src/clientdlgbase.ui \ +FORMS_GUI = src/clientdlgbase.ui \ src/serverdlgbase.ui \ src/clientsettingsdlgbase.ui \ src/chatdlgbase.ui \ src/connectdlgbase.ui \ src/aboutdlgbase.ui -HEADERS += src/audiomixerboard.h \ - src/buffer.h \ +HEADERS += src/buffer.h \ src/channel.h \ - src/chatdlg.h \ src/client.h \ - src/clientsettingsdlg.h \ - src/connectdlg.h \ src/global.h \ - src/clientdlg.h \ - src/serverdlg.h \ src/multicolorled.h \ - src/multicolorledbar.h \ src/protocol.h \ src/server.h \ src/serverlist.h \ @@ -352,13 +350,21 @@ HEADERS += src/audiomixerboard.h \ src/soundbase.h \ src/testbench.h \ src/util.h \ - src/analyzerconsole.h \ src/recorder/jamrecorder.h \ src/recorder/creaperproject.h \ src/recorder/cwavestream.h \ src/historygraph.h \ src/signalhandler.h +HEADERS_GUI = src/audiomixerboard.h \ + src/chatdlg.h \ + src/clientsettingsdlg.h \ + src/connectdlg.h \ + src/clientdlg.h \ + src/serverdlg.h \ + src/multicolorledbar.h \ + src/analyzerconsole.h + HEADERS_OPUS = libs/opus/celt/arch.h \ libs/opus/celt/bands.h \ libs/opus/celt/celt.h \ @@ -430,18 +436,10 @@ HEADERS_OPUS_X86 = libs/opus/celt/x86/celt_lpc_sse.h \ libs/opus/celt/x86/vq_sse.h \ libs/opus/celt/x86/x86cpu.h -SOURCES += src/audiomixerboard.cpp \ - src/buffer.cpp \ +SOURCES += src/buffer.cpp \ src/channel.cpp \ - src/chatdlg.cpp \ src/client.cpp \ - src/clientsettingsdlg.cpp \ - src/connectdlg.cpp \ - src/clientdlg.cpp \ - src/serverdlg.cpp \ src/main.cpp \ - src/multicolorled.cpp \ - src/multicolorledbar.cpp \ src/protocol.cpp \ src/server.cpp \ src/serverlist.cpp \ @@ -451,12 +449,21 @@ SOURCES += src/audiomixerboard.cpp \ src/socket.cpp \ src/soundbase.cpp \ src/util.cpp \ - src/analyzerconsole.cpp \ src/recorder/jamrecorder.cpp \ src/recorder/creaperproject.cpp \ src/recorder/cwavestream.cpp \ src/historygraph.cpp +SOURCES_GUI = src/audiomixerboard.cpp \ + src/chatdlg.cpp \ + src/clientsettingsdlg.cpp \ + src/connectdlg.cpp \ + src/clientdlg.cpp \ + src/serverdlg.cpp \ + src/multicolorled.cpp \ + src/multicolorledbar.cpp \ + src/analyzerconsole.cpp + SOURCES_OPUS = libs/opus/celt/bands.c \ libs/opus/celt/celt.c \ libs/opus/celt/celt_decoder.c \ @@ -985,6 +992,14 @@ DISTFILES_OPUS += libs/opus/AUTHORS \ libs/opus/celt/arm/armopts.s.in \ libs/opus/celt/arm/celt_pitch_xcorr_arm.s \ +!contains(CONFIG, "headless") { + HEADERS += $$HEADERS_GUI + SOURCES += $$SOURCES_GUI + FORMS += $$FORMS_GUI +} else { + DEFINES += HEADLESS +} + # use external OPUS library if requested contains(CONFIG, "opus_shared_lib") { message(OPUS codec is used from a shared library.) diff --git a/src/client.h b/src/client.h index 0a576068..24c61750 100755 --- a/src/client.h +++ b/src/client.h @@ -28,7 +28,6 @@ #include #include #include -#include #ifdef USE_OPUS_SHARED_LIB # include "opus/opus_custom.h" #else diff --git a/src/clientdlg.h b/src/clientdlg.h index 4058b6de..79ead5ce 100755 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -33,6 +33,7 @@ #include #include #include +#include #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) # include #endif diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index c6327bae..da5c31cb 100755 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -34,6 +34,7 @@ #include #include #include +#include #include "global.h" #include "client.h" #include "multicolorled.h" diff --git a/src/historygraph.cpp b/src/historygraph.cpp index ffdf1daa..9bd005c6 100644 --- a/src/historygraph.cpp +++ b/src/historygraph.cpp @@ -299,6 +299,7 @@ void AHistoryGraph::AddMarker ( const SHistoryData& curHistoryData ) /* JPEG History Graph implementation ******************************************/ +#ifndef HEADLESS CJpegHistoryGraph::CJpegHistoryGraph ( const int iMaxDaysHistory ) : AHistoryGraph ( iMaxDaysHistory ), PlotPixmap ( 1, 1, QImage::Format_RGB32 ), @@ -401,6 +402,7 @@ void CJpegHistoryGraph::point ( const unsigned int x, const unsigned int y, cons PlotPainter.setPen ( QPen ( QBrush( QColor ( colour ) ), size ) ); PlotPainter.drawPoint ( x, y ); } +#endif /* SVG History Graph implementation *******************************************/ diff --git a/src/historygraph.h b/src/historygraph.h index 309c28d8..77034f97 100644 --- a/src/historygraph.h +++ b/src/historygraph.h @@ -34,8 +34,10 @@ #include "util.h" // for CJpegHistoryGraph -#include -#include +#ifndef HEADLESS +# include +# include +#endif // for CSvgHistoryGraph #include @@ -134,6 +136,7 @@ protected: /* Implementations ************************************************************/ +#ifndef HEADLESS class CJpegHistoryGraph : public QObject, virtual public AHistoryGraph { Q_OBJECT @@ -157,6 +160,7 @@ private: public slots: void OnTimerDailyUpdate() { Update(); } }; +#endif class CSvgHistoryGraph : public QObject, virtual public AHistoryGraph { diff --git a/src/main.cpp b/src/main.cpp index 03b1fc35..801be8e8 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,15 +22,18 @@ * \******************************************************************************/ -#include -#include +#include #include #include #include #include #include "global.h" -#include "clientdlg.h" -#include "serverdlg.h" +#ifndef HEADLESS +# include +# include +# include "clientdlg.h" +# include "serverdlg.h" +#endif #include "settings.h" #include "testbench.h" #include "util.h" @@ -471,7 +474,7 @@ int main ( int argc, char** argv ) if ( ( !strcmp ( argv[i], "--version" ) ) || ( !strcmp ( argv[i], "-v" ) ) ) { - tsConsole << CAboutDlg::GetVersionAndNameStr ( false ) << endl; + tsConsole << GetVersionAndNameStr ( false ) << endl; exit ( 1 ); } @@ -499,6 +502,14 @@ int main ( int argc, char** argv ) #endif } +#ifdef HEADLESS + if (bUseGUI) + { + bUseGUI = false; + tsConsole << "No GUI support compiled. Running in headless mode." << endl; + } +#endif + // Dependencies ------------------------------------------------------------ // per definition: if we are in "GUI" server mode and no central server @@ -523,9 +534,13 @@ int main ( int argc, char** argv ) // Application/GUI setup --------------------------------------------------- // Application object +#ifdef HEADLESS + QCoreApplication* pApp = new QCoreApplication ( argc, argv ); +#else QCoreApplication* pApp = bUseGUI ? new QApplication ( argc, argv ) : new QCoreApplication ( argc, argv ); +#endif #ifdef ANDROID // special Android coded needed for record audio permission handling @@ -602,6 +617,7 @@ int main ( int argc, char** argv ) CSettings Settings ( &Client, strIniFileName ); Settings.Load(); +#ifndef HEADLESS if ( bUseGUI ) { // GUI object @@ -619,9 +635,10 @@ int main ( int argc, char** argv ) pApp->exec(); } else +#endif { // only start application without using the GUI - tsConsole << CAboutDlg::GetVersionAndNameStr ( false ) << endl; + tsConsole << GetVersionAndNameStr ( false ) << endl; pApp->exec(); } @@ -645,6 +662,7 @@ int main ( int argc, char** argv ) bDisconnectAllClientsOnQuit, bUseDoubleSystemFrameSize, eLicenceType ); +#ifndef HEADLESS if ( bUseGUI ) { // load settings from init-file @@ -671,9 +689,10 @@ int main ( int argc, char** argv ) pApp->exec(); } else +#endif { // only start application without using the GUI - tsConsole << CAboutDlg::GetVersionAndNameStr ( false ) << endl; + tsConsole << GetVersionAndNameStr ( false ) << endl; // update serverlist Server.UpdateServerList(); @@ -686,6 +705,7 @@ int main ( int argc, char** argv ) catch ( CGenErr generr ) { // show generic error +#ifndef HEADLESS if ( bUseGUI ) { QMessageBox::critical ( nullptr, @@ -695,6 +715,7 @@ int main ( int argc, char** argv ) nullptr ); } else +#endif { tsConsole << generr.GetErrorText() << endl; } diff --git a/src/multicolorledbar.h b/src/multicolorledbar.h index e64dab12..6f855b5b 100755 --- a/src/multicolorledbar.h +++ b/src/multicolorledbar.h @@ -24,12 +24,14 @@ #pragma once -#include -#include -#include -#include -#include -#include +#ifndef HEADLESS +# include +# include +# include +# include +# include +# include +#endif #include "util.h" #include "global.h" @@ -42,6 +44,7 @@ /* Classes ********************************************************************/ +#ifndef HEADLESS class CMultiColorLEDBar : public QWidget { Q_OBJECT @@ -95,3 +98,4 @@ protected: CVector vecpLEDs; QProgressBar* pProgressBar; }; +#endif diff --git a/src/serverlogging.cpp b/src/serverlogging.cpp index 702aa7b0..cdbe4468 100755 --- a/src/serverlogging.cpp +++ b/src/serverlogging.cpp @@ -47,14 +47,16 @@ void CServerLogging::Start ( const QString& strLoggingFileName ) void CServerLogging::EnableHistory ( const QString& strHistoryFileName ) { - if ( strHistoryFileName.right ( 4 ).compare ( ".svg", Qt::CaseInsensitive ) == 0 ) - { - SvgHistoryGraph.Start ( strHistoryFileName ); - } - else +#ifndef HEADLESS + if ( strHistoryFileName.right ( 4 ).compare ( ".svg", Qt::CaseInsensitive ) != 0 ) { JpegHistoryGraph.Start ( strHistoryFileName ); } + else +#endif + { + SvgHistoryGraph.Start ( strHistoryFileName ); + } } void CServerLogging::AddNewConnection ( const QHostAddress& ClientInetAddr ) @@ -68,7 +70,9 @@ void CServerLogging::AddNewConnection ( const QHostAddress& ClientInetAddr ) *this << strLogStr; // in log file // add element to history +#ifndef HEADLESS JpegHistoryGraph.Add ( QDateTime::currentDateTime(), ClientInetAddr ); +#endif SvgHistoryGraph.Add ( QDateTime::currentDateTime(), ClientInetAddr ); } @@ -82,10 +86,14 @@ void CServerLogging::AddServerStopped() *this << strLogStr; // in log file // add element to history and update on server stop +#ifndef HEADLESS JpegHistoryGraph.Add ( QDateTime::currentDateTime(), AHistoryGraph::HIT_SERVER_STOP ); +#endif SvgHistoryGraph.Add ( QDateTime::currentDateTime(), AHistoryGraph::HIT_SERVER_STOP ); +#ifndef HEADLESS JpegHistoryGraph.Update(); +#endif SvgHistoryGraph.Update(); } @@ -133,7 +141,9 @@ void CServerLogging::ParseLogFile ( const QString& strFileName ) if ( strAddress.isEmpty() ) { // server stop +#ifndef HEADLESS JpegHistoryGraph.Add ( curDateTime, AHistoryGraph::HIT_SERVER_STOP ); +#endif SvgHistoryGraph.Add ( curDateTime, CSvgHistoryGraph::HIT_SERVER_STOP ); } else @@ -144,7 +154,9 @@ void CServerLogging::ParseLogFile ( const QString& strFileName ) if ( curAddress.setAddress ( strlistCurLine.at ( 1 ).trimmed() ) ) { // new client connection +#ifndef HEADLESS JpegHistoryGraph.Add ( curDateTime, curAddress ); +#endif SvgHistoryGraph.Add ( curDateTime, curAddress ); } } @@ -152,7 +164,9 @@ void CServerLogging::ParseLogFile ( const QString& strFileName ) } } +#ifndef HEADLESS JpegHistoryGraph.Update(); +#endif SvgHistoryGraph.Update(); } diff --git a/src/serverlogging.h b/src/serverlogging.h index 7aeae493..71587d55 100755 --- a/src/serverlogging.h +++ b/src/serverlogging.h @@ -39,7 +39,9 @@ class CServerLogging { public: CServerLogging ( const int iMaxDaysHistory ) : +#ifndef HEADLESS JpegHistoryGraph ( iMaxDaysHistory ), +#endif SvgHistoryGraph ( iMaxDaysHistory ), bDoLogging ( false ), File ( DEFAULT_LOG_FILE_NAME ) {} @@ -56,7 +58,9 @@ protected: void operator<< ( const QString& sNewStr ); QString CurTimeDatetoLogString(); +#ifndef HEADLESS CJpegHistoryGraph JpegHistoryGraph; +#endif CSvgHistoryGraph SvgHistoryGraph; bool bDoLogging; QFile File; diff --git a/src/socket.h b/src/socket.h index bf21abf0..adc9c67f 100755 --- a/src/socket.h +++ b/src/socket.h @@ -25,7 +25,6 @@ #pragma once #include -#include #include #include #include diff --git a/src/soundbase.cpp b/src/soundbase.cpp index 7f4b530c..7d5adb4a 100755 --- a/src/soundbase.cpp +++ b/src/soundbase.cpp @@ -22,6 +22,10 @@ * \******************************************************************************/ +#ifndef HEADLESS +# include +#endif + #include "soundbase.h" @@ -137,6 +141,7 @@ QString CSoundBase::SetDev ( const int iNewDev ) // the same driver is used but the driver properties seems to // have changed so that they are not compatible to our // software anymore +#ifndef HEADLESS QMessageBox::critical ( nullptr, APP_NAME, QString ( tr ( "The audio driver properties " "have changed to a state which is incompatible with this " @@ -145,6 +150,7 @@ QString CSoundBase::SetDev ( const int iNewDev ) strErrorMessage + QString ( "

" + tr ( "Please restart the software." ) ), tr ( "Close" ), nullptr ); +#endif _exit ( 0 ); } diff --git a/src/soundbase.h b/src/soundbase.h index b6a7a4cb..fbd5883a 100755 --- a/src/soundbase.h +++ b/src/soundbase.h @@ -26,7 +26,6 @@ #include #include -#include #include "global.h" #include "util.h" diff --git a/src/util.cpp b/src/util.cpp index b1b4ba8a..65fcebe7 100755 --- a/src/util.cpp +++ b/src/util.cpp @@ -371,6 +371,7 @@ void CAudioReverb::Process ( CVector& vecsStereoInOut, * GUI Utilities * \******************************************************************************/ // About dialog ---------------------------------------------------------------- +#ifndef HEADLESS CAboutDlg::CAboutDlg ( QWidget* parent ) : QDialog ( parent ) { setupUi ( this ); @@ -455,43 +456,6 @@ CAboutDlg::CAboutDlg ( QWidget* parent ) : QDialog ( parent ) setWindowTitle ( tr ( "About " ) + APP_NAME ); } -QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml ) -{ - QString strVersionText = ""; - - // name, short description and GPL hint - if ( bWithHtml ) - { - strVersionText += ""; - } - else - { - strVersionText += " *** "; - } - - strVersionText += APP_NAME + tr ( ", Version " ) + VERSION; - - if ( bWithHtml ) - { - strVersionText += "
"; - } - else - { - strVersionText += "\n *** "; - } - - if ( !bWithHtml ) - { - strVersionText += tr ( "Internet Jam Session Software" ); - strVersionText += "\n *** "; - } - - strVersionText += tr ( "Released under the GNU General Public License (GPL)" ); - - return strVersionText; -} - - // Licence dialog -------------------------------------------------------------- CLicenceDlg::CLicenceDlg ( QWidget* parent ) : QDialog ( parent ) { @@ -886,6 +850,7 @@ CHelpMenu::CHelpMenu ( const bool bIsClient, QWidget* parent ) : QMenu ( tr ( "& addAction ( tr ( "&About..." ), this, SLOT ( OnHelpAbout() ) ); } +#endif /******************************************************************************\ * Other Classes * @@ -1428,3 +1393,39 @@ void DebugError ( const QString& pchErDescr, printf ( "\nDebug error! For more information see test/DebugError.dat\n" ); exit ( 1 ); } + +QString GetVersionAndNameStr ( const bool bWithHtml ) +{ + QString strVersionText = ""; + + // name, short description and GPL hint + if ( bWithHtml ) + { + strVersionText += ""; + } + else + { + strVersionText += " *** "; + } + + strVersionText += APP_NAME + QCoreApplication::tr ( ", Version " ) + VERSION; + + if ( bWithHtml ) + { + strVersionText += "
"; + } + else + { + strVersionText += "\n *** "; + } + + if ( !bWithHtml ) + { + strVersionText += QCoreApplication::tr ( "Internet Jam Session Software" ); + strVersionText += "\n *** "; + } + + strVersionText += QCoreApplication::tr ( "Released under the GNU General Public License (GPL)" ); + + return strVersionText; +} diff --git a/src/util.h b/src/util.h index 56c3aa49..9118f617 100755 --- a/src/util.h +++ b/src/util.h @@ -24,19 +24,22 @@ #pragma once +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#ifndef HEADLESS +# include +# include +# include +# include +# include +# include +# include +# include +# include +#endif #include -#include #include #include #include @@ -56,7 +59,9 @@ using namespace std; // because of the library: "vector" #else # include #endif -#include "ui_aboutdlgbase.h" +#ifndef HEADLESS +# include "ui_aboutdlgbase.h" +#endif class CClient; // forward declaration of CClient @@ -100,6 +105,7 @@ inline int CalcBitRateBitsPerSecFromCodedBytes ( const int iCeltNumCodedBytes, return ( SYSTEM_SAMPLE_RATE_HZ * iCeltNumCodedBytes * 8 ) / iFrameSize; } +QString GetVersionAndNameStr ( const bool bWithHtml = true ); /******************************************************************************\ @@ -408,6 +414,7 @@ template void CMovingAv::Add ( const TData tNewD ) /******************************************************************************\ * GUI Utilities * \******************************************************************************/ +#ifndef HEADLESS // About dialog ---------------------------------------------------------------- class CAboutDlg : public QDialog, private Ui_CAboutDlgBase { @@ -416,7 +423,6 @@ class CAboutDlg : public QDialog, private Ui_CAboutDlgBase public: CAboutDlg ( QWidget* parent = nullptr ); - static QString GetVersionAndNameStr ( const bool bWithHtml = true ); }; @@ -484,6 +490,7 @@ public slots: void OnHelpSoftwareMan() { QDesktopServices::openUrl ( QUrl ( SOFTWARE_MANUAL_URL ) ); } }; +#endif // Console writer factory ------------------------------------------------------ // this class was written by pljones