nx_metadata_sdk 1.0 Metadata SDK

consuming_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 #include <nx/sdk/analytics/i_custom_metadata_packet.h>
21
22 namespace nx {
23 namespace sdk {
24 namespace analytics {
25
38 class ConsumingDeviceAgent: public RefCountable<IConsumingDeviceAgent>
39 {
40 protected:
41 const LogUtils logUtils;
42
43 protected:
48 ConsumingDeviceAgent(
49 const IDeviceInfo* deviceInfo,
50 bool enableOutput,
51 const std::string& pluginInstanceId = "");
52
53 virtual std::string manifestString() const = 0;
54
60 virtual bool pushCompressedVideoFrame(const ICompressedVideoPacket* videoFrame);
61
66 virtual bool pushUncompressedVideoFrame(const IUncompressedVideoFrame* videoFrame);
67
72 virtual bool pushCustomMetadataPacket(const ICustomMetadataPacket* /*customMetadataPacket*/)
73 {
74 return true;
75 }
76
83 virtual bool pullMetadataPackets(std::vector<IMetadataPacket*>* metadataPackets);
84
89 void pushMetadataPacket(IMetadataPacket* metadataPacket);
90
96 void pushPluginDiagnosticEvent(
97 IPluginDiagnosticEvent::Level level,
98 std::string caption,
99 std::string description);
100
106 virtual nx::sdk::Result<const nx::sdk::ISettingsResponse*> settingsReceived()
107 {
108 return nullptr;
109 }
110
120 std::string settingValue(const std::string& settingName) const;
121
122 std::map<std::string, std::string> currentSettings() const;
123
124 void pushManifest(const std::string& pushManifest);
125
126 virtual void finalize() override;
127
128 public:
129 virtual ~ConsumingDeviceAgent() override;
130
131 //-------------------------------------------------------------------------------------------------
132 // Not intended to be used by the descendant.
133
134 public:
135 virtual void setHandler(IHandler* handler) override;
136
137 protected:
138 virtual void doPushDataPacket(Result<void>* outResult, IDataPacket* dataPacket) override;
139 virtual void doSetSettings(
140 Result<const ISettingsResponse*>* outResult, const IStringMap* settings) override;
141 virtual void getPluginSideSettings(Result<const ISettingsResponse*>* outResult) const override;
142 virtual void getManifest(Result<const IString*>* outResult) const override;
143
144 private:
145 void logMetadataPacketIfNeeded(
146 const IMetadataPacket* metadataPacket,
147 int packetIndex) const;
148 void processMetadataPackets(const std::vector<IMetadataPacket*>& metadataPackets);
149 void processMetadataPacket(IMetadataPacket* metadataPacket, int packetIndex /*= -1*/);
150
151 private:
152 mutable std::mutex m_mutex;
153 Ptr<IDeviceAgent::IHandler> m_handler;
154 std::map<std::string, std::string> m_settings;
155 };
156
157 } // namespace analytics
158 } // namespace sdk
159 } // namespace nx
nx::sdk::IStringMap
Definition: i_string_map.h:10
nx::sdk::analytics::IMetadataPacket
Definition: i_metadata_packet.h:16
nx::sdk::analytics::ConsumingDeviceAgent::pullMetadataPackets
virtual bool pullMetadataPackets(std::vector< IMetadataPacket *> *metadataPackets)
Definition: consuming_device_agent.cpp:61
nx::sdk::analytics::ICompressedVideoPacket
Definition: i_compressed_video_packet.h:34
nx::sdk::analytics::ConsumingDeviceAgent::pushCompressedVideoFrame
virtual bool pushCompressedVideoFrame(const ICompressedVideoPacket *videoFrame)
Definition: consuming_device_agent.cpp:49
nx::sdk::analytics::ConsumingDeviceAgent::settingValue
std::string settingValue(const std::string &settingName) const
Definition: consuming_device_agent.cpp:230
nx::sdk::analytics::ConsumingDeviceAgent::pushUncompressedVideoFrame
virtual bool pushUncompressedVideoFrame(const IUncompressedVideoFrame *videoFrame)
Definition: consuming_device_agent.cpp:55
nx::sdk::analytics::ConsumingDeviceAgent::pushPluginDiagnosticEvent
void pushPluginDiagnosticEvent(IPluginDiagnosticEvent::Level level, std::string caption, std::string description)
Definition: consuming_device_agent.cpp:208
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::analytics::ConsumingDeviceAgent::pushCustomMetadataPacket
virtual bool pushCustomMetadataPacket(const ICustomMetadataPacket *)
Definition: consuming_device_agent.h:72
nx::sdk::analytics::ConsumingDeviceAgent::ConsumingDeviceAgent
ConsumingDeviceAgent(const IDeviceInfo *deviceInfo, bool enableOutput, const std::string &pluginInstanceId="")
Definition: consuming_device_agent.cpp:35
nx::sdk::analytics::ConsumingDeviceAgent
Definition: consuming_device_agent.h:38
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::analytics::ICustomMetadataPacket
Definition: i_custom_metadata_packet.h:16
nx::sdk::LogUtils
Definition: log_utils.h:26
nx::sdk::analytics::IUncompressedVideoFrame
Definition: i_uncompressed_video_frame.h:73
nx::sdk::analytics::IDataPacket
Definition: i_data_packet.h:17
nx::sdk::analytics::ConsumingDeviceAgent::settingsReceived
virtual nx::sdk::Result< const nx::sdk::ISettingsResponse * > settingsReceived()
Definition: consuming_device_agent.h:106
nx::sdk::RefCountable
Definition: ref_countable.h:84
nx::sdk::analytics::ConsumingDeviceAgent::pushMetadataPacket
void pushMetadataPacket(IMetadataPacket *metadataPacket)
Definition: consuming_device_agent.cpp:200