diff --git a/ngx_rtmp_gop_cache_module.c b/ngx_rtmp_gop_cache_module.c index 98ea07b..4dc11f6 100644 --- a/ngx_rtmp_gop_cache_module.c +++ b/ngx_rtmp_gop_cache_module.c @@ -267,7 +267,6 @@ static ngx_int_t ngx_rtmp_gop_cache_alloc_cache(ngx_rtmp_session_t *s) { ngx_rtmp_codec_ctx_t *codec_ctx; - ngx_rtmp_core_srv_conf_t *cscf; ngx_rtmp_gop_cache_ctx_t *ctx; ngx_rtmp_gop_cache_t *cache, **iter; @@ -281,11 +280,6 @@ ngx_rtmp_gop_cache_alloc_cache(ngx_rtmp_session_t *s) return NGX_ERROR; } - cscf = ngx_rtmp_get_module_srv_conf(s, ngx_rtmp_core_module); - if (cscf == NULL) { - return NGX_ERROR; - } - if (ctx->free_cache) { cache = ctx->free_cache; ctx->free_cache = cache->next; @@ -378,19 +372,18 @@ ngx_rtmp_gop_cache_cleanup(ngx_rtmp_session_t *s) ngx_rtmp_gop_cache_free_cache(s, cache); } - if (ctx->pool) { - ngx_destroy_pool(ctx->pool); - ctx->pool = NULL; - } - ctx->video_seq_header = NULL; ctx->audio_seq_header = NULL; ctx->meta = NULL; - ctx->cache_tail = ctx->cache_head = NULL; + if (ctx->cache_head) { + ctx->cache_head->next = ctx->free_cache; + ctx->free_cache = ctx->cache_head; + ctx->cache_head = NULL; + } + + ctx->cache_tail = NULL; ctx->gop_cache_count = 0; - ctx->free_cache = NULL; - ctx->free_frame = NULL; ctx->video_frame_in_all = 0; ctx->audio_frame_in_all = 0; } @@ -720,10 +713,10 @@ ngx_rtmp_gop_cache_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, ngx_rtmp_live_ctx_t *ctx; ngx_rtmp_gop_cache_app_conf_t *gacf; ngx_rtmp_live_app_conf_t *lacf; + ngx_rtmp_live_chunk_stream_t *cs; ngx_rtmp_header_t ch; ngx_uint_t prio; ngx_uint_t csidx; - ngx_rtmp_live_chunk_stream_t *cs; gacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_gop_cache_module); if (gacf == NULL || !gacf->gop_cache) { @@ -851,6 +844,7 @@ ngx_rtmp_gop_cache_close_stream(ngx_rtmp_session_t *s, ngx_rtmp_close_stream_t *v) { ngx_rtmp_live_ctx_t *ctx; + ngx_rtmp_gop_cache_ctx_t *gctx; ngx_rtmp_live_app_conf_t *lacf; ngx_rtmp_gop_cache_app_conf_t *gacf; @@ -873,6 +867,16 @@ ngx_rtmp_gop_cache_close_stream(ngx_rtmp_session_t *s, goto next; } + gctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_gop_cache_module); + if (gctx == NULL) { + goto next; + } + + if (gctx->pool) { + ngx_destroy_pool(gctx->pool); + gctx->pool = NULL; + } + ngx_rtmp_gop_cache_cleanup(s); next: diff --git a/ngx_rtmp_version.h b/ngx_rtmp_version.h index a382c16..f3d3b56 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 1002004 -#define NGINX_RTMP_VERSION "1.2.4" +#define nginx_rtmp_version 1002005 +#define NGINX_RTMP_VERSION "1.2.5" #endif /* _NGX_RTMP_VERSION_H_INCLUDED_ */