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
5a1ef1dd
Commit
5a1ef1dd
authored
Apr 30, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a proper accessor for timestampedByterate.
parent
8fa68f96
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
23 deletions
+27
-23
client.go
client.go
+4
-22
group.go
group.go
+23
-1
No files found.
client.go
View file @
5a1ef1dd
...
@@ -579,12 +579,6 @@ func addDownTrack(c *client, id string, remoteTrack *upTrack, remoteConn *upConn
...
@@ -579,12 +579,6 @@ func addDownTrack(c *client, id string, remoteTrack *upTrack, remoteConn *upConn
return
conn
,
s
,
nil
return
conn
,
s
,
nil
}
}
var
epoch
=
time
.
Now
()
func
msSinceEpoch
()
uint64
{
return
uint64
(
time
.
Since
(
epoch
)
/
time
.
Millisecond
)
}
func
rtcpDownListener
(
g
*
group
,
conn
*
downConnection
,
track
*
downTrack
,
s
*
webrtc
.
RTPSender
)
{
func
rtcpDownListener
(
g
*
group
,
conn
*
downConnection
,
track
*
downTrack
,
s
*
webrtc
.
RTPSender
)
{
for
{
for
{
ps
,
err
:=
s
.
ReadRTCP
()
ps
,
err
:=
s
.
ReadRTCP
()
...
@@ -603,18 +597,7 @@ func rtcpDownListener(g *group, conn *downConnection, track *downTrack, s *webrt
...
@@ -603,18 +597,7 @@ func rtcpDownListener(g *group, conn *downConnection, track *downTrack, s *webrt
log
.
Printf
(
"sendPLI: %v"
,
err
)
log
.
Printf
(
"sendPLI: %v"
,
err
)
}
}
case
*
rtcp
.
ReceiverEstimatedMaximumBitrate
:
case
*
rtcp
.
ReceiverEstimatedMaximumBitrate
:
ms
:=
msSinceEpoch
()
track
.
maxBitrate
.
Set
(
p
.
Bitrate
,
msSinceEpoch
())
// this is racy -- a reader might read the
// data between the two writes. This shouldn't
// matter, we'll recover at the next sample.
atomic
.
StoreUint64
(
&
track
.
maxBitrate
.
bitrate
,
p
.
Bitrate
,
)
atomic
.
StoreUint64
(
&
track
.
maxBitrate
.
timestamp
,
uint64
(
ms
),
)
case
*
rtcp
.
ReceiverReport
:
case
*
rtcp
.
ReceiverReport
:
for
_
,
r
:=
range
p
.
Reports
{
for
_
,
r
:=
range
p
.
Reports
{
if
r
.
SSRC
==
track
.
track
.
SSRC
()
{
if
r
.
SSRC
==
track
.
track
.
SSRC
()
{
...
@@ -658,10 +641,8 @@ func updateUpBitrate(up *upConnection) {
...
@@ -658,10 +641,8 @@ func updateUpBitrate(up *upConnection) {
track
.
maxBitrate
=
^
uint64
(
0
)
track
.
maxBitrate
=
^
uint64
(
0
)
local
:=
track
.
getLocal
()
local
:=
track
.
getLocal
()
for
_
,
l
:=
range
local
{
for
_
,
l
:=
range
local
{
ms
:=
atomic
.
LoadUint64
(
&
l
.
maxBitrate
.
timestamp
)
bitrate
:=
l
.
maxBitrate
.
Get
(
now
)
bitrate
:=
atomic
.
LoadUint64
(
&
l
.
maxBitrate
.
bitrate
)
if
bitrate
==
^
uint64
(
0
)
{
loss
:=
atomic
.
LoadUint32
(
&
l
.
loss
)
if
now
<
ms
||
now
>
ms
+
5000
||
bitrate
==
0
{
continue
continue
}
}
...
@@ -673,6 +654,7 @@ func updateUpBitrate(up *upConnection) {
...
@@ -673,6 +654,7 @@ func updateUpBitrate(up *upConnection) {
minrate2
=
512000
minrate2
=
512000
}
}
if
bitrate
<
minrate2
{
if
bitrate
<
minrate2
{
loss
:=
atomic
.
LoadUint32
(
&
l
.
loss
)
if
loss
<=
13
{
if
loss
<=
13
{
// less than 10% loss, go ahead
// less than 10% loss, go ahead
bitrate
=
minrate2
bitrate
=
minrate2
...
...
group.go
View file @
5a1ef1dd
...
@@ -68,11 +68,33 @@ type upConnection struct {
...
@@ -68,11 +68,33 @@ type upConnection struct {
tracks
[]
*
upTrack
tracks
[]
*
upTrack
}
}
func
msSinceEpoch
()
uint64
{
return
uint64
(
time
.
Since
(
epoch
)
/
time
.
Millisecond
)
}
var
epoch
=
time
.
Now
()
type
timeStampedBitrate
struct
{
type
timeStampedBitrate
struct
{
bitrate
uint64
bitrate
uint64
timestamp
uint64
timestamp
uint64
}
}
func
(
tb
*
timeStampedBitrate
)
Set
(
bitrate
,
timestamp
uint64
)
{
// this is racy -- a reader might read the
// data between the two writes. This shouldn't
// matter, we'll recover at the next sample.
atomic
.
StoreUint64
(
&
tb
.
bitrate
,
bitrate
)
atomic
.
StoreUint64
(
&
tb
.
timestamp
,
timestamp
)
}
func
(
tb
*
timeStampedBitrate
)
Get
(
now
uint64
)
uint64
{
ts
:=
atomic
.
LoadUint64
(
&
tb
.
timestamp
)
if
now
<
ts
||
now
>
ts
+
1000
{
return
^
uint64
(
0
)
}
return
atomic
.
LoadUint64
(
&
tb
.
bitrate
)
}
type
downTrack
struct
{
type
downTrack
struct
{
track
*
webrtc
.
Track
track
*
webrtc
.
Track
remote
*
upTrack
remote
*
upTrack
...
@@ -695,7 +717,7 @@ func getClientStats(c *client) clientStats {
...
@@ -695,7 +717,7 @@ func getClientStats(c *client) clientStats {
loss
:=
atomic
.
LoadUint32
(
&
t
.
loss
)
loss
:=
atomic
.
LoadUint32
(
&
t
.
loss
)
conns
.
tracks
=
append
(
conns
.
tracks
,
trackStats
{
conns
.
tracks
=
append
(
conns
.
tracks
,
trackStats
{
bitrate
:
uint64
(
t
.
rate
.
Estimate
())
*
8
,
bitrate
:
uint64
(
t
.
rate
.
Estimate
())
*
8
,
maxBitrate
:
atomic
.
LoadUint64
(
&
t
.
maxBitrate
.
bitrate
),
maxBitrate
:
t
.
maxBitrate
.
Get
(
msSinceEpoch
()
),
loss
:
uint8
((
loss
*
100
)
/
256
),
loss
:
uint8
((
loss
*
100
)
/
256
),
})
})
}
}
...
...
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