use proper fix for using shared bufferFactory, remove resync hack

This commit is contained in:
David Zhao
2021-02-07 23:06:16 -08:00
parent e30c9f706c
commit f1f5b8dafe
7 changed files with 4 additions and 55 deletions
+1
View File
@@ -137,6 +137,7 @@ func (t *MediaTrack) AddSubscriber(sub types.Participant) error {
if err != nil {
return err
}
downTrack.SetBufferFactory(bufferFactory)
subTrack := NewSubscribedTrack(downTrack)
transceiver, err := sub.PeerConnection().AddTransceiverFromTrack(downTrack, webrtc.RTPTransceiverInit{
-15
View File
@@ -580,8 +580,6 @@ func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *w
if newTrack {
p.handleTrackPublished(mt)
}
p.resyncSubscriptions()
}
func (p *ParticipantImpl) onDataChannel(dc *webrtc.DataChannel) {
@@ -646,7 +644,6 @@ func (p *ParticipantImpl) handleTrackPublished(track types.PublishedTrack) {
p.onTrackUpdated(p, track)
}
track.OnClose(nil)
go p.resyncSubscriptions()
})
if p.onTrackPublished != nil {
@@ -654,18 +651,6 @@ func (p *ParticipantImpl) handleTrackPublished(track types.PublishedTrack) {
}
}
func (p *ParticipantImpl) resyncSubscriptions() {
// TODO: video tracks the current participant is subscribed to tends to freeze when the participant adds/removes tracks
// to get around this, we'll trigger a resync on all tracks it's subscribed to
p.lock.RLock()
defer p.lock.RUnlock()
for _, tracks := range p.subscribedTracks {
for _, subTrack := range tracks {
subTrack.Resync()
}
}
}
// downTracksRTCPWorker sends SenderReports periodically when the participant is subscribed to
// other publishedTracks in the room.
func (p *ParticipantImpl) downTracksRTCPWorker() {
-8
View File
@@ -38,14 +38,6 @@ func (t *SubscribedTrack) SetPublisherMuted(muted bool) {
t.updateDownTrackMute()
}
// cause downtrack to resync and request a keyframe
// this is sort of a hack to prevent a subscriber from having tracks freeze on the client due to missing
// keyframes
func (t *SubscribedTrack) Resync() {
t.dt.Mute(true)
t.updateDownTrackMute()
}
func (t *SubscribedTrack) updateDownTrackMute() {
muted := t.subMuted.Get() || t.pubMuted.Get()
t.dt.Mute(muted)
-1
View File
@@ -109,7 +109,6 @@ type SubscribedTrack interface {
IsMuted() bool
SetMuted(muted bool)
SetPublisherMuted(muted bool)
Resync()
}
// interface for properties of webrtc.TrackRemote
@@ -29,10 +29,6 @@ type FakeSubscribedTrack struct {
isMutedReturnsOnCall map[int]struct {
result1 bool
}
ResyncStub func()
resyncMutex sync.RWMutex
resyncArgsForCall []struct {
}
SetMutedStub func(bool)
setMutedMutex sync.RWMutex
setMutedArgsForCall []struct {
@@ -153,30 +149,6 @@ func (fake *FakeSubscribedTrack) IsMutedReturnsOnCall(i int, result1 bool) {
}{result1}
}
func (fake *FakeSubscribedTrack) Resync() {
fake.resyncMutex.Lock()
fake.resyncArgsForCall = append(fake.resyncArgsForCall, struct {
}{})
stub := fake.ResyncStub
fake.recordInvocation("Resync", []interface{}{})
fake.resyncMutex.Unlock()
if stub != nil {
fake.ResyncStub()
}
}
func (fake *FakeSubscribedTrack) ResyncCallCount() int {
fake.resyncMutex.RLock()
defer fake.resyncMutex.RUnlock()
return len(fake.resyncArgsForCall)
}
func (fake *FakeSubscribedTrack) ResyncCalls(stub func()) {
fake.resyncMutex.Lock()
defer fake.resyncMutex.Unlock()
fake.ResyncStub = stub
}
func (fake *FakeSubscribedTrack) SetMuted(arg1 bool) {
fake.setMutedMutex.Lock()
fake.setMutedArgsForCall = append(fake.setMutedArgsForCall, struct {
@@ -248,8 +220,6 @@ func (fake *FakeSubscribedTrack) Invocations() map[string][][]interface{} {
defer fake.downTrackMutex.RUnlock()
fake.isMutedMutex.RLock()
defer fake.isMutedMutex.RUnlock()
fake.resyncMutex.RLock()
defer fake.resyncMutex.RUnlock()
fake.setMutedMutex.RLock()
defer fake.setMutedMutex.RUnlock()
fake.setPublisherMutedMutex.RLock()