Our company is developing a proprietary video management system (VMS) written in C ++. In a new release, we want to allow customers to extend its functionality through the plug-in system. We will provide our plugins, but we will also give our customers an SDK so that they can write plugins themselves. Plugins receive the video stream (either uncompressed or uncompressed, so they do not need to decode it themselves), process it, and return metadata, connected to the images. A stream can be processed by several plugins.
- Streams must be processed in real time using as few resources as possible.
- Remote plugins should be possible.
- Customers should be able to write their own plugins.
I see two options on how the plug-in system could be implemented: microservices and dynamically linked libraries. Here are the descriptions of the solutions and advantages and disadvantages in my opinion.
VMS already broadcasts HLS streams, so it is not necessary to implement this part of the communication. Microservice (plugin) processes the video and sends the metadata via REST. If microservice is located on the same computer, it can send an uncompressed video stream in the form of frames using shared memory (to record a plugin stream decoding).
- A plugin can be written in any language.
- A plugin can work on the computer different from the box.
- A plugin crash does not cause the VMS crash.
- A plugin is relatively easy to code and debug.
- For high speed on the same computer, it is necessary to implement communication via shared memory (and not a cross-platform and multi-language solution).
- Will work more slowly than DLL due to the IPC.
Dynamically linked libraries
DLLs are written in a special way (they export functions with specified parameters and names). They are loaded into the VMS. For each flow, an instance of the engine is created. For remote plug-in special servers, a conversation with VMS will be created.
- Will work faster than microservices.
- A plugin must be written in a compiled language that follows STDCALL.
- It is necessary to write a special server for remote plugins.
- A crash of the plugin will cause a crash of VMS.
- A plugin is difficult to code and debug.
What is your opinion which solution is the best?