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
df4aa311
Commit
df4aa311
authored
Mar 29, 2017
by
Anne Heimes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server sendet variable Blocklängen
parent
79a868df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
13 deletions
+31
-13
include/ITANetAudioStreamingServer.h
include/ITANetAudioStreamingServer.h
+5
-1
src/ITANetAudioStreamingServer.cpp
src/ITANetAudioStreamingServer.cpp
+20
-9
tests/NetAudio/ITANetAudioStreamingServerTest.cpp
tests/NetAudio/ITANetAudioStreamingServerTest.cpp
+6
-3
No files found.
include/ITANetAudioStreamingServer.h
View file @
df4aa311
...
...
@@ -64,7 +64,7 @@ public:
~
CITANetAudioStreamingServer
();
//! Start to listen on a socket (blocking)
bool
Start
(
const
std
::
string
&
sAddress
,
const
int
iPort
,
const
double
dTimeIntervalCientSendStatus
);
bool
Start
(
const
std
::
string
&
sAddress
,
const
int
iPort
,
const
double
dTimeIntervalCientSendStatus
);
bool
IsClientConnected
()
const
;
std
::
string
GetNetworkAddress
()
const
;
int
GetNetworkPort
()
const
;
...
...
@@ -77,6 +77,9 @@ public:
int
GetNetStreamNumberOfChannels
()
const
;
double
GetNetStreamSampleRate
()
const
;
int
GetSendingBlockLength
()
const
;
void
SetSendingBlockLength
(
const
int
iSendingBlockLength
);
void
SetAutomaticUpdateRate
();
void
SetTargetLatencySamples
(
const
int
iTargetLatency
);
...
...
@@ -108,6 +111,7 @@ private:
int
m_iEstimatedClientRingBufferFreeSamples
;
int
m_iTargetLatencySamples
;
int
m_iMaxSendBlocks
;
int
m_iSendingBlockLength
;
double
m_dLastTimeStamp
;
friend
class
CITANetAudioServer
;
...
...
src/ITANetAudioStreamingServer.cpp
View file @
df4aa311
...
...
@@ -81,7 +81,7 @@ CITANetAudioStreamingServer::~CITANetAudioStreamingServer()
vstr
::
out
()
<<
"[ ITANetAudioStreamingServer ] Try-read access statistics: "
<<
m_swTryReadAccessStats
.
ToString
()
<<
std
::
endl
;
}
bool
CITANetAudioStreamingServer
::
Start
(
const
std
::
string
&
sAddress
,
int
iPort
,
double
dTimeIntervalCientSendStatus
)
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"
);
...
...
@@ -128,6 +128,8 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort,
m_pMessage
->
WriteDouble
(
dTimeIntervalCientSendStatus
);
m_pMessage
->
WriteMessage
();
m_iSendingBlockLength
=
m_pInputStream
->
GetBlocklength
();
m_sfTempTransmitBuffer
.
init
(
m_pInputStream
->
GetNumberOfChannels
(),
m_oServerParams
.
iRingBufferSize
,
true
);
...
...
@@ -147,28 +149,27 @@ bool CITANetAudioStreamingServer::LoopBody()
oLog
.
iTransmittedSamples
=
0
;
// Sending Samples
int
iBlockLength
=
m_pInputStream
->
GetBlocklength
();
int
iEstimatedClientRingBufferTargetLatencyFreeSamples
=
m_iEstimatedClientRingBufferFreeSamples
-
(
m_oServerParams
.
iRingBufferSize
-
m_iTargetLatencySamples
);
if
(
iEstimatedClientRingBufferTargetLatencyFreeSamples
>=
iBlockLength
)
if
(
iEstimatedClientRingBufferTargetLatencyFreeSamples
>=
m_iSendingBlockLength
)
{
// Send Samples
int
iSendBlocks
=
iEstimatedClientRingBufferTargetLatencyFreeSamples
/
i
BlockLength
;
int
iSendBlocks
=
iEstimatedClientRingBufferTargetLatencyFreeSamples
/
m_iSending
BlockLength
;
// Besser wre vermutlich, gleich alle samples zu senden und nicht nur einen Block nach dem anderen
if
(
m_sfTempTransmitBuffer
.
GetLength
()
!=
iBlockLength
)
m_sfTempTransmitBuffer
.
init
(
m_pInputStream
->
GetNumberOfChannels
(),
iBlockLength
,
false
);
if
(
m_sfTempTransmitBuffer
.
GetLength
()
!=
m_iSendingBlockLength
)
m_sfTempTransmitBuffer
.
init
(
m_pInputStream
->
GetNumberOfChannels
(),
m_iSendingBlockLength
,
false
);
for
(
int
j
=
0
;
j
<
iSendBlocks
;
j
++
)
{
for
(
int
i
=
0
;
i
<
int
(
m_pInputStream
->
GetNumberOfChannels
()
);
i
++
)
{
ITAStreamInfo
oStreamInfo
;
oStreamInfo
.
nSamples
=
i
BlockLength
;
oStreamInfo
.
nSamples
=
m_iSending
BlockLength
;
const
float
*
pfData
=
m_pInputStream
->
GetBlockPointer
(
i
,
&
oStreamInfo
);
if
(
pfData
!=
0
)
m_sfTempTransmitBuffer
[
i
].
write
(
pfData
,
iBlockLength
,
0
);
m_sfTempTransmitBuffer
[
i
].
write
(
pfData
,
m_iSendingBlockLength
,
0
);
}
m_pInputStream
->
IncrementBlockPointer
();
...
...
@@ -177,7 +178,7 @@ bool CITANetAudioStreamingServer::LoopBody()
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_SERVER_SENDING_SAMPLES
);
m_pMessage
->
WriteSampleFrame
(
&
m_sfTempTransmitBuffer
);
m_pMessage
->
WriteMessage
();
m_iEstimatedClientRingBufferFreeSamples
-=
i
BlockLength
;
m_iEstimatedClientRingBufferFreeSamples
-=
m_iSending
BlockLength
;
}
#ifdef NET_AUDIO_SHOW_TRAFFIC
...
...
@@ -266,6 +267,16 @@ int CITANetAudioStreamingServer::GetNetStreamBlocklength() const
return
m_sfTempTransmitBuffer
.
GetLength
();
}
int
CITANetAudioStreamingServer
::
GetSendingBlockLength
()
const
{
return
m_iSendingBlockLength
;
}
void
CITANetAudioStreamingServer
::
SetSendingBlockLength
(
const
int
iSendingBlockLength
)
{
m_iSendingBlockLength
=
iSendingBlockLength
;
}
int
CITANetAudioStreamingServer
::
GetNetStreamNumberOfChannels
()
const
{
return
m_sfTempTransmitBuffer
.
channels
();
...
...
tests/NetAudio/ITANetAudioStreamingServerTest.cpp
View file @
df4aa311
...
...
@@ -18,6 +18,7 @@ int g_iBlockLength = 32;
int
g_iChannels
=
2
;
int
g_iTargetLatencySamples
=
4
*
g_iBlockLength
;
// 1.4512ms
int
g_iRingBufferSize
=
2
*
g_iTargetLatencySamples
;
int
g_iSendingBlockLength
=
8
;
double
g_dClientStatusMessageTimeout
=
0.001
;
// seconds
string
g_sFileName
=
"gershwin-mono.wav"
;
...
...
@@ -34,13 +35,14 @@ int main( int argc, char** argv )
g_dSampleRate
=
strtod
(
argv
[
3
],
NULL
);
g_iBlockLength
=
atoi
(
argv
[
4
]
);
g_iChannels
=
atoi
(
argv
[
5
]
);
g_iTargetLatencySamples
=
atoi
(
argv
[
6
]
);
g_iRingBufferSize
=
atoi
(
argv
[
7
]
);
g_iTargetLatencySamples
=
atoi
(
argv
[
6
]);
g_iRingBufferSize
=
atoi
(
argv
[
7
]);
g_iSendingBlockLength
=
atoi
(
argv
[
8
]);
}
}
else
{
cout
<<
"Syntax: ServerName ServerPort SampleRate BufferSize Channel TargetLatencySamples RingBufferSize"
<<
endl
;
cout
<<
"Syntax: ServerName ServerPort SampleRate BufferSize Channel TargetLatencySamples RingBufferSize
SnedingBlockLength
"
<<
endl
;
cout
<<
"Using default values ..."
<<
endl
;
}
...
...
@@ -71,6 +73,7 @@ int main( int argc, char** argv )
oStreamingServer
.
SetInputStream
(
&
oMuliplier
);
oStreamingServer
.
SetTargetLatencySamples
(
g_iTargetLatencySamples
);
oStreamingServer
.
SetSendingBlockLength
(
g_iSendingBlockLength
);
cout
<<
"Starting net audio server and waiting for connections on '"
<<
g_sServerName
<<
"' on port "
<<
g_iServerPort
<<
endl
;
oStreamingServer
.
Start
(
g_sServerName
,
g_iServerPort
,
g_dClientStatusMessageTimeout
);
...
...
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