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;"
47 "audio/mpeg," "mpegversion=(int) 4, " "stream-format=(string)raw")
50 static GstStaticPadTemplate gst_rtp_mp4g_depay_sink_template =
51 GST_STATIC_PAD_TEMPLATE ("sink",
54 GST_STATIC_CAPS ("application/x-rtp, "
55 "media = (string) { \"video\", \"audio\", \"application\" }, "
56 "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
57 "clock-rate = (int) [1, MAX ], "
58 "encoding-name = (string) \"MPEG4-GENERIC\", "
59 /* required string params */
60 "streamtype = (string) { \"4\", \"5\" }, " /* 4 = video, 5 = audio */
61 /* "profile-level-id = (string) [1,MAX], " */
62 /* "config = (string) [1,MAX]" */
63 "mode = (string) { \"generic\", \"CELP-cbr\", \"CELP-vbr\", \"AAC-lbr\", \"AAC-hbr\" } "
64 /* Optional general parameters */
65 /* "objecttype = (string) [1,MAX], " */
66 /* "constantsize = (string) [1,MAX], " *//* constant size of each AU */
67 /* "constantduration = (string) [1,MAX], " *//* constant duration of each AU */
68 /* "maxdisplacement = (string) [1,MAX], " */
69 /* "de-interleavebuffersize = (string) [1,MAX], " */
70 /* Optional configuration parameters */
71 /* "sizelength = (string) [1, 32], " */
72 /* "indexlength = (string) [1, 32], " */
73 /* "indexdeltalength = (string) [1, 32], " */
74 /* "ctsdeltalength = (string) [1, 32], " */
75 /* "dtsdeltalength = (string) [1, 32], " */
76 /* "randomaccessindication = (string) {0, 1}, " */
77 /* "streamstateindication = (string) [0, 32], " */
78 /* "auxiliarydatasizelength = (string) [0, 32]" */ )
81 /* simple bitstream parser */
86 gint head; /* bitpos in the cache of next bit */
87 guint64 cache; /* cached bytes */
91 gst_bs_parse_init (GstBsParse * bs, const guint8 * data, guint size)
94 bs->end = data + size;
96 bs->cache = 0xffffffff;
100 gst_bs_parse_read (GstBsParse * bs, guint n)
108 /* fill up the cache if we need to */
109 while (bs->head < n) {
110 if (bs->data >= bs->end) {
111 /* we're at the end, can't produce more than head number of bits */
115 /* shift bytes in cache, moving the head bits of the cache left */
116 bs->cache = (bs->cache << 8) | *bs->data++;
120 /* bring the required bits down and truncate */
121 if ((shift = bs->head - n) > 0)
122 res = bs->cache >> shift;
126 /* mask out required bits */
136 GST_BOILERPLATE (GstRtpMP4GDepay, gst_rtp_mp4g_depay, GstBaseRTPDepayload,
137 GST_TYPE_BASE_RTP_DEPAYLOAD);
139 static void gst_rtp_mp4g_depay_finalize (GObject * object);
141 static gboolean gst_rtp_mp4g_depay_setcaps (GstBaseRTPDepayload * depayload,
143 static GstBuffer *gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload,
146 static GstStateChangeReturn gst_rtp_mp4g_depay_change_state (GstElement *
147 element, GstStateChange transition);
151 gst_rtp_mp4g_depay_base_init (gpointer klass)
153 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
155 gst_element_class_add_pad_template (element_class,
156 gst_static_pad_template_get (&gst_rtp_mp4g_depay_src_template));
157 gst_element_class_add_pad_template (element_class,
158 gst_static_pad_template_get (&gst_rtp_mp4g_depay_sink_template));
160 gst_element_class_set_details (element_class, &gst_rtp_mp4gdepay_details);
164 gst_rtp_mp4g_depay_class_init (GstRtpMP4GDepayClass * klass)
166 GObjectClass *gobject_class;
167 GstElementClass *gstelement_class;
168 GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
170 gobject_class = (GObjectClass *) klass;
171 gstelement_class = (GstElementClass *) klass;
172 gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
174 gobject_class->finalize = gst_rtp_mp4g_depay_finalize;
176 gstelement_class->change_state = gst_rtp_mp4g_depay_change_state;
178 gstbasertpdepayload_class->process = gst_rtp_mp4g_depay_process;
179 gstbasertpdepayload_class->set_caps = gst_rtp_mp4g_depay_setcaps;
181 GST_DEBUG_CATEGORY_INIT (rtpmp4gdepay_debug, "rtpmp4gdepay", 0,
182 "MP4-generic RTP Depayloader");
186 gst_rtp_mp4g_depay_init (GstRtpMP4GDepay * rtpmp4gdepay,
187 GstRtpMP4GDepayClass * klass)
189 rtpmp4gdepay->adapter = gst_adapter_new ();
190 rtpmp4gdepay->packets = g_queue_new ();
194 gst_rtp_mp4g_depay_finalize (GObject * object)
196 GstRtpMP4GDepay *rtpmp4gdepay;
198 rtpmp4gdepay = GST_RTP_MP4G_DEPAY (object);
200 g_object_unref (rtpmp4gdepay->adapter);
201 rtpmp4gdepay->adapter = NULL;
202 g_queue_free (rtpmp4gdepay->packets);
203 rtpmp4gdepay->packets = NULL;
205 G_OBJECT_CLASS (parent_class)->finalize (object);
209 gst_rtp_mp4g_depay_parse_int (GstStructure * structure, const gchar * field,
215 if ((str = gst_structure_get_string (structure, field)))
218 if (gst_structure_get_int (structure, field, &res))
225 gst_rtp_mp4g_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
227 GstStructure *structure;
228 GstRtpMP4GDepay *rtpmp4gdepay;
229 GstCaps *srccaps = NULL;
235 rtpmp4gdepay = GST_RTP_MP4G_DEPAY (depayload);
237 structure = gst_caps_get_structure (caps, 0);
239 if (!gst_structure_get_int (structure, "clock-rate", &clock_rate))
240 clock_rate = 90000; /* default */
241 depayload->clock_rate = clock_rate;
243 if ((str = gst_structure_get_string (structure, "media"))) {
244 if (strcmp (str, "audio") == 0) {
245 srccaps = gst_caps_new_simple ("audio/mpeg",
246 "mpegversion", G_TYPE_INT, 4, "stream-format", G_TYPE_STRING, "raw",
248 } else if (strcmp (str, "video") == 0) {
249 srccaps = gst_caps_new_simple ("video/mpeg",
250 "mpegversion", G_TYPE_INT, 4,
251 "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
257 /* these values are optional and have a default value of 0 (no header) */
258 rtpmp4gdepay->sizelength =
259 gst_rtp_mp4g_depay_parse_int (structure, "sizelength", 0);
260 rtpmp4gdepay->indexlength =
261 gst_rtp_mp4g_depay_parse_int (structure, "indexlength", 0);
262 rtpmp4gdepay->indexdeltalength =
263 gst_rtp_mp4g_depay_parse_int (structure, "indexdeltalength", 0);
264 rtpmp4gdepay->ctsdeltalength =
265 gst_rtp_mp4g_depay_parse_int (structure, "ctsdeltalength", 0);
266 rtpmp4gdepay->dtsdeltalength =
267 gst_rtp_mp4g_depay_parse_int (structure, "dtsdeltalength", 0);
269 gst_rtp_mp4g_depay_parse_int (structure, "randomaccessindication", 0);
270 rtpmp4gdepay->randomaccessindication = someint > 0 ? 1 : 0;
271 rtpmp4gdepay->streamstateindication =
272 gst_rtp_mp4g_depay_parse_int (structure, "streamstateindication", 0);
273 rtpmp4gdepay->auxiliarydatasizelength =
274 gst_rtp_mp4g_depay_parse_int (structure, "auxiliarydatasizelength", 0);
275 rtpmp4gdepay->constantSize =
276 gst_rtp_mp4g_depay_parse_int (structure, "constantsize", 0);
277 rtpmp4gdepay->constantDuration =
278 gst_rtp_mp4g_depay_parse_int (structure, "constantduration", 0);
279 rtpmp4gdepay->maxDisplacement =
280 gst_rtp_mp4g_depay_parse_int (structure, "maxdisplacement", 0);
283 /* get config string */
284 if ((str = gst_structure_get_string (structure, "config"))) {
287 g_value_init (&v, GST_TYPE_BUFFER);
288 if (gst_value_deserialize (&v, str)) {
291 buffer = gst_value_get_buffer (&v);
292 gst_caps_set_simple (srccaps,
293 "codec_data", GST_TYPE_BUFFER, buffer, NULL);
296 g_warning ("cannot convert config to buffer");
300 res = gst_pad_set_caps (depayload->srcpad, srccaps);
301 gst_caps_unref (srccaps);
308 GST_DEBUG_OBJECT (rtpmp4gdepay, "Unknown media type");
314 gst_rtp_mp4g_depay_clear_queue (GstRtpMP4GDepay * rtpmp4gdepay)
318 while ((outbuf = g_queue_pop_head (rtpmp4gdepay->packets)))
319 gst_buffer_unref (outbuf);
323 gst_rtp_mp4g_depay_flush_queue (GstRtpMP4GDepay * rtpmp4gdepay)
326 gboolean discont = FALSE;
329 while ((outbuf = g_queue_pop_head (rtpmp4gdepay->packets))) {
330 AU_index = GST_BUFFER_OFFSET (outbuf);
332 GST_DEBUG_OBJECT (rtpmp4gdepay, "next available AU_index %u", AU_index);
334 if (rtpmp4gdepay->next_AU_index != AU_index) {
335 GST_DEBUG_OBJECT (rtpmp4gdepay, "discont, expected AU_index %u",
336 rtpmp4gdepay->next_AU_index);
341 GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
345 GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing AU_index %u", AU_index);
346 gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay), outbuf);
347 rtpmp4gdepay->next_AU_index = AU_index + 1;
352 gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf)
354 guint AU_index = GST_BUFFER_OFFSET (outbuf);
356 if (rtpmp4gdepay->next_AU_index == -1) {
357 GST_DEBUG_OBJECT (rtpmp4gdepay, "Init AU counter %u", AU_index);
358 rtpmp4gdepay->next_AU_index = AU_index;
361 if (rtpmp4gdepay->next_AU_index == AU_index) {
362 GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing expected AU_index %u", AU_index);
364 /* we received the expected packet, push it and flush as much as we can from
366 gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay), outbuf);
367 rtpmp4gdepay->next_AU_index++;
369 while ((outbuf = g_queue_peek_head (rtpmp4gdepay->packets))) {
370 AU_index = GST_BUFFER_OFFSET (outbuf);
372 GST_DEBUG_OBJECT (rtpmp4gdepay, "next available AU_index %u", AU_index);
374 if (rtpmp4gdepay->next_AU_index == AU_index) {
375 GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing expected AU_index %u",
377 outbuf = g_queue_pop_head (rtpmp4gdepay->packets);
378 gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay),
380 rtpmp4gdepay->next_AU_index++;
382 GST_DEBUG_OBJECT (rtpmp4gdepay, "waiting for next AU_index %u",
383 rtpmp4gdepay->next_AU_index);
390 GST_DEBUG_OBJECT (rtpmp4gdepay, "queueing AU_index %u", AU_index);
392 /* loop the list to skip strictly smaller AU_index buffers */
393 for (list = rtpmp4gdepay->packets->head; list; list = g_list_next (list)) {
397 idx = GST_BUFFER_OFFSET (GST_BUFFER_CAST (list->data));
399 /* compare the new seqnum to the one in the buffer */
400 gap = (gint) (idx - AU_index);
402 GST_DEBUG_OBJECT (rtpmp4gdepay, "compare with AU_index %u, gap %d", idx,
405 /* AU_index <= idx, we can stop looking */
406 if (G_LIKELY (gap > 0))
410 g_queue_insert_before (rtpmp4gdepay->packets, list, outbuf);
412 g_queue_push_tail (rtpmp4gdepay->packets, outbuf);
417 gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
419 GstRtpMP4GDepay *rtpmp4gdepay;
421 GstClockTime timestamp;
423 rtpmp4gdepay = GST_RTP_MP4G_DEPAY (depayload);
425 /* flush remaining data on discont */
426 if (GST_BUFFER_IS_DISCONT (buf)) {
427 GST_DEBUG_OBJECT (rtpmp4gdepay, "received DISCONT");
428 gst_adapter_clear (rtpmp4gdepay->adapter);
431 timestamp = GST_BUFFER_TIMESTAMP (buf);
434 gint payload_len, payload_AU;
437 guint AU_headers_len;
438 guint AU_size, AU_index, AU_index_delta, payload_AU_size;
441 payload_len = gst_rtp_buffer_get_payload_len (buf);
442 payload = gst_rtp_buffer_get_payload (buf);
444 GST_DEBUG_OBJECT (rtpmp4gdepay, "received payload of %d", payload_len);
446 rtptime = gst_rtp_buffer_get_timestamp (buf);
447 M = gst_rtp_buffer_get_marker (buf);
449 if (rtpmp4gdepay->sizelength > 0) {
450 gint num_AU_headers, AU_headers_bytes, i;
456 /* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- .. -+-+-+-+-+-+-+-+-+-+
457 * |AU-headers-length|AU-header|AU-header| |AU-header|padding|
458 * | | (1) | (2) | | (n) * | bits |
459 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- .. -+-+-+-+-+-+-+-+-+-+
461 * The length is 2 bytes and contains the length of the following
462 * AU-headers in bits.
464 AU_headers_len = (payload[0] << 8) | payload[1];
465 AU_headers_bytes = (AU_headers_len + 7) / 8;
466 num_AU_headers = AU_headers_len / 16;
468 GST_DEBUG_OBJECT (rtpmp4gdepay, "AU headers len %d, bytes %d, num %d",
469 AU_headers_len, AU_headers_bytes, num_AU_headers);
475 if (payload_len < AU_headers_bytes)
478 /* skip special headers, point to first payload AU */
479 payload_AU = 2 + AU_headers_bytes;
480 payload_AU_size = payload_len - AU_headers_bytes;
482 if (G_UNLIKELY (rtpmp4gdepay->auxiliarydatasizelength)) {
485 /* point the bitstream parser to the first auxiliary data bit */
486 gst_bs_parse_init (&bs, payload + AU_headers_bytes,
487 payload_len - AU_headers_bytes);
489 gst_bs_parse_read (&bs, rtpmp4gdepay->auxiliarydatasizelength);
490 /* convert to bytes */
491 aux_size = (aux_size + 7) / 8;
492 /* AU data then follows auxiliary data */
493 if (payload_AU_size < aux_size)
495 payload_AU += aux_size;
496 payload_AU_size -= aux_size;
499 /* point the bitstream parser to the first AU header bit */
500 gst_bs_parse_init (&bs, payload, payload_len);
501 AU_index = AU_index_delta = 0;
503 for (i = 0; i < num_AU_headers && payload_AU_size > 0; i++) {
505 * +---------------------------------------+
507 * +---------------------------------------+
508 * | AU-Index / AU-Index-delta |
509 * +---------------------------------------+
511 * +---------------------------------------+
513 * +---------------------------------------+
515 * +---------------------------------------+
517 * +---------------------------------------+
519 * +---------------------------------------+
521 * +---------------------------------------+
523 AU_size = gst_bs_parse_read (&bs, rtpmp4gdepay->sizelength);
525 /* calculate the AU_index, which is only on the first AU of the packet
526 * and the AU_index_delta on the other AUs. This will be used to
527 * reconstruct the AU ordering when interleaving. */
529 AU_index = gst_bs_parse_read (&bs, rtpmp4gdepay->indexlength);
531 GST_DEBUG_OBJECT (rtpmp4gdepay, "AU index %u", AU_index);
533 if (AU_index == 0 && rtpmp4gdepay->prev_AU_index == 0) {
537 /* if we see two consecutive packets with AU_index of 0, we can
538 * assume we have constantDuration packets. Since we don't have
539 * the index we must use the AU duration to calculate the
540 * index. Get the diff between the timestamps first, this can be
541 * positive or negative. */
542 if (rtpmp4gdepay->prev_rtptime <= rtptime)
543 diff = rtptime - rtpmp4gdepay->prev_rtptime;
545 diff = -(rtpmp4gdepay->prev_rtptime - rtptime);
547 /* if no constantDuration was given, make one */
548 if (rtpmp4gdepay->constantDuration != 0) {
549 cd = rtpmp4gdepay->constantDuration;
550 GST_DEBUG_OBJECT (depayload, "using constantDuration %d", cd);
552 cd = diff / num_AU_headers;
553 GST_DEBUG_OBJECT (depayload, "guessing constantDuration %d", cd);
557 /* get the number of packets by dividing with the duration */
563 rtpmp4gdepay->last_AU_index += diff;
564 rtpmp4gdepay->prev_AU_index = AU_index;
566 AU_index = rtpmp4gdepay->last_AU_index;
568 GST_DEBUG_OBJECT (rtpmp4gdepay, "diff %d, AU index %u", diff,
571 rtpmp4gdepay->prev_AU_index = AU_index;
572 rtpmp4gdepay->last_AU_index = AU_index;
575 /* keep track of the higest AU_index */
576 if (rtpmp4gdepay->max_AU_index != -1
577 && rtpmp4gdepay->max_AU_index <= AU_index) {
578 GST_DEBUG_OBJECT (rtpmp4gdepay, "new interleave group, flushing");
579 /* a new interleave group started, flush */
580 gst_rtp_mp4g_depay_flush_queue (rtpmp4gdepay);
582 if (G_UNLIKELY (!rtpmp4gdepay->maxDisplacement &&
583 rtpmp4gdepay->max_AU_index != -1
584 && rtpmp4gdepay->max_AU_index >= AU_index)) {
587 /* some broken non-interleaved streams have AU-index jumping around
588 * all over the place, apparently assuming receiver disregards */
589 GST_DEBUG_OBJECT (rtpmp4gdepay, "non-interleaved broken AU indices;"
590 " forcing continuous flush");
591 /* reset AU to avoid repeated DISCONT in such case */
592 outbuf = g_queue_peek_head (rtpmp4gdepay->packets);
593 if (G_LIKELY (outbuf)) {
594 rtpmp4gdepay->next_AU_index = GST_BUFFER_OFFSET (outbuf);
595 gst_rtp_mp4g_depay_flush_queue (rtpmp4gdepay);
598 rtpmp4gdepay->prev_rtptime = rtptime;
601 gst_bs_parse_read (&bs, rtpmp4gdepay->indexdeltalength);
602 AU_index += AU_index_delta + 1;
604 /* keep track of highest AU_index */
605 if (rtpmp4gdepay->max_AU_index == -1
606 || AU_index > rtpmp4gdepay->max_AU_index)
607 rtpmp4gdepay->max_AU_index = AU_index;
609 /* the presentation time offset, a 2s-complement value, we need this to
610 * calculate the timestamp on the output packet. */
611 if (rtpmp4gdepay->ctsdeltalength > 0) {
612 if (gst_bs_parse_read (&bs, 1))
613 gst_bs_parse_read (&bs, rtpmp4gdepay->ctsdeltalength);
615 /* the decoding time offset, a 2s-complement value */
616 if (rtpmp4gdepay->dtsdeltalength > 0) {
617 if (gst_bs_parse_read (&bs, 1))
618 gst_bs_parse_read (&bs, rtpmp4gdepay->dtsdeltalength);
620 /* RAP-flag to indicate that the AU contains a keyframe */
621 if (rtpmp4gdepay->randomaccessindication)
622 gst_bs_parse_read (&bs, 1);
624 if (rtpmp4gdepay->streamstateindication > 0)
625 gst_bs_parse_read (&bs, rtpmp4gdepay->streamstateindication);
627 GST_DEBUG_OBJECT (rtpmp4gdepay, "size %d, index %d, delta %d", AU_size,
628 AU_index, AU_index_delta);
630 /* fragmented pakets have the AU_size set to the size of the
631 * unfragmented AU. */
632 if (AU_size > payload_AU_size)
633 AU_size = payload_AU_size;
635 /* collect stuff in the adapter, strip header from payload and push in
638 gst_rtp_buffer_get_payload_subbuffer (buf, payload_AU, AU_size);
639 gst_adapter_push (rtpmp4gdepay->adapter, outbuf);
644 /* packet is complete, flush */
645 avail = gst_adapter_available (rtpmp4gdepay->adapter);
647 outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
648 gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad));
650 /* copy some of the fields we calculated above on the buffer. We also
651 * copy the AU_index so that we can sort the packets in our queue. */
652 GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
653 GST_BUFFER_OFFSET (outbuf) = AU_index;
655 /* make sure we don't use the timestamp again for other AUs in this
659 GST_DEBUG_OBJECT (depayload, "pushing buffer of size %d",
660 GST_BUFFER_SIZE (outbuf));
662 gst_rtp_mp4g_depay_queue (rtpmp4gdepay, outbuf);
665 payload_AU += AU_size;
666 payload_AU_size -= AU_size;
669 /* push complete buffer in adapter */
670 outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 0, payload_len);
671 gst_adapter_push (rtpmp4gdepay->adapter, outbuf);
673 /* if this was the last packet of the VOP, create and push a buffer */
677 avail = gst_adapter_available (rtpmp4gdepay->adapter);
679 outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
681 GST_DEBUG ("gst_rtp_mp4g_depay_chain: pushing buffer of size %d",
682 GST_BUFFER_SIZE (outbuf));
693 GST_ELEMENT_WARNING (rtpmp4gdepay, STREAM, DECODE,
694 ("Packet payload was too short."), (NULL));
699 static GstStateChangeReturn
700 gst_rtp_mp4g_depay_change_state (GstElement * element,
701 GstStateChange transition)
703 GstRtpMP4GDepay *rtpmp4gdepay;
704 GstStateChangeReturn ret;
706 rtpmp4gdepay = GST_RTP_MP4G_DEPAY (element);
708 switch (transition) {
709 case GST_STATE_CHANGE_READY_TO_PAUSED:
710 gst_adapter_clear (rtpmp4gdepay->adapter);
711 rtpmp4gdepay->max_AU_index = -1;
712 rtpmp4gdepay->next_AU_index = -1;
713 rtpmp4gdepay->prev_AU_index = -1;
714 rtpmp4gdepay->prev_rtptime = -1;
715 rtpmp4gdepay->last_AU_index = -1;
721 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
723 switch (transition) {
724 case GST_STATE_CHANGE_PAUSED_TO_READY:
725 gst_adapter_clear (rtpmp4gdepay->adapter);
726 gst_rtp_mp4g_depay_clear_queue (rtpmp4gdepay);
735 gst_rtp_mp4g_depay_plugin_init (GstPlugin * plugin)
737 return gst_element_register (plugin, "rtpmp4gdepay",
738 GST_RANK_MARGINAL, GST_TYPE_RTP_MP4G_DEPAY);