mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Don't reduce video rate in large groups.
This commit is contained in:
parent
a8ca2e8559
commit
903e499dd6
3 changed files with 3 additions and 39 deletions
1
group.go
1
group.go
|
@ -45,7 +45,6 @@ type group struct {
|
||||||
name string
|
name string
|
||||||
dead bool
|
dead bool
|
||||||
description *groupDescription
|
description *groupDescription
|
||||||
videoCount uint32
|
|
||||||
locked uint32
|
locked uint32
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
|
|
11
rtpconn.go
11
rtpconn.go
|
@ -429,10 +429,6 @@ func newUpConn(c client, id string) (*rtpUpConnection, error) {
|
||||||
|
|
||||||
conn.tracks = append(conn.tracks, track)
|
conn.tracks = append(conn.tracks, track)
|
||||||
|
|
||||||
if remote.Kind() == webrtc.RTPCodecTypeVideo {
|
|
||||||
atomic.AddUint32(&c.Group().videoCount, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
go readLoop(conn, track)
|
go readLoop(conn, track)
|
||||||
|
|
||||||
go rtcpUpListener(conn, track, receiver)
|
go rtcpUpListener(conn, track, receiver)
|
||||||
|
@ -1090,7 +1086,7 @@ func handleReport(track *rtpDownTrack, report rtcp.ReceptionReport, jiffies uint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUpTrack(track *rtpUpTrack, maxVideoRate uint64) uint64 {
|
func updateUpTrack(track *rtpUpTrack) uint64 {
|
||||||
now := rtptime.Jiffies()
|
now := rtptime.Jiffies()
|
||||||
|
|
||||||
isvideo := track.track.Kind() == webrtc.RTPCodecTypeVideo
|
isvideo := track.track.Kind() == webrtc.RTPCodecTypeVideo
|
||||||
|
@ -1099,10 +1095,7 @@ func updateUpTrack(track *rtpUpTrack, maxVideoRate uint64) uint64 {
|
||||||
rate := ^uint64(0)
|
rate := ^uint64(0)
|
||||||
if isvideo {
|
if isvideo {
|
||||||
minrate = minVideoRate
|
minrate = minVideoRate
|
||||||
rate = maxVideoRate
|
rate = ^uint64(0)
|
||||||
if rate < minrate {
|
|
||||||
rate = minrate
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
local := track.getLocal()
|
local := track.getLocal()
|
||||||
var maxrto uint64
|
var maxrto uint64
|
||||||
|
|
30
webclient.go
30
webclient.go
|
@ -9,7 +9,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -228,7 +227,6 @@ func addUpConn(c *webClient, id string) (*rtpUpConnection, error) {
|
||||||
|
|
||||||
old := c.up[id]
|
old := c.up[id]
|
||||||
if old != nil {
|
if old != nil {
|
||||||
decrementVideoTracks(c, old)
|
|
||||||
old.pc.Close()
|
old.pc.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,8 +253,6 @@ func delUpConn(c *webClient, id string) bool {
|
||||||
delete(c.up, id)
|
delete(c.up, id)
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
|
|
||||||
decrementVideoTracks(c, conn)
|
|
||||||
|
|
||||||
go func(clients []client) {
|
go func(clients []client) {
|
||||||
for _, c := range clients {
|
for _, c := range clients {
|
||||||
c.pushConn(conn.id, nil, nil, "")
|
c.pushConn(conn.id, nil, nil, "")
|
||||||
|
@ -267,21 +263,6 @@ func delUpConn(c *webClient, id string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func decrementVideoTracks(c *webClient, conn *rtpUpConnection) {
|
|
||||||
conn.mu.Lock()
|
|
||||||
defer conn.mu.Unlock()
|
|
||||||
for _, track := range conn.tracks {
|
|
||||||
if track.track.Kind() == webrtc.RTPCodecTypeVideo {
|
|
||||||
count := atomic.AddUint32(&c.group.videoCount,
|
|
||||||
^uint32(0))
|
|
||||||
if count == ^uint32(0) {
|
|
||||||
log.Printf("Negative track count!")
|
|
||||||
atomic.StoreUint32(&c.group.videoCount, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getDownConn(c *webClient, id string) *rtpDownConnection {
|
func getDownConn(c *webClient, id string) *rtpDownConnection {
|
||||||
if c.down == nil {
|
if c.down == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -1042,21 +1023,12 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendRateUpdate(c *webClient) {
|
func sendRateUpdate(c *webClient) {
|
||||||
maxVideoRate := ^uint64(0)
|
|
||||||
count := atomic.LoadUint32(&c.group.videoCount)
|
|
||||||
if count >= 3 {
|
|
||||||
maxVideoRate = uint64(2000000 / math.Sqrt(float64(count)))
|
|
||||||
if maxVideoRate < minVideoRate {
|
|
||||||
maxVideoRate = minVideoRate
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
up := getUpConns(c)
|
up := getUpConns(c)
|
||||||
|
|
||||||
for _, u := range up {
|
for _, u := range up {
|
||||||
tracks := u.getTracks()
|
tracks := u.getTracks()
|
||||||
for _, t := range tracks {
|
for _, t := range tracks {
|
||||||
rate := updateUpTrack(t, maxVideoRate)
|
rate := updateUpTrack(t)
|
||||||
if !t.hasRtcpFb("goog-remb", "") {
|
if !t.hasRtcpFb("goog-remb", "") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue