Tweaks to reduce supervisor error logs (#1039)

Seeing some supervisor error logs under two conditions
- Issuing a full reconnect - client should close this session and
form a new one. So, supervisor errors on the to be closed session
is not useful.
- Some times it takes a long time for publisher PC to establish.
If publish monitor timer stars when a pending track is added,
the time out fires before ICE/DTLS is established. So, include
a condition to start timer on publication monitor only after
peer connection is connected.
This commit is contained in:
Raja Subramanian
2022-09-27 08:20:06 +05:30
committed by GitHub
parent 123baa571b
commit b3e148771a
4 changed files with 51 additions and 10 deletions
+23 -6
View File
@@ -24,8 +24,9 @@ type publish struct {
}
type PublicationMonitorParams struct {
TrackID livekit.TrackID
Logger logger.Logger
TrackID livekit.TrackID
IsPeerConnectionConnected bool
Logger logger.Logger
}
type PublicationMonitor struct {
@@ -34,6 +35,8 @@ type PublicationMonitor struct {
lock sync.RWMutex
desiredPublishes deque.Deque
isConnected bool
publishedTrack types.LocalMediaTrack
isMuted bool
unmutedAt time.Time
@@ -43,7 +46,8 @@ type PublicationMonitor struct {
func NewPublicationMonitor(params PublicationMonitorParams) *PublicationMonitor {
p := &PublicationMonitor{
params: params,
params: params,
isConnected: params.IsPeerConnectionConnected,
}
p.desiredPublishes.SetMinCapacity(2)
return p
@@ -51,6 +55,8 @@ func NewPublicationMonitor(params PublicationMonitorParams) *PublicationMonitor
func (p *PublicationMonitor) PostEvent(ome types.OperationMonitorEvent, omd types.OperationMonitorData) {
switch ome {
case types.OperationMonitorEventPublisherPeerConnectionConnected:
p.setConnected(omd.(bool))
case types.OperationMonitorEventAddPendingPublication:
p.addPending()
case types.OperationMonitorEventSetPublicationMute:
@@ -80,12 +86,23 @@ func (p *PublicationMonitor) addPending() {
p.lock.Unlock()
}
func (p *PublicationMonitor) maybeStartMonitor() {
if p.isConnected && !p.isMuted {
p.unmutedAt = time.Now()
}
}
func (p *PublicationMonitor) setConnected(isConnected bool) {
p.lock.Lock()
p.isConnected = isConnected
p.maybeStartMonitor()
p.lock.Unlock()
}
func (p *PublicationMonitor) setMute(isMuted bool) {
p.lock.Lock()
p.isMuted = isMuted
if !p.isMuted {
p.unmutedAt = time.Now()
}
p.maybeStartMonitor()
p.lock.Unlock()
}