mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Split out sending loop into a separate function.
This commit is contained in:
parent
9bd093e78c
commit
a813cc9ce4
1 changed files with 54 additions and 53 deletions
19
client.go
19
client.go
|
@ -286,10 +286,9 @@ func addUpConn(c *client, id string) (*upConnection, error) {
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
list := packetlist.New(32)
|
|
||||||
track := &upTrack{
|
track := &upTrack{
|
||||||
track: remote,
|
track: remote,
|
||||||
list: list,
|
list: packetlist.New(32),
|
||||||
maxBitrate: ^uint64(0),
|
maxBitrate: ^uint64(0),
|
||||||
}
|
}
|
||||||
u.tracks = append(u.tracks, track)
|
u.tracks = append(u.tracks, track)
|
||||||
|
@ -304,7 +303,13 @@ func addUpConn(c *client, id string) (*upConnection, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go upLoop(conn, track)
|
||||||
|
})
|
||||||
|
|
||||||
|
return conn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func upLoop(conn *upConnection, track *upTrack) {
|
||||||
buf := make([]byte, packetlist.BufSize)
|
buf := make([]byte, packetlist.BufSize)
|
||||||
var packet rtp.Packet
|
var packet rtp.Packet
|
||||||
var local []*downTrack
|
var local []*downTrack
|
||||||
|
@ -317,7 +322,7 @@ func addUpConn(c *client, id string) (*upConnection, error) {
|
||||||
localTime = now
|
localTime = now
|
||||||
}
|
}
|
||||||
|
|
||||||
i, err := remote.Read(buf)
|
i, err := track.track.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != io.EOF {
|
if err != io.EOF {
|
||||||
log.Printf("%v", err)
|
log.Printf("%v", err)
|
||||||
|
@ -342,7 +347,7 @@ func addUpConn(c *client, id string) (*upConnection, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.Store(packet.SequenceNumber, buf[:i])
|
track.list.Store(packet.SequenceNumber, buf[:i])
|
||||||
|
|
||||||
for _, l := range local {
|
for _, l := range local {
|
||||||
if l.muted() {
|
if l.muted() {
|
||||||
|
@ -354,10 +359,6 @@ func addUpConn(c *client, id string) (*upConnection, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
})
|
|
||||||
|
|
||||||
return conn, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func delUpConn(c *client, id string) {
|
func delUpConn(c *client, id string) {
|
||||||
|
|
Loading…
Reference in a new issue