Documentation
¶
Overview ¶
Package flexfec implements a FlexFEC-03 decoder used to recover RTP packets lost on the publisher leg before they are forwarded downstream. https://datatracker.ietf.org/doc/html/draft-ietf-payload-flexible-fec-scheme-03
The recovery logic is ported from pion/interceptor pkg/flexfec (https://github.com/pion/interceptor, MIT License, Copyright The Pion community), which is itself modeled on libwebrtc's ForwardErrorCorrection receiver. Deviations from the pion implementation:
- FEC packets are deep-copied only when retained (callers reuse packet memory), while protected media is read from the owning packet store
- packet masks are expanded on demand instead of retaining per-packet protection entries
- recovery XORs the stored RTP wire representation directly
- failed recoveries are not emitted as empty packets
- usage counters for metrics
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder recovers lost media packets of a single protected SSRC from a FlexFEC-03 repair stream. It is not safe for concurrent use; the owning buffer serializes access.
func NewDecoder ¶
func (*Decoder) DecodeFEC ¶
DecodeFEC ingests a packet of either the FEC stream (fecSSRC) or the protected media stream (protectedSSRC) and returns any media packets that became recoverable. Ownership of returned packets transfers to the caller.
func (*Decoder) Stats ¶
func (d *Decoder) Stats() DecoderStats
type DecoderStats ¶
type DecoderStats struct {
// FEC packets fed to the decoder
FECPacketsReceived uint64
// FEC bytes fed to the decoder (RTP payload sizes)
FECBytesReceived uint64
// FEC packets that could not be used: parse failures, foreign protected
// SSRC, empty masks and duplicates
FECPacketsDiscarded uint64
// media packets reconstructed from FEC
PacketsRecovered uint64
}
DecoderStats accumulates FEC usage counters. Snapshot via Decoder.Stats.