diff --git a/ChangeLog b/ChangeLog index 8ede002228..71d87c3556 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-07-19 Wim Taymans + + * gst-libs/gst/rtp/gstbasertpdepayload.c: + (gst_base_rtp_depayload_chain), + (gst_base_rtp_depayload_change_state): + Don't assert when not negotiated but post a meaningfull + error message. Fixes #347918. + + * gst-libs/gst/rtp/gstbasertppayload.c: + Add comment about better default MTU size. + + * gst-libs/gst/rtp/gstrtpbuffer.c: (gst_rtp_buffer_validate_data): + Small cleanups, start docs. + 2006-07-19 Tim-Philipp Müller Patch by: Martin Szulecki diff --git a/gst-libs/gst/rtp/gstbasertpdepayload.c b/gst-libs/gst/rtp/gstbasertpdepayload.c index 89ea92d9ad..5e94d8b844 100644 --- a/gst-libs/gst/rtp/gstbasertpdepayload.c +++ b/gst-libs/gst/rtp/gstbasertpdepayload.c @@ -205,7 +205,8 @@ gst_base_rtp_depayload_chain (GstPad * pad, GstBuffer * in) filter = GST_BASE_RTP_DEPAYLOAD (GST_OBJECT_PARENT (pad)); - g_return_val_if_fail (filter->clock_rate > 0, GST_FLOW_ERROR); + if (filter->clock_rate <= 0) + goto not_configured; bclass = GST_BASE_RTP_DEPAYLOAD_GET_CLASS (filter); @@ -217,6 +218,14 @@ gst_base_rtp_depayload_chain (GstPad * pad, GstBuffer * in) ret = bclass->add_to_queue (filter, in); } return ret; + + /* ERRORS */ +not_configured: + { + GST_ELEMENT_ERROR (filter, STREAM, FORMAT, + (NULL), ("no clock rate was specified, likely incomplete input caps")); + return GST_FLOW_NOT_NEGOTIATED; + } } static gboolean diff --git a/gst-libs/gst/rtp/gstbasertppayload.c b/gst-libs/gst/rtp/gstbasertppayload.c index 36d262d845..121b1a3be3 100644 --- a/gst-libs/gst/rtp/gstbasertppayload.c +++ b/gst-libs/gst/rtp/gstbasertppayload.c @@ -32,6 +32,12 @@ enum LAST_SIGNAL }; +/* FIXME 0.11, a better default is the Ethernet MTU of + * 1500 - sizeof(headers) as pointed out by marcelm in IRC: + * So an Ethernet MTU of 1500, minus 60 for the max IP, minus 8 for UDP, gives + * 1432 bytes or so. And that should be adjusted downward further for other + * encapsulations like PPPoE, so 1400 at most. + */ #define DEFAULT_MTU 1024 #define DEFAULT_PT 96 #define DEFAULT_SSRC -1 diff --git a/gst-libs/gst/rtp/gstrtpbuffer.c b/gst-libs/gst/rtp/gstrtpbuffer.c index f9148cdf94..0c924ec27f 100644 --- a/gst-libs/gst/rtp/gstrtpbuffer.c +++ b/gst-libs/gst/rtp/gstrtpbuffer.c @@ -1,5 +1,6 @@ /* GStreamer * Copyright (C) <2005> Philippe Khalaf + * Copyright (C) <2006> Wim Taymans * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -17,6 +18,22 @@ * Boston, MA 02111-1307, USA. */ +/** + * SECTION:gstrtpbuffer + * @short_description: Helper methods for dealing with RTP buffers + * @see_also: gstbasertppayload, gstbasertpdepayload + * + * + * + * The GstRTPBuffer helper functions makes it easy to parse and create regular + * #GstBuffer objects that contain RTP payloads. These buffers are typically of + * 'application/x-rtp' #GstCaps. + * + * + * + * Last reviewed on 2006-07-17 (0.10.10) + */ + #include "gstrtpbuffer.h" #define GST_RTP_HEADER_LEN 12 @@ -176,17 +193,13 @@ gst_rtp_buffer_validate_data (guint8 * data, guint len) g_return_val_if_fail (data != NULL, FALSE); header_len = GST_RTP_HEADER_LEN; - if (len < header_len) { - GST_DEBUG ("len < header_len check failed (%d < %d)", len, header_len); - return FALSE; - } + if (G_UNLIKELY (len < header_len)) + goto wrong_length; /* check version */ version = (data[0] & 0xc0) >> 6; - if (version != GST_RTP_VERSION) { - GST_DEBUG ("version check failed (%d != %d)", version, GST_RTP_VERSION); - return FALSE; - } + if (G_UNLIKELY (version != GST_RTP_VERSION)) + goto wrong_version; /* calc header length with csrc */ csrc_count = (data[0] & 0x0f); @@ -199,13 +212,28 @@ gst_rtp_buffer_validate_data (guint8 * data, guint len) padding = 0; /* check if padding not bigger than packet and header */ - if (len - header_len <= padding) { + if (G_UNLIKELY (len - header_len <= padding)) + goto wrong_padding; + + return TRUE; + + /* ERRORS */ +wrong_length: + { + GST_DEBUG ("len < header_len check failed (%d < %d)", len, header_len); + return FALSE; + } +wrong_version: + { + GST_DEBUG ("version check failed (%d != %d)", version, GST_RTP_VERSION); + return FALSE; + } +wrong_padding: + { GST_DEBUG ("padding check failed (%d - %d <= %d)", len, header_len, padding); return FALSE; } - - return TRUE; } gboolean