gst/rtpmanager/gstrtpjitterbuffer.c: Only peek at the tail element instead of popping...
[platform/upstream/gst-plugins-good.git] / gst / rtpmanager / gstrtpssrcdemux.c
1 /* GStreamer
2  * Copyright (C) <2007> Wim Taymans <wim@fluendo.com>
3  *
4  * RTP SSRC demuxer
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 /**
23  * SECTION:element-gstrtpssrcdemux
24  * @short_description: separate RTP payloads based on the SSRC
25  *
26  * <refsect2>
27  * <para>
28  * gstrtpssrcdemux acts as a demuxer for RTP packets based on the SSRC of the
29  * packets. Its main purpose is to allow an application to easily receive and
30  * decode an RTP stream with multiple SSRCs.
31  * </para>
32  * <para>
33  * For each SSRC that is detected, a new pad will be created and the
34  * ::new-ssrc-pad signal will be emitted. 
35  * </para>
36  * <title>Example pipelines</title>
37  * <para>
38  * <programlisting>
39  * gst-launch udpsrc caps="application/x-rtp" ! gstrtpssrcdemux ! fakesink
40  * </programlisting>
41  * Takes an RTP stream and send the RTP packets with the first detected SSRC
42  * to fakesink, discarding the other SSRCs.
43  * </para>
44  * </refsect2>
45  *
46  * Last reviewed on 2007-05-28 (0.10.5)
47  */
48
49 #ifdef HAVE_CONFIG_H
50 #include "config.h"
51 #endif
52
53 #include <string.h>
54 #include <gst/rtp/gstrtpbuffer.h>
55 #include <gst/rtp/gstrtcpbuffer.h>
56
57 #include "gstrtpbin-marshal.h"
58 #include "gstrtpssrcdemux.h"
59
60 GST_DEBUG_CATEGORY_STATIC (gst_rtp_ssrc_demux_debug);
61 #define GST_CAT_DEFAULT gst_rtp_ssrc_demux_debug
62
63 /* generic templates */
64 static GstStaticPadTemplate rtp_ssrc_demux_sink_template =
65 GST_STATIC_PAD_TEMPLATE ("sink",
66     GST_PAD_SINK,
67     GST_PAD_ALWAYS,
68     GST_STATIC_CAPS ("application/x-rtp")
69     );
70
71 static GstStaticPadTemplate rtp_ssrc_demux_rtcp_sink_template =
72 GST_STATIC_PAD_TEMPLATE ("rtcp_sink",
73     GST_PAD_SINK,
74     GST_PAD_ALWAYS,
75     GST_STATIC_CAPS ("application/x-rtcp")
76     );
77
78 static GstStaticPadTemplate rtp_ssrc_demux_src_template =
79 GST_STATIC_PAD_TEMPLATE ("src_%d",
80     GST_PAD_SRC,
81     GST_PAD_SOMETIMES,
82     GST_STATIC_CAPS ("application/x-rtp")
83     );
84
85 static GstStaticPadTemplate rtp_ssrc_demux_rtcp_src_template =
86 GST_STATIC_PAD_TEMPLATE ("rtcp_src_%d",
87     GST_PAD_SRC,
88     GST_PAD_SOMETIMES,
89     GST_STATIC_CAPS ("application/x-rtcp")
90     );
91
92 static GstElementDetails gst_rtp_ssrc_demux_details = {
93   "RTP SSRC Demux",
94   "Demux/Network/RTP",
95   "Splits RTP streams based on the SSRC",
96   "Wim Taymans <wim@fluendo.com>"
97 };
98
99 #define GST_PAD_LOCK(obj)   (g_mutex_lock ((obj)->padlock))
100 #define GST_PAD_UNLOCK(obj) (g_mutex_unlock ((obj)->padlock))
101
102 /* signals */
103 enum
104 {
105   SIGNAL_NEW_SSRC_PAD,
106   LAST_SIGNAL
107 };
108
109 GST_BOILERPLATE (GstRtpSsrcDemux, gst_rtp_ssrc_demux, GstElement,
110     GST_TYPE_ELEMENT);
111
112
113 /* GObject vmethods */
114 static void gst_rtp_ssrc_demux_dispose (GObject * object);
115 static void gst_rtp_ssrc_demux_finalize (GObject * object);
116
117 /* GstElement vmethods */
118 static GstStateChangeReturn gst_rtp_ssrc_demux_change_state (GstElement *
119     element, GstStateChange transition);
120
121 /* sinkpad stuff */
122 static GstFlowReturn gst_rtp_ssrc_demux_chain (GstPad * pad, GstBuffer * buf);
123 static gboolean gst_rtp_ssrc_demux_sink_event (GstPad * pad, GstEvent * event);
124
125 static GstFlowReturn gst_rtp_ssrc_demux_rtcp_chain (GstPad * pad,
126     GstBuffer * buf);
127 static gboolean gst_rtp_ssrc_demux_rtcp_sink_event (GstPad * pad,
128     GstEvent * event);
129
130 /* srcpad stuff */
131 static gboolean gst_rtp_ssrc_demux_src_event (GstPad * pad, GstEvent * event);
132 static GList *gst_rtp_ssrc_demux_internal_links (GstPad * pad);
133 static gboolean gst_rtp_ssrc_demux_src_query (GstPad * pad, GstQuery * query);
134
135 static guint gst_rtp_ssrc_demux_signals[LAST_SIGNAL] = { 0 };
136
137 /**
138  * Item for storing GstPad <-> SSRC pairs.
139  */
140 struct _GstRtpSsrcDemuxPad
141 {
142   guint32 ssrc;
143   GstPad *rtp_pad;
144   GstCaps *caps;
145   GstPad *rtcp_pad;
146   GstClockTime first_ts;
147 };
148
149 /* find a src pad for a given SSRC, returns NULL if the SSRC was not found
150  */
151 static GstRtpSsrcDemuxPad *
152 find_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
153 {
154   GSList *walk;
155
156   for (walk = demux->srcpads; walk; walk = g_slist_next (walk)) {
157     GstRtpSsrcDemuxPad *pad = (GstRtpSsrcDemuxPad *) walk->data;
158
159     if (pad->ssrc == ssrc)
160       return pad;
161   }
162   return NULL;
163 }
164
165 /* with PAD_LOCK */
166 static GstRtpSsrcDemuxPad *
167 create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc,
168     GstClockTime timestamp)
169 {
170   GstPad *rtp_pad, *rtcp_pad;
171   GstElementClass *klass;
172   GstPadTemplate *templ;
173   gchar *padname;
174   GstRtpSsrcDemuxPad *demuxpad;
175
176   GST_DEBUG_OBJECT (demux, "creating pad for SSRC %08x", ssrc);
177
178   klass = GST_ELEMENT_GET_CLASS (demux);
179   templ = gst_element_class_get_pad_template (klass, "src_%d");
180   padname = g_strdup_printf ("src_%d", ssrc);
181   rtp_pad = gst_pad_new_from_template (templ, padname);
182   g_free (padname);
183
184   templ = gst_element_class_get_pad_template (klass, "rtcp_src_%d");
185   padname = g_strdup_printf ("rtcp_src_%d", ssrc);
186   rtcp_pad = gst_pad_new_from_template (templ, padname);
187   g_free (padname);
188
189   /* we use the first timestamp received to calculate the difference between
190    * timestamps on all streams */
191   GST_DEBUG_OBJECT (demux, "SSRC %08x, first timestamp %" GST_TIME_FORMAT,
192       ssrc, GST_TIME_ARGS (timestamp));
193
194   /* wrap in structure and add to list */
195   demuxpad = g_new0 (GstRtpSsrcDemuxPad, 1);
196   demuxpad->ssrc = ssrc;
197   demuxpad->rtp_pad = rtp_pad;
198   demuxpad->rtcp_pad = rtcp_pad;
199   demuxpad->first_ts = timestamp;
200
201   GST_DEBUG_OBJECT (demux, "first timestamp %" GST_TIME_FORMAT,
202       GST_TIME_ARGS (timestamp));
203
204   gst_pad_set_element_private (rtp_pad, demuxpad);
205   gst_pad_set_element_private (rtcp_pad, demuxpad);
206
207   demux->srcpads = g_slist_prepend (demux->srcpads, demuxpad);
208
209   /* copy caps from input */
210   gst_pad_set_caps (rtp_pad, GST_PAD_CAPS (demux->rtp_sink));
211   gst_pad_use_fixed_caps (rtp_pad);
212   gst_pad_set_caps (rtcp_pad, GST_PAD_CAPS (demux->rtcp_sink));
213   gst_pad_use_fixed_caps (rtcp_pad);
214
215   gst_pad_set_event_function (rtp_pad, gst_rtp_ssrc_demux_src_event);
216   gst_pad_set_query_function (rtp_pad, gst_rtp_ssrc_demux_src_query);
217   gst_pad_set_internal_link_function (rtp_pad,
218       gst_rtp_ssrc_demux_internal_links);
219   gst_pad_set_active (rtp_pad, TRUE);
220
221   gst_pad_set_internal_link_function (rtcp_pad,
222       gst_rtp_ssrc_demux_internal_links);
223   gst_pad_set_active (rtcp_pad, TRUE);
224
225   gst_element_add_pad (GST_ELEMENT_CAST (demux), rtp_pad);
226   gst_element_add_pad (GST_ELEMENT_CAST (demux), rtcp_pad);
227
228   g_signal_emit (G_OBJECT (demux),
229       gst_rtp_ssrc_demux_signals[SIGNAL_NEW_SSRC_PAD], 0, ssrc, rtp_pad);
230
231   return demuxpad;
232 }
233
234 static void
235 gst_rtp_ssrc_demux_base_init (gpointer g_class)
236 {
237   GstElementClass *gstelement_klass = GST_ELEMENT_CLASS (g_class);
238
239   gst_element_class_add_pad_template (gstelement_klass,
240       gst_static_pad_template_get (&rtp_ssrc_demux_sink_template));
241   gst_element_class_add_pad_template (gstelement_klass,
242       gst_static_pad_template_get (&rtp_ssrc_demux_rtcp_sink_template));
243   gst_element_class_add_pad_template (gstelement_klass,
244       gst_static_pad_template_get (&rtp_ssrc_demux_src_template));
245   gst_element_class_add_pad_template (gstelement_klass,
246       gst_static_pad_template_get (&rtp_ssrc_demux_rtcp_src_template));
247
248   gst_element_class_set_details (gstelement_klass, &gst_rtp_ssrc_demux_details);
249 }
250
251 static void
252 gst_rtp_ssrc_demux_class_init (GstRtpSsrcDemuxClass * klass)
253 {
254   GObjectClass *gobject_klass;
255   GstElementClass *gstelement_klass;
256
257   gobject_klass = (GObjectClass *) klass;
258   gstelement_klass = (GstElementClass *) klass;
259
260   gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_rtp_ssrc_demux_dispose);
261   gobject_klass->finalize = GST_DEBUG_FUNCPTR (gst_rtp_ssrc_demux_finalize);
262
263   /**
264    * GstRtpSsrcDemux::new-ssrc-pad:
265    * @demux: the object which received the signal
266    * @ssrc: the SSRC of the pad
267    * @pad: the new pad.
268    *
269    * Emited when a new SSRC pad has been created.
270    */
271   gst_rtp_ssrc_demux_signals[SIGNAL_NEW_SSRC_PAD] =
272       g_signal_new ("new-ssrc-pad",
273       G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
274       G_STRUCT_OFFSET (GstRtpSsrcDemuxClass, new_ssrc_pad),
275       NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_OBJECT,
276       G_TYPE_NONE, 2, G_TYPE_UINT, GST_TYPE_PAD);
277
278   gstelement_klass->change_state =
279       GST_DEBUG_FUNCPTR (gst_rtp_ssrc_demux_change_state);
280
281   GST_DEBUG_CATEGORY_INIT (gst_rtp_ssrc_demux_debug,
282       "rtpssrcdemux", 0, "RTP SSRC demuxer");
283 }
284
285 static void
286 gst_rtp_ssrc_demux_init (GstRtpSsrcDemux * demux,
287     GstRtpSsrcDemuxClass * g_class)
288 {
289   GstElementClass *klass = GST_ELEMENT_GET_CLASS (demux);
290
291   demux->rtp_sink =
292       gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
293           "sink"), "sink");
294   gst_pad_set_chain_function (demux->rtp_sink, gst_rtp_ssrc_demux_chain);
295   gst_pad_set_event_function (demux->rtp_sink, gst_rtp_ssrc_demux_sink_event);
296   gst_element_add_pad (GST_ELEMENT_CAST (demux), demux->rtp_sink);
297
298   demux->rtcp_sink =
299       gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
300           "rtcp_sink"), "rtcp_sink");
301   gst_pad_set_chain_function (demux->rtcp_sink, gst_rtp_ssrc_demux_rtcp_chain);
302   gst_pad_set_event_function (demux->rtcp_sink,
303       gst_rtp_ssrc_demux_rtcp_sink_event);
304   gst_element_add_pad (GST_ELEMENT_CAST (demux), demux->rtcp_sink);
305
306   demux->padlock = g_mutex_new ();
307
308   gst_segment_init (&demux->segment, GST_FORMAT_UNDEFINED);
309 }
310
311 static void
312 gst_rtp_ssrc_demux_dispose (GObject * object)
313 {
314   GstRtpSsrcDemux *demux;
315
316   demux = GST_RTP_SSRC_DEMUX (object);
317
318   g_slist_foreach (demux->srcpads, (GFunc) g_free, NULL);
319   g_slist_free (demux->srcpads);
320   demux->srcpads = NULL;
321
322   G_OBJECT_CLASS (parent_class)->dispose (object);
323 }
324
325 static void
326 gst_rtp_ssrc_demux_finalize (GObject * object)
327 {
328   GstRtpSsrcDemux *demux;
329
330   demux = GST_RTP_SSRC_DEMUX (object);
331   g_mutex_free (demux->padlock);
332
333   G_OBJECT_CLASS (parent_class)->finalize (object);
334 }
335
336 static gboolean
337 gst_rtp_ssrc_demux_sink_event (GstPad * pad, GstEvent * event)
338 {
339   GstRtpSsrcDemux *demux;
340   gboolean res = FALSE;
341
342   demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
343
344   switch (GST_EVENT_TYPE (event)) {
345     case GST_EVENT_FLUSH_STOP:
346       gst_segment_init (&demux->segment, GST_FORMAT_UNDEFINED);
347     case GST_EVENT_NEWSEGMENT:
348     default:
349     {
350       GSList *walk;
351
352       res = TRUE;
353       GST_PAD_LOCK (demux);
354       for (walk = demux->srcpads; walk; walk = g_slist_next (walk)) {
355         GstRtpSsrcDemuxPad *pad = (GstRtpSsrcDemuxPad *) walk->data;
356
357         gst_event_ref (event);
358         res &= gst_pad_push_event (pad->rtp_pad, event);
359       }
360       GST_PAD_UNLOCK (demux);
361       gst_event_unref (event);
362       break;
363     }
364   }
365
366   gst_object_unref (demux);
367   return res;
368 }
369
370 static gboolean
371 gst_rtp_ssrc_demux_rtcp_sink_event (GstPad * pad, GstEvent * event)
372 {
373   GstRtpSsrcDemux *demux;
374   gboolean res = FALSE;
375
376   demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
377
378   switch (GST_EVENT_TYPE (event)) {
379     case GST_EVENT_NEWSEGMENT:
380     default:
381     {
382       GSList *walk;
383
384       res = TRUE;
385       GST_PAD_LOCK (demux);
386       for (walk = demux->srcpads; walk; walk = g_slist_next (walk)) {
387         GstRtpSsrcDemuxPad *pad = (GstRtpSsrcDemuxPad *) walk->data;
388
389         res &= gst_pad_push_event (pad->rtcp_pad, event);
390       }
391       GST_PAD_UNLOCK (demux);
392       break;
393     }
394   }
395   gst_object_unref (demux);
396   return res;
397 }
398
399 static GstFlowReturn
400 gst_rtp_ssrc_demux_chain (GstPad * pad, GstBuffer * buf)
401 {
402   GstFlowReturn ret;
403   GstRtpSsrcDemux *demux;
404   guint32 ssrc;
405   GstRtpSsrcDemuxPad *dpad;
406
407   demux = GST_RTP_SSRC_DEMUX (GST_OBJECT_PARENT (pad));
408
409   if (!gst_rtp_buffer_validate (buf))
410     goto invalid_payload;
411
412   ssrc = gst_rtp_buffer_get_ssrc (buf);
413
414   GST_DEBUG_OBJECT (demux, "received buffer of SSRC %08x", ssrc);
415
416   GST_PAD_LOCK (demux);
417   dpad = find_demux_pad_for_ssrc (demux, ssrc);
418   if (dpad == NULL) {
419     if (!(dpad =
420             create_demux_pad_for_ssrc (demux, ssrc,
421                 GST_BUFFER_TIMESTAMP (buf))))
422       goto create_failed;
423   }
424   GST_PAD_UNLOCK (demux);
425
426   /* push to srcpad */
427   ret = gst_pad_push (dpad->rtp_pad, buf);
428
429   return ret;
430
431   /* ERRORS */
432 invalid_payload:
433   {
434     /* this is fatal and should be filtered earlier */
435     GST_ELEMENT_ERROR (demux, STREAM, DECODE, (NULL),
436         ("Dropping invalid RTP payload"));
437     gst_buffer_unref (buf);
438     return GST_FLOW_ERROR;
439   }
440 create_failed:
441   {
442     GST_ELEMENT_ERROR (demux, STREAM, DECODE, (NULL),
443         ("Could not create new pad"));
444     GST_PAD_UNLOCK (demux);
445     gst_buffer_unref (buf);
446     return GST_FLOW_ERROR;
447   }
448 }
449
450 static GstFlowReturn
451 gst_rtp_ssrc_demux_rtcp_chain (GstPad * pad, GstBuffer * buf)
452 {
453   GstFlowReturn ret;
454   GstRtpSsrcDemux *demux;
455   guint32 ssrc;
456   GstRtpSsrcDemuxPad *dpad;
457   GstRTCPPacket packet;
458
459   demux = GST_RTP_SSRC_DEMUX (GST_OBJECT_PARENT (pad));
460
461   if (!gst_rtcp_buffer_validate (buf))
462     goto invalid_rtcp;
463
464   if (!gst_rtcp_buffer_get_first_packet (buf, &packet))
465     goto invalid_rtcp;
466
467   /* first packet must be SR or RR or else the validate would have failed */
468   switch (gst_rtcp_packet_get_type (&packet)) {
469     case GST_RTCP_TYPE_SR:
470       /* get the ssrc so that we can route it to the right source pad */
471       gst_rtcp_packet_sr_get_sender_info (&packet, &ssrc, NULL, NULL, NULL,
472           NULL);
473       break;
474     case GST_RTCP_TYPE_RR:
475       ssrc = gst_rtcp_packet_rr_get_ssrc (&packet);
476       break;
477     default:
478       goto invalid_rtcp;
479   }
480
481   GST_DEBUG_OBJECT (demux, "received RTCP of SSRC %08x", ssrc);
482
483   GST_PAD_LOCK (demux);
484   dpad = find_demux_pad_for_ssrc (demux, ssrc);
485   if (dpad == NULL) {
486     GST_DEBUG_OBJECT (demux, "creating pad for SSRC %08x", ssrc);
487     if (!(dpad = create_demux_pad_for_ssrc (demux, ssrc, -1)))
488       goto create_failed;
489   }
490   GST_PAD_UNLOCK (demux);
491
492   /* push to srcpad */
493   ret = gst_pad_push (dpad->rtcp_pad, buf);
494
495   return ret;
496
497   /* ERRORS */
498 invalid_rtcp:
499   {
500     /* this is fatal and should be filtered earlier */
501     GST_ELEMENT_ERROR (demux, STREAM, DECODE, (NULL),
502         ("Dropping invalid RTCP packet"));
503     gst_buffer_unref (buf);
504     return GST_FLOW_ERROR;
505   }
506 create_failed:
507   {
508     GST_ELEMENT_ERROR (demux, STREAM, DECODE, (NULL),
509         ("Could not create new pad"));
510     GST_PAD_UNLOCK (demux);
511     gst_buffer_unref (buf);
512     return GST_FLOW_ERROR;
513   }
514 }
515
516 static gboolean
517 gst_rtp_ssrc_demux_src_event (GstPad * pad, GstEvent * event)
518 {
519   GstRtpSsrcDemux *demux;
520   gboolean res = FALSE;
521
522   demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
523
524   switch (GST_EVENT_TYPE (event)) {
525     case GST_EVENT_SEEK:
526     default:
527       res = gst_pad_event_default (pad, event);
528       break;
529   }
530   gst_object_unref (demux);
531   return res;
532 }
533
534 static GList *
535 gst_rtp_ssrc_demux_internal_links (GstPad * pad)
536 {
537   GstRtpSsrcDemux *demux;
538   GList *res = NULL;
539   GSList *walk;
540
541   demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
542
543   GST_PAD_LOCK (demux);
544   for (walk = demux->srcpads; walk; walk = g_slist_next (walk)) {
545     GstRtpSsrcDemuxPad *dpad = (GstRtpSsrcDemuxPad *) walk->data;
546
547     if (pad == demux->rtp_sink) {
548       res = g_list_prepend (res, dpad->rtp_pad);
549     } else if (pad == demux->rtcp_sink) {
550       res = g_list_prepend (res, dpad->rtcp_pad);
551     } else if (pad == dpad->rtp_pad) {
552       res = g_list_prepend (res, demux->rtp_sink);
553       break;
554     } else if (pad == dpad->rtcp_pad) {
555       res = g_list_prepend (res, demux->rtcp_sink);
556       break;
557     }
558   }
559   GST_PAD_UNLOCK (demux);
560
561   gst_object_unref (demux);
562   return res;
563 }
564
565 static gboolean
566 gst_rtp_ssrc_demux_src_query (GstPad * pad, GstQuery * query)
567 {
568   GstRtpSsrcDemux *demux;
569   gboolean res = FALSE;
570
571   demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
572
573   switch (GST_QUERY_TYPE (query)) {
574     case GST_QUERY_LATENCY:
575     {
576
577       if ((res = gst_pad_peer_query (demux->rtp_sink, query))) {
578         gboolean live;
579         GstClockTime min_latency, max_latency;
580         GstRtpSsrcDemuxPad *demuxpad;
581
582         demuxpad = gst_pad_get_element_private (pad);
583
584         gst_query_parse_latency (query, &live, &min_latency, &max_latency);
585
586         GST_DEBUG_OBJECT (demux, "peer min latency %" GST_TIME_FORMAT,
587             GST_TIME_ARGS (min_latency));
588
589         GST_DEBUG_OBJECT (demux,
590             "latency for SSRC %08x, latency %" GST_TIME_FORMAT, demuxpad->ssrc,
591             GST_TIME_ARGS (demuxpad->first_ts));
592
593 #if 0
594         min_latency += demuxpad->first_ts;
595         if (max_latency != -1)
596           max_latency += demuxpad->first_ts;
597 #endif
598
599         gst_query_set_latency (query, live, min_latency, max_latency);
600       }
601       break;
602     }
603     default:
604       res = gst_pad_query_default (pad, query);
605       break;
606   }
607   gst_object_unref (demux);
608
609   return res;
610 }
611
612 static GstStateChangeReturn
613 gst_rtp_ssrc_demux_change_state (GstElement * element,
614     GstStateChange transition)
615 {
616   GstStateChangeReturn ret;
617   GstRtpSsrcDemux *demux;
618
619   demux = GST_RTP_SSRC_DEMUX (element);
620
621   switch (transition) {
622     case GST_STATE_CHANGE_NULL_TO_READY:
623     case GST_STATE_CHANGE_READY_TO_PAUSED:
624     case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
625     default:
626       break;
627   }
628
629   ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
630
631   switch (transition) {
632     case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
633     case GST_STATE_CHANGE_PAUSED_TO_READY:
634     case GST_STATE_CHANGE_READY_TO_NULL:
635     default:
636       break;
637   }
638   return ret;
639 }