Use difference in key frame counter to stop seeder. (#3936)
The key frame seeder could be started multiple times. Use difference to detect stop condition.
This commit is contained in:
@@ -1343,6 +1343,14 @@ func (b *Buffer) seedKeyFrame(keyFrameSeederGeneration int32) {
|
|||||||
ticker := time.NewTicker(time.Second)
|
ticker := time.NewTicker(time.Second)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
initialCount := uint32(0)
|
||||||
|
b.RLock()
|
||||||
|
rtpStats := b.rtpStats
|
||||||
|
b.RUnlock()
|
||||||
|
if rtpStats != nil {
|
||||||
|
initialCount, _ = rtpStats.KeyFrame()
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if b.closed.Load() || b.keyFrameSeederGeneration.Load() != keyFrameSeederGeneration {
|
if b.closed.Load() || b.keyFrameSeederGeneration.Load() != keyFrameSeederGeneration {
|
||||||
return
|
return
|
||||||
@@ -1354,15 +1362,12 @@ func (b *Buffer) seedKeyFrame(keyFrameSeederGeneration int32) {
|
|||||||
return
|
return
|
||||||
|
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
b.RLock()
|
|
||||||
rtpStats := b.rtpStats
|
|
||||||
b.RUnlock()
|
|
||||||
|
|
||||||
if rtpStats != nil {
|
if rtpStats != nil {
|
||||||
cnt, last := rtpStats.KeyFrame()
|
cnt, last := rtpStats.KeyFrame()
|
||||||
if cnt > 0 {
|
if cnt > initialCount {
|
||||||
b.logger.Debugw(
|
b.logger.Debugw(
|
||||||
"stopping key frame seeder: received key frame",
|
"stopping key frame seeder: received key frame",
|
||||||
|
"keyFrameCountInitial", initialCount,
|
||||||
"keyFrameCount", cnt,
|
"keyFrameCount", cnt,
|
||||||
"lastKeyFrame", last,
|
"lastKeyFrame", last,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user