stub_analytics_plugin  1.6
Network Optix Video Analytics SDK
video_frame_processing_device_agent.h
1 #pragma once
2 
3 #include <string>
4 #include <map>
5 #include <vector>
6 #include <mutex>
7 
8 #include <nx/sdk/helpers/ref_countable.h>
9 #include <nx/sdk/helpers/log_utils.h>
10 
11 #include <nx/sdk/analytics/i_engine.h>
12 #include <nx/sdk/analytics/i_consuming_device_agent.h>
13 #include <nx/sdk/analytics/i_metadata_packet.h>
14 #include <nx/sdk/analytics/i_metadata_types.h>
15 #include <nx/sdk/analytics/i_compressed_video_packet.h>
16 #include <nx/sdk/analytics/i_uncompressed_video_frame.h>
17 
18 namespace nx {
19 namespace sdk {
20 namespace analytics {
21 
34 class VideoFrameProcessingDeviceAgent: public RefCountable<IConsumingDeviceAgent>
35 {
36 protected:
37  const LogUtils logUtils;
38 
39 protected:
46  IEngine* engine,
47  const IDeviceInfo* deviceInfo,
48  bool enableOutput,
49  const std::string& printPrefix = "");
50 
51  virtual std::string manifest() const = 0;
52 
60  virtual bool pushCompressedVideoFrame(const ICompressedVideoPacket* /*videoFrame*/)
61  {
62  return true;
63  }
64 
71  virtual bool pushUncompressedVideoFrame(const IUncompressedVideoFrame* /*videoFrame*/)
72  {
73  return true;
74  }
75 
82  virtual bool pullMetadataPackets(std::vector<IMetadataPacket*>* /*metadataPackets*/)
83  {
84  return true;
85  }
86 
91  void pushMetadataPacket(IMetadataPacket* metadataPacket);
92 
97  void pushPluginEvent(IPluginEvent::Level level, std::string caption, std::string description);
98 
103  virtual void settingsReceived() {}
104 
112  std::string getParamValue(const char* paramName);
113 
114  virtual Error setNeededMetadataTypes(const IMetadataTypes* metadataTypes) override = 0;
115 
116 public:
117  virtual ~VideoFrameProcessingDeviceAgent() override;
118 
123  template<typename DerivedEngine>
124  DerivedEngine* engineCasted() const
125  {
126  const auto engine = dynamic_cast<DerivedEngine*>(m_engine);
127  assertEngineCasted(engine);
128  return engine;
129  }
130 
131  virtual IEngine* engine() const override { return m_engine; }
132 
133 //-------------------------------------------------------------------------------------------------
134 // Not intended to be used by the descendant.
135 
136 public:
137  virtual Error setHandler(IDeviceAgent::IHandler* handler) override;
138  virtual Error pushDataPacket(IDataPacket* dataPacket) override;
139  virtual const IString* manifest(Error* error) const override;
140  virtual void setSettings(const IStringMap* settings) override;
141  virtual IStringMap* pluginSideSettings() const override;
142 
143 private:
144  void assertEngineCasted(void* engine) const;
145  void processMetadataPackets(const std::vector<IMetadataPacket*>& metadataPackets);
146  void processMetadataPacket(IMetadataPacket* metadataPacket, int packetIndex /*= -1*/);
147 
148 private:
149  mutable std::mutex m_mutex;
150  IEngine* const m_engine;
151  IDeviceAgent::IHandler* m_handler = nullptr;
152  std::map<std::string, std::string> m_settings;
153 };
154 
155 } // namespace analytics
156 } // namespace sdk
157 } // namespace nx
void pushMetadataPacket(IMetadataPacket *metadataPacket)
Definition: video_frame_processing_device_agent.cpp:221
Definition: i_string_map.h:8
Definition: i_metadata_packet.h:17
virtual bool pullMetadataPackets(std::vector< IMetadataPacket *> *)
Definition: video_frame_processing_device_agent.h:82
VideoFrameProcessingDeviceAgent(IEngine *engine, const IDeviceInfo *deviceInfo, bool enableOutput, const std::string &printPrefix="")
Definition: video_frame_processing_device_agent.cpp:50
virtual bool pushUncompressedVideoFrame(const IUncompressedVideoFrame *)
Definition: video_frame_processing_device_agent.h:71
Definition: i_compressed_video_packet.h:14
std::string getParamValue(const char *paramName)
Definition: video_frame_processing_device_agent.cpp:248
Definition: i_engine.h:31
Definition: i_metadata_types.h:11
Definition: i_string.h:8
Definition: i_device_info.h:12
Definition: debug.cpp:12
Definition: log_utils.h:24
virtual void settingsReceived()
Definition: video_frame_processing_device_agent.h:103
Definition: video_frame_processing_device_agent.h:34
DerivedEngine * engineCasted() const
Definition: video_frame_processing_device_agent.h:124
virtual bool pushCompressedVideoFrame(const ICompressedVideoPacket *)
Definition: video_frame_processing_device_agent.h:60
Definition: i_uncompressed_video_frame.h:11
void pushPluginEvent(IPluginEvent::Level level, std::string caption, std::string description)
Definition: video_frame_processing_device_agent.cpp:229
Definition: ref_countable.h:79