1 /* GStreamer plugin for forward error correction
2 * Copyright (C) 2017 Pexip
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 * Author: Mikhail Fludkov <misha@pexip.com>
22 * SECTION:element-rtpulpfecenc
23 * @short_description: Generic RTP Forward Error Correction (FEC) encoder
24 * @title: rtpulpfecenc
26 * Generic Forward Error Correction (FEC) encoder using Uneven Level
27 * Protection (ULP) as described in RFC 5109.
29 * It differs from the RFC in one important way, it multiplexes the
30 * FEC packets in the same sequence number as media packets. This is to be
31 * compatible with libwebrtc as using in Google Chrome and with Microsoft
32 * Lync / Skype for Business.
34 * Be warned that after using this element, it is no longer possible to know if
35 * there is a gap in the media stream based on the sequence numbers as the FEC
36 * packets become interleaved with the media packets.
38 * This element will insert protection packets in any RTP stream, which
39 * can then be used on the receiving side to recover lost packets.
41 * This element rewrites packets' seqnums, which means that when combined
42 * with retransmission elements such as #GstRtpRtxSend, it *must* be
43 * placed upstream of those, otherwise retransmission requests will request
46 * A payload type for the protection packets *must* be specified, different
47 * from the payload type of the protected packets, with the GstRtpUlpFecEnc:pt
50 * The marker bit of RTP packets is used to determine sets of packets to
51 * protect as a unit, in order to modulate the level of protection, this
52 * behaviour can be disabled with GstRtpUlpFecEnc:multipacket, but should
53 * be left enabled for video streams.
55 * The level of protection can be configured with two properties,
56 * #GstRtpUlpFecEnc:percentage and #GstRtpUlpFecEnc:percentage-important,
57 * the element will determine which percentage to use for a given set of
58 * packets based on the presence of the #GST_BUFFER_FLAG_NON_DROPPABLE
59 * flag, upstream payloaders are expected to set this flag on "important"
60 * packets such as those making up a keyframe.
62 * The percentage is expressed not in terms of bytes, but in terms of
63 * packets, this for implementation convenience. The drawback with this
64 * approach is that when using a percentage different from 100 %, and a
65 * low bitrate, entire frames may be contained in a single packet, leading
66 * to some packets not being protected, thus lowering the overall recovery
67 * rate on the receiving side.
69 * When using #GstRtpBin, this element should be inserted through the
70 * #GstRtpBin::request-fec-encoder signal.
75 * gst-launch-1.0 videotestsrc ! x264enc ! video/x-h264, profile=baseline ! rtph264pay pt=96 ! rtpulpfecenc percentage=100 pt=122 ! udpsink port=8888
76 * ]| This example will receive a stream with FEC and try to reconstruct the packets.
78 * Example programs are available at
79 * <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/blob/master/examples/src/bin/rtpfecserver.rs>
81 * <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/blob/master/examples/src/bin/rtpfecclient.rs>
83 * See also: #GstRtpUlpFecDec, #GstRtpBin
87 #include <gst/rtp/gstrtp-enumtypes.h>
88 #include <gst/rtp/gstrtpbuffer.h>
91 #include "rtpulpfeccommon.h"
92 #include "gstrtpulpfecenc.h"
94 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
97 GST_STATIC_CAPS ("application/x-rtp"));
99 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
102 GST_STATIC_CAPS ("application/x-rtp"));
106 #define DEFAULT_PT UNDEF_PT
107 #define DEFAULT_PCT 0
108 #define DEFAULT_PCT_IMPORTANT 0
109 #define DEFAULT_MULTIPACKET TRUE
111 #define PACKETS_BUF_MAX_LENGTH (RTP_ULPFEC_PROTECTED_PACKETS_MAX(TRUE))
113 GST_DEBUG_CATEGORY (gst_rtp_ulpfec_enc_debug);
114 #define GST_CAT_DEFAULT (gst_rtp_ulpfec_enc_debug)
116 G_DEFINE_TYPE (GstRtpUlpFecEnc, gst_rtp_ulpfec_enc, GST_TYPE_ELEMENT);
125 PROP_PERCENTAGE_IMPORTANT,
128 #define RTP_FEC_MAP_INFO_NTH(ctx, data) (&g_array_index (\
129 ((GstRtpUlpFecEncStreamCtx *)ctx)->info_arr, \
131 GPOINTER_TO_UINT(data)))
134 gst_rtp_ulpfec_enc_stream_ctx_start (GstRtpUlpFecEncStreamCtx * ctx,
135 GQueue * packets, guint fec_packets)
137 GList *it = packets->tail;
140 g_array_set_size (ctx->info_arr, packets->length);
142 for (i = 0; i < packets->length; ++i) {
143 GstBuffer *buffer = it->data;
144 RtpUlpFecMapInfo *info = RTP_FEC_MAP_INFO_NTH (ctx, i);
146 if (!rtp_ulpfec_map_info_map (gst_buffer_ref (buffer), info))
147 g_assert_not_reached ();
149 GST_LOG_RTP_PACKET (ctx->parent, "rtp header (incoming)", &info->rtp);
151 it = g_list_previous (it);
154 ctx->fec_packets = fec_packets;
155 ctx->fec_packet_idx = 0;
159 gst_rtp_ulpfec_enc_stream_ctx_stop (GstRtpUlpFecEncStreamCtx * ctx)
161 g_array_set_size (ctx->info_arr, 0);
162 g_array_set_size (ctx->scratch_buf, 0);
164 ctx->fec_packets = 0;
165 ctx->fec_packet_idx = 0;
169 gst_rtp_ulpfec_enc_stream_ctx_get_protection_parameters
170 (GstRtpUlpFecEncStreamCtx * ctx, guint16 * dst_seq_base, guint64 * dst_mask,
171 guint * dst_start, guint * dst_end)
173 guint media_packets = ctx->info_arr->len;
174 guint start = ctx->fec_packet_idx * media_packets / ctx->fec_packets;
176 ((ctx->fec_packet_idx + 1) * media_packets + ctx->fec_packets -
177 1) / ctx->fec_packets - 1;
178 guint len = end - start + 1;
180 guint16 seq_base = 0;
183 len = MIN (len, RTP_ULPFEC_PROTECTED_PACKETS_MAX (TRUE));
184 end = start + len - 1;
186 for (i = start; i <= end; ++i) {
187 RtpUlpFecMapInfo *info = RTP_FEC_MAP_INFO_NTH (ctx, i);
188 guint16 seq = gst_rtp_buffer_get_seq (&info->rtp);
191 gint diff = gst_rtp_buffer_compare_seqnum (seq_base, seq);
194 mask = mask >> (-diff);
196 mask |= rtp_ulpfec_packet_mask_from_seqnum (seq, seq_base, TRUE);
199 mask = rtp_ulpfec_packet_mask_from_seqnum (seq, seq_base, TRUE);
206 *dst_seq_base = seq_base;
210 gst_rtp_ulpfec_enc_stream_ctx_protect (GstRtpUlpFecEncStreamCtx * ctx,
211 guint8 pt, guint16 seq, guint32 timestamp, guint32 ssrc)
215 guint64 fec_mask = 0;
216 guint16 seq_base = 0;
219 gboolean fec_mask_long;
222 if (ctx->fec_packet_idx >= ctx->fec_packets)
225 g_array_set_size (ctx->scratch_buf, 0);
226 gst_rtp_ulpfec_enc_stream_ctx_get_protection_parameters (ctx, &seq_base,
227 &fec_mask, &start, &end);
230 fec_mask_long = rtp_ulpfec_mask_is_long (fec_mask);
231 for (i = start; i <= end; ++i) {
232 RtpUlpFecMapInfo *info = RTP_FEC_MAP_INFO_NTH (ctx, i);
233 guint64 packet_mask =
234 rtp_ulpfec_packet_mask_from_seqnum (gst_rtp_buffer_get_seq (&info->rtp),
238 if (tmp_mask & packet_mask) {
239 tmp_mask ^= packet_mask;
240 rtp_buffer_to_ulpfec_bitstring (&info->rtp, ctx->scratch_buf, FALSE,
245 g_assert (tmp_mask == 0);
247 rtp_ulpfec_bitstring_to_fec_rtp_buffer (ctx->scratch_buf, seq_base,
248 fec_mask_long, fec_mask, FALSE, pt, seq, timestamp, ssrc);
249 ++ctx->fec_packet_idx;
254 gst_rtp_ulpfec_enc_stream_ctx_report_budget (GstRtpUlpFecEncStreamCtx * ctx)
256 GST_TRACE_OBJECT (ctx->parent, "budget = %f budget_important = %f",
257 ctx->budget, ctx->budget_important);
261 gst_rtp_ulpfec_enc_stream_ctx_increment_budget (GstRtpUlpFecEncStreamCtx * ctx,
264 if (ctx->percentage == 0 && ctx->percentage_important == 0) {
265 if (ctx->budget > 0) {
267 ctx->budget_important = 0;
270 ctx->budget += ctx->budget_inc;
274 ctx->budget += ctx->budget_inc;
276 if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_NON_DROPPABLE)) {
277 ctx->budget_important += ctx->budget_inc_important;
280 gst_rtp_ulpfec_enc_stream_ctx_report_budget (ctx);
284 gst_rtp_ulpfec_enc_stream_ctx_decrement_budget (GstRtpUlpFecEncStreamCtx * ctx,
285 guint fec_packets_num)
287 if (ctx->budget_important >= 1.)
288 ctx->budget_important -= fec_packets_num;
289 ctx->budget -= fec_packets_num;
291 gst_rtp_ulpfec_enc_stream_ctx_report_budget (ctx);
295 gst_rtp_ulpfec_enc_stream_ctx_get_fec_packets_num (GstRtpUlpFecEncStreamCtx *
298 g_assert_cmpfloat (ctx->budget_important, >=, 0.);
300 if (ctx->budget_important >= 1.)
301 return ctx->budget_important;
302 return ctx->budget > 0. ? (guint) ctx->budget : 0;
306 gst_rtp_ulpfec_enc_stream_ctx_free_packets_buf (GstRtpUlpFecEncStreamCtx * ctx)
308 while (ctx->packets_buf.length)
309 gst_buffer_unref (g_queue_pop_tail (&ctx->packets_buf));
313 gst_rtp_ulpfec_enc_stream_ctx_prepend_to_fec_buffer (GstRtpUlpFecEncStreamCtx *
314 ctx, GstRTPBuffer * rtp, guint buf_max_size)
317 if (ctx->packets_buf.length == buf_max_size) {
318 new_head = g_queue_pop_tail_link (&ctx->packets_buf);
320 new_head = g_list_alloc ();
323 gst_buffer_replace ((GstBuffer **) & new_head->data, rtp->buffer);
324 g_queue_push_head_link (&ctx->packets_buf, new_head);
326 g_assert_cmpint (ctx->packets_buf.length, <=, buf_max_size);
330 gst_rtp_ulpfec_enc_stream_ctx_push_fec_packets (GstRtpUlpFecEncStreamCtx * ctx,
331 guint8 pt, guint16 seq, guint32 timestamp, guint32 ssrc)
333 GstFlowReturn ret = GST_FLOW_OK;
334 guint fec_packets_num =
335 gst_rtp_ulpfec_enc_stream_ctx_get_fec_packets_num (ctx);
337 if (fec_packets_num) {
338 guint fec_packets_pushed = 0;
339 GstBuffer *latest_packet = ctx->packets_buf.head->data;
340 GstBuffer *fec = NULL;
342 gst_rtp_ulpfec_enc_stream_ctx_start (ctx, &ctx->packets_buf,
345 while (NULL != (fec =
346 gst_rtp_ulpfec_enc_stream_ctx_protect (ctx, pt,
347 seq + fec_packets_pushed, timestamp, ssrc))) {
348 gst_buffer_copy_into (fec, latest_packet, GST_BUFFER_COPY_TIMESTAMPS, 0,
351 ret = gst_pad_push (ctx->srcpad, fec);
352 if (GST_FLOW_OK == ret)
353 ++fec_packets_pushed;
358 gst_rtp_ulpfec_enc_stream_ctx_stop (ctx);
360 g_assert_cmpint (fec_packets_pushed, <=, fec_packets_num);
362 ctx->num_packets_protected += ctx->packets_buf.length;
363 ctx->num_packets_fec += fec_packets_pushed;
364 ctx->seqnum_offset += fec_packets_pushed;
365 ctx->seqnum += fec_packets_pushed;
368 gst_rtp_ulpfec_enc_stream_ctx_decrement_budget (ctx, fec_packets_num);
373 gst_rtp_ulpfec_enc_stream_ctx_cache_packet (GstRtpUlpFecEncStreamCtx * ctx,
374 GstRTPBuffer * rtp, gboolean * dst_empty_packet_buffer,
375 gboolean * dst_push_fec)
377 if (ctx->multipacket) {
378 gst_rtp_ulpfec_enc_stream_ctx_prepend_to_fec_buffer (ctx, rtp,
379 PACKETS_BUF_MAX_LENGTH);
380 gst_rtp_ulpfec_enc_stream_ctx_increment_budget (ctx, rtp->buffer);
382 *dst_empty_packet_buffer = gst_rtp_buffer_get_marker (rtp);
383 *dst_push_fec = *dst_empty_packet_buffer;
387 gst_rtp_ulpfec_enc_stream_ctx_prepend_to_fec_buffer (ctx, rtp, 1);
389 push_fec = ctx->fec_nth == 0 ? FALSE :
390 0 == (ctx->num_packets_received % ctx->fec_nth);
392 ctx->budget = push_fec ? 1 : 0;
393 ctx->budget_important = 0;
395 *dst_push_fec = push_fec;
396 *dst_empty_packet_buffer = FALSE;
401 gst_rtp_ulpfec_enc_stream_ctx_configure (GstRtpUlpFecEncStreamCtx * ctx,
402 guint pt, guint percentage, guint percentage_important,
403 gboolean multipacket)
406 ctx->percentage = percentage;
407 ctx->percentage_important = percentage_important;
408 ctx->multipacket = multipacket;
410 ctx->fec_nth = percentage ? 100 / percentage : 0;
412 ctx->budget_inc = percentage / 100.;
413 ctx->budget_inc_important = percentage > percentage_important ?
414 ctx->budget_inc : percentage_important / 100.;
418 ctx->budget_inc = 0.0;
421 ctx->budget_inc_important = percentage > percentage_important ?
422 ctx->budget_inc : percentage_important / 100.;
425 static GstRtpUlpFecEncStreamCtx *
426 gst_rtp_ulpfec_enc_stream_ctx_new (guint ssrc,
427 GstElement * parent, GstPad * srcpad,
428 guint pt, guint percentage, guint percentage_important,
429 gboolean multipacket)
431 GstRtpUlpFecEncStreamCtx *ctx = g_new0 (GstRtpUlpFecEncStreamCtx, 1);
434 ctx->parent = parent;
435 ctx->srcpad = srcpad;
437 ctx->seqnum = g_random_int_range (0, G_MAXUINT16 / 2);
439 ctx->info_arr = g_array_new (FALSE, TRUE, sizeof (RtpUlpFecMapInfo));
440 g_array_set_clear_func (ctx->info_arr,
441 (GDestroyNotify) rtp_ulpfec_map_info_unmap);
442 ctx->parent = parent;
443 ctx->scratch_buf = g_array_new (FALSE, TRUE, sizeof (guint8));
444 gst_rtp_ulpfec_enc_stream_ctx_configure (ctx, pt,
445 percentage, percentage_important, multipacket);
451 gst_rtp_ulpfec_enc_stream_ctx_free (GstRtpUlpFecEncStreamCtx * ctx)
453 if (ctx->num_packets_received) {
454 GST_INFO_OBJECT (ctx->parent, "Actual FEC overhead is %4.2f%% (%u/%u)\n",
455 ctx->num_packets_fec * (double) 100. / ctx->num_packets_received,
456 ctx->num_packets_fec, ctx->num_packets_received);
458 gst_rtp_ulpfec_enc_stream_ctx_free_packets_buf (ctx);
460 g_assert (0 == ctx->info_arr->len);
461 g_array_free (ctx->info_arr, TRUE);
462 g_array_free (ctx->scratch_buf, TRUE);
463 g_slice_free1 (sizeof (GstRtpUlpFecEncStreamCtx), ctx);
467 gst_rtp_ulpfec_enc_stream_ctx_process (GstRtpUlpFecEncStreamCtx * ctx,
470 GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
472 gboolean push_fec = FALSE;
473 gboolean empty_packet_buffer = FALSE;
475 ctx->num_packets_received++;
477 if (ctx->seqnum_offset > 0) {
478 buffer = gst_buffer_make_writable (buffer);
479 if (!gst_rtp_buffer_map (buffer,
480 GST_MAP_READWRITE | GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING, &rtp))
481 g_assert_not_reached ();
482 gst_rtp_buffer_set_seq (&rtp,
483 gst_rtp_buffer_get_seq (&rtp) + ctx->seqnum_offset);
485 if (!gst_rtp_buffer_map (buffer,
486 GST_MAP_READ | GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING, &rtp))
487 g_assert_not_reached ();
490 gst_rtp_ulpfec_enc_stream_ctx_cache_packet (ctx, &rtp, &empty_packet_buffer,
494 guint32 fec_timestamp = gst_rtp_buffer_get_timestamp (&rtp);
495 guint32 fec_ssrc = gst_rtp_buffer_get_ssrc (&rtp);
496 guint16 fec_seq = gst_rtp_buffer_get_seq (&rtp) + 1;
498 gst_rtp_buffer_unmap (&rtp);
500 ret = gst_pad_push (ctx->srcpad, buffer);
501 if (GST_FLOW_OK == ret)
503 gst_rtp_ulpfec_enc_stream_ctx_push_fec_packets (ctx, ctx->pt, fec_seq,
504 fec_timestamp, fec_ssrc);
506 gst_rtp_buffer_unmap (&rtp);
507 ret = gst_pad_push (ctx->srcpad, buffer);
510 if (empty_packet_buffer)
511 gst_rtp_ulpfec_enc_stream_ctx_free_packets_buf (ctx);
516 static GstRtpUlpFecEncStreamCtx *
517 gst_rtp_ulpfec_enc_aquire_ctx (GstRtpUlpFecEnc * fec, guint ssrc)
519 GstRtpUlpFecEncStreamCtx *ctx;
521 GST_OBJECT_LOCK (fec);
522 ctx = g_hash_table_lookup (fec->ssrc_to_ctx, GUINT_TO_POINTER (ssrc));
525 gst_rtp_ulpfec_enc_stream_ctx_new (ssrc, GST_ELEMENT_CAST (fec),
526 fec->srcpad, fec->pt, fec->percentage,
527 fec->percentage_important, fec->multipacket);
528 g_hash_table_insert (fec->ssrc_to_ctx, GUINT_TO_POINTER (ssrc), ctx);
530 GST_OBJECT_UNLOCK (fec);
536 gst_rtp_ulpfec_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
538 GstRtpUlpFecEnc *fec = GST_RTP_ULPFEC_ENC (parent);
539 GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
542 GstRtpUlpFecEncStreamCtx *ctx;
544 if (fec->pt == UNDEF_PT)
545 return gst_pad_push (fec->srcpad, buffer);
547 /* FIXME: avoid this additional mapping of the buffer to get the
549 if (!gst_rtp_buffer_map (buffer,
550 GST_MAP_READ | GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING, &rtp)) {
551 g_assert_not_reached ();
553 ssrc = gst_rtp_buffer_get_ssrc (&rtp);
554 gst_rtp_buffer_unmap (&rtp);
556 ctx = gst_rtp_ulpfec_enc_aquire_ctx (fec, ssrc);
558 ret = gst_rtp_ulpfec_enc_stream_ctx_process (ctx, buffer);
560 /* FIXME: does not work for multiple ssrcs */
561 fec->num_packets_protected = ctx->num_packets_protected;
567 gst_rtp_ulpfec_enc_configure_ctx (gpointer key, gpointer value,
570 GstRtpUlpFecEnc *fec = user_data;
571 GstRtpUlpFecEncStreamCtx *ctx = value;
573 gst_rtp_ulpfec_enc_stream_ctx_configure (ctx, fec->pt,
574 fec->percentage, fec->percentage_important, fec->multipacket);
578 gst_rtp_ulpfec_enc_set_property (GObject * object, guint prop_id,
579 const GValue * value, GParamSpec * pspec)
581 GstRtpUlpFecEnc *fec = GST_RTP_ULPFEC_ENC (object);
585 fec->pt = g_value_get_uint (value);
587 case PROP_MULTIPACKET:
588 fec->multipacket = g_value_get_boolean (value);
590 case PROP_PERCENTAGE:
591 fec->percentage = g_value_get_uint (value);
593 case PROP_PERCENTAGE_IMPORTANT:
594 fec->percentage_important = g_value_get_uint (value);
597 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
601 GST_OBJECT_LOCK (fec);
602 g_hash_table_foreach (fec->ssrc_to_ctx, gst_rtp_ulpfec_enc_configure_ctx,
604 GST_OBJECT_UNLOCK (fec);
608 gst_rtp_ulpfec_enc_get_property (GObject * object, guint prop_id,
609 GValue * value, GParamSpec * pspec)
611 GstRtpUlpFecEnc *fec = GST_RTP_ULPFEC_ENC (object);
614 g_value_set_uint (value, fec->pt);
617 g_value_set_uint (value, fec->num_packets_protected);
619 case PROP_PERCENTAGE:
620 g_value_set_uint (value, fec->percentage);
622 case PROP_PERCENTAGE_IMPORTANT:
623 g_value_set_uint (value, fec->percentage_important);
625 case PROP_MULTIPACKET:
626 g_value_set_boolean (value, fec->multipacket);
629 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
635 gst_rtp_ulpfec_enc_dispose (GObject * obj)
637 GstRtpUlpFecEnc *fec = GST_RTP_ULPFEC_ENC (obj);
639 g_hash_table_destroy (fec->ssrc_to_ctx);
641 G_OBJECT_CLASS (gst_rtp_ulpfec_enc_parent_class)->dispose (obj);
645 gst_rtp_ulpfec_enc_init (GstRtpUlpFecEnc * fec)
647 fec->srcpad = gst_pad_new_from_static_template (&srctemplate, "src");
648 gst_element_add_pad (GST_ELEMENT (fec), fec->srcpad);
650 fec->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink");
651 GST_PAD_SET_PROXY_CAPS (fec->sinkpad);
652 GST_PAD_SET_PROXY_ALLOCATION (fec->sinkpad);
653 gst_pad_set_chain_function (fec->sinkpad,
654 GST_DEBUG_FUNCPTR (gst_rtp_ulpfec_enc_chain));
655 gst_element_add_pad (GST_ELEMENT (fec), fec->sinkpad);
657 fec->ssrc_to_ctx = g_hash_table_new_full (NULL, NULL, NULL,
658 (GDestroyNotify) gst_rtp_ulpfec_enc_stream_ctx_free);
662 gst_rtp_ulpfec_enc_class_init (GstRtpUlpFecEncClass * klass)
664 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
665 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
667 GST_DEBUG_CATEGORY_INIT (gst_rtp_ulpfec_enc_debug, "rtpulpfecenc", 0,
668 "FEC encoder element");
670 gst_element_class_add_pad_template (element_class,
671 gst_static_pad_template_get (&srctemplate));
672 gst_element_class_add_pad_template (element_class,
673 gst_static_pad_template_get (&sinktemplate));
675 gst_element_class_set_static_metadata (element_class,
677 "Codec/Payloader/Network/RTP",
678 "Encodes RTP FEC (RFC5109)", "Mikhail Fludkov <misha@pexip.com>");
680 gobject_class->set_property =
681 GST_DEBUG_FUNCPTR (gst_rtp_ulpfec_enc_set_property);
682 gobject_class->get_property =
683 GST_DEBUG_FUNCPTR (gst_rtp_ulpfec_enc_get_property);
684 gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_rtp_ulpfec_enc_dispose);
686 g_object_class_install_property (gobject_class, PROP_PT,
687 g_param_spec_uint ("pt", "payload type",
688 "The payload type of FEC packets", 0, 255, DEFAULT_PT,
689 G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
691 g_object_class_install_property (gobject_class, PROP_MULTIPACKET,
692 g_param_spec_boolean ("multipacket", "Multipacket",
693 "Apply FEC on multiple packets", DEFAULT_MULTIPACKET,
694 G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
696 g_object_class_install_property (gobject_class, PROP_PERCENTAGE,
697 g_param_spec_uint ("percentage", "Percentage",
698 "FEC overhead percentage for the whole stream", 0, 100, DEFAULT_PCT,
699 G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
701 g_object_class_install_property (gobject_class, PROP_PERCENTAGE_IMPORTANT,
702 g_param_spec_uint ("percentage-important", "Percentage important",
703 "FEC overhead percentage for important packets",
704 0, 100, DEFAULT_PCT_IMPORTANT,
705 G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
707 g_object_class_install_property (gobject_class, PROP_PROTECTED,
708 g_param_spec_uint ("protected", "Protected",
709 "Count of protected packets", 0, G_MAXUINT32, 0,
710 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));