1
Fork 0
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:
Juliusz Chroboczek 2020-06-12 17:27:38 +02:00
parent a8ca2e8559
commit 903e499dd6
3 changed files with 3 additions and 39 deletions

View file

@ -45,7 +45,6 @@ type group struct {
name string
dead bool
description *groupDescription
videoCount uint32
locked uint32
mu sync.Mutex

View file

@ -429,10 +429,6 @@ func newUpConn(c client, id string) (*rtpUpConnection, error) {
conn.tracks = append(conn.tracks, track)
if remote.Kind() == webrtc.RTPCodecTypeVideo {
atomic.AddUint32(&c.Group().videoCount, 1)
}
go readLoop(conn, track)
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()
isvideo := track.track.Kind() == webrtc.RTPCodecTypeVideo
@ -1099,10 +1095,7 @@ func updateUpTrack(track *rtpUpTrack, maxVideoRate uint64) uint64 {
rate := ^uint64(0)
if isvideo {
minrate = minVideoRate
rate = maxVideoRate
if rate < minrate {
rate = minrate
}
rate = ^uint64(0)
}
local := track.getLocal()
var maxrto uint64

View file

@ -9,7 +9,6 @@ import (
"encoding/json"
"errors"
"log"
"math"
"os"
"strings"
"sync"
@ -228,7 +227,6 @@ func addUpConn(c *webClient, id string) (*rtpUpConnection, error) {
old := c.up[id]
if old != nil {
decrementVideoTracks(c, old)
old.pc.Close()
}
@ -255,8 +253,6 @@ func delUpConn(c *webClient, id string) bool {
delete(c.up, id)
c.mu.Unlock()
decrementVideoTracks(c, conn)
go func(clients []client) {
for _, c := range clients {
c.pushConn(conn.id, nil, nil, "")
@ -267,21 +263,6 @@ func delUpConn(c *webClient, id string) bool {
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 {
if c.down == nil {
return nil
@ -1042,21 +1023,12 @@ func handleClientMessage(c *webClient, m clientMessage) error {
}
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)
for _, u := range up {
tracks := u.getTracks()
for _, t := range tracks {
rate := updateUpTrack(t, maxVideoRate)
rate := updateUpTrack(t)
if !t.hasRtcpFb("goog-remb", "") {
continue
}