1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 11:51:57 +00:00

fix time jitter zero algorithm bug, reset when timestamp overflow.

This commit is contained in:
winlin 2014-06-26 10:13:43 +08:00
parent 1970e18ed6
commit 0cd0761508
2 changed files with 20 additions and 13 deletions

View file

@ -69,25 +69,32 @@ int SrsRtmpJitter::correct(SrsSharedPtrMessage* msg, int tba, int tbv, SrsRtmpJi
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
// for performance issue
if (ag != SrsRtmpJitterAlgorithmFULL) {
// all jitter correct features is disabled, ignore. // all jitter correct features is disabled, ignore.
if (ag == SrsRtmpJitterAlgorithmOFF) { if (ag == SrsRtmpJitterAlgorithmOFF) {
return ret; return ret;
} }
// start at zero, but donot ensure monotonically increasing. // start at zero, but donot ensure monotonically increasing.
if (ag == SrsRtmpJitterAlgorithmZERO) { if (ag == SrsRtmpJitterAlgorithmZERO) {
if (last_pkt_correct_time <= 0) { // 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; last_pkt_correct_time = msg->header.timestamp;
} }
msg->header.timestamp -= last_pkt_correct_time; msg->header.timestamp -= last_pkt_correct_time;
return ret; return ret;
} }
// other algorithm, ignore.
return ret;
}
// full jitter algorithm, do jitter correct. // full jitter algorithm, do jitter correct.
// set to 0 for metadata. // 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; msg->header.timestamp = 0;
return ret; return ret;
} }

View file

@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version // current release version
#define VERSION_MAJOR "0" #define VERSION_MAJOR "0"
#define VERSION_MINOR "9" #define VERSION_MINOR "9"
#define VERSION_REVISION "133" #define VERSION_REVISION "134"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info. // server info.
#define RTMP_SIG_SRS_KEY "SRS" #define RTMP_SIG_SRS_KEY "SRS"