Fix svc: Drop frame is earlier than current keyframe (#2196)
* Fix svc: Drop frame is earlier than current keyframe * Log detail of dependencydescriptor
This commit is contained in:
@@ -614,7 +614,12 @@ func (b *Buffer) getExtPacket(rtpPacket *rtp.Packet, arrivalTime time.Time, flow
|
|||||||
ep.Temporal = 0
|
ep.Temporal = 0
|
||||||
if b.ddParser != nil {
|
if b.ddParser != nil {
|
||||||
ddVal, videoLayer, err := b.ddParser.Parse(ep.Packet)
|
ddVal, videoLayer, err := b.ddParser.Parse(ep.Packet)
|
||||||
if err == nil && ddVal != nil {
|
if err != nil {
|
||||||
|
if err != ErrFrameEarlierThanKeyFrame {
|
||||||
|
b.logger.Warnw("could not parse dependency descriptor", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
} else if ddVal != nil {
|
||||||
ep.DependencyDescriptor = ddVal
|
ep.DependencyDescriptor = ddVal
|
||||||
ep.VideoLayer = videoLayer
|
ep.VideoLayer = videoLayer
|
||||||
// DD-TODO : notify active decode target change if changed.
|
// DD-TODO : notify active decode target change if changed.
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ import (
|
|||||||
"github.com/livekit/protocol/logger"
|
"github.com/livekit/protocol/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrFrameEarlierThanKeyFrame = fmt.Errorf("frame is earlier than current keyframe")
|
||||||
|
)
|
||||||
|
|
||||||
type DependencyDescriptorParser struct {
|
type DependencyDescriptorParser struct {
|
||||||
structure *dd.FrameDependencyStructure
|
structure *dd.FrameDependencyStructure
|
||||||
ddExtID uint8
|
ddExtID uint8
|
||||||
@@ -36,6 +40,7 @@ type DependencyDescriptorParser struct {
|
|||||||
seqWrapAround *utils.WrapAround[uint16, uint64]
|
seqWrapAround *utils.WrapAround[uint16, uint64]
|
||||||
frameWrapAround *utils.WrapAround[uint16, uint64]
|
frameWrapAround *utils.WrapAround[uint16, uint64]
|
||||||
structureExtSeq uint64
|
structureExtSeq uint64
|
||||||
|
structureExtFrameNum uint64
|
||||||
activeDecodeTargetsExtSeq uint64
|
activeDecodeTargetsExtSeq uint64
|
||||||
activeDecodeTargetsMask uint32
|
activeDecodeTargetsMask uint32
|
||||||
frameChecker *FrameIntegrityChecker
|
frameChecker *FrameIntegrityChecker
|
||||||
@@ -88,6 +93,12 @@ func (r *DependencyDescriptorParser) Parse(pkt *rtp.Packet) (*ExtDependencyDescr
|
|||||||
}
|
}
|
||||||
|
|
||||||
extFN := r.frameWrapAround.Update(ddVal.FrameNumber).ExtendedVal
|
extFN := r.frameWrapAround.Update(ddVal.FrameNumber).ExtendedVal
|
||||||
|
|
||||||
|
if extFN < r.structureExtFrameNum {
|
||||||
|
r.logger.Debugw("drop frame which is earlier than current structure", "frameNum", extFN, "structureFrameNum", r.structureExtFrameNum)
|
||||||
|
return nil, videoLayer, ErrFrameEarlierThanKeyFrame
|
||||||
|
}
|
||||||
|
|
||||||
r.frameChecker.AddPacket(extSeq, extFN, &ddVal)
|
r.frameChecker.AddPacket(extSeq, extFN, &ddVal)
|
||||||
|
|
||||||
extDD := &ExtDependencyDescriptor{
|
extDD := &ExtDependencyDescriptor{
|
||||||
@@ -97,11 +108,12 @@ func (r *DependencyDescriptorParser) Parse(pkt *rtp.Packet) (*ExtDependencyDescr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ddVal.AttachedStructure != nil {
|
if ddVal.AttachedStructure != nil {
|
||||||
r.logger.Debugw(fmt.Sprintf("parsed dependency descriptor\n%s", ddVal.String()))
|
r.logger.Debugw("parsed dependency descriptor", "extSeq", extSeq, "extFN", extFN, "structureID", ddVal.AttachedStructure.StructureId, "descriptor", ddVal.String())
|
||||||
if extSeq > r.structureExtSeq {
|
if extSeq > r.structureExtSeq {
|
||||||
r.structure = ddVal.AttachedStructure
|
r.structure = ddVal.AttachedStructure
|
||||||
r.decodeTargets = ProcessFrameDependencyStructure(ddVal.AttachedStructure)
|
r.decodeTargets = ProcessFrameDependencyStructure(ddVal.AttachedStructure)
|
||||||
r.structureExtSeq = extSeq
|
r.structureExtSeq = extSeq
|
||||||
|
r.structureExtFrameNum = extFN
|
||||||
extDD.StructureUpdated = true
|
extDD.StructureUpdated = true
|
||||||
extDD.ActiveDecodeTargetsUpdated = true
|
extDD.ActiveDecodeTargetsUpdated = true
|
||||||
// The dependency descriptor reader will always set ActiveDecodeTargetsBitmask for TemplateDependencyStructure is present,
|
// The dependency descriptor reader will always set ActiveDecodeTargetsBitmask for TemplateDependencyStructure is present,
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ func (fc *FrameChain) OnFrame(extFrameNum uint64, fd *dd.FrameDependencyTemplate
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(fd.ChainDiffs) <= fc.chainIdx {
|
||||||
|
fc.logger.Warnw("invalid frame chain diff", nil, "chanIdx", fc.chainIdx, "frame", extFrameNum, "fd", fd)
|
||||||
|
return fc.broken
|
||||||
|
}
|
||||||
|
|
||||||
// A decodable frame with frame_chain_fdiff equal to 0 indicates that the Chain is intact.
|
// A decodable frame with frame_chain_fdiff equal to 0 indicates that the Chain is intact.
|
||||||
if fd.ChainDiffs[fc.chainIdx] == 0 {
|
if fd.ChainDiffs[fc.chainIdx] == 0 {
|
||||||
if fc.broken {
|
if fc.broken {
|
||||||
|
|||||||
Reference in New Issue
Block a user