Commit c655a514 authored by Jonas Stienen's avatar Jonas Stienen
Browse files

Merge branch 'develop' of https://git.rwth-aachen.de/ita/VANet into develop

parents c4b45ee2 3b74da84
......@@ -32,11 +32,21 @@ if( NOT DEFINED ITA_VANET_SERVER_VERBOSE )
mark_as_advanced( ITA_VANET_SERVER_VERBOSE )
endif( )
if( NOT DEFINED ITA_VANET_NETAUDIO_VERBOSE )
set( ITA_VANET_SERVER_VERBOSE false CACHE BOOL "VANet server side with verbose output" )
mark_as_advanced( ITA_VANET_SERVER_VERBOSE )
endif( )
if( NOT DEFINED ITA_VANET_SERVER_SHOW_RAW_TRAFFIC )
set( ITA_VANET_SERVER_SHOW_RAW_TRAFFIC false CACHE BOOL "VANet server side print raw network traffic (debugging)" )
mark_as_advanced( ITA_VANET_SERVER_SHOW_RAW_TRAFFIC )
endif( )
if( NOT DEFINED ITA_VANET_WITH_NETAUDIO_STREAM_SERVER_EXTENSION )
vista_find_package( ITADataSources QUIET )
set( ITA_VANET_WITH_NETAUDIO_STREAM_SERVER_EXTENSION ${ITADATASOURCES_FOUND} CACHE BOOL "VANet with stream server class extension (requires ITADataSources)" )
endif( )
if( ITA_VANET_CLIENT_VERBOSE )
add_definitions( -DVANET_CLIENT_VERBOSE )
endif( )
......@@ -60,6 +70,11 @@ vista_use_package( VABase REQUIRED )
include( "include/_SourceFiles.cmake" )
include( "src/_SourceFiles.cmake" )
if( ITA_VANET_WITH_NETAUDIO_STREAM_SERVER_EXTENSION )
vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES )
list( APPEND ProjectSources "src/VANetAudioStreamServer.cpp;src/VANetAudioStreamServerImpl.cpp;src/VANetAudioStreamServerImpl.h" )
endif( )
include_directories( "include" )
if( ITA_VISTA_BUILD_STATIC )
......
/*
* --------------------------------------------------------------------------------------------
*
* 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,45 @@
* --------------------------------------------------------------------------------------------
*/
#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 <VABaseDefinitions.h>
#include <VASamples.h>
#include <string>
class CVAAudiostreamProperties;
class CVAAudiostreamState;
class CVANetAudioStreamServerImpl;
//! Receiver-side implementation of a network audio stream
//! 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
class 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);
//! Create a network audio stream
CVANetAudioStreamServer( const double dSampleRate, const int iBlockLength );
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( CVASampleBuffer& oFrame, const CVAAudiostreamState& ) = 0;
private:
CVANetAudioStreamServerImpl* m_pImpl;
};
#endif // __VANET_AUDIOSTREAM_RECEIVER_H__
#endif // IW_VANET_AUDIO_STREAM_SERVER
......@@ -4,8 +4,7 @@ set( RelativeDir "include" )
set( RelativeSourceGroup "include" )
set( DirFiles
VANetAudioStreamReceiver.h
VANetAudioStreamSender.h
VANetAudioStreamServer.h
VANetClient.h
VANetDefinitions.h
VANetServer.h
......
#include <VANetAudioStreamServer.h>
#include "VANetAudioStreamServerImpl.h"
CVANetAudioStreamServer::CVANetAudioStreamServer( const double dSampleRate, const int iBlockLength )
{
m_pImpl = new CVANetAudioStreamServerImpl( this, dSampleRate, iBlockLength );
}
CVANetAudioStreamServer::~CVANetAudioStreamServer()
{
delete m_pImpl;
}
bool CVANetAudioStreamServer::Initialize( const std::string& sBindInterface, const int iBindPort )
{
return m_pImpl->InitializeInternal( sBindInterface, iBindPort );
}
#include "VANetAudioStreamServerImpl.h"
#include <VANetAudioStreamServer.h>
#include <ITAStreamInfo.h>
CVANetAudioStreamServerImpl::CVANetAudioStreamServerImpl( CVANetAudioStreamServer* pParent, const double dSampleRate, const int iBlockLength )
: m_pParent( pParent )
, m_pSampleServer( NULL )
, CITASampleProcessor( 1, dSampleRate, iBlockLength )
{
}
CVANetAudioStreamServerImpl::~CVANetAudioStreamServerImpl()
{
delete m_pSampleServer;
}
void CVANetAudioStreamServerImpl::Process( const ITAStreamInfo* pStreamInfo )
{
m_oStreamInfo.bSyncMod = false;
m_oStreamInfo.bTimeReset = false;
m_oStreamInfo.dCoreTime = pStreamInfo->dTimecode;
m_oStreamInfo.dSysTime = pStreamInfo->dTimecode;
m_oStreamInfo.i64Sample = pStreamInfo->nSamples;
m_pParent->Process( m_sfStreamTransmitBuffer, m_oStreamInfo );
}
bool CVANetAudioStreamServerImpl::InitializeInternal( const std::string& sBindInterface, const int iBindPort )
{
m_pSampleServer = new CITANetAudioSampleServer( this );
const double dSyncTimeInterval = 0.001f; // 1 ms
return m_pSampleServer->Start( sBindInterface, iBindPort, dSyncTimeInterval );
}
\ No newline at end of file
#ifndef IW_VANET_AUDIO_STREAM_SERVER_IMPL
#define IW_VANET_AUDIO_STREAM_SERVER_IMPL
#include <VABaseDefinitions.h>
#include <VASamples.h>
#include <ITANetAudioSampleServer.h>
#include <string>
class CVANetAudioStreamServer;
class ITAStreamInfo;
class CVANetAudioStreamServerImpl : CITASampleProcessor
{
public:
CVANetAudioStreamServerImpl( CVANetAudioStreamServer* pParent, const double, const int );
~CVANetAudioStreamServerImpl();
bool InitializeInternal( const std::string& sBindInterface, const int iBindPort );
void Process( const ITAStreamInfo* pStreamInfo );
private:
CVASampleBuffer m_sfStreamTransmitBuffer;
CVANetAudioStreamServer* m_pParent;
CITANetAudioSampleServer* m_pSampleServer;
CVAAudiostreamState m_oStreamInfo;
};
#endif // IW_VANET_AUDIO_STREAM_SERVER_IMPL
Supports Markdown
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