Skip to content

Commit

Permalink
[fix] added version check for updating meta in gop cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
winshining committed Jan 12, 2024
1 parent 090fadc commit 2adfaee
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
5 changes: 5 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,8 @@ Project author:
Scranton, PA
Contacts:
https://github.com/deamos

vacing
Shenzhen, China
Contacts:
https://github.com/vacing
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 11 additions & 9 deletions ngx_rtmp_gop_cache_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit 2adfaee

Please sign in to comment.