2018-11-16 16:07:47 +01:00
|
|
|
/** Node type: rtp
|
|
|
|
*
|
|
|
|
* @file
|
2022-12-14 17:41:58 +01:00
|
|
|
* @author Steffen Vogel <post@steffenvogel.de>
|
2019-01-25 17:26:08 +01:00
|
|
|
* @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
|
2018-11-16 16:07:47 +01:00
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-12-07 15:15:24 +01:00
|
|
|
#include <pthread.h>
|
|
|
|
|
2019-03-29 09:50:47 +01:00
|
|
|
#include <fstream>
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
#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>
|
2019-01-07 15:22:38 +01:00
|
|
|
#include <villas/queue_signalled.h>
|
2019-03-26 15:34:07 +01:00
|
|
|
#include <villas/hooks/limit_rate.hpp>
|
|
|
|
#include <villas/hooks/decimate.hpp>
|
2019-04-14 19:22:33 +02:00
|
|
|
#include <villas/dsp/pid.hpp>
|
2018-11-16 16:07:47 +01:00
|
|
|
|
2019-04-23 00:12:31 +02:00
|
|
|
extern "C" {
|
2021-03-09 01:49:04 +01:00
|
|
|
#include <re/re_sa.h>
|
|
|
|
#include <re/re_rtp.h>
|
2019-04-23 00:12:31 +02:00
|
|
|
}
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
|
|
|
|
/* Forward declarations */
|
|
|
|
class NodeCompat;
|
|
|
|
class SuperNode;
|
|
|
|
|
2019-01-25 17:26:08 +01:00
|
|
|
/** The maximum length of a packet which contains rtp data. */
|
2018-11-28 18:12:06 +01:00
|
|
|
#define RTP_INITIAL_BUFFER_LEN 1500
|
2019-01-28 10:53:01 +01:00
|
|
|
#define RTP_PACKET_TYPE 21
|
2018-11-16 16:07:47 +01:00
|
|
|
|
2019-06-23 16:13:23 +02:00
|
|
|
enum class RTPHookType {
|
|
|
|
DISABLED,
|
|
|
|
DECIMATE,
|
|
|
|
LIMIT_RATE
|
2019-03-26 15:34:07 +01:00
|
|
|
};
|
2018-11-16 16:07:47 +01:00
|
|
|
|
|
|
|
struct rtp {
|
2018-11-22 17:53:07 +01:00
|
|
|
struct rtp_sock *rs; /**< RTP socket */
|
2018-11-22 07:18:27 +01:00
|
|
|
|
2019-01-21 15:50:18 +01:00
|
|
|
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;
|
2018-11-16 16:07:47 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
Format *formatter;
|
2018-11-22 17:53:07 +01:00
|
|
|
|
2019-01-21 12:12:47 +01:00
|
|
|
struct {
|
|
|
|
int enabled;
|
|
|
|
|
2019-01-28 12:30:47 +01:00
|
|
|
int num_rrs;
|
2019-01-21 12:12:47 +01:00
|
|
|
} rtcp;
|
|
|
|
|
|
|
|
struct {
|
2019-01-21 13:10:55 +01:00
|
|
|
double a;
|
|
|
|
double b;
|
2019-01-21 12:12:47 +01:00
|
|
|
|
2019-06-23 16:13:23 +02:00
|
|
|
enum RTPHookType rate_hook_type;
|
2019-04-14 19:22:33 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
LimitHook::Ptr rate_hook;
|
|
|
|
dsp::PID rate_pid;
|
2019-04-14 19:22:33 +02:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
2019-03-29 10:45:23 +01:00
|
|
|
std::ofstream *log;
|
2019-03-29 09:50:47 +01:00
|
|
|
char *log_filename;
|
|
|
|
} aimd; /** AIMD state */
|
2018-12-07 15:15:24 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
struct CQueueSignalled recv_queue;
|
2019-01-28 10:53:01 +01:00
|
|
|
struct mbuf *send_mb;
|
2018-11-16 16:07:47 +01:00
|
|
|
};
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
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);
|
2018-11-16 16:07:47 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int rtp_stop(NodeCompat *n);
|
2018-11-16 16:07:47 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int rtp_netem_fds(NodeCompat *n, int fds[]);
|
2018-11-16 16:07:47 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int rtp_poll_fds(NodeCompat *n, int fds[]);
|
2018-11-16 16:07:47 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int rtp_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
2018-11-16 16:07:47 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int rtp_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
2018-11-16 16:07:47 +01:00
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|