From ebeea91bc8a30eb7ac328ec67fa68d502814c020 Mon Sep 17 00:00:00 2001 From: Philipp Jungkamp Date: Mon, 19 Jun 2023 12:20:23 +0200 Subject: [PATCH] node-webrtc: remove dead code and comments Signed-off-by: Philipp Jungkamp --- include/villas/nodes/webrtc.hpp | 23 --------------------- lib/nodes/webrtc/peer_connection.cpp | 31 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/include/villas/nodes/webrtc.hpp b/include/villas/nodes/webrtc.hpp index 788af6b15..c9bede10e 100644 --- a/include/villas/nodes/webrtc.hpp +++ b/include/villas/nodes/webrtc.hpp @@ -49,10 +49,6 @@ protected: public: WebRTCNode(const std::string &name = ""); - /* All of the following virtual-declared functions are optional. - * Have a look at node.hpp/node.cpp for the default behaviour. - */ - virtual ~WebRTCNode(); @@ -62,7 +58,6 @@ public: virtual int parse(json_t *json, const uuid_t sn_uuid); - /** Validate node configuration. */ virtual int check(); @@ -72,27 +67,9 @@ public: virtual int stop(); - // virtual - // int pause(); - - // virtual - // int resume(); - - // virtual - // int restart(); - - // virtual - // int reverse(); - virtual std::vector getPollFDs(); - // virtual - // std::vector getNetemFDs(); - - // virtual - // struct villas::node::memory::Type * getMemoryType(); - virtual const std::string & getDetails(); }; diff --git a/lib/nodes/webrtc/peer_connection.cpp b/lib/nodes/webrtc/peer_connection.cpp index dbbf9f44f..1c91ce955 100644 --- a/lib/nodes/webrtc/peer_connection.cpp +++ b/lib/nodes/webrtc/peer_connection.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -22,6 +23,22 @@ using namespace villas; using namespace villas::node; using namespace villas::node::webrtc; +/* + * libdatachannel defines the operator<< overloads required to format + * rtc::PeerConnection::State and similar in the global namespace. + * But C++ ADL based overload set construction does not find these operators, + * if these are invoked in the spdlog/fmt libraries. + * + * See this issue for a short explaination of ADL errors: + * https://github.com/gabime/spdlog/issues/1227#issuecomment-532009129 + * + * Adding the global ::operator<< overload set to the namespace rtc where + * the data structures are defined, allows ADL to pick these up in spdlog/fmt. + */ +namespace rtc { + using ::operator<<; +} + PeerConnection::PeerConnection(const std::string &server, const std::string &session, rtc::Configuration cfg, Web *w, rtc::DataChannelInit d) : web(w), dataChannelInit(d), @@ -163,7 +180,7 @@ void PeerConnection::onLocalCandidate(rtc::Candidate cand) void PeerConnection::onConnectionStateChange(rtc::PeerConnection::State state) { - //logger->debug("Connection State changed: {}", state); + logger->debug("Connection State changed: {}", state); auto lock = std::unique_lock { mutex }; @@ -334,13 +351,15 @@ void PeerConnection::onSignalingMessage(SignalingMessage msg) void PeerConnection::onDataChannel(std::shared_ptr dc) { - /*logger->debug("New data channel: id={}, stream={}, protocol={}, max_msg_size={}, label={}", - dc->id(), - dc->stream(), + logger->debug("New data channel: {}protocol={}, max_msg_size={}, label={}", + dc->id() && dc->stream() ? fmt::format("id={}, stream={}, ", + *(dc->id()), + *(dc->stream()) + ) : "", dc->protocol(), dc->maxMessageSize(), - dc->label()); - */ + dc->label() + ); auto lock = std::unique_lock { mutex };