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
impl ObsContext
pub fn startup_info(&self) -> &Arc<RwLock<StartupInfo>>
pub fn displays( &self, ) -> &Arc<RwLock<HashMap<usize, Arc<Pin<Box<ObsDisplayRef>>>>>>
pub fn outputs(&self) -> &Arc<RwLock<Vec<ObsOutputRef>>>
pub fn scenes(&self) -> &Arc<RwLock<Vec<ObsSceneRef>>>
pub fn runtime(&self) -> &ObsRuntime
pub fn displays_mut( &mut self, ) -> &mut Arc<RwLock<HashMap<usize, Arc<Pin<Box<ObsDisplayRef>>>>>>
pub fn outputs_mut(&mut self) -> &mut Arc<RwLock<Vec<ObsOutputRef>>>
pub fn scenes_mut(&mut self) -> &mut Arc<RwLock<Vec<ObsSceneRef>>>
Source§impl ObsContext
impl ObsContext
pub fn builder() -> StartupInfo
Sourcepub async fn new(info: StartupInfo) -> Result<ObsContextReturn, ObsError>
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.
pub async fn get_version(&self) -> Result<String, ObsError>
pub fn log(&self, level: ObsLogLevel, msg: &str)
Sourcepub async fn reset_video(&mut self, ovi: ObsVideoInfo) -> Result<(), ObsError>
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.
pub async fn get_video_ptr( &self, ) -> Result<Sendable<*mut video_output>, ObsError>
pub async fn get_audio_ptr( &self, ) -> Result<Sendable<*mut audio_output>, ObsError>
pub async fn data(&self) -> Result<ObsData, ObsError>
pub async fn output( &mut self, info: OutputInfo, ) -> Result<ObsOutputRef, ObsError>
Sourcepub async fn display(
&mut self,
data: ObsDisplayCreationData,
) -> Result<Pin<Box<ObsDisplayRef>>, ObsError>
pub async fn display( &mut self, data: ObsDisplayCreationData, ) -> Result<Pin<Box<ObsDisplayRef>>, ObsError>
Creates a new display and returns its ID.
pub async fn remove_display(&mut self, display: &ObsDisplayRef)
pub async fn remove_display_by_id(&mut self, id: usize)
pub async fn get_display_by_id( &self, id: usize, ) -> Option<Arc<Pin<Box<ObsDisplayRef>>>>
pub async fn get_output(&mut self, name: &str) -> Option<ObsOutputRef>
pub async fn update_output( &mut self, name: &str, settings: ObsData, ) -> Result<(), ObsError>
pub async fn scene<T: Into<ObsString> + Send + Sync>( &mut self, name: T, ) -> Result<ObsSceneRef, ObsError>
pub async fn get_scene(&mut self, name: &str) -> Option<ObsSceneRef>
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
impl Clone for ObsContext
Source§fn clone(&self) -> ObsContext
fn clone(&self) -> ObsContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more