From 938d231b3067bdd91903cefe28ea923acaf23893 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sun, 13 Sep 2020 13:01:06 +0200 Subject: [PATCH] Make API a method of group. --- group.go | 4 ++++ rtpconn.go | 6 +++--- webclient.go | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/group.go b/group.go index 8a79fdc..86a2bd4 100644 --- a/group.go +++ b/group.go @@ -47,6 +47,10 @@ var groups struct { api *webrtc.API } +func (g *group) API() *webrtc.API { + return groups.api +} + func addGroup(name string, desc *groupDescription) (*group, error) { groups.mu.Lock() defer groups.mu.Unlock() diff --git a/rtpconn.go b/rtpconn.go index 28fccf1..5104b4d 100644 --- a/rtpconn.go +++ b/rtpconn.go @@ -109,8 +109,8 @@ type rtpDownConnection struct { iceCandidates []*webrtc.ICECandidateInit } -func newDownConn(id string, remote upConnection) (*rtpDownConnection, error) { - pc, err := groups.api.NewPeerConnection(iceConfiguration()) +func newDownConn(c client, id string, remote upConnection) (*rtpDownConnection, error) { + pc, err := c.Group().API().NewPeerConnection(iceConfiguration()) if err != nil { return nil, err } @@ -371,7 +371,7 @@ func (up *rtpUpConnection) complete() bool { } func newUpConn(c client, id string) (*rtpUpConnection, error) { - pc, err := groups.api.NewPeerConnection(iceConfiguration()) + pc, err := c.Group().API().NewPeerConnection(iceConfiguration()) if err != nil { return nil, err } diff --git a/webclient.go b/webclient.go index b83c77f..6ade2b3 100644 --- a/webclient.go +++ b/webclient.go @@ -302,7 +302,7 @@ func getConn(c *webClient, id string) iceConnection { } func addDownConn(c *webClient, id string, remote upConnection) (*rtpDownConnection, error) { - conn, err := newDownConn(id, remote) + conn, err := newDownConn(c, id, remote) if err != nil { return nil, err }