2022-07-19 19:05:13 +00:00
|
|
|
/** WebRTC signaling messages.
|
|
|
|
*
|
|
|
|
* @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-19 19:05:13 +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-19 19:05:13 +00:00
|
|
|
* @license Apache 2.0
|
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <chrono>
|
2023-06-13 17:48:04 +02:00
|
|
|
#include <vector>
|
|
|
|
#include <variant>
|
2022-07-19 19:05:13 +00:00
|
|
|
|
|
|
|
#include <rtc/rtc.hpp>
|
|
|
|
#include <jansson.h>
|
|
|
|
|
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
namespace webrtc {
|
|
|
|
|
2023-06-29 05:48:02 +00:00
|
|
|
struct Peer {
|
2022-07-19 19:05:13 +00:00
|
|
|
int id;
|
2023-06-29 05:48:02 +00:00
|
|
|
std::string name;
|
2022-07-19 19:05:13 +00:00
|
|
|
std::string remote;
|
|
|
|
std::string userAgent;
|
|
|
|
std::chrono::time_point<std::chrono::system_clock> created;
|
|
|
|
|
2023-06-29 05:48:02 +00:00
|
|
|
Peer(json_t *j);
|
2022-07-19 19:05:13 +00:00
|
|
|
json_t * toJSON() const;
|
|
|
|
};
|
|
|
|
|
2023-06-13 17:48:04 +02:00
|
|
|
struct RelayMessage {
|
|
|
|
std::vector<rtc::IceServer> servers;
|
|
|
|
|
|
|
|
RelayMessage(json_t *j);
|
|
|
|
};
|
|
|
|
|
2022-07-19 19:05:13 +00:00
|
|
|
struct ControlMessage {
|
2023-06-29 05:48:02 +00:00
|
|
|
int peerID;
|
|
|
|
std::vector<Peer> peers;
|
2022-07-19 19:05:13 +00:00
|
|
|
|
|
|
|
ControlMessage(json_t *j);
|
|
|
|
json_t * toJSON() const;
|
|
|
|
};
|
|
|
|
|
2023-06-15 15:34:35 +02:00
|
|
|
struct SignalingMessage {
|
|
|
|
std::variant<std::monostate, RelayMessage, ControlMessage, rtc::Description, rtc::Candidate> message;
|
|
|
|
|
|
|
|
static SignalingMessage fromJSON(json_t *j);
|
2022-07-19 19:05:13 +00:00
|
|
|
json_t * toJSON() const;
|
|
|
|
std::string toString() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace webrtc */
|
|
|
|
} /* namespace node */
|
|
|
|
} /* namespace villas */
|