From 2adfaeec0a6451f76c2800f266b3e4d2f78153c3 Mon Sep 17 00:00:00 2001 From: winshining Date: Fri, 12 Jan 2024 21:22:05 +0800 Subject: [PATCH] [fix] added version check for updating meta in gop cache. --- AUTHORS | 5 +++++ LICENSE | 3 ++- ngx_rtmp_gop_cache_module.c | 20 +++++++++++--------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/AUTHORS b/AUTHORS index 7e54731..dda3fa0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -56,3 +56,8 @@ Project author: Scranton, PA Contacts: https://github.com/deamos + + vacing + Shenzhen, China + Contacts: + https://github.com/vacing diff --git a/LICENSE b/LICENSE index 2a8ce81..f628026 100644 --- a/LICENSE +++ b/LICENSE @@ -1,12 +1,13 @@ BSD 2-Clause License Copyright (c) 2012-2017, Roman Arutyunyan -Copyright (c) 2017-2023, Winshining +Copyright (c) 2017-2024, Winshining Copyright (c) 2018, han4235, Vladimir Vainer Copyright (c) 2018-2019, plainheart, HeyJupiter Copyright (c) 2019, ever4Keny Copyright (c) 2020, spacewander, ham3r Copyright (c) 2022, deamons +Copyright (c) 2024, vacing All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/ngx_rtmp_gop_cache_module.c b/ngx_rtmp_gop_cache_module.c index 059fc7a..c09bf39 100644 --- a/ngx_rtmp_gop_cache_module.c +++ b/ngx_rtmp_gop_cache_module.c @@ -438,17 +438,17 @@ ngx_rtmp_gop_cache_frame(ngx_rtmp_session_t *s, ngx_uint_t prio, // drop non-IDR if (prio != NGX_RTMP_VIDEO_KEY_FRAME && ctx->cache_head == NULL) { ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "drop video non-keyframe timestamp=%uD", + "gop cache: drop video non-keyframe timestamp=%uD", ch->timestamp); return; } } - // pure audio + // audio only if (ctx->video_frame_in_all == 0 && ch->type == NGX_RTMP_MSG_AUDIO) { ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "drop audio frame timestamp=%uD", + "gop cache: drop audio frame timestamp=%uD", ch->timestamp); return; @@ -461,23 +461,25 @@ ngx_rtmp_gop_cache_frame(ngx_rtmp_session_t *s, ngx_uint_t prio, } // save video seq header. - if (ctx->video_seq_header == NULL && codec_ctx->avc_header) { + if (codec_ctx->avc_header && ctx->video_seq_header == NULL) { ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "video header comming"); + "gop cache: video seq header is comming"); ctx->video_seq_header = codec_ctx->avc_header; } // save audio seq header. - if (ctx->audio_seq_header == NULL && codec_ctx->aac_header) { + if (codec_ctx->aac_header && ctx->audio_seq_header == NULL) { ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "audio header comming"); + "gop cache: audio seq header is comming"); ctx->audio_seq_header = codec_ctx->aac_header; } // save metadata. - if (ctx->meta == NULL && codec_ctx->meta) { + if (codec_ctx->meta && + (ctx->meta == NULL || codec_ctx->meta_version != ctx->meta_version)) + { ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "meta comming"); + "gop cache: meta is comming"); ctx->meta_version = codec_ctx->meta_version; ctx->meta = codec_ctx->meta; }