diff --git a/srtcore/buffer_rcv.cpp b/srtcore/buffer_rcv.cpp index af3ab7f0c..a41e34329 100644 --- a/srtcore/buffer_rcv.cpp +++ b/srtcore/buffer_rcv.cpp @@ -605,6 +605,24 @@ void CRcvBufferNew::releaseUnitInPos(int pos) m_pUnitQueue->makeUnitFree(tmp); } +bool CRcvBufferNew::dropUnitInPos(int pos) +{ + if (!m_entries[pos].pUnit) + return false; + if (m_tsbpd.isEnabled()) + { + updateTsbPdTimeBase(m_entries[pos].pUnit->m_Packet.getMsgTimeStamp()); + } + else if (m_bMessageAPI && !m_entries[pos].pUnit->m_Packet.getMsgOrderFlag()) + { + --m_numOutOfOrderPackets; + if (pos == m_iFirstReadableOutOfOrder) + m_iFirstReadableOutOfOrder = -1; + } + releaseUnitInPos(pos); + return true; +} + void CRcvBufferNew::releaseNextFillerEntries() { int pos = m_iStartPos; diff --git a/srtcore/buffer_rcv.h b/srtcore/buffer_rcv.h index cee4329a6..0cba51972 100644 --- a/srtcore/buffer_rcv.h +++ b/srtcore/buffer_rcv.h @@ -221,6 +221,11 @@ class CRcvBufferNew void updateNonreadPos(); void releaseUnitInPos(int pos); + /// @brief Drop a unit from the buffer. + /// @param pos position in the m_entries of the unit to drop. + /// @return false if nothing to drop, true if the unit was dropped successfully. + bool dropUnitInPos(int pos); + /// Release entries following the current buffer position if they were already /// read out of order (EntryState_Read) or dropped (EntryState_Drop). void releaseNextFillerEntries();