better logging around negotiations

This commit is contained in:
David Zhao
2021-02-02 01:16:13 -08:00
parent 70574deaf7
commit a4266478c5
5 changed files with 78 additions and 2 deletions
+3
View File
@@ -109,6 +109,9 @@ func (t *MediaTrack) AddSubscriber(participant types.Participant) error {
// don't subscribe to the same track multiple times // don't subscribe to the same track multiple times
if existingDt != nil { if existingDt != nil {
logger.Warnw("participant already subscribed to track",
"participant", participant.Identity(),
"track", existingDt.ID())
return nil return nil
} }
+3 -1
View File
@@ -134,6 +134,7 @@ func NewParticipant(identity string, pc types.PeerConnection, rs routing.Message
// only set after answered // only set after answered
pc.OnNegotiationNeeded(func() { pc.OnNegotiationNeeded(func() {
logger.Debugw("negotiation needed", "participant", participant.Identity())
if !participant.IsReady() { if !participant.IsReady() {
// ignore negotiation requests before connected // ignore negotiation requests before connected
return return
@@ -462,6 +463,8 @@ func (p *ParticipantImpl) negotiate() {
// skip when disconnected // skip when disconnected
return return
} }
logger.Debugw("starting server negotiation", "participant", p.Identity())
p.negotiationCond.L.Lock() p.negotiationCond.L.Lock()
for p.negotiationState != negotiationStateNone { for p.negotiationState != negotiationStateNone {
p.negotiationCond.Wait() p.negotiationCond.Wait()
@@ -469,7 +472,6 @@ func (p *ParticipantImpl) negotiate() {
} }
p.negotiationCond.L.Unlock() p.negotiationCond.L.Unlock()
logger.Debugw("starting server negotiation", "participant", p.Identity())
offer, err := p.peerConn.CreateOffer(nil) offer, err := p.peerConn.CreateOffer(nil)
if err != nil { if err != nil {
logger.Errorw("could not create offer", "err", err) logger.Errorw("could not create offer", "err", err)
+1
View File
@@ -114,6 +114,7 @@ type Receiver interface {
// using this interface to make testing more practical // using this interface to make testing more practical
//counterfeiter:generate . DownTrack //counterfeiter:generate . DownTrack
type DownTrack interface { type DownTrack interface {
ID() string
WriteRTP(p rtp.Packet) error WriteRTP(p rtp.Packet) error
IsBound() bool IsBound() bool
Close() Close()
@@ -35,6 +35,16 @@ type FakeDownTrack struct {
getNACKSeqNoReturnsOnCall map[int]struct { getNACKSeqNoReturnsOnCall map[int]struct {
result1 []uint16 result1 []uint16
} }
IDStub func() string
iDMutex sync.RWMutex
iDArgsForCall []struct {
}
iDReturns struct {
result1 string
}
iDReturnsOnCall map[int]struct {
result1 string
}
IsBoundStub func() bool IsBoundStub func() bool
isBoundMutex sync.RWMutex isBoundMutex sync.RWMutex
isBoundArgsForCall []struct { isBoundArgsForCall []struct {
@@ -253,6 +263,59 @@ func (fake *FakeDownTrack) GetNACKSeqNoReturnsOnCall(i int, result1 []uint16) {
}{result1} }{result1}
} }
func (fake *FakeDownTrack) ID() string {
fake.iDMutex.Lock()
ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)]
fake.iDArgsForCall = append(fake.iDArgsForCall, struct {
}{})
stub := fake.IDStub
fakeReturns := fake.iDReturns
fake.recordInvocation("ID", []interface{}{})
fake.iDMutex.Unlock()
if stub != nil {
return stub()
}
if specificReturn {
return ret.result1
}
return fakeReturns.result1
}
func (fake *FakeDownTrack) IDCallCount() int {
fake.iDMutex.RLock()
defer fake.iDMutex.RUnlock()
return len(fake.iDArgsForCall)
}
func (fake *FakeDownTrack) IDCalls(stub func() string) {
fake.iDMutex.Lock()
defer fake.iDMutex.Unlock()
fake.IDStub = stub
}
func (fake *FakeDownTrack) IDReturns(result1 string) {
fake.iDMutex.Lock()
defer fake.iDMutex.Unlock()
fake.IDStub = nil
fake.iDReturns = struct {
result1 string
}{result1}
}
func (fake *FakeDownTrack) IDReturnsOnCall(i int, result1 string) {
fake.iDMutex.Lock()
defer fake.iDMutex.Unlock()
fake.IDStub = nil
if fake.iDReturnsOnCall == nil {
fake.iDReturnsOnCall = make(map[int]struct {
result1 string
})
}
fake.iDReturnsOnCall[i] = struct {
result1 string
}{result1}
}
func (fake *FakeDownTrack) IsBound() bool { func (fake *FakeDownTrack) IsBound() bool {
fake.isBoundMutex.Lock() fake.isBoundMutex.Lock()
ret, specificReturn := fake.isBoundReturnsOnCall[len(fake.isBoundArgsForCall)] ret, specificReturn := fake.isBoundReturnsOnCall[len(fake.isBoundArgsForCall)]
@@ -652,6 +715,8 @@ func (fake *FakeDownTrack) Invocations() map[string][][]interface{} {
defer fake.createSourceDescriptionChunksMutex.RUnlock() defer fake.createSourceDescriptionChunksMutex.RUnlock()
fake.getNACKSeqNoMutex.RLock() fake.getNACKSeqNoMutex.RLock()
defer fake.getNACKSeqNoMutex.RUnlock() defer fake.getNACKSeqNoMutex.RUnlock()
fake.iDMutex.RLock()
defer fake.iDMutex.RUnlock()
fake.isBoundMutex.RLock() fake.isBoundMutex.RLock()
defer fake.isBoundMutex.RUnlock() defer fake.isBoundMutex.RUnlock()
fake.lastSSRCMutex.RLock() fake.lastSSRCMutex.RLock()
+6 -1
View File
@@ -26,7 +26,12 @@ func NewRTCService(conf *config.Config, roomStore RoomStore, roomManager *RoomMa
s := &RTCService{ s := &RTCService{
router: router, router: router,
roomManager: roomManager, roomManager: roomManager,
upgrader: websocket.Upgrader{}, upgrader: websocket.Upgrader{
// increase buffer size to avoid errors such as
// read: connection reset by peer
//ReadBufferSize: 10240,
//WriteBufferSize: 10240,
},
currentNode: currentNode, currentNode: currentNode,
isDev: conf.Development, isDev: conf.Development,
} }