2012-07-09 14:58:35 +02:00
|
|
|
/******************************************************************************\
|
2020-01-01 15:41:43 +01:00
|
|
|
* \Copyright (c) 2004-2020
|
2012-12-31 13:45:28 +01:00
|
|
|
* \author Volker Fischer
|
2012-07-09 14:58:35 +02:00
|
|
|
*
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
\mainpage Jamulus source code documentation
|
2012-12-31 13:45:28 +01:00
|
|
|
|
|
|
|
\section intro_sec Introduction
|
|
|
|
|
2013-03-24 11:49:25 +01:00
|
|
|
The Jamulus software enables musicians to perform real-time jam sessions over the
|
|
|
|
internet. There is one server running the Jamulus server software which collects
|
|
|
|
the audio data from each Jamulus client, mixes the audio data and sends the mix
|
2012-12-31 13:45:28 +01:00
|
|
|
back to each client.
|
|
|
|
|
|
|
|
|
2012-07-09 14:58:35 +02:00
|
|
|
Prefix definitions for the GUI:
|
|
|
|
|
|
|
|
label: lbl
|
|
|
|
combo box: cbx
|
|
|
|
line edit: edt
|
|
|
|
list view: lvw
|
|
|
|
check box: chb
|
|
|
|
radio button: rbt
|
|
|
|
button: but
|
|
|
|
text view: txv
|
|
|
|
slider: sld
|
|
|
|
LED: led
|
|
|
|
group box: grb
|
|
|
|
pixmap label: pxl
|
|
|
|
LED bar: lbr
|
|
|
|
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2019-07-09 08:52:38 +02:00
|
|
|
#pragma once
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2019-04-03 19:12:45 +02:00
|
|
|
#if _WIN32
|
2019-04-12 18:48:20 +02:00
|
|
|
# define _CRT_SECURE_NO_WARNINGS
|
2019-04-03 19:12:45 +02:00
|
|
|
#endif
|
|
|
|
|
2013-01-02 21:41:04 +01:00
|
|
|
#include <QString>
|
|
|
|
#include <QEvent>
|
|
|
|
#include <QDebug>
|
2012-07-09 14:58:35 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <string>
|
2012-12-31 13:45:28 +01:00
|
|
|
#ifndef _WIN32
|
|
|
|
# include <unistd.h> // solves a compile problem on recent Ubuntu
|
|
|
|
#endif
|
2012-07-09 14:58:35 +02:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Definitions ****************************************************************/
|
|
|
|
// define this macro to get debug output
|
|
|
|
//#define _DEBUG_
|
|
|
|
#undef _DEBUG_
|
|
|
|
|
2014-02-23 10:46:25 +01:00
|
|
|
// define this macro if the version and operating system debugging shall
|
|
|
|
// be enabled in the client (the ping time column in the connect dialog then
|
|
|
|
// shows the requested information instead of the ping time)
|
|
|
|
#undef ENABLE_CLIENT_VERSION_AND_OS_DEBUGGING
|
|
|
|
|
2013-03-24 09:54:11 +01:00
|
|
|
// version and application name (use version from qt prject file)
|
2012-07-09 14:58:35 +02:00
|
|
|
#undef VERSION
|
2020-04-15 15:29:43 +02:00
|
|
|
#define VERSION APP_VERSION
|
|
|
|
#define APP_NAME "Jamulus"
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// Windows registry key name of auto run entry for the server
|
2020-04-15 15:29:43 +02:00
|
|
|
#define AUTORUN_SERVER_REG_NAME "Jamulus server"
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// default names of the ini-file for client and server
|
2020-04-15 15:29:43 +02:00
|
|
|
#define DEFAULT_INI_FILE_NAME "Jamulus.ini"
|
|
|
|
#define DEFAULT_INI_FILE_NAME_SERVER "Jamulusserver.ini"
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// file name for logging file
|
2020-04-15 15:29:43 +02:00
|
|
|
#define DEFAULT_LOG_FILE_NAME "Jamulussrvlog.txt"
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2020-03-22 20:24:30 +01:00
|
|
|
// default oldest item to draw in history graph (days ago)
|
2020-04-15 15:29:43 +02:00
|
|
|
#define DEFAULT_DAYS_HISTORY 60
|
2020-03-21 19:49:12 +01:00
|
|
|
|
2020-03-28 16:27:45 +01:00
|
|
|
// System block size, this is the block size on which the audio coder works.
|
|
|
|
// All other block sizes must be a multiple of this size.
|
|
|
|
// Note that the UpdateAutoSetting() function assumes a value of 128.
|
2020-04-15 15:29:43 +02:00
|
|
|
#define SYSTEM_FRAME_SIZE_SAMPLES 64
|
|
|
|
#define DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ( 2 * SYSTEM_FRAME_SIZE_SAMPLES )
|
2020-03-28 16:27:45 +01:00
|
|
|
|
2020-05-16 11:24:50 +02:00
|
|
|
// default server address and port numbers
|
2020-04-15 15:29:43 +02:00
|
|
|
#define DEFAULT_SERVER_ADDRESS "jamulus.fischvolk.de"
|
2020-05-16 11:24:50 +02:00
|
|
|
#define DEFAULT_PORT_NUMBER 22124
|
2020-05-22 14:40:00 +02:00
|
|
|
#define CENTSERV_ALL_GENRES "jamulusallgenres.fischvolk.de:22224"
|
2020-05-23 21:23:20 +02:00
|
|
|
#define CENTSERV_GENRE_ROCK "jamulusrock.fischvolk.de:22424"
|
|
|
|
#define CENTSERV_GENRE_JAZZ "jamulusjazz.fischvolk.de:22324"
|
|
|
|
#define CENTSERV_GENRE_CLASSICAL_FOLK "jamulusclassical.fischvolk.de:22524"
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2020-05-02 08:24:01 +02:00
|
|
|
// getting started and software manual URL
|
2020-05-17 09:58:26 +02:00
|
|
|
#define CLIENT_GETTING_STARTED_URL "https://github.com/corrados/jamulus/wiki/Getting-Started"
|
2020-05-02 08:24:01 +02:00
|
|
|
#define SERVER_GETTING_STARTED_URL "https://github.com/corrados/jamulus/wiki/Running-a-Server"
|
|
|
|
#define SOFTWARE_MANUAL_URL "https://github.com/corrados/jamulus/blob/master/src/res/homepage/manual.md"
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2020-04-10 10:15:41 +02:00
|
|
|
// determining server internal address uses well-known host and port
|
|
|
|
// (Google DNS, or something else reliable)
|
2020-04-15 15:29:43 +02:00
|
|
|
#define WELL_KNOWN_HOST "8.8.8.8" // Google
|
|
|
|
#define WELL_KNOWN_PORT 53 // DNS
|
|
|
|
#define IP_LOOKUP_TIMEOUT 500 // ms
|
2020-04-10 10:15:41 +02:00
|
|
|
|
2012-07-09 14:58:35 +02:00
|
|
|
// system sample rate (the sound card and audio coder works on this sample rate)
|
2020-04-15 15:29:43 +02:00
|
|
|
#define SYSTEM_SAMPLE_RATE_HZ 48000 // Hz
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// define the allowed audio frame size factors (since the
|
|
|
|
// "SYSTEM_FRAME_SIZE_SAMPLES" is quite small, it may be that on some
|
|
|
|
// computers a larger value is required)
|
2020-04-15 15:29:43 +02:00
|
|
|
#define FRAME_SIZE_FACTOR_PREFERRED 1 // 64 samples accumulated frame size
|
|
|
|
#define FRAME_SIZE_FACTOR_DEFAULT 2 // 128 samples accumulated frame size
|
|
|
|
#define FRAME_SIZE_FACTOR_SAFE 4 // 256 samples accumulated frame size
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2013-02-12 16:32:05 +01:00
|
|
|
// define the minimum allowed number of coded bytes for CELT (the encoder
|
|
|
|
// gets in trouble if the value is too low)
|
2020-04-15 15:29:43 +02:00
|
|
|
#define CELT_MINIMUM_NUM_BYTES 10
|
2013-02-12 16:32:05 +01:00
|
|
|
|
2020-04-01 21:16:44 +02:00
|
|
|
// Maximum block size for network input buffer. It is defined by the longest
|
|
|
|
// protocol message which is PROTMESSID_CLM_SERVER_LIST: Worst case:
|
|
|
|
// (2+2+1+2+2)+200*(4+2+2+1+1+2+20+2+32+2+20)=17609
|
|
|
|
// We add some headroom to that value.
|
2020-04-15 15:29:43 +02:00
|
|
|
#define MAX_SIZE_BYTES_NETW_BUF 20000
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// minimum/maximum network buffer size (which can be chosen by slider)
|
2020-04-15 15:29:43 +02:00
|
|
|
#define MIN_NET_BUF_SIZE_NUM_BL 1 // number of blocks
|
|
|
|
#define MAX_NET_BUF_SIZE_NUM_BL 20 // number of blocks
|
|
|
|
#define AUTO_NET_BUF_SIZE_FOR_PROTOCOL ( MAX_NET_BUF_SIZE_NUM_BL + 1 ) // auto set parameter (only used for protocol)
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// default network buffer size
|
2020-04-15 15:29:43 +02:00
|
|
|
#define DEF_NET_BUF_SIZE_NUM_BL 10 // number of blocks
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2020-05-18 20:46:46 +02:00
|
|
|
// audio mixer fader and panning maximum value
|
2020-04-15 15:29:43 +02:00
|
|
|
#define AUD_MIX_FADER_MAX 100
|
2020-05-12 23:11:06 +02:00
|
|
|
#define AUD_MIX_PAN_MAX 100
|
|
|
|
|
2020-05-26 09:56:46 +02:00
|
|
|
// maximum number of recognized sound cards installed in the system
|
2020-04-15 15:29:43 +02:00
|
|
|
#define MAX_NUMBER_SOUND_CARDS 129 // e.g. 16 inputs, 8 outputs + default entry (MacOS)
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// define the maximum number of audio channel for input/output we can store
|
|
|
|
// channel infos for (and therefore this is the maximum number of entries in
|
|
|
|
// the channel selection combo box regardless of the actual available number
|
|
|
|
// of channels by the audio device)
|
2020-04-15 15:29:43 +02:00
|
|
|
#define MAX_NUM_IN_OUT_CHANNELS 64
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// maximum number of elemts in the server address combo box
|
2020-05-17 11:00:56 +02:00
|
|
|
#define MAX_NUM_SERVER_ADDR_ITEMS 12
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2014-01-19 11:51:31 +01:00
|
|
|
// maximum number of fader settings to be stored (together with the fader tags)
|
2020-05-17 11:00:56 +02:00
|
|
|
#define MAX_NUM_STORED_FADER_SETTINGS 250
|
2013-02-24 10:03:57 +01:00
|
|
|
|
2020-03-29 13:18:59 +02:00
|
|
|
// range for signal level meter
|
2020-04-15 15:29:43 +02:00
|
|
|
#define LOW_BOUND_SIG_METER ( -50.0 ) // dB
|
|
|
|
#define UPPER_BOUND_SIG_METER ( 0.0 ) // dB
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2020-05-26 09:56:46 +02:00
|
|
|
// maximum number of connected clients at the server (must not be larger than 256)
|
2020-04-15 15:29:43 +02:00
|
|
|
#define MAX_NUM_CHANNELS 50 // max number channels for server
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// actual number of used channels in the server
|
|
|
|
// this parameter can safely be changed from 1 to MAX_NUM_CHANNELS
|
|
|
|
// without any other changes in the code
|
2020-04-15 15:29:43 +02:00
|
|
|
#define DEFAULT_USED_NUM_CHANNELS 10 // default used number channels for server
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2020-04-01 21:16:44 +02:00
|
|
|
// Maximum number of servers registered in the server list. If you want to
|
|
|
|
// change this parameter, you most probably have to adjust MAX_SIZE_BYTES_NETW_BUF.
|
2020-05-17 11:00:56 +02:00
|
|
|
#define MAX_NUM_SERVERS_IN_SERVER_LIST 150 // reduced to 150 because we now have genre-based server lists
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// defines the time interval at which the ping time is updated in the GUI
|
2020-04-15 15:29:43 +02:00
|
|
|
#define PING_UPDATE_TIME_MS 500 // ms
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2020-05-17 11:00:56 +02:00
|
|
|
// defines the time interval at which the ping time is updated for the server list
|
|
|
|
#define PING_UPDATE_TIME_SERVER_LIST_MS 2500 // ms
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2020-04-04 23:57:16 +02:00
|
|
|
// defines the interval between Channel Level updates from the server
|
2020-04-15 15:29:43 +02:00
|
|
|
#define CHANNEL_LEVEL_UPDATE_INTERVAL 200 // number of frames at 64 samples frame size
|
2020-04-04 23:57:16 +02:00
|
|
|
|
2012-07-09 14:58:35 +02:00
|
|
|
// time-out until a registered server is deleted from the server list if no
|
|
|
|
// new registering was made in minutes
|
2020-05-17 11:00:56 +02:00
|
|
|
#define SERVLIST_TIME_OUT_MINUTES 33 // minutes (should include 3 UDP registration messages)
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// poll time for server list (to check if entries are time-out)
|
2020-04-15 15:29:43 +02:00
|
|
|
#define SERVLIST_POLL_TIME_MINUTES 1 // minute
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// time interval for sending ping messages to servers in the server list
|
2020-04-15 15:29:43 +02:00
|
|
|
#define SERVLIST_UPDATE_PING_SERVERS_MS 59000 // ms
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// time until a slave server registers in the server list
|
2020-04-15 15:29:43 +02:00
|
|
|
#define SERVLIST_REGIST_INTERV_MINUTES 15 // minutes
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2016-02-09 17:09:59 +01:00
|
|
|
// defines the minimum time a server must run to be a permanent server
|
2020-05-17 11:00:56 +02:00
|
|
|
#define SERVLIST_TIME_PERMSERV_MINUTES 4320 // minutes, 4320 = 60 min * 24 h * 3 d
|
2016-02-09 17:09:59 +01:00
|
|
|
|
2020-04-14 22:00:08 +02:00
|
|
|
// registration response timeout
|
2020-05-01 20:21:33 +02:00
|
|
|
#define REGISTER_SERVER_TIME_OUT_MS 500 // ms
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2020-04-14 22:00:08 +02:00
|
|
|
// defines the maximum number of times to retry server registration
|
|
|
|
// when no response is received within the timeout (before reverting
|
|
|
|
// to SERVLIST_REGIST_INTERV_MINUTES)
|
2020-05-01 20:21:33 +02:00
|
|
|
#define REGISTER_SERVER_RETRY_LIMIT 5 // count
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
// Maximum length of fader tag and text message strings (Since for chat messages
|
|
|
|
// some HTML code is added, we also have to define a second length which includes
|
|
|
|
// this additionl HTML code. Right now the length of the HTML code is approx. 66
|
|
|
|
// character. Here, we add some headroom to this number)
|
2020-04-15 15:29:43 +02:00
|
|
|
#define MAX_LEN_FADER_TAG 16
|
|
|
|
#define MAX_LEN_CHAT_TEXT 1600
|
|
|
|
#define MAX_LEN_CHAT_TEXT_PLUS_HTML 1800
|
|
|
|
#define MAX_LEN_SERVER_NAME 20
|
|
|
|
#define MAX_LEN_IP_ADDRESS 15
|
|
|
|
#define MAX_LEN_SERVER_CITY 20
|
|
|
|
#define MAX_LEN_VERSION_TEXT 20
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
// common tool tip bottom line text
|
2020-05-15 21:34:16 +02:00
|
|
|
#define TOOLTIP_COM_END_TEXT \
|
|
|
|
"<br><div align=right><font size=-1><i>" + \
|
|
|
|
QCoreApplication::translate ( "global","For more information use the ""What's " \
|
|
|
|
"This"" help (help menu, right mouse button or Shift+F1)" ) + \
|
|
|
|
"</i></font></div>"
|
2012-07-09 14:58:35 +02:00
|
|
|
|
2020-04-15 15:29:43 +02:00
|
|
|
#define _MAXSHORT 32767
|
|
|
|
#define _MINSHORT ( -32768 )
|
2020-05-26 09:56:46 +02:00
|
|
|
#define INVALID_INDEX -1 // define invalid index as a negative value (a valid index must always be >= 0)
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
#if HAVE_STDINT_H
|
|
|
|
# include <stdint.h>
|
|
|
|
#elif HAVE_INTTYPES_H
|
|
|
|
# include <inttypes.h>
|
|
|
|
#elif defined ( _WIN32 )
|
|
|
|
typedef __int64 int64_t;
|
|
|
|
typedef __int32 int32_t;
|
|
|
|
typedef __int16 int16_t;
|
|
|
|
typedef unsigned __int64 uint64_t;
|
|
|
|
typedef unsigned __int32 uint32_t;
|
|
|
|
typedef unsigned __int16 uint16_t;
|
|
|
|
typedef unsigned __int8 uint8_t;
|
2020-05-11 17:10:38 +02:00
|
|
|
#elif defined ( ANDROID )
|
|
|
|
// don't redfine types for android as these ones below don't work
|
2012-07-09 14:58:35 +02:00
|
|
|
#else
|
|
|
|
typedef long long int64_t;
|
|
|
|
typedef int int32_t;
|
|
|
|
typedef short int16_t;
|
|
|
|
typedef unsigned long long uint64_t;
|
|
|
|
typedef unsigned int uint32_t;
|
|
|
|
typedef unsigned short uint16_t;
|
|
|
|
typedef unsigned char uint8_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2014-01-03 09:54:49 +01:00
|
|
|
/* Pseudo enum definitions -------------------------------------------------- */
|
|
|
|
// definition for custom event
|
2020-04-15 15:29:43 +02:00
|
|
|
#define MS_PACKET_RECEIVED 0
|
2014-01-03 09:54:49 +01:00
|
|
|
|
2012-07-09 14:58:35 +02:00
|
|
|
|
|
|
|
/* Classes ********************************************************************/
|
|
|
|
class CGenErr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CGenErr ( QString strNewErrorMsg, QString strNewErrorType = "" ) :
|
|
|
|
strErrorMsg ( strNewErrorMsg ), strErrorType ( strNewErrorType ) {}
|
|
|
|
|
|
|
|
QString GetErrorText()
|
|
|
|
{
|
|
|
|
// return formatted error text
|
|
|
|
if ( strErrorType.isEmpty() )
|
|
|
|
{
|
|
|
|
return strErrorMsg;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return strErrorType + ": " + strErrorMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QString strErrorMsg;
|
|
|
|
QString strErrorType;
|
|
|
|
};
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
class CCustomEvent : public QEvent
|
2012-07-09 14:58:35 +02:00
|
|
|
{
|
|
|
|
public:
|
2013-03-24 16:42:23 +01:00
|
|
|
CCustomEvent ( int iNewMeTy, int iNewSt, int iNewChN = 0 ) :
|
2012-07-09 14:58:35 +02:00
|
|
|
QEvent ( QEvent::Type ( QEvent::User + 11 ) ), iMessType ( iNewMeTy ), iStatus ( iNewSt ),
|
|
|
|
iChanNum ( iNewChN ) {}
|
|
|
|
|
|
|
|
int iMessType;
|
|
|
|
int iStatus;
|
|
|
|
int iChanNum;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Prototypes for global functions ********************************************/
|
|
|
|
// command line parsing, TODO do not declare functions globally but in a class
|
|
|
|
QString UsageArguments ( char** argv );
|
|
|
|
|
|
|
|
bool GetFlagArgument ( char** argv,
|
|
|
|
int& i,
|
|
|
|
QString strShortOpt,
|
|
|
|
QString strLongOpt );
|
|
|
|
|
|
|
|
bool GetStringArgument ( QTextStream& tsConsole,
|
|
|
|
int argc,
|
|
|
|
char** argv,
|
|
|
|
int& i,
|
|
|
|
QString strShortOpt,
|
|
|
|
QString strLongOpt,
|
|
|
|
QString& strArg );
|
|
|
|
|
|
|
|
bool GetNumericArgument ( QTextStream& tsConsole,
|
|
|
|
int argc,
|
|
|
|
char** argv,
|
|
|
|
int& i,
|
|
|
|
QString strShortOpt,
|
|
|
|
QString strLongOpt,
|
|
|
|
double rRangeStart,
|
|
|
|
double rRangeStop,
|
|
|
|
double& rValue);
|