Skip to content
Snippets Groups Projects
Commit e6cf226c authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Merge branch 'feature/dev-container' into 'main'

Add dev container

See merge request beyondaka/beyond-protocol!51
parents 50ca18f2 e563d14c
No related branches found
No related tags found
No related merge requests found
FROM app.ftlab.utu.fi/base:1.8-dev
ARG USERNAME=user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create the user
RUN addgroup --gid $USER_GID user \
&& adduser --disabled-password --gecos '' --uid $USER_UID --gid $USER_GID user && usermod -a -G audio user && usermod -a -G video user \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo python3-pip file \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& pip install cpplint cppclean
# ********************************************************
# * Anything else you want to do like clean up goes here *
# ********************************************************
# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
\ No newline at end of file
{
"build": { "dockerfile": "Dockerfile" },
"remoteUser": "user",
"runArgs": [],
"extensions": [
"ms-vscode.cpptools",
"twxs.cmake",
"ms-vscode.cmake-tools",
"ms-azuretools.vscode-docker",
"jbenden.c-cpp-flylint",
"eamodio.gitlens",
"Gruntfuggly.todo-tree",
"ms-vscode.cpptools-extension-pack",
"mine.cpplint"
]
}
...@@ -67,5 +67,5 @@ ...@@ -67,5 +67,5 @@
"variant": "cpp", "variant": "cpp",
"any": "cpp" "any": "cpp"
}, },
"cmake.cmakePath": "/snap/cmake/current/bin/cmake" "cmake.cmakePath": "cmake"
} }
\ No newline at end of file
...@@ -8,10 +8,13 @@ ...@@ -8,10 +8,13 @@
#include <ftl/protocol.hpp> #include <ftl/protocol.hpp>
#include <ftl/protocol/streams.hpp> #include <ftl/protocol/streams.hpp>
#include <ftl/protocol/self.hpp> #include <ftl/protocol/self.hpp>
#include <ftl/protocol/node.hpp>
#include <ftl/time.hpp> #include <ftl/time.hpp>
#include <ftl/protocol/channels.hpp> #include <ftl/protocol/channels.hpp>
#include <ftl/protocol/codecs.hpp> #include <ftl/protocol/codecs.hpp>
#include <ftl/lib/loguru.hpp> #include <ftl/lib/loguru.hpp>
#include <ftl/protocol/muxer.hpp>
#include <nlohmann/json.hpp>
using ftl::protocol::StreamPacket; using ftl::protocol::StreamPacket;
using ftl::protocol::DataPacket; using ftl::protocol::DataPacket;
...@@ -21,19 +24,43 @@ using ftl::protocol::Channel; ...@@ -21,19 +24,43 @@ using ftl::protocol::Channel;
using ftl::protocol::Codec; using ftl::protocol::Codec;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
if (argc != 2) return -1; if (argc != 3) return -1;
ftl::getSelf()->onNodeDetails([]() {
return nlohmann::json{
{"id", ftl::protocol::id.to_string()},
{"title", "Test app"},
{ "gpus", nlohmann::json::array() },
{ "devices", nlohmann::json::array() }
};
});
ftl::getSelf()->listen("tcp://localhost:9000"); ftl::getSelf()->listen("tcp://localhost:9000");
auto node = ftl::connectNode(argv[1]);
node->waitConnection();
auto muxer = std::make_unique<ftl::protocol::Muxer>();
muxer->begin();
auto stream = ftl::createStream(argv[1]); auto stream = ftl::createStream(argv[2]);
muxer->add(stream);
auto h = stream->onError([](ftl::protocol::Error, const std::string &str) { auto h = muxer->onError([](ftl::protocol::Error, const std::string &str) {
LOG(ERROR) << str; LOG(ERROR) << str;
return true; return true;
}); });
auto rh = muxer->onRequest([](const ftl::protocol::Request &r) {
LOG(INFO) << "Got request " << r.id.frameset() << "," << r.id.source();
return true;
});
stream->seen(ftl::protocol::FrameID(0, 0), Channel::kEndFrame);
if (!stream->begin()) return -1; if (!stream->begin()) return -1;
sleep_for(milliseconds(100));
int count = 10; int count = 10;
while (count--) { while (count--) {
StreamPacket spkt; StreamPacket spkt;
...@@ -49,7 +76,9 @@ int main(int argc, char *argv[]) { ...@@ -49,7 +76,9 @@ int main(int argc, char *argv[]) {
sleep_for(milliseconds(100)); sleep_for(milliseconds(100));
} }
stream->end(); LOG(INFO) << "Done";
muxer->end();
return 0; return 0;
} }
...@@ -36,7 +36,10 @@ FrameID Muxer::_mapFromInput(Muxer::StreamEntry *s, FrameID id) { ...@@ -36,7 +36,10 @@ FrameID Muxer::_mapFromInput(Muxer::StreamEntry *s, FrameID id) {
// Otherwise allocate something. // Otherwise allocate something.
lk.unlock(); lk.unlock();
UNIQUE_LOCK(mutex_, ulk); UNIQUE_LOCK(mutex_, ulk);
auto it2 = imap_.find(iid);
if (it2 != imap_.end()) {
return it2->second;
} else {
FrameID newID; FrameID newID;
if (s->fixed_fs >= 0) { if (s->fixed_fs >= 0) {
int source = sourcecount_[s->fixed_fs]++; int source = sourcecount_[s->fixed_fs]++;
...@@ -54,6 +57,7 @@ FrameID Muxer::_mapFromInput(Muxer::StreamEntry *s, FrameID id) { ...@@ -54,6 +57,7 @@ FrameID Muxer::_mapFromInput(Muxer::StreamEntry *s, FrameID id) {
return newID; return newID;
} }
} }
}
FrameID Muxer::_mapFromInput(const Muxer::StreamEntry *s, FrameID id) const { FrameID Muxer::_mapFromInput(const Muxer::StreamEntry *s, FrameID id) const {
SHARED_LOCK(mutex_, lk); SHARED_LOCK(mutex_, lk);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment