From 681b363579b672ae175856176f9a022a649945b3 Mon Sep 17 00:00:00 2001 From: Maxim Sharabayko Date: Mon, 2 May 2022 11:44:07 +0200 Subject: [PATCH] [core] Placed CSndLossList and CRcvLossList inside the srt namespace. --- srtcore/list.cpp | 46 +++++++++++++++++++++++----------------------- srtcore/list.h | 4 ++++ 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/srtcore/list.cpp b/srtcore/list.cpp index ec63c8755..212599595 100644 --- a/srtcore/list.cpp +++ b/srtcore/list.cpp @@ -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) @@ -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) @@ -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 @@ -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); @@ -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); @@ -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; @@ -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); @@ -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)) @@ -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; @@ -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) @@ -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) @@ -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; @@ -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) { @@ -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; @@ -752,12 +752,12 @@ 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; @@ -765,7 +765,7 @@ int32_t CRcvLossList::getFirstLostSeq() const 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; @@ -788,7 +788,7 @@ 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()) { @@ -796,7 +796,7 @@ CRcvFreshLoss::CRcvFreshLoss(int32_t seqlo, int32_t seqhi, int initial_age) 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]); @@ -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]. diff --git a/srtcore/list.h b/srtcore/list.h index d79349aa7..03f05e927 100644 --- a/srtcore/list.h +++ b/srtcore/list.h @@ -56,6 +56,8 @@ modified by #include "udt.h" #include "common.h" +namespace srt { + class CSndLossList { public: @@ -264,4 +266,6 @@ struct CRcvFreshLoss Emod revoke(int32_t lo, int32_t hi); }; +} // namespace srt + #endif