@@ -63,81 +63,19 @@ bool CUDTGroup::getBufferTimeBase(CUDT* forthesakeof,
63
63
}
64
64
65
65
// [[using locked(this->m_GroupLock)]];
66
- bool CUDTGroup::applyGroupSequences (SRTSOCKET target , int32_t & w_snd_isn, int32_t & w_rcv_isn)
66
+ void CUDTGroup::applyGroupSequences (SRTSOCKET /* not sure if needed */ , int32_t & w_snd_isn, int32_t & w_rcv_isn)
67
67
{
68
- if (m_bConnected) // You are the first one, no need to change.
69
- {
70
- IF_HEAVY_LOGGING (string update_reason = " what?" );
71
- // Find a socket that is declared connected and is not
72
- // the socket that caused the call.
73
- for (gli_t gi = m_Group.begin (); gi != m_Group.end (); ++gi)
74
- {
75
- if (gi->id == target)
76
- continue ;
77
-
78
- CUDT& se = gi->ps ->core ();
79
- if (!se.m_bConnected )
80
- continue ;
81
-
82
- // Found it. Get the following sequences:
83
- // For sending, the sequence that is about to be sent next.
84
- // For receiving, the sequence of the latest received packet.
85
-
86
- // SndCurrSeqNo is initially set to ISN-1, this next one is
87
- // the sequence that is about to be stamped on the next sent packet
88
- // over that socket. Using this field is safer because it is atomic
89
- // and its affinity is to the same thread as the sending function.
90
-
91
- // NOTE: the groupwise scheduling sequence might have been set
92
- // already. If so, it means that it was set by either:
93
- // - the call of this function on the very first conencted socket (see below)
94
- // - the call to `sendBroadcast` or `sendBackup`
95
- // In both cases, we want THIS EXACTLY value to be reported
96
- if (m_iLastSchedSeqNo != -1 )
97
- {
98
- w_snd_isn = m_iLastSchedSeqNo;
99
- IF_HEAVY_LOGGING (update_reason = " GROUPWISE snd-seq" );
100
- }
101
- else
102
- {
103
- w_snd_isn = se.m_iSndNextSeqNo ;
104
-
105
- // Write it back to the groupwise scheduling sequence so that
106
- // any next connected socket will take this value as well.
107
- m_iLastSchedSeqNo = w_snd_isn;
108
- IF_HEAVY_LOGGING (update_reason = " existing socket not yet sending" );
109
- }
110
-
111
- // RcvCurrSeqNo is increased by one because it happens that at the
112
- // synchronization moment it's already past reading and delivery.
113
- // This is redundancy, so the redundant socket is connected at the moment
114
- // when the other one is already transmitting, so skipping one packet
115
- // even if later transmitted is less troublesome than requesting a
116
- // "mistakenly seen as lost" packet.
117
- w_rcv_isn = CSeqNo::incseq (se.m_iRcvCurrSeqNo );
118
-
119
- HLOGC (gmlog.Debug ,
120
- log << " applyGroupSequences: @" << target << " gets seq from @" << gi->id << " rcv %" << (w_rcv_isn)
121
- << " snd %" << (w_snd_isn) << " as " << update_reason);
122
- return false ;
123
- }
124
- }
125
-
126
- // If the GROUP (!) is not connected, or no running/pending socket has been found.
127
- // // That is, given socket is the first one.
128
- // The group data should be set up with its own data. They should already be passed here
129
- // in the variables.
130
- //
131
- // Override the schedule sequence of the group in this case because whatever is set now,
132
- // it's not valid.
133
-
134
- HLOGC (gmlog.Debug ,
135
- log << " applyGroupSequences: no socket found connected and transmitting, @" << target
136
- << " not changing sequences, storing snd-seq %" << (w_snd_isn));
137
-
138
- set_currentSchedSequence (w_snd_isn);
139
-
140
- return true ;
68
+ // LastSchedSeqNo is initially set to the ISN of first connected socket,
69
+ // its' also updated in group send functions to the next scheduling seq.
70
+ w_snd_isn = m_iLastSchedSeqNo;
71
+
72
+ // RcvCurrSeqNo is increased by one because it happens that at the
73
+ // synchronization moment it's already past reading and delivery.
74
+ // This is redundancy, so the redundant socket is connected at the moment
75
+ // when the other one is already transmitting, so skipping one packet
76
+ // even if later transmitted is less troublesome than requesting a
77
+ // "mistakenly seen as lost" packet.
78
+ w_rcv_isn = CSeqNo::incseq (m_iRcvCurrSeqNo);
141
79
}
142
80
143
81
// NOTE: This function is now for DEBUG PURPOSES ONLY.
@@ -263,7 +201,6 @@ CUDTGroup::CUDTGroup(SRT_GROUP_TYPE gtype)
263
201
, m_bSynSending(true )
264
202
, m_bTsbPd(true )
265
203
, m_bTLPktDrop(true )
266
- , m_iTsbPdDelay_us(0 )
267
204
// m_*EID and m_*Epolld fields will be initialized
268
205
// in the constructor body.
269
206
, m_iSndTimeOut(-1 )
@@ -276,6 +213,7 @@ CUDTGroup::CUDTGroup(SRT_GROUP_TYPE gtype)
276
213
, m_bClosing(false )
277
214
, m_iLastSchedSeqNo(SRT_SEQNO_NONE)
278
215
, m_iLastSchedMsgNo(SRT_MSGNO_NONE)
216
+ , m_iRcvCurrSeqNo(SRT_SEQNO_NONE)
279
217
{
280
218
setupMutex (m_GroupLock, " Group" );
281
219
setupMutex (m_RcvDataLock, " RcvData" );
@@ -845,6 +783,8 @@ void CUDTGroup::syncWithSocket(const CUDT& core, const HandshakeSide side)
845
783
set_currentSchedSequence (core.ISN ());
846
784
}
847
785
786
+ set_currentRecvSequence (core.m_iRcvCurrSeqNo );
787
+
848
788
// XXX
849
789
// Might need further investigation as to whether this isn't
850
790
// wrong for some cases. By having this -1 here the value will be
@@ -857,11 +797,6 @@ void CUDTGroup::syncWithSocket(const CUDT& core, const HandshakeSide side)
857
797
//
858
798
// Previous implementation used setting to: core.m_iPeerISN
859
799
resetInitialRxSequence ();
860
-
861
- // Get the latency (possibly fixed against the opposite side)
862
- // from the first socket (core.m_iTsbPdDelay_ms),
863
- // and set it on the current socket.
864
- set_latency (core.m_iTsbPdDelay_ms * int64_t (1000 ));
865
800
}
866
801
867
802
void CUDTGroup::close ()
@@ -2089,6 +2024,22 @@ void CUDTGroup::updateReadState(SRTSOCKET /* not sure if needed */, int32_t sequ
2089
2024
}
2090
2025
}
2091
2026
2027
+ void CUDTGroup::updateRcvCurrSeqNo (int32_t seq)
2028
+ {
2029
+ ScopedLock lg (m_GroupLock);
2030
+
2031
+ if (m_iRcvCurrSeqNo == SRT_SEQNO_NONE)
2032
+ {
2033
+ LOGC (grlog.Error ,
2034
+ log << " IPE: CUDTGroup::m_iRcvCurrSeqNo was not initialized by the first member, setting to %" << seq);
2035
+ m_iRcvCurrSeqNo = seq;
2036
+ }
2037
+ else if (CSeqNo::seqcmp (seq, m_iRcvCurrSeqNo) > 0 )
2038
+ {
2039
+ m_iRcvCurrSeqNo = seq;
2040
+ }
2041
+ }
2042
+
2092
2043
int32_t CUDTGroup::getRcvBaseSeqNo ()
2093
2044
{
2094
2045
ScopedLock lg (m_GroupLock);
0 commit comments