Skip to content

A free and open-source video editor for Windows and Linux, written in Rust: a track-based timeline, effects at every level, OpenFX and VST 3 hosts, studio audio and color.

1.3 KB
Raw Blame
//! BananaV's effects as an OpenFX binary, for other OFX hosts (DaVinci
//! Resolve, Natron, Nuke…): the same plug-ins BananaV has built in.
//! `cargo build --release -p bananav-ofx` makes `bananav_ofx.dll`
//! (`libbananav_ofx.so` on Linux); copied as
//! `BananaV.ofx.bundle/Contents/Win64/BananaV.ofx` (`Linux-x86-64`…) into
//! an OFX plug-in folder, hosts find it.

use std::ffi::c_int;

use bv_ofx_sys::OfxPlugin;

/// The specification's `OfxGetNumberOfPlugins`.
///
/// # Safety
/// Called by hosts, as the specification says.
#[allow(unsafe_code, non_snake_case)]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn OfxGetNumberOfPlugins() -> c_int {
    // SAFETY: as the host calls this one.
    unsafe { bv_effects::number_of_plugins() + bv_banana::number_of_plugins() }
}

/// The specification's `OfxGetPlugin`.
///
/// # Safety
/// Called by hosts, as the specification says.
#[allow(unsafe_code, non_snake_case)]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn OfxGetPlugin(nth: c_int) -> *mut OfxPlugin {
    // BananaV's own, then Banana Split's.
    // SAFETY: as the host calls this one.
    unsafe {
        let own = bv_effects::number_of_plugins();
        if nth < own {
            bv_effects::get_plugin(nth)
        } else {
            bv_banana::get_plugin(nth - own)
        }
    }
}