return enabled state by a query function

This commit is contained in:
Volker Fischer 2011-04-23 20:44:09 +00:00
parent 1f87508104
commit 5e82a73b17

View file

@ -1,192 +1,193 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2011 * Copyright (c) 2004-2011
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
* *
****************************************************************************** ******************************************************************************
* *
* This program is free software; you can redistribute it and/or modify it under * 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 * 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 * Foundation; either version 2 of the License, or (at your option) any later
* version. * version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * 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 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * 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., * this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
\******************************************************************************/ \******************************************************************************/
#if !defined ( CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_ ) #if !defined ( CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_ )
#define CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_ #define CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_
#include <qthread.h> #include <qthread.h>
#include <qdatetime.h> #include <qdatetime.h>
#include <qfile.h> #include <qfile.h>
#include <qtextstream.h> #include <qtextstream.h>
#include "global.h" #include "global.h"
#include "buffer.h" #include "buffer.h"
#include "util.h" #include "util.h"
#include "protocol.h" #include "protocol.h"
/* Definitions ****************************************************************/ /* Definitions ****************************************************************/
// Set the time-out for the input buffer until the state changes from // Set the time-out for the input buffer until the state changes from
// connected to not connected (the actual time depends on the way the error // connected to not connected (the actual time depends on the way the error
// correction is implemented) // correction is implemented)
#define CON_TIME_OUT_SEC_MAX 30 // seconds #define CON_TIME_OUT_SEC_MAX 30 // seconds
enum EPutDataStat enum EPutDataStat
{ {
PS_GEN_ERROR, PS_GEN_ERROR,
PS_AUDIO_OK, PS_AUDIO_OK,
PS_AUDIO_ERR, PS_AUDIO_ERR,
PS_PROT_OK, PS_PROT_OK,
PS_PROT_OK_MESS_NOT_EVALUATED, PS_PROT_OK_MESS_NOT_EVALUATED,
PS_PROT_ERR PS_PROT_ERR
}; };
/* Classes ********************************************************************/ /* Classes ********************************************************************/
class CChannel : public QObject class CChannel : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
// we have to make "server" the default since I do not see a chance to // 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 // use constructor initialization in the server for a vector of channels
CChannel ( const bool bNIsServer = true ); CChannel ( const bool bNIsServer = true );
EPutDataStat PutData ( const CVector<uint8_t>& vecbyData, EPutDataStat PutData ( const CVector<uint8_t>& vecbyData,
int iNumBytes ); int iNumBytes );
EGetDataStat GetData ( CVector<uint8_t>& vecbyData ); EGetDataStat GetData ( CVector<uint8_t>& vecbyData );
CVector<uint8_t> PrepSendPacket ( const CVector<uint8_t>& vecbyNPacket ); CVector<uint8_t> PrepSendPacket ( const CVector<uint8_t>& vecbyNPacket );
void ResetTimeOutCounter() { iConTimeOut = iConTimeOutStartVal; } void ResetTimeOutCounter() { iConTimeOut = iConTimeOutStartVal; }
bool IsConnected() const { return iConTimeOut > 0; } bool IsConnected() const { return iConTimeOut > 0; }
void SetEnable ( const bool bNEnStat ); void SetEnable ( const bool bNEnStat );
bool IsEnabled() { return bIsEnabled; }
void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; }
bool GetAddress ( CHostAddress& RetAddr ); void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; }
CHostAddress GetAddress() const { return InetAddr; } bool GetAddress ( CHostAddress& RetAddr );
CHostAddress GetAddress() const { return InetAddr; }
void ResetName() { sName = ""; } // reset does not emit a message
void SetName ( const QString sNNa ); void ResetName() { sName = ""; } // reset does not emit a message
QString GetName(); void SetName ( const QString sNNa );
QString GetName();
void SetRemoteName ( const QString strName ) { Protocol.CreateChanNameMes ( strName ); }
void CreateReqChanNameMes() { Protocol.CreateReqChanNameMes(); } void SetRemoteName ( const QString strName ) { Protocol.CreateChanNameMes ( strName ); }
void CreateReqChanNameMes() { Protocol.CreateReqChanNameMes(); }
void SetGain ( const int iChanID, const double dNewGain );
double GetGain ( const int iChanID ); void SetGain ( const int iChanID, const double dNewGain );
double GetGain ( const int iChanID );
void SetRemoteChanGain ( const int iId, const double dGain )
{ Protocol.CreateChanGainMes ( iId, dGain ); } void SetRemoteChanGain ( const int iId, const double dGain )
{ Protocol.CreateChanGainMes ( iId, dGain ); }
bool SetSockBufNumFrames ( const int iNewNumFrames );
int GetSockBufNumFrames() const { return iCurSockBufNumFrames; } bool SetSockBufNumFrames ( const int iNewNumFrames );
int GetSockBufNumFrames() const { return iCurSockBufNumFrames; }
int GetUploadRateKbps();
int GetUploadRateKbps();
double GetTimingStdDev() { return CycleTimeVariance.GetStdDev(); }
double GetTimingStdDev() { return CycleTimeVariance.GetStdDev(); }
// set/get network out buffer size and size factor
void SetAudioStreamProperties ( const int iNewNetwFrameSize, // set/get network out buffer size and size factor
const int iNewNetwFrameSizeFact, void SetAudioStreamProperties ( const int iNewNetwFrameSize,
const int iNewNumAudioChannels ); const int iNewNetwFrameSizeFact,
int GetNetwFrameSizeFact() const { return iNetwFrameSizeFact; } const int iNewNumAudioChannels );
int GetNetwFrameSize() const { return iNetwFrameSize; } int GetNetwFrameSizeFact() const { return iNetwFrameSizeFact; }
int GetNumAudioChannels() const { return iNumAudioChannels; } int GetNetwFrameSize() const { return iNetwFrameSize; }
int GetNumAudioChannels() const { return iNumAudioChannels; }
double GetJitterBufferErrorRate() { return SockBuf.GetErrorRate(); }
double GetJitterBufferErrorRate() { return SockBuf.GetErrorRate(); }
// network protocol interface
void CreateJitBufMes ( const int iJitBufSize ) // network protocol interface
{ void CreateJitBufMes ( const int iJitBufSize )
if ( ProtocolIsEnabled() ) {
{ if ( ProtocolIsEnabled() )
Protocol.CreateJitBufMes ( iJitBufSize ); {
} Protocol.CreateJitBufMes ( iJitBufSize );
} }
void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); } }
void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); } void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); }
void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); } void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); }
void CreatePingMes ( const int iMs ) { Protocol.CreatePingMes ( iMs ); } void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); }
void CreatePingMes ( const int iMs ) { Protocol.CreatePingMes ( iMs ); }
void CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo )
{ void CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo )
Protocol.CreateConClientListMes ( vecChanInfo ); {
} Protocol.CreateConClientListMes ( vecChanInfo );
}
void CreateNetTranspPropsMessFromCurrentSettings();
void CreateAndImmSendDisconnectionMes() void CreateNetTranspPropsMessFromCurrentSettings();
{ Protocol.CreateAndImmSendDisconnectionMes(); } void CreateAndImmSendDisconnectionMes()
{ Protocol.CreateAndImmSendDisconnectionMes(); }
protected:
bool ProtocolIsEnabled(); protected:
bool ProtocolIsEnabled();
// connection parameters
CHostAddress InetAddr; // connection parameters
CHostAddress InetAddr;
// channel name
QString sName; // channel name
QString sName;
// mixer and effect settings
CVector<double> vecdGains; // mixer and effect settings
CVector<double> vecdGains;
// network jitter-buffer
CNetBuf SockBuf; // network jitter-buffer
int iCurSockBufNumFrames; CNetBuf SockBuf;
int iCurSockBufNumFrames;
CCycleTimeVariance CycleTimeVariance;
CCycleTimeVariance CycleTimeVariance;
// network output conversion buffer
CConvBuf<uint8_t> ConvBuf; // network output conversion buffer
CConvBuf<uint8_t> ConvBuf;
// network protocol
CProtocol Protocol; // network protocol
CProtocol Protocol;
int iConTimeOut;
int iConTimeOutStartVal; int iConTimeOut;
int iConTimeOutStartVal;
bool bIsEnabled;
bool bIsServer; bool bIsEnabled;
bool bIsServer;
int iNetwFrameSizeFact;
int iNetwFrameSize; int iNetwFrameSizeFact;
int iNetwFrameSize;
int iNumAudioChannels;
int iNumAudioChannels;
QMutex Mutex;
QMutex Mutex;
public slots:
void OnSendProtMessage ( CVector<uint8_t> vecMessage ); public slots:
void OnJittBufSizeChange ( int iNewJitBufSize ); void OnSendProtMessage ( CVector<uint8_t> vecMessage );
void OnChangeChanGain ( int iChanID, double dNewGain ); void OnJittBufSizeChange ( int iNewJitBufSize );
void OnChangeChanName ( QString strName ); void OnChangeChanGain ( int iChanID, double dNewGain );
void OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps ); void OnChangeChanName ( QString strName );
void OnReqNetTranspProps(); void OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps );
void OnDisconnection(); void OnReqNetTranspProps();
void OnDisconnection();
signals:
void MessReadyForSending ( CVector<uint8_t> vecMessage ); signals:
void NewConnection(); void MessReadyForSending ( CVector<uint8_t> vecMessage );
void ReqJittBufSize(); void NewConnection();
void ReqConnClientsList(); void ReqJittBufSize();
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo ); void ReqConnClientsList();
void NameHasChanged(); void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ReqChanName(); void NameHasChanged();
void ChatTextReceived ( QString strChatText ); void ReqChanName();
void PingReceived ( int iMs ); void ChatTextReceived ( QString strChatText );
void ReqNetTranspProps(); void PingReceived ( int iMs );
void Disconnected(); void ReqNetTranspProps();
}; void Disconnected();
};
#endif /* !defined ( CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_ ) */
#endif /* !defined ( CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_ ) */