Debian Codegraph @

srtcore/group_common.cpp

raw
1 /*
2 * SRT - Secure, Reliable, Transport
3 * Copyright (c) 2021 Haivision Systems Inc.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 */
10
11 /*****************************************************************************
12 Written by
13 Haivision Systems Inc.
14 *****************************************************************************/
15
16 #include "platform_sys.h"
17
18 #include "group_common.h"
19 #include "api.h"
20
21 namespace srt
22 {
23 namespace groups
24 {
25
26 SocketData prepareSocketData(CUDTSocket* s)
27 {
28 // This uses default SRT_GST_BROKEN because when the group operation is done,
29 // then the SRT_GST_IDLE state automatically turns into SRT_GST_RUNNING. This is
30 // recognized as an initial state of the fresh added socket to the group,
31 // so some "initial configuration" must be done on it, after which it's
32 // turned into SRT_GST_RUNNING, that is, it's treated as all others. When
33 // set to SRT_GST_BROKEN, this socket is disregarded. This socket isn't cleaned
34 // up, however, unless the status is simultaneously SRTS_BROKEN.
35
36 // The order of operations is then:
37 // - add the socket to the group in this "broken" initial state
38 // - connect the socket (or get it extracted from accept)
39 // - update the socket state (should be SRTS_CONNECTED)
40 // - once the connection is established (may take time with connect), set SRT_GST_IDLE
41 // - the next operation of send/recv will automatically turn it into SRT_GST_RUNNING
42 SocketData sd = {
43 s->m_SocketID,
44 s,
45 -1,
46 SRTS_INIT,
47 SRT_GST_BROKEN,
48 SRT_GST_BROKEN,
49 -1,
50 -1,
51 sockaddr_any(),
52 sockaddr_any(),
53 false,
54 false,
55 false,
56 0, // weight
57 0 // pktSndDropTotal
58 };
59 return sd;
60 }
61
62 } // namespace groups
63 } // namespace srt