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
c8de6620
Commit
c8de6620
authored
Oct 12, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send non-trivial bitmaps during NACK forwarding.
parent
9f6e23aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
12 deletions
+43
-12
rtpconn/rtpconn.go
rtpconn/rtpconn.go
+35
-9
rtpconn/rtpreader.go
rtpconn/rtpreader.go
+2
-1
rtpconn/rtpwriter.go
rtpconn/rtpwriter.go
+6
-2
No files found.
rtpconn/rtpconn.go
View file @
c8de6620
...
...
@@ -515,25 +515,51 @@ func sendFIR(pc *webrtc.PeerConnection, ssrc uint32, seqno uint8) error {
func
(
up
*
rtpUpConnection
)
sendNACK
(
track
*
rtpUpTrack
,
first
uint16
,
bitmap
uint16
)
error
{
if
!
track
.
hasRtcpFb
(
"nack"
,
""
)
{
return
nil
return
ErrUnsupportedFeedback
}
err
:=
sendNACK
(
up
.
pc
,
track
.
track
.
SSRC
(),
first
,
bitmap
)
err
:=
sendNACKs
(
up
.
pc
,
track
.
track
.
SSRC
(),
[]
rtcp
.
NackPair
{{
first
,
rtcp
.
PacketBitmap
(
bitmap
)}},
)
if
err
==
nil
{
track
.
cache
.
Expect
(
1
+
bits
.
OnesCount16
(
bitmap
))
}
return
err
}
func
sendNACK
(
pc
*
webrtc
.
PeerConnection
,
ssrc
uint32
,
first
uint16
,
bitmap
uint16
)
error
{
func
(
up
*
rtpUpConnection
)
sendNACKs
(
track
*
rtpUpTrack
,
seqnos
[]
uint16
)
error
{
count
:=
len
(
seqnos
)
if
count
==
0
{
return
nil
}
if
!
track
.
hasRtcpFb
(
"nack"
,
""
)
{
return
ErrUnsupportedFeedback
}
var
nacks
[]
rtcp
.
NackPair
for
len
(
seqnos
)
>
0
{
if
len
(
nacks
)
>=
240
{
log
.
Printf
(
"NACK: packet overflow"
)
break
}
var
f
,
b
uint16
f
,
b
,
seqnos
=
packetcache
.
ToBitmap
(
seqnos
)
nacks
=
append
(
nacks
,
rtcp
.
NackPair
{
f
,
rtcp
.
PacketBitmap
(
b
)})
}
err
:=
sendNACKs
(
up
.
pc
,
track
.
track
.
SSRC
(),
nacks
)
if
err
==
nil
{
track
.
cache
.
Expect
(
count
)
}
return
err
}
func
sendNACKs
(
pc
*
webrtc
.
PeerConnection
,
ssrc
uint32
,
nacks
[]
rtcp
.
NackPair
)
error
{
packet
:=
rtcp
.
Packet
(
&
rtcp
.
TransportLayerNack
{
MediaSSRC
:
ssrc
,
Nacks
:
[]
rtcp
.
NackPair
{
{
first
,
rtcp
.
PacketBitmap
(
bitmap
),
},
},
Nacks
:
nacks
,
},
)
return
pc
.
WriteRTCP
([]
rtcp
.
Packet
{
packet
})
...
...
rtpconn/rtpreader.go
View file @
c8de6620
...
...
@@ -32,6 +32,7 @@ func readLoop(conn *rtpUpConnection, track *rtpUpTrack) {
isvideo
:=
track
.
track
.
Kind
()
==
webrtc
.
RTPCodecTypeVideo
codec
:=
track
.
track
.
Codec
()
.
Name
sendNACK
:=
track
.
hasRtcpFb
(
"nack"
,
""
)
buf
:=
make
([]
byte
,
packetcache
.
BufSize
)
var
packet
rtp
.
Packet
for
{
...
...
@@ -87,7 +88,7 @@ func readLoop(conn *rtpUpConnection, track *rtpUpTrack) {
found
,
first
,
bitmap
:=
track
.
cache
.
BitmapGet
(
packet
.
SequenceNumber
-
unnacked
,
)
if
found
{
if
found
&&
sendNACK
{
err
:=
conn
.
sendNACK
(
track
,
first
,
bitmap
)
if
err
!=
nil
{
log
.
Printf
(
"%v"
,
err
)
...
...
rtpconn/rtpwriter.go
View file @
c8de6620
...
...
@@ -374,6 +374,10 @@ func nackWriter(conn *rtpUpConnection, track *rtpUpTrack) {
track
.
bufferedNACKs
=
nil
track
.
mu
.
Unlock
()
if
!
track
.
hasRtcpFb
(
"nack"
,
""
)
{
return
}
// drop any nacks before the last keyframe
var
cutoff
uint16
found
,
seqno
,
_
:=
track
.
cache
.
KeyframeSeqno
()
...
...
@@ -409,7 +413,7 @@ func nackWriter(conn *rtpUpConnection, track *rtpUpTrack) {
return
nacks
[
i
]
-
cutoff
<
nacks
[
j
]
-
cutoff
})
for
_
,
nack
:=
range
nacks
{
conn
.
sendNACK
(
track
,
nack
,
0
)
if
len
(
nacks
)
>
0
{
conn
.
sendNACK
s
(
track
,
nacks
)
}
}
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