winlin

fix #264, ignore the video NALU which is actually a sequence header to make HLS happy. 1.0.12

@@ -298,6 +298,7 @@ vhost with-hls.srs.com { @@ -298,6 +298,7 @@ vhost with-hls.srs.com {
298 # the error strategy. canbe: 298 # the error strategy. canbe:
299 # ignore, when error ignore and disable hls. 299 # ignore, when error ignore and disable hls.
300 # disconnect, when error disconnect the publish connection. 300 # disconnect, when error disconnect the publish connection.
  301 + # continue, when error ignore and continue output hls.
301 # @see https://github.com/winlinvip/simple-rtmp-server/issues/264 302 # @see https://github.com/winlinvip/simple-rtmp-server/issues/264
302 # default: ignore 303 # default: ignore
303 hls_on_error ignore; 304 hls_on_error ignore;
@@ -50,6 +50,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -50,6 +50,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50 #define SRS_CONF_DEFAULT_HLS_WINDOW 60 50 #define SRS_CONF_DEFAULT_HLS_WINDOW 60
51 #define SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE "ignore" 51 #define SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE "ignore"
52 #define SRS_CONF_DEFAULT_HLS_ON_ERROR_DISCONNECT "disconnect" 52 #define SRS_CONF_DEFAULT_HLS_ON_ERROR_DISCONNECT "disconnect"
  53 +#define SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE "continue"
53 #define SRS_CONF_DEFAULT_HLS_ON_ERROR SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE 54 #define SRS_CONF_DEFAULT_HLS_ON_ERROR SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE
54 #define SRS_CONF_DEFAULT_DVR_PATH "./objs/nginx/html" 55 #define SRS_CONF_DEFAULT_DVR_PATH "./objs/nginx/html"
55 #define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session" 56 #define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session"
@@ -1067,6 +1067,15 @@ int SrsSource::on_audio(SrsMessage* __audio) @@ -1067,6 +1067,15 @@ int SrsSource::on_audio(SrsMessage* __audio)
1067 1067
1068 // ignore. 1068 // ignore.
1069 ret = ERROR_SUCCESS; 1069 ret = ERROR_SUCCESS;
  1070 + } else if (hls_error_strategy == SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE) {
  1071 + // compare the sequence header with audio, continue when it's actually an sequence header.
  1072 + if (ret == ERROR_HLS_DECODE_ERROR && cache_sh_audio && cache_sh_audio->size == msg.size) {
  1073 + srs_warn("the audio is actually a sequence header, ignore this packet.");
  1074 + ret = ERROR_SUCCESS;
  1075 + } else {
  1076 + srs_warn("hls continue audio failed. ret=%d", ret);
  1077 + return ret;
  1078 + }
1070 } else { 1079 } else {
1071 srs_warn("hls disconnect publisher for audio error. ret=%d", ret); 1080 srs_warn("hls disconnect publisher for audio error. ret=%d", ret);
1072 return ret; 1081 return ret;
@@ -1184,6 +1193,15 @@ int SrsSource::on_video(SrsMessage* __video) @@ -1184,6 +1193,15 @@ int SrsSource::on_video(SrsMessage* __video)
1184 1193
1185 // ignore. 1194 // ignore.
1186 ret = ERROR_SUCCESS; 1195 ret = ERROR_SUCCESS;
  1196 + } else if (hls_error_strategy == SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE) {
  1197 + // compare the sequence header with video, continue when it's actually an sequence header.
  1198 + if (ret == ERROR_HLS_DECODE_ERROR && cache_sh_video && cache_sh_video->size == msg.size) {
  1199 + srs_warn("the video is actually a sequence header, ignore this packet.");
  1200 + ret = ERROR_SUCCESS;
  1201 + } else {
  1202 + srs_warn("hls continue video failed. ret=%d", ret);
  1203 + return ret;
  1204 + }
1187 } else { 1205 } else {
1188 srs_warn("hls disconnect publisher for video error. ret=%d", ret); 1206 srs_warn("hls disconnect publisher for video error. ret=%d", ret);
1189 return ret; 1207 return ret;
@@ -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 1 32 #define VERSION_MAJOR 1
33 #define VERSION_MINOR 0 33 #define VERSION_MINOR 0
34 -#define VERSION_REVISION 11 34 +#define VERSION_REVISION 12
35 // server info. 35 // server info.
36 #define RTMP_SIG_SRS_KEY "SRS" 36 #define RTMP_SIG_SRS_KEY "SRS"
37 #define RTMP_SIG_SRS_ROLE "origin/edge server" 37 #define RTMP_SIG_SRS_ROLE "origin/edge server"