Logo
ApraPipes 1.0
Loading...
Searching...
No Matches
FramesMuxer.h
1#pragma once
2
3#include "Module.h"
4#include "declarative/PropertyMacros.h"
5
7{
8public:
14
15public:
23
24 int maxDelay = 30; // Difference between current frame and first frame in the queue
26 double maxTsDelayInMS = 16.67; // Max TimeStampDelay in Milli Seconds
27
28 // ============================================================
29 // Property Binding for Declarative Pipeline
30 // ============================================================
31 template<typename PropsT>
32 static void applyProperties(
33 PropsT& props,
34 const std::map<std::string, apra::ScalarPropertyValue>& values,
35 std::vector<std::string>& missingRequired
36 ) {
37 apra::applyProp(props.maxDelay, "maxDelay", values, false, missingRequired);
38 apra::applyProp(props.maxTsDelayInMS, "maxTsDelayInMS", values, false, missingRequired);
39
40 // Handle Strategy enum
41 auto it = values.find("strategy");
42 if (it != values.end()) {
43 if (auto* strVal = std::get_if<std::string>(&it->second)) {
44 if (*strVal == "ALL_OR_NONE") props.strategy = ALL_OR_NONE;
45 else if (*strVal == "MAX_DELAY_ANY") props.strategy = MAX_DELAY_ANY;
46 else if (*strVal == "MAX_TIMESTAMP_DELAY") props.strategy = MAX_TIMESTAMP_DELAY;
47 }
48 }
49 }
50
51 apra::ScalarPropertyValue getProperty(const std::string& propName) const {
52 if (propName == "maxDelay") return static_cast<int64_t>(maxDelay);
53 if (propName == "maxTsDelayInMS") return maxTsDelayInMS;
54 if (propName == "strategy") {
55 switch (strategy) {
56 case ALL_OR_NONE: return std::string("ALL_OR_NONE");
57 case MAX_DELAY_ANY: return std::string("MAX_DELAY_ANY");
58 case MAX_TIMESTAMP_DELAY: return std::string("MAX_TIMESTAMP_DELAY");
59 }
60 }
61 throw std::runtime_error("Unknown property: " + propName);
62 }
63
64 bool setProperty(const std::string& propName, const apra::ScalarPropertyValue& value) {
65 return false; // All properties are static
66 }
67
68 static std::vector<std::string> dynamicPropertyNames() {
69 return {};
70 }
71};
72
74
75class FramesMuxer : public Module {
76public:
77
79 virtual ~FramesMuxer() {}
80
81 virtual bool init();
82 virtual bool term();
83
84protected:
85 bool process(frame_container& frames);
86 bool validateInputPins();
87 bool validateOutputPins();
89 void addInputPin(framemetadata_sp& metadata, string& pinId);
90
91private:
92 boost::shared_ptr<FramesMuxerStrategy> mDetail;
93};
94
95
96
@ NONE
Definition FIndexStrategy.h:11
Definition FramesMuxer.h:7
static void applyProperties(PropsT &props, const std::map< std::string, apra::ScalarPropertyValue > &values, std::vector< std::string > &missingRequired)
Definition FramesMuxer.h:32
int maxDelay
Definition FramesMuxer.h:24
double maxTsDelayInMS
Definition FramesMuxer.h:26
apra::ScalarPropertyValue getProperty(const std::string &propName) const
Definition FramesMuxer.h:51
FramesMuxerProps()
Definition FramesMuxer.h:16
Strategy strategy
Definition FramesMuxer.h:25
bool setProperty(const std::string &propName, const apra::ScalarPropertyValue &value)
Definition FramesMuxer.h:64
static std::vector< std::string > dynamicPropertyNames()
Definition FramesMuxer.h:68
Strategy
Definition FramesMuxer.h:9
@ MAX_TIMESTAMP_DELAY
Definition FramesMuxer.h:12
@ MAX_DELAY_ANY
Definition FramesMuxer.h:11
@ ALL_OR_NONE
Definition FramesMuxer.h:10
Definition FramesMuxer.cpp:10
Definition FramesMuxer.h:75
virtual bool init()
Definition FramesMuxer.cpp:473
virtual bool term()
Definition FramesMuxer.cpp:484
bool process(frame_container &frames)
Definition FramesMuxer.cpp:497
bool validateInputOutputPins()
Definition FramesMuxer.cpp:462
virtual ~FramesMuxer()
Definition FramesMuxer.h:79
bool validateOutputPins()
Definition FramesMuxer.cpp:457
FramesMuxer(FramesMuxerProps _props=FramesMuxerProps())
Definition FramesMuxer.cpp:432
void addInputPin(framemetadata_sp &metadata, string &pinId)
Definition FramesMuxer.cpp:490
bool validateInputPins()
Definition FramesMuxer.cpp:452
boost::shared_ptr< FramesMuxerStrategy > mDetail
Definition FramesMuxer.h:92
Definition Module.h:33
FIndexStrategy::FIndexStrategyType fIndexStrategyType
Definition Module.h:133
Definition Module.h:151
void applyProp(T &member, const char *propName, const std::map< std::string, ScalarPropertyValue > &values, bool isRequired, std::vector< std::string > &missingRequired)
Definition PropertyMacros.h:36
std::variant< int64_t, double, bool, std::string > ScalarPropertyValue
Definition ModuleRegistry.h:30