4#include "declarative/PropertyMacros.h"
5#include <boost/filesystem.hpp>
17 Mp4ReaderSourceProps(std::string _videoPath,
bool _parseFS, uint16_t _reInitInterval,
bool _direction,
bool _readLoop,
bool _giveLiveTS,
int _parseFSTimeoutDuration = 15,
bool _bFramesEnabled =
false) :
ModuleProps()
30 auto errMsg =
"incorrect prop reInitInterval <" + std::to_string(
reInitInterval) +
">";
31 throw AIPException(AIP_FATAL, errMsg);
34 if (_readLoop && (_reInitInterval || _parseFS))
36 auto errMsg =
"Incorrect parameters. Looping can not be coupled with retry feature or disk parsing. loop <" + std::to_string(_readLoop) +
37 "> reInitInterval <" + std::to_string(
reInitInterval) +
"> parseFS <" + std::to_string(_parseFS) +
">";
38 throw AIPException(AIP_FATAL, errMsg);
40 auto canonicalVideoPath = boost::filesystem::canonical(_videoPath);
46 if (_reInitInterval < 0)
48 throw AIPException(AIP_FATAL,
"reInitInterval must be 0 or more seconds");
57 skipDir = boost::filesystem::path(
videoPath).parent_path().parent_path().parent_path().string();
61 skipDir = boost::filesystem::path(canonicalVideoPath).string();
76 std::string
skipDir =
"./data/Mp4_videos";
95 template<
typename PropsT>
98 const std::map<std::string, apra::ScalarPropertyValue>& values,
99 std::vector<std::string>& missingRequired
101 apra::applyProp(props.videoPath,
"videoPath", values,
true, missingRequired);
102 apra::applyProp(props.parseFS,
"parseFS", values,
false, missingRequired);
103 apra::applyProp(props.direction,
"direction", values,
false, missingRequired);
104 apra::applyProp(props.bFramesEnabled,
"bFramesEnabled", values,
false, missingRequired);
105 apra::applyProp(props.reInitInterval,
"reInitInterval", values,
false, missingRequired);
106 apra::applyProp(props.parseFSTimeoutDuration,
"parseFSTimeoutDuration", values,
false, missingRequired);
107 apra::applyProp(props.readLoop,
"readLoop", values,
false, missingRequired);
108 apra::applyProp(props.giveLiveTS,
"giveLiveTS", values,
false, missingRequired);
109 apra::applyProp(props.outputFormat,
"outputFormat", values,
false, missingRequired);
113 if (propName ==
"videoPath")
return videoPath;
114 if (propName ==
"parseFS")
return parseFS;
115 if (propName ==
"direction")
return direction;
117 if (propName ==
"reInitInterval")
return static_cast<int64_t
>(
reInitInterval);
119 if (propName ==
"readLoop")
return readLoop;
120 if (propName ==
"giveLiveTS")
return giveLiveTS;
122 throw std::runtime_error(
"Unknown property: " + propName);
137 template <
class Archive>
140 ar& boost::serialization::base_object<ModuleProps>(*
this);
168 bool randomSeek(uint64_t skipTS,
bool forceReopen =
false);
192 boost::shared_ptr<Mp4ReaderDetailAbs>
mDetail;
CommandType
Definition Command.h:9
virtual size_t getSerializeSize()
Definition Module.h:101
Definition Mp4ReaderSource.cpp:18
Definition Mp4ReaderSource.cpp:1148
Definition Mp4ReaderSource.cpp:1134
Definition Mp4ReaderSource.h:11
bool bFramesEnabled
Definition Mp4ReaderSource.h:82
std::string videoPath
Definition Mp4ReaderSource.h:77
bool readLoop
Definition Mp4ReaderSource.h:85
bool setProperty(const std::string &propName, const apra::ScalarPropertyValue &value)
Definition Mp4ReaderSource.h:125
bool direction
Definition Mp4ReaderSource.h:81
Mp4ReaderSourceProps()
Definition Mp4ReaderSource.h:13
size_t biggerMetadataFrameSize
Definition Mp4ReaderSource.h:79
bool giveLiveTS
Definition Mp4ReaderSource.h:86
std::string skipDir
Definition Mp4ReaderSource.h:76
uint16_t reInitInterval
Definition Mp4ReaderSource.h:83
bool parseFS
Definition Mp4ReaderSource.h:80
size_t getSerializeSize()
Definition Mp4ReaderSource.h:71
void setMaxFrameSizes(size_t _maxImgFrameSize, size_t _maxMetadataFrameSize)
Definition Mp4ReaderSource.h:65
Mp4ReaderSourceProps(std::string _videoPath, bool _parseFS, uint16_t _reInitInterval, bool _direction, bool _readLoop, bool _giveLiveTS, int _parseFSTimeoutDuration=15, bool _bFramesEnabled=false)
Definition Mp4ReaderSource.h:17
std::vector< std::string > dynamicPropertyNames() const
Definition Mp4ReaderSource.h:130
size_t biggerFrameSize
Definition Mp4ReaderSource.h:78
friend class boost::serialization::access
Definition Mp4ReaderSource.h:135
apra::ScalarPropertyValue getProperty(const std::string &propName) const
Definition Mp4ReaderSource.h:112
int parseFSTimeoutDuration
Definition Mp4ReaderSource.h:84
static void applyProperties(PropsT &props, const std::map< std::string, apra::ScalarPropertyValue > &values, std::vector< std::string > &missingRequired)
Definition Mp4ReaderSource.h:96
void serialize(Archive &ar, const unsigned int version)
Definition Mp4ReaderSource.h:138
std::string outputFormat
Definition Mp4ReaderSource.h:90
Definition Mp4ReaderSource.h:155
void setPlaybackSpeed(float _playbckSpeed)
Definition Mp4ReaderSource.cpp:1723
bool changePlayback(float speed, bool direction)
Definition Mp4ReaderSource.cpp:1687
bool getVideoRangeFromCache(std::string videoPath, uint64_t &start_ts, uint64_t &end_ts)
Definition Mp4ReaderSource.cpp:1600
bool refreshCache()
Definition Mp4ReaderSource.cpp:1559
double getOpenVideoDurationInSecs()
Definition Mp4ReaderSource.cpp:1591
std::string getOpenVideoPath()
Definition Mp4ReaderSource.cpp:1564
Mp4ReaderSourceProps props
Definition Mp4ReaderSource.h:193
bool validateOutputPins()
Definition Mp4ReaderSource.cpp:1641
bool handlePropsChange(frame_sp &frame)
Definition Mp4ReaderSource.cpp:1673
bool init()
Definition Mp4ReaderSource.cpp:1500
boost::shared_ptr< Mp4ReaderDetailAbs > mDetail
Definition Mp4ReaderSource.h:192
bool handlePausePlay(float speed, bool direction) override
Definition Mp4ReaderSource.cpp:1709
bool randomSeek(uint64_t skipTS, bool forceReopen=false)
Definition Mp4ReaderSource.cpp:1717
std::string metadataFramePinId
Definition Mp4ReaderSource.h:191
uint32_t mHeight
Definition Mp4ReaderSource.h:190
void setProps(Mp4ReaderSourceProps &props)
Definition Mp4ReaderSource.cpp:1682
Mp4ReaderSourceProps getProps()
Definition Mp4ReaderSource.cpp:1668
bool handleCommand(Command::CommandType type, frame_sp &fame)
Definition Mp4ReaderSource.cpp:1693
std::map< std::string, std::pair< uint64_t, uint64_t > > getCacheSnapShot()
Definition Mp4ReaderSource.cpp:1554
std::string encodedImagePinId
Definition Mp4ReaderSource.h:188
void setImageMetadata(std::string &pinId, framemetadata_sp &metadata)
Definition Mp4ReaderSource.cpp:1547
bool term()
Definition Mp4ReaderSource.cpp:1605
Mp4ReaderSource(Mp4ReaderSourceProps _props)
Definition Mp4ReaderSource.cpp:1476
virtual ~Mp4ReaderSource()
Definition Mp4ReaderSource.cpp:1498
int32_t getOpenVideoFrameCount()
Definition Mp4ReaderSource.cpp:1573
bool produce()
Definition Mp4ReaderSource.cpp:1633
std::string h264ImagePinId
Definition Mp4ReaderSource.h:187
void getResolution(uint32_t &width, uint32_t &height)
Definition Mp4ReaderSource.h:175
double getOpenVideoFPS()
Definition Mp4ReaderSource.cpp:1582
std::string addOutPutPin(framemetadata_sp &metadata)
Definition Mp4ReaderSource.cpp:1612
uint32_t mWidth
Definition Mp4ReaderSource.h:189
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