From 51371d26eeb8e3c1983f56bda11fa84ff9c3dbab Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 17 Jul 2012 16:38:27 +0200 Subject: [PATCH] update for RTP buffer api changes --- gst/isomp4/gstrtpxqtdepay.c | 9 ------- gst/rtp/gstasteriskh263.c | 6 ++--- gst/rtpmanager/gstrtpjitterbuffer.c | 9 +++---- gst/rtpmanager/gstrtpptdemux.c | 3 +-- gst/rtpmanager/gstrtpssrcdemux.c | 3 +-- gst/rtpmanager/rtpsession.c | 41 ++++++----------------------- gst/rtsp/gstrtpdec.c | 4 +-- 7 files changed, 17 insertions(+), 58 deletions(-) diff --git a/gst/isomp4/gstrtpxqtdepay.c b/gst/isomp4/gstrtpxqtdepay.c index 61567d7217..3803340ec7 100644 --- a/gst/isomp4/gstrtpxqtdepay.c +++ b/gst/isomp4/gstrtpxqtdepay.c @@ -257,9 +257,6 @@ gst_rtp_xqt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf) gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp); - if (!gst_rtp_buffer_validate (buf)) - goto bad_packet; - if (GST_BUFFER_IS_DISCONT (buf)) { /* discont, clear adapter and try to find a new packet start */ gst_adapter_clear (rtpxqtdepay->adapter); @@ -624,12 +621,6 @@ done: gst_rtp_buffer_unmap (&rtp); return outbuf; -bad_packet: - { - GST_ELEMENT_WARNING (rtpxqtdepay, STREAM, DECODE, - ("Packet did not validate."), (NULL)); - goto done; - } need_resync: { GST_DEBUG_OBJECT (rtpxqtdepay, "waiting for marker"); diff --git a/gst/rtp/gstasteriskh263.c b/gst/rtp/gstasteriskh263.c index ae7d05a630..85e91661e4 100644 --- a/gst/rtp/gstasteriskh263.c +++ b/gst/rtp/gstasteriskh263.c @@ -127,9 +127,6 @@ gst_asteriskh263_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) asteriskh263 = GST_ASTERISK_H263 (parent); - if (!gst_rtp_buffer_validate (buf)) - goto bad_packet; - { gint payload_len; guint8 *payload; @@ -140,7 +137,8 @@ gst_asteriskh263_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) GstRTPBuffer rtp = { NULL }; GstMapInfo map; - gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp); + if (!gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp)) + goto bad_packet; payload_len = gst_rtp_buffer_get_payload_len (&rtp); payload = gst_rtp_buffer_get_payload (&rtp); diff --git a/gst/rtpmanager/gstrtpjitterbuffer.c b/gst/rtpmanager/gstrtpjitterbuffer.c index 93a76cf484..06622c9d41 100644 --- a/gst/rtpmanager/gstrtpjitterbuffer.c +++ b/gst/rtpmanager/gstrtpjitterbuffer.c @@ -1255,12 +1255,11 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent, jitterbuffer = GST_RTP_JITTER_BUFFER (parent); - if (G_UNLIKELY (!gst_rtp_buffer_validate (buffer))) - goto invalid_buffer; - priv = jitterbuffer->priv; - gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp); + if (G_UNLIKELY (!gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp))) + goto invalid_buffer; + pt = gst_rtp_buffer_get_payload_type (&rtp); seqnum = gst_rtp_buffer_get_seq (&rtp); gst_rtp_buffer_unmap (&rtp); @@ -1529,7 +1528,7 @@ compute_elapsed (GstRtpJitterBuffer * jitterbuffer, GstBuffer * outbuf) guint64 ext_time, elapsed; guint32 rtp_time; GstRtpJitterBufferPrivate *priv; - GstRTPBuffer rtp = { NULL, }; + GstRTPBuffer rtp = GST_RTP_BUFFER_INIT; priv = jitterbuffer->priv; gst_rtp_buffer_map (outbuf, GST_MAP_READ, &rtp); diff --git a/gst/rtpmanager/gstrtpptdemux.c b/gst/rtpmanager/gstrtpptdemux.c index 634834d412..9a2ee1b9b2 100644 --- a/gst/rtpmanager/gstrtpptdemux.c +++ b/gst/rtpmanager/gstrtpptdemux.c @@ -354,10 +354,9 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) rtpdemux = GST_RTP_PT_DEMUX (parent); - if (!gst_rtp_buffer_validate (buf)) + if (!gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp)) goto invalid_buffer; - gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp); pt = gst_rtp_buffer_get_payload_type (&rtp); gst_rtp_buffer_unmap (&rtp); diff --git a/gst/rtpmanager/gstrtpssrcdemux.c b/gst/rtpmanager/gstrtpssrcdemux.c index 0ddd27b522..bded99cfac 100644 --- a/gst/rtpmanager/gstrtpssrcdemux.c +++ b/gst/rtpmanager/gstrtpssrcdemux.c @@ -580,10 +580,9 @@ gst_rtp_ssrc_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) demux = GST_RTP_SSRC_DEMUX (parent); - if (!gst_rtp_buffer_validate (buf)) + if (!gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp)) goto invalid_payload; - gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp); ssrc = gst_rtp_buffer_get_ssrc (&rtp); gst_rtp_buffer_unmap (&rtp); diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index bb39c0801b..fa55c1691f 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -1711,26 +1711,23 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer, g_return_val_if_fail (RTP_IS_SESSION (sess), GST_FLOW_ERROR); g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR); - if (!gst_rtp_buffer_validate (buffer)) + if (!gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp)) goto invalid_packet; RTP_SESSION_LOCK (sess); - /* update arrival stats */ - update_arrival_stats (sess, &arrival, TRUE, buffer, current_time, - running_time, -1); - /* ignore more RTP packets when we left the session */ if (sess->source->received_bye) goto ignore; + /* update arrival stats */ + update_arrival_stats (sess, &arrival, TRUE, buffer, current_time, + running_time, -1); + /* get SSRC and look up in session database */ - gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp); ssrc = gst_rtp_buffer_get_ssrc (&rtp); source = obtain_source (sess, ssrc, &created, &arrival, TRUE); - if (!source) { - gst_rtp_buffer_unmap (&rtp); + if (!source) goto collision; - } /* copy available csrc for later */ count = gst_rtp_buffer_get_csrc_count (&rtp); @@ -1811,14 +1808,15 @@ invalid_packet: ignore: { RTP_SESSION_UNLOCK (sess); + gst_rtp_buffer_unmap (&rtp); gst_buffer_unref (buffer); - clean_arrival_stats (&arrival); GST_DEBUG ("ignoring RTP packet because we are leaving"); return GST_FLOW_OK; } collision: { RTP_SESSION_UNLOCK (sess); + gst_rtp_buffer_unmap (&rtp); gst_buffer_unref (buffer); clean_arrival_stats (&arrival); GST_DEBUG ("ignoring packet because its collisioning"); @@ -2454,26 +2452,11 @@ rtp_session_send_rtp (RTPSession * sess, gpointer data, gboolean is_list, GstFlowReturn result; RTPSource *source; gboolean prevsender; - gboolean valid_packet; guint64 oldrate; g_return_val_if_fail (RTP_IS_SESSION (sess), GST_FLOW_ERROR); g_return_val_if_fail (is_list || GST_IS_BUFFER (data), GST_FLOW_ERROR); - if (is_list) { - GstBufferList *blist = GST_BUFFER_LIST_CAST (data); - gint i, len = gst_buffer_list_length (blist); - - valid_packet = TRUE; - for (i = 0; i < len; i++) - valid_packet &= gst_rtp_buffer_validate (gst_buffer_list_get (blist, i)); - } else { - valid_packet = gst_rtp_buffer_validate (GST_BUFFER_CAST (data)); - } - - if (!valid_packet) - goto invalid_packet; - GST_LOG ("received RTP %s for sending", is_list ? "list" : "packet"); RTP_SESSION_LOCK (sess); @@ -2495,14 +2478,6 @@ rtp_session_send_rtp (RTPSession * sess, gpointer data, gboolean is_list, RTP_SESSION_UNLOCK (sess); return result; - - /* ERRORS */ -invalid_packet: - { - gst_mini_object_unref (GST_MINI_OBJECT_CAST (data)); - GST_DEBUG ("invalid RTP packet received"); - return GST_FLOW_OK; - } } static void diff --git a/gst/rtsp/gstrtpdec.c b/gst/rtsp/gstrtpdec.c index 70f0372478..a639b8c703 100644 --- a/gst/rtsp/gstrtpdec.c +++ b/gst/rtsp/gstrtpdec.c @@ -469,11 +469,9 @@ gst_rtp_dec_chain_rtp (GstPad * pad, GstObject * parent, GstBuffer * buffer) GST_DEBUG_OBJECT (rtpdec, "got rtp packet"); - if (!gst_rtp_buffer_validate (buffer)) + if (!gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp)) goto bad_packet; - - gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp); ssrc = gst_rtp_buffer_get_ssrc (&rtp); pt = gst_rtp_buffer_get_payload_type (&rtp); gst_rtp_buffer_unmap (&rtp);