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