From 1906a8d89615c5febfe15c9bc725468fc5a55cf2 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Fri, 10 Jul 2020 16:18:44 +0300 Subject: [PATCH] WIP Allow render all framesets by default --- components/net/cpp/include/ftl/net/peer.hpp | 2 ++ components/streams/include/ftl/streams/renderer.hpp | 1 + components/streams/src/feed.cpp | 2 +- components/streams/src/renderer.cpp | 12 +++++++++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/components/net/cpp/include/ftl/net/peer.hpp b/components/net/cpp/include/ftl/net/peer.hpp index 6ac41b2f7..91f3f2f06 100644 --- a/components/net/cpp/include/ftl/net/peer.hpp +++ b/components/net/cpp/include/ftl/net/peer.hpp @@ -193,6 +193,8 @@ class Peer { bool isWaiting() const { return is_waiting_; } void rawClose() { _badClose(false); } + + inline void noReconnect() { can_reconnect_ = false; } public: static const int kMaxMessage = 10*1024*1024; // 10Mb currently diff --git a/components/streams/include/ftl/streams/renderer.hpp b/components/streams/include/ftl/streams/renderer.hpp index bb19a042d..441e65fe6 100644 --- a/components/streams/include/ftl/streams/renderer.hpp +++ b/components/streams/include/ftl/streams/renderer.hpp @@ -28,6 +28,7 @@ class Source : public ftl::Configurable, public ftl::data::DiscreteSource { ftl::data::FrameSetPtr input_; std::unique_ptr<ftl::render::CUDARender> renderer_; ftl::Configurable *intrinsics_; + uint32_t my_id_; }; } diff --git a/components/streams/src/feed.cpp b/components/streams/src/feed.cpp index b11a56a67..1b080f0e6 100644 --- a/components/streams/src/feed.cpp +++ b/components/streams/src/feed.cpp @@ -358,7 +358,7 @@ void Feed::autoConnect() { auto &known_hosts = getConfig()["known_hosts"]; for (auto &h : known_hosts.items()) { - net_->connect(h.key()); + net_->connect(h.key())->noReconnect(); } }); } diff --git a/components/streams/src/renderer.cpp b/components/streams/src/renderer.cpp index a9f80db5e..48de45b31 100644 --- a/components/streams/src/renderer.cpp +++ b/components/streams/src/renderer.cpp @@ -10,7 +10,7 @@ using ftl::rgbd::Capability; Source::Source(nlohmann::json &config, ftl::stream::Feed *feed) -: ftl::Configurable(config), feed_(feed) { +: ftl::Configurable(config), feed_(feed), my_id_(0) { restore("device:render", { "renderer", "source", @@ -33,6 +33,14 @@ Source::Source(nlohmann::json &config, ftl::stream::Feed *feed) std::atomic_store(&input_, fs); return true; }); + } else { + filter_ = feed_->filter({Channel::Colour, Channel::Depth}); + + filter_->on([this](const ftl::data::FrameSetPtr &fs) { + if (fs->frameset() == my_id_) return true; // Never render self + std::atomic_store(&input_, fs); + return true; + }); } on("source", [this](const ftl::config::Event &e) { @@ -62,6 +70,8 @@ bool Source::capture(int64_t ts) { bool Source::retrieve(ftl::data::Frame &frame_out) { auto input = std::atomic_load(&input_); + my_id_ = frame_out.frameset(); + if (input) { ftl::rgbd::Frame &rgbdframe = frame_out.cast<ftl::rgbd::Frame>(); -- GitLab