From a46983c2a2da5e92e459262ea71383d14242114e Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Tue, 13 Nov 2012 15:15:08 +0400 Subject: [PATCH] added activity flag to xml; updated xsl to display it; improved live sync handler to have default value and to receive off --- ngx_rtmp_live_module.c | 27 ++++++++++++++++++++++++--- ngx_rtmp_stat_module.c | 9 +++++---- stat.xsl | 32 +++++++++++++++++++++++++++++--- 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/ngx_rtmp_live_module.c b/ngx_rtmp_live_module.c index 66c99e4..ca339ef 100644 --- a/ngx_rtmp_live_module.c +++ b/ngx_rtmp_live_module.c @@ -16,7 +16,9 @@ static ngx_rtmp_close_stream_pt next_close_stream; static ngx_int_t ngx_rtmp_live_postconfiguration(ngx_conf_t *cf); static void * ngx_rtmp_live_create_app_conf(ngx_conf_t *cf); static char * ngx_rtmp_live_merge_app_conf(ngx_conf_t *cf, - void *parent, void *child); + void *parent, void *child); +static char *ngx_rtmp_live_sync(ngx_conf_t *cf, ngx_command_t *cmd, + void *conf); #define NGX_RTMP_LIVE_TIME_ABSOLUTE 0x01 @@ -55,7 +57,7 @@ static ngx_command_t ngx_rtmp_live_commands[] = { { ngx_string("sync"), NGX_RTMP_MAIN_CONF|NGX_RTMP_SRV_CONF|NGX_RTMP_APP_CONF|NGX_CONF_TAKE1, - ngx_conf_set_msec_slot, + ngx_rtmp_live_sync, NGX_RTMP_APP_CONF_OFFSET, offsetof(ngx_rtmp_live_app_conf_t, sync), NULL }, @@ -154,7 +156,7 @@ ngx_rtmp_live_merge_app_conf(ngx_conf_t *cf, void *parent, void *child) ngx_conf_merge_value(conf->meta, prev->meta, 1); ngx_conf_merge_value(conf->nbuckets, prev->nbuckets, 1024); ngx_conf_merge_msec_value(conf->buflen, prev->buflen, 0); - ngx_conf_merge_msec_value(conf->sync, prev->sync, 0); + ngx_conf_merge_msec_value(conf->sync, prev->sync, 300); ngx_conf_merge_value(conf->interleave, prev->interleave, 0); ngx_conf_merge_value(conf->wait_key, prev->wait_key, 0); ngx_conf_merge_value(conf->publish_notify, prev->publish_notify, 0); @@ -172,6 +174,25 @@ ngx_rtmp_live_merge_app_conf(ngx_conf_t *cf, void *parent, void *child) } +static char * +ngx_rtmp_live_sync(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +{ + ngx_rtmp_live_app_conf_t *lacf = conf; + ngx_str_t *value; + + value = cf->args->elts; + + if (value->len == sizeof("off") - 1 && + ngx_strncasecmp(value->data, (u_char *) "off", value->len)) + { + lacf->sync = 0; + return NGX_CONF_OK; + } + + return ngx_conf_set_msec_slot(cf, cmd, conf); +} + + static ngx_rtmp_live_stream_t ** ngx_rtmp_live_get_stream(ngx_rtmp_session_t *s, u_char *name, int create) { diff --git a/ngx_rtmp_stat_module.c b/ngx_rtmp_stat_module.c index 0c633e5..eb8ec5c 100644 --- a/ngx_rtmp_stat_module.c +++ b/ngx_rtmp_stat_module.c @@ -258,7 +258,6 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll, ngx_rtmp_session_t *s; ngx_int_t n; size_t nclients, total_nclients; - ngx_int_t publishing; u_char buf[NGX_OFF_T_LEN + 1]; ngx_rtmp_stat_loc_conf_t *slcf; u_char *cname; @@ -270,7 +269,6 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll, total_nclients = 0; for (n = 0; n < lacf->nbuckets; ++n) { for (stream = lacf->streams[n]; stream; stream = stream->next) { - publishing = 0; NGX_RTMP_STAT_L("\r\n"); NGX_RTMP_STAT_L(""); @@ -346,7 +344,6 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll, NGX_RTMP_STAT_L("\r\n"); } if (ctx->publishing) { - publishing = 1; codec = ngx_rtmp_get_module_ctx(s, ngx_rtmp_codec_module); } } @@ -393,10 +390,14 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll, "%uz", nclients) - buf); NGX_RTMP_STAT_L("\r\n"); - if (publishing) { + if (stream->publishing) { NGX_RTMP_STAT_L("\r\n"); } + if (stream->active) { + NGX_RTMP_STAT_L("\r\n"); + } + NGX_RTMP_STAT_L("\r\n"); } } diff --git a/stat.xsl b/stat.xsl index f744e0a..d4f9147 100644 --- a/stat.xsl +++ b/stat.xsl @@ -105,7 +105,7 @@ - + @@ -157,9 +157,31 @@ + + + active + idle + + + + + + + publishing + playing + + + + - - + + + + #cccccc + #eeeeee + + + @@ -185,6 +207,10 @@ publishing + + active + + /