winlin

merge from srs2.

@@ -928,12 +928,12 @@ vhost with-hls.srs.com { @@ -928,12 +928,12 @@ vhost with-hls.srs.com {
928 # default: 60 928 # default: 60
929 hls_window 60; 929 hls_window 60;
930 # the error strategy. canbe: 930 # the error strategy. canbe:
931 - # ignore, when error ignore and disable hls.  
932 - # disconnect, when error disconnect the publish connection.  
933 - # continue, when error ignore and continue output hls. 931 + # ignore, disable the hls.
  932 + # disconnect, require encoder republish.
  933 + # continue, ignore failed try to continue output hls.
934 # @see https://github.com/ossrs/srs/issues/264 934 # @see https://github.com/ossrs/srs/issues/264
935 - # default: ignore  
936 - hls_on_error ignore; 935 + # default: continue
  936 + hls_on_error continue;
937 # the hls storage: disk, ram or both. 937 # the hls storage: disk, ram or both.
938 # disk, to write hls m3u8/ts to disk. 938 # disk, to write hls m3u8/ts to disk.
939 # ram, serve m3u8/ts in memory, which use embeded http server to delivery. 939 # ram, serve m3u8/ts in memory, which use embeded http server to delivery.
@@ -6002,7 +6002,8 @@ double SrsConfig::get_hls_window(string vhost) @@ -6002,7 +6002,8 @@ double SrsConfig::get_hls_window(string vhost)
6002 6002
6003 string SrsConfig::get_hls_on_error(string vhost) 6003 string SrsConfig::get_hls_on_error(string vhost)
6004 { 6004 {
6005 - static string DEFAULT = "ignore"; 6005 + // try to ignore the error.
  6006 + static string DEFAULT = "continue";
6006 6007
6007 SrsConfDirective* conf = get_hls(vhost); 6008 SrsConfDirective* conf = get_hls(vhost);
6008 if (!conf) { 6009 if (!conf) {
@@ -1770,6 +1770,23 @@ int SrsSource::on_video(SrsCommonMessage* shared_video) @@ -1770,6 +1770,23 @@ int SrsSource::on_video(SrsCommonMessage* shared_video)
1770 return ret; 1770 return ret;
1771 } 1771 }
1772 1772
  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 +
1773 int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) 1790 int SrsSource::on_video_imp(SrsSharedPtrMessage* msg)
1774 { 1791 {
1775 int ret = ERROR_SUCCESS; 1792 int ret = ERROR_SUCCESS;
@@ -1834,7 +1851,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) @@ -1834,7 +1851,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg)
1834 ret = ERROR_SUCCESS; 1851 ret = ERROR_SUCCESS;
1835 } else if (srs_config_hls_is_on_error_continue(hls_error_strategy)) { 1852 } else if (srs_config_hls_is_on_error_continue(hls_error_strategy)) {
1836 // compare the sequence header with video, continue when it's actually an sequence header. 1853 // compare the sequence header with video, continue when it's actually an sequence header.
1837 - if (ret == ERROR_HLS_DECODE_ERROR && cache_sh_video && cache_sh_video->size == msg->size) { 1854 + if (srs_hls_can_continue(ret, cache_sh_video, msg)) {
1838 srs_warn("the video is actually a sequence header, ignore this packet."); 1855 srs_warn("the video is actually a sequence header, ignore this packet.");
1839 ret = ERROR_SUCCESS; 1856 ret = ERROR_SUCCESS;
1840 } else { 1857 } else {