Refactoring #2

parent 32d65f52
......@@ -110,23 +110,21 @@ endif( )
if( ITA_DATA_SOURCES_WITH_NET_AUDIO )
list( APPEND ITADataSourcesHeader
"include/ITANetAudioClient.h"
"include/ITANetAudioMessage.h"
"include/ITANetAudioProtocol.h"
"include/ITANetAudioServer.h"
"include/ITANetAudioStream.h"
"include/ITANetAudioStreamingClient.h"
"include/ITANetAudioStreamingServer.h"
"include/ITANetAudioStreamingClient.h"
)
list( APPEND ITADataSourcesSources
"src/ITANetAudioClient.cpp"
"src/ITANetAudioClient.h"
"src/ITANetAudioMessage.cpp"
"src/ITANetAudioProtocol.cpp"
"src/ITANetAudioMessage.h"
"src/ITANetAudioProtocol.h"
"src/ITANetAudioServer.cpp"
"src/ITANetAudioServer.h"
"src/ITANetAudioStream.cpp"
"src/ITANetAudioStreamingClient.cpp"
"src/ITANetAudioStreamingClient.h"
"src/ITANetAudioStreamingServer.cpp"
"src/ITANetAudioServer.cpp"
)
endif( )
......
......@@ -21,8 +21,6 @@
#include <ITADataSourcesDefinitions.h>
#include <ITANetAudioProtocol.h>
#include <ITANetAudioProtocol.h>
#include <ITASampleFrame.h>
#include <ITAStopWatch.h>
......@@ -40,6 +38,7 @@ class CITANetAudioServer;
class CITANetAudioMessage;
class VistaTCPSocket;
class ITABufferedDataLoggerImplServer;
class VistaConnectionIP;
//! Network audio streaming server (for connecting a net audio stream) with an ITADataSource connection
......@@ -97,7 +96,6 @@ private:
ITADatasource* m_pInputStream;
VistaConnectionIP* m_pConnection;
CITANetAudioProtocol::StreamingParameters m_oServerParams;
CITANetAudioMessage* m_pMessage;
ITABufferedDataLoggerImplServer* m_pServerLogger;
......@@ -110,6 +108,7 @@ private:
int m_iTargetLatencySamples;
int m_iEstimatedClientRingBufferFreeSamples;
int m_iClientRingBufferSize;
int m_iSendingBlockLength;
int m_iMaxSendBlocks;
......
#include <ITANetAudioClient.h>
#include "ITANetAudioClient.h"
#include <ITANetAudioMessage.h>
#include <ITANetAudioProtocol.h>
#include <ITANetAudioStream.h>
#include <ITAException.h>
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
......
#include <ITANetAudioMessage.h>
#include "ITANetAudioMessage.h"
#include <ITAClock.h>
#include <ITADataLog.h>
#include <ITAStringUtils.h>
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
#include <VistaBase/VistaExceptionBase.h>
#include <VistaBase/VistaStreamUtils.h>
#include <ITAClock.h>
#include <ITADataLog.h>
#include <cstring>
#include <algorithm>
#include <cstring>
#include <cassert>
#include <iostream>
#include <iomanip>
......
......@@ -21,11 +21,12 @@
#include <ITADataSourcesDefinitions.h>
#include "ITANetAudioProtocol.h"
// ITA includes
#include <ITAException.h>
#include <ITASampleBuffer.h>
#include <ITASampleFrame.h>
#include <ITANetAudioProtocol.h>
// Vista includes
#include <VistaInterProcComm/Connections/VistaByteBufferSerializer.h>
......
#include <ITANetAudioProtocol.h>
#include "ITANetAudioProtocol.h"
// @todo remove (all inline implemented)
\ No newline at end of file
#include <ITANetAudioServer.h>
#include "ITANetAudioServer.h"
#include "ITANetAudioProtocol.h"
#include <ITANetAudioStreamingServer.h>
#include <ITANetAudioProtocol.h>
// ITA includes
#include <ITADataSource.h>
......
......@@ -21,8 +21,6 @@
#include <ITADataSourcesDefinitions.h>
#include <ITANetAudioProtocol.h>
#include <ITASampleFrame.h>
#include <string>
......
#include <ITANetAudioStream.h>
#include <ITANetAudioStreamingClient.h>
#include "ITANetAudioStreamingClient.h"
// ITA includes
#include <ITAException.h>
......
#include <ITANetAudioStreamingClient.h>
#include "ITANetAudioStreamingClient.h"
#include "ITANetAudioClient.h"
#include "ITANetAudioMessage.h"
#include "ITANetAudioProtocol.h"
#include <ITANetAudioClient.h>
#include <ITANetAudioMessage.h>
#include <ITANetAudioStream.h>
#include <ITADataLog.h>
#include <ITAClock.h>
......@@ -57,18 +59,15 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP
, m_dServerClockSyncLastSyncTime( 0.0f )
{
m_pClient = new CITANetAudioClient();
m_oParams.iChannels = pParent->GetNumberOfChannels();
m_oParams.dSampleRate = pParent->GetSampleRate();
m_oParams.iBlockSize = pParent->GetBlocklength();
m_oParams.iRingBufferSize = pParent->GetRingBufferSize();
m_sfReceivingBuffer.init( m_oParams.iChannels, m_oParams.iRingBufferSize, false );
m_sfReceivingBuffer.init( pParent->GetNumberOfChannels(), pParent->GetRingBufferSize(), false );
m_pMessage = new CITANetAudioMessage( VistaSerializingToolset::SWAPS_MULTIBYTE_VALUES );
m_pClientLogger = new ITABufferedDataLoggerImplClient();
SetClientLoggerBaseName( "ITANetAudioStreamingClient" );
// Careful with this.
//SetPriority( VistaPriority::VISTA_MID_PRIORITY );
}
......@@ -103,9 +102,15 @@ bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPor
m_pMessage->ResetMessage();
m_pMessage->SetConnection( m_pConnection );
CITANetAudioProtocol::StreamingParameters oParams;
oParams.dSampleRate = m_pStream->GetSampleRate();
oParams.iBlockSize = m_pStream->GetBlocklength();
oParams.iChannels= m_pStream->GetNumberOfChannels();
oParams.iRingBufferSize = m_pStream->GetRingBufferSize();
// Validate streaming parameters of server and client
m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_OPEN );
m_pMessage->WriteStreamingParameters( m_oParams );
m_pMessage->WriteStreamingParameters( oParams );
m_pMessage->WriteMessage();
m_pMessage->ResetMessage();
......
......@@ -21,8 +21,6 @@
#include <ITADataSourcesDefinitions.h>
#include <ITANetAudioProtocol.h>
#include <ITASampleFrame.h>
#include <ITAStreamProbe.h>
#include <ITAStopWatch.h>
......@@ -38,6 +36,7 @@ class CITANetAudioMessage;
class CITANetAudioProtocol;
class CITANetAudioStream;
class ITABufferedDataLoggerImplClient;
class VistaConnectionIP;
//! Network audio streaming client
/**
......@@ -75,9 +74,7 @@ private:
VistaConnectionIP* m_pConnection;
ITASampleFrame m_sfReceivingBuffer; //!< Buffer incoming data
CITANetAudioProtocol::StreamingParameters m_oParams;
bool m_bStopIndicated;
bool m_bStopped;
......
#include <ITANetAudioStreamingServer.h>
#include <ITANetAudioServer.h>
#include <ITANetAudioMessage.h>
#include "ITANetAudioServer.h"
#include "ITANetAudioMessage.h"
// ITA includes
#include <ITADataSource.h>
#include <ITANetAudioMessage.h>
#include <ITAException.h>
#include <ITAStreamInfo.h>
#include <ITAClock.h>
......@@ -67,6 +67,7 @@ CITANetAudioStreamingServer::CITANetAudioStreamingServer()
, m_iMaxSendBlocks( 40 )
, m_iServerBlockId( 0 )
, m_iEstimatedClientRingBufferFreeSamples( 0 )
, m_iClientRingBufferSize( 0 )
{
// Careful with this:
//SetPriority( VistaPriority::VISTA_MID_PRIORITY );
......@@ -104,19 +105,23 @@ bool CITANetAudioStreamingServer::Start(const std::string& sAddress, int iPort,
assert( m_pMessage->GetMessageType() == CITANetAudioProtocol::NP_CLIENT_OPEN );
CITANetAudioProtocol::StreamingParameters oClientParams = m_pMessage->ReadStreamingParameters();
m_oServerParams.iRingBufferSize = oClientParams.iRingBufferSize;
m_oServerParams.iBlockSize = oClientParams.iBlockSize;
CITANetAudioProtocol::StreamingParameters oServerParams;
oServerParams.iRingBufferSize = oClientParams.iRingBufferSize;
oServerParams.iBlockSize = m_pInputStream->GetBlocklength();
oServerParams.dSampleRate = m_pInputStream->GetSampleRate();
oServerParams.iChannels = m_pInputStream->GetNumberOfChannels();
m_iEstimatedClientRingBufferFreeSamples = m_oServerParams.iRingBufferSize;
m_iSendingBlockLength = m_oServerParams.iBlockSize;
m_iEstimatedClientRingBufferFreeSamples = oServerParams.iRingBufferSize;
m_iClientRingBufferSize = oClientParams.iRingBufferSize;
m_iSendingBlockLength = oServerParams.iBlockSize;
m_sfTempTransmitBuffer.init( m_pInputStream->GetNumberOfChannels(), m_oServerParams.iRingBufferSize, true );
m_sfTempTransmitBuffer.init( m_pInputStream->GetNumberOfChannels(), oServerParams.iRingBufferSize, true );
m_pServerLogger = new ITABufferedDataLoggerImplServer();
m_pServerLogger->setOutputFile( m_sServerLogBaseName + "_Server.log" );
m_dLastTimeStamp = ITAClock::getDefaultClock()->getTime();
if( m_oServerParams == oClientParams )
if( oServerParams == oClientParams )
{
m_pMessage->SetMessageType( CITANetAudioProtocol::NP_SERVER_OPEN );
m_pMessage->WriteDouble( dTimeIntervalCientSendStatus );
......@@ -153,7 +158,7 @@ bool CITANetAudioStreamingServer::LoopBody()
oLog.iTransmittedSamples = 0;
// Sending Samples
int iEstimatedClientRingBufferTargetLatencyFreeSamples = m_iEstimatedClientRingBufferFreeSamples - ( m_oServerParams.iRingBufferSize - m_iTargetLatencySamples );
int iEstimatedClientRingBufferTargetLatencyFreeSamples = m_iEstimatedClientRingBufferFreeSamples - ( m_iClientRingBufferSize - m_iTargetLatencySamples );
if (iEstimatedClientRingBufferTargetLatencyFreeSamples >= m_iSendingBlockLength)
{
......@@ -256,9 +261,6 @@ void CITANetAudioStreamingServer::SetInputStream( ITADatasource* pInStream )
ITA_EXCEPT1( MODAL_EXCEPTION, "Streaming loop already running, can not change input stream" );
m_pInputStream = pInStream;
m_oServerParams.dSampleRate = m_pInputStream->GetSampleRate();
m_oServerParams.iBlockSize = m_pInputStream->GetBlocklength();
m_oServerParams.iChannels = m_pInputStream->GetNumberOfChannels();
}
ITADatasource* CITANetAudioStreamingServer::GetInputStream() const
......@@ -299,8 +301,12 @@ bool CITANetAudioStreamingServer::GetLoggingExportEnabled() const
void CITANetAudioStreamingServer::SetTargetLatencySamples( const int iTargetLatency )
{
// Streaming already set up?
if( IsClientConnected() && m_iTargetLatencySamples < m_oServerParams.iBlockSize )
ITA_EXCEPT1( INVALID_PARAMETER, "Target latency has to be at least the block size of the audio streaming at client side." );
if( IsClientConnected() )
ITA_EXCEPT1( MODAL_EXCEPTION, "Server not connected, client ring buffer unkown" );
if( m_pInputStream )
if( m_iTargetLatencySamples < m_pInputStream->GetBlocklength() )
ITA_EXCEPT1( INVALID_PARAMETER, "Target latency has to be at least the block size of the audio streaming at client side." );
m_iTargetLatencySamples = iTargetLatency;
}
......
cmake_minimum_required( VERSION 2.9 )
cmake_minimum_required( VERSION 2.9 )
project( ITANetAudioTests )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
......@@ -72,12 +73,12 @@ vista_install_all_dlls( bin )
set_property( TARGET ITANetAudioTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/NetAudio" )
if( NOT DEFINED ITA_NETAUDIO_SERVER_WITH_TESTS )
set( ITA_NETAUDIO_SERVER_WITH_TESTS "default value" CACHE STRING "localhost 12480 44100 32 2" )
set( ITA_NETAUDIO_SERVER_WITH_TESTS "localhost 12480 44100 32 2" CACHE STRING "default value")
endif( )
if( NOT DEFINED ITA_NETAUDIO_CLIENT_WITH_TESTS )
set( ITA_NETAUDIO_CLIENT_WITH_TESTS "default value" CACHE STRING "localhost 12480 44100 32 2 3200" )
set( ITA_NETAUDIO_CLIENT_WITH_TESTS "localhost 12480 44100 32 2 3200" CACHE STRING "default value" )
endif( )
vista_set_target_msvc_arguments( ITANetAudioStreamingPortaudioClientTest ITA_NETAUDIO_CLIENT_WITH_TESTS )
vista_set_target_msvc_arguments( ITANetAudioStreamingClientTest ITA_NETAUDIO_CLIENT_WITH_TESTS )
vista_set_target_msvc_arguments( ITANetAudioStreamingServerTest ITA_NETAUDIO_SERVER_WITH_TESTS )
vista_set_target_msvc_arguments( ITANetAudioStreamingPortaudioClientTest ${ITA_NETAUDIO_CLIENT_WITH_TESTS} )
vista_set_target_msvc_arguments( ITANetAudioStreamingClientTest ${ITA_NETAUDIO_CLIENT_WITH_TESTS} )
vista_set_target_msvc_arguments( ITANetAudioStreamingServerTest ${ITA_NETAUDIO_SERVER_WITH_TESTS} )
#include <ITANetAudioStreamingServer.h>
#include <ITANetAudioServer.h>
#include <ITAStreamFunctionGenerator.h>
#include <ITAStreamMultiplier1N.h>
#include <ITAFileDataSource.h>
#include <ITAException.h>
#include <VistaBase/VistaTimeUtils.h>
#include <iostream>
......
#include <cmath>
#include <iostream>
#include <string>
#include <ITANetAudioStreamingServer.h>
#include <ITANetAudioServer.h>
#include <ITANetAudioStream.h>
#include <ITAPortaudioInterface.h>
#include <ITAStreamFunctionGenerator.h>
......@@ -18,6 +13,10 @@
#include <VistaBase/VistaTimeUtils.h>
#include <VistaBase/VistaExceptionBase.h>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;
const static string g_sServerName = "localhost";
......
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