diff --git a/srtcore/buffer_rcv.cpp b/srtcore/buffer_rcv.cpp index 363bd7e9c..e74d48c07 100644 --- a/srtcore/buffer_rcv.cpp +++ b/srtcore/buffer_rcv.cpp @@ -1096,12 +1096,12 @@ void CRcvBuffer::applyGroupDrift(const steady_clock::time_point& timebase, CRcvBuffer::time_point CRcvBuffer::getTsbPdTimeBase(uint32_t usPktTimestamp) const { - return m_tsbpd.getTsbPdTimeBase(usPktTimestamp); + return m_tsbpd.getBaseTime(usPktTimestamp); } void CRcvBuffer::updateTsbPdTimeBase(uint32_t usPktTimestamp) { - m_tsbpd.updateTsbPdTimeBase(usPktTimestamp); + m_tsbpd.updateBaseTime(usPktTimestamp); } string CRcvBuffer::strFullnessState(int iFirstUnackSeqNo, const time_point& tsNow) const @@ -1125,7 +1125,7 @@ string CRcvBuffer::strFullnessState(int iFirstUnackSeqNo, const time_point& tsNo { ss << ", timespan "; const uint32_t usPktTimestamp = packetAt(iLastPos).getMsgTimeStamp(); - ss << count_milliseconds(m_tsbpd.getPktTsbPdTime(usPktTimestamp) - nextValidPkt.tsbpd_time); + ss << count_milliseconds(m_tsbpd.getPktTime(usPktTimestamp) - nextValidPkt.tsbpd_time); ss << " ms"; } } @@ -1142,7 +1142,7 @@ string CRcvBuffer::strFullnessState(int iFirstUnackSeqNo, const time_point& tsNo CRcvBuffer::time_point CRcvBuffer::getPktTsbPdTime(uint32_t usPktTimestamp) const { - return m_tsbpd.getPktTsbPdTime(usPktTimestamp); + return m_tsbpd.getPktTime(usPktTimestamp); } /* Return moving average of acked data pkts, bytes, and timespan (ms) of the receive buffer */ diff --git a/srtcore/tsbpd_time.cpp b/srtcore/tsbpd_time.cpp index ec0f39f7b..d45215a01 100644 --- a/srtcore/tsbpd_time.cpp +++ b/srtcore/tsbpd_time.cpp @@ -122,7 +122,7 @@ bool CTsbpdTime::addDriftSample(uint32_t usPktTimestamp, const time_point& tsPkt // is to estimate RTT change and assume that the change of the one way network delay is // approximated by the half of the RTT change. const duration tdRTTDelta = usRTTSample >= 0 ? microseconds_from((usRTTSample - m_iFirstRTT) / 2) : duration(0); - const time_point tsPktBaseTime = getPktTsbPdBaseTimeNoLock(usPktTimestamp); + const time_point tsPktBaseTime = getPktBaseTimeNoLock(usPktTimestamp); const steady_clock::duration tdDrift = tsPktArrival - tsPktBaseTime - tdRTTDelta; const bool updated = m_DriftTracer.update(count_microseconds(tdDrift)); @@ -210,10 +210,10 @@ void CTsbpdTime::applyGroupDrift(const steady_clock::time_point& timebase, m_DriftTracer.forceDrift(count_microseconds(udrift)); } -CTsbpdTime::time_point CTsbpdTime::getTsbPdTimeBaseNoLock(uint32_t timestamp_us) const +CTsbpdTime::time_point CTsbpdTime::getBaseTimeNoLock(uint32_t timestamp_us) const { // A data packet within [TSBPD_WRAP_PERIOD; 2 * TSBPD_WRAP_PERIOD] would end TSBPD wrap-aware state. - // Some incoming control packets may not update the TSBPD base (calling updateTsbPdTimeBase(..)), + // Some incoming control packets may not update the TSBPD base (calling updateBaseTime(..)), // but may come before a data packet with a timestamp in this range. Therefore the whole range should be tracked. const int64_t carryover_us = (m_bTsbPdWrapCheck && timestamp_us <= 2 * TSBPD_WRAP_PERIOD) ? int64_t(CPacket::MAX_TIMESTAMP) + 1 : 0; @@ -221,31 +221,31 @@ CTsbpdTime::time_point CTsbpdTime::getTsbPdTimeBaseNoLock(uint32_t timestamp_us) return (m_tsTsbPdTimeBase + microseconds_from(carryover_us)); } -CTsbpdTime::time_point CTsbpdTime::getTsbPdTimeBase(uint32_t timestamp_us) const +CTsbpdTime::time_point CTsbpdTime::getBaseTime(uint32_t timestamp_us) const { SharedLock lck(m_mtxRW); - return getTsbPdTimeBaseNoLock(timestamp_us); + return getBaseTimeNoLock(timestamp_us); } -CTsbpdTime::time_point CTsbpdTime::getPktTsbPdTime(uint32_t usPktTimestamp) const +CTsbpdTime::time_point CTsbpdTime::getPktTime(uint32_t usPktTimestamp) const { SharedLock lck(m_mtxRW); - time_point value = getPktTsbPdBaseTimeNoLock(usPktTimestamp) + m_tdTsbPdDelay + microseconds_from(m_DriftTracer.drift()); + time_point value = getPktBaseTimeNoLock(usPktTimestamp) + m_tdTsbPdDelay + microseconds_from(m_DriftTracer.drift()); return value; } -CTsbpdTime::time_point CTsbpdTime::getPktTsbPdBaseTimeNoLock(uint32_t usPktTimestamp) const +CTsbpdTime::time_point CTsbpdTime::getPktBaseTimeNoLock(uint32_t usPktTimestamp) const { - return getTsbPdTimeBaseNoLock(usPktTimestamp) + microseconds_from(usPktTimestamp); + return getBaseTimeNoLock(usPktTimestamp) + microseconds_from(usPktTimestamp); } -CTsbpdTime::time_point CTsbpdTime::getPktTsbPdBaseTime(uint32_t usPktTimestamp) const +CTsbpdTime::time_point CTsbpdTime::getPktBaseTime(uint32_t usPktTimestamp) const { - return getTsbPdTimeBase(usPktTimestamp) + microseconds_from(usPktTimestamp); + return getBaseTime(usPktTimestamp) + microseconds_from(usPktTimestamp); } -void CTsbpdTime::updateTsbPdTimeBase(uint32_t usPktTimestamp) +void CTsbpdTime::updateBaseTime(uint32_t usPktTimestamp) { ExclusiveLock lck(m_mtxRW); if (m_bTsbPdWrapCheck) diff --git a/srtcore/tsbpd_time.h b/srtcore/tsbpd_time.h index 78cf18d6f..9ef2a9838 100644 --- a/srtcore/tsbpd_time.h +++ b/srtcore/tsbpd_time.h @@ -76,31 +76,31 @@ class CTsbpdTime /// When packet timestamp approaches CPacket::MAX_TIMESTAMP, the TSBPD base time should be /// shifted accordingly to correctly handle new packets with timestamps starting from zero. /// @param usPktTimestamp timestamp field value of a data packet. - void updateTsbPdTimeBase(uint32_t usPktTimestamp); + void updateBaseTime(uint32_t usPktTimestamp); /// @brief Get TSBPD base time adjusted for carryover, which occurs when /// a packet's timestamp exceeds the UINT32_MAX and continues from zero. /// @param [in] usPktTimestamp 32-bit value of packet timestamp field (microseconds). /// /// @return TSBPD base time for a provided packet timestamp. - time_point getTsbPdTimeBase(uint32_t usPktTimestamp) const; + time_point getBaseTime(uint32_t usPktTimestamp) const; /// @brief Get packet TSBPD time without buffering delay and clock drift, which is /// the target time for delivering the packet to an upstream application. - /// Essentially: getTsbPdTimeBase(usPktTimestamp) + usPktTimestamp + /// Essentially: getBaseTime(usPktTimestamp) + usPktTimestamp /// @param [in] usPktTimestamp 32-bit value of packet timestamp field (microseconds). /// /// @return Packet TSBPD base time without buffering delay. - time_point getPktTsbPdBaseTime(uint32_t usPktTimestamp) const; + time_point getPktBaseTime(uint32_t usPktTimestamp) const; /// @brief Get packet TSBPD time with buffering delay and clock drift, which is /// the target time for delivering the packet to an upstream application /// (including drift and carryover effects, if any). - /// Essentially: getPktTsbPdBaseTime(usPktTimestamp) + m_tdTsbPdDelay + drift() + /// Essentially: getPktBaseTime(usPktTimestamp) + m_tdTsbPdDelay + drift() /// @param [in] usPktTimestamp 32-bit value of packet timestamp field (microseconds). /// /// @return Packet TSBPD time with buffering delay. - time_point getPktTsbPdTime(uint32_t usPktTimestamp) const; + time_point getPktTime(uint32_t usPktTimestamp) const; /// @brief Get current drift value. /// @return current drift value. @@ -123,16 +123,16 @@ class CTsbpdTime /// @param [in] usPktTimestamp 32-bit value of packet timestamp field (microseconds). /// /// @return TSBPD base time for a provided packet timestamp. - time_point getTsbPdTimeBaseNoLock(uint32_t usPktTimestamp) const; + time_point getBaseTimeNoLock(uint32_t usPktTimestamp) const; /// @brief Get packet TSBPD time without buffering delay and clock drift, which is /// the target time for delivering the packet to an upstream application. - /// Essentially: getTsbPdTimeBase(usPktTimestamp) + usPktTimestamp + /// Essentially: getBaseTime(usPktTimestamp) + usPktTimestamp /// Does not lock the internal state. /// @param [in] usPktTimestamp 32-bit value of packet timestamp field (microseconds). /// /// @return Packet TSBPD base time without buffering delay. - time_point getPktTsbPdBaseTimeNoLock(uint32_t usPktTimestamp) const; + time_point getPktBaseTimeNoLock(uint32_t usPktTimestamp) const; int m_iFirstRTT; // First measured RTT sample. @@ -143,7 +143,7 @@ class CTsbpdTime /// @note m_tsTsbPdTimeBase is changed in the following cases: /// 1. Initialized upon SRT_CMD_HSREQ packet as the difference with the current time: /// = (NOW - PACKET_TIMESTAMP), at the time of HSREQ reception. - /// 2. Shifted forward on timestamp overflow (@see CTsbpdTime::updateTsbPdTimeBase), when overflow + /// 2. Shifted forward on timestamp overflow (@see CTsbpdTime::updateBaseTime), when overflow /// of the timestamp field value of a data packet is detected. /// += CPacket::MAX_TIMESTAMP + 1 /// 3. Clock drift (@see CTsbpdTime::addDriftSample, executed exclusively