Progress on net audio stream server side

parent 62491c92
......@@ -55,6 +55,7 @@ endif( )
vista_use_package( VistaCoreLibs REQUIRED COMPONENTS VistaBase VistaInterProcComm FIND_DEPENDENCIES )
vista_use_package( VABase REQUIRED )
vista_find_package( ITADataSources QUIET FIND_DEPENDENCIES )
# Including the source files of all source subfolders recursively
include( "include/_SourceFiles.cmake" )
......
/*
* --------------------------------------------------------------------------------------------
*
* VVV VVV A
* VVV VVV AAA Virtual Acoustics (VA)
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institute of Technical Acoustics (ITA), 2015-2017
* VVVV AAA RWTH Aachen University (http://www.akustik.rwth-aachen.de)
*
* --------------------------------------------------------------------------------------------
*/
#ifndef IW_VANET_AUDIO_STREAM_SERVER
#define IW_VANET_AUDIO_STREAM_SERVER
#include <VANetDefinitions.h>
#include <string>
class CVAAudiostreamProperties;
class CVAAudiostreamState;
//! Server-side implementation of a network audio stream
/**
* Sender-side implementation of a network audio stream,
* which transfers samples over TCP network to a audio stream receiver
* Sender and receiver are in an 1:1 relation.
*/
class VANET_API CVANetAudioStreamServer
{
public:
//! Return types / errors
enum ErrorType
{
VA_NASS_NO_ERROR = 0, //!< No error / success
VA_NASS_SERVER_CONNECTION_FAILED, //!< Verbindung zum Server fehlgeschlagen - Falsche Addresse, oder Server luft nicht
VA_NASS_SERVER_NOT_RESPONDING, //!< Verbindung zum Server wurde aufgebaut, aber keine Antwort erhalten
VA_NASS_SERVICE_IN_USE, //!< Netzwerkdienst wird bereits von anderem Client benutzt
VA_NASS_CONNECTION_ERROR, //!< Ein unbekannter netzwerkfehler ist aufgetreten
VA_NASS_PROTOCOL_INCOMPATIBLE, //!< Das Netzwerkprotokoll von Client und Server ist inkompatibel
VA_NASS_UNKNOWN_ERROR,
};
CVANetAudioStreamServer();
virtual ~CVANetAudioStreamServer();
// Gibt die Adresse des verbundenen Servers zurck
// (Rckgabe: leerer String, falls nicht verbunden)
virtual std::string GetServerAddress() const = 0;
// Client initialisieren und mit einem Server verbinden
// (Rckgabe: Statuscode)
virtual int Initialize( const std::string& sBindAddress, int iPort ) = 0;
void Finalize();
class VANET_API IHandler
{
public:
inline virtual ~IHandler() {};
// Handle that the connection to a receiver is established
// Thereby the sender it told the expected stream properties (sampling rate, buffersize)
// and designated signal source name on the receiver-side (VA).
// Returns: Status code (0=Connection accepted, 1=Connection refused)
virtual int HandleReceiverConnect( const CVAAudiostreamProperties& oStreamProps, const std::string& sSignalSourceName ) = 0;
// Informs that the connection to the receiver is closed
virtual void HandleReceiverDisconnect() = 0;
// Receiver-side requests new samples from the sender
// Thereby the sender is informed about the current status of the audiostream
virtual void HandleReceiverRequestSamples( const CVAAudiostreamState& oStreamState ) = 0;
};
// Sets the handler for sender events
void SetEventHandler( IHandler* pHandler );
// Pushes a block of samples into the sender buffer and transfers them to the client
// Return: Status information (still connected, etc.)
int SendSamples( const float* pfSamples, int iNumSamples );
};
#endif // IW_VANET_AUDIO_STREAM_SERVER
......@@ -11,44 +11,42 @@
* --------------------------------------------------------------------------------------------
*/
#ifndef __VANET_AUDIOSTREAM_RECEIVER_H__
#define __VANET_AUDIOSTREAM_RECEIVER_H__
#ifndef IW_VANET_AUDIO_STREAM_SERVER
#define IW_VANET_AUDIO_STREAM_SERVER
#include <VANetDefinitions.h>
#include <string>
class CVAAudiostreamProperties;
class CVAAudiostreamState;
#include <VASamples.h>
//! Receiver-side implementation of a network audio stream
class CVANetAudioStreamServerImpl;
//! Stream server framework for providing samples for a network stream
/**
* Sender-side implementation of a network audio stream,
* which transfers samples over TCP network to a audiostream receiver
* Sender and receiver are in an 1:1 relation.
* This class helps to set up a network audio streaming server
* to be connected with a VA network stream. Process() method
* needs to be implemented by user and is called by the network
* server implementation occasionally if more samples are requested.
* Timing can be observed with the stream status, i.e. a time stamp and
* sample count. The timing is most probably not as acurate as an
* audio stream that is driven by a sound card, because network
* transmission deviates stream process call timings.
*
*/
class VANET_API CVANetAudioStreamReceiver
public VANET_API CVANetAudioStreamServer
{
public:
//! Return types / errors
enum ErrorType
{
VA_NO_ERROR = 0, //!< No error
VA_CONNECTION_LOST, //!< Connection to sender unexpectedly lost
VA_BUFFER_UNDERRUN //!< Not enough samples in the receive buffer
};
//! Creates an audio stream
CVANetAudioStreamReceiver( const std::string sSenderAddress, int iSenderPort, const std::string& sTargetName, const CVAAudiostreamProperties& oStreamProps, int iFlags );
virtual ~CVANetAudioStreamReceiver();
//! Returns sender address / IP
/**
* @return Empty, if not connected
*/
virtual std::string GetSenderAddress() const=0;
//! Receives a block of samples from the sender buffer
int ReceiveSamples(const float* pfSamples, int iNumSamples);
};
#endif // __VANET_AUDIOSTREAM_RECEIVER_H__
//! Create a network audio stream
CVANetAudioStreamServer();
virtual ~CVANetAudioStreamServer();
//! Initialize server and start listening on network port
bool Initialize( const std::string& sBindAddress, const int iBindPort );
//! Provide a frame of samples on request (overload this method)
virtual void Process( CVASamples& oFrame, CVAStreamInfo ) =0;
private:
CVANetAudioStreamServerImpl* m_pImpl;
}
#endif // IW_VANET_AUDIO_STREAM_SERVER
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment