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
2a516674
Commit
2a516674
authored
Oct 11, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Request a keyframe every 10s when saving to disk.
parent
5e845eb4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
diskwriter/diskwriter.go
diskwriter/diskwriter.go
+19
-4
No files found.
diskwriter/diskwriter.go
View file @
2a516674
...
...
@@ -2,11 +2,11 @@ package diskwriter
import
(
crand
"crypto/rand"
"encoding/hex"
"errors"
"fmt"
"os"
"path/filepath"
"encoding/hex"
"sync"
"time"
...
...
@@ -206,6 +206,8 @@ type diskTrack struct {
// bit 32 is a boolean indicating that the origin is valid
origin
uint64
lastKf
uint32
}
func
newDiskConn
(
directory
,
label
string
,
up
conn
.
Up
,
remoteTracks
[]
conn
.
UpTrack
)
(
*
diskConn
,
error
)
{
...
...
@@ -219,12 +221,12 @@ func newDiskConn(directory, label string, up conn.Up, remoteTracks []conn.UpTrac
var
builder
*
samplebuilder
.
SampleBuilder
switch
remote
.
Codec
()
.
Name
{
case
webrtc
.
Opus
:
builder
=
samplebuilder
.
New
(
1
6
,
&
codecs
.
OpusPacket
{})
builder
=
samplebuilder
.
New
(
1
28
,
&
codecs
.
OpusPacket
{})
case
webrtc
.
VP8
:
if
conn
.
hasVideo
{
return
nil
,
errors
.
New
(
"multiple video tracks not supported"
)
}
builder
=
samplebuilder
.
New
(
32
,
&
codecs
.
VP8Packet
{})
builder
=
samplebuilder
.
New
(
128
,
&
codecs
.
VP8Packet
{})
conn
.
hasVideo
=
true
}
track
:=
&
diskTrack
{
...
...
@@ -277,11 +279,16 @@ func (t *diskTrack) WriteRTP(packet *rtp.Packet) error {
return
nil
}
kfNeeded
:=
false
t
.
builder
.
Push
(
p
)
for
{
sample
,
ts
:=
t
.
builder
.
PopWithTimestamp
()
if
sample
==
nil
{
if
kfNeeded
{
return
conn
.
ErrKeyframeNeeded
}
return
nil
}
...
...
@@ -290,7 +297,7 @@ func (t *diskTrack) WriteRTP(packet *rtp.Packet) error {
switch
t
.
remote
.
Codec
()
.
Name
{
case
webrtc
.
VP8
:
if
len
(
sample
.
Data
)
<
1
{
return
nil
continue
}
keyframe
=
(
sample
.
Data
[
0
]
&
0x1
==
0
)
if
keyframe
{
...
...
@@ -298,6 +305,14 @@ func (t *diskTrack) WriteRTP(packet *rtp.Packet) error {
if
err
!=
nil
{
return
err
}
t
.
lastKf
=
ts
}
else
if
t
.
writer
!=
nil
{
// Request a keyframe every 10s
delta
:=
ts
-
t
.
lastKf
if
(
delta
&
0x80000000
)
==
0
&&
delta
>
10
*
90000
{
kfNeeded
=
true
}
}
default
:
if
t
.
writer
==
nil
{
...
...
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