From 6c2c18fe508ac136780e5d9341710f0e4dceb542 Mon Sep 17 00:00:00 2001 From: "joe_zhang2006@163.com" Date: Wed, 9 Nov 2022 09:22:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=86Gop=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/remux/gop_cache.go | 5 +++-- pkg/remux/gop_cache_mpegts.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/remux/gop_cache.go b/pkg/remux/gop_cache.go index 1848ff2..ff13b2f 100644 --- a/pkg/remux/gop_cache.go +++ b/pkg/remux/gop_cache.go @@ -155,8 +155,9 @@ func (gc *GopCache) Clear() { // 注意,如果GopCache为空,则不缓存msg func (gc *GopCache) feedLastGop(msg base.RtmpMsg, b []byte) { if !gc.isGopRingEmpty() { - if gc.gopRing[(gc.gopRingLast-1+gc.gopSize)%gc.gopSize].len()<=gc.singleGopMaxNum ||gc.singleGopMaxNum==0{ - gc.gopRing[(gc.gopRingLast-1+gc.gopSize)%gc.gopSize].Feed(msg, b) + gopPos:=(gc.gopRingLast-1+gc.gopSize)%gc.gopSize + if gc.gopRing[gopPos].len()<=gc.singleGopMaxNum ||gc.singleGopMaxNum==0{ + gc.gopRing[gopPos].Feed(msg, b) } } } diff --git a/pkg/remux/gop_cache_mpegts.go b/pkg/remux/gop_cache_mpegts.go index 380bed3..2f7101f 100644 --- a/pkg/remux/gop_cache_mpegts.go +++ b/pkg/remux/gop_cache_mpegts.go @@ -74,8 +74,9 @@ func (gc *GopCacheMpegts) Clear() { // 注意,如果GopCache为空,则不缓存msg func (gc *GopCacheMpegts) feedLastGop(b []byte) { if !gc.isGopRingEmpty() { - if gc.gopRing[(gc.gopRingLast-1+gc.gopSize)%gc.gopSize].len()<=gc.singleGopMaxNum ||gc.singleGopMaxNum==0{ - gc.gopRing[(gc.gopRingLast-1+gc.gopSize)%gc.gopSize].Feed(b) + gopPos:=(gc.gopRingLast-1+gc.gopSize)%gc.gopSize + if gc.gopRing[gopPos].len()<=gc.singleGopMaxNum ||gc.singleGopMaxNum==0{ + gc.gopRing[gopPos].Feed(b) } }