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:
+13
-8
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user