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
7ae9a9ea
Commit
7ae9a9ea
authored
Jun 03, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename mono to rtptime.
parent
e373054f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
22 deletions
+23
-22
group.go
group.go
+4
-3
jitter/jitter.go
jitter/jitter.go
+5
-5
rtptime/rtptime.go
rtptime/rtptime.go
+1
-1
rtptime/rtptime_test.go
rtptime/rtptime_test.go
+1
-1
webclient.go
webclient.go
+12
-12
No files found.
group.go
View file @
7ae9a9ea
...
...
@@ -16,7 +16,7 @@ import (
"sync/atomic"
"time"
"sfu/
mono
"
"sfu/
rtptime
"
"github.com/pion/webrtc/v2"
)
...
...
@@ -587,12 +587,13 @@ func getClientStats(c *webClient) clientStats {
for
_
,
down
:=
range
c
.
down
{
conns
:=
connStats
{
id
:
down
.
id
}
for
_
,
t
:=
range
down
.
tracks
{
loss
,
jitter
:=
t
.
stats
.
Get
(
mono
.
Microseconds
())
us
:=
rtptime
.
Microseconds
()
loss
,
jitter
:=
t
.
stats
.
Get
(
us
)
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
(
mono
.
Microseconds
()
),
maxBitrate
:
t
.
GetMaxBitrate
(
us
),
loss
:
uint8
(
uint32
(
loss
)
*
100
/
256
),
jitter
:
j
,
})
...
...
jitter/jitter.go
View file @
7ae9a9ea
...
...
@@ -3,13 +3,13 @@ package jitter
import
(
"sync/atomic"
"sfu/
mono
"
"sfu/
rtptime
"
)
type
Estimator
struct
{
hz
uint32
timestamp
uint32
time
uint32
time
uint32
jitter
uint32
// atomic
}
...
...
@@ -25,11 +25,11 @@ func (e *Estimator) accumulate(timestamp, now uint32) {
}
d
:=
uint32
((
e
.
time
-
now
)
-
(
e
.
timestamp
-
timestamp
))
if
d
&
0x80000000
!=
0
{
if
d
&
0x80000000
!=
0
{
d
=
uint32
(
-
int32
(
d
))
}
oldjitter
:=
atomic
.
LoadUint32
(
&
e
.
jitter
)
jitter
:=
(
oldjitter
*
15
+
d
)
/
16
jitter
:=
(
oldjitter
*
15
+
d
)
/
16
atomic
.
StoreUint32
(
&
e
.
jitter
,
jitter
)
e
.
timestamp
=
timestamp
...
...
@@ -37,7 +37,7 @@ func (e *Estimator) accumulate(timestamp, now uint32) {
}
func
(
e
*
Estimator
)
Accumulate
(
timestamp
uint32
)
{
e
.
accumulate
(
timestamp
,
uint32
(
mono
.
Now
(
e
.
hz
)))
e
.
accumulate
(
timestamp
,
uint32
(
rtptime
.
Now
(
e
.
hz
)))
}
func
(
e
*
Estimator
)
Jitter
()
uint32
{
...
...
mono/mono
.go
→
rtptime/rtptime
.go
View file @
7ae9a9ea
package
mono
package
rtptime
import
(
"time"
...
...
mono/mono
_test.go
→
rtptime/rtptime
_test.go
View file @
7ae9a9ea
package
mono
package
rtptime
import
(
"testing"
...
...
webclient.go
View file @
7ae9a9ea
...
...
@@ -20,7 +20,7 @@ import (
"sfu/estimator"
"sfu/jitter"
"sfu/
mono
"
"sfu/
rtptime
"
"sfu/packetcache"
"github.com/gorilla/websocket"
...
...
@@ -559,7 +559,7 @@ func rtcpUpListener(conn *upConnection, track *upTrack, r *webrtc.RTPReceiver) {
switch
p
:=
p
.
(
type
)
{
case
*
rtcp
.
SenderReport
:
track
.
mu
.
Lock
()
track
.
srTime
=
mono
.
Now
(
0x10000
)
track
.
srTime
=
rtptime
.
Now
(
0x10000
)
track
.
srNTPTime
=
p
.
NTPTime
track
.
srRTPTime
=
p
.
RTPTime
track
.
mu
.
Unlock
()
...
...
@@ -574,7 +574,7 @@ func sendRR(conn *upConnection) error {
return
nil
}
now
:=
mono
.
Now
(
0x10000
)
now
:=
rtptime
.
Now
(
0x10000
)
reports
:=
make
([]
rtcp
.
ReceptionReport
,
0
,
len
(
conn
.
tracks
))
for
_
,
t
:=
range
conn
.
tracks
{
...
...
@@ -631,7 +631,7 @@ func sendSR(conn *rtpDownConnection) error {
packets
:=
make
([]
rtcp
.
Packet
,
0
,
len
(
conn
.
tracks
))
now
:=
time
.
Now
()
nowNTP
:=
mono
.
TimeToNTP
(
now
)
nowNTP
:=
rtptime
.
TimeToNTP
(
now
)
for
_
,
t
:=
range
conn
.
tracks
{
clockrate
:=
t
.
track
.
Codec
()
.
ClockRate
...
...
@@ -643,10 +643,10 @@ func sendSR(conn *rtpDownConnection) error {
nowRTP
:=
srRTPTime
if
srNTPTime
!=
0
{
srTime
:=
mono
.
NTPToTime
(
srNTPTime
)
srTime
:=
rtptime
.
NTPToTime
(
srNTPTime
)
delay
:=
now
.
Sub
(
srTime
)
if
delay
>
0
&&
delay
<
time
.
Hour
{
d
:=
mono
.
FromDuration
(
delay
,
clockrate
)
d
:=
rtptime
.
FromDuration
(
delay
,
clockrate
)
nowRTP
=
srRTPTime
+
uint32
(
d
)
}
}
...
...
@@ -918,7 +918,7 @@ func rtcpDownListener(conn *rtpDownConnection, track *rtpDownTrack, s *webrtc.RT
}
case
*
rtcp
.
ReceiverEstimatedMaximumBitrate
:
track
.
maxREMBBitrate
.
Set
(
p
.
Bitrate
,
mono
.
Microseconds
(),
p
.
Bitrate
,
rtptime
.
Microseconds
(),
)
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
(
mono
.
Microseconds
(),
rtptime
.
Microseconds
(),
)
bitrate
:=
track
.
rate
.
Estimate
()
if
uint64
(
bitrate
)
*
7
/
8
<
maxBitrate
{
...
...
@@ -946,7 +946,7 @@ func rtcpDownListener(conn *rtpDownConnection, track *rtpDownTrack, s *webrtc.RT
}
func
handleReport
(
track
*
rtpDownTrack
,
report
rtcp
.
ReceptionReport
)
{
now
:=
mono
.
Microseconds
()
now
:=
rtptime
.
Microseconds
()
track
.
stats
.
Set
(
report
.
FractionLost
,
report
.
Jitter
,
now
)
track
.
updateRate
(
report
.
FractionLost
,
now
)
}
...
...
@@ -972,7 +972,7 @@ func trackKinds(down *rtpDownConnection) (audio bool, video bool) {
}
func
updateUpBitrate
(
up
*
upConnection
,
maxVideoRate
uint64
)
{
now
:=
mono
.
Microseconds
()
now
:=
rtptime
.
Microseconds
()
for
_
,
track
:=
range
up
.
tracks
{
isvideo
:=
track
.
track
.
Kind
()
==
webrtc
.
RTPCodecTypeVideo
...
...
@@ -1011,7 +1011,7 @@ func (up *upConnection) sendPLI(track *upTrack) error {
return
ErrUnsupportedFeedback
}
last
:=
atomic
.
LoadUint64
(
&
track
.
lastPLI
)
now
:=
mono
.
Microseconds
()
now
:=
rtptime
.
Microseconds
()
if
now
>=
last
&&
now
-
last
<
200000
{
return
ErrRateLimited
}
...
...
@@ -1039,7 +1039,7 @@ func (up *upConnection) sendFIR(track *upTrack, increment bool) error {
return
ErrUnsupportedFeedback
}
last
:=
atomic
.
LoadUint64
(
&
track
.
lastFIR
)
now
:=
mono
.
Microseconds
()
now
:=
rtptime
.
Microseconds
()
if
now
>=
last
&&
now
-
last
<
200000
{
return
ErrRateLimited
}
...
...
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