Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Institute of Technical Acoustics (ITA)
ITADataSources
Commits
01cb7c2a
Commit
01cb7c2a
authored
Feb 17, 2017
by
Anne Heimes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sendet jetzt bis buffer voll und horcht erst dann - not running
parent
a37247be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
55 deletions
+58
-55
src/ITANetAudioStreamingServer.cpp
src/ITANetAudioStreamingServer.cpp
+58
-55
No files found.
src/ITANetAudioStreamingServer.cpp
View file @
01cb7c2a
...
...
@@ -6,7 +6,7 @@
#include <ITADataSource.h>
#include <ITANetAudioMessage.h>
#include <ITAException.h>
#include <ITAStreamInfo.h>
#include <ITAStreamInfo.h>
#include <ITAClock.h>
// Vista includes
...
...
@@ -15,39 +15,39 @@
#include <VistaInterProcComm/IPNet/VistaTCPSocket.h>
#include <VistaBase/VistaTimeUtils.h>
#include <VistaInterProcComm/IPNet/VistaIPAddress.h>
#include <VistaBase/VistaStreamUtils.h>
#include <VistaBase/VistaStreamUtils.h>
#include <ITADataLog.h>
// STL
#include <cmath>
#include <cassert>
struct
ITAServerLog
:
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
;
struct
ITAServerLog
:
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
ITABufferedDataLoggerImplServer
:
public
ITABufferedDataLogger
<
ITAServerLog
>
{};
...
...
@@ -57,7 +57,7 @@ CITANetAudioStreamingServer::CITANetAudioStreamingServer( )
,
m_iUpdateStrategy
(
AUTO
)
,
m_pConnection
(
NULL
)
,
m_pNetAudioServer
(
new
CITANetAudioServer
(
)
)
{
{
iServerBlockId
=
0
;
}
...
...
@@ -74,7 +74,7 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort
m_pMessage
=
new
CITANetAudioMessage
(
m_pConnection
->
GetByteorderSwapFlag
(
)
);
m_pMessage
->
ResetMessage
(
);
m_pMessage
->
SetConnection
(
m_pConnection
);
while
(
!
m_pMessage
->
ReadMessage
(
0
)
);
//blocking
while
(
!
m_pMessage
->
ReadMessage
(
0
)
);
//blocking
assert
(
m_pMessage
->
GetMessageType
(
)
==
CITANetAudioProtocol
::
NP_CLIENT_OPEN
);
CITANetAudioProtocol
::
StreamingParameters
oClientParams
=
m_pMessage
->
ReadStreamingParameters
(
);
...
...
@@ -93,9 +93,9 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort
vstr
::
out
()
<<
"[ITANetAudioStreamingServer] Server and client parameters mismatch detected. Will notify client and stop."
<<
std
::
endl
;
#endif
}
std
::
string
paras
=
std
::
string
(
"NetAudioLogServer"
)
+
std
::
string
(
"_BS"
)
+
std
::
to_string
(
m_oServerParams
.
iBlockSize
)
+
std
::
string
(
"_Ch"
)
+
std
::
to_string
(
m_oServerParams
.
iChannels
)
+
std
::
string
(
".txt"
);
m_pServerLogger
=
new
ITABufferedDataLoggerImplServer
(
);
std
::
string
paras
=
std
::
string
(
"NetAudioLogServer"
)
+
std
::
string
(
"_BS"
)
+
std
::
to_string
(
m_oServerParams
.
iBlockSize
)
+
std
::
string
(
"_Ch"
)
+
std
::
to_string
(
m_oServerParams
.
iChannels
)
+
std
::
string
(
".txt"
);
m_pServerLogger
=
new
ITABufferedDataLoggerImplServer
(
);
m_pServerLogger
->
setOutputFile
(
paras
);
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_SERVER_OPEN
);
...
...
@@ -118,24 +118,27 @@ bool CITANetAudioStreamingServer::LoopBody( )
if
(
m_iClientRingBufferFreeSamples
>=
int
(
m_pInputStream
->
GetBlocklength
(
)
)
)
{
// Send Samples
for
(
int
i
=
0
;
i
<
int
(
m_pInputStream
->
GetNumberOfChannels
(
)
);
i
++
)
while
(
m_iClientRingBufferFreeSamples
>=
int
(
m_pInputStream
->
GetBlocklength
(
)
)
)
{
ITAStreamInfo
oStreamInfo
;
oStreamInfo
.
nSamples
=
m_sfTempTransmitBuffer
.
GetLength
(
);
const
float
*
pfData
=
m_pInputStream
->
GetBlockPointer
(
i
,
&
oStreamInfo
);
if
(
pfData
!=
0
)
m_sfTempTransmitBuffer
[
i
].
write
(
pfData
,
m_sfTempTransmitBuffer
.
GetLength
(
)
);
}
m_pInputStream
->
IncrementBlockPointer
(
);
iMsgType
=
CITANetAudioProtocol
::
NP_SERVER_SENDING_SAMPLES
;
m_pMessage
->
SetMessageType
(
iMsgType
);
m_pMessage
->
WriteSampleFrame
(
&
m_sfTempTransmitBuffer
);
m_pMessage
->
WriteMessage
(
);
m_iClientRingBufferFreeSamples
-=
m_sfTempTransmitBuffer
.
GetLength
(
);
for
(
int
i
=
0
;
i
<
int
(
m_pInputStream
->
GetNumberOfChannels
(
)
);
i
++
)
{
ITAStreamInfo
oStreamInfo
;
oStreamInfo
.
nSamples
=
m_sfTempTransmitBuffer
.
GetLength
(
);
const
float
*
pfData
=
m_pInputStream
->
GetBlockPointer
(
i
,
&
oStreamInfo
);
if
(
pfData
!=
0
)
m_sfTempTransmitBuffer
[
i
].
write
(
pfData
,
m_sfTempTransmitBuffer
.
GetLength
(
)
);
}
m_pInputStream
->
IncrementBlockPointer
(
);
iMsgType
=
CITANetAudioProtocol
::
NP_SERVER_SENDING_SAMPLES
;
m_pMessage
->
SetMessageType
(
iMsgType
);
m_pMessage
->
WriteSampleFrame
(
&
m_sfTempTransmitBuffer
);
m_pMessage
->
WriteMessage
(
);
m_iClientRingBufferFreeSamples
-=
m_sfTempTransmitBuffer
.
GetLength
(
);
#ifdef NET_AUDIO_SHOW_TRAFFIC
vstr
::
out
(
)
<<
"[ITANetAudioStreamingServer] Transmitted "
<<
m_sfTempTransmitBuffer
.
GetLength
(
)
<<
" samples for "
<<
m_pInputStream
->
GetNumberOfChannels
(
)
<<
" channels"
<<
std
::
endl
;
<<
m_pInputStream
->
GetNumberOfChannels
(
)
<<
" channels"
<<
std
::
endl
;
#endif
}
}
else
{
...
...
@@ -148,9 +151,9 @@ bool CITANetAudioStreamingServer::LoopBody( )
vstr
::
out
(
)
<<
"[ITANetAudioStreamingServer] Not enough free samples in client buffer, requesting a trigger when more free samples available"
<<
std
::
endl
;
#endif
}
oLog
.
iFreeSamples
=
m_iClientRingBufferFreeSamples
;
oLog
.
iProtocolStatus
=
iMsgType
;
oLog
.
iFreeSamples
=
m_iClientRingBufferFreeSamples
;
oLog
.
iProtocolStatus
=
iMsgType
;
oLog
.
dWorldTimeStamp
=
ITAClock
::
getDefaultClock
(
)
->
getTime
(
);
m_pServerLogger
->
log
(
oLog
);
...
...
@@ -158,7 +161,7 @@ bool CITANetAudioStreamingServer::LoopBody( )
//m_pMessage->SetConnection( m_pConnection );
m_pMessage
->
ResetMessage
(
);
if
(
m_pMessage
->
ReadMessage
(
1
)
)
if
(
m_pMessage
->
ReadMessage
(
1
)
)
{
ITAServerLog
oLog
;
oLog
.
uiBlockId
=
++
iServerBlockId
;
...
...
@@ -184,12 +187,12 @@ bool CITANetAudioStreamingServer::LoopBody( )
vstr
::
out
(
)
<<
"[ITANetAudioStreamingServer] Unkown protocol type : "
<<
iMsgType
<<
std
::
endl
;
break
;
}
}
oLog
.
iFreeSamples
=
m_iClientRingBufferFreeSamples
;
oLog
.
iProtocolStatus
=
iMsgType
;
}
oLog
.
iFreeSamples
=
m_iClientRingBufferFreeSamples
;
oLog
.
iProtocolStatus
=
iMsgType
;
oLog
.
dWorldTimeStamp
=
ITAClock
::
getDefaultClock
(
)
->
getTime
(
);
m_pServerLogger
->
log
(
oLog
);
}
}
return
false
;
...
...
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