mirror of
https://github.com/jech/galene.git
synced 2024-11-26 02:25:58 +01:00
Send FIR when WriteRTP returns ErrKeyframeNeeded.
This commit is contained in:
parent
88fbce262f
commit
d56628be15
2 changed files with 24 additions and 1 deletions
23
client.go
23
client.go
|
@ -471,11 +471,14 @@ func writeLoop(conn *upConnection, track *upTrack, ch <-chan packetIndex) {
|
||||||
|
|
||||||
local := make([]downTrack, 0)
|
local := make([]downTrack, 0)
|
||||||
|
|
||||||
|
firSent := false
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case action := <-track.localCh:
|
case action := <-track.localCh:
|
||||||
if action.add {
|
if action.add {
|
||||||
local = append(local, action.track)
|
local = append(local, action.track)
|
||||||
|
firSent = false
|
||||||
} else {
|
} else {
|
||||||
found := false
|
found := false
|
||||||
for i, t := range local {
|
for i, t := range local {
|
||||||
|
@ -505,16 +508,34 @@ func writeLoop(conn *upConnection, track *upTrack, ch <-chan packetIndex) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kfNeeded := false
|
||||||
|
|
||||||
for _, l := range local {
|
for _, l := range local {
|
||||||
err := l.WriteRTP(&packet)
|
err := l.WriteRTP(&packet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != io.ErrClosedPipe {
|
if err == ErrKeyframeNeeded {
|
||||||
|
kfNeeded = true
|
||||||
|
} else if err != io.ErrClosedPipe {
|
||||||
log.Printf("WriteRTP: %v", err)
|
log.Printf("WriteRTP: %v", err)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
l.Accumulate(uint32(bytes))
|
l.Accumulate(uint32(bytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if kfNeeded {
|
||||||
|
err := conn.sendFIR(track, !firSent)
|
||||||
|
if err == ErrUnsupportedFeedback {
|
||||||
|
err := conn.sendPLI(track)
|
||||||
|
if err != nil &&
|
||||||
|
err != ErrUnsupportedFeedback {
|
||||||
|
log.Printf("sendPLI: %v", err)
|
||||||
|
}
|
||||||
|
} else if err != nil {
|
||||||
|
log.Printf("sendFIR: %v", err)
|
||||||
|
}
|
||||||
|
firSent = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
conn.go
2
conn.go
|
@ -241,6 +241,8 @@ func (s *receiverStats) Get(now uint64) (uint8, uint32) {
|
||||||
return uint8(atomic.LoadUint32(&s.loss)), atomic.LoadUint32(&s.jitter)
|
return uint8(atomic.LoadUint32(&s.loss)), atomic.LoadUint32(&s.jitter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ErrKeyframeNeeded = errors.New("keyframe needed")
|
||||||
|
|
||||||
type downTrack interface {
|
type downTrack interface {
|
||||||
WriteRTP(packat *rtp.Packet) error
|
WriteRTP(packat *rtp.Packet) error
|
||||||
Accumulate(bytes uint32)
|
Accumulate(bytes uint32)
|
||||||
|
|
Loading…
Reference in a new issue