blob: a0d6cbe37518d6d4c9a4060376ba117a76a56fb8 [file] [log] [blame]
Wim Taymansff825a22013-08-12 16:15:54 +02001/* RTP Retransmission queue element for GStreamer
2 *
3 * gstrtprtxqueue.c:
4 *
5 * Copyright (C) 2013 Wim Taymans <wim.taymans@gmail.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22
23/**
24 * SECTION:element-rtprtxqueue
George Kiagiadakis3e916012017-03-20 12:03:29 +020025 *
26 * rtprtxqueue maintains a queue of transmitted RTP packets, up to a
27 * configurable limit (see #GstRTPRtxQueue::max-size-time,
28 * #GstRTPRtxQueue::max-size-packets), and retransmits them upon request
29 * from the downstream rtpsession (GstRTPRetransmissionRequest event).
30 *
31 * This element is similar to rtprtxsend, but it has differences:
32 * - Retransmission from rtprtxqueue is not RFC 4588 compliant. The
33 * retransmitted packets have the same ssrc and payload type as the original
34 * stream.
35 * - As a side-effect of the above, rtprtxqueue does not require the use of
36 * rtprtxreceive on the receiving end. rtpjitterbuffer alone is able to
37 * reconstruct the stream.
38 * - Retransmission from rtprtxqueue happens as soon as the next regular flow
39 * packet is chained, while rtprtxsend retransmits as soon as the retransmission
40 * event is received, using a helper thread.
41 * - rtprtxqueue can be used with rtpbin without the need of hooking to its
42 * #GstRtpBin::request-aux-sender signal, which means it can be used with
43 * rtpbin using gst-launch.
44 *
45 * See also #GstRtpRtxSend, #GstRtpRtxReceive
46 *
47 * # Example pipelines
48 * |[
49 * gst-launch-1.0 rtpbin name=b rtp-profile=avpf \
50 * audiotestsrc is-live=true ! opusenc ! rtpopuspay pt=96 ! rtprtxqueue ! b.send_rtp_sink_0 \
51 * b.send_rtp_src_0 ! identity drop-probability=0.01 ! udpsink host="127.0.0.1" port=5000 \
52 * udpsrc port=5001 ! b.recv_rtcp_sink_0 \
53 * b.send_rtcp_src_0 ! udpsink host="127.0.0.1" port=5002 sync=false async=false
54 * ]| Sender pipeline
55 * |[
56 * gst-launch-1.0 rtpbin name=b rtp-profile=avpf do-retransmission=true \
57 * udpsrc port=5000 caps="application/x-rtp,media=(string)audio,clock-rate=(int)48000,encoding-name=(string)OPUS,payload=(int)96" ! \
58 * b.recv_rtp_sink_0 \
59 * b. ! rtpopusdepay ! opusdec ! audioconvert ! audioresample ! autoaudiosink \
60 * udpsrc port=5002 ! b.recv_rtcp_sink_0 \
61 * b.send_rtcp_src_0 ! udpsink host="127.0.0.1" port=5001 sync=false async=false
62 * ]| Receiver pipeline
Wim Taymansff825a22013-08-12 16:15:54 +020063 */
64
65#ifdef HAVE_CONFIG_H
66#include "config.h"
67#endif
68
69#include <gst/gst.h>
70#include <gst/rtp/gstrtpbuffer.h>
71#include <string.h>
72
73#include "gstrtprtxqueue.h"
74
75GST_DEBUG_CATEGORY_STATIC (gst_rtp_rtx_queue_debug);
76#define GST_CAT_DEFAULT gst_rtp_rtx_queue_debug
77
Wim Taymans54e7e752013-08-23 15:47:25 +020078#define DEFAULT_MAX_SIZE_TIME 0
79#define DEFAULT_MAX_SIZE_PACKETS 100
80
Wim Taymansff825a22013-08-12 16:15:54 +020081enum
82{
83 PROP_0,
Wim Taymans54e7e752013-08-23 15:47:25 +020084 PROP_MAX_SIZE_TIME,
Mathieu Duponchelle191330c2017-01-11 18:52:28 +010085 PROP_MAX_SIZE_PACKETS,
86 PROP_REQUESTS,
87 PROP_FULFILLED_REQUESTS,
Wim Taymansff825a22013-08-12 16:15:54 +020088};
89
90static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
91 GST_PAD_SRC,
92 GST_PAD_ALWAYS,
93 GST_STATIC_CAPS ("application/x-rtp")
94 );
95
96static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
97 GST_PAD_SINK,
98 GST_PAD_ALWAYS,
99 GST_STATIC_CAPS ("application/x-rtp")
100 );
101
102static gboolean gst_rtp_rtx_queue_src_event (GstPad * pad, GstObject * parent,
103 GstEvent * event);
George Kiagiadakis7f6c7832017-04-04 17:33:31 +0300104static gboolean gst_rtp_rtx_queue_sink_event (GstPad * pad, GstObject * parent,
105 GstEvent * event);
Wim Taymansff825a22013-08-12 16:15:54 +0200106static GstFlowReturn gst_rtp_rtx_queue_chain (GstPad * pad, GstObject * parent,
107 GstBuffer * buffer);
Sebastian Dröge57ff27f2015-03-19 11:39:38 +0100108static GstFlowReturn gst_rtp_rtx_queue_chain_list (GstPad * pad,
109 GstObject * parent, GstBufferList * list);
Wim Taymansff825a22013-08-12 16:15:54 +0200110
111static GstStateChangeReturn gst_rtp_rtx_queue_change_state (GstElement *
112 element, GstStateChange transition);
113
114static void gst_rtp_rtx_queue_set_property (GObject * object, guint prop_id,
115 const GValue * value, GParamSpec * pspec);
116static void gst_rtp_rtx_queue_get_property (GObject * object, guint prop_id,
117 GValue * value, GParamSpec * pspec);
118static void gst_rtp_rtx_queue_finalize (GObject * object);
119
120G_DEFINE_TYPE (GstRTPRtxQueue, gst_rtp_rtx_queue, GST_TYPE_ELEMENT);
121
122static void
123gst_rtp_rtx_queue_class_init (GstRTPRtxQueueClass * klass)
124{
125 GObjectClass *gobject_class;
126 GstElementClass *gstelement_class;
127
128 gobject_class = (GObjectClass *) klass;
129 gstelement_class = (GstElementClass *) klass;
130
Wim Taymans54e7e752013-08-23 15:47:25 +0200131 gobject_class->get_property = gst_rtp_rtx_queue_get_property;
132 gobject_class->set_property = gst_rtp_rtx_queue_set_property;
133 gobject_class->finalize = gst_rtp_rtx_queue_finalize;
134
135 g_object_class_install_property (gobject_class, PROP_MAX_SIZE_TIME,
136 g_param_spec_uint ("max-size-time", "Max Size Times",
137 "Amount of ms to queue (0 = unlimited)", 0, G_MAXUINT,
138 DEFAULT_MAX_SIZE_TIME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
139
140 g_object_class_install_property (gobject_class, PROP_MAX_SIZE_PACKETS,
141 g_param_spec_uint ("max-size-packets", "Max Size Packets",
142 "Amount of packets to queue (0 = unlimited)", 0, G_MAXUINT,
143 DEFAULT_MAX_SIZE_PACKETS,
144 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
145
Mathieu Duponchelle191330c2017-01-11 18:52:28 +0100146 g_object_class_install_property (gobject_class, PROP_REQUESTS,
147 g_param_spec_uint ("requests", "Requests",
148 "Total number of retransmission requests", 0, G_MAXUINT,
149 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
150
151 g_object_class_install_property (gobject_class, PROP_FULFILLED_REQUESTS,
152 g_param_spec_uint ("fulfilled-requests", "Fulfilled Requests",
153 "Number of fulfilled retransmission requests", 0, G_MAXUINT,
154 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
155
Vineeth TM10713092016-03-04 10:30:12 +0900156 gst_element_class_add_static_pad_template (gstelement_class, &src_factory);
157 gst_element_class_add_static_pad_template (gstelement_class, &sink_factory);
Wim Taymansff825a22013-08-12 16:15:54 +0200158
159 gst_element_class_set_static_metadata (gstelement_class,
160 "RTP Retransmission Queue", "Codec",
161 "Keep RTP packets in a queue for retransmission",
162 "Wim Taymans <wim.taymans@gmail.com>");
163
Wim Taymansff825a22013-08-12 16:15:54 +0200164 gstelement_class->change_state =
165 GST_DEBUG_FUNCPTR (gst_rtp_rtx_queue_change_state);
166}
167
168static void
Wim Taymans89b90192013-08-21 16:53:59 +0200169gst_rtp_rtx_queue_reset (GstRTPRtxQueue * rtx, gboolean full)
170{
171 g_mutex_lock (&rtx->lock);
172 g_queue_foreach (rtx->queue, (GFunc) gst_buffer_unref, NULL);
173 g_queue_clear (rtx->queue);
174 g_list_foreach (rtx->pending, (GFunc) gst_buffer_unref, NULL);
175 g_list_free (rtx->pending);
176 rtx->pending = NULL;
Mathieu Duponchelle191330c2017-01-11 18:52:28 +0100177 rtx->n_requests = 0;
178 rtx->n_fulfilled_requests = 0;
Wim Taymans89b90192013-08-21 16:53:59 +0200179 g_mutex_unlock (&rtx->lock);
180}
181
182static void
Wim Taymansff825a22013-08-12 16:15:54 +0200183gst_rtp_rtx_queue_finalize (GObject * object)
184{
185 GstRTPRtxQueue *rtx = GST_RTP_RTX_QUEUE (object);
186
Wim Taymans89b90192013-08-21 16:53:59 +0200187 gst_rtp_rtx_queue_reset (rtx, TRUE);
Wim Taymansff825a22013-08-12 16:15:54 +0200188 g_queue_free (rtx->queue);
Wim Taymans89b90192013-08-21 16:53:59 +0200189 g_mutex_clear (&rtx->lock);
Wim Taymansff825a22013-08-12 16:15:54 +0200190
191 G_OBJECT_CLASS (gst_rtp_rtx_queue_parent_class)->finalize (object);
192}
193
194static void
195gst_rtp_rtx_queue_init (GstRTPRtxQueue * rtx)
196{
197 GstElementClass *klass = GST_ELEMENT_GET_CLASS (rtx);
198
199 rtx->srcpad =
200 gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
201 "src"), "src");
202 GST_PAD_SET_PROXY_CAPS (rtx->srcpad);
203 GST_PAD_SET_PROXY_ALLOCATION (rtx->srcpad);
204 gst_pad_set_event_function (rtx->srcpad,
205 GST_DEBUG_FUNCPTR (gst_rtp_rtx_queue_src_event));
206 gst_element_add_pad (GST_ELEMENT (rtx), rtx->srcpad);
207
208 rtx->sinkpad =
209 gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
210 "sink"), "sink");
211 GST_PAD_SET_PROXY_CAPS (rtx->sinkpad);
212 GST_PAD_SET_PROXY_ALLOCATION (rtx->sinkpad);
George Kiagiadakis7f6c7832017-04-04 17:33:31 +0300213 gst_pad_set_event_function (rtx->sinkpad,
214 GST_DEBUG_FUNCPTR (gst_rtp_rtx_queue_sink_event));
Wim Taymansff825a22013-08-12 16:15:54 +0200215 gst_pad_set_chain_function (rtx->sinkpad,
216 GST_DEBUG_FUNCPTR (gst_rtp_rtx_queue_chain));
Sebastian Dröge57ff27f2015-03-19 11:39:38 +0100217 gst_pad_set_chain_list_function (rtx->sinkpad,
218 GST_DEBUG_FUNCPTR (gst_rtp_rtx_queue_chain_list));
Wim Taymansff825a22013-08-12 16:15:54 +0200219 gst_element_add_pad (GST_ELEMENT (rtx), rtx->sinkpad);
220
Wim Taymansff825a22013-08-12 16:15:54 +0200221 rtx->queue = g_queue_new ();
Wim Taymans89b90192013-08-21 16:53:59 +0200222 g_mutex_init (&rtx->lock);
Wim Taymans54e7e752013-08-23 15:47:25 +0200223
224 rtx->max_size_time = DEFAULT_MAX_SIZE_TIME;
225 rtx->max_size_packets = DEFAULT_MAX_SIZE_PACKETS;
Wim Taymansff825a22013-08-12 16:15:54 +0200226}
227
228typedef struct
229{
230 GstRTPRtxQueue *rtx;
231 guint seqnum;
Wim Taymans89b90192013-08-21 16:53:59 +0200232 gboolean found;
Wim Taymansff825a22013-08-12 16:15:54 +0200233} RTXData;
234
235static void
236push_seqnum (GstBuffer * buffer, RTXData * data)
237{
238 GstRTPRtxQueue *rtx = data->rtx;
239 GstRTPBuffer rtpbuffer = GST_RTP_BUFFER_INIT;
240 guint16 seqnum;
241
Wim Taymans89b90192013-08-21 16:53:59 +0200242 if (data->found)
243 return;
244
George Kiagiadakis7f6c7832017-04-04 17:33:31 +0300245 if (!GST_IS_BUFFER (buffer) ||
246 !gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtpbuffer))
Wim Taymansff825a22013-08-12 16:15:54 +0200247 return;
248
249 seqnum = gst_rtp_buffer_get_seq (&rtpbuffer);
250 gst_rtp_buffer_unmap (&rtpbuffer);
251
252 if (seqnum == data->seqnum) {
Wim Taymans89b90192013-08-21 16:53:59 +0200253 data->found = TRUE;
254 GST_DEBUG_OBJECT (rtx, "found %d", seqnum);
255 rtx->pending = g_list_prepend (rtx->pending, gst_buffer_ref (buffer));
Wim Taymansff825a22013-08-12 16:15:54 +0200256 }
257}
258
259static gboolean
260gst_rtp_rtx_queue_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
261{
262 GstRTPRtxQueue *rtx = GST_RTP_RTX_QUEUE (parent);
263 gboolean res;
264
265 switch (GST_EVENT_TYPE (event)) {
266 case GST_EVENT_CUSTOM_UPSTREAM:
267 {
268 const GstStructure *s;
269
270 s = gst_event_get_structure (event);
271 if (gst_structure_has_name (s, "GstRTPRetransmissionRequest")) {
272 guint seqnum;
273 RTXData data;
274
275 if (!gst_structure_get_uint (s, "seqnum", &seqnum))
276 seqnum = -1;
277
Wim Taymans89b90192013-08-21 16:53:59 +0200278 GST_DEBUG_OBJECT (rtx, "request %d", seqnum);
279
280 g_mutex_lock (&rtx->lock);
Wim Taymansff825a22013-08-12 16:15:54 +0200281 data.rtx = rtx;
282 data.seqnum = seqnum;
Wim Taymans89b90192013-08-21 16:53:59 +0200283 data.found = FALSE;
Mathieu Duponchelle191330c2017-01-11 18:52:28 +0100284 rtx->n_requests += 1;
Wim Taymansff825a22013-08-12 16:15:54 +0200285 g_queue_foreach (rtx->queue, (GFunc) push_seqnum, &data);
Wim Taymans89b90192013-08-21 16:53:59 +0200286 g_mutex_unlock (&rtx->lock);
287
Wim Taymansff825a22013-08-12 16:15:54 +0200288 gst_event_unref (event);
289 res = TRUE;
290 } else {
291 res = gst_pad_event_default (pad, parent, event);
292 }
293 break;
294 }
295 default:
296 res = gst_pad_event_default (pad, parent, event);
297 break;
298 }
299 return res;
300}
301
George Kiagiadakis7f6c7832017-04-04 17:33:31 +0300302static gboolean
303gst_rtp_rtx_queue_sink_event (GstPad * pad, GstObject * parent,
304 GstEvent * event)
305{
306 GstRTPRtxQueue *rtx = GST_RTP_RTX_QUEUE (parent);
307 gboolean res;
308
309 switch (GST_EVENT_TYPE (event)) {
310 case GST_EVENT_SEGMENT:
311 {
312 g_mutex_lock (&rtx->lock);
313 gst_event_copy_segment (event, &rtx->head_segment);
314 g_queue_push_head (rtx->queue, gst_event_ref (event));
315 g_mutex_unlock (&rtx->lock);
316 /* fall through */
317 }
318 default:
319 res = gst_pad_event_default (pad, parent, event);
320 break;
321 }
322 return res;
323}
324
Wim Taymans89b90192013-08-21 16:53:59 +0200325static void
326do_push (GstBuffer * buffer, GstRTPRtxQueue * rtx)
327{
Mathieu Duponchelle191330c2017-01-11 18:52:28 +0100328 rtx->n_fulfilled_requests += 1;
Wim Taymans89b90192013-08-21 16:53:59 +0200329 gst_pad_push (rtx->srcpad, buffer);
330}
331
George Kiagiadakis7f6c7832017-04-04 17:33:31 +0300332static guint32
333get_ts_diff (GstRTPRtxQueue * rtx)
334{
335 GstClockTime high_ts, low_ts;
336 GstClockTimeDiff result;
337 GstBuffer *high_buf, *low_buf;
338
339 high_buf = g_queue_peek_head (rtx->queue);
340
341 while (GST_IS_EVENT ((low_buf = g_queue_peek_tail (rtx->queue)))) {
342 GstEvent *event = g_queue_pop_tail (rtx->queue);
343 gst_event_copy_segment (event, &rtx->tail_segment);
344 gst_event_unref (event);
345 }
346
347 if (!high_buf || !low_buf || high_buf == low_buf)
348 return 0;
349
350 high_ts = GST_BUFFER_TIMESTAMP (high_buf);
351 low_ts = GST_BUFFER_TIMESTAMP (low_buf);
352
353 high_ts = gst_segment_to_running_time (&rtx->head_segment, GST_FORMAT_TIME,
354 high_ts);
355 low_ts = gst_segment_to_running_time (&rtx->tail_segment, GST_FORMAT_TIME,
356 low_ts);
357
358 result = high_ts - low_ts;
359
360 /* return value in ms instead of ns */
361 return (guint32) gst_util_uint64_scale_int (result, 1, GST_MSECOND);
362}
363
Sebastian Dröge57ff27f2015-03-19 11:39:38 +0100364/* Must be called with rtx->lock */
365static void
366shrink_queue (GstRTPRtxQueue * rtx)
367{
368 if (rtx->max_size_packets) {
369 while (g_queue_get_length (rtx->queue) > rtx->max_size_packets)
370 gst_buffer_unref (g_queue_pop_tail (rtx->queue));
371 }
George Kiagiadakis7f6c7832017-04-04 17:33:31 +0300372 if (rtx->max_size_time) {
373 while (get_ts_diff (rtx) > rtx->max_size_time)
374 gst_buffer_unref (g_queue_pop_tail (rtx->queue));
375 }
Sebastian Dröge57ff27f2015-03-19 11:39:38 +0100376}
377
Wim Taymansff825a22013-08-12 16:15:54 +0200378static GstFlowReturn
379gst_rtp_rtx_queue_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
380{
381 GstRTPRtxQueue *rtx;
382 GstFlowReturn ret;
Wim Taymans89b90192013-08-21 16:53:59 +0200383 GList *pending;
Wim Taymansff825a22013-08-12 16:15:54 +0200384
385 rtx = GST_RTP_RTX_QUEUE (parent);
386
Wim Taymans89b90192013-08-21 16:53:59 +0200387 g_mutex_lock (&rtx->lock);
Wim Taymansff825a22013-08-12 16:15:54 +0200388 g_queue_push_head (rtx->queue, gst_buffer_ref (buffer));
Sebastian Dröge57ff27f2015-03-19 11:39:38 +0100389 shrink_queue (rtx);
Wim Taymans54e7e752013-08-23 15:47:25 +0200390
Wim Taymans89b90192013-08-21 16:53:59 +0200391 pending = rtx->pending;
392 rtx->pending = NULL;
393 g_mutex_unlock (&rtx->lock);
394
Miguel París Díaz40957a92015-06-19 14:50:59 +0200395 pending = g_list_reverse (pending);
Wim Taymans89b90192013-08-21 16:53:59 +0200396 g_list_foreach (pending, (GFunc) do_push, rtx);
397 g_list_free (pending);
Wim Taymansff825a22013-08-12 16:15:54 +0200398
399 ret = gst_pad_push (rtx->srcpad, buffer);
400
401 return ret;
402}
403
Sebastian Dröge57ff27f2015-03-19 11:39:38 +0100404static gboolean
405push_to_queue (GstBuffer ** buffer, guint idx, gpointer user_data)
406{
407 GQueue *queue = user_data;
408
409 g_queue_push_head (queue, gst_buffer_ref (*buffer));
410
411 return TRUE;
412}
413
414static GstFlowReturn
415gst_rtp_rtx_queue_chain_list (GstPad * pad, GstObject * parent,
416 GstBufferList * list)
417{
418 GstRTPRtxQueue *rtx;
419 GstFlowReturn ret;
420 GList *pending;
421
422 rtx = GST_RTP_RTX_QUEUE (parent);
423
424 g_mutex_lock (&rtx->lock);
425 gst_buffer_list_foreach (list, push_to_queue, rtx->queue);
426 shrink_queue (rtx);
427
428 pending = rtx->pending;
429 rtx->pending = NULL;
430 g_mutex_unlock (&rtx->lock);
431
Miguel París Díaz40957a92015-06-19 14:50:59 +0200432 pending = g_list_reverse (pending);
Sebastian Dröge57ff27f2015-03-19 11:39:38 +0100433 g_list_foreach (pending, (GFunc) do_push, rtx);
434 g_list_free (pending);
435
436 ret = gst_pad_push_list (rtx->srcpad, list);
437
438 return ret;
439}
440
Wim Taymansff825a22013-08-12 16:15:54 +0200441static void
442gst_rtp_rtx_queue_get_property (GObject * object,
443 guint prop_id, GValue * value, GParamSpec * pspec)
444{
Wim Taymans54e7e752013-08-23 15:47:25 +0200445 GstRTPRtxQueue *rtx = GST_RTP_RTX_QUEUE (object);
446
Wim Taymansff825a22013-08-12 16:15:54 +0200447 switch (prop_id) {
Wim Taymans54e7e752013-08-23 15:47:25 +0200448 case PROP_MAX_SIZE_TIME:
449 g_value_set_uint (value, rtx->max_size_time);
450 break;
451 case PROP_MAX_SIZE_PACKETS:
452 g_value_set_uint (value, rtx->max_size_packets);
453 break;
Mathieu Duponchelle191330c2017-01-11 18:52:28 +0100454 case PROP_REQUESTS:
455 g_value_set_uint (value, rtx->n_requests);
456 break;
457 case PROP_FULFILLED_REQUESTS:
458 g_value_set_uint (value, rtx->n_fulfilled_requests);
459 break;
Wim Taymansff825a22013-08-12 16:15:54 +0200460 default:
461 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
462 break;
463 }
464}
465
466static void
467gst_rtp_rtx_queue_set_property (GObject * object,
468 guint prop_id, const GValue * value, GParamSpec * pspec)
469{
Wim Taymans54e7e752013-08-23 15:47:25 +0200470 GstRTPRtxQueue *rtx = GST_RTP_RTX_QUEUE (object);
471
Wim Taymansff825a22013-08-12 16:15:54 +0200472 switch (prop_id) {
Wim Taymans54e7e752013-08-23 15:47:25 +0200473 case PROP_MAX_SIZE_TIME:
474 rtx->max_size_time = g_value_get_uint (value);
475 break;
476 case PROP_MAX_SIZE_PACKETS:
477 rtx->max_size_packets = g_value_get_uint (value);
478 break;
Wim Taymansff825a22013-08-12 16:15:54 +0200479 default:
480 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
481 break;
482 }
483}
484
485static GstStateChangeReturn
486gst_rtp_rtx_queue_change_state (GstElement * element, GstStateChange transition)
487{
488 GstStateChangeReturn ret;
Wim Taymans89b90192013-08-21 16:53:59 +0200489 GstRTPRtxQueue *rtx;
490
491 rtx = GST_RTP_RTX_QUEUE (element);
Wim Taymansff825a22013-08-12 16:15:54 +0200492
493 switch (transition) {
494 default:
495 break;
496 }
497
498 ret =
499 GST_ELEMENT_CLASS (gst_rtp_rtx_queue_parent_class)->change_state (element,
500 transition);
501
502 switch (transition) {
Wim Taymans89b90192013-08-21 16:53:59 +0200503 case GST_STATE_CHANGE_PAUSED_TO_READY:
504 gst_rtp_rtx_queue_reset (rtx, TRUE);
505 break;
Wim Taymansff825a22013-08-12 16:15:54 +0200506 default:
507 break;
508 }
509
510 return ret;
511}
512
513gboolean
514gst_rtp_rtx_queue_plugin_init (GstPlugin * plugin)
515{
516 GST_DEBUG_CATEGORY_INIT (gst_rtp_rtx_queue_debug, "rtprtxqueue", 0,
517 "rtp retransmission queue");
518
519 return gst_element_register (plugin, "rtprtxqueue", GST_RANK_NONE,
520 GST_TYPE_RTP_RTX_QUEUE);
521}