From a34d2e547b159cf0148356b58c152a845ddba506 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 14 Mar 2016 19:17:03 +0200 Subject: [PATCH] rtp: Properly timestamp buffers in the GStreamer sender pipeline Otherwise default timestamping will happen, which might not be correct, especially not after the stream was suspended for a while. --- src/modules/rtp/rtp-gstreamer.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/modules/rtp/rtp-gstreamer.c b/src/modules/rtp/rtp-gstreamer.c index fa66363..52ebd41 100644 --- a/src/modules/rtp/rtp-gstreamer.c +++ b/src/modules/rtp/rtp-gstreamer.c @@ -233,6 +233,19 @@ int pa_rtp_send(pa_rtp_context *c, pa_memblockq *q) { return -1; while (!stop && pa_memblockq_peek(q, &chunk) == 0) { + GstClock *clock; + GstClockTime timestamp, clock_time; + + clock = gst_element_get_clock(c->pipeline); + clock_time = gst_clock_get_time(clock); + gst_object_unref(clock); + + timestamp = gst_element_get_base_time(c->pipeline); + if (timestamp > clock_time) + timestamp -= clock_time; + else + timestamp = 0; + pa_assert(chunk.memblock); data = pa_memblock_acquire(chunk.memblock); @@ -241,6 +254,8 @@ int pa_rtp_send(pa_rtp_context *c, pa_memblockq *q) { data, chunk.length, chunk.index, chunk.length, chunk.memblock, (GDestroyNotify) free_buffer); + GST_BUFFER_PTS(buf) = timestamp; + if (gst_app_src_push_buffer(GST_APP_SRC(c->appsrc), buf) != GST_FLOW_OK) { pa_log_error("Could not push buffer"); stop = true; -- 2.7.4