@@ -504,9 +504,9 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
504504 ngx_rtmp_live_ctx_t * ctx ;
505505 ngx_rtmp_session_t * s ;
506506 ngx_int_t n ;
507- ngx_uint_t m ;
508507 ngx_uint_t nclients , total_nclients ;
509508 ngx_uint_t f ;
509+ ngx_flag_t prev ;
510510 u_char buf [NGX_INT_T_LEN ];
511511 u_char bbuf [NGX_INT32_LEN ];
512512 ngx_rtmp_stat_loc_conf_t * slcf ;
@@ -527,18 +527,19 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
527527
528528 total_nclients = 0 ;
529529 for (n = 0 ; n < lacf -> nbuckets ; ++ n ) {
530- m = 0 ;
531- if (n > 0 && lacf -> streams [n - 1 ]) {
532- m = 1 ;
530+ prev = 0 ;
531+ if (n && lacf -> streams [n - 1 ]) {
532+ prev = 1 ;
533533 }
534+
534535 for (stream = lacf -> streams [n ]; stream ; stream = stream -> next ) {
535-
536536 if (slcf -> format & NGX_RTMP_STAT_FORMAT_XML ) {
537537 NGX_RTMP_STAT_L ("<stream>\r\n" );
538538 } else {
539- if (m == 1 || stream -> next != NULL ) {
539+ if (prev || stream -> next ) {
540540 NGX_RTMP_STAT_L ("," );
541541 }
542+
542543 NGX_RTMP_STAT_L ("{" );
543544 }
544545
@@ -895,7 +896,8 @@ ngx_rtmp_stat_play(ngx_http_request_t *r, ngx_chain_t ***lll,
895896{
896897 ngx_rtmp_play_ctx_t * ctx , * sctx ;
897898 ngx_rtmp_session_t * s ;
898- ngx_uint_t m , n , nclients , total_nclients ;
899+ ngx_uint_t n , nclients , total_nclients ;
900+ ngx_flag_t prev ;
899901 u_char buf [NGX_INT_T_LEN ];
900902 u_char bbuf [NGX_INT32_LEN ];
901903 ngx_rtmp_stat_loc_conf_t * slcf ;
@@ -915,21 +917,22 @@ ngx_rtmp_stat_play(ngx_http_request_t *r, ngx_chain_t ***lll,
915917
916918 total_nclients = 0 ;
917919 for (n = 0 ; n < pacf -> nbuckets ; ++ n ) {
918- m = 0 ;
919- if (n > 0 && pacf -> ctx [n - 1 ]) {
920- m = 1 ;
920+ prev = 0 ;
921+ if (n && pacf -> ctx [n - 1 ]) {
922+ prev = 1 ;
921923 }
924+
922925 for (ctx = pacf -> ctx [n ]; ctx ; ) {
923-
924926 if (slcf -> format & NGX_RTMP_STAT_FORMAT_XML ) {
925927 NGX_RTMP_STAT_L ("<stream>\r\n" );
926928 NGX_RTMP_STAT_L ("<name>" );
927929 NGX_RTMP_STAT_ECS (ctx -> name );
928930 NGX_RTMP_STAT_L ("</name>\r\n" );
929931 } else {
930- if (m == 1 || ctx -> next != NULL ) {
932+ if (prev || ctx -> next ) {
931933 NGX_RTMP_STAT_L ("," );
932934 }
935+
933936 NGX_RTMP_STAT_L ("{\"name\":\"" );
934937 NGX_RTMP_STAT_ECS (ctx -> name );
935938 NGX_RTMP_STAT_L ("\",\"clients\":[" );
@@ -938,7 +941,6 @@ ngx_rtmp_stat_play(ngx_http_request_t *r, ngx_chain_t ***lll,
938941 nclients = 0 ;
939942 sctx = ctx ;
940943 for (; ctx ; ctx = ctx -> next ) {
941-
942944 if (ngx_strcmp (ctx -> name , sctx -> name )) {
943945 break ;
944946 }
0 commit comments