Track subscription operations per source track. (#1248)

This commit is contained in:
Raja Subramanian
2022-12-23 12:23:26 +05:30
committed by GitHub
parent 6719a3c714
commit 1a48cc6a8b
11 changed files with 302 additions and 196 deletions
+1 -15
View File
@@ -40,8 +40,6 @@ type PublicationMonitor struct {
publishedTrack types.LocalMediaTrack
isMuted bool
unmutedAt time.Time
lastError error
}
func NewPublicationMonitor(params PublicationMonitorParams) *PublicationMonitor {
@@ -118,7 +116,7 @@ func (p *PublicationMonitor) clearPublishedTrack(pubTrack types.LocalMediaTrack)
if p.publishedTrack == pubTrack {
p.publishedTrack = nil
} else {
p.params.Logger.Errorw("mismatched published track on clear", nil, "trackID", p.params.TrackID)
p.params.Logger.Errorw("supervisor: mismatched published track on clear", nil, "trackID", p.params.TrackID)
}
p.update()
@@ -127,12 +125,6 @@ func (p *PublicationMonitor) clearPublishedTrack(pubTrack types.LocalMediaTrack)
func (p *PublicationMonitor) Check() error {
p.lock.RLock()
if p.lastError != nil {
p.lock.RUnlock()
// return an error only once
return nil
}
var pub *publish
if p.desiredPublishes.Len() > 0 {
pub = p.desiredPublishes.Front().(*publish)
@@ -148,10 +140,6 @@ func (p *PublicationMonitor) Check() error {
if pub.isStart && !isMuted && !unmutedAt.IsZero() && time.Since(unmutedAt) > publishWaitDuration {
// timed out waiting for publish
p.lock.Lock()
p.lastError = errPublishTimeout
p.lock.Unlock()
return errPublishTimeout
}
@@ -183,7 +171,5 @@ func (p *PublicationMonitor) update() {
p.desiredPublishes.PushFront(pub)
return
}
p.lastError = nil
}
}