nx_server_plugin_sdk 1.0 Server Plugin 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 <atomic>
6 #include <condition_variable>
7 #include <deque>
8 #include <memory>
9 #include <string>
10 #include <thread>
11 #include <vector>
12
13 #include <nx/sdk/analytics/helpers/consuming_device_agent.h>
14 #include <nx/sdk/analytics/helpers/object_metadata_packet.h>
15 #include <nx/sdk/analytics/helpers/pixel_format.h>
16
17 #include "engine.h"
18 #include "stub_analytics_integration_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 kGenerateIntegrationDiagnosticEventsFromDeviceAgentSetting =
27 "generateIntegrationDiagnosticEventsFromDeviceAgent";
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 std::string manifestString() const override;
37
38 virtual nx::sdk::Result<const nx::sdk::ISettingsResponse*> settingsReceived() override;
39
40 private:
41 void eventThreadLoop();
42 void startEventThread();
43 void stopEventThread();
44
45 void processFrameMotion(
46 nx::sdk::Ptr<nx::sdk::IList<nx::sdk::analytics::IMetadataPacket>> metadataPacketList);
47
48 private:
49 Engine* const m_engine;
50
51 std::unique_ptr<std::thread> m_eventThread;
52 std::mutex m_eventThreadMutex;
53 std::condition_variable m_eventThreadCondition;
54 std::atomic<bool> m_stopping{false};
55 std::atomic<bool> m_terminated{false};
56
57 struct DeviceAgentSettings
58 {
59 std::atomic<bool> generateEvents{true};
60 };
61
62 DeviceAgentSettings m_deviceAgentSettings;
63 };
64
65 } // namespace diagnostic_events
66 } // namespace stub
67 } // namespace analytics
68 } // namespace vms_server_plugins
69 } // 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:62
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::analytics::ConsumingDeviceAgent
Definition: consuming_device_agent.h:36
nx::sdk::IDeviceInfo
Definition: i_device_info.h:13
nx::sdk::Result
Definition: result.h:52
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:10