summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThijs Vermeir <thijsvermeir@gmail.com>2010-10-12 15:02:42 +0200
committerThijs Vermeir <thijsvermeir@gmail.com>2010-10-12 15:17:02 +0200
commitbcde8c1b297540c1297c70b06b3eea878b93a4e9 (patch)
treee4dfde810eea4897d883bf21209e4d03be05f012
parent96fb89f86c591ba76d552cb2ce67749157d19bd7 (diff)
rtpmpvpay: fix timestamping of rtp buffers
Incomming buffer is only pushed on the adapter at the end of the handle_buffer function. But duration/timestamp of this buffer is already taken into account for the current data in the adapter. This leads to wrong rtp timestamps and extra latency.
-rw-r--r--gst/rtp/gstrtpmpvpay.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/gst/rtp/gstrtpmpvpay.c b/gst/rtp/gstrtpmpvpay.c
index 50bff2793..6523dbbed 100644
--- a/gst/rtp/gstrtpmpvpay.c
+++ b/gst/rtp/gstrtpmpvpay.c
@@ -27,6 +27,9 @@
#include "gstrtpmpvpay.h"
+GST_DEBUG_CATEGORY_STATIC (rtpmpvpay_debug);
+#define GST_CAT_DEFAULT (rtpmpvpay_debug)
+
static GstStaticPadTemplate gst_rtp_mpv_pay_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
@@ -83,6 +86,9 @@ gst_rtp_mpv_pay_class_init (GstRTPMPVPayClass * klass)
gstbasertppayload_class->set_caps = gst_rtp_mpv_pay_setcaps;
gstbasertppayload_class->handle_buffer = gst_rtp_mpv_pay_handle_buffer;
+
+ GST_DEBUG_CATEGORY_INIT (rtpmpvpay_debug, "rtpmpvpay", 0,
+ "MPEG2 ES Video RTP Payloader");
}
static void
@@ -190,27 +196,31 @@ gst_rtp_mpv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
if (duration == -1)
duration = 0;
- /* Initialize new RTP payload */
- if (avail == 0) {
+ if (rtpmpvpay->first_ts == GST_CLOCK_TIME_NONE || avail == 0)
rtpmpvpay->first_ts = timestamp;
+
+ if (avail == 0) {
rtpmpvpay->duration = duration;
+ } else {
+ rtpmpvpay->duration += duration;
}
+ gst_adapter_push (rtpmpvpay->adapter, buffer);
+ avail = gst_adapter_available (rtpmpvpay->adapter);
+
/* get packet length of previous data and this new data,
* payload length includes a 4 byte MPEG video-specific header */
packet_len = gst_rtp_buffer_calc_packet_len (avail, 4, 0);
+ GST_LOG_OBJECT (rtpmpvpay, "available %d, rtp packet length %d", avail,
+ packet_len);
if (gst_basertppayload_is_filled (basepayload,
- packet_len, rtpmpvpay->duration + duration)) {
+ packet_len, rtpmpvpay->duration)) {
ret = gst_rtp_mpv_pay_flush (rtpmpvpay);
+ } else {
rtpmpvpay->first_ts = timestamp;
- rtpmpvpay->duration = 0;
}
- gst_adapter_push (rtpmpvpay->adapter, buffer);
-
- rtpmpvpay->duration += duration;
-
return ret;
}