Skip to main content

libobs_wrapper/
lib.rs

1//! Safe, runtime-affine Rust access to the libobs object model.
2//!
3//! # Start here
4//!
5//! [`crate::context::ObsContext`] is the root managed handle. Most applications create it through
6//! [`crate::utils::StartupInfo`], then use only the modules needed for their workflow.
7//!
8//! | What you need | Module |
9//! | --- | --- |
10//! | Discover installed sources/encoders/outputs/services | [`crate::capabilities`] |
11//! | Configure arbitrary plugins from runtime metadata | [`crate::settings`] |
12//! | Sources and filters | [`crate::sources`] |
13//! | Scenes, groups, native order and transform snapshots | [`crate::scenes`] |
14//! | Audio/video encoders | [`crate::encoders`] |
15//! | Streaming services | [`crate::services`] |
16//! | Validated output graphs, lifecycle and telemetry | [`crate::data::output`] |
17//! | Source audio/meter/monitoring controls | [`crate::sources`] + [`crate::audio_monitoring`] |
18//! | Transitions and controllable media | [`crate::sources`] |
19//! | Preview/display surfaces and editor geometry | [`crate::display`] |
20//! | Instance-bound property actions | [`crate::settings_actions`] |
21//! | Managed hotkeys | [`crate::hotkeys`] |
22//! | OBS event subscriptions | [`crate::signals`] and per-object `signals()` methods |
23//! | Raw FFI escape hatch | [`crate::sys`] |
24//!
25//! If you only need a conventional recorder, RTMP stream, replay buffer, or common capture source,
26//! the `libobs-simple` crate is normally a better starting point. It uses this wrapper internally
27//! and can be mixed with wrapper calls on the same [`crate::context::ObsContext`].
28//!
29//! # Plugin-generic workflow
30//!
31//! Do not assume every machine has the same OBS plugins. The preferred generic path is:
32//!
33//! 1. call [`crate::context::ObsContext::capabilities`];
34//! 2. choose by codec/protocol/capability, or use
35//!    [`crate::capabilities::ObsCapabilities::best_output_plan`];
36//! 3. use descriptor `settings_schema_for` / `settings_snapshot_for` methods to configure plugin
37//!    settings without hard-coded property models;
38//! 4. create managed objects from the descriptors;
39//! 5. use [`crate::data::output::ObsOutputPipelineBuilder`] for complete output graphs.
40//!
41//! # Scene composition
42//!
43//! [`crate::scenes::ObsSceneRef`] owns managed scene items and exposes libobs's actual native order.
44//! [`crate::scenes::SceneItemTrait`] covers transform/state behavior, including crop, bounds, scale
45//! filters, blending, and restorable snapshots. [`crate::scenes::ObsSceneGroupRef`] represents native
46//! OBS groups rather than simulating groups in Rust.
47//!
48//! One important libobs behavior is exposed explicitly: ungrouping creates replacement parent-scene
49//! items. [`crate::scenes::ObsSceneGroupRef::ungroup`] therefore returns replacement managed handles
50//! and marks the replaced child handles removed.
51//!
52//! # Ownership and unsafe access
53//!
54//! Managed objects retain native references through one OBS runtime. Clones share a lifetime lease,
55//! and operations validate runtime affinity before combining objects. Prefer opaque object IDs for
56//! identity. [`crate::sys`] is available when raw libobs functionality is genuinely needed, but raw
57//! pointers carry the usual libobs thread-affinity and reference-count responsibilities.
58//!
59//! The repository's `docs/api_orientation.md` contains a longer task-to-module guide and examples.
60
61#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
62
63pub mod audio_monitoring;
64pub mod capabilities;
65pub mod context;
66pub mod crash_handler;
67pub mod data;
68pub mod display;
69pub mod encoders;
70pub mod enums;
71pub mod logger;
72pub mod runtime;
73pub mod scenes;
74pub mod services;
75pub mod settings;
76pub mod settings_actions;
77pub mod signals;
78pub mod sources;
79#[doc(hidden)]
80pub mod unsafe_send;
81pub mod utils;
82
83pub use libobs as sys;
84
85// Add the macros module to the public exports
86pub mod graphics;
87pub mod hotkeys;
88#[cfg_attr(coverage_nightly, coverage(off))]
89mod macros;