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
72011a7c
Commit
72011a7c
authored
Mar 23, 2017
by
Anne Heimes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server kalkuliert selbst den Ringbuffer, Client gibt nur noch alle x sec bufferInfos an server
parent
677458e7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
26 deletions
+34
-26
include/ITANetAudioProtocol.h
include/ITANetAudioProtocol.h
+4
-1
include/ITANetAudioStreamingClient.h
include/ITANetAudioStreamingClient.h
+1
-0
include/ITANetAudioStreamingServer.h
include/ITANetAudioStreamingServer.h
+1
-1
src/ITANetAudioMessage.cpp
src/ITANetAudioMessage.cpp
+2
-0
src/ITANetAudioStreamingClient.cpp
src/ITANetAudioStreamingClient.cpp
+11
-6
src/ITANetAudioStreamingServer.cpp
src/ITANetAudioStreamingServer.cpp
+14
-17
tests/NetAudio/ITANetAudioStreamingServerTest.cpp
tests/NetAudio/ITANetAudioStreamingServerTest.cpp
+1
-1
No files found.
include/ITANetAudioProtocol.h
View file @
72011a7c
...
...
@@ -66,6 +66,7 @@ public:
int
iBlockSize
;
int
iRingBufferSize
;
int
iTargetSampleLatency
;
int
dTimeIntervalSendInfos
;
inline
StreamingParameters
()
{
...
...
@@ -74,6 +75,7 @@ public:
iBlockSize
=
0
;
iRingBufferSize
=
0
;
iTargetSampleLatency
=
0
;
dTimeIntervalSendInfos
=
0
;
};
inline
bool
operator
==
(
const
StreamingParameters
&
rhs
)
...
...
@@ -82,7 +84,8 @@ public:
&&
(
dSampleRate
==
rhs
.
dSampleRate
)
&&
(
iBlockSize
==
rhs
.
iBlockSize
)
&&
(
iRingBufferSize
==
rhs
.
iRingBufferSize
)
&&
(
iTargetSampleLatency
==
rhs
.
iTargetSampleLatency
))
&&
(
iTargetSampleLatency
==
rhs
.
iTargetSampleLatency
)
&&
(
dTimeIntervalSendInfos
==
rhs
.
dTimeIntervalSendInfos
))
return
true
;
else
return
false
;
...
...
include/ITANetAudioStreamingClient.h
View file @
72011a7c
...
...
@@ -78,6 +78,7 @@ private:
bool
m_bStopIndicated
;
bool
m_bStopped
;
double
m_dLastAckknowlengementTimeStamp
;
int
iStreamingBlockId
;
ITABufferedDataLoggerImplClient
*
m_pClientLogger
;
...
...
include/ITANetAudioStreamingServer.h
View file @
72011a7c
...
...
@@ -63,7 +63,7 @@ public:
CITANetAudioStreamingServer
();
~
CITANetAudioStreamingServer
();
bool
Start
(
const
std
::
string
&
sAddress
,
int
iPort
);
bool
Start
(
const
std
::
string
&
sAddress
,
int
iPort
,
double
dTimeIntervalCientSendStatus
);
bool
IsClientConnected
()
const
;
std
::
string
GetNetworkAddress
()
const
;
int
GetNetworkPort
()
const
;
...
...
src/ITANetAudioMessage.cpp
View file @
72011a7c
...
...
@@ -321,6 +321,7 @@ CITANetAudioProtocol::StreamingParameters CITANetAudioMessage::ReadStreamingPara
oParams
.
iBlockSize
=
ReadInt
();
oParams
.
iRingBufferSize
=
ReadInt
();
oParams
.
iTargetSampleLatency
=
ReadInt
();
oParams
.
dTimeIntervalSendInfos
=
ReadDouble
();
return
oParams
;
}
...
...
@@ -332,6 +333,7 @@ void CITANetAudioMessage::WriteStreamingParameters( const CITANetAudioProtocol::
WriteInt
(
oParams
.
iBlockSize
);
WriteInt
(
oParams
.
iRingBufferSize
);
WriteInt
(
oParams
.
iTargetSampleLatency
);
WriteDouble
(
oParams
.
dTimeIntervalSendInfos
);
}
int
CITANetAudioMessage
::
ReadRingBufferSize
()
...
...
src/ITANetAudioStreamingClient.cpp
View file @
72011a7c
...
...
@@ -102,9 +102,10 @@ bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPor
while
(
!
m_pMessage
->
ReadMessage
(
0
)
);
assert
(
m_pMessage
->
GetMessageType
(
)
==
CITANetAudioProtocol
::
NP_SERVER_OPEN
);
bool
bOK
=
m_pMessage
->
ReadBool
();
CITANetAudioProtocol
::
StreamingParameters
oServerParas
=
m_pMessage
->
ReadStreamingParameters
();
m_oParams
.
dTimeIntervalSendInfos
=
oServerParas
.
dTimeIntervalSendInfos
;
if
(
!
bOK
)
if
(
!
(
oServerParas
==
m_oParams
)
)
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Streaming server declined connection, detected streaming parameter mismatch."
);
Run
();
...
...
@@ -182,10 +183,14 @@ bool CITANetAudioStreamingClient::LoopBody()
}
else
{
// sende mal freie samples
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_CLIENT_SENDING_RINGBUFFER_FREE_SAMPLES
);
m_pMessage
->
WriteInt
(
m_pStream
->
GetRingBufferFreeSamples
());
m_pMessage
->
WriteMessage
();
if
((
m_dLastAckknowlengementTimeStamp
+
m_oParams
.
dTimeIntervalSendInfos
)
<
ITAClock
::
getDefaultClock
()
->
getTime
()
)
{
// sende mal freie samples
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_CLIENT_SENDING_RINGBUFFER_FREE_SAMPLES
);
m_pMessage
->
WriteInt
(
m_pStream
->
GetRingBufferFreeSamples
());
m_pMessage
->
WriteMessage
();
m_dLastAckknowlengementTimeStamp
=
ITAClock
::
getDefaultClock
()
->
getTime
();
}
}
return
false
;
}
...
...
src/ITANetAudioStreamingServer.cpp
View file @
72011a7c
...
...
@@ -70,7 +70,7 @@ CITANetAudioStreamingServer::~CITANetAudioStreamingServer()
delete
m_pServerLogger
;
}
bool
CITANetAudioStreamingServer
::
Start
(
const
std
::
string
&
sAddress
,
int
iPort
)
bool
CITANetAudioStreamingServer
::
Start
(
const
std
::
string
&
sAddress
,
int
iPort
,
double
dTimeIntervalCientSendStatus
)
{
if
(
!
m_pInputStream
)
ITA_EXCEPT1
(
MODAL_EXCEPTION
,
"Can not start server without a valid input stream"
);
...
...
@@ -92,6 +92,7 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort
m_oServerParams
.
iRingBufferSize
=
oClientParams
.
iRingBufferSize
;
m_oServerParams
.
iTargetSampleLatency
=
oClientParams
.
iTargetSampleLatency
;
m_oServerParams
.
iBlockSize
=
oClientParams
.
iBlockSize
;
m_oServerParams
.
dTimeIntervalSendInfos
=
dTimeIntervalCientSendStatus
;
m_iClientRingBufferFreeSamples
=
m_oServerParams
.
iTargetSampleLatency
;
m_dLastTimeStamp
=
ITAClock
::
getDefaultClock
()
->
getTime
();
...
...
@@ -113,8 +114,8 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort
m_pServerLogger
=
new
ITABufferedDataLoggerImplServer
(
);
m_pServerLogger
->
setOutputFile
(
paras
);
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_SERVER_OPEN
);
m_pMessage
->
Write
Bool
(
bOK
);
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_SERVER_OPEN
);
m_pMessage
->
Write
StreamingParameters
(
m_oServerParams
);
m_pMessage
->
WriteMessage
(
);
m_sfTempTransmitBuffer
.
init
(
m_pInputStream
->
GetNumberOfChannels
(
),
m_oServerParams
.
iRingBufferSize
,
true
);
...
...
@@ -135,13 +136,12 @@ bool CITANetAudioStreamingServer::LoopBody( )
int
iMsgType
;
// Sending Samples
unsigned
int
uiBlockLength
=
m_pInputStream
->
GetBlocklength
(
);
int
iClientRingBufferTargetFreeSamples
=
m_iClientRingBufferFreeSamples
-
(
m_oServerParams
.
iRingBufferSize
-
m_oServerParams
.
iTargetSampleLatency
);
if
(
iClientRingBufferTargetFreeSamples
<
0
)
iClientRingBufferTargetFreeSamples
=
0
;
if
(
iClientRingBufferTargetFreeSamples
>=
uiBlockLength
)
int
iClientRingBufferTargetLatencyFreeSamples
=
m_iClientRingBufferFreeSamples
-
(
m_oServerParams
.
iRingBufferSize
-
m_oServerParams
.
iTargetSampleLatency
);
if
(
iClientRingBufferTargetLatencyFreeSamples
>=
uiBlockLength
)
{
// Send Samples
int
iSendBlocks
=
iClientRingBufferTargetFreeSamples
/
uiBlockLength
;
int
iSendBlocks
=
iClientRingBufferTarget
Latency
FreeSamples
/
uiBlockLength
;
bAskClient
=
true
;
if
(
m_sfTempTransmitBuffer
.
GetLength
(
)
!=
iSendBlocks
*
uiBlockLength
)
...
...
@@ -217,21 +217,18 @@ bool CITANetAudioStreamingServer::LoopBody( )
}
else
{
/*
ITAServerLog
oLog
;
oLog
.
uiBlockId
=
++
iServerBlockId
;
// Neue Samples, bei ca 1ms warten
double dTimeDiff = ITAClock::getDefaultClock()->getTime() - m_dLastTimeStamp
;
float dSamples = dTimeDiff * m_pInputStream->GetSampleRate()
;
m_dLastTimeStamp =
ITAClock::getDefaultClock()->getTime()
;
int iSamples = ( int ) dSamples
;
int offset = iSamples % m_pInputStream->GetBlocklength(
);
m_iClientRingBufferFreeSamples +=
iSamples - offset
;
const
double
dTimestamp
=
ITAClock
::
getDefaultClock
()
->
getTime
()
;
const
double
dTimeDiff
=
dTimestamp
-
m_dLastTimeStamp
;
m_dLastTimeStamp
=
dTimestamp
;
oLog
.
dWorldTimeStamp
=
dTimestamp
;
float
dEstimatedSamples
=
dTimeDiff
*
m_pInputStream
->
GetSampleRate
(
);
m_iClientRingBufferFreeSamples
+=
(
int
)
dEstimatedSamples
;
oLog
.
iFreeSamples
=
m_iClientRingBufferFreeSamples
;
oLog
.
iProtocolStatus
=
555
;
oLog.dWorldTimeStamp = ITAClock::getDefaultClock()->getTime();
m_pServerLogger
->
log
(
oLog
);
*/
}
bAskClient
=
false
;
...
...
tests/NetAudio/ITANetAudioStreamingServerTest.cpp
View file @
72011a7c
...
...
@@ -30,7 +30,7 @@ int main(int argc, char** argv)
oStreamingServer
.
SetInputStream
(
&
oMuliplier
);
cout
<<
"Starting net audio server and waiting for connections on '"
<<
sServerName
<<
"' on port "
<<
iServerPort
<<
endl
;
oStreamingServer
.
Start
(
sServerName
,
iServerPort
);
oStreamingServer
.
Start
(
sServerName
,
iServerPort
,
100
);
while
(
!
oStreamingServer
.
IsClientConnected
())
{
...
...
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