ITANetAudioStreamingServer.cpp 2.47 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
	// TODO: vorrckgabe noch anfangen zu senden (Samples)
	if (m_pNetAudioServer->Start(sAddress, iPort))
	{
		m_pSocket = m_pNetAudioServer->GetSocket();
36 37 38 39 40 41 42 43 44 45 46
		// TODO: Init neu mit Netmessage 
		long nIncomingBytes = m_pSocket->WaitForIncomingData(0);
		int iBytesReceived = m_pSocket->ReceiveRaw(&m_initData, sizeof( InitData ));
		m_iClientRingBufferFreeSamples = m_iClientRingBufferFreeSamples;

		int iMessageID = 1;
		m_pSocket->SendRaw(&iMessageID, sizeof(int));

		Run();

		return true;
Anne's avatar
Anne committed
47 48 49
		return true;
	}
	return false;
50 51
}

52
bool CITANetAudioStreamingServer::IsClientConnected() const
53
{
54
	return m_pNetAudioServer->IsConnected();
55 56
}

57
std::string CITANetAudioStreamingServer::GetNetworkAddress() const
58
{
59
	return m_pNetAudioServer->GetServerAddress();
60 61
}

62
int CITANetAudioStreamingServer::GetNetworkPort() const
63
{
64
	return m_pNetAudioServer->GetNetworkPort();
65 66
}

Anne's avatar
Anne committed
67 68 69 70 71
void CITANetAudioStreamingServer::Stop() 
{
	m_pNetAudioServer->Disconnect();
}

72
void CITANetAudioStreamingServer::SetInputStream( ITADatasource* pInStream )
73
{
74
	m_pInputStream = pInStream;
75 76
}

Anne's avatar
Anne committed
77 78 79 80 81 82 83 84 85 86 87 88
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
89
	return m_dClientSampleRate;
Anne's avatar
Anne committed
90 91
}

92
void CITANetAudioStreamingServer::SetAutomaticUpdateRate()
93
{
94
	m_iUpdateStrategy = AUTO;
95 96
}

97
ITADatasource* CITANetAudioStreamingServer::GetInputStream() const
98
{
99 100
	return m_pInputStream;
}
Anne's avatar
Anne committed
101 102 103

int CITANetAudioStreamingServer::Transmit(const ITASampleFrame& sfNewSamples, int iNumSamples)
{
104
	return 0;
Anne's avatar
Anne committed
105
}