Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sfu
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
Alain Takoudjou
sfu
Commits
3e305e98
Commit
3e305e98
authored
Jun 03, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use jiffies instead of microseconds.
parent
dddecd86
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
24 deletions
+25
-24
conn.go
conn.go
+12
-11
group.go
group.go
+3
-3
webclient.go
webclient.go
+10
-10
No files found.
conn.go
View file @
3e305e98
...
...
@@ -13,6 +13,7 @@ import (
"sfu/estimator"
"sfu/jitter"
"sfu/packetcache"
"sfu/rtptime"
"github.com/pion/rtp"
"github.com/pion/webrtc/v2"
...
...
@@ -223,42 +224,42 @@ func (up *upConnection) complete() bool {
}
type
bitrate
struct
{
bitrate
uint64
microsecond
s
uint64
bitrate
uint64
jiffie
s
uint64
}
const
receiverReportTimeout
=
8
000000
const
receiverReportTimeout
=
8
*
rtptime
.
JiffiesPerSec
func
(
br
*
bitrate
)
Set
(
bitrate
uint64
,
now
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
(
&
br
.
bitrate
,
bitrate
)
atomic
.
StoreUint64
(
&
br
.
microsecond
s
,
now
)
atomic
.
StoreUint64
(
&
br
.
jiffie
s
,
now
)
}
func
(
br
*
bitrate
)
Get
(
now
uint64
)
uint64
{
ts
:=
atomic
.
LoadUint64
(
&
br
.
microsecond
s
)
if
now
<
ts
||
now
>
ts
+
receiverReportTimeout
{
ts
:=
atomic
.
LoadUint64
(
&
br
.
jiffie
s
)
if
now
<
ts
||
now
-
ts
>
receiverReportTimeout
{
return
^
uint64
(
0
)
}
return
atomic
.
LoadUint64
(
&
br
.
bitrate
)
}
type
receiverStats
struct
{
loss
uint32
jitter
uint32
microsecond
s
uint64
loss
uint32
jitter
uint32
jiffie
s
uint64
}
func
(
s
*
receiverStats
)
Set
(
loss
uint8
,
jitter
uint32
,
now
uint64
)
{
atomic
.
StoreUint32
(
&
s
.
loss
,
uint32
(
loss
))
atomic
.
StoreUint32
(
&
s
.
jitter
,
jitter
)
atomic
.
StoreUint64
(
&
s
.
microsecond
s
,
now
)
atomic
.
StoreUint64
(
&
s
.
jiffie
s
,
now
)
}
func
(
s
*
receiverStats
)
Get
(
now
uint64
)
(
uint8
,
uint32
)
{
ts
:=
atomic
.
LoadUint64
(
&
s
.
microsecond
s
)
ts
:=
atomic
.
LoadUint64
(
&
s
.
jiffie
s
)
if
now
<
ts
||
now
>
ts
+
receiverReportTimeout
{
return
0
,
0
}
...
...
group.go
View file @
3e305e98
...
...
@@ -587,13 +587,13 @@ func getClientStats(c *webClient) clientStats {
for
_
,
down
:=
range
c
.
down
{
conns
:=
connStats
{
id
:
down
.
id
}
for
_
,
t
:=
range
down
.
tracks
{
us
:=
rtptime
.
Microsecond
s
()
loss
,
jitter
:=
t
.
stats
.
Get
(
u
s
)
jiffies
:=
rtptime
.
Jiffie
s
()
loss
,
jitter
:=
t
.
stats
.
Get
(
jiffie
s
)
j
:=
time
.
Duration
(
jitter
)
*
time
.
Second
/
time
.
Duration
(
t
.
track
.
Codec
()
.
ClockRate
)
conns
.
tracks
=
append
(
conns
.
tracks
,
trackStats
{
bitrate
:
uint64
(
t
.
rate
.
Estimate
())
*
8
,
maxBitrate
:
t
.
GetMaxBitrate
(
u
s
),
maxBitrate
:
t
.
GetMaxBitrate
(
jiffie
s
),
loss
:
uint8
(
uint32
(
loss
)
*
100
/
256
),
jitter
:
j
,
})
...
...
webclient.go
View file @
3e305e98
...
...
@@ -918,7 +918,7 @@ func rtcpDownListener(conn *rtpDownConnection, track *rtpDownTrack, s *webrtc.RT
}
case
*
rtcp
.
ReceiverEstimatedMaximumBitrate
:
track
.
maxREMBBitrate
.
Set
(
p
.
Bitrate
,
rtptime
.
Microsecond
s
(),
p
.
Bitrate
,
rtptime
.
Jiffie
s
(),
)
case
*
rtcp
.
ReceiverReport
:
for
_
,
r
:=
range
p
.
Reports
{
...
...
@@ -934,7 +934,7 @@ func rtcpDownListener(conn *rtpDownConnection, track *rtpDownTrack, s *webrtc.RT
}
case
*
rtcp
.
TransportLayerNack
:
maxBitrate
:=
track
.
GetMaxBitrate
(
rtptime
.
Microsecond
s
(),
rtptime
.
Jiffie
s
(),
)
bitrate
:=
track
.
rate
.
Estimate
()
if
uint64
(
bitrate
)
*
7
/
8
<
maxBitrate
{
...
...
@@ -946,9 +946,9 @@ func rtcpDownListener(conn *rtpDownConnection, track *rtpDownTrack, s *webrtc.RT
}
func
handleReport
(
track
*
rtpDownTrack
,
report
rtcp
.
ReceptionReport
)
{
now
:=
rtptime
.
Microsecond
s
()
track
.
stats
.
Set
(
report
.
FractionLost
,
report
.
Jitter
,
now
)
track
.
updateRate
(
report
.
FractionLost
,
now
)
jiffies
:=
rtptime
.
Jiffie
s
()
track
.
stats
.
Set
(
report
.
FractionLost
,
report
.
Jitter
,
jiffies
)
track
.
updateRate
(
report
.
FractionLost
,
jiffies
)
}
func
trackKinds
(
down
*
rtpDownConnection
)
(
audio
bool
,
video
bool
)
{
...
...
@@ -972,7 +972,7 @@ func trackKinds(down *rtpDownConnection) (audio bool, video bool) {
}
func
updateUpBitrate
(
up
*
upConnection
,
maxVideoRate
uint64
)
{
now
:=
rtptime
.
Microsecond
s
()
now
:=
rtptime
.
Jiffie
s
()
for
_
,
track
:=
range
up
.
tracks
{
isvideo
:=
track
.
track
.
Kind
()
==
webrtc
.
RTPCodecTypeVideo
...
...
@@ -1011,8 +1011,8 @@ func (up *upConnection) sendPLI(track *upTrack) error {
return
ErrUnsupportedFeedback
}
last
:=
atomic
.
LoadUint64
(
&
track
.
lastPLI
)
now
:=
rtptime
.
Microsecond
s
()
if
now
>=
last
&&
now
-
last
<
200000
{
now
:=
rtptime
.
Jiffie
s
()
if
now
>=
last
&&
now
-
last
<
rtptime
.
JiffiesPerSec
/
5
{
return
ErrRateLimited
}
atomic
.
StoreUint64
(
&
track
.
lastPLI
,
now
)
...
...
@@ -1039,8 +1039,8 @@ func (up *upConnection) sendFIR(track *upTrack, increment bool) error {
return
ErrUnsupportedFeedback
}
last
:=
atomic
.
LoadUint64
(
&
track
.
lastFIR
)
now
:=
rtptime
.
Microsecond
s
()
if
now
>=
last
&&
now
-
last
<
200000
{
now
:=
rtptime
.
Jiffie
s
()
if
now
>=
last
&&
now
-
last
<
rtptime
.
JiffiesPerSec
/
5
{
return
ErrRateLimited
}
atomic
.
StoreUint64
(
&
track
.
lastFIR
,
now
)
...
...
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