2022-07-19 19:05:13 +00:00
|
|
|
/** Node-type webrtc.
|
2022-07-14 10:43:09 +00:00
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @author Steffen Vogel <svogel2@eonerc.rwth-aachen.de>
|
2023-06-19 12:12:33 +02:00
|
|
|
* @author Philipp Jungkamp <Philipp.Jungkamp@opal-rt.com>
|
2022-07-14 10:43:09 +00:00
|
|
|
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
|
2023-06-19 12:12:33 +02:00
|
|
|
* @copyright 2023, OPAL-RT Germany GmbH
|
2022-07-14 10:43:09 +00:00
|
|
|
* @license Apache 2.0
|
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-07-19 19:05:13 +00:00
|
|
|
#include <rtc/rtc.hpp>
|
|
|
|
|
|
|
|
#include <villas/nodes/webrtc/peer_connection.hpp>
|
2022-07-14 10:43:09 +00:00
|
|
|
#include <villas/node/config.hpp>
|
|
|
|
#include <villas/node.hpp>
|
|
|
|
#include <villas/timing.hpp>
|
2023-06-13 17:48:04 +02:00
|
|
|
#include <villas/format.hpp>
|
|
|
|
#include <villas/queue_signalled.h>
|
2022-07-14 10:43:09 +00:00
|
|
|
|
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
|
|
|
|
/* Forward declarations */
|
|
|
|
struct Sample;
|
|
|
|
|
|
|
|
class WebRTCNode : public Node {
|
|
|
|
|
|
|
|
protected:
|
2022-07-19 19:05:13 +00:00
|
|
|
std::string server;
|
|
|
|
std::string session;
|
2023-06-29 05:53:04 +00:00
|
|
|
std::string peer;
|
2022-07-19 19:05:13 +00:00
|
|
|
|
2023-06-13 17:48:04 +02:00
|
|
|
int wait_seconds;
|
|
|
|
Format *format;
|
|
|
|
struct CQueueSignalled queue;
|
|
|
|
struct Pool pool;
|
2022-07-19 19:05:13 +00:00
|
|
|
|
|
|
|
std::shared_ptr<webrtc::PeerConnection> conn;
|
2023-06-15 11:24:18 +02:00
|
|
|
rtc::Configuration rtcConf;
|
2023-06-13 17:48:04 +02:00
|
|
|
rtc::DataChannelInit dci;
|
2022-07-14 10:43:09 +00:00
|
|
|
|
|
|
|
virtual
|
|
|
|
int _read(struct Sample *smps[], unsigned cnt);
|
|
|
|
|
|
|
|
virtual
|
|
|
|
int _write(struct Sample *smps[], unsigned cnt);
|
|
|
|
|
2023-06-30 11:52:14 +02:00
|
|
|
virtual
|
|
|
|
json_t * _readStatus() const;
|
|
|
|
|
2022-07-14 10:43:09 +00:00
|
|
|
public:
|
2023-06-30 10:51:01 +02:00
|
|
|
WebRTCNode(const uuid_t &id = {}, const std::string &name = "");
|
2022-07-14 10:43:09 +00:00
|
|
|
|
|
|
|
virtual
|
|
|
|
~WebRTCNode();
|
|
|
|
|
|
|
|
virtual
|
|
|
|
int prepare();
|
|
|
|
|
|
|
|
virtual
|
2023-06-30 10:51:01 +02:00
|
|
|
int parse(json_t *json);
|
2022-07-14 10:43:09 +00:00
|
|
|
|
|
|
|
virtual
|
|
|
|
int start();
|
|
|
|
|
2023-06-13 17:48:04 +02:00
|
|
|
virtual
|
|
|
|
int stop();
|
2022-07-14 10:43:09 +00:00
|
|
|
|
2023-06-13 17:48:04 +02:00
|
|
|
virtual
|
|
|
|
std::vector<int> getPollFDs();
|
2022-07-14 10:43:09 +00:00
|
|
|
|
|
|
|
virtual
|
|
|
|
const std::string & getDetails();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-07-19 19:05:13 +00:00
|
|
|
class WebRTCNodeFactory : public NodeFactory {
|
|
|
|
|
|
|
|
public:
|
|
|
|
using NodeFactory::NodeFactory;
|
|
|
|
|
|
|
|
virtual
|
2023-06-30 10:51:01 +02:00
|
|
|
Node * make(const uuid_t &id = {}, const std::string &nme = "")
|
2022-07-19 19:05:13 +00:00
|
|
|
{
|
2023-06-30 10:51:01 +02:00
|
|
|
auto *n = new WebRTCNode(id, nme);
|
2022-07-19 19:05:13 +00:00
|
|
|
|
|
|
|
init(n);
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual
|
|
|
|
int getFlags() const
|
|
|
|
{
|
|
|
|
return (int) NodeFactory::Flags::SUPPORTS_READ |
|
|
|
|
(int) NodeFactory::Flags::SUPPORTS_WRITE |
|
|
|
|
(int) NodeFactory::Flags::SUPPORTS_POLL |
|
|
|
|
(int) NodeFactory::Flags::REQUIRES_WEB;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual
|
|
|
|
std::string getName() const
|
|
|
|
{
|
|
|
|
return "webrtc";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual
|
|
|
|
std::string getDescription() const
|
|
|
|
{
|
|
|
|
return "Web Real-time Communication";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual
|
|
|
|
int start(SuperNode *sn);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|