1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

add plugin frame for rtp node

using nanomsg as a template
This commit is contained in:
Marvin Klimke 2018-11-16 16:07:47 +01:00
parent ab41fb657d
commit a1e43c7f00
2 changed files with 233 additions and 0 deletions

View file

@ -0,0 +1,80 @@
/** Node type: rtp
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017-2018, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
/**
* @addtogroup rtp rtp node type
* @ingroup node
* @{
*/
#pragma once
#include <villas/node.h>
#include <villas/list.h>
#include <villas/io.h>
#ifdef __cplusplus
extern "C" {
#endif
/** The maximum length of a packet which contains stuct rtp. */
#define RTP_MAX_PACKET_LEN 1500
/* Forward declarations */
struct format_type;
struct rtp {
/*
struct {
int socket;
struct list endpoints;
} in, out;
struct format_type *format;
struct io io;
*/
};
/** @see node_type::print */
char * rtp_print(struct node *n);
/** @see node_type::parse */
int rtp_parse(struct node *n, json_t *cfg);
/** @see node_type::open */
int rtp_start(struct node *n);
/** @see node_type::close */
int rtp_stop(struct node *n);
/** @see node_type::read */
int rtp_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *release);
/** @see node_type::write */
int rtp_write(struct node *n, struct sample *smps[], unsigned cnt, unsigned *release);
#ifdef __cplusplus
}
#endif
/** @} */

153
lib/nodes/rtp.c Normal file
View file

@ -0,0 +1,153 @@
/** Node type: rtp
*
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017-2018, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
/* TODO: individual includes instead of wrapper include */
#include <re/re.h>
#include <string.h>
#include <villas/plugin.h>
#include <villas/nodes/rtp.h>
#include <villas/utils.h>
#include <villas/format_type.h>
int rtp_reverse(struct node *n)
{
struct rtp *m = (struct rtp *) n->_vd;
/* TODO */
return 0;
}
int rtp_parse(struct node *n, json_t *cfg)
{
int ret;
struct rtp *m = (struct rtp *) n->_vd;
const char *format = "villas.binary";
json_error_t err;
/* TODO ret = json_unpack_ex(...); */
if (ret)
jerror(&err, "Failed to parse configuration of node %s", node_name(n));
return 0;
}
char * rtp_print(struct node *n)
{
struct rtp *m = (struct rtp *) n->_vd;
char *buf = NULL;
/* TODO */
return buf;
}
int rtp_start(struct node *n)
{
int ret;
struct rtp *m = (struct rtp *) n->_vd;
/* TODO */
return 0;
}
int rtp_stop(struct node *n)
{
int ret;
struct rtp *m = (struct rtp *) n->_vd;
/* TODO */
return 0;
}
int rtp_type_stop()
{
/* TODO */
return -1;
}
int rtp_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *release)
{
struct rtp *m = (struct rtp *) n->_vd;
int bytes;
char data[RTP_MAX_PACKET_LEN];
/* TODO */
return -1;
}
int rtp_write(struct node *n, struct sample *smps[], unsigned cnt, unsigned *release)
{
int ret;
struct rtp *m = (struct rtp *) n->_vd;
size_t wbytes;
char data[RTP_MAX_PACKET_LEN];
/* TODO */
return cnt;
}
int rtp_fd(struct node *n)
{
int ret;
struct rtp *m = (struct rtp *) n->_vd;
int fd;
size_t len = sizeof(fd);
/* TODO */
return fd;
}
static struct plugin p = {
.name = "rtp",
.description = "real-time transport protocol (libre)",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0,
.size = sizeof(struct rtp),
.type.stop = rtp_type_stop,
.reverse = rtp_reverse,
.parse = rtp_parse,
.print = rtp_print,
.start = rtp_start,
.stop = rtp_stop,
.read = rtp_read,
.write = rtp_write,
.fd = rtp_fd
}
};
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)