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_terminated{false};
55
56 struct DeviceAgentSettings
57 {
58 std::atomic<bool> generateEvents{true};
59 };
60
61 DeviceAgentSettings m_deviceAgentSettings;
62 };
63
64 } // namespace diagnostic_events
65 } // namespace stub
66 } // namespace analytics
67 } // namespace vms_server_plugins
68 } // 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