Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
ITADataSources
Commits
dd34eff7
Commit
dd34eff7
authored
Dec 21, 2016
by
Dipl.-Ing. Jonas Stienen
Browse files
Finished client server init until some values are exchanged.
parent
d37462eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/ITANetAudioMessage.cpp
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
;
...
...
src/ITANetAudioStreamingClient.cpp
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
();
...
...
src/ITANetAudioStreamingServer.cpp
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
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment