[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gstreamer-cvs
Subject:    [gst-cvs] gst-plugins-good: rtpsession: avoid buffer ref/unref
From:       wtay () kemper ! freedesktop ! org (Wim Taymans)
Date:       2009-11-30 15:04:16
Message-ID: 20091130150417.065EF10051 () kemper ! freedesktop ! org
[Download RAW message or body]

Module: gst-plugins-good
Branch: master
Commit: 07f27f0efd5a866721fd83c6873e7eacc989c0fe
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=07f27f0efd5a866721fd83c6873e7eacc989c0fe


Author: Aurelien Grimaud <gstelzz at yahoo dot fr>
Date:   Mon Nov 30 15:59:50 2009 +0100

rtpsession: avoid buffer ref/unref pairs for CSRCs

We ref the buffer before pushing it downstream in order to get the CSRCs of it
after pushing. This causes performance problems when downstream elements want to
change the metadata because the buffer needs to be subbuffered.

Instead, read and store the CSRCs of the buffer in an array before pushing it
and process the array after pushing the buffer. This allows us to remove the
ref/unref pair.

Fixes #603376

---

 gst/rtpmanager/rtpsession.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c
index 7f39155..e3eae0f 100644
--- a/gst/rtpmanager/rtpsession.c
+++ b/gst/rtpmanager/rtpsession.c
@@ -1432,6 +1432,8 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
   gboolean created;
   gboolean prevsender, prevactive;
   RTPArrivalStats arrival;
+  guint32 csrcs[16];
+  guint8 i, count;
 
   g_return_val_if_fail (RTP_IS_SESSION (sess), GST_FLOW_ERROR);
   g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
@@ -1457,8 +1459,14 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * \
buffer,  prevsender = RTP_SOURCE_IS_SENDER (source);
   prevactive = RTP_SOURCE_IS_ACTIVE (source);
 
-  /* we need to ref so that we can process the CSRCs later */
-  gst_buffer_ref (buffer);
+  /* copy available csrc for later */
+  count = gst_rtp_buffer_get_csrc_count (buffer);
+  /* 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 (buffer, i);
 
   /* let source process the packet */
   result = rtp_source_process_rtp (source, buffer, &arrival);
@@ -1480,17 +1488,14 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * \
buffer,  on_new_ssrc (sess, source);
 
   if (source->validated) {
-    guint8 i, count;
     gboolean created;
 
     /* for validated sources, we add the CSRCs as well */
-    count = gst_rtp_buffer_get_csrc_count (buffer);
-
     for (i = 0; i < count; i++) {
       guint32 csrc;
       RTPSource *csrc_src;
 
-      csrc = gst_rtp_buffer_get_csrc (buffer, i);
+      csrc = csrcs[i];
 
       /* get source */
       csrc_src = obtain_source (sess, csrc, &created, &arrival, TRUE);
@@ -1508,7 +1513,6 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
     }
   }
   g_object_unref (source);
-  gst_buffer_unref (buffer);
 
   RTP_SESSION_UNLOCK (sess);
 


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
gstreamer-cvs mailing list
gstreamer-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic