RTC Toolkit 5.0.0
Loading...
Searching...
No Matches
publisher.hpp
Go to the documentation of this file.
1
13#ifndef RTCTK_REUSABLECOMPONENT_MUDPIPUB_PUBLISHER_HPP
14#define RTCTK_REUSABLECOMPONENT_MUDPIPUB_PUBLISHER_HPP
15
16#include <atomic>
17#include <string>
18#include <thread>
19#include <vector>
20
23
24namespace rtctk::mudpiPub {
25
26class Publisher {
27public:
28 Publisher(const std::string& pub_id, const PubCfg& cfg);
29
30 virtual ~Publisher();
31 void SendSample();
37 void Init();
38
43 void UpdateDynamicConfig(const PubCfg& cfg);
44
50 void SetData(std::vector<std::vector<uint8_t>> data);
51
52 const std::string& GetId() const {
53 return m_id;
54 }
55
56private:
57 void Run();
58
59 // Helper function to fill a sample buffer with a pattern.
60 void FillSample(std::vector<uint8_t>& sample_data, std::uint32_t sample_id);
61
62 // cppcheck-suppress-begin unusedStructMember
63
64 log4cplus::Logger& m_logger;
65
66 std::string m_id;
67
68 PubCfg m_cfg;
69
70 // Buffers of sample data loaded from the data file i.e. provided by user.
71 std::vector<std::vector<uint8_t>> m_user_samples_data;
72
73 std::atomic<bool> m_send_sample;
74 std::atomic<bool> m_stop;
75
76 std::thread m_thread;
77 // next members are used in Run method which is executed just in Running
78 // ... and UpdateDynamicConfig which can be executed just in Idle, so should not be a problem
79 // ... with race condition
80 uint32_t m_n_frames_per_sample;
81 unsigned int m_sample_id = 0;
82 std::vector<uint8_t> m_sample_data;
83
84 // cppcheck-suppress-end unusedStructMember
85};
86
87} // namespace rtctk::mudpiPub
88
89#endif // RTCTK_REUSABLECOMPONENT_MUDPIPUB_PUBLISHER_HPP
Definition publisher.hpp:26
void WaitUntilSendingDone()
Definition publisher.cpp:172
void SendSample()
Definition publisher.cpp:168
virtual ~Publisher()
Definition publisher.cpp:81
const std::string & GetId() const
Definition publisher.hpp:52
void UpdateDynamicConfig(const PubCfg &cfg)
Update (dynamic) configuration.
Definition publisher.cpp:88
void Init()
(Re)Initialize publisher (called before going to Running)
Definition publisher.cpp:163
void SetData(std::vector< std::vector< uint8_t > > data)
Set the User's Data (samples)
Definition publisher.cpp:155
Publisher(const std::string &pub_id, const PubCfg &cfg)
Definition publisher.cpp:49
Logging Support Library based on log4cplus.
Definition businessLogic.cpp:21
RTC toolkit MUDPI publisher configuration class declaration.
Configuration (Dynamic + Static) of a single MUDPI Publisher object.
Definition config.hpp:75