From c6c7693550f9fca06ababbbe037266098faf6940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 2 Dec 2017 12:15:07 +0200 Subject: [PATCH] Add Buffer::get_dts_or_pts() --- gstreamer/src/buffer.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gstreamer/src/buffer.rs b/gstreamer/src/buffer.rs index 5b3a607d9..97c10e304 100644 --- a/gstreamer/src/buffer.rs +++ b/gstreamer/src/buffer.rs @@ -332,6 +332,15 @@ impl BufferRef { self.0.dts = dts.to_glib(); } + pub fn get_dts_or_pts(&self) -> ClockTime { + let val = self.get_dts(); + if val.is_none() { + self.get_pts() + } else { + val + } + } + pub fn get_duration(&self) -> ClockTime { from_glib(self.0.duration) }