@@ -504,6 +504,7 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
504
504
ngx_rtmp_live_ctx_t * ctx ;
505
505
ngx_rtmp_session_t * s ;
506
506
ngx_int_t n ;
507
+ ngx_uint_t m ;
507
508
ngx_uint_t nclients , total_nclients ;
508
509
ngx_uint_t f ;
509
510
u_char buf [NGX_INT_T_LEN ];
@@ -526,15 +527,18 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
526
527
527
528
total_nclients = 0 ;
528
529
for (n = 0 ; n < lacf -> nbuckets ; ++ n ) {
529
- for ( stream = lacf -> streams [ n ]; ; stream = stream -> next ) {
530
-
531
- if (! stream ) {
532
- break ;
533
- }
530
+ m = 0 ;
531
+ if ( n > 0 && lacf -> streams [ n - 1 ]) {
532
+ m = 1 ;
533
+ }
534
+ for ( stream = lacf -> streams [ n ]; stream ; stream = stream -> next ) {
534
535
535
536
if (slcf -> format & NGX_RTMP_STAT_FORMAT_XML ) {
536
537
NGX_RTMP_STAT_L ("<stream>\r\n" );
537
538
} else {
539
+ if (m == 1 || stream -> next != NULL ) {
540
+ NGX_RTMP_STAT_L ("," );
541
+ }
538
542
NGX_RTMP_STAT_L ("{" );
539
543
}
540
544
@@ -781,7 +785,7 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
781
785
}
782
786
783
787
784
- NGX_RTMP_STAT_L ("}, \"audio\": {" );
788
+ NGX_RTMP_STAT_L ("},\"audio\": {" );
785
789
cname = ngx_rtmp_get_audio_codec_name (codec -> audio_codec_id );
786
790
f = 0 ;
787
791
if (* cname ) {
@@ -866,8 +870,6 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
866
870
867
871
NGX_RTMP_STAT_L ("}" );
868
872
}
869
-
870
- NGX_RTMP_STAT_L ("," );
871
873
}
872
874
}
873
875
@@ -893,7 +895,7 @@ ngx_rtmp_stat_play(ngx_http_request_t *r, ngx_chain_t ***lll,
893
895
{
894
896
ngx_rtmp_play_ctx_t * ctx , * sctx ;
895
897
ngx_rtmp_session_t * s ;
896
- ngx_uint_t n , nclients , total_nclients ;
898
+ ngx_uint_t m , n , nclients , total_nclients ;
897
899
u_char buf [NGX_INT_T_LEN ];
898
900
u_char bbuf [NGX_INT32_LEN ];
899
901
ngx_rtmp_stat_loc_conf_t * slcf ;
@@ -913,6 +915,10 @@ ngx_rtmp_stat_play(ngx_http_request_t *r, ngx_chain_t ***lll,
913
915
914
916
total_nclients = 0 ;
915
917
for (n = 0 ; n < pacf -> nbuckets ; ++ n ) {
918
+ m = 0 ;
919
+ if (n > 0 && pacf -> ctx [n - 1 ]) {
920
+ m = 1 ;
921
+ }
916
922
for (ctx = pacf -> ctx [n ]; ctx ; ) {
917
923
918
924
if (slcf -> format & NGX_RTMP_STAT_FORMAT_XML ) {
@@ -921,6 +927,9 @@ ngx_rtmp_stat_play(ngx_http_request_t *r, ngx_chain_t ***lll,
921
927
NGX_RTMP_STAT_ECS (ctx -> name );
922
928
NGX_RTMP_STAT_L ("</name>\r\n" );
923
929
} else {
930
+ if (m == 1 || ctx -> next != NULL ) {
931
+ NGX_RTMP_STAT_L ("," );
932
+ }
924
933
NGX_RTMP_STAT_L ("{\"name\":\"" );
925
934
NGX_RTMP_STAT_ECS (ctx -> name );
926
935
NGX_RTMP_STAT_L ("\",\"clients\":[" );
@@ -959,9 +968,6 @@ ngx_rtmp_stat_play(ngx_http_request_t *r, ngx_chain_t ***lll,
959
968
"%D" , s -> current_time ) - bbuf );
960
969
961
970
NGX_RTMP_STAT_L ("}" );
962
- if (ctx -> next ) {
963
- NGX_RTMP_STAT_L ("," );
964
- }
965
971
}
966
972
}
967
973
}
0 commit comments