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 <set>
6 #include <thread>
7
8 #include <nx/sdk/analytics/helpers/consuming_device_agent.h>
9 #include <nx/sdk/helpers/uuid_helper.h>
10
11 #include "engine.h"
12
13 namespace nx {
14 namespace vms_server_plugins {
15 namespace analytics {
16 namespace stub {
17 namespace object_detection {
18
19 class DeviceAgent: public nx::sdk::analytics::ConsumingDeviceAgent
20 {
21 public:
22 static const std::string kTimeShiftSetting;
23 static const std::string kSendAttributesSetting;
24 static const std::string kObjectTypeGenerationSettingPrefix;
25
26 public:
27 DeviceAgent(const nx::sdk::IDeviceInfo* deviceInfo);
28 virtual ~DeviceAgent() override;
29
30 protected:
31 virtual std::string manifestString() const override;
32
33 virtual bool pushCompressedVideoFrame(
34 const nx::sdk::analytics::ICompressedVideoPacket* videoFrame) override;
35
36 virtual void doSetNeededMetadataTypes(
37 nx::sdk::Result<void>* outValue,
38 const nx::sdk::analytics::IMetadataTypes* neededMetadataTypes) override;
39
40 virtual nx::sdk::Result<const nx::sdk::ISettingsResponse*> settingsReceived() override;
41
42 private:
43 nx::sdk::Uuid trackIdByTrackIndex(int trackIndex);
44
45 nx::sdk::Ptr<nx::sdk::analytics::IMetadataPacket> generateObjectMetadataPacket(
46 int64_t frameTimestampUs);
47
48 private:
49 mutable std::mutex m_mutex;
50
51 int m_frameIndex = 0;
52 int m_timestampShiftMs = 0;
53 bool m_sendAttributes = true;
54 std::vector<nx::sdk::Uuid> m_trackIds;
55 std::set<std::string> m_objectTypeIdsToGenerate;
56 };
57
58 } // namespace object_detection
59 } // namespace stub
60 } // namespace analytics
61 } // namespace vms_server_plugins
62 } // namespace nx
nx::sdk::analytics::ICompressedVideoPacket
Definition: i_compressed_video_packet.h:34
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::Uuid
Definition: uuid.h:22
nx::sdk::IDeviceInfo
Definition: i_device_info.h:14
nx::sdk::Result
Definition: result.h:47
nx::vms_server_plugins::analytics::stub::object_detection::DeviceAgent::settingsReceived
virtual nx::sdk::Result< const nx::sdk::ISettingsResponse * > settingsReceived() override
Definition: device_agent.cpp:128
nx
Definition: apple_utils.h:6
nx::vms_server_plugins::analytics::stub::object_detection::DeviceAgent::pushCompressedVideoFrame
virtual bool pushCompressedVideoFrame(const nx::sdk::analytics::ICompressedVideoPacket *videoFrame) override
Definition: device_agent.cpp:108
nx::vms_server_plugins::analytics::stub::object_detection::DeviceAgent
Definition: device_agent.h:19