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
aa876bcd
Commit
aa876bcd
authored
Sep 03, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Propagate CNAME.
parent
5a91a7aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
25 deletions
+71
-25
conn.go
conn.go
+1
-0
disk.go
disk.go
+3
-0
rtpconn.go
rtpconn.go
+67
-25
No files found.
conn.go
View file @
aa876bcd
...
...
@@ -41,4 +41,5 @@ type downTrack interface {
WriteRTP
(
packat
*
rtp
.
Packet
)
error
Accumulate
(
bytes
uint32
)
setTimeOffset
(
ntp
uint64
,
rtp
uint32
)
setCname
(
string
)
}
disk.go
View file @
aa876bcd
...
...
@@ -216,6 +216,9 @@ func newDiskConn(directory, label string, up upConnection, remoteTracks []upTrac
func
(
t
*
diskTrack
)
setTimeOffset
(
ntp
uint64
,
rtp
uint32
)
{
}
func
(
t
*
diskTrack
)
setCname
(
string
)
{
}
func
clonePacket
(
packet
*
rtp
.
Packet
)
*
rtp
.
Packet
{
buf
,
err
:=
packet
.
Marshal
()
if
err
!=
nil
{
...
...
rtpconn.go
View file @
aa876bcd
...
...
@@ -79,6 +79,7 @@ type rtpDownTrack struct {
srNTPTime
uint64
remoteNTPTime
uint64
remoteRTPTime
uint32
cname
atomic
.
Value
rtt
uint64
}
...
...
@@ -95,6 +96,10 @@ func (down *rtpDownTrack) setTimeOffset(ntp uint64, rtp uint32) {
atomic
.
StoreUint32
(
&
down
.
remoteRTPTime
,
rtp
)
}
func
(
down
*
rtpDownTrack
)
setCname
(
cname
string
)
{
down
.
cname
.
Store
(
cname
)
}
type
rtpDownConnection
struct
{
id
string
pc
*
webrtc
.
PeerConnection
...
...
@@ -187,6 +192,7 @@ type rtpUpTrack struct {
writerDone
chan
struct
{}
mu
sync
.
Mutex
cname
string
local
[]
downTrack
srTime
uint64
srNTPTime
uint64
...
...
@@ -362,7 +368,7 @@ func getTrackMid(pc *webrtc.PeerConnection, track *webrtc.Track) string {
// called locked
func
(
up
*
rtpUpConnection
)
complete
()
bool
{
for
mid
,
_
:=
range
up
.
labels
{
for
mid
:=
range
up
.
labels
{
found
:=
false
for
_
,
t
:=
range
up
.
tracks
{
m
:=
getTrackMid
(
up
.
pc
,
t
.
track
)
...
...
@@ -566,10 +572,14 @@ func writeLoop(conn *rtpUpConnection, track *rtpUpTrack, ch <-chan packetIndex)
track
.
mu
.
Lock
()
ntp
:=
track
.
srNTPTime
rtp
:=
track
.
srRTPTime
cname
:=
track
.
cname
track
.
mu
.
Unlock
()
if
ntp
!=
0
{
action
.
track
.
setTimeOffset
(
ntp
,
rtp
)
}
if
cname
!=
""
{
action
.
track
.
setCname
(
cname
)
}
}
else
{
found
:=
false
for
i
,
t
:=
range
local
{
...
...
@@ -691,7 +701,7 @@ func sendFIR(pc *webrtc.PeerConnection, ssrc uint32, seqno uint8) error {
return
pc
.
WriteRTCP
([]
rtcp
.
Packet
{
&
rtcp
.
FullIntraRequest
{
FIR
:
[]
rtcp
.
FIREntry
{
rtcp
.
FIREntry
{
{
SSRC
:
ssrc
,
SequenceNumber
:
seqno
,
},
...
...
@@ -716,7 +726,7 @@ func sendNACK(pc *webrtc.PeerConnection, ssrc uint32, first uint16, bitmap uint1
&
rtcp
.
TransportLayerNack
{
MediaSSRC
:
ssrc
,
Nacks
:
[]
rtcp
.
NackPair
{
rtcp
.
NackPair
{
{
first
,
rtcp
.
PacketBitmap
(
bitmap
),
},
...
...
@@ -763,6 +773,7 @@ func rtcpUpListener(conn *rtpUpConnection, track *rtpUpTrack, r *webrtc.RTPRecei
now
:=
rtptime
.
Jiffies
()
for
_
,
p
:=
range
ps
{
local
:=
track
.
getLocal
()
switch
p
:=
p
.
(
type
)
{
case
*
rtcp
.
SenderReport
:
track
.
mu
.
Lock
()
...
...
@@ -773,11 +784,26 @@ 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
:
for
_
,
c
:=
range
p
.
Chunks
{
if
c
.
Source
!=
track
.
track
.
SSRC
()
{
continue
}
for
_
,
i
:=
range
c
.
Items
{
if
i
.
Type
!=
rtcp
.
SDESCNAME
{
continue
}
track
.
mu
.
Lock
()
track
.
cname
=
i
.
Text
track
.
mu
.
Unlock
()
for
_
,
l
:=
range
local
{
l
.
setCname
(
i
.
Text
)
}
}
}
}
}
...
...
@@ -910,30 +936,46 @@ func sendSR(conn *rtpDownConnection) error {
remoteNTP
:=
atomic
.
LoadUint64
(
&
t
.
remoteNTPTime
)
remoteRTP
:=
atomic
.
LoadUint32
(
&
t
.
remoteRTPTime
)
if
remoteNTP
==
0
{
// we never got a remote SR for this track
continue
if
remoteNTP
!=
0
{
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
()
packets
=
append
(
packets
,
&
rtcp
.
SenderReport
{
SSRC
:
t
.
track
.
SSRC
(),
NTPTime
:
nowNTP
,
RTPTime
:
nowRTP
,
PacketCount
:
p
,
OctetCount
:
b
,
})
atomic
.
StoreUint64
(
&
t
.
srTime
,
jiffies
)
atomic
.
StoreUint64
(
&
t
.
srNTPTime
,
nowNTP
)
}
srTime
:=
rtptime
.
NTPToTime
(
remoteNTP
)
d
:=
now
.
Sub
(
srTime
)
if
d
>
0
&&
d
<
time
.
Hour
{
delay
:=
rtptime
.
FromDuration
(
d
,
clockrate
,
cname
,
ok
:=
t
.
cname
.
Load
()
.
(
string
)
if
ok
{
item
:=
rtcp
.
SourceDescriptionItem
{
Type
:
rtcp
.
SDESCNAME
,
Text
:
cname
,
}
packets
=
append
(
packets
,
&
rtcp
.
SourceDescription
{
Chunks
:
[]
rtcp
.
SourceDescriptionChunk
{
{
Source
:
t
.
track
.
SSRC
(),
Items
:
[]
rtcp
.
SourceDescriptionItem
{
item
},
},
},
},
)
nowRTP
=
remoteRTP
+
uint32
(
delay
)
}
p
,
b
:=
t
.
rate
.
Totals
()
packets
=
append
(
packets
,
&
rtcp
.
SenderReport
{
SSRC
:
t
.
track
.
SSRC
(),
NTPTime
:
nowNTP
,
RTPTime
:
nowRTP
,
PacketCount
:
p
,
OctetCount
:
b
,
})
atomic
.
StoreUint64
(
&
t
.
srTime
,
jiffies
)
atomic
.
StoreUint64
(
&
t
.
srNTPTime
,
nowNTP
)
}
if
len
(
packets
)
==
0
{
...
...
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