1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-16 00:00:02 +01:00
VILLASnode/include/villas/nodes/rtp.hpp

114 lines
2.2 KiB
C++
Raw Normal View History

/** Node type: rtp
*
* @file
* @author Steffen Vogel <post@steffenvogel.de>
* @author Marvin Klimke <marvin.klimke@rwth-aachen.de>
2022-03-15 09:28:57 -04:00
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
2022-07-04 18:20:03 +02:00
* @license Apache 2.0
*********************************************************************************/
#pragma once
#include <pthread.h>
2019-03-29 09:50:47 +01:00
#include <fstream>
#include <villas/list.hpp>
2019-03-29 09:50:27 +01:00
#include <villas/log.hpp>
2021-05-10 00:12:30 +02:00
#include <villas/format.hpp>
#include <villas/queue_signalled.h>
2019-03-26 15:34:07 +01:00
#include <villas/hooks/limit_rate.hpp>
#include <villas/hooks/decimate.hpp>
#include <villas/dsp/pid.hpp>
extern "C" {
2021-03-09 01:49:04 +01:00
#include <re/re_sa.h>
#include <re/re_rtp.h>
}
namespace villas {
namespace node {
/* Forward declarations */
class NodeCompat;
class SuperNode;
/** The maximum length of a packet which contains rtp data. */
#define RTP_INITIAL_BUFFER_LEN 1500
2019-01-28 10:53:01 +01:00
#define RTP_PACKET_TYPE 21
2019-06-23 16:13:23 +02:00
enum class RTPHookType {
DISABLED,
DECIMATE,
LIMIT_RATE
2019-03-26 15:34:07 +01:00
};
struct rtp {
struct rtp_sock *rs; /**< RTP socket */
struct {
struct sa saddr_rtp; /**< Local/Remote address of the RTP socket */
struct sa saddr_rtcp; /**< Local/Remote address of the RTCP socket */
} in, out;
Format *formatter;
struct {
int enabled;
2019-01-28 12:30:47 +01:00
int num_rrs;
} rtcp;
struct {
double a;
double b;
2019-06-23 16:13:23 +02:00
enum RTPHookType rate_hook_type;
LimitHook::Ptr rate_hook;
dsp::PID rate_pid;
/* PID parameters for rate controller */
double Kp, Ki, Kd;
double rate_min;
double rate;
double rate_source; /**< Sample rate of source */
2019-01-28 12:30:47 +01:00
std::ofstream *log;
2019-03-29 09:50:47 +01:00
char *log_filename;
} aimd; /** AIMD state */
struct CQueueSignalled recv_queue;
2019-01-28 10:53:01 +01:00
struct mbuf *send_mb;
};
char * rtp_print(NodeCompat *n);
int rtp_parse(NodeCompat *n, json_t *json);
int rtp_init(NodeCompat *n);
int rtp_destroy(NodeCompat *n);
int rtp_reverse(NodeCompat *n);
int rtp_type_start(SuperNode *sn);
int rtp_type_stop();
int rtp_start(NodeCompat *n);
int rtp_stop(NodeCompat *n);
int rtp_netem_fds(NodeCompat *n, int fds[]);
int rtp_poll_fds(NodeCompat *n, int fds[]);
int rtp_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
int rtp_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
} // namespace node
} // namespace villas