Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
fd6b9f6b
Commit
fd6b9f6b
authored
May 09, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Limit the video rate when we have large numbers of presenters.
parent
ffee8044
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
13 deletions
+48
-13
client.go
client.go
+42
-13
group.go
group.go
+6
-0
No files found.
client.go
View file @
fd6b9f6b
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"errors"
"errors"
"io"
"io"
"log"
"log"
"math"
"math/bits"
"math/bits"
"os"
"os"
"strings"
"strings"
...
@@ -306,6 +307,9 @@ func addUpConn(c *client, id string) (*upConnection, error) {
...
@@ -306,6 +307,9 @@ func addUpConn(c *client, id string) (*upConnection, error) {
}
}
u
.
tracks
=
append
(
u
.
tracks
,
track
)
u
.
tracks
=
append
(
u
.
tracks
,
track
)
done
:=
len
(
u
.
tracks
)
>=
u
.
trackCount
done
:=
len
(
u
.
tracks
)
>=
u
.
trackCount
if
remote
.
Kind
()
==
webrtc
.
RTPCodecTypeVideo
{
atomic
.
AddUint32
(
&
c
.
group
.
videoCount
,
1
)
}
c
.
mu
.
Unlock
()
c
.
mu
.
Unlock
()
clients
:=
c
.
group
.
getClients
(
c
)
clients
:=
c
.
group
.
getClients
(
c
)
...
@@ -464,6 +468,17 @@ func delUpConn(c *client, id string) bool {
...
@@ -464,6 +468,17 @@ func delUpConn(c *client, id string) bool {
return
false
return
false
}
}
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
)
}
}
}
type
clientId
struct
{
type
clientId
struct
{
client
*
client
client
*
client
id
string
id
string
...
@@ -707,30 +722,35 @@ func trackKinds(down *downConnection) (audio bool, video bool) {
...
@@ -707,30 +722,35 @@ func trackKinds(down *downConnection) (audio bool, video bool) {
return
return
}
}
func
updateUpBitrate
(
up
*
upConnection
)
{
func
updateUpBitrate
(
up
*
upConnection
,
maxVideoRate
uint64
)
{
now
:=
mono
.
Microseconds
()
now
:=
mono
.
Microseconds
()
for
_
,
track
:=
range
up
.
tracks
{
for
_
,
track
:=
range
up
.
tracks
{
track
.
maxBitrate
=
^
uint64
(
0
)
isvideo
:=
track
.
track
.
Kind
()
==
webrtc
.
RTPCodecTypeVideo
minrate
:=
uint64
(
minAudioRate
)
rate
:=
^
uint64
(
0
)
if
isvideo
{
minrate
=
minVideoRate
rate
=
maxVideoRate
if
rate
<
minrate
{
rate
=
minrate
}
}
local
:=
track
.
getLocal
()
local
:=
track
.
getLocal
()
for
_
,
l
:=
range
local
{
for
_
,
l
:=
range
local
{
bitrate
:=
l
.
GetMaxBitrate
(
now
)
bitrate
:=
l
.
GetMaxBitrate
(
now
)
if
bitrate
==
^
uint64
(
0
)
{
if
bitrate
==
^
uint64
(
0
)
{
continue
continue
}
}
if
bitrate
<=
minrate
{
isvideo
:=
l
.
track
.
Kind
()
==
webrtc
.
RTPCodecTypeVideo
rate
=
minrate
minrate
:=
uint64
(
9600
)
break
if
isvideo
{
minrate
=
384000
}
if
bitrate
<
minrate
{
bitrate
=
minrate
}
}
if
track
.
maxBit
rate
>
bitrate
{
if
rate
>
bitrate
{
track
.
maxBit
rate
=
bitrate
rate
=
bitrate
}
}
}
}
track
.
maxBitrate
=
rate
}
}
}
}
...
@@ -1168,9 +1188,18 @@ func sendRateUpdate(c *client) {
...
@@ -1168,9 +1188,18 @@ func sendRateUpdate(c *client) {
}
}
rembs
:=
make
([]
remb
,
0
)
rembs
:=
make
([]
remb
,
0
)
maxVideoRate
:=
^
uint64
(
0
)
count
:=
atomic
.
LoadUint32
(
&
c
.
group
.
videoCount
)
if
count
>=
3
{
maxVideoRate
=
uint64
(
2000000
/
math
.
Sqrt
(
float64
(
count
)))
if
maxVideoRate
<
minVideoRate
{
maxVideoRate
=
minVideoRate
}
}
c
.
mu
.
Lock
()
c
.
mu
.
Lock
()
for
_
,
u
:=
range
c
.
up
{
for
_
,
u
:=
range
c
.
up
{
updateUpBitrate
(
u
)
updateUpBitrate
(
u
,
maxVideoRate
)
for
_
,
t
:=
range
u
.
tracks
{
for
_
,
t
:=
range
u
.
tracks
{
bitrate
:=
t
.
maxBitrate
bitrate
:=
t
.
maxBitrate
if
bitrate
==
^
uint64
(
0
)
{
if
bitrate
==
^
uint64
(
0
)
{
...
...
group.go
View file @
fd6b9f6b
...
@@ -162,10 +162,16 @@ type chatHistoryEntry struct {
...
@@ -162,10 +162,16 @@ type chatHistoryEntry struct {
me
bool
me
bool
}
}
const
(
minVideoRate
=
38400
minAudioRate
=
9600
)
type
group
struct
{
type
group
struct
{
name
string
name
string
dead
bool
dead
bool
description
*
groupDescription
description
*
groupDescription
videoCount
uint32
mu
sync
.
Mutex
mu
sync
.
Mutex
clients
map
[
string
]
*
client
clients
map
[
string
]
*
client
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment