ITANetAudioStreamingServer.cpp 2.13 KB
Newer Older
1
#include <ITANetAudioStreamingServer.h>
2
#include <ITANetAudioServer.h>
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

// ITA includes
#include <ITADataSource.h>
#include <ITAException.h>
#include <ITAStreamInfo.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
#include <cmath>
#include <cassert>

21 22 23
CITANetAudioStreamingServer::CITANetAudioStreamingServer()
	: m_pInputStream( NULL )
	, m_iUpdateStrategy( AUTO )
Anne's avatar
Anne committed
24
	, m_pSocket( NULL )
25
{
Anne's avatar
Anne committed
26
	m_pNetAudioServer = new CITANetAudioServer();
Anne's avatar
Anne committed
27
	// TODO: Init members
28
}
29

Anne's avatar
Anne committed
30
bool CITANetAudioStreamingServer::Start(const std::string& sAddress, int iPort)
31
{
Anne's avatar
Anne committed
32 33 34 35 36 37 38
	// TODO: vorrckgabe noch anfangen zu senden (Samples)
	if (m_pNetAudioServer->Start(sAddress, iPort))
	{
		m_pSocket = m_pNetAudioServer->GetSocket();
		return true;
	}
	return false;
39 40
}

41
bool CITANetAudioStreamingServer::IsClientConnected() const
42
{
43
	return m_pNetAudioServer->IsConnected();
44 45
}

46
std::string CITANetAudioStreamingServer::GetNetworkAddress() const
47
{
48
	return m_pNetAudioServer->GetServerAddress();
49 50
}

51
int CITANetAudioStreamingServer::GetNetworkPort() const
52
{
53
	return m_pNetAudioServer->GetNetworkPort();
54 55
}

Anne's avatar
Anne committed
56 57 58 59 60
void CITANetAudioStreamingServer::Stop() 
{
	m_pNetAudioServer->Disconnect();
}

61
void CITANetAudioStreamingServer::SetInputStream( ITADatasource* pInStream )
62
{
63
	m_pInputStream = pInStream;
64 65
}

Anne's avatar
Anne committed
66 67 68 69 70 71 72 73 74 75 76 77
int CITANetAudioStreamingServer::GetNetStreamBlocklength() const
{
	return m_sfTempTransmitBuffer.GetLength();
}

int CITANetAudioStreamingServer::GetNetStreamNumberOfChannels() const
{
	return m_sfTempTransmitBuffer.channels();
}

double CITANetAudioStreamingServer::GetNetStreamSampleRate() const
{
Anne's avatar
Anne committed
78
	return m_dClientSampleRate;
Anne's avatar
Anne committed
79 80
}

81
void CITANetAudioStreamingServer::SetAutomaticUpdateRate()
82
{
83
	m_iUpdateStrategy = AUTO;
84 85
}

86
ITADatasource* CITANetAudioStreamingServer::GetInputStream() const
87
{
88 89
	return m_pInputStream;
}
Anne's avatar
Anne committed
90 91 92 93 94

int CITANetAudioStreamingServer::Transmit(const ITASampleFrame& sfNewSamples, int iNumSamples)
{
	return 1;
}