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
7665067a
Commit
7665067a
authored
May 17, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rate-limit keyframe requests in disk writer.
We were requesting two keyframes in a row.
parent
d94e5583
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
18 deletions
+13
-18
diskwriter/diskwriter.go
diskwriter/diskwriter.go
+13
-18
No files found.
diskwriter/diskwriter.go
View file @
7665067a
...
...
@@ -259,8 +259,9 @@ type diskTrack struct {
// bit 32 is a boolean indicating that the origin is valid
origin
uint64
lastKf
uint32
savedKf
*
rtp
.
Packet
kfRequested
time
.
Time
lastKf
time
.
Time
savedKf
*
rtp
.
Packet
}
func
newDiskConn
(
client
*
Client
,
directory
string
,
up
conn
.
Up
,
remoteTracks
[]
conn
.
UpTrack
)
(
*
diskConn
,
error
)
{
...
...
@@ -435,7 +436,6 @@ func keyframeDimensions(codec string, data []byte, packet *rtp.Packet) (uint32,
}
func
(
t
*
diskTrack
)
Write
(
buf
[]
byte
)
(
int
,
error
)
{
// since we call initWriter, we take the connection lock for simplicity.
t
.
conn
.
mu
.
Lock
()
defer
t
.
conn
.
mu
.
Unlock
()
...
...
@@ -471,17 +471,11 @@ func (t *diskTrack) Write(buf []byte) (int, error) {
}
}
kfNeeded
:=
false
t
.
builder
.
Push
(
p
)
for
{
sample
,
ts
:=
t
.
builder
.
PopWithTimestamp
()
if
sample
==
nil
{
if
kfNeeded
{
t
.
remote
.
RequestKeyframe
()
return
0
,
nil
}
return
len
(
buf
),
nil
}
...
...
@@ -503,13 +497,6 @@ func (t *diskTrack) Write(buf []byte) (int, error) {
)
return
0
,
err
}
t
.
lastKf
=
ts
}
else
if
t
.
writer
!=
nil
{
// Request a keyframe every 4s
delta
:=
ts
-
t
.
lastKf
if
(
delta
&
0x80000000
)
!=
0
||
delta
>
4
*
90000
{
kfNeeded
=
true
}
}
}
else
{
if
t
.
writer
==
nil
{
...
...
@@ -526,13 +513,21 @@ func (t *diskTrack) Write(buf []byte) (int, error) {
}
}
if
t
.
writer
==
nil
{
if
!
keyframe
{
now
:=
time
.
Now
()
if
keyframe
{
t
.
lastKf
=
now
}
else
if
t
.
writer
==
nil
||
now
.
Sub
(
t
.
lastKf
)
>
4
*
time
.
Second
{
if
now
.
Sub
(
t
.
kfRequested
)
>
time
.
Second
{
t
.
remote
.
RequestKeyframe
()
t
.
kfRequested
=
now
}
return
0
,
nil
}
if
t
.
writer
==
nil
{
continue
}
if
t
.
origin
==
0
{
t
.
origin
=
uint64
(
ts
)
|
(
1
<<
32
)
}
...
...
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