Commit c3da6ef0 authored by Anne Heimes's avatar Anne Heimes

implement ClientLog

parent e6c73581
......@@ -36,6 +36,7 @@ class CITANetAudioClient;
class CITANetAudioMessage;
class CITANetAudioProtocol;
class CITANetAudioStream;
class ITABufferedDataLoggerImplClient;
//! Network audio streaming client
/**
......@@ -76,6 +77,8 @@ private:
CITANetAudioProtocol::StreamingParameters m_oParams;
bool m_bStopIndicated;
int iStreamingBlockId;
ITABufferedDataLoggerImplClient* m_pClientLogger;
friend class CITANetAudioStream;
};
......
......@@ -92,7 +92,7 @@ CITANetAudioStream::CITANetAudioStream( int iChannels, double dSamplingRate, int
, m_bRingBufferFull( false )
, m_iStreamingStatus( INVALID )
, m_dLastStreamingTimeCode( 0.0f )
, m_iTargetSampleLatency( 10*iBufferSize )
, m_iTargetSampleLatency( iRingBufferCapacity )
{
m_bRingBufferFull = false;
if( iBufferSize > iRingBufferCapacity )
......
......@@ -3,10 +3,45 @@
#include <ITANetAudioClient.h>
#include <ITANetAudioMessage.h>
#include <ITANetAudioStream.h>
#include <ITADataLog.h>
#include <ITAClock.h>
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
#include <VistaBase/VistaStreamUtils.h>
//! Audio streaming log item
struct ITAClientLog : public ITALogDataBase
{
inline static std::ostream& outputDesc( std::ostream& os )
{
os << "BlockId";
os << "\t" << "WorldTimeStamp";
os << "\t" << "ProtocolStatus";
os << "\t" << "FreeSamples";
os << std::endl;
return os;
};
inline std::ostream& outputData( std::ostream& os ) const
{
os << uiBlockId;
os << "\t" << std::setprecision( 12 ) << dWorldTimeStamp;
os << "\t" << iProtocolStatus;
os << "\t" << iFreeSamples;
os << std::endl;
return os;
};
unsigned int uiBlockId; //!< Block identifier (audio streaming)
double dWorldTimeStamp;
int iProtocolStatus; //!< ... usw
int iFreeSamples;
};
class ITABufferedDataLoggerImplClient : public ITABufferedDataLogger < ITAClientLog > {};
CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pParent )
: m_oBlockIncrementEvent( VistaThreadEvent::WAITABLE_EVENT )
, m_pStream( pParent )
......@@ -18,7 +53,9 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP
m_oParams.iChannels = pParent->GetNumberOfChannels();
m_oParams.dSampleRate = pParent->GetSampleRate();
m_oParams.iBlockSize = pParent->GetBlocklength();
m_pClientLogger = new ITABufferedDataLoggerImplClient( );
m_pClientLogger->setOutputFile("NetAudioLogClient.txt");
iStreamingBlockId = 0;
m_pMessage = new CITANetAudioMessage( VistaSerializingToolset::SWAPS_MULTIBYTE_VALUES );
}
......@@ -32,6 +69,7 @@ CITANetAudioStreamingClient::~CITANetAudioStreamingClient()
m_pMessage->WriteMessage();
m_pClient->Disconnect();
}
delete m_pClientLogger;
}
bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPort )
......@@ -66,6 +104,9 @@ bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPor
bool CITANetAudioStreamingClient::LoopBody()
{
ITAClientLog oLog;
oLog.uiBlockId = ++iStreamingBlockId;
if( m_bStopIndicated )
return true;
......@@ -74,6 +115,7 @@ bool CITANetAudioStreamingClient::LoopBody()
m_pMessage->SetConnection( m_pConnection );
m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_WAITING_FOR_SAMPLES );
int iFreeSamplesUntilAllowedReached = m_pStream->GetAllowedLatencySamples() - m_pStream->GetRingBufferAvailableSamples();
oLog.iFreeSamples = iFreeSamplesUntilAllowedReached;
if( iFreeSamplesUntilAllowedReached < 0 )
iFreeSamplesUntilAllowedReached = 0;
m_pMessage->WriteInt( iFreeSamplesUntilAllowedReached );
......@@ -108,7 +150,9 @@ bool CITANetAudioStreamingClient::LoopBody()
case CITANetAudioProtocol::NP_SERVER_GET_RINGBUFFER_FREE :
break;
}
oLog.iProtocolStatus = iAnswerType;
oLog.dWorldTimeStamp = ITAClock::getDefaultClock( )->getTime( );
m_pClientLogger->log( oLog );
return true;
}
......
......@@ -12,11 +12,11 @@
using namespace std;
//static string g_sServerName = "137.226.61.163";
static string g_sServerName = "137.226.61.67";
static string g_sServerName = "137.226.61.163";
static int g_iServerPort = 12480;
static double g_dSampleRate = 44100;
static int g_iBufferSize = 512;
static int g_iChannels = 500;
static int g_iBufferSize = 1024;
static int g_iChannels = 1;
int main( int , char** )
{
......@@ -57,7 +57,7 @@ int main( int , char** )
cout << "Connected." << endl;
// Playback
float fSeconds = 10.0f;
float fSeconds = 20.0f;
cout << "Playback started, waiting " << fSeconds << " seconds" << endl;
ITAPA.Sleep( fSeconds ); // blocking
cout << "Done." << endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment