From b069db6a2e58e4db24855deb7c40525c7f63d63b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 25 Jul 2013 17:35:02 +0200 Subject: [PATCH] session: parse packet outside of the session lock --- gst/rtpmanager/rtpsession.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index 0d0c3bc..bc0843b 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -1654,6 +1654,19 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer, if (!gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp)) goto invalid_packet; + /* get SSRC to look up in session database */ + ssrc = gst_rtp_buffer_get_ssrc (&rtp); + /* copy available csrc for later */ + count = gst_rtp_buffer_get_csrc_count (&rtp); + /* make sure to not overflow our array. An RTP buffer can maximally contain + * 16 CSRCs */ + count = MIN (count, 16); + + for (i = 0; i < count; i++) + csrcs[i] = gst_rtp_buffer_get_csrc (&rtp, i); + + gst_rtp_buffer_unmap (&rtp); + RTP_SESSION_LOCK (sess); /* ignore more RTP packets when we left the session */ if (sess->source->marked_bye) @@ -1663,23 +1676,10 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer, update_arrival_stats (sess, &arrival, TRUE, buffer, current_time, running_time, -1); - /* get SSRC and look up in session database */ - ssrc = gst_rtp_buffer_get_ssrc (&rtp); source = obtain_source (sess, ssrc, &created, &arrival, TRUE); if (!source) goto collision; - /* copy available csrc for later */ - count = gst_rtp_buffer_get_csrc_count (&rtp); - /* make sure to not overflow our array. An RTP buffer can maximally contain - * 16 CSRCs */ - count = MIN (count, 16); - - for (i = 0; i < count; i++) - csrcs[i] = gst_rtp_buffer_get_csrc (&rtp, i); - - gst_rtp_buffer_unmap (&rtp); - prevsender = RTP_SOURCE_IS_SENDER (source); prevactive = RTP_SOURCE_IS_ACTIVE (source); oldrate = source->bitrate; @@ -1748,7 +1748,6 @@ invalid_packet: ignore: { RTP_SESSION_UNLOCK (sess); - gst_rtp_buffer_unmap (&rtp); gst_buffer_unref (buffer); GST_DEBUG ("ignoring RTP packet because we are leaving"); return GST_FLOW_OK; @@ -1756,7 +1755,6 @@ ignore: 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"); -- 2.7.4