nx_metadata_sdk 1.0 Metadata SDK

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 <thread>
6 #include <atomic>
7 #include <memory>
8 #include <condition_variable>
9 #include <vector>
10 #include <string>
11 #include <deque>
12
13 #include <nx/sdk/analytics/helpers/consuming_device_agent.h>
14 #include <nx/sdk/analytics/helpers/pixel_format.h>
15 #include <nx/sdk/analytics/helpers/object_metadata_packet.h>
16
17 #include "engine.h"
18 #include "stub_analytics_plugin_diagnostic_events_ini.h"
19
20 namespace nx {
21 namespace vms_server_plugins {
22 namespace analytics {
23 namespace stub {
24 namespace diagnostic_events {
25
26 const std::string kGeneratePluginDiagnosticEventsFromDeviceAgentSetting =
27 "generatePluginDiagnosticEventsFromDeviceAgent";
28
29 class DeviceAgent: public nx::sdk::analytics::ConsumingDeviceAgent
30 {
31 public:
32 DeviceAgent(Engine* engine, const nx::sdk::IDeviceInfo* deviceInfo);
33 virtual ~DeviceAgent() override;
34
35 protected:
36 virtual void doSetNeededMetadataTypes(
37 nx::sdk::Result<void>* outValue,
38 const nx::sdk::analytics::IMetadataTypes* neededMetadataTypes) override;
39
40 virtual std::string manifestString() const override;
41
42 virtual nx::sdk::Result<const nx::sdk::ISettingsResponse*> settingsReceived() override;
43
44 private:
45 void eventThreadLoop();
46 void startEventThread();
47 void stopEventThread();
48
49 void processFrameMotion(
50 nx::sdk::Ptr<nx::sdk::IList<nx::sdk::analytics::IMetadataPacket>> metadataPacketList);
51
52 private:
53 Engine* const m_engine;
54
55 std::unique_ptr<std::thread> m_eventThread;
56 std::mutex m_eventThreadMutex;
57 std::condition_variable m_eventThreadCondition;
58 std::atomic<bool> m_terminated{false};
59
60 struct DeviceAgentSettings
61 {
62 std::atomic<bool> generateEvents{true};
63 };
64
65 DeviceAgentSettings m_deviceAgentSettings;
66 };
67
68 } // namespace diagnostic_events
69 } // namespace stub
70 } // namespace analytics
71 } // namespace vms_server_plugins
72 } // namespace nx
nx::vms_server_plugins::analytics::stub::diagnostic_events::DeviceAgent::settingsReceived
virtual nx::sdk::Result< const nx::sdk::ISettingsResponse * > settingsReceived() override
Definition: device_agent.cpp:61
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::analytics::ConsumingDeviceAgent
Definition: consuming_device_agent.h:38
nx::sdk::analytics::IMetadataTypes
Definition: i_metadata_types.h:13
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::vms_server_plugins::analytics::stub::diagnostic_events::DeviceAgent
Definition: device_agent.h:29
nx::vms_server_plugins::analytics::stub::diagnostic_events::Engine
Definition: engine.h:25
nx::sdk::IList
Definition: i_list.h:9