Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] added version check for updating meta in gop cache. #258

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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