# rtpulpfecenc

Generic Forward Error Correction (FEC) encoder using Uneven Level Protection (ULP) as described in RFC 5109.

It differs from the RFC in one important way, it multiplexes the FEC packets in the same sequence number as media packets. This is to be compatible with libwebrtc as using in Google Chrome and with Microsoft Lync / Skype for Business.

Be warned that after using this element, it is no longer possible to know if there is a gap in the media stream based on the sequence numbers as the FEC packets become interleaved with the media packets.

This element will insert protection packets in any RTP stream, which can then be used on the receiving side to recover lost packets.

This element rewrites packets' seqnums, which means that when combined with retransmission elements such as rtprtxsend, it must be placed upstream of those, otherwise retransmission requests will request incorrect seqnums.

A payload type for the protection packets must be specified, different from the payload type of the protected packets, with the GstRtpUlpFecEnc:pt property.

The marker bit of RTP packets is used to determine sets of packets to protect as a unit, in order to modulate the level of protection, this behaviour can be disabled with GstRtpUlpFecEnc:multipacket, but should be left enabled for video streams.

The level of protection can be configured with two properties, percentage and percentage-important, the element will determine which percentage to use for a given set of packets based on the presence of the GST_BUFFER_FLAG_NON_DROPPABLE flag, upstream payloaders are expected to set this flag on "important" packets such as those making up a keyframe.

The percentage is expressed not in terms of bytes, but in terms of packets, this for implementation convenience. The drawback with this approach is that when using a percentage different from 100 %, and a low bitrate, entire frames may be contained in a single packet, leading to some packets not being protected, thus lowering the overall recovery rate on the receiving side.

When using rtpbin, this element should be inserted through the request-fec-encoder signal.

## Example pipeline

     gst-launch-1.0 videotestsrc ! x264enc ! video/x-h264, profile=baseline ! rtph264pay pt=96 ! rtpulpfecenc percentage=100 pt=122 ! udpsink port=8888

This example will receive a stream with FEC and try to reconstruct the packets.

Example programs are available at https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/blob/master/examples/src/bin/rtpfecserver.rs and https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/blob/master/examples/src/bin/rtpfecclient.rs

See also: rtpulpfecdec, rtpbin

## Hierarchy

    GObject
        ╰──GInitiallyUnowned
            ╰──GstObject
                ╰──GstElement
                    ╰──rtpulpfecenc

## Factory details

Authors: – Mikhail Fludkov

Classification: – `Codec/Payloader/Network/RTP`

Rank – none

Plugin – rtp

Package – GStreamer Good Plug-ins

## Pad Templates

### `sink`

    application/x-rtp:

Presence – always

Direction – sink

Object type – GstPad

### `src`

    application/x-rtp:

Presence – always

Direction – src

Object type – GstPad

## Properties

### multipacket

    “multipacket” gboolean

Apply FEC on multiple packets

Flags : Read / Write / Construct

Default value : true

### percentage

    “percentage” guint

FEC overhead percentage for the whole stream

Flags : Read / Write / Construct

Default value : 0

### percentage-important

    “percentage-important” guint

FEC overhead percentage for important packets

Flags : Read / Write / Construct

Default value : 0

### protected

    “protected” guint

Count of protected packets

Flags : Read

Default value : 0

### pt

    “pt” guint

The payload type of FEC packets

Flags : Read / Write / Construct

Default value : 255

The results of the search are