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.
This commit is contained in:
Sebastian Dröge 2016-03-14 19:17:03 +02:00 committed by Arun Raghavan
parent 72dbbcbc65
commit a34d2e547b

View file

@ -233,6 +233,19 @@ int pa_rtp_send(pa_rtp_context *c, pa_memblockq *q) {
return -1; return -1;
while (!stop && pa_memblockq_peek(q, &chunk) == 0) { 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); pa_assert(chunk.memblock);
data = pa_memblock_acquire(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, data, chunk.length, chunk.index, chunk.length, chunk.memblock,
(GDestroyNotify) free_buffer); (GDestroyNotify) free_buffer);
GST_BUFFER_PTS(buf) = timestamp;
if (gst_app_src_push_buffer(GST_APP_SRC(c->appsrc), buf) != GST_FLOW_OK) { if (gst_app_src_push_buffer(GST_APP_SRC(c->appsrc), buf) != GST_FLOW_OK) {
pa_log_error("Could not push buffer"); pa_log_error("Could not push buffer");
stop = true; stop = true;