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
Alain Takoudjou
galene
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) {
}
}
const
(
kfUnneeded
=
iota
kfNeededPLI
kfNeededFIR
kfNeededNewFIR
)
// rtpWriterLoop is the main loop of an rtpWriter.
func
rtpWriterLoop
(
writer
*
rtpWriter
,
up
*
rtpUpConnection
,
track
*
rtpUpTrack
)
{
defer
close
(
writer
.
done
)
...
...
@@ -241,9 +248,7 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
local
:=
make
([]
conn
.
DownTrack
,
0
)
// 3 means we want a new keyframe, 2 means we already sent FIR but
// haven't gotten a keyframe yet, 1 means we want a PLI.
kfNeeded
:=
0
kfNeeded
:=
kfUnneeded
for
{
select
{
...
...
@@ -283,7 +288,7 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
)
}
else
{
// Request a new keyframe
kfNeeded
=
3
kfNeeded
=
kfNeededNewFIR
}
}
else
{
// no keyframe yet, one should
...
...
@@ -328,7 +333,7 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
err
:=
l
.
WriteRTP
(
&
packet
)
if
err
!=
nil
{
if
err
==
conn
.
ErrKeyframeNeeded
{
kfNeeded
=
1
kfNeeded
=
kfNeededPLI
}
else
{
continue
}
...
...
@@ -336,27 +341,39 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
l
.
Accumulate
(
uint32
(
bytes
))
}
if
kfNeeded
>
0
{
if
kfNeeded
>
kfUnneeded
{
kf
:=
false
kfValid
:=
false
switch
codec
{
case
webrtc
.
VP8
:
kf
=
isVP8Keyframe
(
&
packet
)
default
:
kf
=
true
kfValid
=
true
}
if
kf
{
kfNeeded
=
0
kfNeeded
=
kfUnneeded
}
}
if
kfNeeded
>=
2
{
err
:=
up
.
sendFIR
(
track
,
kfNeeded
>=
3
)
if
err
==
ErrUnsupportedFeedback
{
if
kfNeeded
>=
kfNeededFIR
{
err
:=
up
.
sendFIR
(
track
,
kfNeeded
>=
kfNeededNewFIR
,
)
if
err
==
ErrUnsupportedFeedback
{
kfNeeded
=
kfNeededPLI
}
else
{
kfNeeded
=
kfNeededFIR
}
}
if
kfNeeded
==
kfNeededPLI
{
up
.
sendPLI
(
track
)
}
kfNeeded
=
2
}
else
if
kfNeeded
>
0
{
up
.
sendPLI
(
track
)
if
!
kfValid
{
// 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