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 ( SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_ )
|
2006-12-18 15:39:33 +01:00
|
|
|
#define SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_
|
|
|
|
|
2008-01-20 19:07:13 +01:00
|
|
|
#include <qobject.h>
|
|
|
|
#include <qmessagebox.h>
|
|
|
|
#include <qudpsocket.h>
|
|
|
|
#include <qsocketnotifier.h>
|
2006-12-18 15:39:33 +01:00
|
|
|
#include <vector>
|
|
|
|
#include "global.h"
|
|
|
|
#include "channel.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Definitions ****************************************************************/
|
2009-03-01 12:17:35 +01: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 )
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* Classes ********************************************************************/
|
|
|
|
class CSocket : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2008-08-13 21:08:45 +02:00
|
|
|
CSocket ( CChannel* pNewChannel, const quint16 iPortNumber ) :
|
|
|
|
pChannel( pNewChannel ), bIsClient ( true ) { Init ( iPortNumber ); }
|
2008-07-22 17:17:19 +02:00
|
|
|
CSocket ( CChannelSet* pNewChannelSet, QObject* pNServP, const quint16 iPortNumber ) :
|
2009-03-08 09:31:55 +01:00
|
|
|
pChannelSet ( pNewChannelSet ), pServer ( pNServP ), bIsClient ( false )
|
2008-07-22 17:17:19 +02:00
|
|
|
{ Init ( iPortNumber ); }
|
2006-12-18 15:39:33 +01:00
|
|
|
virtual ~CSocket() {}
|
|
|
|
|
|
|
|
void SendPacket ( const CVector<unsigned char>& vecbySendBuf,
|
|
|
|
const CHostAddress& HostAddr );
|
|
|
|
|
|
|
|
protected:
|
2009-03-10 18:35:39 +01:00
|
|
|
void Init ( const quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER );
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2008-01-14 23:14:17 +01:00
|
|
|
QUdpSocket SocketDevice;
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
CVector<unsigned char> vecbyRecBuf;
|
|
|
|
CHostAddress RecHostAddr;
|
|
|
|
|
2009-03-08 09:31:55 +01:00
|
|
|
CChannel* pChannel; // for client
|
2007-09-08 12:45:14 +02:00
|
|
|
CChannelSet* pChannelSet; // for server
|
2006-02-26 11:50:47 +01:00
|
|
|
|
2006-12-18 15:39:33 +01:00
|
|
|
QObject* pServer;
|
|
|
|
bool bIsClient;
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void OnDataReceived();
|
|
|
|
};
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
#endif /* !defined ( SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_ ) */
|