diff --git a/components/rgbd-sources/include/ftl/rgbd/streamer.hpp b/components/rgbd-sources/include/ftl/rgbd/streamer.hpp index 02025e22209a029e0bf6827214260369ab693929..972f48beca8771743bfd3111704001086a7c5546 100644 --- a/components/rgbd-sources/include/ftl/rgbd/streamer.hpp +++ b/components/rgbd-sources/include/ftl/rgbd/streamer.hpp @@ -8,7 +8,7 @@ #include <ftl/rgbd/source.hpp> #include <ftl/net/universe.hpp> #include <string> -#include <list> +#include <vector> #include <map> #include <shared_mutex> @@ -32,7 +32,7 @@ struct StreamSource { unsigned int state; // Busy or ready to swap? cv::Mat rgb; // Tx buffer cv::Mat depth; // Tx buffer - std::list<detail::StreamClient> clients[10]; // One list per bitrate + std::vector<detail::StreamClient> clients[10]; // One list per bitrate std::shared_mutex mutex; }; diff --git a/components/rgbd-sources/src/net.cpp b/components/rgbd-sources/src/net.cpp index ac7bc8553da8a8b7e417a26787f72f32b6c91c3d..ee89beca2e3e1827c40602ec99f61b5c30032dff 100644 --- a/components/rgbd-sources/src/net.cpp +++ b/components/rgbd-sources/src/net.cpp @@ -135,7 +135,7 @@ void NetSource::_updateURI() { } bool NetSource::grab() { - if (N_ == 0) { + if (N_ == 1) { N_ += 10; if (!host_->getNet()->send(peer_, "get_stream", *host_->get<string>("uri"), 10, 0, host_->getNet()->id(), *host_->get<string>("uri"))) { active_ = false; diff --git a/components/rgbd-sources/src/streamer.cpp b/components/rgbd-sources/src/streamer.cpp index ccf16b170b9c29d565753a6aeb7eaf23e78071de..4c1051397e2e0adbb0c184015a344071df73d5af 100644 --- a/components/rgbd-sources/src/streamer.cpp +++ b/components/rgbd-sources/src/streamer.cpp @@ -114,13 +114,22 @@ void Streamer::_addClient(const string &source, int N, int rate, const ftl::UUID LOG(INFO) << "Adding Stream Peer: " << peer.to_string(); + StreamSource *s = sources_[source]; + for (int i=0; i<s->clients[rate].size(); i++) { + if (s->clients[rate][i].peerid == peer) { + StreamClient &c = s->clients[rate][i]; + c.txmax = N; + c.txcount -= N; + return; + } + } + StreamClient c; c.peerid = peer; c.uri = dest; c.txcount = 0; c.txmax = N; - StreamSource *s = sources_[source]; //unique_lock<shared_mutex> ulk(s->mutex); s->clients[rate].push_back(c); }