From 0cd07615084e1e21d95760b6cb28dd80faf9b298 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 26 Jun 2014 10:13:43 +0800 Subject: [PATCH] fix time jitter zero algorithm bug, reset when timestamp overflow. --- trunk/src/app/srs_app_source.cpp | 31 +++++++++++++++++++------------ trunk/src/core/srs_core.hpp | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 58542672e..d0cf40dee 100644 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -69,25 +69,32 @@ int SrsRtmpJitter::correct(SrsSharedPtrMessage* msg, int tba, int tbv, SrsRtmpJi { int ret = ERROR_SUCCESS; - // all jitter correct features is disabled, ignore. - if (ag == SrsRtmpJitterAlgorithmOFF) { - return ret; - } - - - // start at zero, but donot ensure monotonically increasing. - if (ag == SrsRtmpJitterAlgorithmZERO) { - if (last_pkt_correct_time <= 0) { - last_pkt_correct_time = msg->header.timestamp; + // for performance issue + if (ag != SrsRtmpJitterAlgorithmFULL) { + // all jitter correct features is disabled, ignore. + if (ag == SrsRtmpJitterAlgorithmOFF) { + return ret; } - msg->header.timestamp -= last_pkt_correct_time; + + // start at zero, but donot ensure monotonically increasing. + if (ag == SrsRtmpJitterAlgorithmZERO) { + // for the first time, last_pkt_correct_time is zero. + // while when timestamp overflow, the timestamp become smaller, reset the last_pkt_correct_time. + if (last_pkt_correct_time <= 0 || last_pkt_correct_time > msg->header.timestamp) { + last_pkt_correct_time = msg->header.timestamp; + } + msg->header.timestamp -= last_pkt_correct_time; + return ret; + } + + // other algorithm, ignore. return ret; } // full jitter algorithm, do jitter correct. // set to 0 for metadata. - if (!msg->header.is_video() && !msg->header.is_audio()) { + if (!msg->header.is_audio() && !msg->header.is_video()) { msg->header.timestamp = 0; return ret; } diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index a90ab17fe..995cd2492 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR "0" #define VERSION_MINOR "9" -#define VERSION_REVISION "133" +#define VERSION_REVISION "134" #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION // server info. #define RTMP_SIG_SRS_KEY "SRS"