ros2 component stable version

This commit is contained in:
dmalad committed 2023-12-04 16:37:58 +01:00
1 parent 083693732c
commit 59baa89f5d
12 files changed
+170 -145

No files matched your search

Regular → Executable
+28 -22
View File
@@ -1,41 +1,47 @@
#ifndef IMAGE2RTSP_IMAGE2RTSP_HPP
#define IMAGE2RTSP_IMAGE2RTSP_HPP
#ifndef IMAGE2RTSP__IMAGE2RTSP_HPP_
#define IMAGE2RTSP__IMAGE2RTSP_HPP_
#include "visibility_control.h"
#include <gst/gst.h>
#include <gst/rtsp-server/rtsp-server.h>
#include <rclcpp/rclcpp.hpp>
#include <string>
#include "sensor_msgs/msg/image.hpp"
#include <gst/app/gstappsrc.h>
using namespace std;
class Image2rtsp : public rclcpp::Node{
class Image2rtsp : public rclcpp::Node
{
public:
Image2rtsp();
GstRTSPServer *rtsp_server;
IMAGE2RTSP_PUBLIC
explicit Image2rtsp(const rclcpp::NodeOptions & options);
GstRTSPServer *rtsp_server;
private:
string topic;
string mountpoint;
string bitrate;
string caps;
string port;
string pipeline;
string pipeline_head;
string pipeline_tail;
bool local_only;
GstAppSrc *appsrc;
string topic = "/color/image_raw";
string mountpoint = "/rs";
string bitrate = "500";
string framerate = "30";
string caps = "video/x-raw,framerate=" + framerate + "/1,width=1280,height=720";
string port = "8554";
string pipeline;
string pipeline_head;
string pipeline_tail;
bool local_only = false;
GstAppSrc *appsrc;
void video_mainloop_start();
void rtsp_server_add_url(const char *url, const char *sPipeline, GstElement **appsrc);
void topic_callback(const sensor_msgs::msg::Image::SharedPtr msg);
GstRTSPServer *rtsp_server_create(const string &port, const bool local_only);
GstCaps *gst_caps_new_from_image(const sensor_msgs::msg::Image::SharedPtr &msg);
rclcpp::Subscription<sensor_msgs::msg::Image>::SharedPtr subscription_;
void video_mainloop_start();
void rtsp_server_add_url(const char *url, const char *sPipeline, GstElement **appsrc);
void topic_callback(const sensor_msgs::msg::Image::SharedPtr msg);
GstRTSPServer *rtsp_server_create(const string &port, const bool local_only);
GstCaps *gst_caps_new_from_image(const sensor_msgs::msg::Image::SharedPtr &msg);
rclcpp::Subscription<sensor_msgs::msg::Image>::SharedPtr subscription_;
};
static void media_configure(GstRTSPMediaFactory *factory, GstRTSPMedia *media, GstElement **appsrc);
static void *mainloop(void *arg);
static gboolean session_cleanup(Image2rtsp *node, rclcpp::Logger logger, gboolean ignored);
#endif // IMAGE2RTSP_IMAGE2RTSP_HPP
#endif // IMAGE2RTSP__IMAGE2RTSP_HPP_
+44
View File
@@ -0,0 +1,44 @@
#ifndef IMAGE2RTSP__VISIBILITY_CONTROL_H_
#define IMAGE2RTSP__VISIBILITY_CONTROL_H_
#ifdef __cplusplus
extern "C"
{
#endif
// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
// https://gcc.gnu.org/wiki/Visibility
#if defined _WIN32 || defined __CYGWIN__
#ifdef __GNUC__
#define IMAGE2RTSP_EXPORT __attribute__ ((dllexport))
#define IMAGE2RTSP_IMPORT __attribute__ ((dllimport))
#else
#define IMAGE2RTSP_EXPORT __declspec(dllexport)
#define IMAGE2RTSP_IMPORT __declspec(dllimport)
#endif
#ifdef IMAGE2RTSP_BUILDING_DLL
#define IMAGE2RTSP_PUBLIC IMAGE2RTSP_EXPORT
#else
#define IMAGE2RTSP_PUBLIC IMAGE2RTSP_IMPORT
#endif
#define IMAGE2RTSP_PUBLIC_TYPE IMAGE2RTSP_PUBLIC
#define IMAGE2RTSP_LOCAL
#else
#define IMAGE2RTSP_EXPORT __attribute__ ((visibility("default")))
#define IMAGE2RTSP_IMPORT
#if __GNUC__ >= 4
#define IMAGE2RTSP_PUBLIC __attribute__ ((visibility("default")))
#define IMAGE2RTSP_LOCAL __attribute__ ((visibility("hidden")))
#else
#define IMAGE2RTSP_PUBLIC
#define IMAGE2RTSP_LOCAL
#endif
#define IMAGE2RTSP_PUBLIC_TYPE
#endif
#ifdef __cplusplus
}
#endif
#endif // IMAGE2RTSP__VISIBILITY_CONTROL_H_