nx_metadata_sdk 1.0 Metadata SDK

video_frame_processing_device_agent.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2
3 #pragma once
4
5 #include <string>
6 #include <map>
7 #include <vector>
8 #include <mutex>
9
10 #include <nx/sdk/helpers/ref_countable.h>
11 #include <nx/sdk/helpers/log_utils.h>
12 #include <nx/sdk/ptr.h>
13
14 #include <nx/sdk/analytics/i_engine.h>
15 #include <nx/sdk/analytics/i_consuming_device_agent.h>
16 #include <nx/sdk/analytics/i_compound_metadata_packet.h>
17 #include <nx/sdk/analytics/i_metadata_types.h>
18 #include <nx/sdk/analytics/i_compressed_video_packet.h>
19 #include <nx/sdk/analytics/i_uncompressed_video_frame.h>
20
21 namespace nx {
22 namespace sdk {
23 namespace analytics {
24
37 class VideoFrameProcessingDeviceAgent: public RefCountable<IConsumingDeviceAgent>
38 {
39 protected:
40 const LogUtils logUtils;
41
42 protected:
46 VideoFrameProcessingDeviceAgent(const IDeviceInfo* deviceInfo, bool enableOutput);
47
48 virtual std::string manifestString() const = 0;
49
55 virtual bool pushCompressedVideoFrame(const ICompressedVideoPacket* /*videoFrame*/)
56 {
57 return true;
58 }
59
64 virtual bool pushUncompressedVideoFrame(const IUncompressedVideoFrame* /*videoFrame*/)
65 {
66 return true;
67 }
68
75 virtual bool pullMetadataPackets(std::vector<IMetadataPacket*>* /*metadataPackets*/)
76 {
77 return true;
78 }
79
84 void pushMetadataPacket(IMetadataPacket* metadataPacket);
85
91 void pushPluginDiagnosticEvent(
92 IPluginDiagnosticEvent::Level level,
93 std::string caption,
94 std::string description);
95
101 virtual nx::sdk::Result<const nx::sdk::IStringMap*> settingsReceived() { return nullptr; }
102
112 std::string settingValue(const std::string& paramName);
113
114 public:
115 virtual ~VideoFrameProcessingDeviceAgent() override;
116
117 //-------------------------------------------------------------------------------------------------
118 // Not intended to be used by the descendant.
119
120 public:
121 virtual void setHandler(IHandler* handler) override;
122
123 protected:
124 virtual void doPushDataPacket(Result<void>* outResult, IDataPacket* dataPacket) override;
125 virtual void doSetSettings(
126 Result<const IStringMap*>* outResult, const IStringMap* settings) override;
127 virtual void getPluginSideSettings(Result<const ISettingsResponse*>* outResult) const override;
128 virtual void getManifest(Result<const IString*>* outResult) const override;
129
130 private:
131 void logMetadataPacketIfNeeded(
132 const IMetadataPacket* metadataPacket,
133 const std::string& packetIndexName) const;
134 void processMetadataPackets(const std::vector<IMetadataPacket*>& metadataPackets);
135 void processMetadataPacket(IMetadataPacket* metadataPacket, int packetIndex /*= -1*/);
136
137 private:
138 mutable std::mutex m_mutex;
139 Ptr<IDeviceAgent::IHandler> m_handler;
140 std::map<std::string, std::string> m_settings;
141 };
142
143 } // namespace analytics
144 } // namespace sdk
145 } // namespace nx
nx::sdk::analytics::VideoFrameProcessingDeviceAgent::pushMetadataPacket
void pushMetadataPacket(IMetadataPacket *metadataPacket)
Definition: video_frame_processing_device_agent.cpp:166
nx::sdk::IStringMap
Definition: i_string_map.h:10
nx::sdk::analytics::IMetadataPacket
Definition: i_metadata_packet.h:16
nx::sdk::analytics::VideoFrameProcessingDeviceAgent::pullMetadataPackets
virtual bool pullMetadataPackets(std::vector< IMetadataPacket *> *)
Definition: video_frame_processing_device_agent.h:75
nx::sdk::analytics::VideoFrameProcessingDeviceAgent::pushUncompressedVideoFrame
virtual bool pushUncompressedVideoFrame(const IUncompressedVideoFrame *)
Definition: video_frame_processing_device_agent.h:64
nx::sdk::analytics::ICompressedVideoPacket
Definition: i_compressed_video_packet.h:16
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::analytics::VideoFrameProcessingDeviceAgent::pushPluginDiagnosticEvent
void pushPluginDiagnosticEvent(IPluginDiagnosticEvent::Level level, std::string caption, std::string description)
Definition: video_frame_processing_device_agent.cpp:174
nx::sdk::analytics::VideoFrameProcessingDeviceAgent::settingsReceived
virtual nx::sdk::Result< const nx::sdk::IStringMap * > settingsReceived()
Definition: video_frame_processing_device_agent.h:101
nx::sdk::Result< void >
Definition: result.h:81
nx::sdk::IDeviceInfo
Definition: i_device_info.h:14
nx::sdk::Result
Definition: result.h:47
nx
Definition: apple_utils.h:6
nx::sdk::LogUtils
Definition: log_utils.h:26
nx::sdk::analytics::VideoFrameProcessingDeviceAgent::settingValue
std::string settingValue(const std::string &paramName)
Definition: video_frame_processing_device_agent.cpp:193
nx::sdk::analytics::VideoFrameProcessingDeviceAgent
Definition: video_frame_processing_device_agent.h:37
nx::sdk::analytics::VideoFrameProcessingDeviceAgent::pushCompressedVideoFrame
virtual bool pushCompressedVideoFrame(const ICompressedVideoPacket *)
Definition: video_frame_processing_device_agent.h:55
nx::sdk::analytics::IUncompressedVideoFrame
Definition: i_uncompressed_video_frame.h:13
nx::sdk::analytics::IDataPacket
Definition: i_data_packet.h:16
nx::sdk::analytics::VideoFrameProcessingDeviceAgent::VideoFrameProcessingDeviceAgent
VideoFrameProcessingDeviceAgent(const IDeviceInfo *deviceInfo, bool enableOutput)
Definition: video_frame_processing_device_agent.cpp:31
nx::sdk::RefCountable
Definition: ref_countable.h:84