Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
ITADataSources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
ITADataSources
Commits
c3da6ef0
Commit
c3da6ef0
authored
Jan 26, 2017
by
Anne Heimes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement ClientLog
parent
e6c73581
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
69 deletions
+116
-69
include/ITANetAudioStreamingClient.h
include/ITANetAudioStreamingClient.h
+3
-0
src/ITANetAudioStream.cpp
src/ITANetAudioStream.cpp
+1
-1
src/ITANetAudioStreamingClient.cpp
src/ITANetAudioStreamingClient.cpp
+46
-2
tests/NetAudio/ITANetAudioStreamingClientTest.cpp
tests/NetAudio/ITANetAudioStreamingClientTest.cpp
+66
-66
No files found.
include/ITANetAudioStreamingClient.h
View file @
c3da6ef0
...
...
@@ -36,6 +36,7 @@ class CITANetAudioClient;
class
CITANetAudioMessage
;
class
CITANetAudioProtocol
;
class
CITANetAudioStream
;
class
ITABufferedDataLoggerImplClient
;
//! Network audio streaming client
/**
...
...
@@ -76,6 +77,8 @@ private:
CITANetAudioProtocol
::
StreamingParameters
m_oParams
;
bool
m_bStopIndicated
;
int
iStreamingBlockId
;
ITABufferedDataLoggerImplClient
*
m_pClientLogger
;
friend
class
CITANetAudioStream
;
};
...
...
src/ITANetAudioStream.cpp
View file @
c3da6ef0
...
...
@@ -92,7 +92,7 @@ CITANetAudioStream::CITANetAudioStream( int iChannels, double dSamplingRate, int
,
m_bRingBufferFull
(
false
)
,
m_iStreamingStatus
(
INVALID
)
,
m_dLastStreamingTimeCode
(
0.0
f
)
,
m_iTargetSampleLatency
(
10
*
iBufferSize
)
,
m_iTargetSampleLatency
(
iRingBufferCapacity
)
{
m_bRingBufferFull
=
false
;
if
(
iBufferSize
>
iRingBufferCapacity
)
...
...
src/ITANetAudioStreamingClient.cpp
View file @
c3da6ef0
...
...
@@ -3,10 +3,45 @@
#include <ITANetAudioClient.h>
#include <ITANetAudioMessage.h>
#include <ITANetAudioStream.h>
#include <ITADataLog.h>
#include <ITAClock.h>
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
#include <VistaBase/VistaStreamUtils.h>
//! Audio streaming log item
struct
ITAClientLog
:
public
ITALogDataBase
{
inline
static
std
::
ostream
&
outputDesc
(
std
::
ostream
&
os
)
{
os
<<
"BlockId"
;
os
<<
"
\t
"
<<
"WorldTimeStamp"
;
os
<<
"
\t
"
<<
"ProtocolStatus"
;
os
<<
"
\t
"
<<
"FreeSamples"
;
os
<<
std
::
endl
;
return
os
;
};
inline
std
::
ostream
&
outputData
(
std
::
ostream
&
os
)
const
{
os
<<
uiBlockId
;
os
<<
"
\t
"
<<
std
::
setprecision
(
12
)
<<
dWorldTimeStamp
;
os
<<
"
\t
"
<<
iProtocolStatus
;
os
<<
"
\t
"
<<
iFreeSamples
;
os
<<
std
::
endl
;
return
os
;
};
unsigned
int
uiBlockId
;
//!< Block identifier (audio streaming)
double
dWorldTimeStamp
;
int
iProtocolStatus
;
//!< ... usw
int
iFreeSamples
;
};
class
ITABufferedDataLoggerImplClient
:
public
ITABufferedDataLogger
<
ITAClientLog
>
{};
CITANetAudioStreamingClient
::
CITANetAudioStreamingClient
(
CITANetAudioStream
*
pParent
)
:
m_oBlockIncrementEvent
(
VistaThreadEvent
::
WAITABLE_EVENT
)
,
m_pStream
(
pParent
)
...
...
@@ -18,7 +53,9 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP
m_oParams
.
iChannels
=
pParent
->
GetNumberOfChannels
();
m_oParams
.
dSampleRate
=
pParent
->
GetSampleRate
();
m_oParams
.
iBlockSize
=
pParent
->
GetBlocklength
();
m_pClientLogger
=
new
ITABufferedDataLoggerImplClient
(
);
m_pClientLogger
->
setOutputFile
(
"NetAudioLogClient.txt"
);
iStreamingBlockId
=
0
;
m_pMessage
=
new
CITANetAudioMessage
(
VistaSerializingToolset
::
SWAPS_MULTIBYTE_VALUES
);
}
...
...
@@ -32,6 +69,7 @@ CITANetAudioStreamingClient::~CITANetAudioStreamingClient()
m_pMessage
->
WriteMessage
();
m_pClient
->
Disconnect
();
}
delete
m_pClientLogger
;
}
bool
CITANetAudioStreamingClient
::
Connect
(
const
std
::
string
&
sAddress
,
int
iPort
)
...
...
@@ -66,6 +104,9 @@ bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPor
bool
CITANetAudioStreamingClient
::
LoopBody
()
{
ITAClientLog
oLog
;
oLog
.
uiBlockId
=
++
iStreamingBlockId
;
if
(
m_bStopIndicated
)
return
true
;
...
...
@@ -74,6 +115,7 @@ bool CITANetAudioStreamingClient::LoopBody()
m_pMessage
->
SetConnection
(
m_pConnection
);
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_CLIENT_WAITING_FOR_SAMPLES
);
int
iFreeSamplesUntilAllowedReached
=
m_pStream
->
GetAllowedLatencySamples
()
-
m_pStream
->
GetRingBufferAvailableSamples
();
oLog
.
iFreeSamples
=
iFreeSamplesUntilAllowedReached
;
if
(
iFreeSamplesUntilAllowedReached
<
0
)
iFreeSamplesUntilAllowedReached
=
0
;
m_pMessage
->
WriteInt
(
iFreeSamplesUntilAllowedReached
);
...
...
@@ -108,7 +150,9 @@ bool CITANetAudioStreamingClient::LoopBody()
case
CITANetAudioProtocol
::
NP_SERVER_GET_RINGBUFFER_FREE
:
break
;
}
oLog
.
iProtocolStatus
=
iAnswerType
;
oLog
.
dWorldTimeStamp
=
ITAClock
::
getDefaultClock
(
)
->
getTime
(
);
m_pClientLogger
->
log
(
oLog
);
return
true
;
}
...
...
tests/NetAudio/ITANetAudioStreamingClientTest.cpp
View file @
c3da6ef0
#include <iostream>
#include <string>
#include <ITANetAudioStream.h>
#include <ITAPortaudioInterface.h>
#include <ITAStreamMultiplier1N.h>
#include <ITAException.h>
#include <ITAFileDatasource.h>
#include <ITAStreamProbe.h>
#include <ITAStreamPatchbay.h>
using
namespace
std
;
//static string g_sServerName = "137.226.61.163";
static
string
g_sServerName
=
"137.226.61.
67"
;
static
int
g_iServerPort
=
12480
;
static
double
g_dSampleRate
=
44100
;
static
int
g_iBufferSize
=
512
;
static
int
g_iChannels
=
500
;
int
main
(
int
,
char
**
)
{
CITANetAudioStream
oNetAudioStream
(
g_iChannels
,
g_dSampleRate
,
g_iBufferSize
,
100
*
g_iBufferSize
);
#include <iostream>
#include <string>
#include <ITANetAudioStream.h>
#include <ITAPortaudioInterface.h>
#include <ITAStreamMultiplier1N.h>
#include <ITAException.h>
#include <ITAFileDatasource.h>
#include <ITAStreamProbe.h>
#include <ITAStreamPatchbay.h>
using
namespace
std
;
//static string g_sServerName = "137.226.61.163";
static
string
g_sServerName
=
"137.226.61.
163"
;
static
int
g_iServerPort
=
12480
;
static
double
g_dSampleRate
=
44100
;
static
int
g_iBufferSize
=
1024
;
static
int
g_iChannels
=
1
;
int
main
(
int
,
char
**
)
{
CITANetAudioStream
oNetAudioStream
(
g_iChannels
,
g_dSampleRate
,
g_iBufferSize
,
100
*
g_iBufferSize
);
ITAStreamPatchbay
oPatchbay
(
g_dSampleRate
,
g_iBufferSize
);
oPatchbay
.
AddInput
(
&
oNetAudioStream
);
int
iOutputID
=
oPatchbay
.
AddOutput
(
2
);
...
...
@@ -31,45 +31,45 @@ int main( int , char** )
oPatchbay
.
ConnectChannels
(
0
,
i
,
0
,
i
%
2
,
1
/
double
(
N
)
);
ITAStreamProbe
oProbe
(
oPatchbay
.
GetOutputDatasource
(
iOutputID
),
"ITANetAudioTest.stream.wav"
);
ITAPortaudioInterface
ITAPA
(
g_dSampleRate
,
g_iBufferSize
);
ITAPA
.
Initialize
();
ITAPA
.
SetPlaybackDatasource
(
&
oProbe
);
ITAPA
.
Open
();
ITAPA
.
Start
();
cout
<<
"Waiting 3 seconds (net audio stream not connected and returning zeros)"
<<
endl
;
ITAPA
.
Sleep
(
2.0
f
);
cout
<<
"Will now connect to '"
<<
g_sServerName
<<
"' on port "
<<
g_iServerPort
<<
endl
;
try
{
if
(
!
oNetAudioStream
.
Connect
(
g_sServerName
,
g_iServerPort
)
)
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Could not connect to server"
);
}
catch
(
ITAException
e
)
{
cout
<<
"Connection failed."
<<
endl
;
cerr
<<
e
<<
endl
;
return
255
;
}
cout
<<
"Connected."
<<
endl
;
// Playback
float
fSeconds
=
10.0
f
;
cout
<<
"Playback started, waiting "
<<
fSeconds
<<
" seconds"
<<
endl
;
ITAPA
.
Sleep
(
fSeconds
);
// blocking
cout
<<
"Done."
<<
endl
;
cout
<<
"Will now disconnect from '"
<<
g_sServerName
<<
"' and port "
<<
g_iServerPort
<<
endl
;
cout
<<
"Closing in 3 seconds (net audio stream not connected and returning zeros)"
<<
endl
;
ITAPA
.
Sleep
(
1.0
f
);
ITAPA
.
Stop
();
ITAPA
.
Close
();
ITAPA
.
Finalize
();
return
0
;
}
ITAPortaudioInterface
ITAPA
(
g_dSampleRate
,
g_iBufferSize
);
ITAPA
.
Initialize
();
ITAPA
.
SetPlaybackDatasource
(
&
oProbe
);
ITAPA
.
Open
();
ITAPA
.
Start
();
cout
<<
"Waiting 3 seconds (net audio stream not connected and returning zeros)"
<<
endl
;
ITAPA
.
Sleep
(
2.0
f
);
cout
<<
"Will now connect to '"
<<
g_sServerName
<<
"' on port "
<<
g_iServerPort
<<
endl
;
try
{
if
(
!
oNetAudioStream
.
Connect
(
g_sServerName
,
g_iServerPort
)
)
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Could not connect to server"
);
}
catch
(
ITAException
e
)
{
cout
<<
"Connection failed."
<<
endl
;
cerr
<<
e
<<
endl
;
return
255
;
}
cout
<<
"Connected."
<<
endl
;
// Playback
float
fSeconds
=
20.0
f
;
cout
<<
"Playback started, waiting "
<<
fSeconds
<<
" seconds"
<<
endl
;
ITAPA
.
Sleep
(
fSeconds
);
// blocking
cout
<<
"Done."
<<
endl
;
cout
<<
"Will now disconnect from '"
<<
g_sServerName
<<
"' and port "
<<
g_iServerPort
<<
endl
;
cout
<<
"Closing in 3 seconds (net audio stream not connected and returning zeros)"
<<
endl
;
ITAPA
.
Sleep
(
1.0
f
);
ITAPA
.
Stop
();
ITAPA
.
Close
();
ITAPA
.
Finalize
();
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment