This article explains how the Server interacts with integrations, manages their lifecycle, and handles data flow.
Integration initialization
The Server loads the integrations dynamic library and calls its entry point function,
createNxIntegration()(defined ini_integration.h). This function returns a pointer to thenx::sdk::IIntegrationinterface instance.-
The Server creates an
Engineinstance by passing this pointer toIIntegration::createEngine().createEngine()calls thedoCreateEngine()virtual method of the interface class, which is implemented in theIntegrationhelper class.doCreateEngine()then calls the virtual methoddoObtainEngine(), which is overridden in the Integrationhelper class.IIntegration::createEngine()returns a pointer to theIEngineinterface instance.
DeviceAgent creation
When you enable an integration for a specific camera in the Desktop Client, the Server creates a DeviceAgent instance using the following process:
The Desktop Client displays the configuration options defined in the
deviceAgentSettingsModelwhich is returned by theEngine::manifestString()method.When a user clicks
OKorApplyin the Desktop Client, the Server calls theIEngine::obtainDeviceAgent()virtual method.IEngine::obtainDeviceAgent()calls thedoObtainDeviceAgent()virtual method, which is overridden in theEnginehelper class.
Data processing flow
The Server delivers data packets, such as video frames, directly to the integration.
Whenever the Server retrieves a frame, it invokes the
doPushDataPacket()method of theIConsumingDeviceAgentinterface. This is a universal method used across all integration types (analytics, video source, and storage) and executes entirely within the Server without external resources.Within the Metadata SDK,
pushDataPacketinvokes thedoPushDataPacket()virtual method defined insrc/nx/sdk/analytics/i_consuming_device_agent.h.The
doPushDataPacket()method is overridden in theConsumingDeviceAgenthelper class located insrc/nx/sdk/analytics/helpers/consuming_device_agent.cpp.
To simplify development, the helper class implements several additional methods:
pushCompressedVideoFrame()pushUncompressedVideoFrame()pullMetadataPackets()pushMetadataPacket()
When the Server retrieves a new frame from a camera, it simultaneously calls the following methods:
pushUncompressedFrame()orpushUncompressedVideoFrame()to deliver the frame to the integration.pullMetadataPackets()to request and receive metadata back from the integration.
Alternatively, the DeviceAgent can call pushMetadataPacket() at any time.
Push vs. pull paradigms
You can choose either a push or a pull workflow based on your integrations architectural needs.
-
Push paradigm (
pushMetadataPacket())Initiated by: The integration
Expected data: A single metadata packet
-
Pull paradigm (
pullMetadataPackets())Initiated by: The Server
Expected data: A
std::vectorof metadata packets
Recommended helper classes
To build analytics integrations efficiently, we recommend using these three built-in helper classes:
Integration: Implemented inintegration.cppandintegration.h.Engine: Implemented inengine.cppandengine.h.DeviceAgent: Implemented indevice_agent.cppanddevice_agent.h.
NOTE: To better understand the integration lifecycle, see the Integration Lifecycle Guide. This tutorial focuses on using the DeviceAgent helper class alongside its pushUncompressedFrame() and pushMetadataPacket() methods. |
Comments
0 comments
Article is closed for comments.