2006-12-18 15:39:33 +01:00
|
|
|
/******************************************************************************\
|
2010-01-03 14:40:46 +01:00
|
|
|
* Copyright (c) 2004-2010
|
2006-12-18 15:39:33 +01:00
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Volker Fischer
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2008-04-08 20:38:55 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
2006-12-18 15:39:33 +01:00
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
2008-04-08 20:38:55 +02:00
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
2006-12-18 15:39:33 +01:00
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
2008-04-08 20:38:55 +02:00
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
2006-12-18 15:39:33 +01:00
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
#if !defined ( GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_ )
|
2006-12-18 15:39:33 +01:00
|
|
|
#define GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_
|
|
|
|
|
2008-01-20 19:07:13 +01:00
|
|
|
#include <qstring.h>
|
|
|
|
#include <qevent.h>
|
|
|
|
#include <qdebug.h>
|
2006-12-18 15:39:33 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <string>
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Definitions ****************************************************************/
|
2007-09-08 12:45:14 +02:00
|
|
|
// define this macro to get debug output
|
2009-07-24 16:31:25 +02:00
|
|
|
//#define _DEBUG_
|
2006-12-18 15:39:33 +01:00
|
|
|
#undef _DEBUG_
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// version and application name (always use this version)
|
2006-12-18 15:39:33 +01:00
|
|
|
#undef VERSION
|
2009-12-05 12:49:11 +01:00
|
|
|
#define VERSION "3.0.4cvs"
|
2006-12-18 15:39:33 +01:00
|
|
|
#define APP_NAME "llcon"
|
|
|
|
|
2007-05-06 14:27:41 +02:00
|
|
|
// file name for logging file
|
2008-12-28 23:30:18 +01:00
|
|
|
#define DEFAULT_LOG_FILE_NAME "llconsrvlog.txt"
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2009-02-14 19:36:20 +01:00
|
|
|
// default server address
|
|
|
|
#define DEFAULT_SERVER_ADDRESS "llcon.dyndns.org"
|
|
|
|
|
2008-04-08 20:38:55 +02:00
|
|
|
// defined port number for client and server
|
2009-07-24 16:31:25 +02:00
|
|
|
#define LLCON_DEFAULT_PORT_NUMBER 22124
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2009-07-24 16:31:25 +02:00
|
|
|
// system sample rate (the sound card and audio coder works on this sample rate)
|
|
|
|
#define SYSTEM_SAMPLE_RATE 48000
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2009-07-24 16:31:25 +02: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
|
2009-08-13 18:12:49 +02:00
|
|
|
#define SYSTEM_FRAME_SIZE_SAMPLES 128
|
2009-03-01 12:17:35 +01:00
|
|
|
|
2009-07-24 22:17:01 +02:00
|
|
|
#define SYSTEM_BLOCK_DURATION_MS_FLOAT \
|
2009-08-13 18:12:49 +02:00
|
|
|
( static_cast<double> ( SYSTEM_FRAME_SIZE_SAMPLES ) / \
|
2009-07-24 22:17:01 +02:00
|
|
|
SYSTEM_SAMPLE_RATE * 1000 )
|
|
|
|
|
2009-08-02 19:44:45 +02:00
|
|
|
// define the allowed audio frame size factors (since the
|
2009-08-13 18:12:49 +02:00
|
|
|
// "SYSTEM_FRAME_SIZE_SAMPLES" is quite small, it may be that on some
|
2009-08-02 19:44:45 +02:00
|
|
|
// computers a larger value is required)
|
|
|
|
#define FRAME_SIZE_FACTOR_PREFERRED 1 // 128 (for frame size 128)
|
|
|
|
#define FRAME_SIZE_FACTOR_DEFAULT 2 // 256 (for frame size 128)
|
|
|
|
#define FRAME_SIZE_FACTOR_SAFE 4 // 512 (for frame size 128)
|
|
|
|
|
2009-08-23 18:22:57 +02:00
|
|
|
// low complexity CELT encoder (if defined)
|
|
|
|
#define USE_LOW_COMPLEXITY_CELT_ENC
|
|
|
|
|
2009-03-01 12:17:35 +01:00
|
|
|
// define the maximum mono audio buffer size at a sample rate
|
|
|
|
// of 48 kHz, this is important for defining the maximum number
|
2009-07-24 16:31:25 +02:00
|
|
|
// of bytes to be expected from the network interface
|
2009-03-01 12:17:35 +01:00
|
|
|
#define MAX_MONO_AUD_BUFF_SIZE_AT_48KHZ 4096
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2009-08-13 18:12:49 +02:00
|
|
|
// Maximum block size for network input buffer. Consider a maximum sample rate
|
|
|
|
// of 48 kHz and two audio channels and two bytes per sample.
|
|
|
|
#define MAX_SIZE_BYTES_NETW_BUF ( MAX_MONO_AUD_BUFF_SIZE_AT_48KHZ * 4 )
|
|
|
|
|
2009-03-01 12:17:35 +01:00
|
|
|
// minimum/maximum network buffer size (which can be chosen by slider)
|
|
|
|
#define MIN_NET_BUF_SIZE_NUM_BL 1 // number of blocks
|
|
|
|
#define MAX_NET_BUF_SIZE_NUM_BL 20 // number of blocks
|
2006-10-30 21:35:46 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// default network buffer size
|
2009-03-01 23:08:06 +01:00
|
|
|
#define DEF_NET_BUF_SIZE_NUM_BL 10 // number of blocks
|
2006-12-09 16:00:24 +01:00
|
|
|
|
2008-11-02 09:31:48 +01:00
|
|
|
// maximum number of recognized sound cards installed in the system,
|
|
|
|
// definition for "no device"
|
2008-10-31 00:23:26 +01:00
|
|
|
#define MAX_NUMBER_SOUND_CARDS 10
|
2008-11-02 09:31:48 +01:00
|
|
|
#define INVALID_SNC_CARD_DEVICE -1
|
2008-10-31 00:23:26 +01:00
|
|
|
|
2009-05-04 13:27:05 +02:00
|
|
|
// maximum number of elemts in the server address combo box
|
|
|
|
#define MAX_NUM_SERVER_ADDR_ITEMS 6
|
|
|
|
|
2009-05-01 16:00:53 +02:00
|
|
|
// defines for LED input level meter
|
2009-05-02 11:22:05 +02:00
|
|
|
#define NUM_STEPS_INP_LEV_METER 10
|
|
|
|
#define YELLOW_BOUND_INP_LEV_METER 7
|
|
|
|
#define RED_BOUND_INP_LEV_METER 9
|
2009-05-01 16:00:53 +02:00
|
|
|
|
2009-03-01 12:17:35 +01:00
|
|
|
|
2006-12-09 16:00:24 +01:00
|
|
|
// maximum number of internet connections (channels)
|
2006-12-09 19:37:40 +01:00
|
|
|
// if you want to change this paramter, there has to be done code modifications
|
|
|
|
// on other places, too! The code tag "MAX_NUM_CHANNELS_TAG" shows these places
|
|
|
|
// (just search for the tag in the entire code)
|
2009-03-01 12:17:35 +01:00
|
|
|
#define MAX_NUM_CHANNELS 10 // max number channels for server
|
|
|
|
|
|
|
|
// 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
|
|
|
|
#define USED_NUM_CHANNELS 6 // used number channels for server
|
|
|
|
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// length of the moving average buffer for response time measurement
|
|
|
|
#define TIME_MOV_AV_RESPONSE 30 // seconds
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2009-10-26 22:10:14 +01: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)
|
|
|
|
#define MAX_LEN_FADER_TAG 16
|
|
|
|
#define MAX_LEN_CHAT_TEXT 1600
|
|
|
|
#define MAX_LEN_CHAT_TEXT_PLUS_HTML 1800
|
2009-12-02 23:35:53 +01:00
|
|
|
|
|
|
|
// common tool tip bottom line text
|
|
|
|
#define TOOLTIP_COM_END_TEXT tr ( \
|
|
|
|
"<br><div align=right><font size=-1><i>" \
|
2009-12-03 22:21:26 +01:00
|
|
|
"For more information use the ""What's " \
|
|
|
|
"This"" help (? menu, right mouse button or Shift+F1)" \
|
2009-12-02 23:35:53 +01:00
|
|
|
"</i></font></div>" )
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
#define _MAXSHORT 32767
|
2007-09-08 12:45:14 +02:00
|
|
|
#define _MAXBYTE 255 // binary: 11111111
|
|
|
|
#define _MINSHORT ( -32768 )
|
2006-02-18 23:05:46 +01:00
|
|
|
|
|
|
|
#if HAVE_STDINT_H
|
|
|
|
# include <stdint.h>
|
|
|
|
#elif HAVE_INTTYPES_H
|
|
|
|
# include <inttypes.h>
|
|
|
|
#elif defined ( _WIN32 )
|
2010-02-18 21:35:48 +01:00
|
|
|
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;
|
2006-02-18 23:05:46 +01:00
|
|
|
#else
|
2010-02-18 21:35:48 +01:00
|
|
|
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;
|
2006-02-18 23:05:46 +01:00
|
|
|
#endif
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* Definitions for window message system ------------------------------------ */
|
|
|
|
typedef unsigned int _MESSAGE_IDENT;
|
2007-09-08 12:45:14 +02:00
|
|
|
#define MS_RESET_ALL 0 // MS: Message
|
2006-12-18 15:39:33 +01:00
|
|
|
#define MS_SOUND_IN 1
|
|
|
|
#define MS_SOUND_OUT 2
|
|
|
|
#define MS_JIT_BUF_PUT 3
|
2006-11-25 15:46:57 +01:00
|
|
|
#define MS_JIT_BUF_GET 4
|
|
|
|
#define MS_PACKET_RECEIVED 5
|
2009-02-24 19:20:33 +01:00
|
|
|
#define MS_ERROR_IN_THREAD 6
|
|
|
|
#define MS_SET_JIT_BUF_SIZE 7
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
#define MUL_COL_LED_RED 0
|
|
|
|
#define MUL_COL_LED_YELLOW 1
|
|
|
|
#define MUL_COL_LED_GREEN 2
|
|
|
|
|
|
|
|
|
|
|
|
/* Classes ********************************************************************/
|
|
|
|
class CGenErr
|
|
|
|
{
|
|
|
|
public:
|
2008-07-22 17:17:19 +02:00
|
|
|
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;
|
2010-02-28 13:28:02 +01:00
|
|
|
QString strErrorType;
|
2006-12-18 15:39:33 +01:00
|
|
|
};
|
|
|
|
|
2008-01-14 23:14:17 +01:00
|
|
|
class CLlconEvent : public QEvent
|
2006-12-18 15:39:33 +01:00
|
|
|
{
|
|
|
|
public:
|
2007-09-08 12:45:14 +02:00
|
|
|
CLlconEvent ( int iNewMeTy, int iNewSt, int iNewChN = 0 ) :
|
2008-01-14 23:14:17 +01:00
|
|
|
QEvent ( QEvent::Type ( QEvent::User + 11 ) ), iMessType ( iNewMeTy ), iStatus ( iNewSt ),
|
2007-09-08 12:45:14 +02:00
|
|
|
iChanNum ( iNewChN ) {}
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
int iMessType;
|
|
|
|
int iStatus;
|
|
|
|
int iChanNum;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Prototypes for global functions ********************************************/
|
2007-09-09 11:50:22 +02:00
|
|
|
// command line parsing, TODO do not declare functions globally but in a class
|
2009-07-24 16:31:25 +02:00
|
|
|
std::string UsageArguments ( char** argv );
|
2010-03-12 21:25:30 +01:00
|
|
|
bool GetFlagArgument ( char** argv, int& i, std::string strShortOpt, std::string strLongOpt );
|
2009-07-24 16:31:25 +02:00
|
|
|
bool GetStringArgument ( int argc, char** argv, int& i, std::string strShortOpt, std::string strLongOpt, std::string& strArg );
|
|
|
|
bool GetNumericArgument ( int argc, char** argv, int& i, std::string strShortOpt, std::string strLongOpt, double rRangeStart, double rRangeStop, double& rValue);
|
2007-09-09 11:50:22 +02:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// posting a window message
|
|
|
|
void PostWinMessage ( const _MESSAGE_IDENT MessID, const int iMessageParam = 0,
|
|
|
|
const int iChanNum = 0 );
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
#endif /* !defined ( GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_ ) */
|