Commit e3a1d229 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen

:Merge branch 'ba_2016_heimes' of https://git.rwth-aachen.de/ita/ITADataSources into ba_2016_heimes

Conflicts:
	tests/NetAudio/ITANetAudioStreamingServerTest.cpp
parents bd2e4e4a 8eb85966
......@@ -4,9 +4,9 @@
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
#include <VistaBase/VistaExceptionBase.h>
#include <VistaBase/VistaStreamUtils.h>
#include <cstring>
#include <algorithm>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <iostream>
#include <iomanip>
......@@ -140,7 +140,7 @@ void CITANetAudioMessage::ReadMessage()
int iIncommingBytes = m_pConnection->WaitForIncomingData( 0 );
int iBytesReceived = m_pConnection->Receive( &m_vecIncomingBuffer[ iBytesReceivedTotal ], iIncommingBytes );
iBytesReceivedTotal += iBytesReceived;
#if NET_AUDIO_SHOW_TRAFFIC
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "[ CITANetAudioMessage ] " << std::setw( 3 ) << std::floor( iBytesReceivedTotal / float( nMessagePayloadSize ) * 100.0f ) << "% transmitted" << std::endl;
#endif
}
......@@ -225,7 +225,7 @@ void CITANetAudioMessage::ReadAnswer()
int iIncommingBytes = m_pConnection->WaitForIncomingData( 0 );
int iBytesReceived = m_pConnection->Receive( &m_vecIncomingBuffer[ iBytesReceivedTotal ], iIncommingBytes );
iBytesReceivedTotal += iBytesReceived;
#if NET_AUDIO_SHOW_TRAFFIC
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "[ CITANetAudioMessage ] " << std::setw( 3 ) << std::floor( iBytesReceivedTotal / float( nMessagePayloadSize ) * 100.0f ) << "% of answer transmitted" << std::endl;
#endif
}
......
......@@ -61,14 +61,19 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP
CITANetAudioStreamingClient::~CITANetAudioStreamingClient()
{
if( m_pConnection )
{
m_pMessage->ResetMessage();
m_pMessage->SetConnection( m_pConnection );
m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_CLOSE );
m_pMessage->WriteMessage();
m_pClient->Disconnect();
}
//try{
if (m_pConnection->GetIsOpen())
{
m_pMessage->ResetMessage();
m_pMessage->SetConnection(m_pConnection);
m_pMessage->SetMessageType(CITANetAudioProtocol::NP_CLIENT_CLOSE);
//m_pMessage->WriteMessage();
m_pClient->Disconnect();
}
//}
//catch (ITAException e){
// std::cout << e << std::endl;
//}
delete m_pClientLogger;
}
......
......@@ -7,6 +7,7 @@ include( VistaCommon )
vista_use_package( VistaCoreLibs REQUIRED COMPONENTS VistaInterProcComm FIND_DEPENDENCIES )
vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES )
add_definitions(-DIEEE754_64FLOAT)
add_executable( ITANABufferServerTest ITANABufferServerTest.cpp )
target_link_libraries( ITANABufferServerTest ${VISTA_USE_PACKAGE_LIBRARIES} )
......@@ -56,4 +57,6 @@ vista_configure_app( ITANetAudioTest )
vista_install( ITANetAudioTest )
vista_create_default_info_file( ITANetAudioTest )
vista_install_all_dlls( bin )
set_property( TARGET ITANetAudioTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/NetAudio" )
cmake_minimum_required( VERSION 2.9 )
project( ITANetAudioTests )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
vista_use_package( VistaCoreLibs REQUIRED COMPONENTS VistaInterProcComm FIND_DEPENDENCIES )
vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES )
add_executable( ITANABufferServerTest ITANABufferServerTest.cpp )
target_link_libraries( ITANABufferServerTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITANABufferServerTest )
vista_install( ITANABufferServerTest )
vista_create_default_info_file( ITANABufferServerTest )
set_property( TARGET ITANABufferServerTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/NetAudio" )
add_executable( ITANAPlayerTest ITANAPlayerTest.cpp )
target_link_libraries( ITANAPlayerTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITANAPlayerTest )
vista_install( ITANAPlayerTest )
vista_create_default_info_file( ITANAPlayerTest )
set_property( TARGET ITANAPlayerTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/NetAudio" )
add_executable( ITANetAudioStreamingServerTest ITANetAudioStreamingServerTest.cpp )
target_link_libraries( ITANetAudioStreamingServerTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITANetAudioStreamingServerTest )
vista_install( ITANetAudioStreamingServerTest )
vista_create_default_info_file( ITANetAudioStreamingServerTest )
set_property( TARGET ITANetAudioStreamingServerTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/NetAudio" )
if( WIN32 ) # uses ASIO
add_executable( ITANetAudioStreamingClientTest ITANetAudioStreamingClientTest.cpp )
target_link_libraries( ITANetAudioStreamingClientTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITANetAudioStreamingClientTest )
vista_install( ITANetAudioStreamingClientTest )
vista_create_default_info_file( ITANetAudioStreamingClientTest )
set_property( TARGET ITANetAudioStreamingClientTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/NetAudio" )
endif( )
add_executable( ITANetAudioTest ITANetAudioTest.cpp )
target_link_libraries( ITANetAudioTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITANetAudioTest )
vista_install( ITANetAudioTest )
vista_create_default_info_file( ITANetAudioTest )
set_property( TARGET ITANetAudioTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataSources/NetAudio" )
......@@ -13,24 +13,34 @@
using namespace std;
//static string g_sServerName = "137.226.61.163";
static string g_sServerName = "137.226.61.85";
static int g_iServerPort = 12480;
static double g_dSampleRate = 44100;
static int g_iBufferSize = 32;
static int g_iChannels = 10;
int main( int , char** )
int main(int argc, char* argv[])
{
std::cout << "BufferSize: " << endl;
cin >> g_iBufferSize;
cout << "ChannelAnzahl: " << endl;
cin >> g_iChannels;
if (argc != 7)
{
cout << "argc = " << argc << endl;
cout << "sServerName = " << argv[1] << endl;
cout << "iServerPort = " << argv[2] << endl;
cout << "dSampleRate = " << argv[3] << endl;
cout << "iBlockLength = " << argv[4] << endl;
cout << "iChannels = " << argv[5] << endl;
cout << "iBufferSize = " << argv[6] << endl;
fprintf(stderr, "Fehler: Syntax = ServerName ServerPort SampleRate BufferSize Channel RingBufferSize!\n");
}
string sServerName = argv[1];
unsigned int iServerPort = atoi(argv[2]);
double dSampleRate = strtod(argv[3], NULL);
int iBlockLength = atoi(argv[4]);
int iChannels = atoi(argv[5]);
int iBufferSize = atoi(argv[6]);
cout << "Channel " << iChannels << endl;
CITANetAudioStream oNetAudioStream( g_iChannels, g_dSampleRate, g_iBufferSize, 1 * g_iBufferSize );
CITANetAudioStream oNetAudioStream(iChannels, dSampleRate, iBlockLength, 1 * iBufferSize);
ITAStreamPatchbay oPatchbay( g_dSampleRate, g_iBufferSize );
ITAStreamPatchbay oPatchbay(dSampleRate, iBlockLength);
oPatchbay.AddInput( &oNetAudioStream );
int iOutputID = oPatchbay.AddOutput( 2 );
......@@ -45,7 +55,7 @@ int main( int , char** )
try {
cout << "Will now connect to '" << g_sServerName << "' on port " << g_iServerPort << endl;
cout << "Will now connect to '" << sServerName << "' on port " << iServerPort << endl;
if (ITAsioInitializeDriver("ASIO MADIface USB") != ASE_OK) {
ITAsioFinalizeLibrary();
......@@ -63,7 +73,7 @@ int main( int , char** )
}
if (ITAsioSetSampleRate((ASIOSampleRate)g_dSampleRate) != ASE_OK) {
if (ITAsioSetSampleRate((ASIOSampleRate)dSampleRate) != ASE_OK) {
ITAsioFinalizeLibrary();
fprintf(stderr, "Fehler: ITAsioSetSamplerate schlug fehl!\n");
......@@ -96,11 +106,10 @@ int main( int , char** )
return 255;
}
if (!oNetAudioStream.Connect(g_sServerName, g_iServerPort))
if (!oNetAudioStream.Connect(sServerName, iServerPort))
ITA_EXCEPT1(INVALID_PARAMETER, "Could not connect to server");
VistaTimeUtils::Sleep(2 * 1000);
printf("Wiedergabe gestartet ...\n");
VistaTimeUtils::Sleep(20 * 1000);
VistaTimeUtils::Sleep(10 * 1000);
if (ITAsioStop() != ASE_OK) {
ITAsioFinalizeLibrary();
......
......@@ -5,29 +5,46 @@
#include <ITANetAudioServer.h>
#include <ITAStreamFunctionGenerator.h>
#include <ITAStreamMultiplier1N.h>
<<<<<<< HEAD
#include <ITAFileDataSource.h>
=======
#include <ITAFileDatasource.h>
#include <VistaBase\VistaTimeUtils.h>
>>>>>>> 8eb8596629ad0642aaaec5a68bf1554216289863
using namespace std;
static string g_sServerName = "localhost";
static int g_iServerPort = 12480;
static double g_dSampleRate = 44100;
static int g_iBlockLength = 256;
static int g_iChannels = 1;
int main( int, char** )
int main(int argc, char** argv)
{
ITAFileDatasource oFile( "gershwin-mono.wav", g_iBlockLength );
if (argc != 6)
{
fprintf(stderr, "Fehler: Syntax = ServerName ServerPort SampleRate BufferSize Channel!\n");
}
string sServerName = argv[1];
unsigned int iServerPort = atoi(argv[2]);
double dSampleRate = strtod(argv[3], NULL);
int iBlockLength = atoi(argv[4]);
int iChannels = atoi(argv[5]);
ITAFileDatasource oFile( "gershwin-mono.wav", iBlockLength );
oFile.SetIsLooping( true );
ITAStreamMultiplier1N oMuliplier( &oFile, g_iChannels );
ITAStreamMultiplier1N oMuliplier( &oFile, iChannels );
CITANetAudioStreamingServer oStreamingServer;
oStreamingServer.SetInputStream( &oMuliplier );
cout << "Starting net audio server and waiting for connections on '" << g_sServerName << "' on port " << g_iServerPort << endl;
oStreamingServer.Start( g_sServerName, g_iServerPort );
cout << "Starting net audio server and waiting for connections on '" << sServerName << "' on port " << iServerPort << endl;
oStreamingServer.Start( sServerName, iServerPort );
int iKey;
std::cin >> iKey;
while (!oStreamingServer.IsClientConnected())
{
VistaTimeUtils::Sleep(100);
}
while (oStreamingServer.IsClientConnected())
{
VistaTimeUtils::Sleep(100);
}
VistaTimeUtils::Sleep(1000);
return 0;
}
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