rtpmux: update the current_ssrc from the caps
[platform/upstream/gst-plugins-good.git] / gst / rtpmanager / gstrtpmux.c
1 /* RTP muxer element for GStreamer
2  *
3  * gstrtpmux.c:
4  *
5  * Copyright (C) <2007> Nokia Corporation.
6  *   Contact: Zeeshan Ali <zeeshan.ali@nokia.com>
7  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
8  *               2000,2005 Wim Taymans <wim@fluendo.com>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  */
25
26 /**
27  * SECTION:element-rtpmux
28  *
29  * The rtp muxer takes multiple RTP streams having the same clock-rate and
30  * muxes into a single stream with a single SSRC.
31  */
32
33 #ifdef HAVE_CONFIG_H
34 #include "config.h"
35 #endif
36
37 #include <gst/gst.h>
38 #include <gst/rtp/gstrtpbuffer.h>
39 #include <string.h>
40
41 #include "gstrtpmux.h"
42
43 GST_DEBUG_CATEGORY_STATIC (gst_rtp_mux_debug);
44 #define GST_CAT_DEFAULT gst_rtp_mux_debug
45
46 /* elementfactory information */
47 static const GstElementDetails gst_rtp_mux_details =
48 GST_ELEMENT_DETAILS ("RTP muxer",
49     "Codec/Muxer",
50     "multiplex N rtp streams into one",
51     "Zeeshan Ali <first.last@nokia.com>");
52
53 enum
54 {
55   ARG_0,
56   PROP_TIMESTAMP_OFFSET,
57   PROP_SEQNUM_OFFSET,
58   PROP_SEQNUM,
59   PROP_SSRC
60 };
61
62 #define DEFAULT_TIMESTAMP_OFFSET -1
63 #define DEFAULT_SEQNUM_OFFSET    -1
64 #define DEFAULT_SSRC             -1
65
66 typedef struct
67 {
68   gboolean have_clock_base;
69   guint clock_base;
70
71   GstCaps *out_caps;
72 } GstRTPMuxPadPrivate;
73
74 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
75     GST_PAD_SRC,
76     GST_PAD_ALWAYS,
77     GST_STATIC_CAPS ("application/x-rtp")
78     );
79
80 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%d",
81     GST_PAD_SINK,
82     GST_PAD_REQUEST,
83     GST_STATIC_CAPS ("application/x-rtp")
84     );
85
86 static GstPad *gst_rtp_mux_request_new_pad (GstElement * element,
87     GstPadTemplate * templ, const gchar * name);
88 static void gst_rtp_mux_release_pad (GstElement * element, GstPad * pad);
89 static GstFlowReturn gst_rtp_mux_chain (GstPad * pad, GstBuffer * buffer);
90 static gboolean gst_rtp_mux_setcaps (GstPad * pad, GstCaps * caps);
91 static GstCaps *gst_rtp_mux_getcaps (GstPad * pad);
92
93 static GstStateChangeReturn gst_rtp_mux_change_state (GstElement *
94     element, GstStateChange transition);
95
96 static void gst_rtp_mux_set_property (GObject * object, guint prop_id,
97     const GValue * value, GParamSpec * pspec);
98 static void gst_rtp_mux_get_property (GObject * object, guint prop_id,
99     GValue * value, GParamSpec * pspec);
100 static void gst_rtp_mux_dispose (GObject * object);
101
102 GST_BOILERPLATE (GstRTPMux, gst_rtp_mux, GstElement, GST_TYPE_ELEMENT);
103
104 static void
105 gst_rtp_mux_base_init (gpointer g_class)
106 {
107   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
108
109   gst_element_class_add_pad_template (element_class,
110       gst_static_pad_template_get (&src_factory));
111   gst_element_class_add_pad_template (element_class,
112       gst_static_pad_template_get (&sink_factory));
113
114   gst_element_class_set_details (element_class, &gst_rtp_mux_details);
115 }
116
117 static void
118 gst_rtp_mux_class_init (GstRTPMuxClass * klass)
119 {
120   GObjectClass *gobject_class;
121   GstElementClass *gstelement_class;
122
123   gobject_class = (GObjectClass *) klass;
124   gstelement_class = (GstElementClass *) klass;
125
126   gobject_class->get_property = gst_rtp_mux_get_property;
127   gobject_class->set_property = gst_rtp_mux_set_property;
128   gobject_class->dispose = gst_rtp_mux_dispose;
129
130   g_object_class_install_property (G_OBJECT_CLASS (klass),
131       PROP_TIMESTAMP_OFFSET, g_param_spec_int ("timestamp-offset",
132           "Timestamp Offset",
133           "Offset to add to all outgoing timestamps (-1 = random)", -1,
134           G_MAXINT, DEFAULT_TIMESTAMP_OFFSET, G_PARAM_READWRITE));
135   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SEQNUM_OFFSET,
136       g_param_spec_int ("seqnum-offset", "Sequence number Offset",
137           "Offset to add to all outgoing seqnum (-1 = random)", -1, G_MAXINT,
138           DEFAULT_SEQNUM_OFFSET, G_PARAM_READWRITE));
139   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SEQNUM,
140       g_param_spec_uint ("seqnum", "Sequence number",
141           "The RTP sequence number of the last processed packet",
142           0, G_MAXUINT, 0, G_PARAM_READABLE));
143   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SSRC,
144       g_param_spec_uint ("ssrc", "SSRC",
145           "The SSRC of the packets (-1 == random)",
146           0, G_MAXUINT, DEFAULT_SSRC, G_PARAM_READWRITE));
147
148   gstelement_class->request_new_pad =
149       GST_DEBUG_FUNCPTR (gst_rtp_mux_request_new_pad);
150   gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_rtp_mux_release_pad);
151   gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_mux_change_state);
152
153   klass->chain_func = gst_rtp_mux_chain;
154 }
155
156 static void
157 gst_rtp_mux_dispose (GObject * object)
158 {
159   GList *item;
160
161 restart:
162   for (item = GST_ELEMENT_PADS (object); item; item = g_list_next (item)) {
163     GstPad *pad = GST_PAD (item->data);
164     if (GST_PAD_IS_SINK (pad)) {
165       gst_element_release_request_pad (GST_ELEMENT (object), pad);
166       goto restart;
167     }
168   }
169
170   G_OBJECT_CLASS (parent_class)->dispose (object);
171 }
172
173 static gboolean
174 gst_rtp_mux_src_event (GstPad * pad, GstEvent * event)
175 {
176   GstElement *rtp_mux;
177   GstIterator *iter;
178   GstPad *sinkpad;
179   gboolean result = FALSE;
180   gboolean done = FALSE;
181
182   rtp_mux = gst_pad_get_parent_element (pad);
183   g_return_val_if_fail (rtp_mux != NULL, FALSE);
184
185   iter = gst_element_iterate_sink_pads (rtp_mux);
186
187   while (!done) {
188     switch (gst_iterator_next (iter, (gpointer) & sinkpad)) {
189       case GST_ITERATOR_OK:
190         gst_event_ref (event);
191         result |= gst_pad_push_event (sinkpad, event);
192         gst_object_unref (sinkpad);
193         break;
194       case GST_ITERATOR_RESYNC:
195         gst_iterator_resync (iter);
196         result = FALSE;
197         break;
198       case GST_ITERATOR_ERROR:
199         GST_WARNING_OBJECT (rtp_mux, "Error iterating sinkpads");
200       case GST_ITERATOR_DONE:
201         done = TRUE;
202         break;
203     }
204   }
205   gst_iterator_free (iter);
206   gst_object_unref (rtp_mux);
207   gst_event_unref (event);
208
209   return result;
210 }
211
212 static void
213 gst_rtp_mux_init (GstRTPMux * object, GstRTPMuxClass * g_class)
214 {
215   GstElementClass *klass = GST_ELEMENT_GET_CLASS (object);
216
217   object->srcpad =
218       gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
219           "src"), "src");
220   gst_pad_set_event_function (object->srcpad,
221       GST_DEBUG_FUNCPTR (gst_rtp_mux_src_event));
222   gst_element_add_pad (GST_ELEMENT (object), object->srcpad);
223
224   object->ssrc = DEFAULT_SSRC;
225   object->ts_offset = DEFAULT_TIMESTAMP_OFFSET;
226   object->seqnum_offset = DEFAULT_SEQNUM_OFFSET;
227 }
228
229 static GstPad *
230 gst_rtp_mux_create_sinkpad (GstRTPMux * rtp_mux, GstPadTemplate * templ,
231     const gchar * req_name)
232 {
233   GstPad *newpad = NULL;
234   GstPadTemplate *class_templ;
235
236   class_templ =
237       gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (rtp_mux),
238       "sink_%d");
239
240   if (templ == class_templ) {
241     gchar *tmpname = NULL;
242     const gchar *name = NULL;
243
244     /* create new pad with the name */
245     if (req_name)
246       name = req_name;
247     else
248       name = tmpname = g_strdup_printf ("sink_%02d", rtp_mux->numpads);
249     newpad = gst_pad_new_from_template (templ, name);
250     g_free (tmpname);
251
252     rtp_mux->numpads++;
253   } else {
254     GST_WARNING_OBJECT (rtp_mux, "this is not our template!\n");
255   }
256
257   return newpad;
258 }
259
260 static void
261 gst_rtp_mux_setup_sinkpad (GstRTPMux * rtp_mux, GstPad * sinkpad)
262 {
263   GstRTPMuxClass *klass;
264   GstRTPMuxPadPrivate *padpriv = g_slice_new0 (GstRTPMuxPadPrivate);
265
266   klass = GST_RTP_MUX_GET_CLASS (rtp_mux);
267
268   /* setup some pad functions */
269   gst_pad_set_setcaps_function (sinkpad, gst_rtp_mux_setcaps);
270   gst_pad_set_getcaps_function (sinkpad, gst_rtp_mux_getcaps);
271   if (klass->chain_func)
272     gst_pad_set_chain_function (sinkpad, klass->chain_func);
273   if (klass->sink_event_func)
274     gst_pad_set_event_function (sinkpad, klass->sink_event_func);
275
276   /* This could break with gstreamer 0.10.9 */
277   gst_pad_set_active (sinkpad, TRUE);
278
279   gst_pad_set_element_private (sinkpad, padpriv);
280
281   /* dd the pad to the element */
282   gst_element_add_pad (GST_ELEMENT (rtp_mux), sinkpad);
283 }
284
285 static GstPad *
286 gst_rtp_mux_request_new_pad (GstElement * element,
287     GstPadTemplate * templ, const gchar * req_name)
288 {
289   GstRTPMux *rtp_mux;
290   GstPad *newpad;
291
292   g_return_val_if_fail (templ != NULL, NULL);
293   g_return_val_if_fail (GST_IS_RTP_MUX (element), NULL);
294
295   rtp_mux = GST_RTP_MUX (element);
296
297   if (templ->direction != GST_PAD_SINK) {
298     GST_WARNING_OBJECT (rtp_mux, "request pad that is not a SINK pad");
299     return NULL;
300   }
301
302   newpad = gst_rtp_mux_create_sinkpad (rtp_mux, templ, req_name);
303   if (newpad)
304     gst_rtp_mux_setup_sinkpad (rtp_mux, newpad);
305   else
306     GST_WARNING_OBJECT (rtp_mux, "failed to create request pad");
307
308   return newpad;
309 }
310
311 static void
312 gst_rtp_mux_release_pad (GstElement * element, GstPad * pad)
313 {
314   GstRTPMuxPadPrivate *padpriv;
315
316   GST_OBJECT_LOCK (element);
317   padpriv = gst_pad_get_element_private (pad);
318   gst_pad_set_element_private (pad, NULL);
319   GST_OBJECT_UNLOCK (element);
320
321   gst_element_remove_pad (element, pad);
322
323   if (padpriv) {
324     gst_caps_replace (&padpriv->out_caps, NULL);
325     g_slice_free (GstRTPMuxPadPrivate, padpriv);
326   }
327 }
328
329 /* Put our own clock-base on the buffer */
330 static void
331 gst_rtp_mux_readjust_rtp_timestamp (GstRTPMux * rtp_mux, GstPad * pad,
332     GstBuffer * buffer)
333 {
334   guint32 ts;
335   guint32 sink_ts_base = 0;
336   GstRTPMuxPadPrivate *padpriv;
337
338
339   GST_OBJECT_LOCK (rtp_mux);
340   padpriv = gst_pad_get_element_private (pad);
341   if (padpriv && padpriv->have_clock_base)
342     sink_ts_base = padpriv->clock_base;
343   GST_OBJECT_UNLOCK (rtp_mux);
344
345   ts = gst_rtp_buffer_get_timestamp (buffer) - sink_ts_base + rtp_mux->ts_base;
346   GST_LOG_OBJECT (rtp_mux, "Re-adjusting RTP ts %u to %u",
347       gst_rtp_buffer_get_timestamp (buffer), ts);
348   gst_rtp_buffer_set_timestamp (buffer, ts);
349 }
350
351 static GstFlowReturn
352 gst_rtp_mux_chain (GstPad * pad, GstBuffer * buffer)
353 {
354   GstRTPMux *rtp_mux;
355   GstFlowReturn ret;
356   GstRTPMuxPadPrivate *padpriv;
357
358   rtp_mux = GST_RTP_MUX (gst_pad_get_parent (pad));
359
360   if (!gst_rtp_buffer_validate (buffer)) {
361     GST_ERROR_OBJECT (rtp_mux, "Invalid RTP buffer");
362     gst_object_unref (rtp_mux);
363     return GST_FLOW_ERROR;
364   }
365
366   buffer = gst_buffer_make_writable (buffer);
367
368   GST_OBJECT_LOCK (rtp_mux);
369   rtp_mux->seqnum++;
370   gst_rtp_buffer_set_seq (buffer, rtp_mux->seqnum);
371   padpriv = gst_pad_get_element_private (pad);
372   if (padpriv)
373     gst_buffer_set_caps (buffer, padpriv->out_caps);
374   GST_OBJECT_UNLOCK (rtp_mux);
375   gst_rtp_buffer_set_ssrc (buffer, rtp_mux->current_ssrc);
376   gst_rtp_mux_readjust_rtp_timestamp (rtp_mux, pad, buffer);
377   GST_LOG_OBJECT (rtp_mux, "Pushing packet size %d, seq=%d, ts=%u",
378       GST_BUFFER_SIZE (buffer), rtp_mux->seqnum,
379       gst_rtp_buffer_get_timestamp (buffer));
380
381   if (!padpriv) {
382     ret = GST_FLOW_NOT_LINKED;
383     gst_buffer_unref (buffer);
384     goto out;
385   }
386
387   ret = gst_pad_push (rtp_mux->srcpad, buffer);
388
389 out:
390
391   gst_object_unref (rtp_mux);
392   return ret;
393 }
394
395 static gboolean
396 gst_rtp_mux_setcaps (GstPad * pad, GstCaps * caps)
397 {
398   GstRTPMux *rtp_mux;
399   GstStructure *structure;
400   gboolean ret = FALSE;
401   GstRTPMuxPadPrivate *padpriv;
402
403   rtp_mux = GST_RTP_MUX (gst_pad_get_parent (pad));
404
405   structure = gst_caps_get_structure (caps, 0);
406
407   if (!structure)
408     goto out;
409
410   GST_OBJECT_LOCK (rtp_mux);
411   padpriv = gst_pad_get_element_private (pad);
412   if (padpriv &&
413       gst_structure_get_uint (structure, "clock-base", &padpriv->clock_base)) {
414     padpriv->have_clock_base = TRUE;
415   }
416   GST_OBJECT_UNLOCK (rtp_mux);
417
418   caps = gst_caps_copy (caps);
419
420   gst_caps_set_simple (caps,
421       "clock-base", G_TYPE_UINT, rtp_mux->ts_base,
422       "seqnum-base", G_TYPE_UINT, rtp_mux->seqnum_base, NULL);
423
424   GST_DEBUG_OBJECT (rtp_mux,
425       "setting caps %" GST_PTR_FORMAT " on src pad..", caps);
426   ret = gst_pad_set_caps (rtp_mux->srcpad, caps);
427
428   if (rtp_mux->ssrc == -1) {
429     if (gst_structure_has_field_typed (structure, "ssrc", G_TYPE_UINT)) {
430       rtp_mux->current_ssrc = g_value_get_uint
431           (gst_structure_get_value (structure, "ssrc"));
432     }
433   }
434
435   if (ret) {
436     GST_OBJECT_LOCK (rtp_mux);
437     padpriv = gst_pad_get_element_private (pad);
438     if (padpriv)
439       gst_caps_replace (&padpriv->out_caps, caps);
440     GST_OBJECT_UNLOCK (rtp_mux);
441   }
442   gst_caps_unref (caps);
443
444 out:
445   gst_object_unref (rtp_mux);
446
447   return ret;
448 }
449
450 static void
451 clear_caps (GstCaps * caps, gboolean only_clock_rate)
452 {
453   gint i, j;
454
455   /* Lets only match on the clock-rate */
456   for (i = 0; i < gst_caps_get_size (caps); i++) {
457     GstStructure *s = gst_caps_get_structure (caps, i);
458
459     for (j = 0; j < gst_structure_n_fields (s); j++) {
460       const gchar *name = gst_structure_nth_field_name (s, j);
461
462       if (strcmp (name, "clock-rate") && (only_clock_rate ||
463               (strcmp (name, "ssrc")))) {
464         gst_structure_remove_field (s, name);
465         j--;
466       }
467     }
468   }
469 }
470
471 static gboolean
472 same_clock_rate_fold (gpointer item, GValue * ret, gpointer user_data)
473 {
474   GstPad *mypad = user_data;
475   GstPad *pad = item;
476   GstCaps *peercaps;
477   GstCaps *othercaps;
478   const GstCaps *accumcaps;
479   GstCaps *intersect;
480
481   if (pad == mypad) {
482     gst_object_unref (pad);
483     return TRUE;
484   }
485
486   peercaps = gst_pad_peer_get_caps (pad);
487   if (!peercaps) {
488     gst_object_unref (pad);
489     return TRUE;
490   }
491
492   othercaps = gst_caps_intersect (peercaps,
493       gst_pad_get_pad_template_caps (pad));
494   gst_caps_unref (peercaps);
495
496   accumcaps = gst_value_get_caps (ret);
497
498   clear_caps (othercaps, TRUE);
499
500   intersect = gst_caps_intersect (accumcaps, othercaps);
501
502   g_value_take_boxed (ret, intersect);
503
504   gst_caps_unref (othercaps);
505   gst_object_unref (pad);
506
507   return !gst_caps_is_empty (intersect);
508 }
509
510 static GstCaps *
511 gst_rtp_mux_getcaps (GstPad * pad)
512 {
513   GstRTPMux *mux = GST_RTP_MUX (gst_pad_get_parent (pad));
514   GstCaps *caps = NULL;
515   GstIterator *iter = NULL;
516   GValue v = { 0 };
517   GstIteratorResult res;
518   GstCaps *peercaps = gst_pad_peer_get_caps (mux->srcpad);
519   GstCaps *othercaps = NULL;
520
521   if (peercaps) {
522     othercaps = gst_caps_intersect (peercaps,
523         gst_pad_get_pad_template_caps (pad));
524     gst_caps_unref (peercaps);
525   } else {
526     othercaps = gst_caps_copy (gst_pad_get_pad_template_caps (mux->srcpad));
527   }
528
529   clear_caps (othercaps, FALSE);
530
531   g_value_init (&v, GST_TYPE_CAPS);
532
533   iter = gst_element_iterate_sink_pads (GST_ELEMENT (mux));
534   do {
535     gst_value_set_caps (&v, othercaps);
536     res = gst_iterator_fold (iter, same_clock_rate_fold, &v, pad);
537   } while (res == GST_ITERATOR_RESYNC);
538   gst_iterator_free (iter);
539
540   caps = (GstCaps *) gst_value_get_caps (&v);
541
542   if (res == GST_ITERATOR_ERROR) {
543     gst_caps_unref (caps);
544     caps = gst_caps_new_empty ();
545   }
546
547   if (othercaps)
548     gst_caps_unref (othercaps);
549   gst_object_unref (mux);
550
551   return caps;
552 }
553
554
555 static void
556 gst_rtp_mux_get_property (GObject * object,
557     guint prop_id, GValue * value, GParamSpec * pspec)
558 {
559   GstRTPMux *rtp_mux;
560
561   rtp_mux = GST_RTP_MUX (object);
562
563   switch (prop_id) {
564     case PROP_TIMESTAMP_OFFSET:
565       g_value_set_int (value, rtp_mux->ts_offset);
566       break;
567     case PROP_SEQNUM_OFFSET:
568       g_value_set_int (value, rtp_mux->seqnum_offset);
569       break;
570     case PROP_SEQNUM:
571       GST_OBJECT_LOCK (rtp_mux);
572       g_value_set_uint (value, rtp_mux->seqnum);
573       GST_OBJECT_UNLOCK (rtp_mux);
574       break;
575     case PROP_SSRC:
576       g_value_set_uint (value, rtp_mux->ssrc);
577       break;
578     default:
579       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
580       break;
581   }
582 }
583
584 static void
585 gst_rtp_mux_set_property (GObject * object,
586     guint prop_id, const GValue * value, GParamSpec * pspec)
587 {
588   GstRTPMux *rtp_mux;
589
590   rtp_mux = GST_RTP_MUX (object);
591
592   switch (prop_id) {
593     case PROP_TIMESTAMP_OFFSET:
594       rtp_mux->ts_offset = g_value_get_int (value);
595       break;
596     case PROP_SEQNUM_OFFSET:
597       rtp_mux->seqnum_offset = g_value_get_int (value);
598       break;
599     case PROP_SSRC:
600       rtp_mux->ssrc = g_value_get_uint (value);
601       break;
602     default:
603       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
604       break;
605   }
606 }
607
608 static void
609 gst_rtp_mux_ready_to_paused (GstRTPMux * rtp_mux)
610 {
611   GST_OBJECT_LOCK (rtp_mux);
612
613   if (rtp_mux->ssrc == -1)
614     rtp_mux->current_ssrc = g_random_int ();
615   else
616     rtp_mux->current_ssrc = rtp_mux->ssrc;
617
618   if (rtp_mux->seqnum_offset == -1)
619     rtp_mux->seqnum_base = g_random_int_range (0, G_MAXUINT16);
620   else
621     rtp_mux->seqnum_base = rtp_mux->seqnum_offset;
622   rtp_mux->seqnum = rtp_mux->seqnum_base;
623
624   if (rtp_mux->ts_offset == -1)
625     rtp_mux->ts_base = g_random_int ();
626   else
627     rtp_mux->ts_base = rtp_mux->ts_offset;
628   GST_DEBUG_OBJECT (rtp_mux, "set clock-base to %u", rtp_mux->ts_base);
629
630   GST_OBJECT_UNLOCK (rtp_mux);
631 }
632
633 static GstStateChangeReturn
634 gst_rtp_mux_change_state (GstElement * element, GstStateChange transition)
635 {
636   GstRTPMux *rtp_mux;
637
638   rtp_mux = GST_RTP_MUX (element);
639
640   switch (transition) {
641     case GST_STATE_CHANGE_NULL_TO_READY:
642       break;
643     case GST_STATE_CHANGE_READY_TO_PAUSED:
644       gst_rtp_mux_ready_to_paused (rtp_mux);
645       break;
646     case GST_STATE_CHANGE_PAUSED_TO_READY:
647       break;
648     default:
649       break;
650   }
651
652   return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
653 }
654
655 gboolean
656 gst_rtp_mux_plugin_init (GstPlugin * plugin)
657 {
658   GST_DEBUG_CATEGORY_INIT (gst_rtp_mux_debug, "rtpmux", 0, "rtp muxer");
659
660   return gst_element_register (plugin, "rtpmux", GST_RANK_NONE,
661       GST_TYPE_RTP_MUX);
662 }