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 {
...
@@ -41,4 +41,5 @@ type downTrack interface {
WriteRTP
(
packat
*
rtp
.
Packet
)
error
WriteRTP
(
packat
*
rtp
.
Packet
)
error
Accumulate
(
bytes
uint32
)
Accumulate
(
bytes
uint32
)
GetMaxBitrate
(
now
uint64
)
uint64
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
...
@@ -204,6 +204,9 @@ func newDiskConn(directory, label string, up upConnection, remoteTracks []upTrac
return
&
conn
,
nil
return
&
conn
,
nil
}
}
func
(
t
*
diskTrack
)
setTimeOffset
(
ntp
uint64
,
rtp
uint32
)
{
}
func
clonePacket
(
packet
*
rtp
.
Packet
)
*
rtp
.
Packet
{
func
clonePacket
(
packet
*
rtp
.
Packet
)
*
rtp
.
Packet
{
buf
,
err
:=
packet
.
Marshal
()
buf
,
err
:=
packet
.
Marshal
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
rtpconn.go
View file @
f9edde65
...
@@ -78,6 +78,8 @@ type rtpDownTrack struct {
...
@@ -78,6 +78,8 @@ type rtpDownTrack struct {
stats
*
receiverStats
stats
*
receiverStats
srTime
uint64
srTime
uint64
srNTPTime
uint64
srNTPTime
uint64
remoteNTPTime
uint64
remoteRTPTime
uint32
rtt
uint64
rtt
uint64
}
}
...
@@ -98,6 +100,11 @@ func (down *rtpDownTrack) GetMaxBitrate(now uint64) uint64 {
...
@@ -98,6 +100,11 @@ func (down *rtpDownTrack) GetMaxBitrate(now uint64) uint64 {
return
br2
return
br2
}
}
func
(
down
*
rtpDownTrack
)
setTimeOffset
(
ntp
uint64
,
rtp
uint32
)
{
atomic
.
StoreUint64
(
&
down
.
remoteNTPTime
,
ntp
)
atomic
.
StoreUint32
(
&
down
.
remoteRTPTime
,
rtp
)
}
type
rtpDownConnection
struct
{
type
rtpDownConnection
struct
{
id
string
id
string
pc
*
webrtc
.
PeerConnection
pc
*
webrtc
.
PeerConnection
...
@@ -554,11 +561,19 @@ func writeLoop(conn *rtpUpConnection, track *rtpUpTrack, ch <-chan packetIndex)
...
@@ -554,11 +561,19 @@ func writeLoop(conn *rtpUpConnection, track *rtpUpTrack, ch <-chan packetIndex)
if
action
.
add
{
if
action
.
add
{
local
=
append
(
local
,
action
.
track
)
local
=
append
(
local
,
action
.
track
)
firSent
=
false
firSent
=
false
track
.
mu
.
Lock
()
ntp
:=
track
.
srNTPTime
rtp
:=
track
.
srRTPTime
track
.
mu
.
Unlock
()
if
ntp
!=
0
{
action
.
track
.
setTimeOffset
(
ntp
,
rtp
)
}
}
else
{
}
else
{
found
:=
false
found
:=
false
for
i
,
t
:=
range
local
{
for
i
,
t
:=
range
local
{
if
t
==
action
.
track
{
if
t
==
action
.
track
{
local
=
append
(
local
[
:
i
],
local
[
i
+
1
:
]
...
)
local
=
append
(
local
[
:
i
],
local
[
i
+
1
:
]
...
)
found
=
true
found
=
true
break
break
}
}
...
@@ -754,6 +769,10 @@ func rtcpUpListener(conn *rtpUpConnection, track *rtpUpTrack, r *webrtc.RTPRecei
...
@@ -754,6 +769,10 @@ func rtcpUpListener(conn *rtpUpConnection, track *rtpUpTrack, r *webrtc.RTPRecei
track
.
srNTPTime
=
p
.
NTPTime
track
.
srNTPTime
=
p
.
NTPTime
track
.
srRTPTime
=
p
.
RTPTime
track
.
srRTPTime
=
p
.
RTPTime
track
.
mu
.
Unlock
()
track
.
mu
.
Unlock
()
local
:=
track
.
getLocal
()
for
_
,
l
:=
range
local
{
l
.
setTimeOffset
(
p
.
NTPTime
,
p
.
RTPTime
)
}
case
*
rtcp
.
SourceDescription
:
case
*
rtcp
.
SourceDescription
:
}
}
}
}
...
@@ -848,37 +867,22 @@ func sendSR(conn *rtpDownConnection) error {
...
@@ -848,37 +867,22 @@ func sendSR(conn *rtpDownConnection) error {
for
_
,
t
:=
range
conn
.
tracks
{
for
_
,
t
:=
range
conn
.
tracks
{
clockrate
:=
t
.
track
.
Codec
()
.
ClockRate
clockrate
:=
t
.
track
.
Codec
()
.
ClockRate
remote
:=
t
.
remote
var
nowRTP
uint32
var
nowRTP
uint32
switch
r
:=
remote
.
(
type
)
{
remoteNTP
:=
atomic
.
LoadUint64
(
&
t
.
remoteNTPTime
)
case
*
rtpUpTrack
:
remoteRTP
:=
atomic
.
LoadUint32
(
&
t
.
remoteRTPTime
)
r
.
mu
.
Lock
()
if
remoteNTP
==
0
{
lastTime
:=
r
.
srTime
// we never got a remote SR for this track
srNTPTime
:=
r
.
srNTPTime
continue
srRTPTime
:=
r
.
srRTPTime
}
r
.
mu
.
Unlock
()
srTime
:=
rtptime
.
NTPToTime
(
remoteNTP
)
if
lastTime
==
0
{
d
:=
now
.
Sub
(
srTime
)
// we never got a remote SR, skip this track
if
d
>
0
&&
d
<
time
.
Hour
{
continue
delay
:=
rtptime
.
FromDuration
(
}
d
,
clockrate
,
if
srNTPTime
!=
0
{
)
srTime
:=
rtptime
.
NTPToTime
(
srNTPTime
)
nowRTP
=
remoteRTP
+
uint32
(
delay
)
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
}
}
p
,
b
:=
t
.
rate
.
Totals
()
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