fix time jitter zero algorithm bug, reset when timestamp overflow.
正在显示
2 个修改的文件
包含
20 行增加
和
13 行删除
| @@ -69,25 +69,32 @@ int SrsRtmpJitter::correct(SrsSharedPtrMessage* msg, int tba, int tbv, SrsRtmpJi | @@ -69,25 +69,32 @@ int SrsRtmpJitter::correct(SrsSharedPtrMessage* msg, int tba, int tbv, SrsRtmpJi | ||
| 69 | { | 69 | { |
| 70 | int ret = ERROR_SUCCESS; | 70 | int ret = ERROR_SUCCESS; |
| 71 | 71 | ||
| 72 | - // all jitter correct features is disabled, ignore. | ||
| 73 | - if (ag == SrsRtmpJitterAlgorithmOFF) { | ||
| 74 | - return ret; | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - | ||
| 78 | - // start at zero, but donot ensure monotonically increasing. | ||
| 79 | - if (ag == SrsRtmpJitterAlgorithmZERO) { | ||
| 80 | - if (last_pkt_correct_time <= 0) { | ||
| 81 | - last_pkt_correct_time = msg->header.timestamp; | 72 | + // for performance issue |
| 73 | + if (ag != SrsRtmpJitterAlgorithmFULL) { | ||
| 74 | + // all jitter correct features is disabled, ignore. | ||
| 75 | + if (ag == SrsRtmpJitterAlgorithmOFF) { | ||
| 76 | + return ret; | ||
| 82 | } | 77 | } |
| 83 | - msg->header.timestamp -= last_pkt_correct_time; | 78 | + |
| 79 | + // start at zero, but donot ensure monotonically increasing. | ||
| 80 | + if (ag == SrsRtmpJitterAlgorithmZERO) { | ||
| 81 | + // for the first time, last_pkt_correct_time is zero. | ||
| 82 | + // while when timestamp overflow, the timestamp become smaller, reset the last_pkt_correct_time. | ||
| 83 | + if (last_pkt_correct_time <= 0 || last_pkt_correct_time > msg->header.timestamp) { | ||
| 84 | + last_pkt_correct_time = msg->header.timestamp; | ||
| 85 | + } | ||
| 86 | + msg->header.timestamp -= last_pkt_correct_time; | ||
| 87 | + return ret; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + // other algorithm, ignore. | ||
| 84 | return ret; | 91 | return ret; |
| 85 | } | 92 | } |
| 86 | 93 | ||
| 87 | // full jitter algorithm, do jitter correct. | 94 | // full jitter algorithm, do jitter correct. |
| 88 | 95 | ||
| 89 | // set to 0 for metadata. | 96 | // set to 0 for metadata. |
| 90 | - if (!msg->header.is_video() && !msg->header.is_audio()) { | 97 | + if (!msg->header.is_audio() && !msg->header.is_video()) { |
| 91 | msg->header.timestamp = 0; | 98 | msg->header.timestamp = 0; |
| 92 | return ret; | 99 | return ret; |
| 93 | } | 100 | } |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR "0" | 32 | #define VERSION_MAJOR "0" |
| 33 | #define VERSION_MINOR "9" | 33 | #define VERSION_MINOR "9" |
| 34 | -#define VERSION_REVISION "133" | 34 | +#define VERSION_REVISION "134" |
| 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION | 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION |
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
-
请 注册 或 登录 后发表评论