better debug logs around negotiations

This commit is contained in:
David Zhao
2021-02-02 00:40:55 -08:00
parent 712d0da6cc
commit 70574deaf7
7 changed files with 186 additions and 31 deletions
+4 -9
View File
@@ -25,6 +25,7 @@ import (
type RTCClient struct {
id string
identity string
conn *websocket.Conn
PeerConn *webrtc.PeerConnection
// sid => track
@@ -173,13 +174,10 @@ func (c *RTCClient) Run() error {
})
// create a data channel, in order to work
dc, err := c.PeerConn.CreateDataChannel("_private", nil)
_, err := c.PeerConn.CreateDataChannel("_private", nil)
if err != nil {
return err
}
dc.OnOpen(func() {
logger.Debugw("data channel open")
})
// run the session
for {
@@ -190,6 +188,7 @@ func (c *RTCClient) Run() error {
switch msg := res.Message.(type) {
case *livekit.SignalResponse_Join:
c.id = msg.Join.Participant.Sid
c.identity = msg.Join.Participant.Identity
c.lock.Lock()
for _, p := range msg.Join.OtherParticipants {
@@ -310,6 +309,7 @@ func (c *RTCClient) ReadResponse() (*livekit.SignalResponse, error) {
}
}
// TODO: this function is not thread safe, need to cleanup
func (c *RTCClient) SubscribedTracks() map[string][]*webrtc.TrackRemote {
return c.subscribedTracks
}
@@ -517,11 +517,6 @@ func (c *RTCClient) negotiate() error {
})
}
type logEntry struct {
msg string
args []interface{}
}
func (c *RTCClient) processTrack(track *webrtc.TrackRemote) {
lastUpdate := time.Time{}
pId, trackId := rtc.UnpackTrackId(track.ID())