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-rtpulpfecdec
23 * @short_description: Generic RTP Forward Error Correction (FEC) decoder
24 * @title: rtpulpfecdec
26 * Generic Forward Error Correction (FEC) decoder for 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 * This element will work in combination with an upstream #GstRtpStorage
35 * element and attempt to recover packets declared lost through custom
36 * 'GstRTPPacketLost' events, usually emitted by #GstRtpJitterBuffer.
38 * If no storage is provided using the #GstRtpUlpFecDec:storage
39 * property, it will try to get it from an element upstream.
41 * Additionally, the payload types of the protection packets *must* be
42 * provided to this element via its #GstRtpUlpFecDec:pt property.
44 * When using #GstRtpBin, this element should be inserted through the
45 * #GstRtpBin::request-fec-decoder signal.
48 * <title>Example pipeline</title>
50 * gst-launch-1.0 udpsrc port=8888 caps="application/x-rtp, payload=96, clock-rate=90000" ! rtpstorage size-time=220000000 ! rtpssrcdemux ! application/x-rtp, payload=96, clock-rate=90000, media=video, encoding-name=H264 ! rtpjitterbuffer do-lost=1 latency=200 ! rtpulpfecdec pt=122 ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink
51 * ]| This example will receive a stream with FEC and try to reconstruct the packets.
53 * Example programs are available at
54 * <ulink url="https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/blob/master/examples/src/bin/rtpfecserver.rs">rtpfecserver.rs</ulink>
56 * <ulink url="https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/blob/master/examples/src/bin/rtpfecclient.rs">rtpfecclient.rs</ulink>
60 * See also: #GstRtpUlpFecEnc, #GstRtpBin, #GstRtpStorage
64 #include <gst/rtp/gstrtpbuffer.h>
65 #include <gst/rtp/gstrtp-enumtypes.h>
67 #include "rtpulpfeccommon.h"
68 #include "gstrtpulpfecdec.h"
70 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
73 GST_STATIC_CAPS ("application/x-rtp")
76 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
79 GST_STATIC_CAPS ("application/x-rtp")
92 #define DEFAULT_FEC_PT 0
94 static GParamSpec *klass_properties[N_PROPERTIES] = { NULL, };
96 GST_DEBUG_CATEGORY (gst_rtp_ulpfec_dec_debug);
97 #define GST_CAT_DEFAULT (gst_rtp_ulpfec_dec_debug)
99 G_DEFINE_TYPE (GstRtpUlpFecDec, gst_rtp_ulpfec_dec, GST_TYPE_ELEMENT);
101 #define RTP_FEC_MAP_INFO_NTH(dec, data) (&g_array_index (\
102 ((GstRtpUlpFecDec *)dec)->info_arr, \
104 GPOINTER_TO_UINT(data)))
107 _compare_fec_map_info (gconstpointer a, gconstpointer b, gpointer userdata)
110 gst_rtp_buffer_get_seq (&RTP_FEC_MAP_INFO_NTH (userdata, a)->rtp);
112 gst_rtp_buffer_get_seq (&RTP_FEC_MAP_INFO_NTH (userdata, b)->rtp);
113 return gst_rtp_buffer_compare_seqnum (bseq, aseq);
117 gst_rtp_ulpfec_dec_start (GstRtpUlpFecDec * self, GstBufferList * buflist,
118 guint8 fec_pt, guint16 lost_seq)
120 guint fec_packets = 0;
123 g_assert (NULL == self->info_media);
124 g_assert (0 == self->info_fec->len);
125 g_assert (0 == self->info_arr->len);
127 g_array_set_size (self->info_arr, gst_buffer_list_length (buflist));
130 i < gst_buffer_list_length (buflist) && !self->lost_packet_from_storage;
132 GstBuffer *buffer = gst_buffer_list_get (buflist, i);
133 RtpUlpFecMapInfo *info = RTP_FEC_MAP_INFO_NTH (self, i);
135 if (!rtp_ulpfec_map_info_map (gst_buffer_ref (buffer), info))
136 g_assert_not_reached ();
138 if (fec_pt == gst_rtp_buffer_get_payload_type (&info->rtp)) {
139 GST_DEBUG_RTP_PACKET (self, "rtp header (fec)", &info->rtp);
142 if (rtp_ulpfec_buffer_is_valid (&info->rtp)) {
143 GST_DEBUG_FEC_PACKET (self, &info->rtp);
144 g_ptr_array_add (self->info_fec, GUINT_TO_POINTER (i));
147 GST_LOG_RTP_PACKET (self, "rtp header (incoming)", &info->rtp);
149 if (lost_seq == gst_rtp_buffer_get_seq (&info->rtp)) {
150 GST_DEBUG_OBJECT (self, "Received lost packet from the storage");
151 g_list_free (self->info_media);
152 self->info_media = NULL;
153 self->lost_packet_from_storage = TRUE;
156 g_list_insert_sorted_with_data (self->info_media,
157 GUINT_TO_POINTER (i), _compare_fec_map_info, self);
160 if (!self->lost_packet_from_storage) {
161 self->fec_packets_received += fec_packets;
162 self->fec_packets_rejected += fec_packets - self->info_fec->len;
167 gst_rtp_ulpfec_dec_stop (GstRtpUlpFecDec * self)
169 g_array_set_size (self->info_arr, 0);
170 g_ptr_array_set_size (self->info_fec, 0);
171 g_list_free (self->info_media);
172 self->info_media = NULL;
173 self->lost_packet_from_storage = FALSE;
174 self->lost_packet_returned = FALSE;
178 gst_rtp_ulpfec_dec_get_media_buffers_mask (GstRtpUlpFecDec * self,
179 guint16 fec_seq_base)
184 for (it = self->info_media; it; it = it->next) {
185 RtpUlpFecMapInfo *info = RTP_FEC_MAP_INFO_NTH (self, it->data);
187 rtp_ulpfec_packet_mask_from_seqnum (gst_rtp_buffer_get_seq (&info->rtp),
194 gst_rtp_ulpfec_dec_is_recovered_pt_valid (GstRtpUlpFecDec * self, gint media_pt,
198 if (media_pt == recovered_pt)
201 for (it = self->info_media; it; it = it->next) {
202 RtpUlpFecMapInfo *info = RTP_FEC_MAP_INFO_NTH (self, it->data);
203 if (gst_rtp_buffer_get_payload_type (&info->rtp) == recovered_pt)
210 gst_rtp_ulpfec_dec_recover_from_fec (GstRtpUlpFecDec * self,
211 RtpUlpFecMapInfo * info_fec, guint32 ssrc, gint media_pt, guint16 seq,
214 guint64 fec_mask = rtp_ulpfec_buffer_get_mask (&info_fec->rtp);
215 gboolean fec_mask_long = rtp_ulpfec_buffer_get_fechdr (&info_fec->rtp)->L;
216 guint16 fec_seq_base = rtp_ulpfec_buffer_get_seq_base (&info_fec->rtp);
220 g_array_set_size (self->scratch_buf, 0);
221 rtp_buffer_to_ulpfec_bitstring (&info_fec->rtp, self->scratch_buf, TRUE,
224 for (it = self->info_media; it; it = it->next) {
225 RtpUlpFecMapInfo *info = RTP_FEC_MAP_INFO_NTH (self, it->data);
226 guint64 packet_mask =
227 rtp_ulpfec_packet_mask_from_seqnum (gst_rtp_buffer_get_seq (&info->rtp),
230 if (fec_mask & packet_mask) {
231 fec_mask ^= packet_mask;
232 rtp_buffer_to_ulpfec_bitstring (&info->rtp, self->scratch_buf, FALSE,
238 rtp_ulpfec_bitstring_to_media_rtp_buffer (self->scratch_buf,
239 fec_mask_long, ssrc, seq);
241 /* We are about to put recovered packet back in self->info_media to be able
242 * to reuse it later for recovery of other packets
244 gint i = self->info_arr->len;
245 RtpUlpFecMapInfo *info;
248 g_array_set_size (self->info_arr, self->info_arr->len + 1);
249 info = RTP_FEC_MAP_INFO_NTH (self, i);
251 if (!rtp_ulpfec_map_info_map (gst_buffer_ref (ret), info)) {
252 GST_WARNING_OBJECT (self, "Invalid recovered packet");
253 goto recovered_packet_invalid;
256 recovered_pt = gst_rtp_buffer_get_payload_type (&info->rtp);
257 if (!gst_rtp_ulpfec_dec_is_recovered_pt_valid (self, media_pt,
259 GST_WARNING_OBJECT (self,
260 "Recovered packet has unexpected payload type (%u)", recovered_pt);
261 goto recovered_packet_invalid;
264 GST_DEBUG_RTP_PACKET (self, "rtp header (recovered)", &info->rtp);
266 g_list_insert_sorted_with_data (self->info_media, GUINT_TO_POINTER (i),
267 _compare_fec_map_info, self);
268 *dst_pt = recovered_pt;
272 recovered_packet_invalid:
273 g_array_set_size (self->info_arr, self->info_arr->len - 1);
274 gst_buffer_unref (ret);
279 gst_rtp_ulpfec_dec_recover_from_storage (GstRtpUlpFecDec * self,
280 guint8 * dst_pt, guint16 * dst_seq)
282 RtpUlpFecMapInfo *info;
284 if (self->lost_packet_returned)
287 g_assert (g_list_length (self->info_media) == 1);
289 info = RTP_FEC_MAP_INFO_NTH (self, self->info_media->data);
290 *dst_seq = gst_rtp_buffer_get_seq (&info->rtp);
291 *dst_pt = gst_rtp_buffer_get_payload_type (&info->rtp);
292 self->lost_packet_returned = TRUE;
293 GST_DEBUG_RTP_PACKET (self, "rtp header (recovered)", &info->rtp);
294 return gst_buffer_ref (info->rtp.buffer);
297 /* __has_builtin only works with clang, so test compiler version for gcc */
298 /* Intel compiler and MSVC probably have their own things as well */
299 /* TODO: make sure we use builtin for clang as well */
300 #if defined(__GNUC__) && __GNUC__ >= 4
301 #define rtp_ulpfec_ctz64 __builtin_ctzll
304 rtp_ulpfec_ctz64_inline (guint64 mask)
312 } while (++nth_bit < 64);
314 return -1; /* should not be reached, since mask must not be 0 */
317 #define rtp_ulpfec_ctz64 rtp_ulpfec_ctz64_inline
321 gst_rtp_ulpfec_dec_recover (GstRtpUlpFecDec * self, guint32 ssrc, gint media_pt,
322 guint8 * dst_pt, guint16 * dst_seq)
324 guint64 media_mask = 0;
325 gint media_mask_seq_base = -1;
328 if (self->lost_packet_from_storage)
329 return gst_rtp_ulpfec_dec_recover_from_storage (self, dst_pt, dst_seq);
331 /* Looking for a FEC packet which can be used for recovery */
332 for (i = 0; i < self->info_fec->len; ++i) {
333 RtpUlpFecMapInfo *info = RTP_FEC_MAP_INFO_NTH (self,
334 g_ptr_array_index (self->info_fec, i));
335 guint16 seq_base = rtp_ulpfec_buffer_get_seq_base (&info->rtp);
336 guint64 fec_mask = rtp_ulpfec_buffer_get_mask (&info->rtp);
337 guint64 missing_packets_mask;
339 if (media_mask_seq_base != (gint) seq_base) {
340 media_mask_seq_base = seq_base;
341 media_mask = gst_rtp_ulpfec_dec_get_media_buffers_mask (self, seq_base);
344 /* media_mask has 1s if packet exist.
345 * fec_mask is the mask of protected packets
346 * The statement below excludes existing packets from the protected. So
347 * we are left with 1s only for missing packets which can be recovered
348 * by this FEC packet. */
349 missing_packets_mask = fec_mask & (~media_mask);
351 /* Do we have any 1s? Checking if current FEC packet can be used for recovery */
352 if (0 != missing_packets_mask) {
353 guint trailing_zeros = rtp_ulpfec_ctz64 (missing_packets_mask);
355 /* Is it the only 1 in the mask? Checking if we lacking single packet in
356 * that case FEC packet can be used for recovery */
357 if (missing_packets_mask == (G_GUINT64_CONSTANT (1) << trailing_zeros)) {
361 seq_base + (RTP_ULPFEC_SEQ_BASE_OFFSET_MAX (TRUE) - trailing_zeros);
363 gst_rtp_ulpfec_dec_recover_from_fec (self, info, ssrc, media_pt,
374 gst_rtp_ulpfec_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
376 GstRtpUlpFecDec *self = GST_RTP_ULPFEC_DEC (parent);
378 if (G_LIKELY (GST_FLOW_OK == self->chain_return_val)) {
379 GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
380 buf = gst_buffer_make_writable (buf);
382 if (G_UNLIKELY (self->unset_discont_flag)) {
383 self->unset_discont_flag = FALSE;
384 GST_BUFFER_FLAG_UNSET (buf, GST_BUFFER_FLAG_DISCONT);
387 gst_rtp_buffer_map (buf, GST_MAP_WRITE, &rtp);
388 gst_rtp_buffer_set_seq (&rtp, self->next_seqnum++);
389 gst_rtp_buffer_unmap (&rtp);
391 return gst_pad_push (self->srcpad, buf);
394 gst_buffer_unref (buf);
395 return self->chain_return_val;
399 gst_rtp_ulpfec_dec_handle_packet_loss (GstRtpUlpFecDec * self, guint16 seqnum,
400 GstClockTime timestamp, GstClockTime duration)
402 gint caps_pt = self->have_caps_pt ? self->caps_pt : -1;
404 GstBufferList *buflist =
405 rtp_storage_get_packets_for_recovery (self->storage, self->fec_pt,
406 self->caps_ssrc, seqnum);
409 GstBuffer *recovered_buffer = NULL;
410 guint16 recovered_seq = 0;
411 guint8 recovered_pt = 0;
413 gst_rtp_ulpfec_dec_start (self, buflist, self->fec_pt, seqnum);
415 while (NULL != (recovered_buffer =
416 gst_rtp_ulpfec_dec_recover (self, self->caps_ssrc, caps_pt,
417 &recovered_pt, &recovered_seq))) {
418 if (seqnum == recovered_seq) {
419 GstBuffer *sent_buffer;
420 GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
422 recovered_buffer = gst_buffer_make_writable (recovered_buffer);
423 GST_BUFFER_PTS (recovered_buffer) = timestamp;
424 /* GST_BUFFER_DURATION (recovered_buffer) = duration;
425 * JB does not set the duration, so we will not too */
427 if (!self->lost_packet_from_storage)
428 rtp_storage_put_recovered_packet (self->storage,
429 recovered_buffer, recovered_pt, self->caps_ssrc, recovered_seq);
431 GST_DEBUG_OBJECT (self,
432 "Pushing recovered packet ssrc=0x%08x seq=%u %" GST_PTR_FORMAT,
433 self->caps_ssrc, seqnum, recovered_buffer);
435 sent_buffer = gst_buffer_copy_deep (recovered_buffer);
437 if (self->lost_packet_from_storage)
438 gst_buffer_unref (recovered_buffer);
440 gst_rtp_buffer_map (sent_buffer, GST_MAP_WRITE, &rtp);
441 gst_rtp_buffer_set_seq (&rtp, self->next_seqnum++);
442 gst_rtp_buffer_unmap (&rtp);
445 self->unset_discont_flag = TRUE;
446 self->chain_return_val = gst_pad_push (self->srcpad, sent_buffer);
450 if (!self->lost_packet_from_storage) {
451 rtp_storage_put_recovered_packet (self->storage,
452 recovered_buffer, recovered_pt, self->caps_ssrc, recovered_seq);
454 gst_buffer_unref (recovered_buffer);
458 gst_rtp_ulpfec_dec_stop (self);
459 gst_buffer_list_unref (buflist);
462 GST_DEBUG_OBJECT (self, "Packet lost ssrc=0x%08x seq=%u", self->caps_ssrc,
469 gst_rtp_ulpfec_dec_handle_sink_event (GstPad * pad, GstObject * parent,
472 GstRtpUlpFecDec *self = GST_RTP_ULPFEC_DEC (parent);
473 gboolean forward = TRUE;
475 GST_LOG_OBJECT (self, "Received event %" GST_PTR_FORMAT, event);
477 if (GST_FLOW_OK == self->chain_return_val &&
478 GST_EVENT_CUSTOM_DOWNSTREAM == GST_EVENT_TYPE (event) &&
479 gst_event_has_name (event, "GstRTPPacketLost")) {
481 GstClockTime timestamp, duration;
484 event = gst_event_make_writable (event);
485 s = gst_event_writable_structure (event);
487 g_assert (self->have_caps_ssrc);
489 if (self->storage == NULL) {
490 GstQuery *q = gst_query_new_custom (GST_QUERY_CUSTOM,
491 gst_structure_new_empty ("GstRtpStorage"));
493 if (gst_pad_peer_query (self->sinkpad, q)) {
494 const GstStructure *s = gst_query_get_structure (q);
496 if (gst_structure_has_field_typed (s, "storage", G_TYPE_OBJECT)) {
497 gst_structure_get (s, "storage", G_TYPE_OBJECT, &self->storage, NULL);
503 if (self->storage == NULL) {
504 GST_ELEMENT_WARNING (self, STREAM, FAILED, ("Internal storage not found"),
505 ("You need to add rtpstorage element upstream from rtpulpfecdec."));
509 if (!gst_structure_get (s,
510 "seqnum", G_TYPE_UINT, &seqnum,
511 "timestamp", G_TYPE_UINT64, ×tamp,
512 "duration", G_TYPE_UINT64, &duration, NULL))
513 g_assert_not_reached ();
516 gst_rtp_ulpfec_dec_handle_packet_loss (self, seqnum, timestamp,
520 gst_structure_remove_field (s, "seqnum");
521 gst_structure_set (s, "might-have-been-fec", G_TYPE_BOOLEAN, TRUE, NULL);
522 ++self->packets_unrecovered;
524 ++self->packets_recovered;
527 GST_DEBUG_OBJECT (self, "Unrecovered / Recovered: %lu / %lu",
528 (gulong) self->packets_unrecovered, (gulong) self->packets_recovered);
529 } else if (GST_EVENT_CAPS == GST_EVENT_TYPE (event)) {
531 gboolean have_caps_pt = FALSE;
532 gboolean have_caps_ssrc = FALSE;
536 gst_event_parse_caps (event, &caps);
538 gst_structure_get_uint (gst_caps_get_structure (caps, 0), "ssrc",
541 gst_structure_get_int (gst_caps_get_structure (caps, 0), "payload",
544 if (self->have_caps_ssrc != have_caps_ssrc || self->caps_ssrc != caps_ssrc)
545 GST_DEBUG_OBJECT (self, "SSRC changed %u, 0x%08x -> %u, 0x%08x",
546 self->have_caps_ssrc, self->caps_ssrc, have_caps_ssrc, caps_ssrc);
547 if (self->have_caps_pt != have_caps_pt || self->caps_pt != caps_pt)
548 GST_DEBUG_OBJECT (self, "PT changed %u, %u -> %u, %u",
549 self->have_caps_pt, self->caps_pt, have_caps_pt, caps_pt);
551 self->have_caps_ssrc = have_caps_ssrc;
552 self->have_caps_pt = have_caps_pt;
553 self->caps_ssrc = caps_ssrc;
554 self->caps_pt = caps_pt;
558 return gst_pad_push_event (self->srcpad, event);
559 gst_event_unref (event);
564 gst_rtp_ulpfec_dec_init (GstRtpUlpFecDec * self)
566 self->srcpad = gst_pad_new_from_static_template (&srctemplate, "src");
567 self->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink");
568 GST_PAD_SET_PROXY_CAPS (self->sinkpad);
569 GST_PAD_SET_PROXY_ALLOCATION (self->sinkpad);
570 gst_pad_set_chain_function (self->sinkpad,
571 GST_DEBUG_FUNCPTR (gst_rtp_ulpfec_dec_chain));
572 gst_pad_set_event_function (self->sinkpad,
573 GST_DEBUG_FUNCPTR (gst_rtp_ulpfec_dec_handle_sink_event));
575 gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
576 gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
578 self->fec_pt = DEFAULT_FEC_PT;
580 self->next_seqnum = g_random_int_range (0, G_MAXINT16);
582 self->chain_return_val = GST_FLOW_OK;
583 self->have_caps_ssrc = FALSE;
585 self->info_fec = g_ptr_array_new ();
586 self->info_arr = g_array_new (FALSE, TRUE, sizeof (RtpUlpFecMapInfo));
587 g_array_set_clear_func (self->info_arr,
588 (GDestroyNotify) rtp_ulpfec_map_info_unmap);
589 self->scratch_buf = g_array_new (FALSE, TRUE, sizeof (guint8));
593 gst_rtp_ulpfec_dec_dispose (GObject * obj)
595 GstRtpUlpFecDec *self = GST_RTP_ULPFEC_DEC (obj);
597 GST_INFO_OBJECT (self,
599 " packets_recovered=%" G_GSIZE_FORMAT
600 " packets_unrecovered=%" G_GSIZE_FORMAT,
601 self->caps_ssrc, self->caps_pt,
602 self->packets_recovered, self->packets_unrecovered);
605 g_object_unref (self->storage);
607 g_assert (NULL == self->info_media);
608 g_assert (0 == self->info_fec->len);
609 g_assert (0 == self->info_arr->len);
611 if (self->fec_packets_received) {
612 GST_INFO_OBJECT (self,
613 " fec_packets_received=%" G_GSIZE_FORMAT
614 " fec_packets_rejected=%" G_GSIZE_FORMAT
615 " packets_rejected=%" G_GSIZE_FORMAT,
616 self->fec_packets_received,
617 self->fec_packets_rejected, self->packets_rejected);
620 g_ptr_array_free (self->info_fec, TRUE);
621 g_array_free (self->info_arr, TRUE);
622 g_array_free (self->scratch_buf, TRUE);
624 G_OBJECT_CLASS (gst_rtp_ulpfec_dec_parent_class)->dispose (obj);
628 gst_rtp_ulpfec_dec_set_property (GObject * object, guint prop_id,
629 const GValue * value, GParamSpec * pspec)
631 GstRtpUlpFecDec *self = GST_RTP_ULPFEC_DEC (object);
635 self->fec_pt = g_value_get_uint (value);
639 g_object_unref (self->storage);
640 self->storage = g_value_get_object (value);
642 g_object_ref (self->storage);
645 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
651 gst_rtp_ulpfec_dec_get_property (GObject * object, guint prop_id,
652 GValue * value, GParamSpec * pspec)
654 GstRtpUlpFecDec *self = GST_RTP_ULPFEC_DEC (object);
658 g_value_set_uint (value, self->fec_pt);
661 g_value_set_object (value, self->storage);
664 g_value_set_uint (value, (guint) self->packets_recovered);
666 case PROP_UNRECOVERED:
667 g_value_set_uint (value, (guint) self->packets_unrecovered);
670 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
676 gst_rtp_ulpfec_dec_class_init (GstRtpUlpFecDecClass * klass)
678 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
679 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
681 GST_DEBUG_CATEGORY_INIT (gst_rtp_ulpfec_dec_debug,
682 "rtpulpfecdec", 0, "RTP FEC Decoder");
684 gst_element_class_add_pad_template (element_class,
685 gst_static_pad_template_get (&srctemplate));
686 gst_element_class_add_pad_template (element_class,
687 gst_static_pad_template_get (&sinktemplate));
689 gst_element_class_set_static_metadata (element_class,
691 "Codec/Depayloader/Network/RTP",
692 "Decodes RTP FEC (RFC5109)", "Mikhail Fludkov <misha@pexip.com>");
694 gobject_class->set_property =
695 GST_DEBUG_FUNCPTR (gst_rtp_ulpfec_dec_set_property);
696 gobject_class->get_property =
697 GST_DEBUG_FUNCPTR (gst_rtp_ulpfec_dec_get_property);
698 gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_rtp_ulpfec_dec_dispose);
700 klass_properties[PROP_PT] = g_param_spec_uint ("pt", "pt",
701 "FEC packets payload type", 0, 127,
702 DEFAULT_FEC_PT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
703 klass_properties[PROP_STORAGE] =
704 g_param_spec_object ("storage", "RTP storage", "RTP storage",
705 G_TYPE_OBJECT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
706 klass_properties[PROP_RECOVERED] =
707 g_param_spec_uint ("recovered", "recovered",
708 "The number of recovered packets", 0, G_MAXUINT, 0,
709 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
710 klass_properties[PROP_UNRECOVERED] =
711 g_param_spec_uint ("unrecovered", "unrecovered",
712 "The number of unrecovered packets", 0, G_MAXUINT, 0,
713 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
715 g_object_class_install_properties (gobject_class, N_PROPERTIES,
718 g_assert (rtp_ulpfec_ctz64 (G_GUINT64_CONSTANT (0x1)) == 0);
719 g_assert (rtp_ulpfec_ctz64 (G_GUINT64_CONSTANT (0x8000000000000000)) == 63);