正在显示
1 个修改的文件
包含
19 行增加
和
22 行删除
| @@ -1555,6 +1555,24 @@ int SrsSource::on_audio(SrsCommonMessage* shared_audio) | @@ -1555,6 +1555,24 @@ int SrsSource::on_audio(SrsCommonMessage* shared_audio) | ||
| 1555 | return ret; | 1555 | return ret; |
| 1556 | } | 1556 | } |
| 1557 | 1557 | ||
| 1558 | +bool srs_hls_can_continue(int ret, SrsSharedPtrMessage* sh, SrsSharedPtrMessage* msg) | ||
| 1559 | +{ | ||
| 1560 | + // only continue for decode error. | ||
| 1561 | + if (ret != ERROR_HLS_DECODE_ERROR) { | ||
| 1562 | + return false; | ||
| 1563 | + } | ||
| 1564 | + | ||
| 1565 | + // when video size equals to sequence header, | ||
| 1566 | + // the video actually maybe a sequence header, | ||
| 1567 | + // continue to make ffmpeg happy. | ||
| 1568 | + if (sh && sh->size == msg->size) { | ||
| 1569 | + srs_warn("the msg is actually a sequence header, ignore this packet."); | ||
| 1570 | + return true; | ||
| 1571 | + } | ||
| 1572 | + | ||
| 1573 | + return false; | ||
| 1574 | +} | ||
| 1575 | + | ||
| 1558 | int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg) | 1576 | int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg) |
| 1559 | { | 1577 | { |
| 1560 | int ret = ERROR_SUCCESS; | 1578 | int ret = ERROR_SUCCESS; |
| @@ -1615,9 +1633,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg) | @@ -1615,9 +1633,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg) | ||
| 1615 | // ignore. | 1633 | // ignore. |
| 1616 | ret = ERROR_SUCCESS; | 1634 | ret = ERROR_SUCCESS; |
| 1617 | } else if (srs_config_hls_is_on_error_continue(hls_error_strategy)) { | 1635 | } else if (srs_config_hls_is_on_error_continue(hls_error_strategy)) { |
| 1618 | - // compare the sequence header with audio, continue when it's actually an sequence header. | ||
| 1619 | - if (ret == ERROR_HLS_DECODE_ERROR && cache_sh_audio && cache_sh_audio->size == msg->size) { | ||
| 1620 | - srs_warn("the audio is actually a sequence header, ignore this packet."); | 1636 | + if (srs_hls_can_continue(ret, cache_sh_audio, msg)) { |
| 1621 | ret = ERROR_SUCCESS; | 1637 | ret = ERROR_SUCCESS; |
| 1622 | } else { | 1638 | } else { |
| 1623 | srs_warn("hls continue audio failed. ret=%d", ret); | 1639 | srs_warn("hls continue audio failed. ret=%d", ret); |
| @@ -1770,23 +1786,6 @@ int SrsSource::on_video(SrsCommonMessage* shared_video) | @@ -1770,23 +1786,6 @@ int SrsSource::on_video(SrsCommonMessage* shared_video) | ||
| 1770 | return ret; | 1786 | return ret; |
| 1771 | } | 1787 | } |
| 1772 | 1788 | ||
| 1773 | -bool srs_hls_can_continue(int ret, SrsSharedPtrMessage* sh, SrsSharedPtrMessage* video) | ||
| 1774 | -{ | ||
| 1775 | - // only continue for decode error. | ||
| 1776 | - if (ret != ERROR_HLS_DECODE_ERROR) { | ||
| 1777 | - return false; | ||
| 1778 | - } | ||
| 1779 | - | ||
| 1780 | - // when video size equals to sequence header, | ||
| 1781 | - // the video actually maybe a sequence header, | ||
| 1782 | - // continue to make ffmpeg happy. | ||
| 1783 | - if (sh && sh->size == video->size) { | ||
| 1784 | - return true; | ||
| 1785 | - } | ||
| 1786 | - | ||
| 1787 | - return false; | ||
| 1788 | -} | ||
| 1789 | - | ||
| 1790 | int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) | 1789 | int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) |
| 1791 | { | 1790 | { |
| 1792 | int ret = ERROR_SUCCESS; | 1791 | int ret = ERROR_SUCCESS; |
| @@ -1850,9 +1849,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) | @@ -1850,9 +1849,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) | ||
| 1850 | // ignore. | 1849 | // ignore. |
| 1851 | ret = ERROR_SUCCESS; | 1850 | ret = ERROR_SUCCESS; |
| 1852 | } else if (srs_config_hls_is_on_error_continue(hls_error_strategy)) { | 1851 | } else if (srs_config_hls_is_on_error_continue(hls_error_strategy)) { |
| 1853 | - // compare the sequence header with video, continue when it's actually an sequence header. | ||
| 1854 | if (srs_hls_can_continue(ret, cache_sh_video, msg)) { | 1852 | if (srs_hls_can_continue(ret, cache_sh_video, msg)) { |
| 1855 | - srs_warn("the video is actually a sequence header, ignore this packet."); | ||
| 1856 | ret = ERROR_SUCCESS; | 1853 | ret = ERROR_SUCCESS; |
| 1857 | } else { | 1854 | } else { |
| 1858 | srs_warn("hls continue video failed. ret=%d", ret); | 1855 | srs_warn("hls continue video failed. ret=%d", ret); |
-
请 注册 或 登录 后发表评论