From d4fb58b175a7d3f4324fac40cc70c003004fd97c Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 19 Dec 2014 22:02:12 +0800 Subject: [PATCH 1/3] update donation, refer to nginx http://nginx.org/en/donation.html --- DONATIONS.txt | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/DONATIONS.txt b/DONATIONS.txt index 6a350d929..271c0f9fe 100644 --- a/DONATIONS.txt +++ b/DONATIONS.txt @@ -1,17 +1,30 @@ Donations ordered by first donation. -* [2014-04-25 13:21] 刘连响 刘连响(492827340) -* [2014-04-25 13:25] 张瑞圣 大圣(5839109) -* [2014-04-25 13:31] 郭强 寒一冰(63395865) -* [2014-05-12 10:22] 陈晨 陈晨(undeadalpha@gmail.com) -* [2014-06-17 17:57] 陈江兵 将兵(176340267) -* [2014-07-24 08:52] 黄英才 贝奇小天狼星(303441547) -* [2014-07-30 11:29] 周凯 子陵(93632886) -* [2014-08-04 10:47] 宋志 胖胖(37210101) -* [2014-08-07 22:56] 陈亮 陈亮 -* [2014-08-15 10:55] 雷健 万山奔一溪(76411408) -* [2014-08-15 13:31] ZACH ZACH(18601653557) -* [2014-08-19 20:00] Matthew Matthew(1206651693) -* [2014-08-20 20:13] 林瑞潮 甲子(459505921) -* [2014-09-05 16:13] 于冰 秋雨☆ice(3373749) +=========================================================== +2014 + +RMB 1000+ +* [2014-04-25 13:21] 刘连响 +* [2014-04-25 13:31] 郭强 +* [2014-07-30 11:29] 周凯 +* [2014-08-15 10:55] 雷健 + +RMB 500-999 +* [2014-07-24 08:52] 黄英才 + +RMB 100-499 +* [2014-04-25 13:25] 张瑞圣 +* [2014-05-12 10:22] 陈晨 +* [2014-08-07 22:56] 陈亮 +* [2014-08-19 20:00] Matthew +* [2014-09-05 16:13] 于冰 +* [2014-11-19 22:38] 夏江龙 + +RMB 50-99 +* [2014-06-17 17:57] 陈江兵 +* [2014-08-04 10:47] 宋志 +* [2014-08-15 13:31] ZACH + +RMB 0.01-49 +* [2014-08-20 20:13] 林瑞潮 From 1dfac0bf1df45a2a622c77169808df9c0f1c297a Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 20 Dec 2014 11:45:59 +0800 Subject: [PATCH 2/3] fix #264, support disconnect publish connect when hls error. 1.0.11 --- trunk/conf/full.conf | 6 ++++ trunk/src/app/srs_app_config.cpp | 20 ++++++++++++- trunk/src/app/srs_app_config.hpp | 10 +++++++ trunk/src/app/srs_app_hls.cpp | 5 ++-- trunk/src/app/srs_app_source.cpp | 48 +++++++++++++++++++++----------- trunk/src/core/srs_core.hpp | 2 +- 6 files changed, 71 insertions(+), 20 deletions(-) mode change 100644 => 100755 trunk/conf/full.conf diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf old mode 100644 new mode 100755 index 61c8b3d49..29084ecc1 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -295,6 +295,12 @@ vhost with-hls.srs.com { # the hls window in seconds, the number of ts in m3u8. # default: 60 hls_window 60; + # the error strategy. canbe: + # ignore, when error ignore and disable hls. + # disconnect, when error disconnect the publish connection. + # @see https://github.com/winlinvip/simple-rtmp-server/issues/264 + # default: ignore + hls_on_error ignore; } } # the vhost with hls disabled. diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 904d2cb39..2372b6988 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -797,6 +797,7 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) srs_trace("vhost %s reload forward success.", vhost.c_str()); } // hls, only one per vhost + // @remark, the hls_on_error directly support reload. if (!srs_directive_equals(new_vhost->get("hls"), old_vhost->get("hls"))) { for (it = subscribes.begin(); it != subscribes.end(); ++it) { ISrsReloadHandler* subscribe = *it; @@ -1356,7 +1357,7 @@ int SrsConfig::check_config() } else if (n == "hls") { for (int j = 0; j < (int)conf->directives.size(); j++) { string m = conf->at(j)->name.c_str(); - if (m != "enabled" && m != "hls_path" && m != "hls_fragment" && m != "hls_window") { + if (m != "enabled" && m != "hls_path" && m != "hls_fragment" && m != "hls_window" && m != "hls_on_error") { ret = ERROR_SYSTEM_CONFIG_INVALID; srs_error("unsupported vhost hls directive %s, ret=%d", m.c_str(), ret); return ret; @@ -2910,6 +2911,23 @@ double SrsConfig::get_hls_window(string vhost) return ::atof(conf->arg0().c_str()); } +string SrsConfig::get_hls_on_error(string vhost) +{ + SrsConfDirective* hls = get_hls(vhost); + + if (!hls) { + return SRS_CONF_DEFAULT_HLS_ON_ERROR; + } + + SrsConfDirective* conf = hls->get("hls_on_error"); + + if (!conf) { + return SRS_CONF_DEFAULT_HLS_ON_ERROR; + } + + return conf->arg0(); +} + SrsConfDirective* SrsConfig::get_dvr(string vhost) { SrsConfDirective* conf = get_vhost(vhost); diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 675036e2f..0df1bdd48 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -48,6 +48,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html" #define SRS_CONF_DEFAULT_HLS_FRAGMENT 10 #define SRS_CONF_DEFAULT_HLS_WINDOW 60 +#define SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE "ignore" +#define SRS_CONF_DEFAULT_HLS_ON_ERROR_DISCONNECT "disconnect" +#define SRS_CONF_DEFAULT_HLS_ON_ERROR SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE #define SRS_CONF_DEFAULT_DVR_PATH "./objs/nginx/html" #define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session" #define SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT "segment" @@ -826,6 +829,13 @@ public: * @remark SRS will delete the ts exceed the window. */ virtual double get_hls_window(std::string vhost); + /** + * get the hls hls_on_error config. + * the ignore will ignore error and disable hls. + * the disconnect will disconnect publish connection. + * @see https://github.com/winlinvip/simple-rtmp-server/issues/264 + */ + virtual std::string get_hls_on_error(std::string vhost); // dvr section private: /** diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index 8cd71c8e1..ea1271c2d 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -1435,10 +1435,11 @@ int SrsHls::on_audio(SrsSharedPtrMessage* audio) if (!hls_enabled) { return ret; } +return 1; sample->clear(); if ((ret = codec->audio_aac_demux(audio->payload, audio->size, sample)) != ERROR_SUCCESS) { - srs_error("codec demux audio failed. ret=%d", ret); + srs_error("hls codec demux audio failed. ret=%d", ret); return ret; } @@ -1482,7 +1483,7 @@ int SrsHls::on_video(SrsSharedPtrMessage* video) sample->clear(); if ((ret = codec->video_avc_demux(video->payload, video->size, sample)) != ERROR_SUCCESS) { - srs_error("codec demux video failed. ret=%d", ret); + srs_error("hls codec demux video failed. ret=%d", ret); return ret; } diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index aab8a9513..a9a66a36d 100644 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1056,13 +1056,21 @@ int SrsSource::on_audio(SrsMessage* __audio) #ifdef SRS_AUTO_HLS if ((ret = hls->on_audio(msg.copy())) != ERROR_SUCCESS) { - srs_warn("hls process audio message failed, ignore and disable hls. ret=%d", ret); - - // unpublish, ignore ret. - hls->on_unpublish(); - - // ignore. - ret = ERROR_SUCCESS; + // apply the error strategy for hls. + // @see https://github.com/winlinvip/simple-rtmp-server/issues/264 + std::string hls_error_strategy = _srs_config->get_hls_on_error(_req->vhost); + if (hls_error_strategy == SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE) { + srs_warn("hls process audio message failed, ignore and disable hls. ret=%d", ret); + + // unpublish, ignore ret. + hls->on_unpublish(); + + // ignore. + ret = ERROR_SUCCESS; + } else { + srs_warn("hls disconnect publisher for audio error. ret=%d", ret); + return ret; + } } #endif @@ -1113,7 +1121,7 @@ int SrsSource::on_audio(SrsMessage* __audio) SrsAvcAacCodec codec; SrsCodecSample sample; if ((ret = codec.audio_aac_demux(msg.payload, msg.size, &sample)) != ERROR_SUCCESS) { - srs_error("codec demux audio failed. ret=%d", ret); + srs_error("source codec demux audio failed. ret=%d", ret); return ret; } @@ -1165,13 +1173,21 @@ int SrsSource::on_video(SrsMessage* __video) #ifdef SRS_AUTO_HLS if ((ret = hls->on_video(msg.copy())) != ERROR_SUCCESS) { - srs_warn("hls process video message failed, ignore and disable hls. ret=%d", ret); - - // unpublish, ignore ret. - hls->on_unpublish(); - - // ignore. - ret = ERROR_SUCCESS; + // apply the error strategy for hls. + // @see https://github.com/winlinvip/simple-rtmp-server/issues/264 + std::string hls_error_strategy = _srs_config->get_hls_on_error(_req->vhost); + if (hls_error_strategy == SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE) { + srs_warn("hls process video message failed, ignore and disable hls. ret=%d", ret); + + // unpublish, ignore ret. + hls->on_unpublish(); + + // ignore. + ret = ERROR_SUCCESS; + } else { + srs_warn("hls disconnect publisher for video error. ret=%d", ret); + return ret; + } } #endif @@ -1222,7 +1238,7 @@ int SrsSource::on_video(SrsMessage* __video) SrsAvcAacCodec codec; SrsCodecSample sample; if ((ret = codec.video_avc_demux(msg.payload, msg.size, &sample)) != ERROR_SUCCESS) { - srs_error("codec demux video failed. ret=%d", ret); + srs_error("source codec demux video failed. ret=%d", ret); return ret; } diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index d20fb6a99..a9d605215 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 1 #define VERSION_MINOR 0 -#define VERSION_REVISION 10 +#define VERSION_REVISION 11 // server info. #define RTMP_SIG_SRS_KEY "SRS" #define RTMP_SIG_SRS_ROLE "origin/edge server" From 773704279574005341325b8745dac379a5ca6aa1 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 20 Dec 2014 11:56:16 +0800 Subject: [PATCH 3/3] fix #264, remove the test code. 1.0.11 --- trunk/src/app/srs_app_hls.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index ea1271c2d..34d9eb446 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -1435,7 +1435,6 @@ int SrsHls::on_audio(SrsSharedPtrMessage* audio) if (!hls_enabled) { return ret; } -return 1; sample->clear(); if ((ret = codec->audio_aac_demux(audio->payload, audio->size, sample)) != ERROR_SUCCESS) {