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
aae6b460
Commit
aae6b460
authored
Oct 27, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up keyframe handling in rtpwriter.
parent
6c6b0b39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
16 deletions
+33
-16
rtpconn/rtpwriter.go
rtpconn/rtpwriter.go
+33
-16
No files found.
rtpconn/rtpwriter.go
View file @
aae6b460
...
@@ -230,6 +230,13 @@ func sendKeyframe(kf []uint16, track conn.DownTrack, cache *packetcache.Cache) {
...
@@ -230,6 +230,13 @@ func sendKeyframe(kf []uint16, track conn.DownTrack, cache *packetcache.Cache) {
}
}
}
}
const
(
kfUnneeded
=
iota
kfNeededPLI
kfNeededFIR
kfNeededNewFIR
)
// rtpWriterLoop is the main loop of an rtpWriter.
// rtpWriterLoop is the main loop of an rtpWriter.
func
rtpWriterLoop
(
writer
*
rtpWriter
,
up
*
rtpUpConnection
,
track
*
rtpUpTrack
)
{
func
rtpWriterLoop
(
writer
*
rtpWriter
,
up
*
rtpUpConnection
,
track
*
rtpUpTrack
)
{
defer
close
(
writer
.
done
)
defer
close
(
writer
.
done
)
...
@@ -241,9 +248,7 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
...
@@ -241,9 +248,7 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
local
:=
make
([]
conn
.
DownTrack
,
0
)
local
:=
make
([]
conn
.
DownTrack
,
0
)
// 3 means we want a new keyframe, 2 means we already sent FIR but
kfNeeded
:=
kfUnneeded
// haven't gotten a keyframe yet, 1 means we want a PLI.
kfNeeded
:=
0
for
{
for
{
select
{
select
{
...
@@ -283,7 +288,7 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
...
@@ -283,7 +288,7 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
)
)
}
else
{
}
else
{
// Request a new keyframe
// Request a new keyframe
kfNeeded
=
3
kfNeeded
=
kfNeededNewFIR
}
}
}
else
{
}
else
{
// no keyframe yet, one should
// no keyframe yet, one should
...
@@ -328,7 +333,7 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
...
@@ -328,7 +333,7 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
err
:=
l
.
WriteRTP
(
&
packet
)
err
:=
l
.
WriteRTP
(
&
packet
)
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
conn
.
ErrKeyframeNeeded
{
if
err
==
conn
.
ErrKeyframeNeeded
{
kfNeeded
=
1
kfNeeded
=
kfNeededPLI
}
else
{
}
else
{
continue
continue
}
}
...
@@ -336,27 +341,39 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
...
@@ -336,27 +341,39 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
l
.
Accumulate
(
uint32
(
bytes
))
l
.
Accumulate
(
uint32
(
bytes
))
}
}
if
kfNeeded
>
0
{
if
kfNeeded
>
kfUnneeded
{
kf
:=
false
kf
:=
false
kfValid
:=
false
switch
codec
{
switch
codec
{
case
webrtc
.
VP8
:
case
webrtc
.
VP8
:
kf
=
isVP8Keyframe
(
&
packet
)
kf
=
isVP8Keyframe
(
&
packet
)
default
:
kfValid
=
true
kf
=
true
}
}
if
kf
{
if
kf
{
kfNeeded
=
0
kfNeeded
=
kfUnneeded
}
}
}
if
kfNeeded
>=
2
{
if
kfNeeded
>=
kfNeededFIR
{
err
:=
up
.
sendFIR
(
track
,
kfNeeded
>=
3
)
err
:=
up
.
sendFIR
(
if
err
==
ErrUnsupportedFeedback
{
track
,
kfNeeded
>=
kfNeededNewFIR
,
)
if
err
==
ErrUnsupportedFeedback
{
kfNeeded
=
kfNeededPLI
}
else
{
kfNeeded
=
kfNeededFIR
}
}
if
kfNeeded
==
kfNeededPLI
{
up
.
sendPLI
(
track
)
up
.
sendPLI
(
track
)
}
}
kfNeeded
=
2
}
else
if
kfNeeded
>
0
{
if
!
kfValid
{
up
.
sendPLI
(
track
)
// we cannot detect keyframes for
// this codec, reset our state
kfNeeded
=
kfUnneeded
}
}
}
}
}
}
}
...
...
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