Misc clean up (#931)

* Start RTCP workers after peer connection connects

* Move more things into transport module

* Start RTCP workers only on connected

* Test needs PeerConnection() method

* adjust comment
This commit is contained in:
Raja Subramanian
2022-08-19 11:49:12 +05:30
committed by GitHub
parent 770076febf
commit 0cd9c87dc9
6 changed files with 328 additions and 153 deletions
+13 -8
View File
@@ -570,8 +570,6 @@ func (p *ParticipantImpl) SetMigrateInfo(previousAnswer *webrtc.SessionDescripti
func (p *ParticipantImpl) Start() {
p.once.Do(func() {
p.UpTrackManager.Start()
go p.rtcpSendWorker()
go p.downTracksRTCPWorker()
})
}
@@ -1002,6 +1000,7 @@ func (p *ParticipantImpl) setupTransportManager() error {
tm.OnPublisherGetDTX(p.onPublisherGetDTX)
tm.OnPublisherAnswer(p.onPublisherAnswer)
tm.OnPublisherTrack(p.onMediaTrack)
tm.OnPublisherInitialConnected(p.onPublisherInitialConnected)
tm.OnSubscriberOffer(p.onSubscriberOffer)
tm.OnSubscriberICECandidate(func(c *webrtc.ICECandidate) {
@@ -1159,7 +1158,13 @@ func (p *ParticipantImpl) onICECandidate(c *webrtc.ICECandidate, target livekit.
p.sendICECandidate(c, target)
}
func (p *ParticipantImpl) onPublisherInitialConnected() {
go p.publisherRTCPWorker()
}
func (p *ParticipantImpl) onSubscriberInitialConnected() {
go p.subscriberRTCPWorker()
p.setDowntracksConnected()
}
@@ -1198,13 +1203,11 @@ func (p *ParticipantImpl) onAnyTransportFailed() {
p.lock.Unlock()
}
// downTracksRTCPWorker sends SenderReports periodically when the participant is subscribed to
// subscriberRTCPWorker sends SenderReports periodically when the participant is subscribed to
// other publishedTracks in the room.
func (p *ParticipantImpl) downTracksRTCPWorker() {
func (p *ParticipantImpl) subscriberRTCPWorker() {
defer Recover()
for {
time.Sleep(5 * time.Second)
if p.State() == livekit.ParticipantInfo_DISCONNECTED {
return
}
@@ -1257,6 +1260,8 @@ func (p *ParticipantImpl) downTracksRTCPWorker() {
pkts = pkts[:0]
batchSize = 0
}
time.Sleep(5 * time.Second)
}
}
@@ -1752,13 +1757,13 @@ func (p *ParticipantImpl) getPublishedTrackBySdpCid(clientId string) types.Media
return nil
}
func (p *ParticipantImpl) rtcpSendWorker() {
func (p *ParticipantImpl) publisherRTCPWorker() {
defer Recover()
// read from rtcpChan
for pkts := range p.rtcpCh {
if pkts == nil {
p.params.Logger.Infow("exiting RTCP send worker")
p.params.Logger.Infow("exiting publisher RTCP worker")
return
}