Logo
ApraPipes 1.0
Loading...
Searching...
No Matches
RTSPClientSrc.h
1#pragma once
2#include <chrono>
3#include <string>
4#include "Module.h"
5#include "declarative/PropertyMacros.h"
6
8{
9public:
10 RTSPClientSrcProps(const std::string& rtspURL, const std::string& userName, const std::string& password, bool useTCP=true) : ModuleProps(),
12 {
13 }
14
16 {
17 }
18
20 {
21 return ModuleProps::getSerializeSize() + sizeof(rtspURL) + sizeof(userName) + sizeof(password), sizeof(useTCP);
22 }
23
25 bool useTCP = true;
26
27 // ============================================================
28 // Property Binding for Declarative Pipeline
29 // ============================================================
30 template<typename PropsT>
31 static void applyProperties(
32 PropsT& props,
33 const std::map<std::string, apra::ScalarPropertyValue>& values,
34 std::vector<std::string>& missingRequired
35 ) {
36 apra::applyProp(props.rtspURL, "rtspURL", values, true, missingRequired);
37 apra::applyProp(props.userName, "userName", values, false, missingRequired);
38 apra::applyProp(props.password, "password", values, false, missingRequired);
39 apra::applyProp(props.useTCP, "useTCP", values, false, missingRequired);
40 }
41
42 apra::ScalarPropertyValue getProperty(const std::string& propName) const {
43 if (propName == "rtspURL") return rtspURL;
44 if (propName == "userName") return userName;
45 if (propName == "password") return password;
46 if (propName == "useTCP") return useTCP;
47 throw std::runtime_error("Unknown property: " + propName);
48 }
49
50 bool setProperty(const std::string& propName, const apra::ScalarPropertyValue& value) {
51 // All properties are static (can't change after init)
52 return false;
53 }
54
55 static std::vector<std::string> dynamicPropertyNames() {
56 return {}; // No dynamically changeable properties
57 }
58
59private:
61
62 template<class Archive>
63 void serialize(Archive& ar, const unsigned int version)
64 {
65 ar& boost::serialization::base_object<ModuleProps>(*this);
66 ar& rtspURL;
67 ar& userName;
68 ar& password;
69 ar& useTCP;
70 }
71};
72
73class RTSPClientSrc : public Module {
74public:
76 virtual ~RTSPClientSrc();
77 bool init();
78 bool term();
79 void setProps(RTSPClientSrcProps& props);
80 int getCurrentFps();
82
83protected:
84 bool produce();
85 bool validateOutputPins();
86 void notifyPlay(bool play);
87 bool handleCommand(Command::CommandType type, frame_sp& frame);
88 bool handlePropsChange(frame_sp& frame);
89private:
91 class Detail;
92 boost::shared_ptr<Detail> mDetail;
93};
CommandType
Definition Command.h:9
Definition Module.h:33
virtual size_t getSerializeSize()
Definition Module.h:101
Definition Module.h:151
bool play(float speed, bool direction=true)
Definition Module.cpp:1140
Definition RTSPClientSrc.h:8
static void applyProperties(PropsT &props, const std::map< std::string, apra::ScalarPropertyValue > &values, std::vector< std::string > &missingRequired)
Definition RTSPClientSrc.h:31
void serialize(Archive &ar, const unsigned int version)
Definition RTSPClientSrc.h:63
RTSPClientSrcProps()
Definition RTSPClientSrc.h:15
bool useTCP
Definition RTSPClientSrc.h:25
string userName
Definition RTSPClientSrc.h:24
string password
Definition RTSPClientSrc.h:24
bool setProperty(const std::string &propName, const apra::ScalarPropertyValue &value)
Definition RTSPClientSrc.h:50
RTSPClientSrcProps(const std::string &rtspURL, const std::string &userName, const std::string &password, bool useTCP=true)
Definition RTSPClientSrc.h:10
friend class boost::serialization::access
Definition RTSPClientSrc.h:60
size_t getSerializeSize()
Definition RTSPClientSrc.h:19
string rtspURL
Definition RTSPClientSrc.h:24
apra::ScalarPropertyValue getProperty(const std::string &propName) const
Definition RTSPClientSrc.h:42
static std::vector< std::string > dynamicPropertyNames()
Definition RTSPClientSrc.h:55
Definition RTSPClientSrc.cpp:49
Definition RTSPClientSrc.h:73
bool produce()
Definition RTSPClientSrc.cpp:245
boost::shared_ptr< Detail > mDetail
Definition RTSPClientSrc.h:92
int getCurrentFps()
Definition RTSPClientSrc.cpp:262
bool handleCommand(Command::CommandType type, frame_sp &frame)
Definition RTSPClientSrc.cpp:253
bool handlePropsChange(frame_sp &frame)
Definition RTSPClientSrc.cpp:267
bool term()
Definition RTSPClientSrc.cpp:232
RTSPClientSrcProps getProps()
Definition RTSPClientSrc.cpp:241
bool init()
Definition RTSPClientSrc.cpp:225
RTSPClientSrc(RTSPClientSrcProps _props)
Definition RTSPClientSrc.cpp:219
virtual ~RTSPClientSrc()
Definition RTSPClientSrc.cpp:223
bool validateOutputPins()
Definition RTSPClientSrc.cpp:248
void setProps(RTSPClientSrcProps &props)
Definition RTSPClientSrc.cpp:236
void notifyPlay(bool play)
Definition RTSPClientSrc.cpp:252
RTSPClientSrcProps mProps
Definition RTSPClientSrc.h:90
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