2006-12-18 15:39:33 +01:00
|
|
|
/******************************************************************************\
|
2009-02-22 12:07:18 +01:00
|
|
|
* Copyright (c) 2004-2009
|
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.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
#if !defined ( CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_ )
|
2006-12-18 15:39:33 +01:00
|
|
|
#define CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_
|
|
|
|
|
2008-01-20 19:07:13 +01:00
|
|
|
#include <qthread.h>
|
|
|
|
#include <qdatetime.h>
|
2008-08-08 08:28:47 +02:00
|
|
|
#include <qfile.h>
|
|
|
|
#include <qtextstream.h>
|
2006-12-18 15:39:33 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "protocol.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Definitions ****************************************************************/
|
|
|
|
// Set the time-out for the input buffer until the state changes from
|
2009-05-09 23:20:42 +02:00
|
|
|
// connected to not connected (the actual time depends on the way the error
|
2006-12-09 11:04:27 +01:00
|
|
|
// correction is implemented)
|
2009-05-09 23:20:42 +02:00
|
|
|
#define CON_TIME_OUT_SEC_MAX 60 // seconds
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2006-03-06 18:04:07 +01:00
|
|
|
enum EPutDataStat
|
|
|
|
{
|
2006-11-25 15:46:57 +01:00
|
|
|
PS_GEN_ERROR,
|
|
|
|
PS_AUDIO_OK,
|
|
|
|
PS_AUDIO_ERR,
|
|
|
|
PS_PROT_OK,
|
|
|
|
PS_PROT_ERR
|
2006-12-09 11:40:18 +01:00
|
|
|
};
|
|
|
|
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
/* Classes ********************************************************************/
|
|
|
|
class CChannel : public QObject
|
2006-02-26 11:50:47 +01:00
|
|
|
{
|
2006-11-25 15:46:57 +01:00
|
|
|
Q_OBJECT
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
public:
|
2009-03-01 12:17:35 +01:00
|
|
|
// we have to make "server" the default since I do not see a chance to
|
|
|
|
// use constructor initialization in the server for a vector of channels
|
|
|
|
CChannel ( const bool bNIsServer = true );
|
2006-12-18 15:39:33 +01:00
|
|
|
virtual ~CChannel() {}
|
|
|
|
|
2009-03-28 21:02:21 +01:00
|
|
|
EPutDataStat PutData ( const CVector<uint8_t>& vecbyData,
|
2006-12-18 15:39:33 +01:00
|
|
|
int iNumBytes );
|
2009-07-24 16:31:25 +02:00
|
|
|
EGetDataStat GetData ( CVector<uint8_t>& vecbyData );
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2009-07-28 22:31:23 +02:00
|
|
|
CVector<uint8_t> PrepSendPacket ( const CVector<uint8_t>& vecbyNPacket );
|
2006-02-26 11:50:47 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
bool IsConnected() const { return iConTimeOut > 0; }
|
2006-12-09 11:04:27 +01:00
|
|
|
|
|
|
|
void SetEnable ( const bool bNEnStat );
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; }
|
|
|
|
bool GetAddress ( CHostAddress& RetAddr );
|
2009-07-26 09:29:32 +02:00
|
|
|
CHostAddress GetAddress() const { return InetAddr; }
|
2006-10-30 22:14:44 +01:00
|
|
|
|
2008-08-14 21:12:23 +02:00
|
|
|
void SetName ( const QString sNNa );
|
|
|
|
QString GetName();
|
2006-11-04 10:57:59 +01:00
|
|
|
|
2008-01-22 22:15:04 +01:00
|
|
|
void SetRemoteName ( const QString strName )
|
2006-12-10 12:06:14 +01:00
|
|
|
{ Protocol.CreateChanNameMes ( strName ); }
|
|
|
|
|
2008-08-14 21:12:23 +02:00
|
|
|
void SetGain ( const int iChanID, const double dNewGain );
|
|
|
|
double GetGain ( const int iChanID );
|
2006-12-09 16:00:24 +01:00
|
|
|
|
|
|
|
void SetRemoteChanGain ( const int iId, const double dGain )
|
|
|
|
{ Protocol.CreateChanGainMes ( iId, dGain ); }
|
2006-12-10 12:06:14 +01:00
|
|
|
|
2009-08-02 09:54:15 +02:00
|
|
|
bool SetSockBufNumFrames ( const int iNewNumFrames );
|
|
|
|
int GetSockBufNumFrames() const { return iCurSockBufNumFrames; }
|
2006-02-26 11:50:47 +01:00
|
|
|
|
2009-03-03 23:46:36 +01:00
|
|
|
int GetUploadRateKbps();
|
2009-03-01 12:17:35 +01:00
|
|
|
|
2009-03-17 07:50:00 +01:00
|
|
|
double GetTimingStdDev() { return CycleTimeVariance.GetStdDev(); }
|
|
|
|
|
2009-07-28 09:17:04 +02:00
|
|
|
// set/get network out buffer size and size factor
|
2009-07-28 22:31:23 +02:00
|
|
|
void SetNetwFrameSizeAndFact ( const int iNewNetwFrameSize,
|
|
|
|
const int iNewNetwFrameSizeFact );
|
|
|
|
int GetNetwFrameSizeFact() const { return iNetwFrameSizeFact; }
|
|
|
|
int GetNetwFrameSize() const { return iNetwFrameSize; }
|
2009-07-28 09:17:04 +02:00
|
|
|
|
2006-03-12 12:50:35 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
// network protocol interface
|
|
|
|
void CreateJitBufMes ( const int iJitBufSize )
|
|
|
|
{
|
2009-03-01 12:17:35 +01:00
|
|
|
if ( ProtocolIsEnabled() )
|
2006-11-25 15:46:57 +01:00
|
|
|
{
|
|
|
|
Protocol.CreateJitBufMes ( iJitBufSize );
|
|
|
|
}
|
|
|
|
}
|
2008-07-24 18:20:25 +02:00
|
|
|
void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); }
|
|
|
|
void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); }
|
|
|
|
void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); }
|
2008-08-10 23:56:03 +02:00
|
|
|
void CreatePingMes ( const int iMs ) { Protocol.CreatePingMes ( iMs ); }
|
2006-02-26 11:50:47 +01:00
|
|
|
|
2006-11-26 22:25:56 +01:00
|
|
|
void CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo )
|
2006-11-25 15:46:57 +01:00
|
|
|
{
|
2006-11-26 22:25:56 +01:00
|
|
|
Protocol.CreateConClientListMes ( vecChanInfo );
|
2006-11-25 15:46:57 +01:00
|
|
|
}
|
2006-03-12 12:50:35 +01:00
|
|
|
|
2009-03-01 21:53:12 +01:00
|
|
|
void CreateNetTranspPropsMessFromCurrentSettings();
|
2009-08-19 09:23:33 +02:00
|
|
|
void CreateAndImmSendDisconnectionMes()
|
|
|
|
{ Protocol.CreateAndImmSendDisconnectionMes(); }
|
2009-03-01 21:53:12 +01:00
|
|
|
|
2006-03-11 21:35:38 +01:00
|
|
|
protected:
|
2009-03-01 12:17:35 +01:00
|
|
|
bool ProtocolIsEnabled();
|
2008-08-14 21:12:23 +02:00
|
|
|
|
2006-12-18 15:39:33 +01:00
|
|
|
// connection parameters
|
2006-11-25 15:46:57 +01:00
|
|
|
CHostAddress InetAddr;
|
2006-10-30 22:14:44 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
// channel name
|
2008-01-22 22:15:04 +01:00
|
|
|
QString sName;
|
2006-11-04 10:57:59 +01:00
|
|
|
|
2006-11-26 22:25:56 +01:00
|
|
|
// mixer and effect settings
|
2006-12-18 15:39:33 +01:00
|
|
|
CVector<double> vecdGains;
|
|
|
|
|
|
|
|
// network jitter-buffer
|
2006-11-25 15:46:57 +01:00
|
|
|
CNetBuf SockBuf;
|
2009-08-02 09:54:15 +02:00
|
|
|
int iCurSockBufNumFrames;
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2009-03-17 07:50:00 +01:00
|
|
|
CCycleTimeVariance CycleTimeVariance;
|
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
// network output conversion buffer
|
2009-07-28 22:31:23 +02:00
|
|
|
CConvBuf<uint8_t> ConvBuf;
|
2006-02-20 22:09:36 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
// network protocol
|
|
|
|
CProtocol Protocol;
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
int iConTimeOut;
|
|
|
|
int iConTimeOutStartVal;
|
2006-03-11 21:35:38 +01:00
|
|
|
|
2006-12-09 11:04:27 +01:00
|
|
|
bool bIsEnabled;
|
2008-08-10 10:14:30 +02:00
|
|
|
bool bIsServer;
|
|
|
|
|
2009-07-28 22:31:23 +02:00
|
|
|
int iNetwFrameSizeFact;
|
|
|
|
int iNetwFrameSize;
|
2008-08-10 10:14:30 +02:00
|
|
|
|
|
|
|
QMutex Mutex;
|
2006-12-09 11:04:27 +01:00
|
|
|
|
2006-02-27 20:45:27 +01:00
|
|
|
public slots:
|
2006-11-25 15:46:57 +01:00
|
|
|
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
|
|
|
|
void OnJittBufSizeChange ( int iNewJitBufSize );
|
2006-12-06 21:22:41 +01:00
|
|
|
void OnChangeChanGain ( int iChanID, double dNewGain );
|
2008-01-22 22:15:04 +01:00
|
|
|
void OnChangeChanName ( QString strName );
|
2009-03-01 12:17:35 +01:00
|
|
|
void OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps );
|
2009-03-01 21:53:12 +01:00
|
|
|
void OnReqNetTranspProps();
|
2009-05-09 10:22:09 +02:00
|
|
|
void OnDisconnection();
|
2006-02-27 20:45:27 +01:00
|
|
|
|
2006-02-26 11:50:47 +01:00
|
|
|
signals:
|
2006-11-25 15:46:57 +01:00
|
|
|
void MessReadyForSending ( CVector<uint8_t> vecMessage );
|
|
|
|
void NewConnection();
|
|
|
|
void ReqJittBufSize();
|
2006-12-08 19:19:16 +01:00
|
|
|
void ReqConnClientsList();
|
2006-11-26 22:25:56 +01:00
|
|
|
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
|
2006-12-10 12:06:14 +01:00
|
|
|
void NameHasChanged();
|
2008-07-24 18:20:25 +02:00
|
|
|
void ChatTextReceived ( QString strChatText );
|
2008-08-10 23:56:03 +02:00
|
|
|
void PingReceived ( int iMs );
|
2009-03-01 21:53:12 +01:00
|
|
|
void ReqNetTranspProps();
|
2009-08-17 18:20:15 +02:00
|
|
|
void Disconnected();
|
2006-11-26 22:25:56 +01:00
|
|
|
};
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
#endif /* !defined ( CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_ ) */
|