detect the monotonically increase and warn to use mix_correct
正在显示
2 个修改的文件
包含
28 行增加
和
0 行删除
@@ -900,6 +900,9 @@ SrsSource::SrsSource() | @@ -900,6 +900,9 @@ SrsSource::SrsSource() | ||
900 | gop_cache = new SrsGopCache(); | 900 | gop_cache = new SrsGopCache(); |
901 | aggregate_stream = new SrsStream(); | 901 | aggregate_stream = new SrsStream(); |
902 | 902 | ||
903 | + is_monotonically_increase = false; | ||
904 | + last_packet_time = 0; | ||
905 | + | ||
903 | _srs_config->subscribe(this); | 906 | _srs_config->subscribe(this); |
904 | atc = false; | 907 | atc = false; |
905 | } | 908 | } |
@@ -1467,6 +1470,15 @@ int SrsSource::on_audio(SrsCommonMessage* shared_audio) | @@ -1467,6 +1470,15 @@ int SrsSource::on_audio(SrsCommonMessage* shared_audio) | ||
1467 | { | 1470 | { |
1468 | int ret = ERROR_SUCCESS; | 1471 | int ret = ERROR_SUCCESS; |
1469 | 1472 | ||
1473 | + // monotically increase detect. | ||
1474 | + if (!mix_correct && is_monotonically_increase) { | ||
1475 | + if (last_packet_time > 0 && shared_audio->header.timestamp < last_packet_time) { | ||
1476 | + is_monotonically_increase = false; | ||
1477 | + srs_warn("stream not monotonically increase, please open mix_correct."); | ||
1478 | + } | ||
1479 | + } | ||
1480 | + last_packet_time = shared_audio->header.timestamp; | ||
1481 | + | ||
1470 | // convert shared_audio to msg, user should not use shared_audio again. | 1482 | // convert shared_audio to msg, user should not use shared_audio again. |
1471 | // the payload is transfer to msg, and set to NULL in shared_audio. | 1483 | // the payload is transfer to msg, and set to NULL in shared_audio. |
1472 | SrsSharedPtrMessage msg; | 1484 | SrsSharedPtrMessage msg; |
@@ -1649,6 +1661,15 @@ int SrsSource::on_video(SrsCommonMessage* shared_video) | @@ -1649,6 +1661,15 @@ int SrsSource::on_video(SrsCommonMessage* shared_video) | ||
1649 | { | 1661 | { |
1650 | int ret = ERROR_SUCCESS; | 1662 | int ret = ERROR_SUCCESS; |
1651 | 1663 | ||
1664 | + // monotically increase detect. | ||
1665 | + if (!mix_correct && is_monotonically_increase) { | ||
1666 | + if (last_packet_time > 0 && shared_video->header.timestamp < last_packet_time) { | ||
1667 | + is_monotonically_increase = false; | ||
1668 | + srs_warn("stream not monotonically increase, please open mix_correct."); | ||
1669 | + } | ||
1670 | + } | ||
1671 | + last_packet_time = shared_video->header.timestamp; | ||
1672 | + | ||
1652 | // drop any unknown header video. | 1673 | // drop any unknown header video. |
1653 | // @see https://github.com/simple-rtmp-server/srs/issues/421 | 1674 | // @see https://github.com/simple-rtmp-server/srs/issues/421 |
1654 | if (!SrsFlvCodec::video_is_acceptable(shared_video->payload, shared_video->size)) { | 1675 | if (!SrsFlvCodec::video_is_acceptable(shared_video->payload, shared_video->size)) { |
@@ -1970,6 +1991,10 @@ int SrsSource::on_publish() | @@ -1970,6 +1991,10 @@ int SrsSource::on_publish() | ||
1970 | // reset the mix queue. | 1991 | // reset the mix queue. |
1971 | mix_queue->clear(); | 1992 | mix_queue->clear(); |
1972 | 1993 | ||
1994 | + // detect the monotonically again. | ||
1995 | + is_monotonically_increase = true; | ||
1996 | + last_packet_time = 0; | ||
1997 | + | ||
1973 | // create forwarders | 1998 | // create forwarders |
1974 | if ((ret = create_forwarders()) != ERROR_SUCCESS) { | 1999 | if ((ret = create_forwarders()) != ERROR_SUCCESS) { |
1975 | srs_error("create forwarders failed. ret=%d", ret); | 2000 | srs_error("create forwarders failed. ret=%d", ret); |
@@ -437,6 +437,9 @@ private: | @@ -437,6 +437,9 @@ private: | ||
437 | // whether use interlaced/mixed algorithm to correct timestamp. | 437 | // whether use interlaced/mixed algorithm to correct timestamp. |
438 | bool mix_correct; | 438 | bool mix_correct; |
439 | SrsMixQueue* mix_queue; | 439 | SrsMixQueue* mix_queue; |
440 | + // whether stream is monotonically increase. | ||
441 | + bool is_monotonically_increase; | ||
442 | + int64_t last_packet_time; | ||
440 | // hls handler. | 443 | // hls handler. |
441 | #ifdef SRS_AUTO_HLS | 444 | #ifdef SRS_AUTO_HLS |
442 | SrsHls* hls; | 445 | SrsHls* hls; |
-
请 注册 或 登录 后发表评论