summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2014-06-25 14:34:21 +0200
committerWim Taymans <wtaymans@redhat.com>2014-06-25 16:14:46 +0200
commitca9cfd40dd63e44d7fec8ac2735457dd92949d02 (patch)
tree034159d7130d494d5fa1775bbf12d87a9dce6f6f
parentf7aeb57858aa20757076aa2680cf1f780bf047ef (diff)
jitterbuffer: improve SR packet handling
Implement 3 different cases for handling the SR: 1) we don't have enough timing information to handle the SR packet and we need to wait a little for more RTP packets. In that case we keep the SR packet around and retry when we get an RTP packet in the chain function. 2) the SR packet has a too old timestamp and should be discarded. It is labeled invalid and the last_sr is cleared. 3) the SR packet is ok and there is enough timing information, proceed with processing the SR packet. Before this patch, case 2) and 1) were handled in the same way, resulting that SR packets with too old timestamps were checked over and over again for each RTP packet.
-rw-r--r--gst/rtpmanager/gstrtpjitterbuffer.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/gst/rtpmanager/gstrtpjitterbuffer.c b/gst/rtpmanager/gstrtpjitterbuffer.c
index 9e454928d7..c8c512e1cc 100644
--- a/gst/rtpmanager/gstrtpjitterbuffer.c
+++ b/gst/rtpmanager/gstrtpjitterbuffer.c
@@ -3063,7 +3063,7 @@ do_handle_sync (GstRtpJitterBuffer * jitterbuffer)
guint64 last_rtptime;
guint64 clock_base;
guint64 ext_rtptime, diff;
- gboolean drop = FALSE;
+ gboolean valid = TRUE, keep = FALSE;
priv = jitterbuffer->priv;
@@ -3080,13 +3080,15 @@ do_handle_sync (GstRtpJitterBuffer * jitterbuffer)
ext_rtptime, base_rtptime, clock_rate, clock_base, last_rtptime);
if (base_rtptime == -1 || clock_rate == -1 || base_time == -1) {
- GST_DEBUG_OBJECT (jitterbuffer, "dropping, no RTP values");
- drop = TRUE;
+ /* we keep this SR packet for later. When we get a valid RTP packet the
+ * above values will be set and we can try to use the SR packet */
+ GST_DEBUG_OBJECT (jitterbuffer, "keeping for later, no RTP values");
+ keep = TRUE;
} else {
/* we can't accept anything that happened before we did the last resync */
if (base_rtptime > ext_rtptime) {
GST_DEBUG_OBJECT (jitterbuffer, "dropping, older than base time");
- drop = TRUE;
+ valid = FALSE;
} else {
/* the SR RTP timestamp must be something close to what we last observed
* in the jitterbuffer */
@@ -3108,7 +3110,9 @@ do_handle_sync (GstRtpJitterBuffer * jitterbuffer)
}
}
- if (!drop) {
+ if (keep) {
+ GST_DEBUG_OBJECT (jitterbuffer, "keeping RTCP packet for later");
+ } else if (valid) {
GstStructure *s;
s = gst_structure_new ("application/x-rtp-sync",
@@ -3128,6 +3132,7 @@ do_handle_sync (GstRtpJitterBuffer * jitterbuffer)
gst_structure_free (s);
} else {
GST_DEBUG_OBJECT (jitterbuffer, "dropping RTCP packet");
+ gst_buffer_replace (&priv->last_sr, NULL);
}
}