Creating Commercial Plugins

From MOD Wiki
Jump to: navigation, search

Introduction

In this page we give you an overview of how the license authentication mechanism works and how to build your commercial LV2 plugins using the mod-plugin-builder. If want to know information regarding the legal aspect of the commercial plugins please contact us.

Creating commercial LV2 plugins is just like the regular ones except that you have to link the mod license API to them. Here in this page we assume you already know how to build plugins using the MPB, if you don't please read How To Build and Deploy LV2 Plugin to MOD Duo first.

Authentication

The authentication process, among other steps, works by reading a license file which is generated by us, MOD Devices. The license file is per plugin, per user. The file contents looks like this:

 John Doe
 http://example.com/my-commercial-plugin
 00112233445566778899AABBCCDDEEFF
 I6FvK5XRu8PP/u5AJ+oi4rHnk2MizRln0Bmd/mk3gAIWpvbLPsnDgX5ZnI2hFv2Y
 mEUkKFxPRQheb7bVUSRuLT9NWYA2aEier9MNozlSUP7+c7Jb+7YBPdWBL/O1Ckqb
 N2kq4+ZY3oOWWSwxV9jzAZluWtEHzPuJv6DuHbSVtD0=

The first line is the name of the user, the licensee. The second line is the URI of the plugin that the license file applies to (note: this can also be a plugin collection). The third line is the device unique ID that the license file applies to. The next 3 lines are exactly the same content as the initial 3 but signed with our private key (also called signature).

With this file setup, we're able to know the username, plugin URI, and device ID directly by reading the license, but it still offers protection by signing the same content on the file. If someone changes something in the first 3 lines, the signature will no longer match and thus the plugin runs unlicensed.

If the license file is invalid or not found, the plugin must generate periodic silence in the output or another sound degrading method, representing a trial plugin. The periodic silence function is provided by default by the library.

The API / Library

The library package has 3 main files:

  • mod-license.h the LV2 API that the host implements in order to support the licensing API. This is actually only meta-data.
  • libmodla.h the API that the commercial plugin developer must implement in its LV2 plugin.
  • libmodla.a the static library containing the implementation of the license authentication.

How to use the library

  1. Add the library include: #include "libmodla.h"
  2. Add uint32_t run_count as a member variable of the plugin object, initialized to 0 on instantiate/construction
  3. Call mod_license_check(host_features, PLUGIN_URI); during instantiate function
  4. In the beginning of your process function, call run_count = mod_license_run_begin(run_count, nsamples);. Where nsamples is the number of samples in the process function.
  5. For each audio output, call mod_license_run_silence(run_count, audio_output[i], nframes, i);
  6. At the end of your LV2 descriptor extension_data function use return mod_license_interface(extension_uri);

Additionally, you need to edit the meta-data in your LV2 plugin TTL file by adding the following lines. This will let the host know that the plugin supports such LV2 feature.

 lv2:extensionData <http://moddevices.com/ns/ext/license#interface> ;
 lv2:requiredFeature <http://moddevices.com/ns/ext/license#feature> ;

Plugin example

There is a full example of commercial plugin in our github repository, check the source code here. Once you are done understanding the code, take a careful look at the Makefile and make sure you use the same flags and commands as the ones in the example. This is very important to help with the protection of your plugins.

When you are ready run ./build commercial-plugin-example inside the MPB directory to build the plugin.

Publishing

If you want to have your plugin published please contact us.