Skip to content

Commit

Permalink
[fix] fix a JSON stat bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
winshining committed Mar 14, 2019
1 parent 3054375 commit 6096945
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions ngx_rtmp_stat_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,6 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
ngx_int_t n;
ngx_uint_t nclients, total_nclients;
ngx_uint_t f;
ngx_flag_t prev;
u_char buf[NGX_INT_T_LEN];
u_char bbuf[NGX_INT32_LEN];
ngx_rtmp_stat_loc_conf_t *slcf;
Expand All @@ -528,16 +527,11 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,

total_nclients = 0;
for (n = 0; n < lacf->nbuckets; ++n) {
prev = 0;
if (n && lacf->streams[n - 1]) {
prev = 1;
}

for (stream = lacf->streams[n]; stream; stream = stream->next) {
if (slcf->format & NGX_RTMP_STAT_FORMAT_XML) {
NGX_RTMP_STAT_L("<stream>\r\n");
} else {
if (prev || stream->next) {
if (total_nclients || stream->next) {
NGX_RTMP_STAT_L(",");
}

Expand Down Expand Up @@ -897,7 +891,6 @@ ngx_rtmp_stat_play(ngx_http_request_t *r, ngx_chain_t ***lll,
ngx_rtmp_play_ctx_t *ctx, *sctx;
ngx_rtmp_session_t *s;
ngx_uint_t n, nclients, total_nclients;
ngx_flag_t prev;
u_char buf[NGX_INT_T_LEN];
u_char bbuf[NGX_INT32_LEN];
ngx_rtmp_stat_loc_conf_t *slcf;
Expand All @@ -917,19 +910,14 @@ ngx_rtmp_stat_play(ngx_http_request_t *r, ngx_chain_t ***lll,

total_nclients = 0;
for (n = 0; n < pacf->nbuckets; ++n) {
prev = 0;
if (n && pacf->ctx[n - 1]) {
prev = 1;
}

for (ctx = pacf->ctx[n]; ctx; ) {
if (slcf->format & NGX_RTMP_STAT_FORMAT_XML) {
NGX_RTMP_STAT_L("<stream>\r\n");
NGX_RTMP_STAT_L("<name>");
NGX_RTMP_STAT_ECS(ctx->name);
NGX_RTMP_STAT_L("</name>\r\n");
} else {
if (prev || ctx->next) {
if (total_nclients || ctx->next) {
NGX_RTMP_STAT_L(",");
}

Expand Down

0 comments on commit 6096945

Please sign in to comment.