Crate phaneron_plugin

Source
Expand description

This module defines the interfaces to be implemented for a Phaneron plugin to be successfully loaded.

To create a plugin you must have a function annotated with the #[export_root_module] from the abi_stable crate. This function should return a PhaneronPluginRootModule which acts as the handle which can be used to initialize your plugin. This first function should not perform any additional work such as loading assets etc. as your plugin will be given an opportunity to initialize itself later.

You should then have a load function that is annotated using the #[sabi_external_fn] macro from the abi_stable crate. This function is the initializer for your plugin and is where you can load assets that are globally required and pre-allocate large amounts of memory if required. This function is allowed to fail and will only be called once. If it fails then the plugin will not be loaded and Phaneron will not attempt to load the plugin again. If failing, please return some useful error message.

#[export_root_module]
fn instantiate_root_module() -> PhaneronPluginRootModuleRef {
    PhaneronPluginRootModule { load }.leak_into_prefix()
}

#[sabi_extern_fn]
pub fn load(context: PhaneronPluginContext) -> RResult<PhaneronPlugin, RString> {
    log::set_logger(phaneron_plugin::get_logger(&context)).unwrap();
    log::set_max_level(LevelFilter::Trace);
    let plugin = DemoPlugin {};

    ROk(PhaneronPlugin_TO::from_value(plugin, TD_Opaque))
}

The returned plugin is of type DemoPlugin in this instance, which implements the PhaneronPlugin trait. This object will be used to create nodes from your plugin and manage its lifecycle. Refer to the documentation of PhaneronPlugin.

Modules§

PhaneronLoggingContext_trait
This module is generated by the #[sabi_trait] attribute on PhaneronLoggingContext
traits
types
This module provides aliases for the trait objects generated by abi_stable for traits annotated with sabi_trait.

Structs§

AudioFrameWithId
An audio frame along with its associated output Id.
AudioInputId
AudioOutputId
ColourSpec
Defines the transformation function for a colourspace. May be used to define custom colour spaces.
PhaneronLoggingContext_TO
The trait object for PhaneronLoggingContext.
PhaneronPluginContext
Context passed to plugins, currently only serves as a way to provide a logging contet.
PhaneronPluginRootModule
Describes the entrypoint for a plugin.
PhaneronPluginRootModuleRef
This is the pointer to the prefix of PhaneronPluginRootModule.
PhaneronPluginRootModule_Prefix
This is the prefix fields of PhaneronPluginRootModule, accessible through PhaneronPluginRootModuleRef, with .0.prefix().
PluginLogger
Provides logging to a plugin. It can be set as the default logger for the log trait by calling init.
ShaderParams
Parameters to be passed to a process shader. Each call to a set_param_ function will push a parameter of that type to the arguments list, so calls should be made in the order in which parameters are required to be sent to the shader.
VideoFrameWithId
A video frame along with its associated output Id.
VideoInputId
VideoOutputId

Enums§

AudioChannelLayout
Supported audio channel layouts.
AudioFormat
Supported audio I/O formats. Audio will be converted to 32 bit floating-point on input.
ColourSpace
Built-in colour space definitions.
InterlaceMode
Supported interlacing modes.
LogLevel
This should not be used by plugins, it is consumed by Phaneron to carry log messages across the FFI boundary.
ShaderParam
Available shader parameter types, these do not need to be directly consumed by plugins.
VideoFormat
Supported pixel packing formats.

Constants§

COLOUR_SPEC_BT_709
Colour space transformation for BT.709. Reference: https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.709-6-201506-I!!PDF-E.pdf
COLOUR_SPEC_BT_601_525
Colour space transformation for BT.601 (525 lines). Reference: https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf
COLOUR_SPEC_BT_601_625
Colour space transformation for BT.601 (625 lines). Reference: https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf
COLOUR_SPEC_BT_2020
Colour space transformation for BT.709. Reference: https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2020-2-201510-I!!PDF-E.pdf
COLOUR_SPEC_SRGB
Colour space transformation for sRGB using kR and kB values from BT.709. Reference: https://en.wikipedia.org/wiki/SRGB

Traits§

PhaneronLoggingContext
This trait is used to allow the logger to be used across the FFI boundary. It should not be consumed by plugins.

Functions§

get_logger
Returns the logger for a plugin which can then be used to pass log messages to Phaneron.

Type Aliases§

PhaneronLoggingContext_CTO
A type alias for the const-constructible PhaneronLoggingContext_TO.