Commit f8cea23d authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen

Merge remote-tracking branch 'remotes/origin/ba_2016_heimes' into develop

# Conflicts:
#	include/ITANetAudioMessage.h
#	include/ITANetAudioProtocol.h
#	include/ITANetAudioStreamingServer.h
#	src/ITANetAudioMessage.cpp
#	src/ITANetAudioStreamingClient.cpp
#	src/ITANetAudioStreamingServer.cpp
parents a7a4d983 c1f56f7a
......@@ -48,13 +48,15 @@ class VistaConnectionIP;
class ITA_DATA_SOURCES_API CITANetAudioMessage
{
public:
CITANetAudioMessage( VistaConnectionIP* );
CITANetAudioMessage( VistaSerializingToolset::ByteOrderSwapBehavior bSwapBuffers );
void SetConnection( VistaConnectionIP* );
VistaConnectionIP* GetConnection() const;
void ClearConnection();
void WriteMessage();
bool TryReadMessage();
// Returns false if no incomming data
bool ReadMessage( int timeout );
void ResetMessage();
......@@ -65,6 +67,7 @@ public:
void SetMessageType( int nType );
int GetMessageType() const;
void WriteInt( const int );
void WriteBool( const bool );
void WriteDouble( const double );
......@@ -94,12 +97,16 @@ public:
private:
int m_nMessageType;
int m_nMessageId;
unsigned long m_iBytesReceivedTotal;
VistaByteBufferSerializer m_oOutgoing; //!< Serialization buffer for messages
VistaByteBufferDeSerializer m_oIncoming; //!< Deserialization buffer for messages
std::vector< VistaType::byte > m_vecIncomingBuffer; // Net IO buffer
int m_nTimeoutMilliseconds; //!< Timeout for try-read message
VistaConnectionIP* m_pConnection;
//DEBUG
int i;
};
#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_MESSAGE
......@@ -47,20 +47,14 @@ class CITANetAudioStream;
class ITA_DATA_SOURCES_API CITANetAudioProtocol
{
public:
static const int NET_AUDIO_VERSION = 1;
static const int NP_INVALID = -1;
static const int NP_GET_VERSION_INFO = 1;
static const int NP_CLIENT_OPEN = 100;
static const int NP_CLIENT_CLOSE = 101;
static const int NP_CLIENT_WAITING_FOR_SAMPLES = 111;
static const int NP_CLIENT_SENDING_RINGBUFFER_FREE_SAMPLES = 111;
static const int NP_SERVER_CLOSE = 200;
static const int NP_SERVER_OPEN = 201;
static const int NP_SERVER_GET_RINGBUFFER_SIZE = 210;
static const int NP_SERVER_GET_RINGBUFFER_FREE = 211;
static const int NP_SERVER_SEND_SAMPLES = 222;
static const int NP_SERVER_OPEN = 200;
static const int NP_SERVER_CLOSE = 201;
static const int NP_SERVER_GET_RINGBUFFER_FREE_SAMPLES = 211;
static const int NP_SERVER_SENDING_SAMPLES = 222;
inline CITANetAudioProtocol() {};
inline ~CITANetAudioProtocol() {};
......@@ -70,17 +64,19 @@ public:
int iChannels;
double dSampleRate;
int iBlockSize;
int iRingBufferSize;
inline StreamingParameters()
{
iChannels = 0;
dSampleRate = 0.0f;
iBlockSize = 0;
iRingBufferSize = 0;
};
inline bool operator==( const StreamingParameters& rhs )
{
if( ( iChannels == rhs.iChannels ) && ( dSampleRate == rhs.dSampleRate ) && ( iBlockSize == rhs.iBlockSize ) )
if ( ( iChannels == rhs.iChannels ) && ( dSampleRate == rhs.dSampleRate ) && ( iBlockSize == rhs.iBlockSize ) && ( iRingBufferSize == rhs.iRingBufferSize ) )
return true;
else
return false;
......
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_SERVER
#define INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_SERVER
#include <ITADataSourcesDefinitions.h>
#include <ITANetAudioProtocol.h>
#include <string>
#include <vector>
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_SERVER
#define INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_SERVER
#include <ITADataSourcesDefinitions.h>
#include <ITANetAudioProtocol.h>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <ITANetAudioProtocol.h>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
#include <ITASampleFrame.h>
class ITADatasource;
class CITANetAudioMessage;
class CITANetAudioProtocol;
class CITANetAudioServer;
class CITANetAudioMessage;
class VistaTCPSocket;
//! Network audio sample server (for connecting a net audio stream)
/**
* Audio sample transmitter for a networked signal source that can connect via TCP/IP.
*
* \sa CITANetAudioStream
* \note not thread-safe
*/
class ITA_DATA_SOURCES_API CITANetAudioStreamingServer : public VistaThreadLoop
{
public:
enum UpdateStrategy
{
AUTO = 1, //!< Automatic update rate based on sample rate and block length of client (default)
ADAPTIVE, //!< Adaptive update rate, adjusts for drifting clocks
CONSTANT, //!< Set a user-defined update rate (may cause forced pausing of sample feeding or dropouts on client side)
};
CITANetAudioStreamingServer();
virtual ~CITANetAudioStreamingServer() {};
bool Start( const std::string& sAddress, int iPort );
bool IsClientConnected() const;
std::string GetNetworkAddress() const;
int GetNetworkPort() const;
bool LoopBody();
void Stop();
void SetInputStream( ITADatasource* pInStream );
int GetNetStreamBlocklength() const;
int GetNetStreamNumberOfChannels() const;
double GetNetStreamSampleRate() const;
void SetAutomaticUpdateRate();
protected:
ITADatasource* GetInputStream() const;
private:
CITANetAudioServer* m_pNetAudioServer;
ITASampleFrame m_sfTempTransmitBuffer;
ITADatasource* m_pInputStream;
VistaConnectionIP* m_pConnection;
CITANetAudioProtocol::StreamingParameters m_oServerParams;
CITANetAudioMessage* m_pIncomingMessage;
CITANetAudioMessage* m_pOutgoingMessage;
int m_iUpdateStrategy;
int m_iClientRingBufferFreeSamples;
friend class CITANetAudioServer;
};
#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_SERVER
#include <fstream>
#include <ITANetAudioProtocol.h>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
#include <ITASampleFrame.h>
class ITADatasource;
class CITANetAudioMessage;
class CITANetAudioProtocol;
class CITANetAudioServer;
class CITANetAudioMessage;
class VistaTCPSocket;
class ITABufferedDataLoggerImplServer;
//! Network audio sample server (for connecting a net audio stream)
/**
* Audio sample transmitter for a networked signal source that can connect via TCP/IP.
*
* \sa CITANetAudioStream
* \note not thread-safe
*/
class ITA_DATA_SOURCES_API CITANetAudioStreamingServer : public VistaThreadLoop
{
public:
enum UpdateStrategy
{
AUTO = 1, //!< Automatic update rate based on sample rate and block length of client (default)
ADAPTIVE, //!< Adaptive update rate, adjusts for drifting clocks
CONSTANT, //!< Set a user-defined update rate (may cause forced pausing of sample feeding or dropouts on client side)
};
CITANetAudioStreamingServer();
virtual ~CITANetAudioStreamingServer() {};
bool Start( const std::string& sAddress, int iPort );
bool IsClientConnected() const;
std::string GetNetworkAddress() const;
int GetNetworkPort() const;
bool LoopBody();
void Stop();
void SetInputStream( ITADatasource* pInStream );
int GetNetStreamBlocklength() const;
int GetNetStreamNumberOfChannels() const;
double GetNetStreamSampleRate() const;
void SetAutomaticUpdateRate();
protected:
ITADatasource* GetInputStream() const;
private:
CITANetAudioServer* m_pNetAudioServer;
ITASampleFrame m_sfTempTransmitBuffer;
ITADatasource* m_pInputStream;
VistaConnectionIP* m_pConnection;
CITANetAudioProtocol::StreamingParameters m_oServerParams;
CITANetAudioMessage* m_pMessage;
int iServerBlockId;
ITABufferedDataLoggerImplServer* m_pServerLogger;
int m_iUpdateStrategy;
int m_iClientRingBufferFreeSamples;
int m_iMaxSendBlocks;
friend class CITANetAudioServer;
};
#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_SERVER
......@@ -4,6 +4,7 @@
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
#include <VistaBase/VistaExceptionBase.h>
#include <VistaBase/VistaStreamUtils.h>
#include <ITAClock.h>
#include <cstring>
#include <algorithm>
......@@ -13,14 +14,14 @@
static int S_nMessageIds = 0;
CITANetAudioMessage::CITANetAudioMessage( VistaConnectionIP* pConnection )
CITANetAudioMessage::CITANetAudioMessage( VistaSerializingToolset::ByteOrderSwapBehavior bSwapBuffers )
: m_vecIncomingBuffer( 2048 )
, m_oOutgoing( 2048 )
, m_pConnection( pConnection )
, m_nTimeoutMilliseconds( 1 )
, m_pConnection( NULL )
, m_iBytesReceivedTotal(0)
{
m_oOutgoing.SetByteorderSwapFlag( pConnection->GetByteorderSwapFlag() );
m_oIncoming.SetByteorderSwapFlag( pConnection->GetByteorderSwapFlag() );
m_oOutgoing.SetByteorderSwapFlag( bSwapBuffers );
m_oIncoming.SetByteorderSwapFlag( bSwapBuffers );
ResetMessage();
}
......@@ -44,13 +45,20 @@ void CITANetAudioMessage::ResetMessage()
m_oIncoming.SetBuffer( NULL, 0 );
m_nMessageType = CITANetAudioProtocol::NP_INVALID;
m_nMessageType = -1;
//m_pConnection = NULL;
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [Preparing] (id=" << std::setw( 4 ) << m_nMessageId << ")" << std::endl;
#endif
}
void CITANetAudioMessage::SetConnection( VistaConnectionIP* pConn )
{
m_pConnection = pConn;
}
void CITANetAudioMessage::WriteMessage()
{
VistaType::byte* pBuffer = ( VistaType::byte* ) m_oOutgoing.GetBuffer();
......@@ -86,7 +94,6 @@ void CITANetAudioMessage::WriteMessage()
{
// It appears safe to send even very big data payload, so we will send at once
int iRawBufferSize = m_oOutgoing.GetBufferSize();
assert( iRawBufferSize > 4 );
int nRet = m_pConnection->Send( m_oOutgoing.GetBuffer(), iRawBufferSize );
#if NET_AUDIO_SHOW_TRAFFIC
......@@ -94,30 +101,31 @@ void CITANetAudioMessage::WriteMessage()
#endif
m_pConnection->WaitForSendFinish();
if( nRet != m_oOutgoing.GetBufferSize() )
VISTA_THROW( "ITANetAudioMessage: could not send all data from output buffer via network connection", 255 );
//if( nRet != m_oOutgoing.GetBufferSize() )
//VISTA_THROW( "ITANetAudioMessage: could not send all data from output buffer via network connection", 255 );
}
catch( VistaExceptionBase& ex )
catch (VistaExceptionBase& ex)
{
ITA_EXCEPT1( NETWORK_ERROR, ex.GetExceptionText() );
}
}
bool CITANetAudioMessage::TryReadMessage()
bool CITANetAudioMessage::ReadMessage( int timeout)
{
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [ TryRead ] Waiting for incoming data for " << m_nTimeoutMilliseconds << std::endl;
#endif
long nIncomingBytes = m_pConnection->WaitForIncomingData( m_nTimeoutMilliseconds );
if( nIncomingBytes <= 0 )
{
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [ TryRead ] nothing incoming" << std::endl;
vstr::out() << "CITANetAudioMessage [ Reading ] Waiting for incoming data" << std::endl;
#endif
// WaitForIncomming Data int in ca ms
long nIncomingBytes = m_pConnection->WaitForIncomingData( timeout );
// TODO Timer entfernen
if (nIncomingBytes == -1)
return false;
}
assert( nIncomingBytes >= 4 ); // we need at least the size of message
else
int a = 5;
if (timeout != 0)
nIncomingBytes = m_pConnection->WaitForIncomingData( 0 );
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [ Reading ] " << nIncomingBytes << " bytes incoming" << std::endl;
#endif
......@@ -128,23 +136,30 @@ bool CITANetAudioMessage::TryReadMessage()
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [ Reading ] Expecting " << nMessagePayloadSize << " bytes message payload" << std::endl;
#endif
if (nMessagePayloadSize <= 0)
return false;
// we need at least the two protocol ints
//assert( nMessagePayloadSize >= 2 * sizeof( VistaType::sint32 ) );
if( nMessagePayloadSize > ( int ) m_vecIncomingBuffer.size() )
m_vecIncomingBuffer.resize( nMessagePayloadSize );
// Receive all incoming data (potentially splitted)
int iBytesReceivedTotal = 0;
while( nMessagePayloadSize < iBytesReceivedTotal )
while (nMessagePayloadSize > m_iBytesReceivedTotal)
{
int iIncommingBytes = m_pConnection->WaitForIncomingData( 0 );
int iBytesReceived = m_pConnection->Receive( &m_vecIncomingBuffer[ iBytesReceivedTotal ], iIncommingBytes );
iBytesReceivedTotal += iBytesReceived;
int iBytesReceived;
if ( nMessagePayloadSize < iIncommingBytes )
iBytesReceived = m_pConnection->Receive(&m_vecIncomingBuffer[m_iBytesReceivedTotal], nMessagePayloadSize - m_iBytesReceivedTotal);
else
iBytesReceived = m_pConnection->Receive(&m_vecIncomingBuffer[m_iBytesReceivedTotal], iIncommingBytes);
m_iBytesReceivedTotal += iBytesReceived;
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "[ CITANetAudioMessage ] " << std::setw( 3 ) << std::floor( iBytesReceivedTotal / float( nMessagePayloadSize ) * 100.0f ) << "% transmitted" << std::endl;
#endif
}
m_iBytesReceivedTotal = 0;
// Transfer data into members
m_oIncoming.SetBuffer( &m_vecIncomingBuffer[ 0 ], nMessagePayloadSize, false );
......@@ -154,7 +169,6 @@ bool CITANetAudioMessage::TryReadMessage()
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [ Reading ] Finished receiving " << m_nMessageType << " (id=" << std::setw( 4 ) << m_nMessageId << ")" << std::endl;
#endif
return true;
}
......@@ -165,7 +179,7 @@ int CITANetAudioMessage::GetMessageType() const
void CITANetAudioMessage::SetMessageType( int nType )
{
assert( m_nMessageType == CITANetAudioProtocol::NP_INVALID ); // should only be set once
//assert( m_nMessageType == CITANetAudioProtocol::NP_INVALID ); // should only be set once
m_nMessageType = nType;
}
......@@ -305,8 +319,9 @@ CITANetAudioProtocol::StreamingParameters CITANetAudioMessage::ReadStreamingPara
CITANetAudioProtocol::StreamingParameters oParams;
oParams.iChannels = ReadInt();
oParams.dSampleRate = ReadDouble();
oParams.iBlockSize = ReadInt();
oParams.dSampleRate = ReadDouble( );
oParams.iBlockSize = ReadInt( );
oParams.iRingBufferSize = ReadInt( );
return oParams;
}
......@@ -316,6 +331,7 @@ void CITANetAudioMessage::WriteStreamingParameters( const CITANetAudioProtocol::
WriteInt( oParams.iChannels );
WriteDouble( oParams.dSampleRate );
WriteInt( oParams.iBlockSize );
WriteInt( oParams.iRingBufferSize );
}
int CITANetAudioMessage::ReadRingBufferSize()
......@@ -342,7 +358,6 @@ void CITANetAudioMessage::ReadSampleFrame( ITASampleFrame* pSampleFrame )
{
int iChannels = ReadInt();
int iSamples = ReadInt();
if( pSampleFrame->channels() != iChannels || pSampleFrame->GetLength() != iSamples )
pSampleFrame->init( iChannels, iSamples, false );
......@@ -368,3 +383,4 @@ void CITANetAudioMessage::WriteSampleFrame( ITASampleFrame* pSamples )
}
}
}
......@@ -236,14 +236,16 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
if( !GetIsConnected() )
{
m_sfOutputStreamBuffer[ uiChannel ].Zero( );
m_iStreamingStatus = STOPPED;
if (uiChannel == 0 )
m_iStreamingStatus = STOPPED;
}
else
{
if( GetIsRingBufferEmpty() )
{
m_sfOutputStreamBuffer[ uiChannel ].Zero();
m_iStreamingStatus = BUFFER_UNDERRUN;
if (uiChannel == 0 )
m_iStreamingStatus = BUFFER_UNDERRUN;
#if NET_AUDIO_SHOW_TRAFFIC
//vstr::out() << "[ Stream ] Buffer underrun" << std::endl;
#endif
......@@ -254,7 +256,8 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
{
// @todo: fade out
m_sfRingBuffer[ uiChannel ].Zero();
m_iStreamingStatus = BUFFER_UNDERRUN;
if (uiChannel == 0 )
m_iStreamingStatus = BUFFER_UNDERRUN;
#if NET_AUDIO_SHOW_TRAFFIC
//vstr::out() << "[ Stream ] Buffer underrun" << std::endl;
#endif
......@@ -263,7 +266,8 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
{
// Normal behaviour (if everything is OK with ring buffer status)
m_sfRingBuffer[ uiChannel ].cyclic_read( m_sfOutputStreamBuffer[ uiChannel ].GetData(), GetBlocklength(), m_iReadCursor );
m_iStreamingStatus = STREAMING;
if ( uiChannel == 0 )
m_iStreamingStatus = STREAMING;
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "[ Stream ] Streaming" << std::endl;
#endif
......@@ -274,6 +278,7 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
if( uiChannel == 0 )
m_dLastStreamingTimeCode = pInfo->dTimecode;
return m_sfOutputStreamBuffer[uiChannel].GetData();
}
......@@ -283,26 +288,26 @@ void CITANetAudioStream::IncrementBlockPointer()
int iSavedSample = GetRingBufferSize( ) - GetRingBufferFreeSamples( );
if ( !GetIsConnected( ) )
{
m_iStreamingStatus = STOPPED;
//m_iStreamingStatus = STOPPED;
} else if ( iSavedSample >= int( GetBlocklength( ) ) )
{
//es wurden Samples abgespielt
m_iReadCursor = ( m_iReadCursor + m_sfOutputStreamBuffer.GetLength() ) % m_sfRingBuffer.GetLength();
m_iStreamingStatus = STREAMING;
//m_iStreamingStatus = STREAMING;
#if NET_AUDIO_SHOW_TRAFFIC
//vstr::out() << "[ Stream ] Streaming" << std::endl;
#endif
}
else if ( GetIsRingBufferEmpty( ) )
{
m_iStreamingStatus = BUFFER_UNDERRUN;
//m_iStreamingStatus = BUFFER_UNDERRUN;
#if NET_AUDIO_SHOW_TRAFFIC
//vstr::out() << "[ Stream ] Buffer underrun" << std::endl;
#endif
}
else
{
m_iStreamingStatus = BUFFER_UNDERRUN;
//m_iStreamingStatus = BUFFER_UNDERRUN;
#if NET_AUDIO_SHOW_TRAFFIC
//vstr::out() << "[ Stream ] Buffer underrun" << std::endl;
#endif
......@@ -310,15 +315,15 @@ void CITANetAudioStream::IncrementBlockPointer()
}
m_bRingBufferFull = false;
ITAStreamLog oLog;
ITAStreamLog oLog;
oLog.iStreamingStatus = m_iStreamingStatus;
oLog.dWorldTimeStamp = ITAClock::getDefaultClock()->getTime();
oLog.dStreamingTimeCode = m_dLastStreamingTimeCode;
oLog.uiBlockId = ++iAudioStreamingBlockID;
oLog.iFreeSamples = GetRingBufferFreeSamples( );
m_pStreamLogger->log( oLog );
//m_pStreamLogger->log( oLog );
m_pNetAudioStreamingClient->TriggerBlockIncrement();
//m_pNetAudioStreamingClient->TriggerBlockIncrement();
}
int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSamples )
......
......@@ -54,18 +54,35 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP
m_pClient = new CITANetAudioClient();
m_oParams.iChannels = pParent->GetNumberOfChannels();
m_oParams.dSampleRate = pParent->GetSampleRate();
m_oParams.iBlockSize = pParent->GetBlocklength();
m_oParams.dSampleRate = pParent->GetSampleRate( );
m_oParams.iBlockSize = pParent->GetBlocklength( );
m_oParams.iRingBufferSize = pParent->GetRingBufferSize( );
std::string paras = std::string("NetAudioLogClient") + std::string("_BS") + std::to_string(pParent->GetBlocklength()) + std::string("_Ch") + std::to_string(pParent->GetNumberOfChannels()) + std::string(".txt");
m_pClientLogger = new ITABufferedDataLoggerImplClient( );
m_pClientLogger->setOutputFile(paras);
iStreamingBlockId = 0;
m_pMessage = new CITANetAudioMessage( VistaSerializingToolset::SWAPS_MULTIBYTE_VALUES );
m_sfReceivingBuffer.init(m_oParams.iChannels, m_oParams.iRingBufferSize, false);
}
CITANetAudioStreamingClient::~CITANetAudioStreamingClient()
{
delete m_pClientLogger;
//try{
if (m_pConnection != NULL && m_pConnection->GetIsConnected())
{
m_pMessage->ResetMessage();
m_pMessage->SetConnection(m_pConnection);
m_pMessage->SetMessageType(CITANetAudioProtocol::NP_CLIENT_CLOSE);
m_pMessage->WriteBool(true);
m_pMessage->WriteMessage();
//m_pClient->Disconnect();
}
delete m_pClientLogger;
//}
//catch (ITAException e){
// std::cout << e << std::endl;
//}
}
bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPort )
......@@ -78,13 +95,22 @@ bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPor
m_pConnection = m_pClient->GetConnection();
m_pIncomingMessage = new CITANetAudioMessage( m_pConnection );
m_pOutgoingMessage = new CITANetAudioMessage( m_pConnection );
m_pMessage->ResetMessage();
m_pMessage->SetConnection( m_pConnection );
// Validate streaming parameters of server and client
m_pOutgoingMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_OPEN );
m_pOutgoingMessage->WriteStreamingParameters( m_oParams );
m_pOutgoingMessage->WriteMessage();
m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_OPEN );
m_pMessage->WriteStreamingParameters( m_oParams );
m_pMessage->WriteMessage( );
m_pMessage->ResetMessage( );
while ( !m_pMessage->ReadMessage( 0 ) );
assert( m_pMessage->GetMessageType( ) == CITANetAudioProtocol::NP_SERVER_OPEN );
bool bOK = m_pMessage->ReadBool();
if( !bOK )
ITA_EXCEPT1( INVALID_PARAMETER, "Streaming server declined connection, detected streaming parameter mismatch." );
Run();
......@@ -99,54 +125,54 @@ bool CITANetAudioStreamingClient::LoopBody()
if( m_bStopIndicated )
return true;
// Send message to server that (and how many) samples can be received
m_pIncomingMessage->ResetMessage();