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

#ifndef INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_CLIENT
#define INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_CLIENT

#include <ITADataSourcesDefinitions.h>

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

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

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

class CITANetAudioClient;
35 36 37
class CITANetAudioMessage;
class CITANetAudioProtocol;
class CITANetAudioStream;
Anne Heimes's avatar
Anne Heimes committed
38
class ITABufferedDataLoggerImplClient;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
39
class VistaConnectionIP;
40 41 42

//! Network audio streaming client
/**
43
 * Audio streaming for a signal source that is connected via TCP/IP or UDP.
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
	virtual ~CITANetAudioStreamingClient();

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

	bool LoopBody();

Jonas Stienen's avatar
Jonas Stienen committed
62 63 64
	std::string GetClientLoggerBaseName() const;
	void SetClientLoggerBaseName( const std::string& );

65
	void SetDebuggingEnabled( const bool bEnabled );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
66 67
	bool GetIsDebuggingEnabled() const;

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
68 69 70
protected:
	void TriggerBlockIncrement();

71 72 73 74
private:
	CITANetAudioClient* m_pClient;
	CITANetAudioStream* m_pStream;

75 76
	CITANetAudioProtocol* m_pProtocol;
	CITANetAudioMessage* m_pMessage;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
77
	VistaConnectionIP* m_pConnection;
78
	
79
	ITASampleFrame m_sfReceivingBuffer; //!< Buffer incoming data
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
80
	
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
81
	bool m_bStopIndicated;
82
	bool m_bStopped;
83 84 85 86 87 88

	int m_iStreamingBlockId;

	double m_dServerClockSyncRequestTimeInterval;
	double m_dServerClockSyncLastSyncTime;

89
	ITABufferedDataLoggerImplClient* m_pClientLogger;
Jonas Stienen's avatar
Jonas Stienen committed
90
	std::string m_sClientLoggerBaseName;
91
	ITAStopWatch m_swTryReadBlockStats, m_swTryReadAccessStats;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
92
	bool m_bDebuggingEnabled;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
93

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
94
	friend class CITANetAudioStream;
95 96 97
};

#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_CLIENT