• Stars
    star
    183
  • Rank 210,154 (Top 5 %)
  • Language
    Rust
  • License
    GNU General Publi...
  • Created over 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A safe wrapper around the OBS API, useful for creating OBS sources, filters and effects.

Rust OBS Wrapper

Build Status Wrapper Docs

A safe wrapper around the OBS API, useful for creating OBS sources, filters and effects. The wrapper is quite incomplete and will most likely see dramatic API changes in the future.

This repo also includes plugins creating using the wrapper in the /plugins folder.

Plugins

Folder Description
/scroll-focus-filter an OBS filter that will zoom into the currently focused X window
/rnnoise-denoiser-filter an OBS filter for removing background noise from your Mic

Usage

In your Cargo.toml file add the following section, substituting <module-name> for the name of the module:

[dependencies]
obs-wrapper = "0.4"

[lib]
name = "<module-name>"
crate-type = ["cdylib"]

The process for creating a plugin is:

  1. Create a struct that implements Module
  2. Create a struct that will store the plugin state
  3. Implement the required traits for the module
  4. Enable the traits which have been enabled in the module load method
use obs_wrapper::{
    // Everything required for modules
    prelude::*,
    // Everything required for creating a source
    source::*,
    // Macro for registering modules
    obs_register_module,
    // Macro for creating strings
    obs_string,
};

// The module that will handle creating the source.
struct TestModule {
    context: ModuleContext
}

// The source that will be shown inside OBS.
struct TestSource;

// Implement the Sourceable trait for TestSource, this is required for each source.
// It allows you to specify the source ID and type.
impl Sourceable for TestSource {
    fn get_id() -> ObsString {
        obs_string!("test_source")
    }

    fn get_type() -> SourceType {
        SourceType::FILTER
    }

    fn create(create: &mut CreatableSourceContext<Self>, source: SourceContext) -> Self {
        Self
    }
}

// Allow OBS to show a name for the source
impl GetNameSource for TestSource {
    fn get_name() -> ObsString {
        obs_string!("Test Source")
    }
}

// Implement the Module trait for TestModule. This will handle the creation of the source and
// has some methods for telling OBS a bit about itself.
impl Module for TestModule {
    fn new(context: ModuleContext) -> Self {
        Self { context }
    }

    fn get_ctx(&self) -> &ModuleContext {
        &self.context
    }

    // Load the module - create all sources, returning true if all went well.
    fn load(&mut self, load_context: &mut LoadContext) -> bool {
        // Create the source
        let source = load_context
            .create_source_builder::<TestSource>()
            // Since GetNameSource is implemented, this method needs to be called to
            // enable it.
            .enable_get_name()
            .build();

        // Tell OBS about the source so that it will show it.
        load_context.register_source(source);

        // Nothing could have gone wrong, so return true.
        true
    }

    fn description() -> ObsString {
        obs_string!("A great test module.")
    }

    fn name() -> ObsString {
        obs_string!("Test Module")
    }

    fn author() -> ObsString {
        obs_string!("Bennett")
    }
}

obs_register_module!(TestModule);

Installation

  1. Run cargo build --release
  2. Copy /target/release/<module-name>.so to your OBS plugins folder (/usr/lib/obs-plugins/)
  3. The plugin should be available for use from inside OBS

License

Like obs-studio, obs-wrapper is licensed under GNU General Public License v2.0.

See LICENSE for details.

More Repositories

1

dotfiles

Gruvbox inspired Arch Linux Hyprland rice.
Shell
95
star
2

recoil-clone

A Recoil clone written in under 100 lines (excluding comments, examples and tests).
TypeScript
89
star
3

darknet.js

A NodeJS wrapper of pjreddie's darknet / yolo.
C++
65
star
4

simple-dev-blog-zola-starter

A simple dev-blog theme for Zola.
SCSS
48
star
5

gruvbox-gtk

Arc theme but with gruvbox colours.
CSS
14
star
6

audio-graph

An audio graph written in Rust, optimised for bulk memory operations and minimising runtime allocations.
Rust
12
star
7

react-merged-context

A simple library for creating a context provider that merges with its parent's values.
TypeScript
9
star
8

factorial-rayon-neon

Rust
3
star
9

nano-arena

A tiny arena allocator that uses atomics.
Rust
2
star
10

static-site-optimizer

Convert a static site into a static site + amp
Rust
2
star
11

static-dsp

A no_std dsp library using const generics in Rust.
Rust
2
star
12

buffer-pool

A "vector of vectors" backed by one contiguous vector - allows mutable borrows of non-overlapping regions.
Rust
2
star
13

react-provided

A dead simply dependency injection library inspired by Recoil.
TypeScript
2
star
14

zathura-cmark-plugin

Rust
1
star
15

gatsby-intense-benchmark

A gatsby site with a lot of pages.
CSS
1
star
16

i3wm-react

i3wm recreated using react.
TypeScript
1
star
17

web-audio-modular-synth

A modular synth framework made using the web audio API.
TypeScript
1
star
18

cab403-distributed-hangman

Create a client/server system that allows users to play the game Hangman in C, using TCP and POSIX Threads.
C
1
star
19

stripe-wrapper

A wrapper of the stripe wrapper of the stripe API following the Fluent Interface design pattern.
TypeScript
1
star
20

interactive-javascript-console

An interactive JavaScript console inspired by thebookofshaders, to use on your website.
TypeScript
1
star
21

rust-react

Using React from Rust.
Rust
1
star