mirror of
https://github.com/jech/galene.git
synced 2024-11-14 04:35:57 +01:00
Push a connection even if all tracks didn't arrive.
We used to push a connection when we got all tracks. However, it may happen that some tracks fail; in that case, the connection would never get pushed.
This commit is contained in:
parent
e5fec68acf
commit
3c04d48b85
1 changed files with 41 additions and 16 deletions
|
@ -279,6 +279,7 @@ type rtpUpConnection struct {
|
||||||
iceCandidates []*webrtc.ICECandidateInit
|
iceCandidates []*webrtc.ICECandidateInit
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
|
pushed bool
|
||||||
tracks []*rtpUpTrack
|
tracks []*rtpUpTrack
|
||||||
local []conn.Down
|
local []conn.Down
|
||||||
}
|
}
|
||||||
|
@ -372,6 +373,44 @@ func (up *rtpUpConnection) complete() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pushConnNow pushes a connection to all of the clients in a group
|
||||||
|
func pushConnNow(up *rtpUpConnection, g *group.Group, cs []group.Client) {
|
||||||
|
up.mu.Lock()
|
||||||
|
up.pushed = true
|
||||||
|
tracks := make([]conn.UpTrack, len(up.tracks))
|
||||||
|
for i, t := range up.tracks {
|
||||||
|
tracks[i] = t
|
||||||
|
}
|
||||||
|
up.mu.Unlock()
|
||||||
|
|
||||||
|
for _, c := range cs {
|
||||||
|
c.PushConn(g, up.id, up, tracks, up.label)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// pushConn schedules a call to pushConnNow
|
||||||
|
func pushConn(up *rtpUpConnection, g *group.Group, cs []group.Client) {
|
||||||
|
if up.complete() {
|
||||||
|
pushConnNow(up, g, cs)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
up.mu.Lock()
|
||||||
|
up.pushed = false
|
||||||
|
up.mu.Unlock()
|
||||||
|
|
||||||
|
go func(g *group.Group, cs []group.Client) {
|
||||||
|
time.Sleep(300 * time.Millisecond)
|
||||||
|
up.mu.Lock()
|
||||||
|
pushed := up.pushed
|
||||||
|
up.pushed = true
|
||||||
|
up.mu.Unlock()
|
||||||
|
if !pushed {
|
||||||
|
pushConnNow(up, g, cs)
|
||||||
|
}
|
||||||
|
}(g, cs)
|
||||||
|
}
|
||||||
|
|
||||||
func newUpConn(c group.Client, id string) (*rtpUpConnection, error) {
|
func newUpConn(c group.Client, id string) (*rtpUpConnection, error) {
|
||||||
pc, err := c.Group().API().NewPeerConnection(group.IceConfiguration())
|
pc, err := c.Group().API().NewPeerConnection(group.IceConfiguration())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -436,26 +475,12 @@ func newUpConn(c group.Client, id string) (*rtpUpConnection, error) {
|
||||||
|
|
||||||
go rtcpUpListener(up, track, receiver)
|
go rtcpUpListener(up, track, receiver)
|
||||||
|
|
||||||
complete := up.complete()
|
|
||||||
var tracks []conn.UpTrack
|
|
||||||
if complete {
|
|
||||||
tracks = make([]conn.UpTrack, len(up.tracks))
|
|
||||||
for i, t := range up.tracks {
|
|
||||||
tracks[i] = t
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// pushConn might need to take the lock
|
|
||||||
up.mu.Unlock()
|
up.mu.Unlock()
|
||||||
|
|
||||||
if complete {
|
pushConn(up, c.Group(), c.Group().GetClients(c))
|
||||||
clients := c.Group().GetClients(c)
|
|
||||||
for _, cc := range clients {
|
|
||||||
cc.PushConn(c.Group(), up.id, up, tracks, up.label)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
pushConn(up, c.Group(), c.Group().GetClients(c))
|
||||||
go rtcpUpSender(up)
|
go rtcpUpSender(up)
|
||||||
|
|
||||||
return up, nil
|
return up, nil
|
||||||
|
|
Loading…
Reference in a new issue