Plugin Development

Plugins for Agent DVR are created as .Net Standard 2.0 projects which should run on all platforms. To get started clone our open source plugins at https://github.com/ispysoftware/AgentDVR-Plugins. You will need a recent version of Visual Studio to build them.

We recommend you build the demo plugin first and develop from that. You will need the latest version of Agent installed. Build the demo plugin and copy all the files in the Demo\bin\Debug\netstandard2.0 folder to Agent\Plugins\Demo\. Restart Agent, edit a camera and go to the Plugins tab. Check Enable, Select Demo in the dropdown and click the "..." button to configure it.

The Demo plugin is fully crossplatform compatible and demonstrates most of the functionality you can build with plugins. It applies a live video effect, overlay graphics, live volume control and integration with the Events subsystem in Agent (you can trigger an action when the bouncing rectangle hits the side of the video). See the menu in the plugin to learn how various input controls work.


Plugin Notes:

Configuration: Agent uses a mix of XML, XSD and JSON to store and render settings. Edit the config.xsd file in visual studio by right clicking on it, click "Open With" and choose "XML (Text) Editor with Encoding". Add the fields you need to store. When you have done that generate the c# code for the xsd file by calling (in the same directory): C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\xsd.exe /c config.xsd This will generate a class file you can access from within the code.

Agent stores information on how to render the configuration and update your XML in .json files. Edit the config_en.json file in the json directory. You can have multiple json files here with locales in the filename. Agent will use the users language to load the correspoding json for display in the web ui. There must always be a config_en.json file as a fallback if the users language is not available.

You can add multiple sections to this json file and it will be rendered with tabs in the UI. There are many available controls available here. Take a look at the demo project which displays all the available controls in the tabs and binds the values to the xsd file. The most important fields are the "bindto" fields which tell Agent which config xml field to update with the rendered HTML controls. Agent takes care of rendering the controls and storing and updating the settings.

You can add an additional property "live": true to the json item entries to have Agent update them immediately without waiting for the OK button to be clicked - which is useful for live tuning of settings.

Where a converter is specified it will use the code in PopulateResponse in Utils.cs to convert the supplied value to a fixed format.

Media Support You can choose to process "video", "audio" or "video,audio". You can hard code the Supports field in Main.cs.

Processing Continuously The plugin is sent every video frame and audio frame decoded from the device. You can analyse these fields or apply processing to them like we do in the demo,

Processing on Motion/ Alert You can process incoming frames when Agent detects motion or alerts. To do this see the ProcessEvent method in the demo plugin. You can then ignore incoming frames and start processing them only when you receive these events.

Custom Events: Agent will call the method GetCustomEvents - you should return a list of strings of custom events that your plugin generates (if any). These events are then able to be selected under Actions in the Agent UI when you edit the device (at the bottom of the If list). To trigger these events add a Result item with the action name and optional MSG, Tag, Filename and AIJSON values set for merging. See the demo project "Rectangle Bounce" example.

Alert, Detect and Tag: To raise an alert or detect event you can add a Result with the eventName "alert", or "detect". To tag an ongoing recording you can add a Result with the eventName "tag" and set Tags to whatever you want.

Calling the API Agent initializes the plugin when the device is enabled and will call the methods SetCameraInfo and/ or SetMicrophoneInfo, passing in the name, object ID and port of the local server. You can use this information to call commands for the device using the API.

Agent also sets the properties AppDataPath and AppPath which you can use for display or locations to save files.

Distribution Created something cool/ useful? Please feel free to share it with us.