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
gst_rtp_vraw_depay_class_init(GstRtpVRawDepayClass * klass)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_static_pad_template (gstelement_class,
92 &gst_rtp_vraw_depay_src_template);
93 gst_element_class_add_static_pad_template (gstelement_class,
94 &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
gst_rtp_vraw_depay_init(GstRtpVRawDepay * rtpvrawdepay)106 gst_rtp_vraw_depay_init (GstRtpVRawDepay * rtpvrawdepay)
107 {
108 }
109
110 static void
gst_rtp_vraw_depay_reset(GstRtpVRawDepay * rtpvrawdepay,gboolean full)111 gst_rtp_vraw_depay_reset (GstRtpVRawDepay * rtpvrawdepay, gboolean full)
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
120 if (full && rtpvrawdepay->pool) {
121 gst_buffer_pool_set_active (rtpvrawdepay->pool, FALSE);
122 gst_object_unref (rtpvrawdepay->pool);
123 rtpvrawdepay->pool = NULL;
124 }
125 }
126
127 static GstFlowReturn
gst_rtp_vraw_depay_negotiate_pool(GstRtpVRawDepay * depay,GstCaps * caps,GstVideoInfo * info)128 gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps,
129 GstVideoInfo * info)
130 {
131 GstQuery *query;
132 GstBufferPool *pool = NULL;
133 guint size, min, max;
134 GstStructure *config;
135
136 /* find a pool for the negotiated caps now */
137 query = gst_query_new_allocation (caps, TRUE);
138
139 if (!gst_pad_peer_query (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depay), query)) {
140 /* not a problem, we use the defaults of query */
141 GST_DEBUG_OBJECT (depay, "could not get downstream ALLOCATION hints");
142 }
143
144 if (gst_query_get_n_allocation_pools (query) > 0) {
145 /* we got configuration from our peer, parse them */
146 gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
147 } else {
148 GST_DEBUG_OBJECT (depay, "didn't get downstream pool hints");
149 size = info->size;
150 min = max = 0;
151 }
152
153 if (pool == NULL) {
154 /* we did not get a pool, make one ourselves then */
155 pool = gst_video_buffer_pool_new ();
156 }
157
158 if (depay->pool)
159 gst_object_unref (depay->pool);
160 depay->pool = pool;
161
162 config = gst_buffer_pool_get_config (pool);
163 gst_buffer_pool_config_set_params (config, caps, size, min, max);
164 if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
165 /* just set the metadata, if the pool can support it we will transparently use
166 * it through the video info API. We could also see if the pool support this
167 * metadata and only activate it then. */
168 gst_buffer_pool_config_add_option (config,
169 GST_BUFFER_POOL_OPTION_VIDEO_META);
170 }
171
172 gst_buffer_pool_set_config (pool, config);
173 /* and activate */
174 gst_buffer_pool_set_active (pool, TRUE);
175
176 gst_query_unref (query);
177
178 return GST_FLOW_OK;
179 }
180
181 static gboolean
gst_rtp_vraw_depay_setcaps(GstRTPBaseDepayload * depayload,GstCaps * caps)182 gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
183 {
184 GstStructure *structure;
185 GstRtpVRawDepay *rtpvrawdepay;
186 gint clock_rate;
187 const gchar *str;
188 gint format, width, height, depth, pgroup, xinc, yinc;
189 GstCaps *srccaps;
190 gboolean res;
191 GstFlowReturn ret;
192
193 rtpvrawdepay = GST_RTP_VRAW_DEPAY (depayload);
194
195 structure = gst_caps_get_structure (caps, 0);
196
197 xinc = yinc = 1;
198
199 if (!gst_structure_get_int (structure, "clock-rate", &clock_rate))
200 clock_rate = 90000; /* default */
201 depayload->clock_rate = clock_rate;
202
203 if (!(str = gst_structure_get_string (structure, "width")))
204 goto no_width;
205 width = atoi (str);
206
207 if (!(str = gst_structure_get_string (structure, "height")))
208 goto no_height;
209 height = atoi (str);
210
211 if (!(str = gst_structure_get_string (structure, "depth")))
212 goto no_depth;
213 depth = atoi (str);
214
215 /* optional interlace value but we don't handle interlaced
216 * formats yet */
217 if (gst_structure_get_string (structure, "interlace"))
218 goto interlaced;
219
220 if (!(str = gst_structure_get_string (structure, "sampling")))
221 goto no_sampling;
222
223 if (!strcmp (str, "RGB")) {
224 format = GST_VIDEO_FORMAT_RGB;
225 pgroup = 3;
226 } else if (!strcmp (str, "RGBA")) {
227 format = GST_VIDEO_FORMAT_RGBA;
228 pgroup = 4;
229 } else if (!strcmp (str, "BGR")) {
230 format = GST_VIDEO_FORMAT_BGR;
231 pgroup = 3;
232 } else if (!strcmp (str, "BGRA")) {
233 format = GST_VIDEO_FORMAT_BGRA;
234 pgroup = 4;
235 } else if (!strcmp (str, "YCbCr-4:4:4")) {
236 format = GST_VIDEO_FORMAT_AYUV;
237 pgroup = 3;
238 } else if (!strcmp (str, "YCbCr-4:2:2")) {
239 if (depth == 8) {
240 format = GST_VIDEO_FORMAT_UYVY;
241 pgroup = 4;
242 } else if (depth == 10) {
243 format = GST_VIDEO_FORMAT_UYVP;
244 pgroup = 5;
245 } else
246 goto unknown_format;
247 xinc = 2;
248 } else if (!strcmp (str, "YCbCr-4:2:0")) {
249 format = GST_VIDEO_FORMAT_I420;
250 pgroup = 6;
251 xinc = yinc = 2;
252 } else if (!strcmp (str, "YCbCr-4:1:1")) {
253 format = GST_VIDEO_FORMAT_Y41B;
254 pgroup = 6;
255 xinc = 4;
256 } else {
257 goto unknown_format;
258 }
259
260 gst_video_info_init (&rtpvrawdepay->vinfo);
261 gst_video_info_set_format (&rtpvrawdepay->vinfo, format, width, height);
262 GST_VIDEO_INFO_FPS_N (&rtpvrawdepay->vinfo) = 0;
263 GST_VIDEO_INFO_FPS_D (&rtpvrawdepay->vinfo) = 1;
264
265 rtpvrawdepay->pgroup = pgroup;
266 rtpvrawdepay->xinc = xinc;
267 rtpvrawdepay->yinc = yinc;
268
269 srccaps = gst_video_info_to_caps (&rtpvrawdepay->vinfo);
270 res = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
271 gst_caps_unref (srccaps);
272
273 GST_DEBUG_OBJECT (depayload, "width %d, height %d, format %d", width, height,
274 format);
275 GST_DEBUG_OBJECT (depayload, "xinc %d, yinc %d, pgroup %d",
276 xinc, yinc, pgroup);
277
278 /* negotiate a bufferpool */
279 if ((ret = gst_rtp_vraw_depay_negotiate_pool (rtpvrawdepay, srccaps,
280 &rtpvrawdepay->vinfo)) != GST_FLOW_OK)
281 goto no_bufferpool;
282
283 return res;
284
285 /* ERRORS */
286 no_width:
287 {
288 GST_ERROR_OBJECT (depayload, "no width specified");
289 return FALSE;
290 }
291 no_height:
292 {
293 GST_ERROR_OBJECT (depayload, "no height specified");
294 return FALSE;
295 }
296 no_depth:
297 {
298 GST_ERROR_OBJECT (depayload, "no depth specified");
299 return FALSE;
300 }
301 interlaced:
302 {
303 GST_ERROR_OBJECT (depayload, "interlaced formats not supported yet");
304 return FALSE;
305 }
306 no_sampling:
307 {
308 GST_ERROR_OBJECT (depayload, "no sampling specified");
309 return FALSE;
310 }
311 unknown_format:
312 {
313 GST_ERROR_OBJECT (depayload, "unknown sampling format '%s'", str);
314 return FALSE;
315 }
316 no_bufferpool:
317 {
318 GST_DEBUG_OBJECT (depayload, "no bufferpool");
319 return FALSE;
320 }
321 }
322
323 static GstBuffer *
gst_rtp_vraw_depay_process_packet(GstRTPBaseDepayload * depayload,GstRTPBuffer * rtp)324 gst_rtp_vraw_depay_process_packet (GstRTPBaseDepayload * depayload,
325 GstRTPBuffer * rtp)
326 {
327 GstRtpVRawDepay *rtpvrawdepay;
328 guint8 *payload, *p0, *yp, *up, *vp, *headers;
329 guint32 timestamp;
330 guint cont, ystride, uvstride, pgroup, payload_len;
331 gint width, height, xinc, yinc;
332 GstVideoFrame *frame;
333 gboolean marker;
334 GstBuffer *outbuf = NULL;
335
336 rtpvrawdepay = GST_RTP_VRAW_DEPAY (depayload);
337
338 timestamp = gst_rtp_buffer_get_timestamp (rtp);
339
340 if (timestamp != rtpvrawdepay->timestamp || rtpvrawdepay->outbuf == NULL) {
341 GstBuffer *new_buffer;
342 GstFlowReturn ret;
343
344 GST_LOG_OBJECT (depayload, "new frame with timestamp %u", timestamp);
345 /* new timestamp, flush old buffer and create new output buffer */
346 if (rtpvrawdepay->outbuf) {
347 gst_video_frame_unmap (&rtpvrawdepay->frame);
348 gst_rtp_base_depayload_push (depayload, rtpvrawdepay->outbuf);
349 rtpvrawdepay->outbuf = NULL;
350 }
351
352 if (gst_pad_check_reconfigure (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload))) {
353 GstCaps *caps;
354
355 caps =
356 gst_pad_get_current_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload));
357 gst_rtp_vraw_depay_negotiate_pool (rtpvrawdepay, caps,
358 &rtpvrawdepay->vinfo);
359 gst_caps_unref (caps);
360 }
361
362 ret =
363 gst_buffer_pool_acquire_buffer (rtpvrawdepay->pool, &new_buffer, NULL);
364
365 if (G_UNLIKELY (ret != GST_FLOW_OK))
366 goto alloc_failed;
367
368 /* clear timestamp from alloc... */
369 GST_BUFFER_PTS (new_buffer) = -1;
370
371 if (!gst_video_frame_map (&rtpvrawdepay->frame, &rtpvrawdepay->vinfo,
372 new_buffer, GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)) {
373 gst_buffer_unref (new_buffer);
374 goto invalid_frame;
375 }
376
377 rtpvrawdepay->outbuf = new_buffer;
378 rtpvrawdepay->timestamp = timestamp;
379 }
380
381 frame = &rtpvrawdepay->frame;
382
383 g_assert (frame->buffer != NULL);
384
385 /* get pointer and strides of the planes */
386 p0 = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
387 yp = GST_VIDEO_FRAME_COMP_DATA (frame, 0);
388 up = GST_VIDEO_FRAME_COMP_DATA (frame, 1);
389 vp = GST_VIDEO_FRAME_COMP_DATA (frame, 2);
390
391 ystride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0);
392 uvstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 1);
393
394 pgroup = rtpvrawdepay->pgroup;
395 width = GST_VIDEO_INFO_WIDTH (&rtpvrawdepay->vinfo);
396 height = GST_VIDEO_INFO_HEIGHT (&rtpvrawdepay->vinfo);
397 xinc = rtpvrawdepay->xinc;
398 yinc = rtpvrawdepay->yinc;
399
400 payload = gst_rtp_buffer_get_payload (rtp);
401 payload_len = gst_rtp_buffer_get_payload_len (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_video_meta (rtpvrawdepay, frame->buffer, rtp->buffer);
414
415 /* find data start */
416 do {
417 if (payload_len < 6)
418 goto short_packet;
419
420 cont = payload[4] & 0x80;
421
422 payload += 6;
423 payload_len -= 6;
424 } while (cont);
425
426 while (TRUE) {
427 guint length, line, offs, plen;
428 guint8 *datap;
429
430 /* stop when we run out of data */
431 if (payload_len == 0)
432 break;
433
434 /* read length and cont. This should work because we iterated the headers
435 * above. */
436 length = (headers[0] << 8) | headers[1];
437 line = ((headers[2] & 0x7f) << 8) | headers[3];
438 offs = ((headers[4] & 0x7f) << 8) | headers[5];
439 cont = headers[4] & 0x80;
440 headers += 6;
441
442 /* length must be a multiple of pgroup */
443 if (length % pgroup != 0)
444 goto wrong_length;
445
446 if (length > payload_len)
447 length = payload_len;
448
449 /* sanity check */
450 if (line > (height - yinc)) {
451 GST_WARNING_OBJECT (depayload, "skipping line %d: out of range", line);
452 goto next;
453 }
454 if (offs > (width - xinc)) {
455 GST_WARNING_OBJECT (depayload, "skipping offset %d: out of range", offs);
456 goto next;
457 }
458
459 /* calculate the maximim amount of bytes we can use per line */
460 if (offs + ((length / pgroup) * xinc) > width) {
461 plen = ((width - offs) * pgroup) / xinc;
462 GST_WARNING_OBJECT (depayload, "clipping length %d, offset %d, plen %d",
463 length, offs, plen);
464 } else
465 plen = length;
466
467 GST_LOG_OBJECT (depayload,
468 "writing length %u/%u, line %u, offset %u, remaining %u", plen, length,
469 line, offs, payload_len);
470
471 switch (GST_VIDEO_INFO_FORMAT (&rtpvrawdepay->vinfo)) {
472 case GST_VIDEO_FORMAT_RGB:
473 case GST_VIDEO_FORMAT_RGBA:
474 case GST_VIDEO_FORMAT_BGR:
475 case GST_VIDEO_FORMAT_BGRA:
476 case GST_VIDEO_FORMAT_UYVY:
477 case GST_VIDEO_FORMAT_UYVP:
478 /* samples are packed just like gstreamer packs them */
479 offs /= xinc;
480 datap = p0 + (line * ystride) + (offs * pgroup);
481
482 memcpy (datap, payload, plen);
483 break;
484 case GST_VIDEO_FORMAT_AYUV:
485 {
486 gint i;
487 guint8 *p;
488
489 datap = p0 + (line * ystride) + (offs * 4);
490 p = payload;
491
492 /* samples are packed in order Cb-Y-Cr for both interlaced and
493 * progressive frames */
494 for (i = 0; i < plen; i += pgroup) {
495 *datap++ = 0;
496 *datap++ = p[1];
497 *datap++ = p[0];
498 *datap++ = p[2];
499 p += pgroup;
500 }
501 break;
502 }
503 case GST_VIDEO_FORMAT_I420:
504 {
505 gint i;
506 guint uvoff;
507 guint8 *yd1p, *yd2p, *udp, *vdp, *p;
508
509 yd1p = yp + (line * ystride) + (offs);
510 yd2p = yd1p + ystride;
511 uvoff = (line / yinc * uvstride) + (offs / xinc);
512
513 udp = up + uvoff;
514 vdp = vp + uvoff;
515 p = payload;
516
517 /* line 0/1: Y00-Y01-Y10-Y11-Cb00-Cr00 Y02-Y03-Y12-Y13-Cb01-Cr01 ... */
518 for (i = 0; i < plen; i += pgroup) {
519 *yd1p++ = p[0];
520 *yd1p++ = p[1];
521 *yd2p++ = p[2];
522 *yd2p++ = p[3];
523 *udp++ = p[4];
524 *vdp++ = p[5];
525 p += pgroup;
526 }
527 break;
528 }
529 case GST_VIDEO_FORMAT_Y41B:
530 {
531 gint i;
532 guint uvoff;
533 guint8 *ydp, *udp, *vdp, *p;
534
535 ydp = yp + (line * ystride) + (offs);
536 uvoff = (line / yinc * uvstride) + (offs / xinc);
537
538 udp = up + uvoff;
539 vdp = vp + uvoff;
540 p = payload;
541
542 /* Samples are packed in order Cb0-Y0-Y1-Cr0-Y2-Y3 for both interlaced
543 * and progressive scan lines */
544 for (i = 0; i < plen; i += pgroup) {
545 *udp++ = p[0];
546 *ydp++ = p[1];
547 *ydp++ = p[2];
548 *vdp++ = p[3];
549 *ydp++ = p[4];
550 *ydp++ = p[5];
551 p += pgroup;
552 }
553 break;
554 }
555 default:
556 goto unknown_sampling;
557 }
558
559 next:
560 if (!cont)
561 break;
562
563 payload += length;
564 payload_len -= length;
565 }
566
567 marker = gst_rtp_buffer_get_marker (rtp);
568
569 if (marker) {
570 GST_LOG_OBJECT (depayload, "marker, flushing frame");
571 gst_video_frame_unmap (&rtpvrawdepay->frame);
572 outbuf = rtpvrawdepay->outbuf;
573 rtpvrawdepay->outbuf = NULL;
574 rtpvrawdepay->timestamp = -1;
575 }
576 return outbuf;
577
578 /* ERRORS */
579 unknown_sampling:
580 {
581 GST_ELEMENT_ERROR (depayload, STREAM, FORMAT,
582 (NULL), ("unimplemented sampling"));
583 return NULL;
584 }
585 alloc_failed:
586 {
587 GST_WARNING_OBJECT (depayload, "failed to alloc output buffer");
588 return NULL;
589 }
590 invalid_frame:
591 {
592 GST_ERROR_OBJECT (depayload, "could not map video frame");
593 return NULL;
594 }
595 wrong_length:
596 {
597 GST_WARNING_OBJECT (depayload, "length not multiple of pgroup");
598 return NULL;
599 }
600 short_packet:
601 {
602 GST_WARNING_OBJECT (depayload, "short packet");
603 return NULL;
604 }
605 }
606
607 static gboolean
gst_rtp_vraw_depay_handle_event(GstRTPBaseDepayload * filter,GstEvent * event)608 gst_rtp_vraw_depay_handle_event (GstRTPBaseDepayload * filter, GstEvent * event)
609 {
610 gboolean ret;
611 GstRtpVRawDepay *rtpvrawdepay;
612
613 rtpvrawdepay = GST_RTP_VRAW_DEPAY (filter);
614
615 switch (GST_EVENT_TYPE (event)) {
616 case GST_EVENT_FLUSH_STOP:
617 gst_rtp_vraw_depay_reset (rtpvrawdepay, FALSE);
618 break;
619 default:
620 break;
621 }
622
623 ret =
624 GST_RTP_BASE_DEPAYLOAD_CLASS (parent_class)->handle_event (filter, event);
625
626 return ret;
627 }
628
629 static GstStateChangeReturn
gst_rtp_vraw_depay_change_state(GstElement * element,GstStateChange transition)630 gst_rtp_vraw_depay_change_state (GstElement * element,
631 GstStateChange transition)
632 {
633 GstRtpVRawDepay *rtpvrawdepay;
634 GstStateChangeReturn ret;
635
636 rtpvrawdepay = GST_RTP_VRAW_DEPAY (element);
637
638 switch (transition) {
639 case GST_STATE_CHANGE_NULL_TO_READY:
640 break;
641 case GST_STATE_CHANGE_READY_TO_PAUSED:
642 gst_rtp_vraw_depay_reset (rtpvrawdepay, TRUE);
643 break;
644 default:
645 break;
646 }
647
648 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
649
650 switch (transition) {
651 case GST_STATE_CHANGE_PAUSED_TO_READY:
652 gst_rtp_vraw_depay_reset (rtpvrawdepay, TRUE);
653 break;
654 case GST_STATE_CHANGE_READY_TO_NULL:
655 break;
656 default:
657 break;
658 }
659 return ret;
660 }
661
662 gboolean
gst_rtp_vraw_depay_plugin_init(GstPlugin * plugin)663 gst_rtp_vraw_depay_plugin_init (GstPlugin * plugin)
664 {
665 return gst_element_register (plugin, "rtpvrawdepay",
666 GST_RANK_SECONDARY, GST_TYPE_RTP_VRAW_DEPAY);
667 }
668