mirror of
https://github.com/livekit/livekit.git
synced 2026-10-22 17:32:23 +00:00
Restart API on receiver. (#4200)
Can be used when track moves forward/backward.
This commit is contained in:
1 parent
25ece1e911
commit
bb00c86489
2 files changed
+17
No files matched your search
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user