stub_analytics_plugin  1.6
Network Optix Video Analytics SDK
common_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 <plugins/plugin_tools.h>
9 #include <nx/sdk/utils.h>
10 
11 #include <nx/sdk/analytics/engine.h>
12 #include <nx/sdk/analytics/consuming_device_agent.h>
13 #include <nx/sdk/analytics/objects_metadata_packet.h>
14 #include <nx/sdk/analytics/compressed_video_packet.h>
15 #include <nx/sdk/analytics/uncompressed_video_frame.h>
16 
17 namespace nx {
18 namespace sdk {
19 namespace analytics {
20 
34  public nxpt::CommonRefCounter<ConsumingDeviceAgent>
35 {
36 protected:
37  const nx::sdk::Utils utils;
38 
39 protected:
46  Engine* engine,
47  bool enableOutput,
48  const std::string& printPrefix = "");
49 
50  virtual std::string manifest() const = 0;
51 
59  virtual bool pushCompressedVideoFrame(const CompressedVideoPacket* /*videoFrame*/)
60  {
61  return true;
62  }
63 
70  virtual bool pushUncompressedVideoFrame(const UncompressedVideoFrame* /*videoFrame*/)
71  {
72  return true;
73  }
74 
81  virtual bool pullMetadataPackets(std::vector<MetadataPacket*>* /*metadataPackets*/)
82  {
83  return true;
84  }
85 
90  void pushMetadataPacket(MetadataPacket* metadataPacket);
91 
96  void pushPluginEvent(IPluginEvent::Level level, std::string caption, std::string description);
97 
102  virtual void settingsReceived() {}
103 
111  std::string getParamValue(const char* paramName);
112 
113  virtual Error setNeededMetadataTypes(const IMetadataTypes* metadataTypes) override = 0;
114 
115 public:
116  virtual ~CommonVideoFrameProcessingDeviceAgent() override;
117 
122  template<typename DerivedEngine>
123  DerivedEngine* engineCasted() const
124  {
125  const auto engine = dynamic_cast<DerivedEngine*>(m_engine);
126  assertEngineCasted(engine);
127  return engine;
128  }
129 
130  virtual Engine* engine() const override { return m_engine; }
131 
132 //-------------------------------------------------------------------------------------------------
133 // Not intended to be used by the descendant.
134 
135 public:
136  virtual void* queryInterface(const nxpl::NX_GUID& interfaceId) override;
137  virtual Error setHandler(DeviceAgent::IHandler* handler) override;
138  virtual Error pushDataPacket(DataPacket* dataPacket) override;
139  virtual const IString* manifest(Error* error) const override;
140  virtual void setSettings(const nx::sdk::Settings* settings) override;
141  virtual nx::sdk::Settings* pluginSideSettings() const override;
142 
143 private:
144  void assertEngineCasted(void* engine) const;
145 
146 private:
147  mutable std::mutex m_mutex;
148  Engine* const m_engine;
149  DeviceAgent::IHandler* m_handler = nullptr;
150  std::map<std::string, std::string> m_settings;
151 };
152 
153 } // namespace analytics
154 } // namespace sdk
155 } // namespace nx
void pushPluginEvent(IPluginEvent::Level level, std::string caption, std::string description)
Definition: common_video_frame_processing_device_agent.cpp:216
CommonVideoFrameProcessingDeviceAgent(Engine *engine, bool enableOutput, const std::string &printPrefix="")
Definition: common_video_frame_processing_device_agent.cpp:39
void pushMetadataPacket(MetadataPacket *metadataPacket)
Definition: common_video_frame_processing_device_agent.cpp:193
virtual bool pushCompressedVideoFrame(const CompressedVideoPacket *)
Definition: common_video_frame_processing_device_agent.h:59
Definition: utils.h:25
Definition: compressed_video_packet.h:16
GUID of plugin interface.
Definition: plugin_api.h:21
Definition: common_video_frame_processing_device_agent.h:33
virtual bool pullMetadataPackets(std::vector< MetadataPacket *> *)
Definition: common_video_frame_processing_device_agent.h:81
Definition: metadata_types.h:13
virtual void settingsReceived()
Definition: common_video_frame_processing_device_agent.h:102
Definition: plugin_tools.h:221
Definition: i_string.h:15
std::string getParamValue(const char *paramName)
Definition: common_video_frame_processing_device_agent.cpp:237
virtual bool pushUncompressedVideoFrame(const UncompressedVideoFrame *)
Definition: common_video_frame_processing_device_agent.h:70
Definition: metadata_packet.h:21
Definition: uncompressed_video_frame.h:17
Definition: debug.cpp:14
DerivedEngine * engineCasted() const
Definition: common_video_frame_processing_device_agent.h:123
Definition: engine.h:37
Definition: settings.h:15