diff --git a/rtpconn/rtpconn.go b/rtpconn/rtpconn.go index 00c4efd..f916694 100644 --- a/rtpconn/rtpconn.go +++ b/rtpconn/rtpconn.go @@ -411,7 +411,7 @@ func pushConn(up *rtpUpConnection, g *group.Group, cs []group.Client) { }(g, cs) } -func newUpConn(c group.Client, id string) (*rtpUpConnection, error) { +func newUpConn(c group.Client, id string, labels map[string]string) (*rtpUpConnection, error) { pc, err := c.Group().API().NewPeerConnection(group.IceConfiguration()) if err != nil { return nil, err @@ -437,7 +437,7 @@ func newUpConn(c group.Client, id string) (*rtpUpConnection, error) { return nil, err } - up := &rtpUpConnection{id: id, pc: pc} + up := &rtpUpConnection{id: id, pc: pc, labels: labels} pc.OnTrack(func(remote *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { up.mu.Lock() diff --git a/rtpconn/webclient.go b/rtpconn/webclient.go index 2a073df..6b3f1f3 100644 --- a/rtpconn/webclient.go +++ b/rtpconn/webclient.go @@ -204,7 +204,7 @@ func getUpConns(c *webClient) []*rtpUpConnection { return up } -func addUpConn(c *webClient, id string) (*rtpUpConnection, bool, error) { +func addUpConn(c *webClient, id string, labels map[string]string) (*rtpUpConnection, bool, error) { c.mu.Lock() defer c.mu.Unlock() @@ -220,7 +220,7 @@ func addUpConn(c *webClient, id string) (*rtpUpConnection, bool, error) { return old, false, nil } - conn, err := newUpConn(c, id) + conn, err := newUpConn(c, id, labels) if err != nil { return nil, false, err } @@ -481,7 +481,7 @@ func gotOffer(c *webClient, id string, offer webrtc.SessionDescription, renegoti delUpConn(c, id) } - up, isnew, err := addUpConn(c, id) + up, isnew, err := addUpConn(c, id, labels) if err != nil { return err } @@ -509,8 +509,6 @@ func gotOffer(c *webClient, id string, offer webrtc.SessionDescription, renegoti return err } - up.labels = labels - err = up.flushICECandidates() if err != nil { log.Printf("ICE: %v", err)