From 80172c7a3be1d8c9c24ed78c113bd4488143a5ec Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Sat, 12 Oct 2019 09:06:39 +0300 Subject: [PATCH] Allow non-realtime mode --- components/rgbd-sources/src/file_source.cpp | 10 +++++++++- components/rgbd-sources/src/file_source.hpp | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/components/rgbd-sources/src/file_source.cpp b/components/rgbd-sources/src/file_source.cpp index 33fa1ab77..bc0a5fc70 100644 --- a/components/rgbd-sources/src/file_source.cpp +++ b/components/rgbd-sources/src/file_source.cpp @@ -1,5 +1,7 @@ #include "file_source.hpp" +#include <ftl/timer.hpp> + using ftl::rgbd::detail::FileSource; using ftl::codecs::codec_t; @@ -23,6 +25,8 @@ FileSource::FileSource(ftl::rgbd::Source *s, ftl::codecs::Reader *r, int sid) : decoders_[1] = nullptr; cache_read_ = -1; cache_write_ = 0; + realtime_ = host_->value("realtime", true); + timestamp_ = r->getStartTime(); r->onPacket(sid, [this](const ftl::codecs::StreamPacket &spkt, ftl::codecs::Packet &pkt) { if (pkt.codec == codec_t::POSE) { @@ -66,7 +70,11 @@ void FileSource::_removeChannel(int channel) { } bool FileSource::capture(int64_t ts) { - timestamp_ = ts; + if (realtime_) { + timestamp_ = ts; + } else { + timestamp_ += ftl::timer::getInterval(); + } return true; } diff --git a/components/rgbd-sources/src/file_source.hpp b/components/rgbd-sources/src/file_source.hpp index 727dc3599..810b1b56c 100644 --- a/components/rgbd-sources/src/file_source.hpp +++ b/components/rgbd-sources/src/file_source.hpp @@ -41,6 +41,8 @@ class FileSource : public detail::Source { ftl::codecs::Decoder *decoders_[2]; + bool realtime_; + void _removeChannel(int channel); void _createDecoder(int ix, const ftl::codecs::Packet &pkt); }; -- GitLab