mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
fix #264, support disconnect publish connect when hls error. 1.0.11
This commit is contained in:
parent
d4fb58b175
commit
1dfac0bf1d
6 changed files with 71 additions and 20 deletions
6
trunk/conf/full.conf
Normal file → Executable file
6
trunk/conf/full.conf
Normal file → Executable file
|
@ -295,6 +295,12 @@ vhost with-hls.srs.com {
|
||||||
# the hls window in seconds, the number of ts in m3u8.
|
# the hls window in seconds, the number of ts in m3u8.
|
||||||
# default: 60
|
# default: 60
|
||||||
hls_window 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.
|
# the vhost with hls disabled.
|
||||||
|
|
|
@ -797,6 +797,7 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root)
|
||||||
srs_trace("vhost %s reload forward success.", vhost.c_str());
|
srs_trace("vhost %s reload forward success.", vhost.c_str());
|
||||||
}
|
}
|
||||||
// hls, only one per vhost
|
// 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"))) {
|
if (!srs_directive_equals(new_vhost->get("hls"), old_vhost->get("hls"))) {
|
||||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||||
ISrsReloadHandler* subscribe = *it;
|
ISrsReloadHandler* subscribe = *it;
|
||||||
|
@ -1356,7 +1357,7 @@ int SrsConfig::check_config()
|
||||||
} else if (n == "hls") {
|
} else if (n == "hls") {
|
||||||
for (int j = 0; j < (int)conf->directives.size(); j++) {
|
for (int j = 0; j < (int)conf->directives.size(); j++) {
|
||||||
string m = conf->at(j)->name.c_str();
|
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;
|
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
||||||
srs_error("unsupported vhost hls directive %s, ret=%d", m.c_str(), ret);
|
srs_error("unsupported vhost hls directive %s, ret=%d", m.c_str(), ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2910,6 +2911,23 @@ double SrsConfig::get_hls_window(string vhost)
|
||||||
return ::atof(conf->arg0().c_str());
|
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* SrsConfig::get_dvr(string vhost)
|
||||||
{
|
{
|
||||||
SrsConfDirective* conf = get_vhost(vhost);
|
SrsConfDirective* conf = get_vhost(vhost);
|
||||||
|
|
|
@ -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_PATH "./objs/nginx/html"
|
||||||
#define SRS_CONF_DEFAULT_HLS_FRAGMENT 10
|
#define SRS_CONF_DEFAULT_HLS_FRAGMENT 10
|
||||||
#define SRS_CONF_DEFAULT_HLS_WINDOW 60
|
#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_PATH "./objs/nginx/html"
|
||||||
#define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session"
|
#define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session"
|
||||||
#define SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT "segment"
|
#define SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT "segment"
|
||||||
|
@ -826,6 +829,13 @@ public:
|
||||||
* @remark SRS will delete the ts exceed the window.
|
* @remark SRS will delete the ts exceed the window.
|
||||||
*/
|
*/
|
||||||
virtual double get_hls_window(std::string vhost);
|
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
|
// dvr section
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1435,10 +1435,11 @@ int SrsHls::on_audio(SrsSharedPtrMessage* audio)
|
||||||
if (!hls_enabled) {
|
if (!hls_enabled) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
|
|
||||||
sample->clear();
|
sample->clear();
|
||||||
if ((ret = codec->audio_aac_demux(audio->payload, audio->size, sample)) != ERROR_SUCCESS) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1482,7 +1483,7 @@ int SrsHls::on_video(SrsSharedPtrMessage* video)
|
||||||
|
|
||||||
sample->clear();
|
sample->clear();
|
||||||
if ((ret = codec->video_avc_demux(video->payload, video->size, sample)) != ERROR_SUCCESS) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1056,6 +1056,10 @@ int SrsSource::on_audio(SrsMessage* __audio)
|
||||||
|
|
||||||
#ifdef SRS_AUTO_HLS
|
#ifdef SRS_AUTO_HLS
|
||||||
if ((ret = hls->on_audio(msg.copy())) != ERROR_SUCCESS) {
|
if ((ret = hls->on_audio(msg.copy())) != 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);
|
srs_warn("hls process audio message failed, ignore and disable hls. ret=%d", ret);
|
||||||
|
|
||||||
// unpublish, ignore ret.
|
// unpublish, ignore ret.
|
||||||
|
@ -1063,6 +1067,10 @@ int SrsSource::on_audio(SrsMessage* __audio)
|
||||||
|
|
||||||
// ignore.
|
// ignore.
|
||||||
ret = ERROR_SUCCESS;
|
ret = ERROR_SUCCESS;
|
||||||
|
} else {
|
||||||
|
srs_warn("hls disconnect publisher for audio error. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1113,7 +1121,7 @@ int SrsSource::on_audio(SrsMessage* __audio)
|
||||||
SrsAvcAacCodec codec;
|
SrsAvcAacCodec codec;
|
||||||
SrsCodecSample sample;
|
SrsCodecSample sample;
|
||||||
if ((ret = codec.audio_aac_demux(msg.payload, msg.size, &sample)) != ERROR_SUCCESS) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1165,6 +1173,10 @@ int SrsSource::on_video(SrsMessage* __video)
|
||||||
|
|
||||||
#ifdef SRS_AUTO_HLS
|
#ifdef SRS_AUTO_HLS
|
||||||
if ((ret = hls->on_video(msg.copy())) != ERROR_SUCCESS) {
|
if ((ret = hls->on_video(msg.copy())) != 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);
|
srs_warn("hls process video message failed, ignore and disable hls. ret=%d", ret);
|
||||||
|
|
||||||
// unpublish, ignore ret.
|
// unpublish, ignore ret.
|
||||||
|
@ -1172,6 +1184,10 @@ int SrsSource::on_video(SrsMessage* __video)
|
||||||
|
|
||||||
// ignore.
|
// ignore.
|
||||||
ret = ERROR_SUCCESS;
|
ret = ERROR_SUCCESS;
|
||||||
|
} else {
|
||||||
|
srs_warn("hls disconnect publisher for video error. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1222,7 +1238,7 @@ int SrsSource::on_video(SrsMessage* __video)
|
||||||
SrsAvcAacCodec codec;
|
SrsAvcAacCodec codec;
|
||||||
SrsCodecSample sample;
|
SrsCodecSample sample;
|
||||||
if ((ret = codec.video_avc_demux(msg.payload, msg.size, &sample)) != ERROR_SUCCESS) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 10
|
#define VERSION_REVISION 11
|
||||||
// server info.
|
// server info.
|
||||||
#define RTMP_SIG_SRS_KEY "SRS"
|
#define RTMP_SIG_SRS_KEY "SRS"
|
||||||
#define RTMP_SIG_SRS_ROLE "origin/edge server"
|
#define RTMP_SIG_SRS_ROLE "origin/edge server"
|
||||||
|
|
Loading…
Reference in a new issue