Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ITADataSources
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Institute of Technical Acoustics (ITA)
ITADataSources
Commits
dd34eff7
Commit
dd34eff7
authored
8 years ago
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Downloads
Patches
Plain Diff
Finished client server init until some values are exchanged.
parent
d37462eb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/ITANetAudioMessage.cpp
+5
-6
5 additions, 6 deletions
src/ITANetAudioMessage.cpp
src/ITANetAudioStreamingClient.cpp
+5
-2
5 additions, 2 deletions
src/ITANetAudioStreamingClient.cpp
src/ITANetAudioStreamingServer.cpp
+17
-18
17 additions, 18 deletions
src/ITANetAudioStreamingServer.cpp
with
27 additions
and
26 deletions
src/ITANetAudioMessage.cpp
+
5
−
6
View file @
dd34eff7
...
...
@@ -10,8 +10,8 @@
static
int
S_nMessageIds
=
0
;
CITANetAudioMessage
::
CITANetAudioMessage
(
VistaSerializingToolset
::
ByteOrderSwapBehavior
bSwapBuffers
)
:
m_vecIncomingBuffer
()
,
m_oOutgoing
()
:
m_vecIncomingBuffer
(
2048
)
,
m_oOutgoing
(
2048
)
,
m_pConnection
(
NULL
)
{
m_oOutgoing
.
SetByteorderSwapFlag
(
bSwapBuffers
);
...
...
@@ -37,7 +37,6 @@ void CITANetAudioMessage::ResetMessage()
m_oOutgoing
.
ClearBuffer
();
m_oOutgoing
.
WriteInt32
(
0
);
// size dummy
m_oOutgoing
.
WriteInt32
(
0
);
// type dummy
m_oOutgoing
.
WriteInt32
(
0
);
// exceptmode dummy
m_oOutgoing
.
WriteInt32
(
0
);
// ID
m_oIncoming
.
SetBuffer
(
NULL
,
0
);
...
...
@@ -82,8 +81,8 @@ void CITANetAudioMessage::WriteMessage()
try
{
int
nRet
=
m_pConnection
->
Write
RawBuffer
(
m_oOutgoing
.
GetBuffer
()
,
m_oOutgoing
.
GetBufferSize
()
);
int
i
RawBuffer
Size
=
m_oOutgoing
.
GetBuffer
Size
()
;
int
nRet
=
m_pConnection
->
WriteRawBuffer
(
m_oOutgoing
.
GetBuffer
(),
iRawBuffer
Size
);
m_pConnection
->
WaitForSendFinish
();
if
(
nRet
!=
m_oOutgoing
.
GetBufferSize
()
)
ITA_EXCEPT1
(
NETWORK_ERROR
,
"Could not write the expected number of bytes"
);
...
...
@@ -196,6 +195,7 @@ void CITANetAudioMessage::ReadAnswer()
if
(
nMessageSize
>
(
int
)
m_vecIncomingBuffer
.
size
()
)
m_vecIncomingBuffer
.
resize
(
nMessageSize
);
// jst: hier nicht while( nReturn < nMessageSize) ReadRawBuffer??
nReturn
=
m_pConnection
->
ReadRawBuffer
(
&
m_vecIncomingBuffer
[
0
],
nMessageSize
);
if
(
nReturn
!=
nMessageSize
)
ITA_EXCEPT1
(
UNKNOWN
,
"Protokoll error, Received less bytes than expected"
);
...
...
@@ -216,7 +216,6 @@ void CITANetAudioMessage::ReadAnswer()
try
{
m_nAnswerType
=
ReadInt
();
// TODO: assert weg, dafr Kontrolle falls Server crasht<
ReadInt
();
// protocol overhead - just read and ignore
int
nMessageID
=
ReadInt
();
assert
(
nMessageID
==
m_nMessageId
);
m_nMessageId
=
nMessageID
;
...
...
This diff is collapsed.
Click to expand it.
src/ITANetAudioStreamingClient.cpp
+
5
−
2
View file @
dd34eff7
...
...
@@ -44,18 +44,21 @@ bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPor
// Validate streaming parameters of server and client
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_CLIENT_OPEN
);
m_pMessage
->
WriteStreamingParameters
(
m_oClientParams
);
//m_pMessage->WriteStreamingParameters( m_oClientParams ); // Not yet
m_pMessage
->
WriteInt
(
42
);
m_pMessage
->
WriteMessage
();
m_pMessage
->
ReadAnswer
();
assert
(
m_pMessage
->
GetAnswerType
()
==
CITANetAudioProtocol
::
NP_SERVER_OPEN
);
bool
bOK
=
m_pMessage
->
Read
Bool
();
int
i42
=
m_pMessage
->
Read
Int
();
/* Not yet
CITANetAudioProtocol::StreamingParameters oServerParams = m_pMessage->ReadStreamingParameters();
if( oServerParams == m_oClientParams )
m_oServerParams = oServerParams;
else
ITA_EXCEPT1( INVALID_PARAMETER, "Streaming parameters of network audio server and client do not match." );
*/
Run
();
...
...
This diff is collapsed.
Click to expand it.
src/ITANetAudioStreamingServer.cpp
+
17
−
18
View file @
dd34eff7
...
...
@@ -24,35 +24,34 @@ CITANetAudioStreamingServer::CITANetAudioStreamingServer()
,
m_pConnection
(
NULL
)
{
m_pNetAudioServer
=
new
CITANetAudioServer
();
m_pMessage
=
new
CITANetAudioMessage
(
VistaSerializingToolset
::
SWAPS_MULTIBYTE_VALUES
);
}
bool
CITANetAudioStreamingServer
::
Start
(
const
std
::
string
&
sAddress
,
int
iPort
)
{
// TODO: vorrckgabe noch anfangen zu senden (Samples)
if
(
m_pNetAudioServer
->
Start
(
sAddress
,
iPort
)
)
{
m_pConnection
=
m_pNetAudioServer
->
GetConnection
();
m_pMessage
->
ResetMessage
();
m_pMessage
->
SetConnection
(
m_pConnection
);
m_pMessage
->
ReadMessage
();
if
(
!
m_pNetAudioServer
->
Start
(
sAddress
,
iPort
)
)
// blocking
return
false
;
int
nMT
=
m_pMessage
->
GetMessageType
();
assert
(
nMT
==
CITANetAudioProtocol
::
NP_CLIENT_OPEN
);
m_pConnection
=
m_pNetAudioServer
->
GetConnection
();
CITANetAudioProtocol
::
StreamingParameters
oClientParams
=
m_pMessage
->
ReadStreamingParameters
();
m_pMessage
=
new
CITANetAudioMessage
(
m_pConnection
->
GetByteorderSwapFlag
()
);
m_pMessage
->
ResetMessage
();
m_pMessage
->
SetConnection
(
m_pConnection
);
m_pMessage
->
ReadMessage
();
// blocking
m_pMessage
->
S
et
AnswerType
(
CITANetAudioProtocol
::
NP_SERVER_OPEN
);
m_pMessage
->
WriteBool
(
true
);
m_pMessage
->
WriteAnswer
();
int
nMT
=
m_pMessage
->
G
et
MessageType
(
);
assert
(
nMT
==
CITANetAudioProtocol
::
NP_CLIENT_OPEN
);
int
i42
=
m_pMessage
->
ReadInt
();
Run
();
//CITANetAudioProtocol::StreamingParameters oClientParams = m_pMessage->ReadStreamingParameters
();
return
true
;
}
m_pMessage
->
SetAnswerType
(
CITANetAudioProtocol
::
NP_SERVER_OPEN
);
m_pMessage
->
WriteInt
(
2
*
42
);
m_pMessage
->
WriteAnswer
();
return
false
;
Run
();
return
true
;
}
bool
CITANetAudioStreamingServer
::
IsClientConnected
()
const
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment