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 static GstStaticPadTemplate gst_rtp_mp4g_depay_src_template =
34 GST_STATIC_PAD_TEMPLATE ("src",
37 GST_STATIC_CAPS ("video/mpeg,"
38 "mpegversion=(int) 4,"
39 "systemstream=(boolean)false;"
40 "audio/mpeg," "mpegversion=(int) 4, " "stream-format=(string)raw")
43 static GstStaticPadTemplate gst_rtp_mp4g_depay_sink_template =
44 GST_STATIC_PAD_TEMPLATE ("sink",
47 GST_STATIC_CAPS ("application/x-rtp, "
48 "media = (string) { \"video\", \"audio\", \"application\" }, "
49 "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
50 "clock-rate = (int) [1, MAX ], "
51 "encoding-name = (string) \"MPEG4-GENERIC\", "
52 /* required string params */
53 "streamtype = (string) { \"4\", \"5\" }, " /* 4 = video, 5 = audio */
54 /* "profile-level-id = (string) [1,MAX], " */
55 /* "config = (string) [1,MAX]" */
56 "mode = (string) { \"generic\", \"CELP-cbr\", \"CELP-vbr\", \"AAC-lbr\", \"AAC-hbr\" } "
57 /* Optional general parameters */
58 /* "objecttype = (string) [1,MAX], " */
59 /* "constantsize = (string) [1,MAX], " *//* constant size of each AU */
60 /* "constantduration = (string) [1,MAX], " *//* constant duration of each AU */
61 /* "maxdisplacement = (string) [1,MAX], " */
62 /* "de-interleavebuffersize = (string) [1,MAX], " */
63 /* Optional configuration parameters */
64 /* "sizelength = (string) [1, 32], " */
65 /* "indexlength = (string) [1, 32], " */
66 /* "indexdeltalength = (string) [1, 32], " */
67 /* "ctsdeltalength = (string) [1, 32], " */
68 /* "dtsdeltalength = (string) [1, 32], " */
69 /* "randomaccessindication = (string) {0, 1}, " */
70 /* "streamstateindication = (string) [0, 32], " */
71 /* "auxiliarydatasizelength = (string) [0, 32]" */ )
74 /* simple bitstream parser */
79 gint head; /* bitpos in the cache of next bit */
80 guint64 cache; /* cached bytes */
84 gst_bs_parse_init (GstBsParse * bs, const guint8 * data, guint size)
87 bs->end = data + size;
89 bs->cache = 0xffffffff;
93 gst_bs_parse_read (GstBsParse * bs, guint n)
101 /* fill up the cache if we need to */
102 while (bs->head < n) {
103 if (bs->data >= bs->end) {
104 /* we're at the end, can't produce more than head number of bits */
108 /* shift bytes in cache, moving the head bits of the cache left */
109 bs->cache = (bs->cache << 8) | *bs->data++;
113 /* bring the required bits down and truncate */
114 if ((shift = bs->head - n) > 0)
115 res = bs->cache >> shift;
119 /* mask out required bits */
129 GST_BOILERPLATE (GstRtpMP4GDepay, gst_rtp_mp4g_depay, GstBaseRTPDepayload,
130 GST_TYPE_BASE_RTP_DEPAYLOAD);
132 static void gst_rtp_mp4g_depay_finalize (GObject * object);
134 static gboolean gst_rtp_mp4g_depay_setcaps (GstBaseRTPDepayload * depayload,
136 static GstBuffer *gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload,
139 static GstStateChangeReturn gst_rtp_mp4g_depay_change_state (GstElement *
140 element, GstStateChange transition);
144 gst_rtp_mp4g_depay_base_init (gpointer klass)
146 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
148 gst_element_class_add_pad_template (element_class,
149 gst_static_pad_template_get (&gst_rtp_mp4g_depay_src_template));
150 gst_element_class_add_pad_template (element_class,
151 gst_static_pad_template_get (&gst_rtp_mp4g_depay_sink_template));
153 gst_element_class_set_details_simple (element_class,
154 "RTP MPEG4 ES depayloader", "Codec/Depayloader/Network/RTP",
155 "Extracts MPEG4 elementary streams from RTP packets (RFC 3640)",
156 "Wim Taymans <wim.taymans@gmail.com>");
160 gst_rtp_mp4g_depay_class_init (GstRtpMP4GDepayClass * klass)
162 GObjectClass *gobject_class;
163 GstElementClass *gstelement_class;
164 GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
166 gobject_class = (GObjectClass *) klass;
167 gstelement_class = (GstElementClass *) klass;
168 gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
170 gobject_class->finalize = gst_rtp_mp4g_depay_finalize;
172 gstelement_class->change_state = gst_rtp_mp4g_depay_change_state;
174 gstbasertpdepayload_class->process = gst_rtp_mp4g_depay_process;
175 gstbasertpdepayload_class->set_caps = gst_rtp_mp4g_depay_setcaps;
177 GST_DEBUG_CATEGORY_INIT (rtpmp4gdepay_debug, "rtpmp4gdepay", 0,
178 "MP4-generic RTP Depayloader");
182 gst_rtp_mp4g_depay_init (GstRtpMP4GDepay * rtpmp4gdepay,
183 GstRtpMP4GDepayClass * klass)
185 rtpmp4gdepay->adapter = gst_adapter_new ();
186 rtpmp4gdepay->packets = g_queue_new ();
190 gst_rtp_mp4g_depay_finalize (GObject * object)
192 GstRtpMP4GDepay *rtpmp4gdepay;
194 rtpmp4gdepay = GST_RTP_MP4G_DEPAY (object);
196 g_object_unref (rtpmp4gdepay->adapter);
197 rtpmp4gdepay->adapter = NULL;
198 g_queue_free (rtpmp4gdepay->packets);
199 rtpmp4gdepay->packets = NULL;
201 G_OBJECT_CLASS (parent_class)->finalize (object);
205 gst_rtp_mp4g_depay_parse_int (GstStructure * structure, const gchar * field,
211 if ((str = gst_structure_get_string (structure, field)))
214 if (gst_structure_get_int (structure, field, &res))
221 gst_rtp_mp4g_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
223 GstStructure *structure;
224 GstRtpMP4GDepay *rtpmp4gdepay;
225 GstCaps *srccaps = NULL;
231 rtpmp4gdepay = GST_RTP_MP4G_DEPAY (depayload);
233 structure = gst_caps_get_structure (caps, 0);
235 if (!gst_structure_get_int (structure, "clock-rate", &clock_rate))
236 clock_rate = 90000; /* default */
237 depayload->clock_rate = clock_rate;
239 if ((str = gst_structure_get_string (structure, "media"))) {
240 if (strcmp (str, "audio") == 0) {
241 srccaps = gst_caps_new_simple ("audio/mpeg",
242 "mpegversion", G_TYPE_INT, 4, "stream-format", G_TYPE_STRING, "raw",
244 } else if (strcmp (str, "video") == 0) {
245 srccaps = gst_caps_new_simple ("video/mpeg",
246 "mpegversion", G_TYPE_INT, 4,
247 "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
253 /* these values are optional and have a default value of 0 (no header) */
254 rtpmp4gdepay->sizelength =
255 gst_rtp_mp4g_depay_parse_int (structure, "sizelength", 0);
256 rtpmp4gdepay->indexlength =
257 gst_rtp_mp4g_depay_parse_int (structure, "indexlength", 0);
258 rtpmp4gdepay->indexdeltalength =
259 gst_rtp_mp4g_depay_parse_int (structure, "indexdeltalength", 0);
260 rtpmp4gdepay->ctsdeltalength =
261 gst_rtp_mp4g_depay_parse_int (structure, "ctsdeltalength", 0);
262 rtpmp4gdepay->dtsdeltalength =
263 gst_rtp_mp4g_depay_parse_int (structure, "dtsdeltalength", 0);
265 gst_rtp_mp4g_depay_parse_int (structure, "randomaccessindication", 0);
266 rtpmp4gdepay->randomaccessindication = someint > 0 ? 1 : 0;
267 rtpmp4gdepay->streamstateindication =
268 gst_rtp_mp4g_depay_parse_int (structure, "streamstateindication", 0);
269 rtpmp4gdepay->auxiliarydatasizelength =
270 gst_rtp_mp4g_depay_parse_int (structure, "auxiliarydatasizelength", 0);
271 rtpmp4gdepay->constantSize =
272 gst_rtp_mp4g_depay_parse_int (structure, "constantsize", 0);
273 rtpmp4gdepay->constantDuration =
274 gst_rtp_mp4g_depay_parse_int (structure, "constantduration", 0);
275 rtpmp4gdepay->maxDisplacement =
276 gst_rtp_mp4g_depay_parse_int (structure, "maxdisplacement", 0);
279 /* get config string */
280 if ((str = gst_structure_get_string (structure, "config"))) {
283 g_value_init (&v, GST_TYPE_BUFFER);
284 if (gst_value_deserialize (&v, str)) {
287 buffer = gst_value_get_buffer (&v);
288 gst_caps_set_simple (srccaps,
289 "codec_data", GST_TYPE_BUFFER, buffer, NULL);
292 g_warning ("cannot convert config to buffer");
296 res = gst_pad_set_caps (depayload->srcpad, srccaps);
297 gst_caps_unref (srccaps);
304 GST_DEBUG_OBJECT (rtpmp4gdepay, "Unknown media type");
310 gst_rtp_mp4g_depay_clear_queue (GstRtpMP4GDepay * rtpmp4gdepay)
314 while ((outbuf = g_queue_pop_head (rtpmp4gdepay->packets)))
315 gst_buffer_unref (outbuf);
319 gst_rtp_mp4g_depay_reset (GstRtpMP4GDepay * rtpmp4gdepay)
321 gst_adapter_clear (rtpmp4gdepay->adapter);
322 rtpmp4gdepay->max_AU_index = -1;
323 rtpmp4gdepay->next_AU_index = -1;
324 rtpmp4gdepay->prev_AU_index = -1;
325 rtpmp4gdepay->prev_rtptime = -1;
326 rtpmp4gdepay->last_AU_index = -1;
327 gst_rtp_mp4g_depay_clear_queue (rtpmp4gdepay);
331 gst_rtp_mp4g_depay_flush_queue (GstRtpMP4GDepay * rtpmp4gdepay)
334 gboolean discont = FALSE;
337 while ((outbuf = g_queue_pop_head (rtpmp4gdepay->packets))) {
338 AU_index = GST_BUFFER_OFFSET (outbuf);
340 GST_DEBUG_OBJECT (rtpmp4gdepay, "next available AU_index %u", AU_index);
342 if (rtpmp4gdepay->next_AU_index != AU_index) {
343 GST_DEBUG_OBJECT (rtpmp4gdepay, "discont, expected AU_index %u",
344 rtpmp4gdepay->next_AU_index);
349 GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
353 GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing AU_index %u", AU_index);
354 gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay), outbuf);
355 rtpmp4gdepay->next_AU_index = AU_index + 1;
360 gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf)
362 guint AU_index = GST_BUFFER_OFFSET (outbuf);
364 if (rtpmp4gdepay->next_AU_index == -1) {
365 GST_DEBUG_OBJECT (rtpmp4gdepay, "Init AU counter %u", AU_index);
366 rtpmp4gdepay->next_AU_index = AU_index;
369 if (rtpmp4gdepay->next_AU_index == AU_index) {
370 GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing expected AU_index %u", AU_index);
372 /* we received the expected packet, push it and flush as much as we can from
374 gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay), outbuf);
375 rtpmp4gdepay->next_AU_index++;
377 while ((outbuf = g_queue_peek_head (rtpmp4gdepay->packets))) {
378 AU_index = GST_BUFFER_OFFSET (outbuf);
380 GST_DEBUG_OBJECT (rtpmp4gdepay, "next available AU_index %u", AU_index);
382 if (rtpmp4gdepay->next_AU_index == AU_index) {
383 GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing expected AU_index %u",
385 outbuf = g_queue_pop_head (rtpmp4gdepay->packets);
386 gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay),
388 rtpmp4gdepay->next_AU_index++;
390 GST_DEBUG_OBJECT (rtpmp4gdepay, "waiting for next AU_index %u",
391 rtpmp4gdepay->next_AU_index);
398 GST_DEBUG_OBJECT (rtpmp4gdepay, "queueing AU_index %u", AU_index);
400 /* loop the list to skip strictly smaller AU_index buffers */
401 for (list = rtpmp4gdepay->packets->head; list; list = g_list_next (list)) {
405 idx = GST_BUFFER_OFFSET (GST_BUFFER_CAST (list->data));
407 /* compare the new seqnum to the one in the buffer */
408 gap = (gint) (idx - AU_index);
410 GST_DEBUG_OBJECT (rtpmp4gdepay, "compare with AU_index %u, gap %d", idx,
413 /* AU_index <= idx, we can stop looking */
414 if (G_LIKELY (gap > 0))
418 g_queue_insert_before (rtpmp4gdepay->packets, list, outbuf);
420 g_queue_push_tail (rtpmp4gdepay->packets, outbuf);
425 gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
427 GstRtpMP4GDepay *rtpmp4gdepay;
429 GstClockTime timestamp;
431 rtpmp4gdepay = GST_RTP_MP4G_DEPAY (depayload);
433 /* flush remaining data on discont */
434 if (GST_BUFFER_IS_DISCONT (buf)) {
435 GST_DEBUG_OBJECT (rtpmp4gdepay, "received DISCONT");
436 gst_adapter_clear (rtpmp4gdepay->adapter);
439 timestamp = GST_BUFFER_TIMESTAMP (buf);
442 gint payload_len, payload_AU;
445 guint AU_headers_len;
446 guint AU_size, AU_index, AU_index_delta, payload_AU_size;
449 payload_len = gst_rtp_buffer_get_payload_len (buf);
450 payload = gst_rtp_buffer_get_payload (buf);
452 GST_DEBUG_OBJECT (rtpmp4gdepay, "received payload of %d", payload_len);
454 rtptime = gst_rtp_buffer_get_timestamp (buf);
455 M = gst_rtp_buffer_get_marker (buf);
457 if (rtpmp4gdepay->sizelength > 0) {
458 gint num_AU_headers, AU_headers_bytes, i;
464 /* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- .. -+-+-+-+-+-+-+-+-+-+
465 * |AU-headers-length|AU-header|AU-header| |AU-header|padding|
466 * | | (1) | (2) | | (n) * | bits |
467 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- .. -+-+-+-+-+-+-+-+-+-+
469 * The length is 2 bytes and contains the length of the following
470 * AU-headers in bits.
472 AU_headers_len = (payload[0] << 8) | payload[1];
473 AU_headers_bytes = (AU_headers_len + 7) / 8;
474 num_AU_headers = AU_headers_len / 16;
476 GST_DEBUG_OBJECT (rtpmp4gdepay, "AU headers len %d, bytes %d, num %d",
477 AU_headers_len, AU_headers_bytes, num_AU_headers);
483 if (payload_len < AU_headers_bytes)
486 /* skip special headers, point to first payload AU */
487 payload_AU = 2 + AU_headers_bytes;
488 payload_AU_size = payload_len - AU_headers_bytes;
490 if (G_UNLIKELY (rtpmp4gdepay->auxiliarydatasizelength)) {
493 /* point the bitstream parser to the first auxiliary data bit */
494 gst_bs_parse_init (&bs, payload + AU_headers_bytes,
495 payload_len - AU_headers_bytes);
497 gst_bs_parse_read (&bs, rtpmp4gdepay->auxiliarydatasizelength);
498 /* convert to bytes */
499 aux_size = (aux_size + 7) / 8;
500 /* AU data then follows auxiliary data */
501 if (payload_AU_size < aux_size)
503 payload_AU += aux_size;
504 payload_AU_size -= aux_size;
507 /* point the bitstream parser to the first AU header bit */
508 gst_bs_parse_init (&bs, payload, payload_len);
509 AU_index = AU_index_delta = 0;
511 for (i = 0; i < num_AU_headers && payload_AU_size > 0; i++) {
513 * +---------------------------------------+
515 * +---------------------------------------+
516 * | AU-Index / AU-Index-delta |
517 * +---------------------------------------+
519 * +---------------------------------------+
521 * +---------------------------------------+
523 * +---------------------------------------+
525 * +---------------------------------------+
527 * +---------------------------------------+
529 * +---------------------------------------+
531 AU_size = gst_bs_parse_read (&bs, rtpmp4gdepay->sizelength);
533 /* calculate the AU_index, which is only on the first AU of the packet
534 * and the AU_index_delta on the other AUs. This will be used to
535 * reconstruct the AU ordering when interleaving. */
537 AU_index = gst_bs_parse_read (&bs, rtpmp4gdepay->indexlength);
539 GST_DEBUG_OBJECT (rtpmp4gdepay, "AU index %u", AU_index);
541 if (AU_index == 0 && rtpmp4gdepay->prev_AU_index == 0) {
545 /* if we see two consecutive packets with AU_index of 0, we can
546 * assume we have constantDuration packets. Since we don't have
547 * the index we must use the AU duration to calculate the
548 * index. Get the diff between the timestamps first, this can be
549 * positive or negative. */
550 if (rtpmp4gdepay->prev_rtptime <= rtptime)
551 diff = rtptime - rtpmp4gdepay->prev_rtptime;
553 diff = -(rtpmp4gdepay->prev_rtptime - rtptime);
555 /* if no constantDuration was given, make one */
556 if (rtpmp4gdepay->constantDuration != 0) {
557 cd = rtpmp4gdepay->constantDuration;
558 GST_DEBUG_OBJECT (depayload, "using constantDuration %d", cd);
559 } else if (rtpmp4gdepay->prev_AU_num > 0) {
560 /* use number of packets and of previous frame */
561 cd = diff / rtpmp4gdepay->prev_AU_num;
562 GST_DEBUG_OBJECT (depayload, "guessing constantDuration %d", cd);
564 /* assume this frame has the same number of packets as the
566 cd = diff / num_AU_headers;
567 GST_DEBUG_OBJECT (depayload, "guessing constantDuration %d", cd);
571 /* get the number of packets by dividing with the duration */
577 rtpmp4gdepay->last_AU_index += diff;
578 rtpmp4gdepay->prev_AU_index = AU_index;
580 AU_index = rtpmp4gdepay->last_AU_index;
582 GST_DEBUG_OBJECT (rtpmp4gdepay, "diff %d, AU index %u", diff,
585 rtpmp4gdepay->prev_AU_index = AU_index;
586 rtpmp4gdepay->last_AU_index = AU_index;
589 /* keep track of the higest AU_index */
590 if (rtpmp4gdepay->max_AU_index != -1
591 && rtpmp4gdepay->max_AU_index <= AU_index) {
592 GST_DEBUG_OBJECT (rtpmp4gdepay, "new interleave group, flushing");
593 /* a new interleave group started, flush */
594 gst_rtp_mp4g_depay_flush_queue (rtpmp4gdepay);
596 if (G_UNLIKELY (!rtpmp4gdepay->maxDisplacement &&
597 rtpmp4gdepay->max_AU_index != -1
598 && rtpmp4gdepay->max_AU_index >= AU_index)) {
601 /* some broken non-interleaved streams have AU-index jumping around
602 * all over the place, apparently assuming receiver disregards */
603 GST_DEBUG_OBJECT (rtpmp4gdepay, "non-interleaved broken AU indices;"
604 " forcing continuous flush");
605 /* reset AU to avoid repeated DISCONT in such case */
606 outbuf = g_queue_peek_head (rtpmp4gdepay->packets);
607 if (G_LIKELY (outbuf)) {
608 rtpmp4gdepay->next_AU_index = GST_BUFFER_OFFSET (outbuf);
609 gst_rtp_mp4g_depay_flush_queue (rtpmp4gdepay);
612 rtpmp4gdepay->prev_rtptime = rtptime;
613 rtpmp4gdepay->prev_AU_num = num_AU_headers;
616 gst_bs_parse_read (&bs, rtpmp4gdepay->indexdeltalength);
617 AU_index += AU_index_delta + 1;
619 /* keep track of highest AU_index */
620 if (rtpmp4gdepay->max_AU_index == -1
621 || AU_index > rtpmp4gdepay->max_AU_index)
622 rtpmp4gdepay->max_AU_index = AU_index;
624 /* the presentation time offset, a 2s-complement value, we need this to
625 * calculate the timestamp on the output packet. */
626 if (rtpmp4gdepay->ctsdeltalength > 0) {
627 if (gst_bs_parse_read (&bs, 1))
628 gst_bs_parse_read (&bs, rtpmp4gdepay->ctsdeltalength);
630 /* the decoding time offset, a 2s-complement value */
631 if (rtpmp4gdepay->dtsdeltalength > 0) {
632 if (gst_bs_parse_read (&bs, 1))
633 gst_bs_parse_read (&bs, rtpmp4gdepay->dtsdeltalength);
635 /* RAP-flag to indicate that the AU contains a keyframe */
636 if (rtpmp4gdepay->randomaccessindication)
637 gst_bs_parse_read (&bs, 1);
639 if (rtpmp4gdepay->streamstateindication > 0)
640 gst_bs_parse_read (&bs, rtpmp4gdepay->streamstateindication);
642 GST_DEBUG_OBJECT (rtpmp4gdepay, "size %d, index %d, delta %d", AU_size,
643 AU_index, AU_index_delta);
645 /* fragmented pakets have the AU_size set to the size of the
646 * unfragmented AU. */
647 if (AU_size > payload_AU_size)
648 AU_size = payload_AU_size;
650 /* collect stuff in the adapter, strip header from payload and push in
653 gst_rtp_buffer_get_payload_subbuffer (buf, payload_AU, AU_size);
654 gst_adapter_push (rtpmp4gdepay->adapter, outbuf);
659 /* packet is complete, flush */
660 avail = gst_adapter_available (rtpmp4gdepay->adapter);
662 outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
663 gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad));
665 /* copy some of the fields we calculated above on the buffer. We also
666 * copy the AU_index so that we can sort the packets in our queue. */
667 GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
668 GST_BUFFER_OFFSET (outbuf) = AU_index;
670 /* make sure we don't use the timestamp again for other AUs in this
674 GST_DEBUG_OBJECT (depayload, "pushing buffer of size %d",
675 GST_BUFFER_SIZE (outbuf));
677 gst_rtp_mp4g_depay_queue (rtpmp4gdepay, outbuf);
680 payload_AU += AU_size;
681 payload_AU_size -= AU_size;
684 /* push complete buffer in adapter */
685 outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 0, payload_len);
686 gst_adapter_push (rtpmp4gdepay->adapter, outbuf);
688 /* if this was the last packet of the VOP, create and push a buffer */
692 avail = gst_adapter_available (rtpmp4gdepay->adapter);
694 outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
696 GST_DEBUG ("gst_rtp_mp4g_depay_chain: pushing buffer of size %d",
697 GST_BUFFER_SIZE (outbuf));
708 GST_ELEMENT_WARNING (rtpmp4gdepay, STREAM, DECODE,
709 ("Packet payload was too short."), (NULL));
714 static GstStateChangeReturn
715 gst_rtp_mp4g_depay_change_state (GstElement * element,
716 GstStateChange transition)
718 GstRtpMP4GDepay *rtpmp4gdepay;
719 GstStateChangeReturn ret;
721 rtpmp4gdepay = GST_RTP_MP4G_DEPAY (element);
723 switch (transition) {
724 case GST_STATE_CHANGE_READY_TO_PAUSED:
725 gst_rtp_mp4g_depay_reset (rtpmp4gdepay);
731 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
733 switch (transition) {
734 case GST_STATE_CHANGE_PAUSED_TO_READY:
735 gst_rtp_mp4g_depay_reset (rtpmp4gdepay);
744 gst_rtp_mp4g_depay_plugin_init (GstPlugin * plugin)
746 return gst_element_register (plugin, "rtpmp4gdepay",
747 GST_RANK_SECONDARY, GST_TYPE_RTP_MP4G_DEPAY);