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 -1
View File
@@ -34,4 +34,4 @@ require (
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
)
replace github.com/pion/ion-sfu => github.com/pion/ion-sfu v1.8.4-0.20210205220645-c9ec7ad1db86
replace github.com/pion/ion-sfu => github.com/davidzhao/ion-sfu v1.8.3-0.20210208065837-f6e01b2d7aeb
+2
View File
@@ -73,6 +73,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davidzhao/ion-sfu v1.8.3-0.20210205220645-c9ec7ad1db86 h1:POGjEQ8fyEQn96DMXMG7xhvWxHjNRMQ5aoiRzQOzOdY=
github.com/davidzhao/ion-sfu v1.8.3-0.20210205220645-c9ec7ad1db86/go.mod h1:MKDh4JSLpBA/hFeYAYALb6nYpe6Ruknd3pmxPMbdpM8=
github.com/davidzhao/ion-sfu v1.8.3-0.20210208065837-f6e01b2d7aeb h1:zrB9w2vGSzorwRYykHFMeMshWjMx/WU7J0T20Ta5WGo=
github.com/davidzhao/ion-sfu v1.8.3-0.20210208065837-f6e01b2d7aeb/go.mod h1:MKDh4JSLpBA/hFeYAYALb6nYpe6Ruknd3pmxPMbdpM8=
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
+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()