ITANetAudioProtocol.h 2.99 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 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
 *
 * ----------------------------------------------------------------
 *				    ____  __________  _______
 *				   //  / //__   ___/ //  _   |
 *				  //  /    //  /    //  /_|  |
 *				 //  /    //  /    //  ___   |
 *				//__/    //__/    //__/   |__|
 *
 * ----------------------------------------------------------------
 *
 */

#ifndef INCLUDE_WATCHER_ITA_NET_AUDIO_PROTOCOL
#define INCLUDE_WATCHER_ITA_NET_AUDIO_PROTOCOL

#include <ITADataSourcesDefinitions.h>

// ITA includes
#include <ITAException.h>
#include <ITASampleBuffer.h>
#include <ITASampleFrame.h>

// Vista includes
#include <VistaBase/VistaBaseTypes.h>
#include <VistaInterProcComm/Connections/VistaByteBufferSerializer.h>
#include <VistaInterProcComm/Connections/VistaByteBufferDeSerializer.h>

// STL includes
#include <string>
#include <vector>

// Forward declarations
class VistaConnectionIP;
40
class CITANetAudioStreamingServer;
41
class CITANetAudioStream;
42 43 44 45 46

//! Network audio protocol
/**
  * Declaration of message types
  */
47
class ITA_DATA_SOURCES_API CITANetAudioProtocol
48
{
49
public:
50
	static const int NP_CLIENT_IDLE = 0;
51 52
	static const int NP_CLIENT_OPEN = 100;
	static const int NP_CLIENT_CLOSE = 101;
Anne's avatar
Anne committed
53
	static const int NP_CLIENT_SENDING_RINGBUFFER_FREE_SAMPLES = 111;
54

Anne's avatar
Anne committed
55 56
	static const int NP_SERVER_OPEN = 200;
	static const int NP_SERVER_CLOSE = 201;
57
	static const int NP_SERVER_REFUSED_INVALID_PARAMETERS = 202;
Anne's avatar
Anne committed
58 59
	static const int NP_SERVER_GET_RINGBUFFER_FREE_SAMPLES = 211;
	static const int NP_SERVER_SENDING_SAMPLES = 222;
60

61 62
	inline CITANetAudioProtocol() {};
	inline ~CITANetAudioProtocol() {};
63 64 65 66 67 68 69 70 71 72

	inline static std::string GetNPMessageID( const int iMessageType )
	{
		switch( iMessageType )
		{
		case NP_CLIENT_IDLE: return "CLIENT_IDLE";
		case NP_CLIENT_OPEN: return "CLIENT_OPEN";
		case NP_CLIENT_CLOSE: return "CLIENT_CLOSE";
		case NP_CLIENT_SENDING_RINGBUFFER_FREE_SAMPLES: return "CLIENT_SENDING_RINGBUFFER_FREE_SAMPLES";
		case NP_SERVER_OPEN: return "SERVER_OPEN";
73
		case NP_SERVER_REFUSED_INVALID_PARAMETERS: return "NP_SERVER_REFUSED_INVALID_PARAMETERS";
74 75 76 77 78 79
		case NP_SERVER_CLOSE: return "SERVER_CLOSE";
		case NP_SERVER_GET_RINGBUFFER_FREE_SAMPLES: return "SERVER_GET_RINGBUFFER_FREE_SAMPLES";
		case NP_SERVER_SENDING_SAMPLES: return "SERVER_SENDING_SAMPLES";
		default: return "INVALID";
		}
	};
80
	
81 82 83 84 85
	struct StreamingParameters
	{
		int iChannels;
		double dSampleRate;
		int iBlockSize;
Anne's avatar
Anne committed
86
		int iRingBufferSize;
87 88 89 90 91 92

		inline StreamingParameters()
		{
			iChannels = 0;
			dSampleRate = 0.0f;
			iBlockSize = 0;
Anne's avatar
Anne committed
93
			iRingBufferSize = 0;
94
		};
Dipl.-Ing. Jonas Stienen's avatar
Running  
Dipl.-Ing. Jonas Stienen committed
95 96 97

		inline bool operator==( const StreamingParameters& rhs )
		{
98 99 100
			if ( ( iChannels == rhs.iChannels ) 
				&& ( dSampleRate == rhs.dSampleRate ) 
				&& (iBlockSize == rhs.iBlockSize)
101
				&& (iRingBufferSize == rhs.iRingBufferSize))
Dipl.-Ing. Jonas Stienen's avatar
Running  
Dipl.-Ing. Jonas Stienen committed
102
				return true;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
103 104 105
			else
				return false;
		};
106
	};
107 108 109
};

#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_PROTOCOL