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 <map>
6 #include <mutex>
7 #include <string>
8 #include <vector>
9
10 #include <nx/sdk/analytics/i_compound_metadata_packet.h>
11 #include <nx/sdk/analytics/i_compressed_video_packet.h>
12 #include <nx/sdk/analytics/i_consuming_device_agent.h>
13 #include <nx/sdk/analytics/i_custom_metadata_packet.h>
14 #include <nx/sdk/analytics/i_engine.h>
15 #include <nx/sdk/analytics/i_metadata_types.h>
16 #include <nx/sdk/analytics/i_uncompressed_video_frame.h>
17 #include <nx/sdk/helpers/log_utils.h>
18 #include <nx/sdk/helpers/ref_countable.h>
19 #include <nx/sdk/ptr.h>
20
21 namespace nx::sdk::analytics {
22
36 class ConsumingDeviceAgent: public RefCountable<IConsumingDeviceAgent>
37 {
38 protected:
39 const LogUtils logUtils;
40
41 protected:
46 ConsumingDeviceAgent(
47 const IDeviceInfo* deviceInfo,
48 bool enableOutput,
49 const std::string& pluginInstanceId = "");
50
51 virtual std::string manifestString() const = 0;
52
58 virtual bool pushCompressedVideoFrame(const ICompressedVideoPacket* videoFrame);
59
64 virtual bool pushUncompressedVideoFrame(const IUncompressedVideoFrame* videoFrame);
65
70 virtual bool pushCustomMetadataPacket(const ICustomMetadataPacket* /*customMetadataPacket*/)
71 {
72 return true;
73 }
74
81 virtual bool pullMetadataPackets(std::vector<IMetadataPacket*>* metadataPackets);
82
87 void pushMetadataPacket(IMetadataPacket* metadataPacket);
88
94 void pushPluginDiagnosticEvent(
95 IPluginDiagnosticEvent::Level level,
96 std::string caption,
97 std::string description) const;
98
104 virtual nx::sdk::Result<const nx::sdk::ISettingsResponse*> settingsReceived()
105 {
106 return nullptr;
107 }
108
118 std::string settingValue(const std::string& settingName) const;
119
120 std::map<std::string, std::string> currentSettings() const;
121
122 void pushManifest(const std::string& pushManifest);
123
124 virtual void finalize() override;
125
126 virtual void doGetSettingsOnActiveSettingChange(
127 Result<const IActiveSettingChangedResponse*>* outResult,
128 const IActiveSettingChangedAction* activeSettingChangedAction) override;
129
130 public:
131 virtual ~ConsumingDeviceAgent() override;
132
133 //-------------------------------------------------------------------------------------------------
134 // Not intended to be used by the descendant.
135
136 public:
137 virtual void setHandler(IHandler* handler) override;
138
139 protected:
140 virtual void doPushDataPacket(Result<void>* outResult, IDataPacket* dataPacket) override;
141 virtual void doSetSettings(
142 Result<const ISettingsResponse*>* outResult, const IStringMap* settings) override;
143 virtual void getPluginSideSettings(Result<const ISettingsResponse*>* outResult) const override;
144 virtual void getManifest(Result<const IString*>* outResult) const override;
145
146 private:
147 void logMetadataPacketIfNeeded(
148 const IMetadataPacket* metadataPacket,
149 int packetIndex) const;
150 void processMetadataPackets(const std::vector<IMetadataPacket*>& metadataPackets);
151 void processMetadataPacket(IMetadataPacket* metadataPacket, int packetIndex /*= -1*/);
152
153 private:
154 mutable std::mutex m_mutex;
155 Ptr<IDeviceAgent::IHandler> m_handler;
156 std::map<std::string, std::string> m_settings;
157 };
158
159 } // namespace nx::sdk::analytics
nx::sdk::IStringMap
Definition: i_string_map.h:9
nx::sdk::analytics::IMetadataPacket
Definition: i_metadata_packet.h:13
nx::sdk::IActiveSettingChangedAction
Definition: i_active_setting_changed_action.h:14
nx::sdk::analytics::ConsumingDeviceAgent::pullMetadataPackets
virtual bool pullMetadataPackets(std::vector< IMetadataPacket *> *metadataPackets)
Definition: consuming_device_agent.cpp:62
nx::sdk::analytics::ConsumingDeviceAgent::pushPluginDiagnosticEvent
void pushPluginDiagnosticEvent(IPluginDiagnosticEvent::Level level, std::string caption, std::string description) const
Definition: consuming_device_agent.cpp:215
nx::sdk::analytics::ICompressedVideoPacket
Definition: i_compressed_video_packet.h:31
nx::sdk::analytics::ConsumingDeviceAgent::pushCompressedVideoFrame
virtual bool pushCompressedVideoFrame(const ICompressedVideoPacket *videoFrame)
Definition: consuming_device_agent.cpp:50
nx::sdk::analytics::ConsumingDeviceAgent::settingValue
std::string settingValue(const std::string &settingName) const
Definition: consuming_device_agent.cpp:237
nx::sdk::analytics::ConsumingDeviceAgent::pushUncompressedVideoFrame
virtual bool pushUncompressedVideoFrame(const IUncompressedVideoFrame *videoFrame)
Definition: consuming_device_agent.cpp:56
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::analytics::ConsumingDeviceAgent::pushCustomMetadataPacket
virtual bool pushCustomMetadataPacket(const ICustomMetadataPacket *)
Definition: consuming_device_agent.h:70
nx::sdk::analytics::ConsumingDeviceAgent::ConsumingDeviceAgent
ConsumingDeviceAgent(const IDeviceInfo *deviceInfo, bool enableOutput, const std::string &pluginInstanceId="")
Definition: consuming_device_agent.cpp:36
nx::sdk::analytics::ConsumingDeviceAgent
Definition: consuming_device_agent.h:36
nx::sdk::analytics
Definition: consuming_device_agent.cpp:24
nx::sdk::Result< void >
Definition: result.h:82
nx::sdk::IDeviceInfo
Definition: i_device_info.h:13
nx::sdk::Result
Definition: result.h:48
nx::sdk::analytics::ICustomMetadataPacket
Definition: i_custom_metadata_packet.h:13
nx::sdk::LogUtils
Definition: log_utils.h:27
nx::sdk::analytics::IUncompressedVideoFrame
Definition: i_uncompressed_video_frame.h:70
nx::sdk::analytics::IDataPacket
Definition: i_data_packet.h:15
nx::sdk::analytics::ConsumingDeviceAgent::settingsReceived
virtual nx::sdk::Result< const nx::sdk::ISettingsResponse * > settingsReceived()
Definition: consuming_device_agent.h:104
nx::sdk::RefCountable
Definition: ref_countable.h:83
nx::sdk::analytics::ConsumingDeviceAgent::pushMetadataPacket
void pushMetadataPacket(IMetadataPacket *metadataPacket)
Definition: consuming_device_agent.cpp:207