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
7 #include <nx/kit/json.h>
8 #include <nx/sdk/analytics/helpers/consuming_device_agent.h>
9 #include <nx/sdk/analytics/i_object_metadata_packet.h>
10
11 #include "stream_parser.h"
12
13 namespace nx {
14 namespace vms_server_plugins {
15 namespace analytics {
16 namespace stub {
17 namespace object_streamer {
18
19 class DeviceAgent: public nx::sdk::analytics::ConsumingDeviceAgent
20 {
21 public:
22 DeviceAgent(const nx::sdk::IDeviceInfo* deviceInfo, std::string pluginHomeDir);
23 virtual ~DeviceAgent() override;
24
25 protected:
26 virtual std::string manifestString() const override;
27
28 virtual bool pushCompressedVideoFrame(
29 const nx::sdk::analytics::ICompressedVideoPacket* videoFrame) override;
30
31 virtual void doSetNeededMetadataTypes(
32 nx::sdk::Result<void>* outValue,
33 const nx::sdk::analytics::IMetadataTypes* neededMetadataTypes) override;
34
35 virtual nx::sdk::Result<const nx::sdk::ISettingsResponse*> settingsReceived() override;
36
37 private:
38 std::vector<nx::sdk::Ptr<nx::sdk::analytics::IMetadataPacket>> generateMetadata(
39 int frameNumber,
40 int64_t frameTimestampUs,
41 int64_t durationUs);
42
43 nx::sdk::Uuid obtainObjectTrackIdFromRef(const std::string& objectTrackIdRef);
44
45 sdk::Ptr<sdk::ISettingsResponse> makeSettingsResponse(
46 const std::string& manifestFilePath,
47 const std::string& streamFilePath) const;
48
49 void reportIssues(const Issues& issues) const;
50
51 private:
52 StreamInfo m_streamInfo;
53 std::set<std::string> m_disabledObjectTypeIds;
54 int m_frameNumber = 0;
55 int m_maxFrameNumber = 0;
56 std::map<std::string, nx::sdk::Uuid> m_trackIdByRef;
57
58 int64_t m_lastFrameTimestampUs = -1;
59 std::string m_pluginHomeDir;
60 bool m_isInitialSettings = true;
61 };
62
63 } // namespace object_streamer
64 } // namespace stub
65 } // namespace analytics
66 } // namespace vms_server_plugins
67 } // namespace nx
nx::vms_server_plugins::analytics::stub::object_streamer::StreamInfo
Definition: stream_parser.h:70
nx::vms_server_plugins::analytics::stub::object_streamer::DeviceAgent::settingsReceived
virtual nx::sdk::Result< const nx::sdk::ISettingsResponse * > settingsReceived() override
Definition: device_agent.cpp:185
nx::sdk::analytics::ICompressedVideoPacket
Definition: i_compressed_video_packet.h:31
nx::sdk::Ptr
Definition: ptr.h:18
nx::vms_server_plugins::analytics::stub::object_streamer::DeviceAgent
Definition: device_agent.h:19
json.h
nx::sdk::analytics::ConsumingDeviceAgent
Definition: consuming_device_agent.h:36
nx::sdk::analytics::IMetadataTypes
Definition: i_metadata_types.h:10
nx::sdk::Result< void >
Definition: result.h:82
nx::sdk::Uuid
Definition: uuid.h:22
nx::sdk::IDeviceInfo
Definition: i_device_info.h:13
nx::vms_server_plugins::analytics::stub::object_streamer::Issues
Definition: stream_parser.h:64
nx::sdk::Result
Definition: result.h:48
nx
Definition: apple_utils.h:6
nx::vms_server_plugins::analytics::stub::object_streamer::DeviceAgent::pushCompressedVideoFrame
virtual bool pushCompressedVideoFrame(const nx::sdk::analytics::ICompressedVideoPacket *videoFrame) override
Definition: device_agent.cpp:50