mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Implement renegotiation in the up direction.
This commit is contained in:
parent
9506615272
commit
23c4aea58f
2 changed files with 20 additions and 13 deletions
|
@ -1243,6 +1243,7 @@ async function negotiate(id) {
|
||||||
id: id,
|
id: id,
|
||||||
labels: c.labelsByMid,
|
labels: c.labelsByMid,
|
||||||
offer: offer,
|
offer: offer,
|
||||||
|
renegotiate: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
32
webclient.go
32
webclient.go
|
@ -209,12 +209,7 @@ func getUpConns(c *webClient) []*rtpUpConnection {
|
||||||
return up
|
return up
|
||||||
}
|
}
|
||||||
|
|
||||||
func addUpConn(c *webClient, id string) (*rtpUpConnection, error) {
|
func addUpConn(c *webClient, id string) (*rtpUpConnection, bool, error) {
|
||||||
conn, err := newUpConn(c, id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
|
|
||||||
|
@ -222,13 +217,17 @@ func addUpConn(c *webClient, id string) (*rtpUpConnection, error) {
|
||||||
c.up = make(map[string]*rtpUpConnection)
|
c.up = make(map[string]*rtpUpConnection)
|
||||||
}
|
}
|
||||||
if c.down != nil && c.down[id] != nil {
|
if c.down != nil && c.down[id] != nil {
|
||||||
conn.pc.Close()
|
return nil, false, errors.New("Adding duplicate connection")
|
||||||
return nil, errors.New("Adding duplicate connection")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
old := c.up[id]
|
old := c.up[id]
|
||||||
if old != nil {
|
if old != nil {
|
||||||
old.pc.Close()
|
return old, false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
conn, err := newUpConn(c, id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
c.up[id] = conn
|
c.up[id] = conn
|
||||||
|
@ -237,7 +236,7 @@ func addUpConn(c *webClient, id string) (*rtpUpConnection, error) {
|
||||||
sendICE(c, id, candidate)
|
sendICE(c, id, candidate)
|
||||||
})
|
})
|
||||||
|
|
||||||
return conn, nil
|
return conn, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func delUpConn(c *webClient, id string) bool {
|
func delUpConn(c *webClient, id string) bool {
|
||||||
|
@ -444,11 +443,18 @@ func sendICE(c *webClient, id string, candidate *webrtc.ICECandidate) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func gotOffer(c *webClient, id string, offer webrtc.SessionDescription, labels map[string]string) error {
|
func gotOffer(c *webClient, id string, offer webrtc.SessionDescription, renegotiate bool, labels map[string]string) error {
|
||||||
up, err := addUpConn(c, id)
|
if !renegotiate {
|
||||||
|
// unless the client indicates that this is a compatible
|
||||||
|
// renegotiation, tear down the existing connection.
|
||||||
|
delUpConn(c, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
up, _, err := addUpConn(c, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.username != "" {
|
if c.username != "" {
|
||||||
up.label = c.username
|
up.label = c.username
|
||||||
}
|
}
|
||||||
|
@ -911,7 +917,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
||||||
if m.Offer == nil {
|
if m.Offer == nil {
|
||||||
return protocolError("null offer")
|
return protocolError("null offer")
|
||||||
}
|
}
|
||||||
err := gotOffer(c, m.Id, *m.Offer, m.Labels)
|
err := gotOffer(c, m.Id, *m.Offer, m.Renegotiate, m.Labels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("gotOffer: %v", err)
|
log.Printf("gotOffer: %v", err)
|
||||||
return failConnection(c, m.Id, "negotiation failed")
|
return failConnection(c, m.Id, "negotiation failed")
|
||||||
|
|
Loading…
Reference in a new issue