summaryrefslogtreecommitdiffstats
path: root/gst/rtp/gstrtpmp4gdepay.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2007-04-10 17:06:05 +0000
committerWim Taymans <wim.taymans@gmail.com>2007-04-10 17:06:05 +0000
commitacddbd83ff23d7016afdcfad5da3d3aa82b63679 (patch)
tree0a7c756fb05a0c6bfb3a1babfd85d327684b5f91 /gst/rtp/gstrtpmp4gdepay.c
parent497d589d56cf5e0ef758ca6c0443cdee7b3da91d (diff)
gst/rtp/gstrtpamrdepay.c: Fix depayloader clock_rate and some cleanups.
Original commit message from CVS: * gst/rtp/gstrtpamrdepay.c: (gst_rtp_amr_depay_setcaps), (gst_rtp_amr_depay_process): Fix depayloader clock_rate and some cleanups. * gst/rtp/gstrtph264depay.c: (gst_rtp_h264_depay_finalize), (gst_rtp_h264_depay_setcaps), (gst_rtp_h264_depay_process): * gst/rtp/gstrtph264depay.h: Don't push codec_data in the adapter because it might get flushed when we get a discont. * gst/rtp/gstrtpmp4gdepay.c: (gst_rtp_mp4g_depay_process): Handle multiple AU per packet. * gst/rtp/gstrtpsv3vdepay.c: (gst_rtp_sv3v_depay_process), (gst_rtp_sv3v_depay_plugin_init): Disable rank, this one does not work. Remove timestamping, base class does that.
Diffstat (limited to 'gst/rtp/gstrtpmp4gdepay.c')
-rw-r--r--gst/rtp/gstrtpmp4gdepay.c98
1 files changed, 63 insertions, 35 deletions
diff --git a/gst/rtp/gstrtpmp4gdepay.c b/gst/rtp/gstrtpmp4gdepay.c
index c9e2d453..f1d68a21 100644
--- a/gst/rtp/gstrtpmp4gdepay.c
+++ b/gst/rtp/gstrtpmp4gdepay.c
@@ -287,64 +287,92 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
guint32 timestamp;
guint AU_headers_len;
guint AU_size, AU_index;
+ gboolean M;
payload_len = gst_rtp_buffer_get_payload_len (buf);
payload = gst_rtp_buffer_get_payload (buf);
payload_header = 0;
+ timestamp = gst_rtp_buffer_get_timestamp (buf);
+ M = gst_rtp_buffer_get_marker (buf);
+
if (rtpmp4gdepay->sizelength > 0) {
+ gint num_AU_headers, AU_headers_bytes, i;
+
/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- .. -+-+-+-+-+-+-+-+-+-+
* |AU-headers-length|AU-header|AU-header| |AU-header|padding|
* | | (1) | (2) | | (n) * | bits |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- .. -+-+-+-+-+-+-+-+-+-+
*
- * The lenght is 2 bytes and contains the length of the following
+ * The length is 2 bytes and contains the length of the following
* AU-headers in bits.
*/
AU_headers_len = (payload[0] << 8) | payload[1];
+ AU_headers_bytes = (AU_headers_len + 7) / 8;
+ num_AU_headers = AU_headers_len / 16;
+
+ GST_DEBUG_OBJECT (rtpmp4gdepay, "AU headers len %d, bytes %d, num %d",
+ AU_headers_len, AU_headers_bytes, num_AU_headers);
/* skip header */
payload += 2;
- payload_header += 2;
- payload_len -= 2;
-
- /* FIXME, use bits */
- AU_size = ((payload[0] << 8) | payload[1]) >> 3;
- AU_index = payload[1] & 0x7;
-
- GST_DEBUG_OBJECT (rtpmp4gdepay, "len, %d, size %d, index %d",
- AU_headers_len, AU_size, AU_index);
-
/* skip special headers */
- payload += (AU_headers_len + 7) / 8;
- payload_header += (AU_headers_len + 7) / 8;
- payload_len = AU_size;
- }
-
- timestamp = gst_rtp_buffer_get_timestamp (buf);
-
- /* strip header from payload and push in the adapter */
- outbuf =
- gst_rtp_buffer_get_payload_subbuffer (buf, payload_header, payload_len);
- gst_adapter_push (rtpmp4gdepay->adapter, outbuf);
+ payload_header = 2 + AU_headers_bytes;
+
+ for (i = 0; i < num_AU_headers; i++) {
+ /* FIXME, use bits */
+ AU_size = ((payload[0] << 8) | payload[1]) >> 3;
+ AU_index = payload[1] & 0x7;
+ payload += 2;
+
+ GST_DEBUG_OBJECT (rtpmp4gdepay, "len, %d, size %d, index %d",
+ AU_headers_len, AU_size, AU_index);
+
+ /* collect stuff in the adapter, strip header from payload and push in
+ * the adapter */
+ outbuf =
+ gst_rtp_buffer_get_payload_subbuffer (buf, payload_header, AU_size);
+ gst_adapter_push (rtpmp4gdepay->adapter, outbuf);
+
+ if (M) {
+ guint avail;
+
+ /* packet is complete, flush */
+ avail = gst_adapter_available (rtpmp4gdepay->adapter);
+
+ outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
+ gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad));
+
+ GST_DEBUG ("gst_rtp_mp4g_depay_chain: pushing buffer of size %d",
+ GST_BUFFER_SIZE (outbuf));
+
+ /* only apply the timestamp for the first buffer */
+ if (i == 0)
+ gst_base_rtp_depayload_push_ts (depayload, timestamp, outbuf);
+ else
+ gst_base_rtp_depayload_push (depayload, outbuf);
+ }
+ payload_header += AU_size;
+ }
+ } else {
+ /* push complete buffer in adapter */
+ outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 0, payload_len);
+ gst_adapter_push (rtpmp4gdepay->adapter, outbuf);
- /* if this was the last packet of the VOP, create and push a buffer */
- if (gst_rtp_buffer_get_marker (buf)) {
- guint avail;
+ /* if this was the last packet of the VOP, create and push a buffer */
+ if (M) {
+ guint avail;
- avail = gst_adapter_available (rtpmp4gdepay->adapter);
+ avail = gst_adapter_available (rtpmp4gdepay->adapter);
- outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
- gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad));
- GST_BUFFER_TIMESTAMP (outbuf) = gst_util_uint64_scale_int
- (timestamp, GST_SECOND, depayload->clock_rate);
+ outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
+ gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad));
- GST_DEBUG ("gst_rtp_mp4g_depay_chain: pushing buffer of size %d",
- GST_BUFFER_SIZE (outbuf));
+ GST_DEBUG ("gst_rtp_mp4g_depay_chain: pushing buffer of size %d",
+ GST_BUFFER_SIZE (outbuf));
- return outbuf;
- } else {
- return NULL;
+ return outbuf;
+ }
}
}
return NULL;