From 2740d65a0f5715c42eb6de24cbf610ba6271b85a Mon Sep 17 00:00:00 2001 From: Thulinma Date: Wed, 17 Aug 2022 10:54:31 +0200 Subject: [PATCH] Improved RTP timestamp logging, fixed bug related to firstTime value --- lib/rtp.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/rtp.cpp b/lib/rtp.cpp index 3ed9b7c6..5a5ed829 100644 --- a/lib/rtp.cpp +++ b/lib/rtp.cpp @@ -877,7 +877,7 @@ namespace RTP{ if (!firstTime){ milliSync = Util::bootMS(); firstTime = pTime + 1; - INFO_MSG("RTP timestamp rollover expected in " PRETTY_PRINT_TIME, + INFO_MSG("RTP timestamp rollover for %" PRIu64 " (%s) expected in " PRETTY_PRINT_TIME, trackId, codec.c_str(), PRETTY_ARG_TIME((0xFFFFFFFFul - firstTime) / multiplier / 1000)); }else{ if (recentWrap){ @@ -886,14 +886,15 @@ namespace RTP{ }else{ if (prevTime > pTime && pTime < 0x40000000lu && prevTime > 0x80000000lu){ ++wrapArounds; + INFO_MSG("RTP timestamp rollover %" PRIu32 " for %" PRIu64 " (%s) happened; next should be in " PRETTY_PRINT_TIME, wrapArounds, trackId, codec.c_str(), PRETTY_ARG_TIME((0xFFFFFFFFul) / multiplier / 1000)); recentWrap = true; } } } // When there are B-frames, the firstTime can be higher than the current time // causing msTime to become negative and thus overflow - if (firstTime > pTime + 1){ - WARN_MSG("firstTime was higher than current packet time. Readjusting firsTime..."); + if (!wrapArounds && firstTime > pTime + 1){ + WARN_MSG("firstTime was higher than current packet time. Readjusting firstTime..."); firstTime = pTime + 1; } prevTime = pkt.getTimeStamp();