ifw-rtmstools 3.0.0
Loading...
Searching...
No Matches
ddtSender.hpp
Go to the documentation of this file.
1
8#ifndef RTMPS2DDT_SENDER_HPP_
9#define RTMPS2DDT_SENDER_HPP_
10
11#define BOOST_BIND_NO_PLACEHOLDERS
12
13#include <boost/lockfree/spsc_queue.hpp>
14#include <boost/atomic.hpp>
15
16#include <ddt/ddtDataPublisherApplication.hpp>
17#include <ddt/ddtDataPublisher.hpp>
18#include <ddt/ddtDataTransferFactory.hpp>
19#include <ddt/ddtEncDecImage3D.hpp>
20#include <ddt/ddtLogger.hpp>
21
22//#include <ifw/rtmslib/dataType.hpp>
23#include <ifw/fnd/defs/dataType.hpp>
24
27
28namespace ifw::rtmstools {
29
30 constexpr short QUEUE_SIZE = 5;
31 constexpr short DDT_BUFFER_ITEMS = 2;
32
40 struct DdtSender {
41
42 // Basic image information.
45 ifw::fnd::datatype::DataType m_data_type;
46
47 // Information to connect to the DDT broker.
48 std::string m_broker_uri;
49 std::string m_ddt_stream;
50
51 // Interval to publish images.
53
54 log4cplus::Logger m_logger;
55
56 std::unique_ptr<ddt::DdtDataPublisher> m_publisher;
57 DdtEncDecImage3D m_encoder;
58
59 DdtSender(int width,
60 int height,
61 ifw::fnd::datatype::DataType datatype,
62 std::string broker_uri,
63 std::string ddt_stream,
64 int interval = 100);
65
71 void RegisterPublisher();
72
76 void Run();
77
78 public:
79 static std::atomic<bool> new_data; // Flag to notify a new image
80 static std::atomic<bool> stopped; // Flag to stop infinite loop
81
82 // Single-writer/single-reader FIFO queue.
83 static boost::lockfree::spsc_queue<std::shared_ptr<rtmstools::DdtImage>,
84 boost::lockfree::capacity<5>> spsc_queue;
85 };
86}
87
88#endif // RTMPS2DDT_SENDER_HPP_
DdtImage Class Implementation.
Definition ddtImage.cpp:10
constexpr short QUEUE_SIZE
Definition ddtSender.hpp:30
constexpr short DDT_BUFFER_ITEMS
Definition ddtSender.hpp:31
The DdtSender struct.
Definition ddtSender.hpp:40
DdtEncDecImage3D m_encoder
Definition ddtSender.hpp:57
void Run()
Implements infinite loop waiting for new images.
Definition ddtSender.cpp:65
int m_width
Definition ddtSender.hpp:43
log4cplus::Logger m_logger
Definition ddtSender.hpp:54
static std::atomic< bool > stopped
Definition ddtSender.hpp:80
ifw::fnd::datatype::DataType m_data_type
Definition ddtSender.hpp:45
static std::atomic< bool > new_data
Definition ddtSender.hpp:79
std::string m_ddt_stream
Definition ddtSender.hpp:49
std::unique_ptr< ddt::DdtDataPublisher > m_publisher
Definition ddtSender.hpp:56
int m_interval
Definition ddtSender.hpp:52
DdtSender(int width, int height, ifw::fnd::datatype::DataType datatype, std::string broker_uri, std::string ddt_stream, int interval=100)
Definition ddtSender.cpp:27
void RegisterPublisher()
Register DDT publisher.
Definition ddtSender.cpp:47
int m_height
Definition ddtSender.hpp:44
static boost::lockfree::spsc_queue< std::shared_ptr< rtmstools::DdtImage >, boost::lockfree::capacity< 5 > > spsc_queue
Definition ddtSender.hpp:84
std::string m_broker_uri
Definition ddtSender.hpp:48