mirror of
https://github.com/livekit/livekit.git
synced 2026-08-28 07:14:12 +00:00
rename EnableVideoFrameCache to SetVideoFrameCacheDuration.
This commit is contained in:
@@ -93,7 +93,7 @@ type BufferProvider interface {
|
||||
ReadExtended(buf []byte) (*ExtPacket, error)
|
||||
GetPacket(buf []byte, esn uint64) (int, error)
|
||||
|
||||
EnableVideoFrameCache(maxDuration time.Duration)
|
||||
SetVideoFrameCacheDuration(maxDuration time.Duration)
|
||||
GetVideoFrameCache() ([]*ExtPacket, bool)
|
||||
GetPacketsAfter(afterESN uint64) ([]*ExtPacket, bool)
|
||||
|
||||
@@ -656,13 +656,13 @@ func (b *BufferBase) ReadExtended(buf []byte) (*ExtPacket, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// EnableVideoFrameCache turns on video frame cache tracking for this (video) buffer: the most recent
|
||||
// SetVideoFrameCacheDuration turns on video frame cache tracking for this (video) buffer: the most recent
|
||||
// key frame is marked so the current group-of-pictures can be read back from the retransmit bucket
|
||||
// via GetVideoFrameCache. No packets are copied - only the key-frame boundary is tracked. maxDuration
|
||||
// bounds the served key-frame interval AND drives the retransmit bucket to retain that much history
|
||||
// (see maybeGrowBucket), so the key frame is not evicted before it can be read; maxDuration <= 0
|
||||
// disables the cache.
|
||||
func (b *BufferBase) EnableVideoFrameCache(maxDuration time.Duration) {
|
||||
func (b *BufferBase) SetVideoFrameCacheDuration(maxDuration time.Duration) {
|
||||
b.Lock()
|
||||
defer b.Unlock()
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ func newVideoFrameCacheTestBuffer(maxDuration time.Duration) *BufferBase {
|
||||
logger: logger.GetLogger(),
|
||||
}
|
||||
b.bucket = bucket.NewBucket[uint64, uint16](256, bucket.RTPMaxPktSize, bucket.RTPSeqNumOffset)
|
||||
b.EnableVideoFrameCache(maxDuration)
|
||||
b.SetVideoFrameCacheDuration(maxDuration)
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -228,6 +228,6 @@ func TestVideoFrameCacheDisabled(t *testing.T) {
|
||||
|
||||
// audio buffers never enable the cache
|
||||
a := &BufferBase{codecType: webrtc.RTPCodecTypeAudio, clockRate: 48000, logger: logger.GetLogger()}
|
||||
a.EnableVideoFrameCache(0)
|
||||
a.SetVideoFrameCacheDuration(0)
|
||||
require.False(t, a.videoFrameCacheMaxDuration > 0)
|
||||
}
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ func WithVideoFrameCache(maxDuration time.Duration) ReceiverOpts {
|
||||
maxDuration = maxVideoFrameCacheDuration
|
||||
}
|
||||
|
||||
w.ReceiverBase.EnableVideoFrameCache(maxDuration)
|
||||
w.ReceiverBase.SetVideoFrameCacheDuration(maxDuration)
|
||||
return w
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,10 +595,10 @@ func (r *ReceiverBase) AddDownTrack(track TrackSender) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// EnableVideoFrameCache turns on the video frame cache for this receiver: each (current and future) buffer
|
||||
// SetVideoFrameCacheDuration turns on the video frame cache for this receiver: each (current and future) buffer
|
||||
// retains the current cached frame, and a newly added down track is bootstrapped from it (see replayVideoFrameCache).
|
||||
// maxDuration bounds the cached video frame and sizes the retransmit bucket accordingly. No-op for audio.
|
||||
func (r *ReceiverBase) EnableVideoFrameCache(maxDuration time.Duration) {
|
||||
func (r *ReceiverBase) SetVideoFrameCacheDuration(maxDuration time.Duration) {
|
||||
if r.Kind() != webrtc.RTPCodecTypeVideo {
|
||||
return
|
||||
}
|
||||
@@ -610,7 +610,7 @@ func (r *ReceiverBase) EnableVideoFrameCache(maxDuration time.Duration) {
|
||||
|
||||
for _, buff := range buffers {
|
||||
if buff != nil {
|
||||
buff.EnableVideoFrameCache(maxDuration)
|
||||
buff.SetVideoFrameCacheDuration(maxDuration)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -625,10 +625,6 @@ const videoFrameCacheReplayMaxCatchupRounds = 8
|
||||
// half the (estimated) video frame interval so the replay runs at ~2x real time and converges on
|
||||
// live. It writes directly to the track (which is not yet in the live broadcast), so there is no
|
||||
// interleaving with live packets.
|
||||
//
|
||||
// It replays the highest spatial layer that currently has a cached video frame cache group: a subscriber requesting full
|
||||
// quality has its forwarder targeting the top layer, and lower layers may not even be flowing (e.g.
|
||||
// paused by dynacast), so layer 0 often has no video frame cache group.
|
||||
func (r *ReceiverBase) replayVideoFrameCache(track TrackSender) {
|
||||
var (
|
||||
buff buffer.BufferProvider
|
||||
@@ -952,7 +948,7 @@ func (r *ReceiverBase) setupBuffer(buff buffer.BufferProvider, layer int32, rtt
|
||||
buff.OnCodecChange(r.handleCodecChange)
|
||||
}
|
||||
if r.videoFrameCacheMaxDuration > 0 && r.Kind() == webrtc.RTPCodecTypeVideo {
|
||||
buff.EnableVideoFrameCache(r.videoFrameCacheMaxDuration)
|
||||
buff.SetVideoFrameCacheDuration(r.videoFrameCacheMaxDuration)
|
||||
}
|
||||
|
||||
buff.OnStreamRestart(func(reason string) {
|
||||
|
||||
Reference in New Issue
Block a user