mirror of
https://github.com/jech/galene.git
synced 2024-11-10 02:35:58 +01:00
Delay rtcpUpSender until the connection is complete.
This avoids locking in sendRR.
This commit is contained in:
parent
7786aa12aa
commit
c4284a45c5
1 changed files with 5 additions and 10 deletions
15
webclient.go
15
webclient.go
|
@ -336,8 +336,6 @@ func addUpConn(c *webClient, id string) (*upConnection, error) {
|
||||||
sendICE(c, id, candidate)
|
sendICE(c, id, candidate)
|
||||||
})
|
})
|
||||||
|
|
||||||
go rtcpUpSender(c, conn)
|
|
||||||
|
|
||||||
pc.OnTrack(func(remote *webrtc.Track, receiver *webrtc.RTPReceiver) {
|
pc.OnTrack(func(remote *webrtc.Track, receiver *webrtc.RTPReceiver) {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
u, ok := c.up[id]
|
u, ok := c.up[id]
|
||||||
|
@ -395,6 +393,7 @@ func addUpConn(c *webClient, id string) (*upConnection, error) {
|
||||||
for _, cc := range clients {
|
for _, cc := range clients {
|
||||||
cc.pushConn(u, tracks, u.label)
|
cc.pushConn(u, tracks, u.label)
|
||||||
}
|
}
|
||||||
|
go rtcpUpSender(conn)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -569,10 +568,8 @@ func rtcpUpListener(conn *upConnection, track *upTrack, r *webrtc.RTPReceiver) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendRR(c *webClient, conn *upConnection) error {
|
func sendRR(conn *upConnection) error {
|
||||||
c.mu.Lock()
|
|
||||||
if len(conn.tracks) == 0 {
|
if len(conn.tracks) == 0 {
|
||||||
c.mu.Unlock()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,25 +597,23 @@ func sendRR(c *webClient, conn *upConnection) error {
|
||||||
Delay: delay,
|
Delay: delay,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
c.mu.Unlock()
|
|
||||||
|
|
||||||
return conn.pc.WriteRTCP([]rtcp.Packet{
|
return conn.pc.WriteRTCP([]rtcp.Packet{
|
||||||
&rtcp.ReceiverReport{
|
&rtcp.ReceiverReport{
|
||||||
SSRC: 1,
|
|
||||||
Reports: reports,
|
Reports: reports,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func rtcpUpSender(c *webClient, conn *upConnection) {
|
func rtcpUpSender(conn *upConnection) {
|
||||||
for {
|
for {
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
err := sendRR(c, conn)
|
err := sendRR(conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF || err == io.ErrClosedPipe {
|
if err == io.EOF || err == io.ErrClosedPipe {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Printf("WriteRTCP: %v", err)
|
log.Printf("sendRR: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue