Finishing refactoring of classes, still not linking though.

parent 8865bb46
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <ITAException.h> #include <ITAException.h>
#include <ITASampleBuffer.h> #include <ITASampleBuffer.h>
#include <ITASampleFrame.h> #include <ITASampleFrame.h>
#include <ITANetAudioProtocol.h>
// Vista includes // Vista includes
#include <VistaInterProcComm/Connections/VistaByteBufferSerializer.h> #include <VistaInterProcComm/Connections/VistaByteBufferSerializer.h>
...@@ -77,6 +78,7 @@ public: ...@@ -77,6 +78,7 @@ public:
void WriteString( const std::string& ); void WriteString( const std::string& );
void WriteIntVector( const std::vector< int > ); void WriteIntVector( const std::vector< int > );
void WriteFloatVector( const std::vector< float > ); void WriteFloatVector( const std::vector< float > );
void WriteStreamingParameters( const CITANetAudioProtocol::StreamingParameters &);
std::string ReadString(); std::string ReadString();
int ReadInt(); int ReadInt();
...@@ -86,8 +88,8 @@ public: ...@@ -86,8 +88,8 @@ public:
double ReadDouble(); double ReadDouble();
std::vector< int > ReadIntVector(); std::vector< int > ReadIntVector();
std::vector< float > ReadFloatVector(); std::vector< float > ReadFloatVector();
CITANetAudioProtocol::StreamingParameters ReadStreamingParameters();
void WriteClientOpen();
private: private:
int m_nMessageType; int m_nMessageType;
......
...@@ -63,6 +63,20 @@ public: ...@@ -63,6 +63,20 @@ public:
CITANetAudioProtocol(); CITANetAudioProtocol();
virtual ~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 #endif // INCLUDE_WATCHER_ITA_NET_AUDIO_PROTOCOL
...@@ -38,7 +38,7 @@ class CITANetAudioStreamingClient; ...@@ -38,7 +38,7 @@ class CITANetAudioStreamingClient;
class ITA_DATA_SOURCES_API CITANetAudioStream : public ITADatasource class ITA_DATA_SOURCES_API CITANetAudioStream : public ITADatasource
{ {
public: public:
CITANetAudioStream( int iChannels, double dSamplingRate, int iBufferSize, int iRingBufferCapacity ); CITANetAudioStream( int iChannels, double dSamplingRate, int iBufferSize, int iRingBufferCapacity = 2048 );
virtual ~CITANetAudioStream(); virtual ~CITANetAudioStream();
bool Connect( const std::string& sAddress, int iPort ); bool Connect( const std::string& sAddress, int iPort );
...@@ -53,8 +53,17 @@ public: ...@@ -53,8 +53,17 @@ public:
void IncrementBlockPointer(); void IncrementBlockPointer();
protected: 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 Transmit( const ITASampleFrame& sfNewSamples, int iNumSamples );
int GetRingbufferFreeSamples();
private: private:
CITANetAudioStreamingClient* m_pNetAudioStreamingClient; CITANetAudioStreamingClient* m_pNetAudioStreamingClient;
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include <ITADataSourcesDefinitions.h> #include <ITADataSourcesDefinitions.h>
#include <ITANetAudioProtocol.h>
#include <ITASampleFrame.h> #include <ITASampleFrame.h>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h> #include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
...@@ -43,7 +45,7 @@ class CITANetAudioStream; ...@@ -43,7 +45,7 @@ class CITANetAudioStream;
class ITA_DATA_SOURCES_API CITANetAudioStreamingClient : public VistaThreadLoop class ITA_DATA_SOURCES_API CITANetAudioStreamingClient : public VistaThreadLoop
{ {
public: public:
CITANetAudioStreamingClient( int iChannels, double dSamplingRate, int iBufferSize, int iRingBufferCapacity ); CITANetAudioStreamingClient( CITANetAudioStream* pParent );
virtual ~CITANetAudioStreamingClient(); virtual ~CITANetAudioStreamingClient();
bool Connect( const std::string& sAddress, int iPort ); bool Connect( const std::string& sAddress, int iPort );
...@@ -60,6 +62,9 @@ private: ...@@ -60,6 +62,9 @@ private:
ITASampleFrame m_sfReceivingBuffer; //!< Buffer incoming data ITASampleFrame m_sfReceivingBuffer; //!< Buffer incoming data
CITANetAudioProtocol::StreamingParameters m_oClientParams;
CITANetAudioProtocol::StreamingParameters m_oServerParams;
friend class CITANetAudioClient; friend class CITANetAudioClient;
}; };
......
#include <ITANetAudioMessage.h> #include <ITANetAudioMessage.h>
#include <ITANetAudioProtocol.h>
#include <ITAStringUtils.h> #include <ITAStringUtils.h>
...@@ -377,7 +376,20 @@ std::vector<int> CITANetAudioMessage::ReadIntVector() ...@@ -377,7 +376,20 @@ std::vector<int> CITANetAudioMessage::ReadIntVector()
return viData; 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 @@ ...@@ -2,17 +2,7 @@
// ITA includes // ITA includes
#include <ITAException.h> #include <ITAException.h>
#include <ITANetAudioMessage.h> #include <ITANetAudioStreamingClient.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>
// STL // STL
#include <cmath> #include <cmath>
...@@ -23,22 +13,25 @@ CITANetAudioStream::CITANetAudioStream( int iChannels, double dSamplingRate, int ...@@ -23,22 +13,25 @@ CITANetAudioStream::CITANetAudioStream( int iChannels, double dSamplingRate, int
, m_sfRingBuffer( iChannels, iRingBufferCapacity, true ) , 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() CITANetAudioStream::~CITANetAudioStream()
{ {
delete m_pNetAudioProducer; delete m_pNetAudioStreamingClient;
} }
bool CITANetAudioStream::Connect( const std::string& sAddress, int iPort ) 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 bool CITANetAudioStream::GetIsConnected() const
{ {
return m_pNetAudioProducer->GetIsConnected(); return m_pNetAudioStreamingClient->GetIsConnected();
} }
const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* ) const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* )
...@@ -59,6 +52,11 @@ int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSa ...@@ -59,6 +52,11 @@ int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSa
ITA_EXCEPT0( NOT_IMPLEMENTED ); ITA_EXCEPT0( NOT_IMPLEMENTED );
} }
int CITANetAudioStream::GetRingbufferFreeSamples()
{
ITA_EXCEPT0( NOT_IMPLEMENTED );
}
int CITANetAudioStream::GetRingBufferSize() const int CITANetAudioStream::GetRingBufferSize() const
{ {
return m_sfRingBuffer.GetLength(); 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