Below is a minimal example of how to use the MXL SDK C API in your application:
- Create an MXL instance
#include <mxl/mxl.h>
mxlInstance instance = mxlCreateInstance("/dev/shm/mxl", NULL);
if (!instance) {
// handle error
}- Create a Flow Writer
#include <mxl/flow.h>
const char* flowDef = "{...}"; // NMOS Flow Resource JSON describing the flow desired
mxlFlowWriter writer;
bool wasCreated;
mxlStatus status = mxlCreateFlowWriter(instance, flowDef, NULL, &writer, NULL, &wasCreated);
if (status != MXL_STATUS_OK) {
// handle error
}- Create a Flow Reader
mxlFlowReader reader;
status = mxlCreateFlowReader(instance, "<flow-id>", NULL, &reader);
if (status != MXL_STATUS_OK) {
// handle error
}- Read/Write Data
- For discrete flows, use
mxlFlowReaderGetGrainandmxlFlowWriterOpenGrain/mxlFlowWriterCommitGrain. - For continuous flows, use
mxlFlowReaderGetSamplesandmxlFlowWriterOpenSamples/mxlFlowWriterCommitSamples.
- Release Resources
mxlReleaseFlowWriter(instance, writer);
mxlReleaseFlowReader(instance, reader);
mxlDestroyInstance(instance);See the header files in lib/include/mxl/ for full API details and additional options.