-
Notifications
You must be signed in to change notification settings - Fork 861
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] SocketData moved to group_common.h (#1907)
(Refactoring)
- Loading branch information
1 parent
262fe21
commit a499c42
Showing
8 changed files
with
138 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* SRT - Secure, Reliable, Transport | ||
* Copyright (c) 2021 Haivision Systems Inc. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
*/ | ||
|
||
/***************************************************************************** | ||
Written by | ||
Haivision Systems Inc. | ||
*****************************************************************************/ | ||
|
||
#include "platform_sys.h" | ||
|
||
#include "group_common.h" | ||
#include "api.h" | ||
|
||
namespace srt | ||
{ | ||
namespace groups | ||
{ | ||
|
||
SocketData prepareSocketData(CUDTSocket* s) | ||
{ | ||
// This uses default SRT_GST_BROKEN because when the group operation is done, | ||
// then the SRT_GST_IDLE state automatically turns into SRT_GST_RUNNING. This is | ||
// recognized as an initial state of the fresh added socket to the group, | ||
// so some "initial configuration" must be done on it, after which it's | ||
// turned into SRT_GST_RUNNING, that is, it's treated as all others. When | ||
// set to SRT_GST_BROKEN, this socket is disregarded. This socket isn't cleaned | ||
// up, however, unless the status is simultaneously SRTS_BROKEN. | ||
|
||
// The order of operations is then: | ||
// - add the socket to the group in this "broken" initial state | ||
// - connect the socket (or get it extracted from accept) | ||
// - update the socket state (should be SRTS_CONNECTED) | ||
// - once the connection is established (may take time with connect), set SRT_GST_IDLE | ||
// - the next operation of send/recv will automatically turn it into SRT_GST_RUNNING | ||
SocketData sd = { | ||
s->m_SocketID, | ||
s, | ||
-1, | ||
SRTS_INIT, | ||
SRT_GST_BROKEN, | ||
SRT_GST_BROKEN, | ||
-1, | ||
-1, | ||
sockaddr_any(), | ||
sockaddr_any(), | ||
false, | ||
false, | ||
false, | ||
0 // weight | ||
}; | ||
return sd; | ||
} | ||
|
||
} // namespace groups | ||
} // namespace srt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* SRT - Secure, Reliable, Transport | ||
* Copyright (c) 2021 Haivision Systems Inc. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
*/ | ||
|
||
/***************************************************************************** | ||
Written by | ||
Haivision Systems Inc. | ||
*****************************************************************************/ | ||
|
||
#ifndef INC_SRT_GROUP_COMMON_H | ||
#define INC_SRT_GROUP_COMMON_H | ||
|
||
#include "srt.h" | ||
#include "common.h" | ||
#include "core.h" | ||
|
||
#include <list> | ||
|
||
namespace srt | ||
{ | ||
namespace groups | ||
{ | ||
typedef SRT_MEMBERSTATUS GroupState; | ||
|
||
struct SocketData | ||
{ | ||
SRTSOCKET id; // same as ps->m_SocketID | ||
CUDTSocket* ps; | ||
int token; | ||
SRT_SOCKSTATUS laststatus; | ||
GroupState sndstate; | ||
GroupState rcvstate; | ||
int sndresult; | ||
int rcvresult; | ||
sockaddr_any agent; | ||
sockaddr_any peer; | ||
bool ready_read; | ||
bool ready_write; | ||
bool ready_error; | ||
|
||
// Configuration | ||
uint16_t weight; | ||
}; | ||
|
||
SocketData prepareSocketData(CUDTSocket* s); | ||
|
||
typedef std::list<SocketData> group_t; | ||
typedef group_t::iterator gli_t; | ||
|
||
} // namespace groups | ||
} // namespace srt | ||
|
||
|
||
#endif // INC_SRT_GROUP_COMMON_H |