Restart API on receiver. (#4200)

Can be used when track moves forward/backward.
This commit is contained in:
Raja Subramanian authored and GitHub committed 2025-12-27 03:42:23 +05:30
1 parent 25ece1e911
commit bb00c86489
2 files changed
+17

No files matched your search

+6
View File
@@ -501,6 +501,12 @@ func (d *DummyReceiver) VideoSizes() []buffer.VideoSize {
return nil
}
func (d *DummyReceiver) Restart(reason string) {
if receiver := d.getReceiver(); receiver != nil {
receiver.Restart(reason)
}
}
func (d *DummyReceiver) getReceiver() sfu.TrackReceiver {
if receiver, ok := d.receiver.Load().(sfu.TrackReceiver); ok {
return receiver
+11
View File
@@ -151,6 +151,10 @@ type TrackReceiver interface {
// VideoSizes returns the video size parsed from rtp packet for each spatial layer.
VideoSizes() []buffer.VideoSize
// closes all associated buffers and issues a resync to all attached downtracks so that
// they can resync and have proper sequncing without gaps in sequence numbers / timestamps
Restart(reason string)
}
// --------------------------------------
@@ -350,6 +354,13 @@ func (r *ReceiverBase) UpdateTrackInfo(ti *livekit.TrackInfo) {
r.streamTrackerManager.UpdateTrackInfo(ti)
}
func (r *ReceiverBase) Restart(reason string) {
r.bufferMu.Lock()
defer r.bufferMu.Unlock()
r.resyncLocked(reason)
}
func (r *ReceiverBase) resyncLocked(reason string) {
// resync to avoid gaps in the forwarded sequence number
r.params.Logger.Debugw("resync receiver", "reason", reason)