rtp: Copy metadata in the (de)payloader, but only the relevant ones
[platform/upstream/gst-plugins-good.git] / gst / rtp / gstrtpvrawdepay.c
1 /* GStreamer
2  * Copyright (C) <2008> Wim Taymans <wim.taymans@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
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  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include <gst/rtp/gstrtpbuffer.h>
25 #include <gst/video/video.h>
26
27 #include <string.h>
28 #include <stdlib.h>
29 #include "gstrtpvrawdepay.h"
30 #include "gstrtputils.h"
31
32 GST_DEBUG_CATEGORY_STATIC (rtpvrawdepay_debug);
33 #define GST_CAT_DEFAULT (rtpvrawdepay_debug)
34
35 static GstStaticPadTemplate gst_rtp_vraw_depay_src_template =
36 GST_STATIC_PAD_TEMPLATE ("src",
37     GST_PAD_SRC,
38     GST_PAD_ALWAYS,
39     GST_STATIC_CAPS ("video/x-raw")
40     );
41
42 static GstStaticPadTemplate gst_rtp_vraw_depay_sink_template =
43 GST_STATIC_PAD_TEMPLATE ("sink",
44     GST_PAD_SINK,
45     GST_PAD_ALWAYS,
46     GST_STATIC_CAPS ("application/x-rtp, "
47         "media = (string) \"video\", "
48         "clock-rate = (int) 90000, "
49         "encoding-name = (string) \"RAW\", "
50         "sampling = (string) { \"RGB\", \"RGBA\", \"BGR\", \"BGRA\", "
51         "\"YCbCr-4:4:4\", \"YCbCr-4:2:2\", \"YCbCr-4:2:0\", "
52         "\"YCbCr-4:1:1\" },"
53         /* we cannot express these as strings 
54          * "width = (string) [1 32767],"
55          * "height = (string) [1 32767],"
56          */
57         "depth = (string) { \"8\", \"10\", \"12\", \"16\" }")
58     );
59
60 #define gst_rtp_vraw_depay_parent_class parent_class
61 G_DEFINE_TYPE (GstRtpVRawDepay, gst_rtp_vraw_depay,
62     GST_TYPE_RTP_BASE_DEPAYLOAD);
63
64 static gboolean gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * depayload,
65     GstCaps * caps);
66 static GstBuffer *gst_rtp_vraw_depay_process_packet (GstRTPBaseDepayload *
67     depay, GstRTPBuffer * rtp);
68
69 static GstStateChangeReturn gst_rtp_vraw_depay_change_state (GstElement *
70     element, GstStateChange transition);
71
72 static gboolean gst_rtp_vraw_depay_handle_event (GstRTPBaseDepayload * filter,
73     GstEvent * event);
74
75 static void
76 gst_rtp_vraw_depay_class_init (GstRtpVRawDepayClass * klass)
77 {
78   GstElementClass *gstelement_class;
79   GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
80
81   gstelement_class = (GstElementClass *) klass;
82   gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
83
84   gstelement_class->change_state = gst_rtp_vraw_depay_change_state;
85
86   gstrtpbasedepayload_class->set_caps = gst_rtp_vraw_depay_setcaps;
87   gstrtpbasedepayload_class->process_rtp_packet =
88       gst_rtp_vraw_depay_process_packet;
89   gstrtpbasedepayload_class->handle_event = gst_rtp_vraw_depay_handle_event;
90
91   gst_element_class_add_pad_template (gstelement_class,
92       gst_static_pad_template_get (&gst_rtp_vraw_depay_src_template));
93   gst_element_class_add_pad_template (gstelement_class,
94       gst_static_pad_template_get (&gst_rtp_vraw_depay_sink_template));
95
96   gst_element_class_set_static_metadata (gstelement_class,
97       "RTP Raw Video depayloader", "Codec/Depayloader/Network/RTP",
98       "Extracts raw video from RTP packets (RFC 4175)",
99       "Wim Taymans <wim.taymans@gmail.com>");
100
101   GST_DEBUG_CATEGORY_INIT (rtpvrawdepay_debug, "rtpvrawdepay", 0,
102       "raw video RTP Depayloader");
103 }
104
105 static void
106 gst_rtp_vraw_depay_init (GstRtpVRawDepay * rtpvrawdepay)
107 {
108 }
109
110 static void
111 gst_rtp_vraw_depay_reset (GstRtpVRawDepay * rtpvrawdepay)
112 {
113   if (rtpvrawdepay->outbuf) {
114     gst_video_frame_unmap (&rtpvrawdepay->frame);
115     gst_buffer_unref (rtpvrawdepay->outbuf);
116     rtpvrawdepay->outbuf = NULL;
117   }
118   rtpvrawdepay->timestamp = -1;
119   if (rtpvrawdepay->pool) {
120     gst_buffer_pool_set_active (rtpvrawdepay->pool, FALSE);
121     gst_object_unref (rtpvrawdepay->pool);
122     rtpvrawdepay->pool = NULL;
123   }
124 }
125
126 static GstFlowReturn
127 gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps,
128     GstVideoInfo * info)
129 {
130   GstQuery *query;
131   GstBufferPool *pool = NULL;
132   guint size, min, max;
133   GstStructure *config;
134
135   /* find a pool for the negotiated caps now */
136   query = gst_query_new_allocation (caps, TRUE);
137
138   if (!gst_pad_peer_query (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depay), query)) {
139     /* not a problem, we use the defaults of query */
140     GST_DEBUG_OBJECT (depay, "could not get downstream ALLOCATION hints");
141   }
142
143   if (gst_query_get_n_allocation_pools (query) > 0) {
144     /* we got configuration from our peer, parse them */
145     gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
146   } else {
147     GST_DEBUG_OBJECT (depay, "didn't get downstream pool hints");
148     size = info->size;
149     min = max = 0;
150   }
151
152   if (pool == NULL) {
153     /* we did not get a pool, make one ourselves then */
154     pool = gst_video_buffer_pool_new ();
155   }
156
157   if (depay->pool)
158     gst_object_unref (depay->pool);
159   depay->pool = pool;
160
161   config = gst_buffer_pool_get_config (pool);
162   gst_buffer_pool_config_set_params (config, caps, size, min, max);
163   if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
164     /* just set the metadata, if the pool can support it we will transparently use
165      * it through the video info API. We could also see if the pool support this
166      * metadata and only activate it then. */
167     gst_buffer_pool_config_add_option (config,
168         GST_BUFFER_POOL_OPTION_VIDEO_META);
169   }
170
171   gst_buffer_pool_set_config (pool, config);
172   /* and activate */
173   gst_buffer_pool_set_active (pool, TRUE);
174
175   gst_query_unref (query);
176
177   return GST_FLOW_OK;
178 }
179
180 static gboolean
181 gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
182 {
183   GstStructure *structure;
184   GstRtpVRawDepay *rtpvrawdepay;
185   gint clock_rate;
186   const gchar *str;
187   gint format, width, height, depth, pgroup, xinc, yinc;
188   GstCaps *srccaps;
189   gboolean res;
190   GstFlowReturn ret;
191
192   rtpvrawdepay = GST_RTP_VRAW_DEPAY (depayload);
193
194   structure = gst_caps_get_structure (caps, 0);
195
196   xinc = yinc = 1;
197
198   if (!gst_structure_get_int (structure, "clock-rate", &clock_rate))
199     clock_rate = 90000;         /* default */
200   depayload->clock_rate = clock_rate;
201
202   if (!(str = gst_structure_get_string (structure, "width")))
203     goto no_width;
204   width = atoi (str);
205
206   if (!(str = gst_structure_get_string (structure, "height")))
207     goto no_height;
208   height = atoi (str);
209
210   if (!(str = gst_structure_get_string (structure, "depth")))
211     goto no_depth;
212   depth = atoi (str);
213
214   /* optional interlace value but we don't handle interlaced
215    * formats yet */
216   if (gst_structure_get_string (structure, "interlace"))
217     goto interlaced;
218
219   if (!(str = gst_structure_get_string (structure, "sampling")))
220     goto no_sampling;
221
222   if (!strcmp (str, "RGB")) {
223     format = GST_VIDEO_FORMAT_RGB;
224     pgroup = 3;
225   } else if (!strcmp (str, "RGBA")) {
226     format = GST_VIDEO_FORMAT_RGBA;
227     pgroup = 4;
228   } else if (!strcmp (str, "BGR")) {
229     format = GST_VIDEO_FORMAT_BGR;
230     pgroup = 3;
231   } else if (!strcmp (str, "BGRA")) {
232     format = GST_VIDEO_FORMAT_BGRA;
233     pgroup = 4;
234   } else if (!strcmp (str, "YCbCr-4:4:4")) {
235     format = GST_VIDEO_FORMAT_AYUV;
236     pgroup = 3;
237   } else if (!strcmp (str, "YCbCr-4:2:2")) {
238     if (depth == 8) {
239       format = GST_VIDEO_FORMAT_UYVY;
240       pgroup = 4;
241     } else if (depth == 10) {
242       format = GST_VIDEO_FORMAT_UYVP;
243       pgroup = 5;
244     } else
245       goto unknown_format;
246     xinc = 2;
247   } else if (!strcmp (str, "YCbCr-4:2:0")) {
248     format = GST_VIDEO_FORMAT_I420;
249     pgroup = 6;
250     xinc = yinc = 2;
251   } else if (!strcmp (str, "YCbCr-4:1:1")) {
252     format = GST_VIDEO_FORMAT_Y41B;
253     pgroup = 6;
254     xinc = 4;
255   } else {
256     goto unknown_format;
257   }
258
259   gst_video_info_init (&rtpvrawdepay->vinfo);
260   gst_video_info_set_format (&rtpvrawdepay->vinfo, format, width, height);
261   GST_VIDEO_INFO_FPS_N (&rtpvrawdepay->vinfo) = 0;
262   GST_VIDEO_INFO_FPS_D (&rtpvrawdepay->vinfo) = 1;
263
264   rtpvrawdepay->pgroup = pgroup;
265   rtpvrawdepay->xinc = xinc;
266   rtpvrawdepay->yinc = yinc;
267
268   srccaps = gst_video_info_to_caps (&rtpvrawdepay->vinfo);
269   res = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
270   gst_caps_unref (srccaps);
271
272   GST_DEBUG_OBJECT (depayload, "width %d, height %d, format %d", width, height,
273       format);
274   GST_DEBUG_OBJECT (depayload, "xinc %d, yinc %d, pgroup %d",
275       xinc, yinc, pgroup);
276
277   /* negotiate a bufferpool */
278   if ((ret = gst_rtp_vraw_depay_negotiate_pool (rtpvrawdepay, srccaps,
279               &rtpvrawdepay->vinfo)) != GST_FLOW_OK)
280     goto no_bufferpool;
281
282   return res;
283
284   /* ERRORS */
285 no_width:
286   {
287     GST_ERROR_OBJECT (depayload, "no width specified");
288     return FALSE;
289   }
290 no_height:
291   {
292     GST_ERROR_OBJECT (depayload, "no height specified");
293     return FALSE;
294   }
295 no_depth:
296   {
297     GST_ERROR_OBJECT (depayload, "no depth specified");
298     return FALSE;
299   }
300 interlaced:
301   {
302     GST_ERROR_OBJECT (depayload, "interlaced formats not supported yet");
303     return FALSE;
304   }
305 no_sampling:
306   {
307     GST_ERROR_OBJECT (depayload, "no sampling specified");
308     return FALSE;
309   }
310 unknown_format:
311   {
312     GST_ERROR_OBJECT (depayload, "unknown sampling format '%s'", str);
313     return FALSE;
314   }
315 no_bufferpool:
316   {
317     GST_DEBUG_OBJECT (depayload, "no bufferpool");
318     return FALSE;
319   }
320 }
321
322 static GstBuffer *
323 gst_rtp_vraw_depay_process_packet (GstRTPBaseDepayload * depayload,
324     GstRTPBuffer * rtp)
325 {
326   GstRtpVRawDepay *rtpvrawdepay;
327   guint8 *payload, *p0, *yp, *up, *vp, *headers;
328   guint32 timestamp;
329   guint cont, ystride, uvstride, pgroup, payload_len;
330   gint width, height, xinc, yinc;
331   GstVideoFrame *frame;
332   gboolean marker;
333   GstBuffer *buf, *outbuf = NULL;
334
335   rtpvrawdepay = GST_RTP_VRAW_DEPAY (depayload);
336
337   timestamp = gst_rtp_buffer_get_timestamp (rtp);
338
339   if (timestamp != rtpvrawdepay->timestamp || rtpvrawdepay->outbuf == NULL) {
340     GstBuffer *new_buffer;
341     GstFlowReturn ret;
342
343     GST_LOG_OBJECT (depayload, "new frame with timestamp %u", timestamp);
344     /* new timestamp, flush old buffer and create new output buffer */
345     if (rtpvrawdepay->outbuf) {
346       gst_video_frame_unmap (&rtpvrawdepay->frame);
347       gst_rtp_base_depayload_push (depayload, rtpvrawdepay->outbuf);
348       rtpvrawdepay->outbuf = NULL;
349     }
350
351     if (gst_pad_check_reconfigure (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload))) {
352       GstCaps *caps;
353
354       caps =
355           gst_pad_get_current_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload));
356       gst_rtp_vraw_depay_negotiate_pool (rtpvrawdepay, caps,
357           &rtpvrawdepay->vinfo);
358       gst_caps_unref (caps);
359     }
360
361     ret =
362         gst_buffer_pool_acquire_buffer (rtpvrawdepay->pool, &new_buffer, NULL);
363
364     if (G_UNLIKELY (ret != GST_FLOW_OK))
365       goto alloc_failed;
366
367     /* clear timestamp from alloc... */
368     GST_BUFFER_PTS (new_buffer) = -1;
369
370     if (!gst_video_frame_map (&rtpvrawdepay->frame, &rtpvrawdepay->vinfo,
371             new_buffer, GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)) {
372       gst_buffer_unref (new_buffer);
373       goto invalid_frame;
374     }
375
376     rtpvrawdepay->outbuf = new_buffer;
377     rtpvrawdepay->timestamp = timestamp;
378   }
379
380   frame = &rtpvrawdepay->frame;
381
382   g_assert (frame->buffer != NULL);
383
384   /* get pointer and strides of the planes */
385   p0 = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
386   yp = GST_VIDEO_FRAME_COMP_DATA (frame, 0);
387   up = GST_VIDEO_FRAME_COMP_DATA (frame, 1);
388   vp = GST_VIDEO_FRAME_COMP_DATA (frame, 2);
389
390   ystride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0);
391   uvstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 1);
392
393   pgroup = rtpvrawdepay->pgroup;
394   width = GST_VIDEO_INFO_WIDTH (&rtpvrawdepay->vinfo);
395   height = GST_VIDEO_INFO_HEIGHT (&rtpvrawdepay->vinfo);
396   xinc = rtpvrawdepay->xinc;
397   yinc = rtpvrawdepay->yinc;
398
399   payload = gst_rtp_buffer_get_payload (rtp);
400   payload_len = gst_rtp_buffer_get_payload_len (rtp);
401   buf = gst_rtp_buffer_get_payload_buffer (rtp);
402
403   if (payload_len < 3)
404     goto short_packet;
405
406   /* skip extended seqnum */
407   payload += 2;
408   payload_len -= 2;
409
410   /* remember header position */
411   headers = payload;
412
413   gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpvrawdepay), frame->buffer, buf,
414       g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
415
416   /* find data start */
417   do {
418     if (payload_len < 6)
419       goto short_packet;
420
421     cont = payload[4] & 0x80;
422
423     payload += 6;
424     payload_len -= 6;
425   } while (cont);
426
427   while (TRUE) {
428     guint length, line, offs, plen;
429     guint8 *datap;
430
431     /* stop when we run out of data */
432     if (payload_len == 0)
433       break;
434
435     /* read length and cont. This should work because we iterated the headers
436      * above. */
437     length = (headers[0] << 8) | headers[1];
438     line = ((headers[2] & 0x7f) << 8) | headers[3];
439     offs = ((headers[4] & 0x7f) << 8) | headers[5];
440     cont = headers[4] & 0x80;
441     headers += 6;
442
443     /* length must be a multiple of pgroup */
444     if (length % pgroup != 0)
445       goto wrong_length;
446
447     if (length > payload_len)
448       length = payload_len;
449
450     /* sanity check */
451     if (line > (height - yinc)) {
452       GST_WARNING_OBJECT (depayload, "skipping line %d: out of range", line);
453       goto next;
454     }
455     if (offs > (width - xinc)) {
456       GST_WARNING_OBJECT (depayload, "skipping offset %d: out of range", offs);
457       goto next;
458     }
459
460     /* calculate the maximim amount of bytes we can use per line */
461     if (offs + ((length / pgroup) * xinc) > width) {
462       plen = ((width - offs) * pgroup) / xinc;
463       GST_WARNING_OBJECT (depayload, "clipping length %d, offset %d, plen %d",
464           length, offs, plen);
465     } else
466       plen = length;
467
468     GST_LOG_OBJECT (depayload,
469         "writing length %u/%u, line %u, offset %u, remaining %u", plen, length,
470         line, offs, payload_len);
471
472     switch (GST_VIDEO_INFO_FORMAT (&rtpvrawdepay->vinfo)) {
473       case GST_VIDEO_FORMAT_RGB:
474       case GST_VIDEO_FORMAT_RGBA:
475       case GST_VIDEO_FORMAT_BGR:
476       case GST_VIDEO_FORMAT_BGRA:
477       case GST_VIDEO_FORMAT_UYVY:
478       case GST_VIDEO_FORMAT_UYVP:
479         /* samples are packed just like gstreamer packs them */
480         offs /= xinc;
481         datap = p0 + (line * ystride) + (offs * pgroup);
482
483         memcpy (datap, payload, plen);
484         break;
485       case GST_VIDEO_FORMAT_AYUV:
486       {
487         gint i;
488         guint8 *p;
489
490         datap = p0 + (line * ystride) + (offs * 4);
491         p = payload;
492
493         /* samples are packed in order Cb-Y-Cr for both interlaced and
494          * progressive frames */
495         for (i = 0; i < plen; i += pgroup) {
496           *datap++ = 0;
497           *datap++ = p[1];
498           *datap++ = p[0];
499           *datap++ = p[2];
500           p += pgroup;
501         }
502         break;
503       }
504       case GST_VIDEO_FORMAT_I420:
505       {
506         gint i;
507         guint uvoff;
508         guint8 *yd1p, *yd2p, *udp, *vdp, *p;
509
510         yd1p = yp + (line * ystride) + (offs);
511         yd2p = yd1p + ystride;
512         uvoff = (line / yinc * uvstride) + (offs / xinc);
513
514         udp = up + uvoff;
515         vdp = vp + uvoff;
516         p = payload;
517
518         /* line 0/1: Y00-Y01-Y10-Y11-Cb00-Cr00 Y02-Y03-Y12-Y13-Cb01-Cr01 ...  */
519         for (i = 0; i < plen; i += pgroup) {
520           *yd1p++ = p[0];
521           *yd1p++ = p[1];
522           *yd2p++ = p[2];
523           *yd2p++ = p[3];
524           *udp++ = p[4];
525           *vdp++ = p[5];
526           p += pgroup;
527         }
528         break;
529       }
530       case GST_VIDEO_FORMAT_Y41B:
531       {
532         gint i;
533         guint uvoff;
534         guint8 *ydp, *udp, *vdp, *p;
535
536         ydp = yp + (line * ystride) + (offs);
537         uvoff = (line / yinc * uvstride) + (offs / xinc);
538
539         udp = up + uvoff;
540         vdp = vp + uvoff;
541         p = payload;
542
543         /* Samples are packed in order Cb0-Y0-Y1-Cr0-Y2-Y3 for both interlaced
544          * and progressive scan lines */
545         for (i = 0; i < plen; i += pgroup) {
546           *udp++ = p[0];
547           *ydp++ = p[1];
548           *ydp++ = p[2];
549           *vdp++ = p[3];
550           *ydp++ = p[4];
551           *ydp++ = p[5];
552           p += pgroup;
553         }
554         break;
555       }
556       default:
557         goto unknown_sampling;
558     }
559
560   next:
561     if (!cont)
562       break;
563
564     payload += length;
565     payload_len -= length;
566   }
567
568   marker = gst_rtp_buffer_get_marker (rtp);
569
570   if (marker) {
571     GST_LOG_OBJECT (depayload, "marker, flushing frame");
572     gst_video_frame_unmap (&rtpvrawdepay->frame);
573     outbuf = rtpvrawdepay->outbuf;
574     rtpvrawdepay->outbuf = NULL;
575     rtpvrawdepay->timestamp = -1;
576   }
577   return outbuf;
578
579   /* ERRORS */
580 unknown_sampling:
581   {
582     GST_ELEMENT_ERROR (depayload, STREAM, FORMAT,
583         (NULL), ("unimplemented sampling"));
584     return NULL;
585   }
586 alloc_failed:
587   {
588     GST_WARNING_OBJECT (depayload, "failed to alloc output buffer");
589     return NULL;
590   }
591 invalid_frame:
592   {
593     GST_ERROR_OBJECT (depayload, "could not map video frame");
594     return NULL;
595   }
596 wrong_length:
597   {
598     GST_WARNING_OBJECT (depayload, "length not multiple of pgroup");
599     return NULL;
600   }
601 short_packet:
602   {
603     GST_WARNING_OBJECT (depayload, "short packet");
604     return NULL;
605   }
606 }
607
608 static gboolean
609 gst_rtp_vraw_depay_handle_event (GstRTPBaseDepayload * filter, GstEvent * event)
610 {
611   gboolean ret;
612   GstRtpVRawDepay *rtpvrawdepay;
613
614   rtpvrawdepay = GST_RTP_VRAW_DEPAY (filter);
615
616   switch (GST_EVENT_TYPE (event)) {
617     case GST_EVENT_FLUSH_STOP:
618       gst_rtp_vraw_depay_reset (rtpvrawdepay);
619       break;
620     default:
621       break;
622   }
623
624   ret =
625       GST_RTP_BASE_DEPAYLOAD_CLASS (parent_class)->handle_event (filter, event);
626
627   return ret;
628 }
629
630 static GstStateChangeReturn
631 gst_rtp_vraw_depay_change_state (GstElement * element,
632     GstStateChange transition)
633 {
634   GstRtpVRawDepay *rtpvrawdepay;
635   GstStateChangeReturn ret;
636
637   rtpvrawdepay = GST_RTP_VRAW_DEPAY (element);
638
639   switch (transition) {
640     case GST_STATE_CHANGE_NULL_TO_READY:
641       break;
642     case GST_STATE_CHANGE_READY_TO_PAUSED:
643       gst_rtp_vraw_depay_reset (rtpvrawdepay);
644       break;
645     default:
646       break;
647   }
648
649   ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
650
651   switch (transition) {
652     case GST_STATE_CHANGE_PAUSED_TO_READY:
653       gst_rtp_vraw_depay_reset (rtpvrawdepay);
654       break;
655     case GST_STATE_CHANGE_READY_TO_NULL:
656       break;
657     default:
658       break;
659   }
660   return ret;
661 }
662
663 gboolean
664 gst_rtp_vraw_depay_plugin_init (GstPlugin * plugin)
665 {
666   return gst_element_register (plugin, "rtpvrawdepay",
667       GST_RANK_SECONDARY, GST_TYPE_RTP_VRAW_DEPAY);
668 }