From e5d61f2c62b7303c4708bcce78984b7e5105b92c Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Tue, 9 Oct 2012 18:22:14 +0400 Subject: [PATCH] added 'busy' directive --- ngx_rtmp.h | 1 + ngx_rtmp_core_module.c | 9 +++++++++ ngx_rtmp_handler.c | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/ngx_rtmp.h b/ngx_rtmp.h index aa7432a..7d9c7f3 100644 --- a/ngx_rtmp.h +++ b/ngx_rtmp.h @@ -287,6 +287,7 @@ typedef struct ngx_rtmp_core_srv_conf_s { size_t max_message; ngx_flag_t play_time_fix; ngx_flag_t publish_time_fix; + ngx_flag_t busy; size_t out_queue; size_t out_cork; diff --git a/ngx_rtmp_core_module.c b/ngx_rtmp_core_module.c index eac72a7..e300e8b 100644 --- a/ngx_rtmp_core_module.c +++ b/ngx_rtmp_core_module.c @@ -127,6 +127,13 @@ static ngx_command_t ngx_rtmp_core_commands[] = { offsetof(ngx_rtmp_core_srv_conf_t, out_cork), NULL }, + { ngx_string("busy"), + NGX_RTMP_MAIN_CONF|NGX_RTMP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_flag_slot, + NGX_RTMP_SRV_CONF_OFFSET, + offsetof(ngx_rtmp_core_srv_conf_t, busy), + NULL }, + /* time fixes are needed for flash clients */ { ngx_string("play_time_fix"), NGX_RTMP_MAIN_CONF|NGX_RTMP_SRV_CONF|NGX_RTMP_APP_CONF|NGX_CONF_TAKE1, @@ -232,6 +239,7 @@ ngx_rtmp_core_create_srv_conf(ngx_conf_t *cf) conf->out_cork = NGX_CONF_UNSET; conf->play_time_fix = NGX_CONF_UNSET; conf->publish_time_fix = NGX_CONF_UNSET; + conf->busy = NGX_CONF_UNSET; return conf; } @@ -258,6 +266,7 @@ ngx_rtmp_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) conf->out_queue / 8); ngx_conf_merge_value(conf->play_time_fix, prev->play_time_fix, 1); ngx_conf_merge_value(conf->publish_time_fix, prev->publish_time_fix, 1); + ngx_conf_merge_value(conf->busy, prev->busy, 0); if (prev->pool == NULL) { prev->pool = ngx_create_pool(4096, &cf->cycle->new_log); diff --git a/ngx_rtmp_handler.c b/ngx_rtmp_handler.c index 79465f7..f0a0c83 100644 --- a/ngx_rtmp_handler.c +++ b/ngx_rtmp_handler.c @@ -164,6 +164,13 @@ ngx_rtmp_ping(ngx_event_t *pev) return; } + if (cscf->busy) { + ngx_log_error(NGX_LOG_INFO, c->log, 0, + "ping: not busy between pings"); + ngx_rtmp_finalize_session(s); + return; + } + ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, "ping: schedule %Mms", cscf->ping_timeout);