From fe901ccec7afe6870c3973f0fcad82439699260b Mon Sep 17 00:00:00 2001 From: Thijs Vermeir Date: Fri, 2 Mar 2007 12:16:16 +0000 Subject: [PATCH] gst/rtp/gstrtpmp2tdepay.*: Add support to strip off proprietary headers. Fixes #350278. Original commit message from CVS: Patch by: Thijs Vermeir * gst/rtp/gstrtpmp2tdepay.c: (gst_rtp_mp2t_depay_class_init), (gst_rtp_mp2t_depay_init), (gst_rtp_mp2t_depay_process), (gst_rtp_mp2t_depay_set_property), (gst_rtp_mp2t_depay_get_property): * gst/rtp/gstrtpmp2tdepay.h: Add support to strip off proprietary headers. Fixes #350278. --- ChangeLog | 11 +++++++++ gst/rtp/gstrtpmp2tdepay.c | 48 +++++++++++++++++++++++++++++++-------- gst/rtp/gstrtpmp2tdepay.h | 3 ++- 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 57841f59be..f01a82bf7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-03-02 Wim Taymans + + Patch by: Thijs Vermeir + + * gst/rtp/gstrtpmp2tdepay.c: (gst_rtp_mp2t_depay_class_init), + (gst_rtp_mp2t_depay_init), (gst_rtp_mp2t_depay_process), + (gst_rtp_mp2t_depay_set_property), + (gst_rtp_mp2t_depay_get_property): + * gst/rtp/gstrtpmp2tdepay.h: + Add support to strip off proprietary headers. Fixes #350278. + 2007-03-02 Wim Taymans * ext/hal/hal.c: diff --git a/gst/rtp/gstrtpmp2tdepay.c b/gst/rtp/gstrtpmp2tdepay.c index 7efe54384d..b0a82d410d 100644 --- a/gst/rtp/gstrtpmp2tdepay.c +++ b/gst/rtp/gstrtpmp2tdepay.c @@ -31,7 +31,8 @@ static const GstElementDetails gst_rtp_mp2tdepay_details = GST_ELEMENT_DETAILS ("RTP packet depayloader", "Codec/Depayloader/Network", "Extracts MPEG2 TS from RTP packets (RFC 2250)", - "Wim Taymans "); + "Wim Taymans \n" + "Thijs Vermeir "); /* RtpMP2TDepay signals and args */ enum @@ -40,10 +41,12 @@ enum LAST_SIGNAL }; +#define DEFAULT_SKIP_FIRST_BYTES 0 + enum { - ARG_0, - ARG_FREQUENCY + PROP_0, + PROP_SKIP_FIRST_BYTES }; static GstStaticPadTemplate gst_rtp_mp2t_depay_src_template = @@ -123,13 +126,24 @@ gst_rtp_mp2t_depay_class_init (GstRtpMP2TDepayClass * klass) gobject_class->set_property = gst_rtp_mp2t_depay_set_property; gobject_class->get_property = gst_rtp_mp2t_depay_get_property; + g_object_class_install_property (gobject_class, PROP_SKIP_FIRST_BYTES, + g_param_spec_uint ("skip-first-bytes", + "Skip first bytes", + "The amount of bytes that need to be skipped at the beginning of the payload", + 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + gstelement_class->change_state = gst_rtp_mp2t_depay_change_state; } static void -gst_rtp_mp2t_depay_init (GstRtpMP2TDepay * rtpmp2tdepay, +gst_rtp_mp2t_depay_init (GstRtpMP2TDepay * depayload, GstRtpMP2TDepayClass * klass) { + GstRtpMP2TDepay *rtpmp2tdepay; + + rtpmp2tdepay = GST_RTP_MP2T_DEPAY (depayload); + + rtpmp2tdepay->skip_first_bytes = DEFAULT_SKIP_FIRST_BYTES; } static gboolean @@ -159,21 +173,22 @@ gst_rtp_mp2t_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) GstRtpMP2TDepay *rtpmp2tdepay; GstBuffer *outbuf; gint payload_len; - guint8 *payload; guint32 timestamp; rtpmp2tdepay = GST_RTP_MP2T_DEPAY (depayload); - if (!gst_rtp_buffer_validate (buf)) + if (G_UNLIKELY (!gst_rtp_buffer_validate (buf))) goto bad_packet; payload_len = gst_rtp_buffer_get_payload_len (buf); - payload = gst_rtp_buffer_get_payload (buf); + + if (G_UNLIKELY (payload_len <= rtpmp2tdepay->skip_first_bytes)) + goto empty_packet; timestamp = gst_rtp_buffer_get_timestamp (buf); - outbuf = gst_buffer_new_and_alloc (payload_len); - memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len); + outbuf = + gst_rtp_buffer_get_payload_subbuffer (rtpmp2tdepay->skip_first_bytes, -1); gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad)); GST_BUFFER_TIMESTAMP (outbuf) = @@ -184,10 +199,17 @@ gst_rtp_mp2t_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) return outbuf; + /* ERRORS */ bad_packet: { GST_ELEMENT_WARNING (rtpmp2tdepay, STREAM, DECODE, - ("Packet did not validate"), (NULL)); + (NULL), ("Packet did not validate")); + return NULL; + } +empty_packet: + { + GST_ELEMENT_WARNING (rtpmp2tdepay, STREAM, DECODE, + (NULL), ("Packet was empty")); return NULL; } } @@ -201,6 +223,9 @@ gst_rtp_mp2t_depay_set_property (GObject * object, guint prop_id, rtpmp2tdepay = GST_RTP_MP2T_DEPAY (object); switch (prop_id) { + case PROP_SKIP_FIRST_BYTES: + rtpmp2tdepay->skip_first_bytes = g_value_get_uint (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -216,6 +241,9 @@ gst_rtp_mp2t_depay_get_property (GObject * object, guint prop_id, rtpmp2tdepay = GST_RTP_MP2T_DEPAY (object); switch (prop_id) { + case PROP_SKIP_FIRST_BYTES: + g_value_set_uint (value, rtpmp2tdepay->skip_first_bytes); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/gst/rtp/gstrtpmp2tdepay.h b/gst/rtp/gstrtpmp2tdepay.h index 9d9e8551aa..e3f6c53dfd 100644 --- a/gst/rtp/gstrtpmp2tdepay.h +++ b/gst/rtp/gstrtpmp2tdepay.h @@ -36,13 +36,14 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_MP2T_DEPAY)) #define GST_IS_RTP_MP2T_DEPAY_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_MP2T_DEPAY)) - typedef struct _GstRtpMP2TDepay GstRtpMP2TDepay; typedef struct _GstRtpMP2TDepayClass GstRtpMP2TDepayClass; struct _GstRtpMP2TDepay { GstBaseRTPDepayload depayload; + + guint8 skip_first_bytes; }; struct _GstRtpMP2TDepayClass