From: Parichay Kapoor Date: Tue, 12 Mar 2019 07:56:10 +0000 (+0900) Subject: [IIO] added _get_times X-Git-Tag: v0.1.2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=88ffe9f730a297b4fa4e6686bee0b4466c84a048;p=platform%2Fupstream%2Fnnstreamer.git [IIO] added _get_times Added _get_times to support syncing of buffer for the live source Signed-off-by: Parichay Kapoor --- diff --git a/gst/nnstreamer/tensor_source/tensor_src_iio.c b/gst/nnstreamer/tensor_source/tensor_src_iio.c index 1db43b6..5d70b1f 100644 --- a/gst/nnstreamer/tensor_source/tensor_src_iio.c +++ b/gst/nnstreamer/tensor_source/tensor_src_iio.c @@ -188,6 +188,8 @@ static GstFlowReturn gst_tensor_src_iio_create (GstBaseSrc * src, guint64 offset, guint size, GstBuffer ** buf); static GstFlowReturn gst_tensor_src_iio_fill (GstBaseSrc * src, guint64 offset, guint size, GstBuffer * buf); +static void gst_tensor_src_iio_get_times (GstBaseSrc * basesrc, + GstBuffer * buffer, GstClockTime * start, GstClockTime * end); /** internal functions */ @@ -271,6 +273,7 @@ gst_tensor_src_iio_class_init (GstTensorSrcIIOClass * klass) bsrc_class->is_seekable = GST_DEBUG_FUNCPTR (gst_tensor_src_iio_is_seekable); bsrc_class->create = GST_DEBUG_FUNCPTR (gst_tensor_src_iio_create); bsrc_class->fill = GST_DEBUG_FUNCPTR (gst_tensor_src_iio_fill); + bsrc_class->get_times = GST_DEBUG_FUNCPTR (gst_tensor_src_iio_get_times); } /** @@ -1137,6 +1140,31 @@ gst_tensor_src_iio_is_seekable (GstBaseSrc * src) } /** + * @brief returns the time for the buffers + */ +static void +gst_tensor_src_iio_get_times (GstBaseSrc * basesrc, GstBuffer * buffer, + GstClockTime * start, GstClockTime * end) +{ + GstClockTime timestamp; + GstClockTime duration; + + timestamp = GST_BUFFER_DTS (buffer); + duration = GST_BUFFER_DURATION (buffer); + + /** can't sync using DTS, use PTS */ + if (!GST_CLOCK_TIME_IS_VALID (timestamp)) + timestamp = GST_BUFFER_PTS (buffer); + + if (GST_CLOCK_TIME_IS_VALID (timestamp)) { + *start = timestamp; + if (GST_CLOCK_TIME_IS_VALID (duration)) { + *end = timestamp + duration; + } + } +} + +/** * @brief create a buffer with requested size and offset */ static GstFlowReturn