ITANetAudioStreamingClient.h 2.46 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
#include <ITAStopWatch.h>
29

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

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

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

//! Network audio streaming client
/**
 * Audio streaming for a signal source that is connected via TCP/IP.
45 46 47
 * Implements the ITA network protocol for audio streaming on client side.
 *
 * @todo: move to src folder
48 49 50 51 52 53
 *
 * \note not thread-safe
 */
class ITA_DATA_SOURCES_API CITANetAudioStreamingClient : public VistaThreadLoop
{
public:
54
	CITANetAudioStreamingClient( CITANetAudioStream* pParent );
55 56 57 58
	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
59
	void Disconnect();
60 61 62

	bool LoopBody();

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

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

69 70 71 72
private:
	CITANetAudioClient* m_pClient;
	CITANetAudioStream* m_pStream;

73 74
	CITANetAudioProtocol* m_pProtocol;
	CITANetAudioMessage* m_pMessage;
Dipl.-Ing. Jonas Stienen's avatar
Running  
Dipl.-Ing. Jonas Stienen committed
75
	VistaConnectionIP* m_pConnection;
76
	
77 78
	ITASampleFrame m_sfReceivingBuffer; //!< Buffer incoming data

79
	CITANetAudioProtocol::StreamingParameters m_oParams;
80

Dipl.-Ing. Jonas Stienen's avatar
Running  
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
Running  
Dipl.-Ing. Jonas Stienen committed
92

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

#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_STREAMING_CLIENT