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
f9edde65
Commit
f9edde65
authored
Jun 08, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Maintain time offsets on the sender side.
parent
917fa33d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
29 deletions
+37
-29
conn.go
conn.go
+1
-0
disk.go
disk.go
+3
-0
rtpconn.go
rtpconn.go
+33
-29
No files found.
conn.go
View file @
f9edde65
...
...
@@ -41,4 +41,5 @@ type downTrack interface {
WriteRTP
(
packat
*
rtp
.
Packet
)
error
Accumulate
(
bytes
uint32
)
GetMaxBitrate
(
now
uint64
)
uint64
setTimeOffset
(
ntp
uint64
,
rtp
uint32
)
}
disk.go
View file @
f9edde65
...
...
@@ -204,6 +204,9 @@ func newDiskConn(directory, label string, up upConnection, remoteTracks []upTrac
return
&
conn
,
nil
}
func
(
t
*
diskTrack
)
setTimeOffset
(
ntp
uint64
,
rtp
uint32
)
{
}
func
clonePacket
(
packet
*
rtp
.
Packet
)
*
rtp
.
Packet
{
buf
,
err
:=
packet
.
Marshal
()
if
err
!=
nil
{
...
...
rtpconn.go
View file @
f9edde65
...
...
@@ -78,6 +78,8 @@ type rtpDownTrack struct {
stats
*
receiverStats
srTime
uint64
srNTPTime
uint64
remoteNTPTime
uint64
remoteRTPTime
uint32
rtt
uint64
}
...
...
@@ -98,6 +100,11 @@ func (down *rtpDownTrack) GetMaxBitrate(now uint64) uint64 {
return
br2
}
func
(
down
*
rtpDownTrack
)
setTimeOffset
(
ntp
uint64
,
rtp
uint32
)
{
atomic
.
StoreUint64
(
&
down
.
remoteNTPTime
,
ntp
)
atomic
.
StoreUint32
(
&
down
.
remoteRTPTime
,
rtp
)
}
type
rtpDownConnection
struct
{
id
string
pc
*
webrtc
.
PeerConnection
...
...
@@ -554,11 +561,19 @@ func writeLoop(conn *rtpUpConnection, track *rtpUpTrack, ch <-chan packetIndex)
if
action
.
add
{
local
=
append
(
local
,
action
.
track
)
firSent
=
false
track
.
mu
.
Lock
()
ntp
:=
track
.
srNTPTime
rtp
:=
track
.
srRTPTime
track
.
mu
.
Unlock
()
if
ntp
!=
0
{
action
.
track
.
setTimeOffset
(
ntp
,
rtp
)
}
}
else
{
found
:=
false
for
i
,
t
:=
range
local
{
if
t
==
action
.
track
{
local
=
append
(
local
[
:
i
],
local
[
i
+
1
:
]
...
)
local
=
append
(
local
[
:
i
],
local
[
i
+
1
:
]
...
)
found
=
true
break
}
...
...
@@ -754,6 +769,10 @@ func rtcpUpListener(conn *rtpUpConnection, track *rtpUpTrack, r *webrtc.RTPRecei
track
.
srNTPTime
=
p
.
NTPTime
track
.
srRTPTime
=
p
.
RTPTime
track
.
mu
.
Unlock
()
local
:=
track
.
getLocal
()
for
_
,
l
:=
range
local
{
l
.
setTimeOffset
(
p
.
NTPTime
,
p
.
RTPTime
)
}
case
*
rtcp
.
SourceDescription
:
}
}
...
...
@@ -848,37 +867,22 @@ func sendSR(conn *rtpDownConnection) error {
for
_
,
t
:=
range
conn
.
tracks
{
clockrate
:=
t
.
track
.
Codec
()
.
ClockRate
remote
:=
t
.
remote
var
nowRTP
uint32
switch
r
:=
remote
.
(
type
)
{
case
*
rtpUpTrack
:
r
.
mu
.
Lock
()
lastTime
:=
r
.
srTime
srNTPTime
:=
r
.
srNTPTime
srRTPTime
:=
r
.
srRTPTime
r
.
mu
.
Unlock
()
if
lastTime
==
0
{
// we never got a remote SR, skip this track
continue
}
if
srNTPTime
!=
0
{
srTime
:=
rtptime
.
NTPToTime
(
srNTPTime
)
d
:=
now
.
Sub
(
srTime
)
if
d
>
0
&&
d
<
time
.
Hour
{
delay
:=
rtptime
.
FromDuration
(
d
,
clockrate
,
)
nowRTP
=
srRTPTime
+
uint32
(
delay
)
}
}
default
:
ts
,
ok
:=
remote
.
getTimestamp
()
if
!
ok
{
continue
}
nowRTP
=
ts
remoteNTP
:=
atomic
.
LoadUint64
(
&
t
.
remoteNTPTime
)
remoteRTP
:=
atomic
.
LoadUint32
(
&
t
.
remoteRTPTime
)
if
remoteNTP
==
0
{
// we never got a remote SR for this track
continue
}
srTime
:=
rtptime
.
NTPToTime
(
remoteNTP
)
d
:=
now
.
Sub
(
srTime
)
if
d
>
0
&&
d
<
time
.
Hour
{
delay
:=
rtptime
.
FromDuration
(
d
,
clockrate
,
)
nowRTP
=
remoteRTP
+
uint32
(
delay
)
}
p
,
b
:=
t
.
rate
.
Totals
()
...
...
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