flexfec

package
v0.1.29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 4 Imported by: 8

Documentation

Overview

Package flexfec implements FlexFEC to recover missing RTP packets due to packet loss. https://datatracker.ietf.org/doc/html/rfc8627

Package flexfec implements FlexFEC to recover missing RTP packets due to packet loss. https://datatracker.ietf.org/doc/html/rfc8627

Index

Constants

View Source
const (
	MaxMediaPackets uint32 = 110
	MaxFecPackets   uint32 = MaxMediaPackets
)

Maximum number of media packets that can be protected by a single FEC packet. We are not supporting the possibility of having an FEC packet protect multiple SSRC source packets for now. https://datatracker.ietf.org/doc/html/rfc8627#section-4.2.2.1

View Source
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
)
View Source
const (
	// BaseFec03HeaderSize represents the minium FEC payload's header size including the
	// required first mask.
	BaseFec03HeaderSize = 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FecInterceptor added in v0.1.26

type FecInterceptor struct {
	interceptor.NoOp
	// contains filtered or unexported fields
}

FecInterceptor implements FlexFec.

func (*FecInterceptor) BindLocalStream added in v0.1.26

BindLocalStream lets you modify any outgoing RTP packets. It is called once for per LocalStream. The returned method will be called once per rtp packet.

type FecInterceptorFactory added in v0.1.26

type FecInterceptorFactory struct {
	// contains filtered or unexported fields
}

FecInterceptorFactory creates new FecInterceptors.

func NewFecInterceptor added in v0.1.26

func NewFecInterceptor(opts ...FecOption) (*FecInterceptorFactory, error)

NewFecInterceptor returns a new Fec interceptor factory.

func (*FecInterceptorFactory) NewInterceptor added in v0.1.26

func (r *FecInterceptorFactory) NewInterceptor(_ string) (interceptor.Interceptor, error)

NewInterceptor constructs a new FecInterceptor.

type FecOption added in v0.1.26

type FecOption func(d *FecInterceptor) error

FecOption can be used to set initial options on Fec encoder interceptors.

type FlexEncoder

type FlexEncoder interface {
	EncodeFec(mediaPackets []rtp.Packet, numFecPackets uint32) []rtp.Packet
}

FlexEncoder is the interface that FecInterceptor uses to encode Fec packets.

type FlexEncoder03 added in v0.1.26

type FlexEncoder03 struct {
	// contains filtered or unexported fields
}

FlexEncoder03 implements the Fec encoding mechanism for the "Flex" variant of FlexFec.

func NewFlexEncoder03 added in v0.1.26

func NewFlexEncoder03(payloadType uint8, ssrc uint32) *FlexEncoder03

NewFlexEncoder03 returns a new FlexFecEncoder.

func (*FlexEncoder03) EncodeFec added in v0.1.26

func (flex *FlexEncoder03) EncodeFec(mediaPackets []rtp.Packet, numFecPackets uint32) []rtp.Packet

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.

type FlexEncoder20 added in v0.1.26

type FlexEncoder20 struct {
	// contains filtered or unexported fields
}

FlexEncoder20 implements the Fec encoding mechanism for the "Flex" variant of FlexFec.

func NewFlexEncoder

func NewFlexEncoder(payloadType uint8, ssrc uint32) *FlexEncoder20

NewFlexEncoder returns a new FlexFecEncer.

func (*FlexEncoder20) EncodeFec added in v0.1.26

func (flex *FlexEncoder20) EncodeFec(mediaPackets []rtp.Packet, numFecPackets uint32) []rtp.Packet

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.

type ProtectionCoverage

type ProtectionCoverage struct {
	// contains filtered or unexported fields
}

ProtectionCoverage defines the map of RTP packets that individual Fec packets protect.

func NewCoverage

func NewCoverage(mediaPackets []rtp.Packet, numFecPackets uint32) *ProtectionCoverage

NewCoverage returns a new ProtectionCoverage object. numFecPackets represents the number of Fec packets that we will be generating to cover the list of mediaPackets. This allows us to know how big the underlying map should be.

func (*ProtectionCoverage) ExtractMask1

func (p *ProtectionCoverage) ExtractMask1(fecPacketIndex uint32) uint16

ExtractMask1 returns the first section of the bitmask as defined by the FEC header. https://datatracker.ietf.org/doc/html/rfc8627#section-4.2.2.1

func (*ProtectionCoverage) ExtractMask2

func (p *ProtectionCoverage) ExtractMask2(fecPacketIndex uint32) uint32

ExtractMask2 returns the second section of the bitmask as defined by the FEC header. https://datatracker.ietf.org/doc/html/rfc8627#section-4.2.2.1

func (*ProtectionCoverage) ExtractMask3

func (p *ProtectionCoverage) ExtractMask3(fecPacketIndex uint32) uint64

ExtractMask3 returns the third section of the bitmask as defined by the FEC header. https://datatracker.ietf.org/doc/html/rfc8627#section-4.2.2.1

func (*ProtectionCoverage) ExtractMask3_03 added in v0.1.26

func (p *ProtectionCoverage) ExtractMask3_03(fecPacketIndex uint32) uint64

ExtractMask3_03 returns the third section of the bitmask as defined by the FEC header. https://datatracker.ietf.org/doc/html/draft-ietf-payload-flexible-fec-scheme-03#section-4.2

func (*ProtectionCoverage) GetCoveredBy

func (p *ProtectionCoverage) GetCoveredBy(fecPacketIndex uint32) *util.MediaPacketIterator

GetCoveredBy returns an iterator over RTP packets that are protected by the specified Fec packet index.

func (*ProtectionCoverage) UpdateCoverage added in v0.1.26

func (p *ProtectionCoverage) UpdateCoverage(mediaPackets []rtp.Packet, numFecPackets uint32)

UpdateCoverage updates the ProtectionCoverage object with new bitmasks accounting for the numFecPackets we want to use to protect the batch media packets.

Directories

Path Synopsis
Package util implements utilities to better support Fec decoding / encoding.
Package util implements utilities to better support Fec decoding / encoding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL