rtptheoradepay: handle packets > 0xffff

Reorganize some things in the depayloader so that it can handle packets larger
than 16 bits.
Remove the size restriction on the payloader.
This commit is contained in:
Wim Taymans 2013-11-21 11:30:28 +01:00
parent 81e2c8130a
commit 43e9b56122
2 changed files with 12 additions and 16 deletions

View file

@ -398,6 +398,7 @@ gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
guint32 header, ident;
guint8 F, TDT, packets;
GstRTPBuffer rtp = { NULL };
guint length;
rtptheoradepay = GST_RTP_THEORA_DEPAY (depayload);
@ -488,10 +489,14 @@ gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
/* construct assembled buffer */
payload_len = gst_adapter_available (rtptheoradepay->adapter);
payload = gst_adapter_take (rtptheoradepay->adapter, payload_len);
/* fix the length */
payload[0] = ((payload_len - 2) >> 8) & 0xff;
payload[1] = (payload_len - 2) & 0xff;
/* use this length */
length = payload_len - 2;
to_free = payload;
} else {
/* read length from data */
length = 0;
}
GST_DEBUG_OBJECT (depayload, "assemble done, payload_len %d", payload_len);
@ -516,9 +521,9 @@ gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+*
*/
while (payload_len >= 2) {
guint16 length;
if (length == 0)
length = GST_READ_UINT16_BE (payload);
length = GST_READ_UINT16_BE (payload);
payload += 2;
payload_len -= 2;
@ -557,6 +562,8 @@ gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
payload += length;
payload_len -= length;
/* make sure to read next length */
length = 0;
ret = gst_rtp_base_depayload_push (depayload, outbuf);
if (ret != GST_FLOW_OK)

View file

@ -734,9 +734,6 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload,
GST_DEBUG_OBJECT (rtptheorapay, "size %" G_GSIZE_FORMAT
", duration %" GST_TIME_FORMAT, size, GST_TIME_ARGS (duration));
if (G_UNLIKELY (size > 0xffff))
goto wrong_size;
/* find packet type */
if (size == 0) {
TDT = 0;
@ -833,14 +830,6 @@ done:
return ret;
/* ERRORS */
wrong_size:
{
GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
("Invalid packet size (%" G_GSIZE_FORMAT " <= 0xffff)", size), (NULL));
gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer);
return GST_FLOW_OK;
}
parse_id_failed:
{
gst_buffer_unmap (buffer, &map);