Record dynacast requirement of a subscriber synchronously. (#834)

With rapid changes to subscription settings, use of a goroutine
could end up processing dynacast needs for that subscriber in
a different order. So, record the susbcription needs of a subscriber
in the callback and process the data in a go routine.
This commit is contained in:
Raja Subramanian
2022-07-15 11:46:02 +05:30
committed by GitHub
parent a0578db3ed
commit 4c7d3161a9
3 changed files with 9 additions and 7 deletions
+3 -3
View File
@@ -301,7 +301,7 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, wr *
})
downTrack.OnMaxLayerChanged(func(dt *sfu.DownTrack, layer int32) {
go t.notifySubscriberMaxQuality(subscriberID, dt.Codec(), utils.QualityForSpatialLayer(layer))
t.notifySubscriberMaxQuality(subscriberID, dt.Codec(), utils.QualityForSpatialLayer(layer))
})
downTrack.OnRttUpdate(func(_ *sfu.DownTrack, rtt uint32) {
@@ -517,7 +517,7 @@ func (t *MediaTrackSubscriptions) notifySubscriberMaxQuality(subscriberID liveki
}
t.maxQualityLock.Unlock()
t.UpdateQualityChange(false)
go t.UpdateQualityChange(false)
}
func (t *MediaTrackSubscriptions) NotifySubscriberNodeMaxQuality(nodeID livekit.NodeID, qualities []types.SubscribedCodecQuality) {
@@ -563,7 +563,7 @@ func (t *MediaTrackSubscriptions) NotifySubscriberNodeMaxQuality(nodeID livekit.
}
t.maxQualityLock.Unlock()
t.UpdateQualityChange(false)
go t.UpdateQualityChange(false)
}
func (t *MediaTrackSubscriptions) UpdateQualityChange(force bool) {
+2
View File
@@ -973,6 +973,7 @@ func (p *ParticipantImpl) UpdateSubscribedTrackSettings(trackID livekit.TrackID,
subTrack := p.subscribedTracks[trackID]
if subTrack == nil {
// will get set when subscribed track is added
p.lock.Unlock()
p.params.Logger.Infow("could not find subscribed track", "trackID", trackID)
return nil
@@ -1969,6 +1970,7 @@ func (p *ParticipantImpl) rtcpSendWorker() {
// read from rtcpChan
for pkts := range p.rtcpCh {
if pkts == nil {
p.params.Logger.Infow("exiting RTCP send worker")
return
}
+4 -4
View File
@@ -259,10 +259,6 @@ func (r *RTPStats) Update(rtph *rtp.Header, payloadSize int, paddingSize int, pa
r.highestSN = rtph.SequenceNumber
r.highestTS = rtph.Timestamp
r.highestTime = packetTime
if rtph.Marker {
r.frames++
}
}
if !isDuplicate {
@@ -271,6 +267,10 @@ func (r *RTPStats) Update(rtph *rtp.Header, payloadSize int, paddingSize int, pa
r.bytesPadding += pktSize
} else {
r.bytes += pktSize
if rtph.Marker {
r.frames++
}
}
r.updateJitter(rtph, packetTime)