ITANetAudioStreamingClient.h 2.19 KB
Newer Older
1 2 3 4 5
/*
 * ----------------------------------------------------------------
 *
 *		ITA core libs
 *		(c) Copyright Institute of Technical Acoustics (ITA)
6
 *		RWTH Aachen University, Germany, 2015-2017
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * ----------------------------------------------------------------
 *				    ____  __________  _______
 *				   //  / //__   ___/ //  _   |
 *				  //  /    //  /    //  /_|  |
 *				 //  /    //  /    //  ___   |
 *				//__/    //__/    //__/   |__|
 *
 * ----------------------------------------------------------------
 *
 */

#ifndef INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_CLIENT
#define INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_CLIENT

#include <ITADataSourcesDefinitions.h>

24 25
#include <ITANetAudioProtocol.h>

26
#include <ITASampleFrame.h>
Anne's avatar
Anne committed
27
#include <ITAStreamProbe.h>
28

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
29
#include <VistaInterProcComm/Concurrency/VistaThreadEvent.h>
30 31
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>

32 33 34 35
#include <string>
#include <vector>

class CITANetAudioClient;
36 37 38
class CITANetAudioMessage;
class CITANetAudioProtocol;
class CITANetAudioStream;
Anne Heimes's avatar
Anne Heimes committed
39
class ITABufferedDataLoggerImplClient;
40 41 42 43

//! Network audio streaming client
/**
 * Audio streaming for a signal source that is connected via TCP/IP.
44 45 46
 * Implements the ITA network protocol for audio streaming on client side.
 *
 * @todo: move to src folder
47 48 49 50 51 52
 *
 * \note not thread-safe
 */
class ITA_DATA_SOURCES_API CITANetAudioStreamingClient : public VistaThreadLoop
{
public:
53
	CITANetAudioStreamingClient( CITANetAudioStream* pParent );
54 55 56 57
	virtual ~CITANetAudioStreamingClient();

	bool Connect( const std::string& sAddress, int iPort );
	bool GetIsConnected() const;
Dipl.-Ing. Jonas Stienen's avatar
Running  
Dipl.-Ing. Jonas Stienen committed
58
	void Disconnect();
59 60 61

	bool LoopBody();

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
62 63 64
protected:
	void TriggerBlockIncrement();

65 66 67 68
private:
	CITANetAudioClient* m_pClient;
	CITANetAudioStream* m_pStream;

69 70
	CITANetAudioProtocol* m_pProtocol;
	CITANetAudioMessage* m_pMessage;
Dipl.-Ing. Jonas Stienen's avatar
Running  
Dipl.-Ing. Jonas Stienen committed
71
	VistaConnectionIP* m_pConnection;
72

73
	//VistaThreadEvent m_oBlockIncrementEvent;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
74

75 76
	ITASampleFrame m_sfReceivingBuffer; //!< Buffer incoming data

77
	CITANetAudioProtocol::StreamingParameters m_oParams;
78

Dipl.-Ing. Jonas Stienen's avatar
Running  
Dipl.-Ing. Jonas Stienen committed
79
	bool m_bStopIndicated;
80 81 82
	bool m_bStopped;
	int iStreamingBlockId;
	ITABufferedDataLoggerImplClient* m_pClientLogger;
Dipl.-Ing. Jonas Stienen's avatar
Running  
Dipl.-Ing. Jonas Stienen committed
83

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
84
	friend class CITANetAudioStream;
85 86 87
};

#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_CLIENT