summaryrefslogtreecommitdiff
path: root/ext/webrtcdsp
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2016-06-22 22:28:03 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2016-06-23 08:04:18 -0400
commitc551a853b323a6148d26aae3b22081df92d8e281 (patch)
tree3bdd2a23debea5d12d1b5eddbe80725e21d56f75 /ext/webrtcdsp
parent86aa3b5f9c7016e749e4f389adc6c5a29108b6f3 (diff)
webrtcdsp: Offset timestamp with duration
The saved timestamp is used to compute the delay of the probe data. As it's used at the following incoming buffer, it needs to be offset with the duration of the buffer to represent the end position. Also, properly initialize the saved timestamp and protect against TIME_NONE.
Diffstat (limited to 'ext/webrtcdsp')
-rw-r--r--ext/webrtcdsp/gstwebrtcdsp.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/webrtcdsp/gstwebrtcdsp.cpp b/ext/webrtcdsp/gstwebrtcdsp.cpp
index 6b6239da4..2f87f589a 100644
--- a/ext/webrtcdsp/gstwebrtcdsp.cpp
+++ b/ext/webrtcdsp/gstwebrtcdsp.cpp
@@ -256,6 +256,10 @@ gst_webrtc_dsp_sync_reverse_stream (GstWebrtcDsp * self,
GstClockTimeDiff diff;
guint64 distance;
+ /* We need to wait for a time reference */
+ if (!GST_CLOCK_TIME_IS_VALID (self->timestamp))
+ return FALSE;
+
probe_timestamp = gst_adapter_prev_pts (probe->adapter, &distance);
if (!GST_CLOCK_TIME_IS_VALID (probe_timestamp)) {
@@ -359,8 +363,10 @@ gst_webrtc_dsp_process_stream (GstWebrtcDsp * self)
frame.samples_per_channel_ = self->period_size / self->info.bpf;
timestamp = gst_adapter_prev_pts (self->adapter, &distance);
- timestamp += gst_util_uint64_scale_int (distance / self->info.bpf,
- GST_SECOND, self->info.rate);
+
+ if (GST_CLOCK_TIME_IS_VALID (timestamp))
+ timestamp += gst_util_uint64_scale_int (distance / self->info.bpf,
+ GST_SECOND, self->info.rate);
buffer = gst_adapter_take_buffer (self->adapter, self->period_size);
@@ -390,7 +396,8 @@ gst_webrtc_dsp_process_stream (GstWebrtcDsp * self)
else
GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DISCONT);
- self->timestamp = timestamp;
+ if (GST_CLOCK_TIME_IS_VALID (timestamp))
+ self->timestamp = timestamp + GST_BUFFER_DURATION (buffer);
return buffer;
}
@@ -488,6 +495,7 @@ gst_webrtc_dsp_setup (GstAudioFilter * filter, const GstAudioInfo * info)
GST_OBJECT_LOCK (self);
gst_adapter_clear (self->adapter);
+ self->timestamp = GST_CLOCK_TIME_NONE;
self->delay_ms = 0;
self->info = *info;
apm = self->apm;