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
if existingDt != nil {
logger.Warnw("participant already subscribed to track",
"participant", participant.Identity(),
"track", existingDt.ID())
return nil
}
+3 -1
View File
@@ -134,6 +134,7 @@ func NewParticipant(identity string, pc types.PeerConnection, rs routing.Message
// only set after answered
pc.OnNegotiationNeeded(func() {
logger.Debugw("negotiation needed", "participant", participant.Identity())
if !participant.IsReady() {
// ignore negotiation requests before connected
return
@@ -462,6 +463,8 @@ func (p *ParticipantImpl) negotiate() {
// skip when disconnected
return
}
logger.Debugw("starting server negotiation", "participant", p.Identity())
p.negotiationCond.L.Lock()
for p.negotiationState != negotiationStateNone {
p.negotiationCond.Wait()
@@ -469,7 +472,6 @@ func (p *ParticipantImpl) negotiate() {
}
p.negotiationCond.L.Unlock()
logger.Debugw("starting server negotiation", "participant", p.Identity())
offer, err := p.peerConn.CreateOffer(nil)
if err != nil {
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
//counterfeiter:generate . DownTrack
type DownTrack interface {
ID() string
WriteRTP(p rtp.Packet) error
IsBound() bool
Close()
@@ -35,6 +35,16 @@ type FakeDownTrack struct {
getNACKSeqNoReturnsOnCall map[int]struct {
result1 []uint16
}
IDStub func() string
iDMutex sync.RWMutex
iDArgsForCall []struct {
}
iDReturns struct {
result1 string
}
iDReturnsOnCall map[int]struct {
result1 string
}
IsBoundStub func() bool
isBoundMutex sync.RWMutex
isBoundArgsForCall []struct {
@@ -253,6 +263,59 @@ func (fake *FakeDownTrack) GetNACKSeqNoReturnsOnCall(i int, result1 []uint16) {
}{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 {
fake.isBoundMutex.Lock()
ret, specificReturn := fake.isBoundReturnsOnCall[len(fake.isBoundArgsForCall)]
@@ -652,6 +715,8 @@ func (fake *FakeDownTrack) Invocations() map[string][][]interface{} {
defer fake.createSourceDescriptionChunksMutex.RUnlock()
fake.getNACKSeqNoMutex.RLock()
defer fake.getNACKSeqNoMutex.RUnlock()
fake.iDMutex.RLock()
defer fake.iDMutex.RUnlock()
fake.isBoundMutex.RLock()
defer fake.isBoundMutex.RUnlock()
fake.lastSSRCMutex.RLock()
+6 -1
View File
@@ -26,7 +26,12 @@ func NewRTCService(conf *config.Config, roomStore RoomStore, roomManager *RoomMa
s := &RTCService{
router: router,
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,
isDev: conf.Development,
}