Struct ObsContext

Source
pub struct ObsContext { /* private fields */ }
Expand description

Interface to the OBS context. Only one context can exist across all threads and any attempt to create a new context while there is an existing one will error.

Note that the order of the struct values is important! OBS is super specific about how it does everything. Things are freed early to latest from top to bottom.

Implementations§

Source§

impl ObsContext

Source

pub fn startup_info(&self) -> &Arc<RwLock<StartupInfo>>

Source

pub fn displays( &self, ) -> &Arc<RwLock<HashMap<usize, Arc<Pin<Box<ObsDisplayRef>>>>>>

Source

pub fn outputs(&self) -> &Arc<RwLock<Vec<ObsOutputRef>>>

Source

pub fn scenes(&self) -> &Arc<RwLock<Vec<ObsSceneRef>>>

Source

pub fn runtime(&self) -> &ObsRuntime

Source

pub fn displays_mut( &mut self, ) -> &mut Arc<RwLock<HashMap<usize, Arc<Pin<Box<ObsDisplayRef>>>>>>

Source

pub fn outputs_mut(&mut self) -> &mut Arc<RwLock<Vec<ObsOutputRef>>>

Source

pub fn scenes_mut(&mut self) -> &mut Arc<RwLock<Vec<ObsSceneRef>>>

Source§

impl ObsContext

Source

pub fn builder() -> StartupInfo

Source

pub async fn new(info: StartupInfo) -> Result<ObsContextReturn, ObsError>

Initializes libobs on the current thread.

Note that there can be only one ObsContext initialized at a time. This is because libobs is not completely thread-safe.

Also note that this might leak a very tiny amount of memory. As a result, it is probably a good idea not to restart the OBS context repeatedly over a very long period of time. Unfortunately the memory leak is caused by a bug in libobs itself.

If the bootstrapper feature is enabled, and ObsContextReturn::Restart is returned, the application must be restarted to apply the updates and initialization can not continue.

Source

pub async fn get_version(&self) -> Result<String, ObsError>

Source

pub fn log(&self, level: ObsLogLevel, msg: &str)

Source

pub async fn reset_video(&mut self, ovi: ObsVideoInfo) -> Result<(), ObsError>

Resets the OBS video context. This is often called when one wants to change a setting related to the OBS video info sent on startup.

It is important to register your video encoders to a video handle after you reset the video context if you are using a video handle other than the main video handle. For convenience, this function sets all video encoder back to the main video handler by default.

Note that you cannot reset the graphics module without destroying the entire OBS context. Trying so will result in an error.

Source

pub async fn get_video_ptr( &self, ) -> Result<Sendable<*mut video_output>, ObsError>

Source

pub async fn get_audio_ptr( &self, ) -> Result<Sendable<*mut audio_output>, ObsError>

Source

pub async fn data(&self) -> Result<ObsData, ObsError>

Source

pub async fn output( &mut self, info: OutputInfo, ) -> Result<ObsOutputRef, ObsError>

Source

pub async fn display( &mut self, data: ObsDisplayCreationData, ) -> Result<Pin<Box<ObsDisplayRef>>, ObsError>

Creates a new display and returns its ID.

Source

pub async fn remove_display(&mut self, display: &ObsDisplayRef)

Source

pub async fn remove_display_by_id(&mut self, id: usize)

Source

pub async fn get_display_by_id( &self, id: usize, ) -> Option<Arc<Pin<Box<ObsDisplayRef>>>>

Source

pub async fn get_output(&mut self, name: &str) -> Option<ObsOutputRef>

Source

pub async fn update_output( &mut self, name: &str, settings: ObsData, ) -> Result<(), ObsError>

Source

pub async fn scene<T: Into<ObsString> + Send + Sync>( &mut self, name: T, ) -> Result<ObsSceneRef, ObsError>

Source

pub async fn get_scene(&mut self, name: &str) -> Option<ObsSceneRef>

Source

pub async fn source_builder<T: ObsSourceBuilder, K: Into<ObsString> + Send + Sync>( &self, name: K, ) -> Result<T, ObsError>

Trait Implementations§

Source§

impl Clone for ObsContext

Source§

fn clone(&self) -> ObsContext

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ObsContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ObsBootstrap for ObsContext

Source§

impl ObsContextEncoders for ObsContext

Source§

fn get_best_video_encoder<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<ObsVideoEncoderType, ObsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_best_audio_encoder<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<ObsAudioEncoderType, ObsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_available_audio_encoders<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ObsAudioEncoderType>, ObsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_available_video_encoders<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ObsVideoEncoderType>, ObsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T