Skip to content

Commit

Permalink
[core] Placed CSndLossList and CRcvLossList inside the srt namespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed May 2, 2022
1 parent 042df34 commit 681b363
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
46 changes: 23 additions & 23 deletions srtcore/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ using srt_logging::qslog;

using namespace srt::sync;

CSndLossList::CSndLossList(int size)
srt::CSndLossList::CSndLossList(int size)
: m_caSeq()
, m_iHead(-1)
, m_iLength(0)
Expand All @@ -89,13 +89,13 @@ CSndLossList::CSndLossList(int size)
setupMutex(m_ListLock, "LossList");
}

CSndLossList::~CSndLossList()
srt::CSndLossList::~CSndLossList()
{
delete[] m_caSeq;
releaseMutex(m_ListLock);
}

void CSndLossList::traceState() const
void srt::CSndLossList::traceState() const
{
int pos = m_iHead;
while (pos != SRT_SEQNO_NONE)
Expand All @@ -109,7 +109,7 @@ void CSndLossList::traceState() const
std::cout << "\n";
}

int CSndLossList::insert(int32_t seqno1, int32_t seqno2)
int srt::CSndLossList::insert(int32_t seqno1, int32_t seqno2)
{
if (seqno1 < 0 || seqno2 < 0 ) {
LOGC(qslog.Error, log << "IPE: Tried to insert negative seqno " << seqno1 << ":" << seqno2
Expand Down Expand Up @@ -226,7 +226,7 @@ int CSndLossList::insert(int32_t seqno1, int32_t seqno2)
return m_iLength - origlen;
}

void CSndLossList::removeUpTo(int32_t seqno)
void srt::CSndLossList::removeUpTo(int32_t seqno)
{
ScopedLock listguard(m_ListLock);

Expand Down Expand Up @@ -338,14 +338,14 @@ void CSndLossList::removeUpTo(int32_t seqno)
}
}

int CSndLossList::getLossLength() const
int srt::CSndLossList::getLossLength() const
{
ScopedLock listguard(m_ListLock);

return m_iLength;
}

int32_t CSndLossList::popLostSeq()
int32_t srt::CSndLossList::popLostSeq()
{
ScopedLock listguard(m_ListLock);

Expand Down Expand Up @@ -389,7 +389,7 @@ int32_t CSndLossList::popLostSeq()
return seqno;
}

void CSndLossList::insertHead(int pos, int32_t seqno1, int32_t seqno2)
void srt::CSndLossList::insertHead(int pos, int32_t seqno1, int32_t seqno2)
{
SRT_ASSERT(pos >= 0);
m_caSeq[pos].seqstart = seqno1;
Expand All @@ -405,7 +405,7 @@ void CSndLossList::insertHead(int pos, int32_t seqno1, int32_t seqno2)
m_iLength += CSeqNo::seqlen(seqno1, seqno2);
}

void CSndLossList::insertAfter(int pos, int pos_after, int32_t seqno1, int32_t seqno2)
void srt::CSndLossList::insertAfter(int pos, int pos_after, int32_t seqno1, int32_t seqno2)
{
m_caSeq[pos].seqstart = seqno1;
SRT_ASSERT(m_caSeq[pos].seqend == SRT_SEQNO_NONE);
Expand All @@ -419,7 +419,7 @@ void CSndLossList::insertAfter(int pos, int pos_after, int32_t seqno1, int32_t s
m_iLength += CSeqNo::seqlen(seqno1, seqno2);
}

void CSndLossList::coalesce(int loc)
void srt::CSndLossList::coalesce(int loc)
{
// coalesce with next node. E.g., [3, 7], ..., [6, 9] becomes [3, 9]
while ((m_caSeq[loc].inext != -1) && (m_caSeq[loc].seqend != SRT_SEQNO_NONE))
Expand Down Expand Up @@ -455,7 +455,7 @@ void CSndLossList::coalesce(int loc)
}
}

bool CSndLossList::updateElement(int pos, int32_t seqno1, int32_t seqno2)
bool srt::CSndLossList::updateElement(int pos, int32_t seqno1, int32_t seqno2)
{
m_iLastInsertPos = pos;

Expand All @@ -481,7 +481,7 @@ bool CSndLossList::updateElement(int pos, int32_t seqno1, int32_t seqno2)

////////////////////////////////////////////////////////////////////////////////

CRcvLossList::CRcvLossList(int size)
srt::CRcvLossList::CRcvLossList(int size)
: m_caSeq()
, m_iHead(-1)
, m_iTail(-1)
Expand All @@ -499,12 +499,12 @@ CRcvLossList::CRcvLossList(int size)
}
}

CRcvLossList::~CRcvLossList()
srt::CRcvLossList::~CRcvLossList()
{
delete[] m_caSeq;
}

void CRcvLossList::insert(int32_t seqno1, int32_t seqno2)
void srt::CRcvLossList::insert(int32_t seqno1, int32_t seqno2)
{
// Data to be inserted must be larger than all those in the list
if (m_iLargestSeq != SRT_SEQNO_NONE && CSeqNo::seqcmp(seqno1, m_iLargestSeq) <= 0)
Expand Down Expand Up @@ -578,7 +578,7 @@ void CRcvLossList::insert(int32_t seqno1, int32_t seqno2)
m_iLength += CSeqNo::seqlen(seqno1, seqno2);
}

bool CRcvLossList::remove(int32_t seqno)
bool srt::CRcvLossList::remove(int32_t seqno)
{
if (m_iLargestSeq == SRT_SEQNO_NONE || CSeqNo::seqcmp(seqno, m_iLargestSeq) > 0)
m_iLargestSeq = seqno;
Expand Down Expand Up @@ -713,7 +713,7 @@ bool CRcvLossList::remove(int32_t seqno)
return true;
}

bool CRcvLossList::remove(int32_t seqno1, int32_t seqno2)
bool srt::CRcvLossList::remove(int32_t seqno1, int32_t seqno2)
{
if (seqno1 <= seqno2)
{
Expand All @@ -731,7 +731,7 @@ bool CRcvLossList::remove(int32_t seqno1, int32_t seqno2)
return true;
}

bool CRcvLossList::find(int32_t seqno1, int32_t seqno2) const
bool srt::CRcvLossList::find(int32_t seqno1, int32_t seqno2) const
{
if (0 == m_iLength)
return false;
Expand All @@ -752,20 +752,20 @@ bool CRcvLossList::find(int32_t seqno1, int32_t seqno2) const
return false;
}

int CRcvLossList::getLossLength() const
int srt::CRcvLossList::getLossLength() const
{
return m_iLength;
}

int32_t CRcvLossList::getFirstLostSeq() const
int32_t srt::CRcvLossList::getFirstLostSeq() const
{
if (0 == m_iLength)
return SRT_SEQNO_NONE;

return m_caSeq[m_iHead].seqstart;
}

void CRcvLossList::getLossArray(int32_t* array, int& len, int limit)
void srt::CRcvLossList::getLossArray(int32_t* array, int& len, int limit)
{
len = 0;

Expand All @@ -788,15 +788,15 @@ void CRcvLossList::getLossArray(int32_t* array, int& len, int limit)
}
}

CRcvFreshLoss::CRcvFreshLoss(int32_t seqlo, int32_t seqhi, int initial_age)
srt::CRcvFreshLoss::CRcvFreshLoss(int32_t seqlo, int32_t seqhi, int initial_age)
: ttl(initial_age)
, timestamp(steady_clock::now())
{
seq[0] = seqlo;
seq[1] = seqhi;
}

CRcvFreshLoss::Emod CRcvFreshLoss::revoke(int32_t sequence)
srt::CRcvFreshLoss::Emod srt::CRcvFreshLoss::revoke(int32_t sequence)
{
int32_t diffbegin = CSeqNo::seqcmp(sequence, seq[0]);
int32_t diffend = CSeqNo::seqcmp(sequence, seq[1]);
Expand Down Expand Up @@ -827,7 +827,7 @@ CRcvFreshLoss::Emod CRcvFreshLoss::revoke(int32_t sequence)
return SPLIT;
}

CRcvFreshLoss::Emod CRcvFreshLoss::revoke(int32_t lo, int32_t hi)
srt::CRcvFreshLoss::Emod srt::CRcvFreshLoss::revoke(int32_t lo, int32_t hi)
{
// This should only if the range lo-hi is anyhow covered by seq[0]-seq[1].

Expand Down
4 changes: 4 additions & 0 deletions srtcore/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ modified by
#include "udt.h"
#include "common.h"

namespace srt {

class CSndLossList
{
public:
Expand Down Expand Up @@ -264,4 +266,6 @@ struct CRcvFreshLoss
Emod revoke(int32_t lo, int32_t hi);
};

} // namespace srt

#endif

0 comments on commit 681b363

Please sign in to comment.