[gst-cvs] gst-plugins-good: rtpsession: avoid buffer ref/unref pairs for CSRCs
Wim Taymans
wtay at kemper.freedesktop.org
Mon Nov 30 07:04:16 PST 2009
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);
More information about the Gstreamer-commits
mailing list