From 71b2db05b95adb765063fb1e2a6428caf0751307 Mon Sep 17 00:00:00 2001 From: winshining Date: Fri, 11 Oct 2019 23:35:08 +0800 Subject: [PATCH] [misc] added timers for playing subscribers and fixed a overflow bug. --- ngx_http_flv_live_module.c | 6 ++++++ ngx_rtmp_handler.c | 9 +++++++-- ngx_rtmp_stat_module.c | 6 +++--- ngx_rtmp_version.h | 4 ++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ngx_http_flv_live_module.c b/ngx_http_flv_live_module.c index fe65607..0a3544f 100644 --- a/ngx_http_flv_live_module.c +++ b/ngx_http_flv_live_module.c @@ -1498,6 +1498,7 @@ ngx_http_flv_live_write_handler(ngx_event_t *wev) ngx_http_request_t *r; ngx_rtmp_session_t *s; ngx_int_t n; + ngx_rtmp_live_ctx_t *lctx; ngx_rtmp_core_srv_conf_t *cscf; ngx_http_flv_live_ctx_t *ctx; @@ -1565,6 +1566,11 @@ ngx_http_flv_live_write_handler(ngx_event_t *wev) } } + lctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_live_module); + if (lctx && !lctx->publishing && !wev->timer_set) { + ngx_add_timer(wev, s->timeout); + } + if (wev->active) { ngx_del_event(wev, NGX_WRITE_EVENT, 0); } diff --git a/ngx_rtmp_handler.c b/ngx_rtmp_handler.c index fe822a6..20be86e 100644 --- a/ngx_rtmp_handler.c +++ b/ngx_rtmp_handler.c @@ -7,9 +7,8 @@ #include #include -#include "ngx_rtmp.h" +#include "ngx_rtmp_live_module.h" #include "ngx_rtmp_amf.h" -#include "ngx_rtmp_cmd_module.h" static void ngx_rtmp_recv(ngx_event_t *rev); @@ -503,6 +502,7 @@ ngx_rtmp_send(ngx_event_t *wev) ngx_connection_t *c; ngx_rtmp_session_t *s; ngx_int_t n; + ngx_rtmp_live_ctx_t *lctx; ngx_rtmp_core_srv_conf_t *cscf; c = wev->data; @@ -565,6 +565,11 @@ ngx_rtmp_send(ngx_event_t *wev) } } + lctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_live_module); + if (lctx && !lctx->publishing && !wev->timer_set) { + ngx_add_timer(wev, s->timeout); + } + if (wev->active) { ngx_del_event(wev, NGX_WRITE_EVENT, 0); } diff --git a/ngx_rtmp_stat_module.c b/ngx_rtmp_stat_module.c index 79f8061..33a55a1 100644 --- a/ngx_rtmp_stat_module.c +++ b/ngx_rtmp_stat_module.c @@ -508,7 +508,7 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll, ngx_uint_t nclients, total_nclients; ngx_uint_t f; ngx_flag_t prev; - u_char buf[NGX_INT_T_LEN]; + u_char buf[NGX_INT64_LEN + 4]; u_char bbuf[NGX_INT32_LEN]; ngx_rtmp_stat_loc_conf_t *slcf; u_char *cname; @@ -770,8 +770,8 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll, } if (codec->avc_profile) { NGX_RTMP_STAT_L(",\"profile\":\""); - NGX_RTMP_STAT_CS( - ngx_rtmp_stat_get_avc_profile(codec->avc_profile)); + NGX_RTMP_STAT_CS(ngx_rtmp_stat_get_avc_profile( + codec->avc_profile)); NGX_RTMP_STAT_L("\""); } if (codec->avc_compat) { diff --git a/ngx_rtmp_version.h b/ngx_rtmp_version.h index 4ee22de..6a2015c 100644 --- a/ngx_rtmp_version.h +++ b/ngx_rtmp_version.h @@ -9,8 +9,8 @@ #define _NGX_RTMP_VERSION_H_INCLUDED_ -#define nginx_rtmp_version 1002006 -#define NGINX_RTMP_VERSION "1.2.6" +#define nginx_rtmp_version 1002007 +#define NGINX_RTMP_VERSION "1.2.7" #endif /* _NGX_RTMP_VERSION_H_INCLUDED_ */