From 247fa4a9ef04f0fc0cfc42a4b500267769885d1e Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Mon, 19 Aug 2019 10:21:18 +0300 Subject: [PATCH] Set FPS centrally --- components/common/cpp/include/ftl/timer.hpp | 2 ++ components/common/cpp/src/configuration.cpp | 4 ++++ components/common/cpp/src/timer.cpp | 4 ++++ components/common/cpp/test/configurable_unit.cpp | 6 ++++++ components/net/cpp/src/peer.cpp | 4 ++-- components/rgbd-sources/src/group.cpp | 5 ++++- components/rgbd-sources/src/streamer.cpp | 4 ++-- 7 files changed, 24 insertions(+), 5 deletions(-) diff --git a/components/common/cpp/include/ftl/timer.hpp b/components/common/cpp/include/ftl/timer.hpp index 045f29375..6af48cd1c 100644 --- a/components/common/cpp/include/ftl/timer.hpp +++ b/components/common/cpp/include/ftl/timer.hpp @@ -60,6 +60,8 @@ struct TimerHandle { */ void setInterval(int ms); +int getInterval(); + /** * Add the specified number of milliseconds to the clock when generating * timestamps. This is used to synchronise clocks on multiple machines as it diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp index 3343832ac..06cf11c85 100644 --- a/components/common/cpp/src/configuration.cpp +++ b/components/common/cpp/src/configuration.cpp @@ -19,6 +19,7 @@ #include <ftl/configurable.hpp> #include <ftl/uri.hpp> #include <ftl/threads.hpp> +#include <ftl/timer.hpp> #include <fstream> #include <string> @@ -515,6 +516,9 @@ Configurable *ftl::config::configure(int argc, char **argv, const std::string &r } }); + // Some global settings + ftl::timer::setInterval(rootcfg->value("fps",20)); + //LOG(INFO) << "CONFIG: " << config["vision_default"]; //CHECK_EQ( &config, config_index["ftl://utu.fi"] ); diff --git a/components/common/cpp/src/timer.cpp b/components/common/cpp/src/timer.cpp index eb6ea8024..5f96f9045 100644 --- a/components/common/cpp/src/timer.cpp +++ b/components/common/cpp/src/timer.cpp @@ -77,6 +77,10 @@ void ftl::timer::setInterval(int ms) { mspf = ms; } +int ftl::timer::getInterval() { + return mspf; +} + void ftl::timer::setClockAdjustment(int64_t ms) { clock_adjust = ms; } diff --git a/components/common/cpp/test/configurable_unit.cpp b/components/common/cpp/test/configurable_unit.cpp index 428208f74..af44e026a 100644 --- a/components/common/cpp/test/configurable_unit.cpp +++ b/components/common/cpp/test/configurable_unit.cpp @@ -6,6 +6,12 @@ using ftl::Configurable; using std::string; +namespace ftl { +namespace timer { +void setInterval(int i) {} +} +} + SCENARIO( "Configurable::get()" ) { GIVEN( "a non-existent property" ) { // cppcheck-suppress constStatement diff --git a/components/net/cpp/src/peer.cpp b/components/net/cpp/src/peer.cpp index 6a864ac93..6738470fe 100644 --- a/components/net/cpp/src/peer.cpp +++ b/components/net/cpp/src/peer.cpp @@ -438,7 +438,7 @@ void Peer::data() { auto buf = recv_buf_.buffer(); lk.unlock(); - #ifndef WIN32 + /*#ifndef WIN32 int n; unsigned int m = sizeof(n); getsockopt(sock_,SOL_SOCKET,SO_RCVBUF,(void *)&n, &m); @@ -446,7 +446,7 @@ void Peer::data() { int pending; ioctl(sock_, SIOCINQ, &pending); if (pending > 100000) LOG(INFO) << "Buffer usage: " << float(pending) / float(n); - #endif + #endif*/ rc = ftl::net::internal::recv(sock_, buf, cap, 0); if (rc >= cap-1) { diff --git a/components/rgbd-sources/src/group.cpp b/components/rgbd-sources/src/group.cpp index 3b3d9afff..29c4ef38d 100644 --- a/components/rgbd-sources/src/group.cpp +++ b/components/rgbd-sources/src/group.cpp @@ -15,7 +15,10 @@ Group::Group() : framesets_(kFrameBufferSize), head_(0) { framesets_[0].timestamp = -1; jobs_ = 0; skip_ = false; - setFPS(20); + //setFPS(20); + + mspf_ = ftl::timer::getInterval(); + setLatency(5); } diff --git a/components/rgbd-sources/src/streamer.cpp b/components/rgbd-sources/src/streamer.cpp index 35339ecf0..e854ac590 100644 --- a/components/rgbd-sources/src/streamer.cpp +++ b/components/rgbd-sources/src/streamer.cpp @@ -33,11 +33,11 @@ Streamer::Streamer(nlohmann::json &config, Universe *net) net_ = net; time_peer_ = ftl::UUID(0); clock_adjust_ = 0; - mspf_ = 1000 / value("fps", 20); + mspf_ = ftl::timer::getInterval(); //1000 / value("fps", 20); //last_dropped_ = 0; //drop_count_ = 0; - group_.setFPS(value("fps", 20)); + //group_.setFPS(value("fps", 20)); group_.setLatency(10); compress_level_ = value("compression", 1); -- GitLab