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
92de141b
Commit
92de141b
authored
May 02, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework sending of NACKs.
parent
98a1776c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
24 deletions
+36
-24
client.go
client.go
+3
-3
packetcache/packetcache.go
packetcache/packetcache.go
+16
-14
packetcache/packetcache_test.go
packetcache/packetcache_test.go
+17
-7
No files found.
client.go
View file @
92de141b
...
@@ -349,9 +349,9 @@ func upLoop(conn *upConnection, track *upTrack) {
...
@@ -349,9 +349,9 @@ func upLoop(conn *upConnection, track *upTrack) {
first
:=
track
.
cache
.
Store
(
packet
.
SequenceNumber
,
buf
[
:
bytes
])
first
:=
track
.
cache
.
Store
(
packet
.
SequenceNumber
,
buf
[
:
bytes
])
if
packet
.
SequenceNumber
-
first
>
24
{
if
packet
.
SequenceNumber
-
first
>
24
{
first
,
bitmap
:=
track
.
cache
.
BitmapGet
()
f
ound
,
f
irst
,
bitmap
:=
track
.
cache
.
BitmapGet
()
if
bitmap
!=
^
uint16
(
0
)
{
if
found
{
err
:=
conn
.
sendNACK
(
track
,
first
,
^
bitmap
)
err
:=
conn
.
sendNACK
(
track
,
first
,
bitmap
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Printf
(
"%v"
,
err
)
log
.
Printf
(
"%v"
,
err
)
}
}
...
...
packetcache/packetcache.go
View file @
92de141b
...
@@ -59,16 +59,6 @@ func (cache *Cache) set(seqno uint16) {
...
@@ -59,16 +59,6 @@ func (cache *Cache) set(seqno uint16) {
return
return
}
}
if
seqno
==
cache
.
first
{
cache
.
bitmap
>>=
1
cache
.
first
+=
1
for
(
cache
.
bitmap
&
1
)
==
1
{
cache
.
bitmap
>>=
1
cache
.
first
+=
1
}
return
}
if
seqno
-
cache
.
first
<
32
{
if
seqno
-
cache
.
first
<
32
{
cache
.
bitmap
|=
(
1
<<
uint16
(
seqno
-
cache
.
first
))
cache
.
bitmap
|=
(
1
<<
uint16
(
seqno
-
cache
.
first
))
return
return
...
@@ -140,16 +130,28 @@ func (cache *Cache) Get(seqno uint16) []byte {
...
@@ -140,16 +130,28 @@ func (cache *Cache) Get(seqno uint16) []byte {
return
nil
return
nil
}
}
// Shift 17 bits out of the bitmap, return first index and remaining 16.
// Shift 17 bits out of the bitmap. Return a boolean indicating if any
func
(
cache
*
Cache
)
BitmapGet
()
(
uint16
,
uint16
)
{
// were 0, the index of the first 0 bit, and a bitmap indicating any
// 0 bits after the first one.
func
(
cache
*
Cache
)
BitmapGet
()
(
bool
,
uint16
,
uint16
)
{
cache
.
mu
.
Lock
()
cache
.
mu
.
Lock
()
defer
cache
.
mu
.
Unlock
()
defer
cache
.
mu
.
Unlock
()
first
:=
cache
.
first
first
:=
cache
.
first
bitmap
:=
uint16
((
cache
.
bitmap
>>
1
)
&
0xFFFF
)
bitmap
:=
(
^
cache
.
bitmap
)
&
0x1FFFF
cache
.
bitmap
>>=
17
cache
.
bitmap
>>=
17
cache
.
first
+=
17
cache
.
first
+=
17
return
first
,
bitmap
if
bitmap
==
0
{
return
false
,
first
,
0
}
for
bitmap
&
1
==
0
{
bitmap
>>=
1
first
++
}
return
true
,
first
,
uint16
(
bitmap
>>
1
)
}
}
func
(
cache
*
Cache
)
GetStats
(
reset
bool
)
(
uint32
,
uint32
,
uint32
,
uint32
)
{
func
(
cache
*
Cache
)
GetStats
(
reset
bool
)
(
uint32
,
uint32
,
uint32
,
uint32
)
{
...
...
packetcache/packetcache_test.go
View file @
92de141b
...
@@ -109,10 +109,13 @@ func TestBitmapGet(t *testing.T) {
...
@@ -109,10 +109,13 @@ func TestBitmapGet(t *testing.T) {
pos
:=
uint16
(
42
)
pos
:=
uint16
(
42
)
for
cache
.
bitmap
!=
0
{
for
cache
.
bitmap
!=
0
{
first
,
bitmap
:=
cache
.
BitmapGet
()
f
ound
,
f
irst
,
bitmap
:=
cache
.
BitmapGet
()
if
first
<
pos
||
first
>=
pos
+
64
{
if
first
<
pos
||
first
>=
pos
+
64
{
t
.
Errorf
(
"First is %v, pos is %v"
,
first
,
pos
)
t
.
Errorf
(
"First is %v, pos is %v"
,
first
,
pos
)
}
}
if
!
found
{
t
.
Fatalf
(
"Didn't find any 0 bits"
)
}
value
>>=
(
first
-
pos
)
value
>>=
(
first
-
pos
)
pos
=
first
pos
=
first
if
(
value
&
1
)
!=
0
{
if
(
value
&
1
)
!=
0
{
...
@@ -120,11 +123,14 @@ func TestBitmapGet(t *testing.T) {
...
@@ -120,11 +123,14 @@ func TestBitmapGet(t *testing.T) {
}
}
value
>>=
1
value
>>=
1
pos
+=
1
pos
+=
1
if
bitmap
!=
uint16
(
value
&
0xFFFF
)
{
for
bitmap
!=
0
{
t
.
Errorf
(
"Got %b, expected %b"
,
bitmap
,
(
value
&
0xFFFF
))
if
uint8
(
bitmap
&
1
)
==
uint8
(
value
&
1
)
{
t
.
Errorf
(
"Bitmap mismatch"
)
}
bitmap
>>=
1
value
>>=
1
pos
+=
1
}
}
value
>>=
16
pos
+=
16
}
}
if
value
!=
0
{
if
value
!=
0
{
t
.
Errorf
(
"Value is %v"
,
value
)
t
.
Errorf
(
"Value is %v"
,
value
)
...
@@ -143,9 +149,13 @@ func TestBitmapPacket(t *testing.T) {
...
@@ -143,9 +149,13 @@ func TestBitmapPacket(t *testing.T) {
}
}
}
}
first
,
bitmap
:=
cache
.
BitmapGet
()
found
,
first
,
bitmap
:=
cache
.
BitmapGet
()
if
!
found
{
t
.
Fatalf
(
"Didn't find any 0 bits"
)
}
p
:=
rtcp
.
NackPair
{
first
,
rtcp
.
PacketBitmap
(
^
bitmap
)}
p
:=
rtcp
.
NackPair
{
first
,
rtcp
.
PacketBitmap
(
bitmap
)}
pl
:=
p
.
PacketList
()
pl
:=
p
.
PacketList
()
for
_
,
s
:=
range
pl
{
for
_
,
s
:=
range
pl
{
...
...
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