Finishing refactoring of classes, still not linking though.

parent 8865bb46
......@@ -25,6 +25,7 @@
#include <ITAException.h>
#include <ITASampleBuffer.h>
#include <ITASampleFrame.h>
#include <ITANetAudioProtocol.h>
// Vista includes
#include <VistaInterProcComm/Connections/VistaByteBufferSerializer.h>
......@@ -77,6 +78,7 @@ public:
void WriteString( const std::string& );
void WriteIntVector( const std::vector< int > );
void WriteFloatVector( const std::vector< float > );
void WriteStreamingParameters( const CITANetAudioProtocol::StreamingParameters &);
std::string ReadString();
int ReadInt();
......@@ -86,8 +88,8 @@ public:
double ReadDouble();
std::vector< int > ReadIntVector();
std::vector< float > ReadFloatVector();
CITANetAudioProtocol::StreamingParameters ReadStreamingParameters();
void WriteClientOpen();
private:
int m_nMessageType;
......
......@@ -63,6 +63,20 @@ public:
CITANetAudioProtocol();
virtual ~CITANetAudioProtocol();
struct StreamingParameters
{
int iChannels;
double dSampleRate;
int iBlockSize;
inline StreamingParameters()
{
iChannels = 0;
dSampleRate = 0.0f;
iBlockSize = 0;
};
};
};
#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_PROTOCOL
......@@ -38,7 +38,7 @@ class CITANetAudioStreamingClient;
class ITA_DATA_SOURCES_API CITANetAudioStream : public ITADatasource
{
public:
CITANetAudioStream( int iChannels, double dSamplingRate, int iBufferSize, int iRingBufferCapacity );
CITANetAudioStream( int iChannels, double dSamplingRate, int iBufferSize, int iRingBufferCapacity = 2048 );
virtual ~CITANetAudioStream();
bool Connect( const std::string& sAddress, int iPort );
......@@ -53,8 +53,17 @@ public:
void IncrementBlockPointer();
protected:
//! This method is called by the streaming client and pushes sampes into the ring buffer
/**
* \param sfNewSamples Sample buffer (multi channel) with sample data
* \param iNumSamples samples to be read from the sample frame (must be smaller or equal length)
*
* \return Number of free samples in ring buffer
*/
int Transmit( const ITASampleFrame& sfNewSamples, int iNumSamples );
int GetRingbufferFreeSamples();
private:
CITANetAudioStreamingClient* m_pNetAudioStreamingClient;
......
......@@ -21,6 +21,8 @@
#include <ITADataSourcesDefinitions.h>
#include <ITANetAudioProtocol.h>
#include <ITASampleFrame.h>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
......@@ -43,7 +45,7 @@ class CITANetAudioStream;
class ITA_DATA_SOURCES_API CITANetAudioStreamingClient : public VistaThreadLoop
{
public:
CITANetAudioStreamingClient( int iChannels, double dSamplingRate, int iBufferSize, int iRingBufferCapacity );
CITANetAudioStreamingClient( CITANetAudioStream* pParent );
virtual ~CITANetAudioStreamingClient();
bool Connect( const std::string& sAddress, int iPort );
......@@ -60,6 +62,9 @@ private:
ITASampleFrame m_sfReceivingBuffer; //!< Buffer incoming data
CITANetAudioProtocol::StreamingParameters m_oClientParams;
CITANetAudioProtocol::StreamingParameters m_oServerParams;
friend class CITANetAudioClient;
};
......
#include <ITANetAudioMessage.h>
#include <ITANetAudioProtocol.h>
#include <ITAStringUtils.h>
......@@ -377,7 +376,20 @@ std::vector<int> CITANetAudioMessage::ReadIntVector()
return viData;
}
void CITANetAudioMessage::WriteClientOpen()
CITANetAudioProtocol::StreamingParameters CITANetAudioMessage::ReadStreamingParameters()
{
SetMessageType( CITANetAudioProtocol::NP_CLIENT_OPEN );
CITANetAudioProtocol::StreamingParameters oParams;
oParams.iChannels = ReadInt();
oParams.dSampleRate = ReadDouble();
oParams.iBlockSize = ReadInt();
return oParams;
}
void CITANetAudioMessage::WriteStreamingParameters( const CITANetAudioProtocol::StreamingParameters & oParams )
{
WriteInt( oParams.iChannels );
WriteDouble( oParams.dSampleRate );
WriteInt( oParams.iBlockSize );
}
......@@ -2,17 +2,7 @@
// ITA includes
#include <ITAException.h>
#include <ITANetAudioMessage.h>
#include <ITANetAudioProtocol.h>
#include <ITANetAudioClient.h>
// Vista includes
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
#include <VistaInterProcComm/IPNet/VistaTCPServer.h>
#include <VistaInterProcComm/IPNet/VistaTCPSocket.h>
//#include <VistaBase/VistaTimeUtils.h>
#include <VistaInterProcComm/IPNet/VistaIPAddress.h>
#include <ITANetAudioStreamingClient.h>
// STL
#include <cmath>
......@@ -23,22 +13,25 @@ CITANetAudioStream::CITANetAudioStream( int iChannels, double dSamplingRate, int
, m_sfRingBuffer( iChannels, iRingBufferCapacity, true )
{
m_pNetAudioProducer = new CITANetAudioClient();
if( iBufferSize > iRingBufferCapacity )
ITA_EXCEPT1( INVALID_PARAMETER, "Ring buffer capacity can not be smaller than buffer size." );
m_pNetAudioStreamingClient = new CITANetAudioStreamingClient( this );
}
CITANetAudioStream::~CITANetAudioStream()
{
delete m_pNetAudioProducer;
delete m_pNetAudioStreamingClient;
}
bool CITANetAudioStream::Connect( const std::string& sAddress, int iPort )
{
return m_pNetAudioProducer->Connect( sAddress, iPort );
return m_pNetAudioStreamingClient->Connect( sAddress, iPort );
}
bool CITANetAudioStream::GetIsConnected() const
{
return m_pNetAudioProducer->GetIsConnected();
return m_pNetAudioStreamingClient->GetIsConnected();
}
const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* )
......@@ -59,6 +52,11 @@ int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSa
ITA_EXCEPT0( NOT_IMPLEMENTED );
}
int CITANetAudioStream::GetRingbufferFreeSamples()
{
ITA_EXCEPT0( NOT_IMPLEMENTED );
}
int CITANetAudioStream::GetRingBufferSize() const
{
return m_sfRingBuffer.GetLength();
......
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