NetObsBindings 0.0.1.25-alpha

This is a prerelease version of NetObsBindings.
There is a newer version of this package available.
See the version list below for details.
dotnet add package NetObsBindings --version 0.0.1.25-alpha
                    
NuGet\Install-Package NetObsBindings -Version 0.0.1.25-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetObsBindings" Version="0.0.1.25-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetObsBindings" Version="0.0.1.25-alpha" />
                    
Directory.Packages.props
<PackageReference Include="NetObsBindings" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NetObsBindings --version 0.0.1.25-alpha
                    
#r "nuget: NetObsBindings, 0.0.1.25-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NetObsBindings@0.0.1.25-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetObsBindings&version=0.0.1.25-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=NetObsBindings&version=0.0.1.25-alpha&prerelease
                    
Install as a Cake Tool

NetObsBindings

NuGet version (NetObsBindings)

NetObsBindings is a library that provides .NET bindings for Open Broadcast Software (OBS).

These bindings are generated from the OBS repository, specifically libobs and obs-frontend projects.

The approach taken is to generate a static class per header file via ClangSharp generator. This means, that, for example, you could find functions exported from the obs-service.h file in the ObsService C# class.

How to use these bindings?

These bindings can be used to create your own plugin in C#.

Simple plugin example:

public static class ObsPlugin
{
    public static nint ObsModulePointer { get; set; }

    [UnmanagedCallersOnly(EntryPoint = "obs_module_set_pointer", CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
    public static void SetPointer(nint obsModulePointer)
    {
        Log("[blog] Pointer Saved!");
        ObsModulePointer = obsModulePointer;
    }
    
    [UnmanagedCallersOnly(EntryPoint = "obs_module_ver", CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
    public static uint GetVersion()
    {
        Log("[blog] Returned version!");
        
        var major = (uint) Obs.Version.Major;
        var minor = (uint) Obs.Version.Minor;
        var patch = (uint) Obs.Version.Build;
        var version = (major << 24) | (minor << 16) | patch;
        return version;
    }

    [UnmanagedCallersOnly(EntryPoint = "obs_module_load", CallConvs = new[] {typeof(System.Runtime.CompilerServices.CallConvCdecl)})]
    public static bool ModuleLoad()
    {
        Log("[blog] Loaded!");
        return true;
    }

    private static unsafe void Log(string text)
    {
        var asciiBytes = Encoding.UTF8.GetBytes(text);
        fixed (byte* logMessagePtr = asciiBytes)
        {
            ObsBase.blogva(ObsBase.LOG_INFO, (sbyte*) logMessagePtr, null);   
        }
    }
}

There is one caveat: make sure you are publishing the plugins as NativeAOT libraries, this is essential to make it work due to the plugin model of OBS.


How to generate bindings locally?

In order to generate bindings locally, please use the build.ps1 script. Make sure that you have ClangSharpPInvokeGenerator dotnet tool installed.

This script will:

  1. Clone the OBS repository
  2. Generate bindings for all required modules
  3. Insert the version of the OBS library to Obs.Version.cs file.

Originally, these bindings generated in the blog post https://sharovarskyi.com/blog/posts/clangsharp-dotnet-interop-bindings/

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
30.1.2 242 4/11/2024
30.0.2 855 12/11/2023
0.0.1.38-alpha 223 10/8/2023
0.0.1.37-alpha 156 10/4/2023
0.0.1.35-alpha 216 5/7/2023
0.0.1.34-alpha 194 4/17/2023
0.0.1.33-alpha 314 4/8/2023
0.0.1.32-alpha 177 3/23/2023
0.0.1.31-alpha 182 3/12/2023
0.0.1.30-alpha 159 3/12/2023
0.0.1.29-alpha 189 2/11/2023
0.0.1.28-alpha 174 2/11/2023
0.0.1.27-alpha 170 2/10/2023
0.0.1.26-alpha 192 2/5/2023
0.0.1.25-alpha 186 1/31/2023
0.0.1.24-alpha 188 1/31/2023
0.0.1.23-alpha 178 1/28/2023
0.0.1.22-alpha 215 1/22/2023
0.0.1.21-alpha 186 1/22/2023
0.0.1.20-alpha 188 1/22/2023
0.0.1.19-alpha 190 1/22/2023
0.0.1.18-alpha 182 1/22/2023
0.0.1.17-alpha 180 1/16/2023
0.0.1.16-alpha 196 1/14/2023
0.0.1.15-alpha 187 1/14/2023
0.0.1.14-alpha 251 9/18/2022
0.0.1-alpha9 199 7/30/2022
0.0.1-alpha8 214 7/30/2022
0.0.1-alpha7 238 2/20/2022
0.0.1-alpha6 243 2/20/2022
0.0.1-alpha5 248 2/20/2022
0.0.1-alpha4 255 2/20/2022
0.0.1-alpha3 238 2/20/2022
0.0.1-alpha2 247 2/20/2022
0.0.1-alpha13 200 7/30/2022
0.0.1-alpha12 206 7/30/2022
0.0.1-alpha11 208 7/30/2022
0.0.1-alpha10 224 7/30/2022
0.0.1-alpha1 245 2/20/2022
0.0.1-alpha 252 2/20/2022