2 * Copyright (C) <2005> Wim Taymans <wim.taymans@gmail.com>
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.
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.
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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
26 #include <gst/rtp/gstrtpbuffer.h>
28 #include "gstrtpmp4gdepay.h"
30 GST_DEBUG_CATEGORY_STATIC (rtpmp4gdepay_debug);
31 #define GST_CAT_DEFAULT (rtpmp4gdepay_debug)
33 /* elementfactory information */
34 static const GstElementDetails gst_rtp_mp4gdepay_details =
35 GST_ELEMENT_DETAILS ("RTP MPEG4 ES depayloader",
36 "Codec/Depayloader/Network",
37 "Extracts MPEG4 elementary streams from RTP packets (RFC 3640)",
38 "Wim Taymans <wim.taymans@gmail.com>");
40 static GstStaticPadTemplate gst_rtp_mp4g_depay_src_template =
41 GST_STATIC_PAD_TEMPLATE ("src",
44 GST_STATIC_CAPS ("video/mpeg,"
45 "mpegversion=(int) 4,"
46 "systemstream=(boolean)false;" "audio/mpeg," "mpegversion=(int) 4")
49 static GstStaticPadTemplate gst_rtp_mp4g_depay_sink_template =
50 GST_STATIC_PAD_TEMPLATE ("sink",
53 GST_STATIC_CAPS ("application/x-rtp, "
54 "media = (string) { \"video\", \"audio\", \"application\" }, "
55 "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
56 "clock-rate = (int) [1, MAX ], "
57 "encoding-name = (string) \"MPEG4-GENERIC\", "
58 /* required string params */
59 "streamtype = (string) { \"4\", \"5\" }, " /* 4 = video, 5 = audio */
60 /* "profile-level-id = (string) [1,MAX], " */
61 /* "config = (string) [1,MAX]" */
62 "mode = (string) { \"generic\", \"CELP-cbr\", \"CELP-vbr\", \"AAC-lbr\", \"AAC-hbr\" } "
63 /* Optional general parameters */
64 /* "objecttype = (string) [1,MAX], " */
65 /* "constantsize = (string) [1,MAX], " *//* constant size of each AU */
66 /* "constantduration = (string) [1,MAX], " *//* constant duration of each AU */
67 /* "maxdisplacement = (string) [1,MAX], " */
68 /* "de-interleavebuffersize = (string) [1,MAX], " */
69 /* Optional configuration parameters */
70 /* "sizelength = (string) [1, 32], " */
71 /* "indexlength = (string) [1, 32], " */
72 /* "indexdeltalength = (string) [1, 32], " */
73 /* "ctsdeltalength = (string) [1, 32], " */
74 /* "dtsdeltalength = (string) [1, 32], " */
75 /* "randomaccessindication = (string) {0, 1}, " */
76 /* "streamstateindication = (string) [0, 32], " */
77 /* "auxiliarydatasizelength = (string) [0, 32]" */ )
80 /* simple bitstream parser */
85 gint head; /* bitpos in the cache of next bit */
86 guint64 cache; /* cached bytes */
90 gst_bs_parse_init (GstBsParse * bs, const guint8 * data, guint size)
93 bs->end = data + size;
95 bs->cache = 0xffffffff;
99 gst_bs_parse_read (GstBsParse * bs, guint n)
107 /* fill up the cache if we need to */
108 while (bs->head < n) {
109 if (bs->data >= bs->end) {
110 /* we're at the end, can't produce more than head number of bits */
114 /* shift bytes in cache, moving the head bits of the cache left */
115 bs->cache = (bs->cache << 8) | *bs->data++;
119 /* bring the required bits down and truncate */
120 if ((shift = bs->head - n) > 0)
121 res = bs->cache >> shift;
125 /* mask out required bits */
135 GST_BOILERPLATE (GstRtpMP4GDepay, gst_rtp_mp4g_depay, GstBaseRTPDepayload,
136 GST_TYPE_BASE_RTP_DEPAYLOAD);
138 static void gst_rtp_mp4g_depay_finalize (GObject * object);
140 static gboolean gst_rtp_mp4g_depay_setcaps (GstBaseRTPDepayload * depayload,
142 static GstBuffer *gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload,
145 static GstStateChangeReturn gst_rtp_mp4g_depay_change_state (GstElement *
146 element, GstStateChange transition);
150 gst_rtp_mp4g_depay_base_init (gpointer klass)
152 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
154 gst_element_class_add_pad_template (element_class,
155 gst_static_pad_template_get (&gst_rtp_mp4g_depay_src_template));
156 gst_element_class_add_pad_template (element_class,
157 gst_static_pad_template_get (&gst_rtp_mp4g_depay_sink_template));
159 gst_element_class_set_details (element_class, &gst_rtp_mp4gdepay_details);
163 gst_rtp_mp4g_depay_class_init (GstRtpMP4GDepayClass * klass)
165 GObjectClass *gobject_class;
166 GstElementClass *gstelement_class;
167 GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
169 gobject_class = (GObjectClass *) klass;
170 gstelement_class = (GstElementClass *) klass;
171 gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
173 gobject_class->finalize = gst_rtp_mp4g_depay_finalize;
175 gstelement_class->change_state = gst_rtp_mp4g_depay_change_state;
177 gstbasertpdepayload_class->process = gst_rtp_mp4g_depay_process;
178 gstbasertpdepayload_class->set_caps = gst_rtp_mp4g_depay_setcaps;
180 GST_DEBUG_CATEGORY_INIT (rtpmp4gdepay_debug, "rtpmp4gdepay", 0,
181 "MP4-generic RTP Depayloader");
185 gst_rtp_mp4g_depay_init (GstRtpMP4GDepay * rtpmp4gdepay,
186 GstRtpMP4GDepayClass * klass)
188 rtpmp4gdepay->adapter = gst_adapter_new ();
189 rtpmp4gdepay->packets = g_queue_new ();
193 gst_rtp_mp4g_depay_finalize (GObject * object)
195 GstRtpMP4GDepay *rtpmp4gdepay;
197 rtpmp4gdepay = GST_RTP_MP4G_DEPAY (object);
199 g_object_unref (rtpmp4gdepay->adapter);
200 rtpmp4gdepay->adapter = NULL;
201 g_queue_free (rtpmp4gdepay->packets);
202 rtpmp4gdepay->packets = NULL;
204 G_OBJECT_CLASS (parent_class)->finalize (object);
208 gst_rtp_mp4g_depay_parse_int (GstStructure * structure, const gchar * field,
214 if ((str = gst_structure_get_string (structure, field)))
217 if (gst_structure_get_int (structure, field, &res))
224 gst_rtp_mp4g_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
226 GstStructure *structure;
227 GstRtpMP4GDepay *rtpmp4gdepay;
228 GstCaps *srccaps = NULL;
234 rtpmp4gdepay = GST_RTP_MP4G_DEPAY (depayload);
236 structure = gst_caps_get_structure (caps, 0);
238 if (!gst_structure_get_int (structure, "clock-rate", &clock_rate))
239 clock_rate = 90000; /* default */
240 depayload->clock_rate = clock_rate;
242 if ((str = gst_structure_get_string (structure, "media"))) {
243 if (strcmp (str, "audio") == 0) {
244 srccaps = gst_caps_new_simple ("audio/mpeg",
245 "mpegversion", G_TYPE_INT, 4, NULL);
246 } else if (strcmp (str, "video") == 0) {
247 srccaps = gst_caps_new_simple ("video/mpeg",
248 "mpegversion", G_TYPE_INT, 4,
249 "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
255 /* these values are optional and have a default value of 0 (no header) */
256 rtpmp4gdepay->sizelength =
257 gst_rtp_mp4g_depay_parse_int (structure, "sizelength", 0);
258 rtpmp4gdepay->indexlength =
259 gst_rtp_mp4g_depay_parse_int (structure, "indexlength", 0);
260 rtpmp4gdepay->indexdeltalength =
261 gst_rtp_mp4g_depay_parse_int (structure, "indexdeltalength", 0);
262 rtpmp4gdepay->ctsdeltalength =
263 gst_rtp_mp4g_depay_parse_int (structure, "ctsdeltalength", 0);
264 rtpmp4gdepay->dtsdeltalength =
265 gst_rtp_mp4g_depay_parse_int (structure, "dtsdeltalength", 0);
267 gst_rtp_mp4g_depay_parse_int (structure, "randomaccessindication", 0);
268 rtpmp4gdepay->randomaccessindication = someint > 0 ? 1 : 0;
269 rtpmp4gdepay->streamstateindication =
270 gst_rtp_mp4g_depay_parse_int (structure, "streamstateindication", 0);
271 rtpmp4gdepay->auxiliarydatasizelength =
272 gst_rtp_mp4g_depay_parse_int (structure, "auxiliarydatasizelength", 0);
273 rtpmp4gdepay->constantSize =
274 gst_rtp_mp4g_depay_parse_int (structure, "constantsize", 0);
275 rtpmp4gdepay->constantDuration =
276 gst_rtp_mp4g_depay_parse_int (structure, "constantduration", 0);
277 rtpmp4gdepay->maxDisplacement =
278 gst_rtp_mp4g_depay_parse_int (structure, "maxdisplacement", 0);
281 /* get config string */
282 if ((str = gst_structure_get_string (structure, "config"))) {
285 g_value_init (&v, GST_TYPE_BUFFER);
286 if (gst_value_deserialize (&v, str)) {
289 buffer = gst_value_get_buffer (&v);
290 gst_caps_set_simple (srccaps,
291 "codec_data", GST_TYPE_BUFFER, buffer, NULL);
294 g_warning ("cannot convert config to buffer");
298 res = gst_pad_set_caps (depayload->srcpad, srccaps);
299 gst_caps_unref (srccaps);
306 GST_DEBUG_OBJECT (rtpmp4gdepay, "Unknown media type");
312 gst_rtp_mp4g_depay_clear_queue (GstRtpMP4GDepay * rtpmp4gdepay)
316 while ((outbuf = g_queue_pop_head (rtpmp4gdepay->packets)))
317 gst_buffer_unref (outbuf);
321 gst_rtp_mp4g_depay_flush_queue (GstRtpMP4GDepay * rtpmp4gdepay)
324 gboolean discont = FALSE;
327 while ((outbuf = g_queue_pop_head (rtpmp4gdepay->packets))) {
328 AU_index = GST_BUFFER_OFFSET (outbuf);
330 GST_DEBUG_OBJECT (rtpmp4gdepay, "next available AU_index %u", AU_index);
332 if (rtpmp4gdepay->next_AU_index != AU_index) {
333 GST_DEBUG_OBJECT (rtpmp4gdepay, "discont, expected AU_index %u",
334 rtpmp4gdepay->next_AU_index);
339 GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
343 GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing AU_index %u", AU_index);
344 gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay), outbuf);
345 rtpmp4gdepay->next_AU_index = AU_index + 1;
350 gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf)
352 guint AU_index = GST_BUFFER_OFFSET (outbuf);
354 if (rtpmp4gdepay->next_AU_index == -1) {
355 GST_DEBUG_OBJECT (rtpmp4gdepay, "Init AU counter %u", AU_index);
356 rtpmp4gdepay->next_AU_index = AU_index;
359 if (rtpmp4gdepay->next_AU_index == AU_index) {
360 GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing expected AU_index %u", AU_index);
362 /* we received the expected packet, push it and flush as much as we can from
364 gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay), outbuf);
365 rtpmp4gdepay->next_AU_index++;
367 while ((outbuf = g_queue_peek_head (rtpmp4gdepay->packets))) {
368 AU_index = GST_BUFFER_OFFSET (outbuf);
370 GST_DEBUG_OBJECT (rtpmp4gdepay, "next available AU_index %u", AU_index);
372 if (rtpmp4gdepay->next_AU_index == AU_index) {
373 GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing expected AU_index %u",
375 outbuf = g_queue_pop_head (rtpmp4gdepay->packets);
376 gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay),
378 rtpmp4gdepay->next_AU_index++;
380 GST_DEBUG_OBJECT (rtpmp4gdepay, "waiting for next AU_index %u",
381 rtpmp4gdepay->next_AU_index);
388 GST_DEBUG_OBJECT (rtpmp4gdepay, "queueing AU_index %u", AU_index);
390 /* loop the list to skip strictly smaller AU_index buffers */
391 for (list = rtpmp4gdepay->packets->head; list; list = g_list_next (list)) {
395 idx = GST_BUFFER_OFFSET (GST_BUFFER_CAST (list->data));
397 /* compare the new seqnum to the one in the buffer */
398 gap = (gint) (idx - AU_index);
400 GST_DEBUG_OBJECT (rtpmp4gdepay, "compare with AU_index %u, gap %d", idx,
403 /* AU_index <= idx, we can stop looking */
404 if (G_LIKELY (gap > 0))
408 g_queue_insert_before (rtpmp4gdepay->packets, list, outbuf);
410 g_queue_push_tail (rtpmp4gdepay->packets, outbuf);
415 gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
417 GstRtpMP4GDepay *rtpmp4gdepay;
419 GstClockTime timestamp;
421 rtpmp4gdepay = GST_RTP_MP4G_DEPAY (depayload);
423 /* flush remaining data on discont */
424 if (GST_BUFFER_IS_DISCONT (buf)) {
425 GST_DEBUG_OBJECT (rtpmp4gdepay, "received DISCONT");
426 gst_adapter_clear (rtpmp4gdepay->adapter);
429 timestamp = GST_BUFFER_TIMESTAMP (buf);
432 gint payload_len, payload_AU;
435 guint AU_headers_len;
436 guint AU_size, AU_index, AU_index_delta, payload_AU_size;
439 payload_len = gst_rtp_buffer_get_payload_len (buf);
440 payload = gst_rtp_buffer_get_payload (buf);
442 rtptime = gst_rtp_buffer_get_timestamp (buf);
443 M = gst_rtp_buffer_get_marker (buf);
445 if (rtpmp4gdepay->sizelength > 0) {
446 gint num_AU_headers, AU_headers_bytes, i;
452 /* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- .. -+-+-+-+-+-+-+-+-+-+
453 * |AU-headers-length|AU-header|AU-header| |AU-header|padding|
454 * | | (1) | (2) | | (n) * | bits |
455 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- .. -+-+-+-+-+-+-+-+-+-+
457 * The length is 2 bytes and contains the length of the following
458 * AU-headers in bits.
460 AU_headers_len = (payload[0] << 8) | payload[1];
461 AU_headers_bytes = (AU_headers_len + 7) / 8;
462 num_AU_headers = AU_headers_len / 16;
464 GST_DEBUG_OBJECT (rtpmp4gdepay, "AU headers len %d, bytes %d, num %d",
465 AU_headers_len, AU_headers_bytes, num_AU_headers);
471 if (payload_len < AU_headers_bytes)
474 /* skip special headers, point to first payload AU */
475 payload_AU = 2 + AU_headers_bytes;
476 payload_AU_size = payload_len - AU_headers_bytes;
478 if (G_UNLIKELY (rtpmp4gdepay->auxiliarydatasizelength)) {
481 /* point the bitstream parser to the first auxiliary data bit */
482 gst_bs_parse_init (&bs, payload + AU_headers_bytes,
483 payload_len - AU_headers_bytes);
485 gst_bs_parse_read (&bs, rtpmp4gdepay->auxiliarydatasizelength);
486 /* convert to bytes */
487 aux_size = (aux_size + 7) / 8;
488 /* AU data then follows auxiliary data */
489 if (payload_AU_size < aux_size)
491 payload_AU += aux_size;
492 payload_AU_size -= aux_size;
495 /* point the bitstream parser to the first AU header bit */
496 gst_bs_parse_init (&bs, payload, payload_len);
497 AU_index = AU_index_delta = 0;
499 for (i = 0; i < num_AU_headers && payload_AU_size > 0; i++) {
501 * +---------------------------------------+
503 * +---------------------------------------+
504 * | AU-Index / AU-Index-delta |
505 * +---------------------------------------+
507 * +---------------------------------------+
509 * +---------------------------------------+
511 * +---------------------------------------+
513 * +---------------------------------------+
515 * +---------------------------------------+
517 * +---------------------------------------+
519 AU_size = gst_bs_parse_read (&bs, rtpmp4gdepay->sizelength);
521 /* calculate the AU_index, which is only on the first AU of the packet
522 * and the AU_index_delta on the other AUs. This will be used to
523 * reconstruct the AU ordering when interleaving. */
525 AU_index = gst_bs_parse_read (&bs, rtpmp4gdepay->indexlength);
527 if (AU_index == 0 && rtpmp4gdepay->prev_AU_index == 0) {
530 /* if we see two consecutive packets with AU_index of 0, we can
531 * assume we have constantDuration packets. Since we don't have
532 * the index we must use the AU duration to calculate the
533 * index. Get the diff between the timestamps first, this can be
534 * positive or negative. */
535 if (rtpmp4gdepay->prev_rtptime <= rtptime)
536 diff = rtptime - rtpmp4gdepay->prev_rtptime;
538 diff = -(rtpmp4gdepay->prev_rtptime - rtptime);
540 /* if no constantDuration was given, make one */
541 if (rtpmp4gdepay->constantDuration == 0) {
542 rtpmp4gdepay->constantDuration = diff / num_AU_headers;
543 GST_DEBUG_OBJECT (depayload, "guessing constantDuration %d",
544 rtpmp4gdepay->constantDuration);
547 /* get the number of packets by dividing with the duration */
548 diff /= rtpmp4gdepay->constantDuration;
550 rtpmp4gdepay->last_AU_index += diff;
551 rtpmp4gdepay->prev_AU_index = AU_index;
553 AU_index = rtpmp4gdepay->last_AU_index;
556 rtpmp4gdepay->prev_AU_index = AU_index;
557 rtpmp4gdepay->last_AU_index = AU_index;
560 /* keep track of the higest AU_index */
561 if (rtpmp4gdepay->max_AU_index != -1
562 && rtpmp4gdepay->max_AU_index <= AU_index) {
563 GST_DEBUG_OBJECT (rtpmp4gdepay, "new interleave group, flushing");
564 /* a new interleave group started, flush */
565 gst_rtp_mp4g_depay_flush_queue (rtpmp4gdepay);
567 if (G_UNLIKELY (!rtpmp4gdepay->maxDisplacement &&
568 rtpmp4gdepay->max_AU_index != -1
569 && rtpmp4gdepay->max_AU_index >= AU_index)) {
572 /* some broken non-interleaved streams have AU-index jumping around
573 * all over the place, apparently assuming receiver disregards */
574 GST_DEBUG_OBJECT (rtpmp4gdepay, "non-interleaved broken AU indices;"
575 " forcing continuous flush");
576 /* reset AU to avoid repeated DISCONT in such case */
577 outbuf = g_queue_peek_head (rtpmp4gdepay->packets);
578 if (G_LIKELY (outbuf)) {
579 rtpmp4gdepay->next_AU_index = GST_BUFFER_OFFSET (outbuf);
580 gst_rtp_mp4g_depay_flush_queue (rtpmp4gdepay);
583 rtpmp4gdepay->prev_rtptime = rtptime;
586 gst_bs_parse_read (&bs, rtpmp4gdepay->indexdeltalength);
587 AU_index += AU_index_delta + 1;
589 /* keep track of highest AU_index */
590 if (rtpmp4gdepay->max_AU_index == -1
591 || AU_index > rtpmp4gdepay->max_AU_index)
592 rtpmp4gdepay->max_AU_index = AU_index;
594 /* the presentation time offset, a 2s-complement value, we need this to
595 * calculate the timestamp on the output packet. */
596 if (rtpmp4gdepay->ctsdeltalength > 0) {
597 if (gst_bs_parse_read (&bs, 1))
598 gst_bs_parse_read (&bs, rtpmp4gdepay->ctsdeltalength);
600 /* the decoding time offset, a 2s-complement value */
601 if (rtpmp4gdepay->dtsdeltalength > 0) {
602 if (gst_bs_parse_read (&bs, 1))
603 gst_bs_parse_read (&bs, rtpmp4gdepay->dtsdeltalength);
605 /* RAP-flag to indicate that the AU contains a keyframe */
606 if (rtpmp4gdepay->randomaccessindication)
607 gst_bs_parse_read (&bs, 1);
609 if (rtpmp4gdepay->streamstateindication > 0)
610 gst_bs_parse_read (&bs, rtpmp4gdepay->streamstateindication);
612 GST_DEBUG_OBJECT (rtpmp4gdepay, "size %d, index %d, delta %d", AU_size,
613 AU_index, AU_index_delta);
615 /* fragmented pakets have the AU_size set to the size of the
616 * unfragmented AU. */
617 if (AU_size > payload_AU_size)
618 AU_size = payload_AU_size;
620 /* collect stuff in the adapter, strip header from payload and push in
623 gst_rtp_buffer_get_payload_subbuffer (buf, payload_AU, AU_size);
624 gst_adapter_push (rtpmp4gdepay->adapter, outbuf);
629 /* packet is complete, flush */
630 avail = gst_adapter_available (rtpmp4gdepay->adapter);
632 outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
633 gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad));
635 /* copy some of the fields we calculated above on the buffer. We also
636 * copy the AU_index so that we can sort the packets in our queue. */
637 GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
638 GST_BUFFER_OFFSET (outbuf) = AU_index;
640 /* make sure we don't use the timestamp again for other AUs in this
644 GST_DEBUG_OBJECT (depayload, "pushing buffer of size %d",
645 GST_BUFFER_SIZE (outbuf));
647 gst_rtp_mp4g_depay_queue (rtpmp4gdepay, outbuf);
650 payload_AU += AU_size;
651 payload_AU_size -= AU_size;
654 /* push complete buffer in adapter */
655 outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 0, payload_len);
656 gst_adapter_push (rtpmp4gdepay->adapter, outbuf);
658 /* if this was the last packet of the VOP, create and push a buffer */
662 avail = gst_adapter_available (rtpmp4gdepay->adapter);
664 outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
666 GST_DEBUG ("gst_rtp_mp4g_depay_chain: pushing buffer of size %d",
667 GST_BUFFER_SIZE (outbuf));
678 GST_ELEMENT_WARNING (rtpmp4gdepay, STREAM, DECODE,
679 ("Packet payload was too short."), (NULL));
684 static GstStateChangeReturn
685 gst_rtp_mp4g_depay_change_state (GstElement * element,
686 GstStateChange transition)
688 GstRtpMP4GDepay *rtpmp4gdepay;
689 GstStateChangeReturn ret;
691 rtpmp4gdepay = GST_RTP_MP4G_DEPAY (element);
693 switch (transition) {
694 case GST_STATE_CHANGE_READY_TO_PAUSED:
695 gst_adapter_clear (rtpmp4gdepay->adapter);
696 rtpmp4gdepay->max_AU_index = -1;
697 rtpmp4gdepay->next_AU_index = -1;
698 rtpmp4gdepay->prev_AU_index = -1;
699 rtpmp4gdepay->prev_rtptime = -1;
700 rtpmp4gdepay->last_AU_index = -1;
706 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
708 switch (transition) {
709 case GST_STATE_CHANGE_PAUSED_TO_READY:
710 gst_adapter_clear (rtpmp4gdepay->adapter);
711 gst_rtp_mp4g_depay_clear_queue (rtpmp4gdepay);
720 gst_rtp_mp4g_depay_plugin_init (GstPlugin * plugin)
722 return gst_element_register (plugin, "rtpmp4gdepay",
723 GST_RANK_MARGINAL, GST_TYPE_RTP_MP4G_DEPAY);