diff --git a/pkg/flexfec/flexfec_encoder.go b/pkg/flexfec/flexfec_encoder.go index 8c6913ad..0af69141 100644 --- a/pkg/flexfec/flexfec_encoder.go +++ b/pkg/flexfec/flexfec_encoder.go @@ -13,10 +13,14 @@ import ( ) const ( + // BaseRtpHeaderSize represents the minium RTP packet header size in bytes. BaseRtpHeaderSize = 12 + // BaseFecHeaderSize represents the minium FEC payload's header size including the + // required first mask. BaseFecHeaderSize = 12 ) +// FlexFecEncoder implements the Fec encoding mechanism for the "Flex" variant of FlexFec. type FlexFecEncoder struct { baseSN uint16 payloadType uint8 @@ -24,6 +28,7 @@ type FlexFecEncoder struct { coverage *ProtectionCoverage } +// NewFlexFecEncoder returns a new FlexFecEncer. func NewFlexFecEncoder(baseSN uint16, payloadType uint8, ssrc uint32) *FlexFecEncoder { return &FlexFecEncoder{ baseSN: baseSN, @@ -33,8 +38,9 @@ func NewFlexFecEncoder(baseSN uint16, payloadType uint8, ssrc uint32) *FlexFecEn } } -// Returns the array of FEC packets protecting mediaPkts specified as parameter. -// Encoding will be skipped if there are missing Media packets. +// EncodeFec returns a list of generated RTP packets with FEC payloads that protect the specified mediaPackets. +// This method does not account for missing RTP packets in the mediaPackets array nor does it account for +// them being passed out of order. func (flex *FlexFecEncoder) EncodeFec(mediaPackets []rtp.Packet, numFecPackets uint32) []rtp.Packet { // Start by defining which FEC packets cover which media packets if flex.coverage == nil { diff --git a/pkg/flexfec/util/bitarray.go b/pkg/flexfec/util/bitarray.go index ad1fdcdf..d24efc20 100644 --- a/pkg/flexfec/util/bitarray.go +++ b/pkg/flexfec/util/bitarray.go @@ -12,7 +12,7 @@ type BitArray struct { // NewBitArray returns a new BitArray. It takes sizeBits as parameter which represents // the size of the underlying bitmask. func NewBitArray(sizeBits uint32) BitArray { - sizeBytes := uint32(0) + var sizeBytes uint32 if sizeBits%8 == 0 { sizeBytes = sizeBits / 8 } else { diff --git a/pkg/flexfec/util/media_packet_iterator.go b/pkg/flexfec/util/media_packet_iterator.go index 42a643bf..3099a39f 100644 --- a/pkg/flexfec/util/media_packet_iterator.go +++ b/pkg/flexfec/util/media_packet_iterator.go @@ -44,6 +44,7 @@ func (m *MediaPacketIterator) Next() *rtp.Packet { return &packet } +// First returns the first media packet to iterate through. func (m *MediaPacketIterator) First() *rtp.Packet { return &m.mediaPackets[0] }