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

#ifndef INCLUDE_WATCHER_ITA_NET_AUDIO_STREAM
#define INCLUDE_WATCHER_ITA_NET_AUDIO_STREAM

#include <ITADataSourcesDefinitions.h>

#include <ITADataSource.h>
#include <ITASampleFrame.h>

#include <string>
#include <vector>

30
class CITANetAudioStreamingClient;
31
32
33
34
35
36
37

//! Network audio stream
/**
 * Audio streaming for a signal source that is connected via TCP/IP.
 *
 * \note not thread-safe
 */
38
class ITA_DATA_SOURCES_API CITANetAudioStream : public ITADatasource
39
40
41
42
43
44
{
public:
	CITANetAudioStream( int iChannels, double dSamplingRate, int iBufferSize, int iRingBufferCapacity );
	virtual ~CITANetAudioStream();

	bool Connect( const std::string& sAddress, int iPort );
45
	bool GetIsConnected() const;
46
47
48
49
50
51
52
53
54
55
56
57
58

	int GetRingBufferSize() const;
	
	unsigned int GetBlocklength() const;
	unsigned int GetNumberOfChannels() const;
	double GetSampleRate() const;
	const float* GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* );
	void IncrementBlockPointer();

protected:
	int Transmit( const ITASampleFrame& sfNewSamples, int iNumSamples );

private:
59
	CITANetAudioStreamingClient* m_pNetAudioStreamingClient;
60
61
62
63
64
65

	double m_dSampleRate;
	ITASampleFrame m_sfOutputStreamBuffer;

	int m_iReadCursor; //!< Cursor where samples will be consumed from ring buffer on next block
	int m_iWriteCursor; //!< Cursor where samples will feeded into ring buffer from net audio producer
66
	ITASampleFrame m_sfRingBuffer; //!< Buffer incoming data
67

68
	friend class CITANetAudioStreamingClient;
69
70
71
};

#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_STREAM