diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-11-01 11:58:57 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-11-01 11:58:57 +0000 |
commit | 0a30db47eb499b9bf8b447d5b7ca920dc6d10a82 (patch) | |
tree | 6fe2f0bbc101e330fc0007e489a836858f78f12b | |
parent | 170521a30f6dad9ba9f0578517bc4310cf7c5dfc (diff) |
gstdepay: check for correct fragment offset
Make sure we only insert the rtp packet in the adapter when the
frag_offset matches. When the first packet of a fragment is dropped,
it avoids putting the remaining packets in the adapter and processing
the partial fragment.
-rw-r--r-- | gst/rtp/gstrtpgstdepay.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/gst/rtp/gstrtpgstdepay.c b/gst/rtp/gstrtpgstdepay.c index c992abf0b..7978a39f5 100644 --- a/gst/rtp/gstrtpgstdepay.c +++ b/gst/rtp/gstrtpgstdepay.c @@ -197,7 +197,7 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) GstBuffer *subbuf, *outbuf = NULL; gint payload_len; guint8 *payload; - guint CV; + guint CV, frag_offset, avail; rtpgstdepay = GST_RTP_GST_DEPAY (depayload); @@ -223,9 +223,12 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) * | Frag_offset | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ - /* frag_offset = - * (payload[4] << 24) | (payload[5] << 16) | (payload[6] << 8) | payload[7]; - */ + frag_offset = + (payload[4] << 24) | (payload[5] << 16) | (payload[6] << 8) | payload[7]; + + avail = gst_adapter_available (rtpgstdepay->adapter); + if (avail != frag_offset) + goto wrong_frag; /* subbuffer skipping the 8 header bytes */ subbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 8, -1); @@ -326,6 +329,12 @@ empty_packet: ("Empty Payload."), (NULL)); return NULL; } +wrong_frag: + { + gst_adapter_clear (rtpgstdepay->adapter); + GST_LOG_OBJECT (rtpgstdepay, "wrong fragment, skipping"); + return NULL; + } too_small: { GST_ELEMENT_WARNING (rtpgstdepay, STREAM, DECODE, |