Commit 9c7683fd authored by Anne's avatar Anne
Browse files

NetServer edited

parent 88a8730d
......@@ -23,7 +23,6 @@
#include <ITASampleFrame.h>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
#include <string>
#include <vector>
......@@ -37,7 +36,7 @@ class VistaTCPServer;
* Can be connected to an ITADataSource as a streaming source
* or to a user-implemented sample producer, i.e. an audio sythesizer.
*/
class ITA_DATA_SOURCES_API CITANetAudioServer : public VistaThreadLoop
class ITA_DATA_SOURCES_API CITANetAudioServer
{
public:
CITANetAudioServer( CITANetAudioStreamingServer* pParent );
......@@ -45,8 +44,12 @@ public:
std::string GetServerAddress() const;
int GetNetworkPort() const;
double GetClientSampleRate() const;
bool Start( const std::string& sAddress, int iPort );
void Disconnect(); bool IsConnected() const; bool LoopBody();
void Disconnect();
bool IsConnected() const;
bool LoopBody();
private:
VistaTCPServer* m_pServer;
......@@ -61,10 +64,5 @@ private:
bool m_bStopIndicated;
int m_iClientChannels;
int m_iClientRingBufferSize;
int m_iClientBufferSize;
int m_iClientRingBufferFreeSamples;
double m_dClientSampleRate;
};
#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_SERVER
......@@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
#include <ITASampleFrame.h>
class ITADatasource;
......@@ -36,7 +37,7 @@ class CITANetAudioServer;
* \sa CITANetAudioStream
* \note not thread-safe
*/
class ITA_DATA_SOURCES_API CITANetAudioStreamingServer
class ITA_DATA_SOURCES_API CITANetAudioStreamingServer : public VistaThreadLoop
{
public:
......@@ -54,7 +55,7 @@ public:
bool IsClientConnected() const;
std::string GetNetworkAddress() const;
int GetNetworkPort() const;
int Stop();
void Stop();
void SetInputStream( ITADatasource* pInStream );
......@@ -76,6 +77,12 @@ private:
int m_iUpdateStrategy;
friend class CITANetAudioServer;
int m_iClientChannels;
int m_iClientRingBufferSize;
int m_iClientBufferSize;
int m_iClientRingBufferFreeSamples;
double m_dClientSampleRate;
};
#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_SERVER
......@@ -46,6 +46,11 @@ int CITANetAudioServer::GetNetworkPort() const
return m_iServerPort;
}
double CITANetAudioServer::GetClientSampleRate() const
{
return m_dClientSampleRate;
}
bool CITANetAudioServer::Start( const std::string& sAddress, int iPort )
{
if( m_pServer )
......@@ -58,6 +63,7 @@ bool CITANetAudioServer::Start( const std::string& sAddress, int iPort )
// blocking wait for connection
m_pSocket = m_pServer->GetNextClient();
// TODO: Init neu mit Netmessage
long nIncomingBytes = m_pSocket->WaitForIncomingData( 0 );
int iBytesReceived = m_pSocket->ReceiveRaw( &m_iClientChannels, sizeof( int ) );
iBytesReceived = m_pSocket->ReceiveRaw( &m_dClientSampleRate, sizeof( double ) );
......
......@@ -23,6 +23,7 @@ CITANetAudioStreamingServer::CITANetAudioStreamingServer()
, m_iUpdateStrategy( AUTO )
{
m_pNetAudioServer = new CITANetAudioServer( this );
// TODO: Init members
}
bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort )
......@@ -45,11 +46,31 @@ int CITANetAudioStreamingServer::GetNetworkPort() const
return m_pNetAudioServer->GetNetworkPort();
}
void CITANetAudioStreamingServer::Stop()
{
m_pNetAudioServer->Disconnect();
}
void CITANetAudioStreamingServer::SetInputStream( ITADatasource* pInStream )
{
m_pInputStream = pInStream;
}
int CITANetAudioStreamingServer::GetNetStreamBlocklength() const
{
return m_sfTempTransmitBuffer.GetLength();
}
int CITANetAudioStreamingServer::GetNetStreamNumberOfChannels() const
{
return m_sfTempTransmitBuffer.channels();
}
double CITANetAudioStreamingServer::GetNetStreamSampleRate() const
{
return m_pNetAudioServer->GetClientSampleRate();
}
void CITANetAudioStreamingServer::SetAutomaticUpdateRate()
{
m_iUpdateStrategy = AUTO;
......@@ -59,3 +80,8 @@ ITADatasource* CITANetAudioStreamingServer::GetInputStream() const
{
return m_pInputStream;
}
int CITANetAudioStreamingServer::Transmit(const ITASampleFrame& sfNewSamples, int iNumSamples)
{
return 1;
}
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