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 <vector>
6
7 #include <nx/sdk/analytics/helpers/consuming_device_agent.h>
8 #include <nx/sdk/analytics/i_object_metadata_packet.h>
9
10 #include "engine.h"
11
12 namespace nx::vms_server_plugins::analytics::stub::http_requests {
13
14 class DeviceAgent: public nx::sdk::analytics::ConsumingDeviceAgent
15 {
16 public:
17 DeviceAgent(Engine* engine, const nx::sdk::IDeviceInfo* deviceInfo);
18 virtual ~DeviceAgent() override;
19
20 protected:
21 virtual std::string manifestString() const override;
22
23 virtual bool pushCompressedVideoFrame(
24 nx::sdk::Ptr<const nx::sdk::analytics::ICompressedVideoPacket> videoFrame) override;
25
26 virtual nx::sdk::Result<const nx::sdk::ISettingsResponse*> settingsReceived() override;
27
28 private:
29 struct HttpRequestContext
30 {
31 nx::sdk::IUtilityProvider4::HttpDomainName domain =
32 nx::sdk::IUtilityProvider4::HttpDomainName::vms;
33 std::string url = "/rest/v4/site/settings";
34 std::string httpMethod = "GET";
35 std::string mimeType;
36 std::string requestBody;
37 int64_t periodSeconds = 1;
38 };
39
40 private:
41 int64_t m_lastFrameTimestampUs = 0;
42 int64_t m_lastEventTimestampUs = 0;
43 HttpRequestContext m_requestContext;
44 Engine* const m_engine;
45 };
46
47 } // namespace nx::vms_server_plugins::analytics::stub::http_requests
nx::vms_server_plugins::analytics::stub::http_requests::Engine
Definition: engine.h:10
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::analytics::ConsumingDeviceAgent
Definition: consuming_device_agent.h:36
nx::vms_server_plugins::analytics::stub::http_requests::DeviceAgent::settingsReceived
virtual nx::sdk::Result< const nx::sdk::ISettingsResponse * > settingsReceived() override
Definition: device_agent.cpp:126
nx::vms_server_plugins::analytics::stub::http_requests
Definition: device_agent.cpp:19
nx::sdk::IDeviceInfo
Definition: i_device_info.h:13
nx::vms_server_plugins::analytics::stub::http_requests::DeviceAgent
Definition: device_agent.h:14
nx::vms_server_plugins::analytics::stub::http_requests::DeviceAgent::pushCompressedVideoFrame
virtual bool pushCompressedVideoFrame(nx::sdk::Ptr< const nx::sdk::analytics::ICompressedVideoPacket > videoFrame) override
Definition: device_agent.cpp:97
nx::sdk::Result
Definition: result.h:52