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
dddecd86
Commit
dddecd86
authored
Jun 03, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement jiffies.
parent
7ae9a9ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
rtptime/rtptime.go
rtptime/rtptime.go
+7
-0
rtptime/rtptime_test.go
rtptime/rtptime_test.go
+8
-1
No files found.
rtptime/rtptime.go
View file @
dddecd86
...
...
@@ -22,6 +22,13 @@ func Microseconds() uint64 {
return
Now
(
1000000
)
}
// JiffiesPerSec is the LCM of 48000, 96000 and 65536
const
JiffiesPerSec
=
24576000
func
Jiffies
()
uint64
{
return
Now
(
JiffiesPerSec
)
}
var
ntpEpoch
=
time
.
Date
(
1900
,
1
,
1
,
0
,
0
,
0
,
0
,
time
.
UTC
)
func
NTPToTime
(
ntp
uint64
)
time
.
Time
{
...
...
rtptime/rtptime_test.go
View file @
dddecd86
...
...
@@ -24,7 +24,7 @@ func differs(a, b, delta uint64) bool {
return
a
-
b
>=
delta
}
func
Test
Mono
(
t
*
testing
.
T
)
{
func
Test
Time
(
t
*
testing
.
T
)
{
a
:=
Now
(
48000
)
time
.
Sleep
(
4
*
time
.
Millisecond
)
b
:=
Now
(
48000
)
-
a
...
...
@@ -38,6 +38,13 @@ func TestMono(t *testing.T) {
if
differs
(
d
,
4000
,
1000
)
{
t
.
Errorf
(
"Expected %v, got %v"
,
4000
,
d
)
}
c
=
Jiffies
()
time
.
Sleep
(
time
.
Second
*
100000
/
JiffiesPerSec
)
d
=
Jiffies
()
-
c
if
differs
(
d
,
100000
,
10000
)
{
t
.
Errorf
(
"Expected %v, got %v"
,
4000
,
d
)
}
}
func
TestNTP
(
t
*
testing
.
T
)
{
...
...
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