Creating Commercial Plugins

From MOD Wiki
Revision as of 17:49, 18 January 2018 by Crudo (talk | contribs) (Created page with "== 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 [https://gith...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to 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 visit this page(TODO) of our website.

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

We, MOD Devices, take care of generating a license file per plugin per user. The license file 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 MOD unit unique ID that the license file applies to. The next 3 lines are exactly the same content as the initial 3 but encrypted with a MOD Cloud private key.

With this file setup we're able to know the user name, plugin URI and MOD unit ID directly by reading the file, but it still offers protection by encrypting the same content on the file. If someone changes something in the first 3 lines, the encrypted content will no longer match and thus the plugin runs unlicensed.

If the license file is invalid or not found, the plugin must generate some random noise in the output, representing then a trial plugin. Such noise function is provided 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.a the API that the commercial plugin developer must implement in its LV2 plugin.
  • libmodla.h 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_noise(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. Note that you'll need to run ./build libmodla-rebuild first if you already have your plugin build system all set (i.e.: the bootstrap done).

Publishing

As we are in the testing phase of the commercial plugins we don't have yet an automated way to publish them. Right now, if you want to have your plugin publish, get your plugin bundle ready and please email us with the link.