Skip to content

Commit 2adfaee

Browse files
committed
[fix] added version check for updating meta in gop cache.
1 parent 090fadc commit 2adfaee

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

AUTHORS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@ Project author:
5656
Scranton, PA
5757
Contacts:
5858
https://github.com/deamos
59+
60+
vacing
61+
Shenzhen, China
62+
Contacts:
63+
https://github.com/vacing

LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
BSD 2-Clause License
22

33
Copyright (c) 2012-2017, Roman Arutyunyan
4-
Copyright (c) 2017-2023, Winshining
4+
Copyright (c) 2017-2024, Winshining
55
Copyright (c) 2018, han4235, Vladimir Vainer
66
Copyright (c) 2018-2019, plainheart, HeyJupiter
77
Copyright (c) 2019, ever4Keny
88
Copyright (c) 2020, spacewander, ham3r
99
Copyright (c) 2022, deamons
10+
Copyright (c) 2024, vacing
1011
All rights reserved.
1112

1213
Redistribution and use in source and binary forms, with or without

ngx_rtmp_gop_cache_module.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -438,17 +438,17 @@ ngx_rtmp_gop_cache_frame(ngx_rtmp_session_t *s, ngx_uint_t prio,
438438
// drop non-IDR
439439
if (prio != NGX_RTMP_VIDEO_KEY_FRAME && ctx->cache_head == NULL) {
440440
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
441-
"drop video non-keyframe timestamp=%uD",
441+
"gop cache: drop video non-keyframe timestamp=%uD",
442442
ch->timestamp);
443443

444444
return;
445445
}
446446
}
447447

448-
// pure audio
448+
// audio only
449449
if (ctx->video_frame_in_all == 0 && ch->type == NGX_RTMP_MSG_AUDIO) {
450450
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
451-
"drop audio frame timestamp=%uD",
451+
"gop cache: drop audio frame timestamp=%uD",
452452
ch->timestamp);
453453

454454
return;
@@ -461,23 +461,25 @@ ngx_rtmp_gop_cache_frame(ngx_rtmp_session_t *s, ngx_uint_t prio,
461461
}
462462

463463
// save video seq header.
464-
if (ctx->video_seq_header == NULL && codec_ctx->avc_header) {
464+
if (codec_ctx->avc_header && ctx->video_seq_header == NULL) {
465465
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
466-
"video header comming");
466+
"gop cache: video seq header is comming");
467467
ctx->video_seq_header = codec_ctx->avc_header;
468468
}
469469

470470
// save audio seq header.
471-
if (ctx->audio_seq_header == NULL && codec_ctx->aac_header) {
471+
if (codec_ctx->aac_header && ctx->audio_seq_header == NULL) {
472472
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
473-
"audio header comming");
473+
"gop cache: audio seq header is comming");
474474
ctx->audio_seq_header = codec_ctx->aac_header;
475475
}
476476

477477
// save metadata.
478-
if (ctx->meta == NULL && codec_ctx->meta) {
478+
if (codec_ctx->meta &&
479+
(ctx->meta == NULL || codec_ctx->meta_version != ctx->meta_version))
480+
{
479481
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
480-
"meta comming");
482+
"gop cache: meta is comming");
481483
ctx->meta_version = codec_ctx->meta_version;
482484
ctx->meta = codec_ctx->meta;
483485
}

0 commit comments

Comments
 (0)