WIP: Redesign Rust API naming

v5-api
Dominik Nakamura 2 years ago
parent 865abcab09
commit be1e0dcbc5
No known key found for this signature in database
GPG Key ID: E4C6A749B2491910

@ -12,12 +12,12 @@ async fn main() -> Result<()> {
let client = Client::connect("localhost", 4455, env::var("OBS_PASSWORD").ok()).await?;
let scene_list = client.scenes().get_scene_list().await?;
let scene_list = client.scenes().list().await?;
for scene in scene_list.scenes.iter().cycle() {
client
.scenes()
.set_current_program_scene(&scene.scene_name)
.set_current_program_scene(&scene.name)
.await?;
tokio::time::sleep(Duration::from_secs(1)).await;
}

@ -15,12 +15,12 @@ async fn main() -> Result<()> {
let screenshot = client
.sources()
.get_source_screenshot(GetSourceScreenshot {
source_name: "OBWS-TEST-Scene",
image_width: None,
image_height: None,
image_compression_quality: None,
image_format: "png",
.take_screenshot(GetSourceScreenshot {
source: "OBWS-TEST-Scene",
width: None,
height: None,
compression_quality: None,
format: "png",
})
.await?;

@ -12,10 +12,10 @@ async fn main() -> Result<()> {
let client = Client::connect("localhost", 4455, env::var("OBS_PASSWORD").ok()).await?;
let version = client.general().get_version().await?;
let version = client.general().version().await?;
println!("{:#?}", version);
let scene_list = client.scenes().get_scene_list().await?.scenes;
let scene_list = client.scenes().list().await?.scenes;
println!("{:#?}", scene_list);
Ok(())

@ -13,9 +13,6 @@ pub struct Config<'a> {
impl<'a> Config<'a> {
/// Gets the value of a "slot" from the selected persistent data realm.
///
/// - `realm`: The data realm to select.
/// - `slot_name`: The name of the slot to retrieve data from.
pub async fn get_persistent_data(
&self,
realm: Realm,
@ -34,7 +31,7 @@ impl<'a> Config<'a> {
}
/// Gets an array of all scene collections.
pub async fn get_scene_collection_list(&self) -> Result<responses::SceneCollections> {
pub async fn list_scene_collections(&self) -> Result<responses::SceneCollections> {
self.client
.send_message(RequestType::GetSceneCollectionList)
.await
@ -43,76 +40,56 @@ impl<'a> Config<'a> {
/// Switches to a scene collection.
///
/// **Note:** This will block until the collection has finished changing.
///
/// - `scene_collection_name`: Name of the scene collection to switch to.
pub async fn set_current_scene_collection(&self, scene_collection_name: &str) -> Result<()> {
pub async fn set_current_scene_collection(&self, name: &str) -> Result<()> {
self.client
.send_message(RequestType::SetCurrentSceneCollection {
scene_collection_name,
})
.send_message(RequestType::SetCurrentSceneCollection { name })
.await
}
/// Creates a new scene collection, switching to it in the process.
///
/// **Note:** This will block until the collection has finished changing.
///
/// - `scene_collection_name`: Name for the new scene collection.
pub async fn create_scene_collection(&self, scene_collection_name: &str) -> Result<()> {
pub async fn create_scene_collection(&self, name: &str) -> Result<()> {
self.client
.send_message(RequestType::CreateSceneCollection {
scene_collection_name,
})
.send_message(RequestType::CreateSceneCollection { name })
.await
}
/// Gets an array of all profiles.
pub async fn get_profile_list(&self) -> Result<responses::Profiles> {
pub async fn list_profiles(&self) -> Result<responses::Profiles> {
self.client.send_message(RequestType::GetProfileList).await
}
/// Switches to a profile.
///
/// - `profile_name`: Name of the profile to switch to.
pub async fn set_current_profile(&self, profile_name: &str) -> Result<()> {
pub async fn set_current_profile(&self, name: &str) -> Result<()> {
self.client
.send_message(RequestType::SetCurrentProfile { profile_name })
.send_message(RequestType::SetCurrentProfile { name })
.await
}
/// Creates a new profile, switching to it in the process.
///
/// - `profile_name`: Name for the new profile.
pub async fn create_profile(&self, profile_name: &str) -> Result<()> {
pub async fn create_profile(&self, name: &str) -> Result<()> {
self.client
.send_message(RequestType::CreateProfile { profile_name })
.send_message(RequestType::CreateProfile { name })
.await
}
/// Removes a profile. If the current profile is chosen, it will change to a different profile
/// first.
///
/// - `profile_name`: Name of the profile to remove.
pub async fn remove_profile(&self, profile_name: &str) -> Result<()> {
pub async fn remove_profile(&self, name: &str) -> Result<()> {
self.client
.send_message(RequestType::RemoveProfile { profile_name })
.send_message(RequestType::RemoveProfile { name })
.await
}
/// Gets a parameter from the current profile's configuration.
///
/// - `parameter_category`: Category of the parameter to get.
/// - `parameter_name`: Name of the parameter to get.
pub async fn get_profile_parameter(
&self,
parameter_category: &str,
parameter_name: &str,
category: &str,
name: &str,
) -> Result<responses::ProfileParameter> {
self.client
.send_message(RequestType::GetProfileParameter {
parameter_category,
parameter_name,
})
.send_message(RequestType::GetProfileParameter { category, name })
.await
}
@ -127,7 +104,7 @@ impl<'a> Config<'a> {
///
/// **Note:** To get the true FPS value, divide the FPS numerator by the FPS denominator.
/// Example: `60000/1001`.
pub async fn get_video_settings(&self) -> Result<responses::VideoSettings> {
pub async fn video_settings(&self) -> Result<responses::VideoSettings> {
self.client
.send_message(RequestType::GetVideoSettings)
.await
@ -135,11 +112,9 @@ impl<'a> Config<'a> {
/// Sets the current video settings.
///
/// **Note:** Fields must be specified in pairs. For example, you cannot set only [`base_width`]
/// without needing to specify [`base_height`].
///
/// [`base_width`]: SetVideoSettings::base_width
/// [`base_height`]: SetVideoSettings::base_height
/// **Note:** Fields must be specified in pairs. For example, you cannot set only
/// [`SetVideoSettings::base_width`] without needing to specify
/// [`SetVideoSettings::base_height`].
pub async fn set_video_settings(&self, settings: SetVideoSettings) -> Result<()> {
self.client
.send_message(RequestType::SetVideoSettings(settings))
@ -147,9 +122,7 @@ impl<'a> Config<'a> {
}
/// Gets the current stream service settings (stream destination).
pub async fn get_stream_service_settings<T>(
&self,
) -> Result<responses::StreamServiceSettings<T>>
pub async fn stream_service_settings<T>(&self) -> Result<responses::StreamServiceSettings<T>>
where
T: DeserializeOwned,
{
@ -162,29 +135,20 @@ impl<'a> Config<'a> {
///
/// **Note:** Simple RTMP settings can be set with type `rtmp_custom` and the settings fields
/// `server` and `key`.
///
/// - `stream_service_type`: Type of stream service to apply. Example: `rtmp_common` or
/// `rtmp_custom`.
/// - `stream_service_settings`: Settings to apply to the service.
pub async fn set_stream_service_settings<T>(
&self,
stream_service_type: &'a str,
stream_service_settings: &T,
) -> Result<()>
pub async fn set_stream_service_settings<T>(&self, r#type: &'a str, settings: &T) -> Result<()>
where
T: Serialize,
{
self.client
.send_message(RequestType::SetStreamServiceSettings {
stream_service_type,
stream_service_settings: serde_json::to_value(stream_service_settings)
.map_err(Error::SerializeCustomData)?,
r#type,
settings: serde_json::to_value(settings).map_err(Error::SerializeCustomData)?,
})
.await
}
/// Gets the current directory that the record output is set to.
pub async fn get_record_directory(&self) -> Result<String> {
pub async fn record_directory(&self) -> Result<String> {
self.client
.send_message::<responses::RecordDirectory>(RequestType::GetRecordDirectory)
.await

@ -33,18 +33,18 @@ impl ReceiverList {
/// Notify a waiting receiver with the response to a request.
pub async fn notify(&self, response: RequestResponse) -> Result<(), InnerError> {
let RequestResponse {
request_type: _,
request_id,
request_status,
response_data,
r#type: _,
id,
status,
data,
} = response;
let request_id = request_id
let id = id
.parse()
.map_err(|e| InnerError::InvalidRequestId(e, request_id))?;
.map_err(|e| InnerError::InvalidRequestId(e, id))?;
if let Some(tx) = self.0.lock().await.remove(&request_id) {
tx.send((request_status, response_data)).ok();
if let Some(tx) = self.0.lock().await.remove(&id) {
tx.send((status, data)).ok();
}
Ok(())

@ -17,12 +17,7 @@ pub struct Filters<'a> {
impl<'a> Filters<'a> {
/// Gets an array of all of a source's filters.
///
/// - `source_name`: Name of the source.
pub async fn get_source_filter_list(
&self,
source_name: &str,
) -> Result<Vec<responses::SourceFilter>> {
pub async fn list(&self, source_name: &str) -> Result<Vec<responses::SourceFilter>> {
self.client
.send_message::<responses::Filters>(RequestType::GetSourceFilterList { source_name })
.await
@ -30,9 +25,7 @@ impl<'a> Filters<'a> {
}
/// Gets the default settings for a filter kind.
///
/// - `filter_kind`: Filter kind to get the default settings for.
pub async fn get_source_filter_default_settings<T>(&self, filter_kind: &str) -> Result<T>
pub async fn default_settings<T>(&self, filter_kind: &str) -> Result<T>
where
T: DeserializeOwned,
{
@ -45,18 +38,18 @@ impl<'a> Filters<'a> {
}
/// Creates a new filter, adding it to the specified source.
pub async fn create_source_filter<T>(&self, filter: CreateSourceFilter<'_, T>) -> Result<()>
pub async fn create<T>(&self, filter: CreateSourceFilter<'_, T>) -> Result<()>
where
T: Serialize,
{
self.client
.send_message(RequestType::CreateSourceFilter(
CreateSourceFilterInternal {
source_name: filter.source_name,
filter_name: filter.filter_name,
filter_kind: filter.filter_kind,
filter_settings: filter
.filter_settings
source: filter.source,
filter: filter.filter,
kind: filter.kind,
settings: filter
.settings
.map(|settings| serde_json::to_value(&settings))
.transpose()
.map_err(Error::SerializeCustomData)?,
@ -66,63 +59,44 @@ impl<'a> Filters<'a> {
}
/// Removes a filter from a source.
///
/// - `source_name`: Name of the source the filter is on.
/// - `filter_name`: Name of the filter to remove.
pub async fn remove_source_filter(&self, source_name: &str, filter_name: &str) -> Result<()> {
pub async fn remove(&self, source: &str, filter: &str) -> Result<()> {
self.client
.send_message(RequestType::RemoveSourceFilter {
source_name,
filter_name,
})
.send_message(RequestType::RemoveSourceFilter { source, filter })
.await
}
/// Sets the name of a source filter (rename).
pub async fn set_source_filter_name(&self, name: SetSourceFilterName<'_>) -> Result<()> {
pub async fn set_name(&self, name: SetSourceFilterName<'_>) -> Result<()> {
self.client
.send_message(RequestType::SetSourceFilterName(name))
.await
}
/// Gets the info for a specific source filter.
///
/// - `source_name`: Name of the source.
/// - `filter_name`: Name of the filter.
pub async fn get_source_filter(
&self,
source_name: &str,
filter_name: &str,
) -> Result<responses::SourceFilter> {
pub async fn get(&self, source: &str, filter: &str) -> Result<responses::SourceFilter> {
self.client
.send_message(RequestType::GetSourceFilter {
source_name,
filter_name,
})
.send_message(RequestType::GetSourceFilter { source, filter })
.await
}
/// Sets the index position of a filter on a source.
pub async fn set_source_filter_index(&self, index: SetSourceFilterIndex<'_>) -> Result<()> {
pub async fn set_index(&self, index: SetSourceFilterIndex<'_>) -> Result<()> {
self.client
.send_message(RequestType::SetSourceFilterIndex(index))
.await
}
/// Sets the settings of a source filter.
pub async fn set_source_filter_settings<T>(
&self,
settings: SetSourceFilterSettings<'_, T>,
) -> Result<()>
pub async fn set_settings<T>(&self, settings: SetSourceFilterSettings<'_, T>) -> Result<()>
where
T: Serialize,
{
self.client
.send_message(RequestType::SetSourceFilterSettings(
SetSourceFilterSettingsInternal {
source_name: settings.source_name,
filter_name: settings.filter_name,
filter_settings: serde_json::to_value(&settings.filter_settings)
source: settings.source,
filter: settings.filter,
settings: serde_json::to_value(&settings.settings)
.map_err(Error::SerializeCustomData)?,
overlay: settings.overlay,
},
@ -131,10 +105,7 @@ impl<'a> Filters<'a> {
}
/// Sets the enable state of a source filter.
pub async fn set_source_filter_enabled(
&self,
enabled: SetSourceFilterEnabled<'_>,
) -> Result<()> {
pub async fn set_enabled(&self, enabled: SetSourceFilterEnabled<'_>) -> Result<()> {
self.client
.send_message(RequestType::SetSourceFilterEnabled(enabled))
.await

@ -13,19 +13,17 @@ pub struct General<'a> {
impl<'a> General<'a> {
/// Gets data about the current plugin and RPC version.
pub async fn get_version(&self) -> Result<responses::Version> {
pub async fn version(&self) -> Result<responses::Version> {
self.client.send_message(RequestType::GetVersion).await
}
/// Gets statistics about OBS, obs-websocket, and the current session.
pub async fn get_stats(&self) -> Result<responses::Stats> {
pub async fn stats(&self) -> Result<responses::Stats> {
self.client.send_message(RequestType::GetStats).await
}
/// Broadcasts a custom event to all web-socket clients. Receivers are clients which are
/// identified and subscribed.
///
/// - `event_data`: Data payload to emit to all receivers.
pub async fn broadcast_custom_event<T>(&self, event_data: &T) -> Result<()>
where
T: Serialize,
@ -41,7 +39,7 @@ impl<'a> General<'a> {
}
/// Call a request registered to a vendor.
///
/// A vendor is a unique name registered by a third-party plugin or script, which allows for
/// custom requests and events to be added to obs-websocket. If a plugin or script implements
/// vendor requests or events, documentation is expected to be provided with them.
@ -64,37 +62,28 @@ impl<'a> General<'a> {
}
/// Gets an array of all hotkey names in OBS.
pub async fn get_hotkey_list(&self) -> Result<Vec<String>> {
pub async fn list_hotkeys(&self) -> Result<Vec<String>> {
self.client
.send_message::<responses::Hotkeys>(RequestType::GetHotkeyList)
.await
.map(|h| h.hotkeys)
}
/// Triggers a hotkey using its name. See [`General::get_hotkey_list`].
///
/// - `hotkey_name`: Name of the hotkey to trigger.
pub async fn trigger_hotkey_by_name(&self, hotkey_name: &str) -> Result<()> {
/// Triggers a hotkey using its name. See [`General::list_hotkeys`].
pub async fn trigger_hotkey_by_name(&self, name: &str) -> Result<()> {
self.client
.send_message(RequestType::TriggerHotkeyByName { hotkey_name })
.send_message(RequestType::TriggerHotkeyByName { name })
.await
}
/// Triggers a hotkey using a sequence of keys.
///
/// - `key_id`: The OBS key ID to use. See
/// <https://github.com/obsproject/obs-studio/blob/master/libobs/obs-hotkeys.h>.
/// - `key_modifiers`: Object containing key modifiers to apply.
pub async fn trigger_hotkey_by_key_sequence(
&self,
key_id: &str,
key_modifiers: KeyModifiers,
id: &str,
modifiers: KeyModifiers,
) -> Result<()> {
self.client
.send_message(RequestType::TriggerHotkeyByKeySequence {
key_id,
key_modifiers,
})
.send_message(RequestType::TriggerHotkeyByKeySequence { id, modifiers })
.await
}
}

@ -18,19 +18,15 @@ pub struct Inputs<'a> {
impl<'a> Inputs<'a> {
/// Gets an array of all inputs in OBS.
///
/// - `input_kind`: Restrict the array to only inputs of the specified kind.
pub async fn get_input_list(&self, input_kind: Option<&str>) -> Result<Vec<responses::Input>> {
pub async fn list(&self, kind: Option<&str>) -> Result<Vec<responses::Input>> {
self.client
.send_message::<responses::Inputs>(RequestType::GetInputList { input_kind })
.send_message::<responses::Inputs>(RequestType::GetInputList { kind })
.await
.map(|i| i.inputs)
}
/// Gets an array of all available input kinds in OBS.
///
/// - `unversioned`: Return all kinds as unversioned or with version suffixes (if available).
pub async fn get_input_kind_list(&self, unversioned: bool) -> Result<Vec<String>> {
pub async fn list_kinds(&self, unversioned: bool) -> Result<Vec<String>> {
self.client
.send_message::<responses::InputKinds>(RequestType::GetInputKindList { unversioned })
.await
@ -38,15 +34,13 @@ impl<'a> Inputs<'a> {
}
/// Gets the default settings for an input kind.
///
/// - `input_kind`: Input kind to get the default settings for.
pub async fn get_input_default_settings<T>(&self, input_kind: &str) -> Result<T>
pub async fn default_settings<T>(&self, kind: &str) -> Result<T>
where
T: DeserializeOwned,
{
self.client
.send_message::<responses::DefaultInputSettings<T>>(
RequestType::GetInputDefaultSettings { input_kind },
RequestType::GetInputDefaultSettings { kind },
)
.await
.map(|dis| dis.default_input_settings)
@ -55,32 +49,25 @@ impl<'a> Inputs<'a> {
/// Gets the settings of an input.
///
/// **Note:** Does not include defaults. To create the entire settings object, overlay input
/// settings over the default input settings provided by [`get_input_default_settings`].
///
/// - `input_name`: Name of the input to get the settings of.
///
/// [`get_input_default_settings`]: Inputs::get_input_default_settings
pub async fn get_input_settings<T>(
&self,
input_name: &str,
) -> Result<responses::InputSettings<T>>
/// settings over the default input settings provided by [`Inputs::default_settings`].
pub async fn settings<T>(&self, name: &str) -> Result<responses::InputSettings<T>>
where
T: DeserializeOwned,
{
self.client
.send_message(RequestType::GetInputSettings { input_name })
.send_message(RequestType::GetInputSettings { name })
.await
}
/// Sets the settings of an input.
pub async fn set_input_settings<T>(&self, settings: SetInputSettings<'_, T>) -> Result<()>
pub async fn set_settings<T>(&self, settings: SetInputSettings<'_, T>) -> Result<()>
where
T: Serialize,
{
self.client
.send_message(RequestType::SetInputSettings(SetInputSettingsInternal {
input_name: settings.input_name,
input_settings: serde_json::to_value(&settings.input_settings)
input: settings.input,
settings: serde_json::to_value(&settings.settings)
.map_err(Error::SerializeCustomData)?,
overlay: settings.overlay,
}))
@ -88,90 +75,66 @@ impl<'a> Inputs<'a> {
}
/// Gets the audio mute state of an input.
///
/// - `input_name`: Name of input to get the mute state of.
pub async fn get_input_mute(&self, input_name: &str) -> Result<bool> {
pub async fn muted(&self, name: &str) -> Result<bool> {
self.client
.send_message::<responses::InputMuted>(RequestType::GetInputMute { input_name })
.send_message::<responses::InputMuted>(RequestType::GetInputMute { name })
.await
.map(|im| im.input_muted)
.map(|im| im.muted)
}
/// Sets the audio mute state of an input..
///
/// - `input_name`: Name of the input to set the mute state of.
/// - `input_muted`: Whether to mute the input.
pub async fn set_input_mute(&self, input_name: &str, input_muted: bool) -> Result<()> {
/// Sets the audio mute state of an input.
pub async fn set_muted(&self, name: &str, muted: bool) -> Result<()> {
self.client
.send_message(RequestType::SetInputMute {
input_name,
input_muted,
})
.send_message(RequestType::SetInputMute { name, muted })
.await
}
/// Toggles the audio mute state of an input.
///
/// - `input_name`: Name of the input to toggle the mute state of.
pub async fn toggle_input_mute(&self, input_name: &str) -> Result<bool> {
pub async fn toggle_mute(&self, name: &str) -> Result<bool> {
self.client
.send_message::<responses::InputMuted>(RequestType::ToggleInputMute { input_name })
.send_message::<responses::InputMuted>(RequestType::ToggleInputMute { name })
.await
.map(|im| im.input_muted)
.map(|im| im.muted)
}
/// Gets the current volume setting of an input.
///
/// - `input_name`: Name of the input to get the volume of.
pub async fn get_input_volume(&self, input_name: &str) -> Result<responses::InputVolume> {
pub async fn volume(&self, name: &str) -> Result<responses::InputVolume> {
self.client
.send_message(RequestType::GetInputVolume { input_name })
.send_message(RequestType::GetInputVolume { name })
.await
}
/// Sets the volume setting of an input.
///
/// - `input_name`: Name of the input to set the volume of.
/// - `input_volume`: Volume settings in either mul or dB.
pub async fn set_input_volume(&self, input_name: &str, input_volume: Volume) -> Result<()> {
pub async fn set_volume(&self, name: &str, volume: Volume) -> Result<()> {
self.client
.send_message(RequestType::SetInputVolume {
input_name,
input_volume,
})
.send_message(RequestType::SetInputVolume { name, volume })
.await
}
/// Sets the name of an input (rename).
///
/// - `input_name`: Current input name.
/// - `new_input_name`: New name for the input.
pub async fn set_input_name(&self, input_name: &str, new_input_name: &str) -> Result<()> {
pub async fn set_name(&self, name: &str, new: &str) -> Result<()> {
self.client
.send_message(RequestType::SetInputName {
input_name,
new_input_name,
})
.send_message(RequestType::SetInputName { name, new })
.await
}
/// Creates a new input, adding it as a scene item to the specified scene.
pub async fn create_input<T>(&self, input: CreateInput<'_, T>) -> Result<i64>
pub async fn create<T>(&self, input: CreateInput<'_, T>) -> Result<i64>
where
T: Serialize,
{
self.client
.send_message::<responses::SceneItemId>(RequestType::CreateInput(CreateInputInternal {
scene_name: input.scene_name,
input_name: input.input_name,
input_kind: input.input_kind,
input_settings: input
.input_settings
scene: input.scene,
input: input.input,
kind: input.kind,
settings: input
.settings
.map(|settings| {
serde_json::to_value(&settings).map_err(Error::SerializeCustomData)
})
.transpose()?,
scene_item_enabled: input.scene_item_enabled,
enabled: input.enabled,
}))
.await
.map(|sii| sii.scene_item_id)
@ -180,71 +143,49 @@ impl<'a> Inputs<'a> {
/// Removes an existing input.
///
/// **Note:** Will immediately remove all associated scene items.
///
/// - `input_name`: Name of the input to remove.
pub async fn remove_input(&self, input_name: &str) -> Result<()> {
pub async fn remove(&self, name: &str) -> Result<()> {
self.client
.send_message(RequestType::RemoveInput { input_name })
.send_message(RequestType::RemoveInput { name })
.await
}
/// Gets the audio sync offset of an input.
///
/// **Note:** The audio sync offset can be negative too!
///
/// - `input_name`: Name of the input to get the audio sync offset of.
pub async fn get_input_audio_sync_offset(&self, input_name: &str) -> Result<Duration> {
pub async fn audio_sync_offset(&self, name: &str) -> Result<Duration> {
self.client
.send_message::<responses::AudioSyncOffset>(RequestType::GetInputAudioSyncOffset {
input_name,
name,
})
.await
.map(|aso| aso.input_audio_sync_offset)
}
/// Sets the audio sync offset of an input.
///
/// - `input_name`: Name of the input to set the audio sync offset of.
/// - `input_audio_sync_offset`: New audio sync offset in milliseconds.
pub async fn set_input_audio_sync_offset(
&self,
input_name: &str,
input_audio_sync_offset: Duration,
) -> Result<()> {
pub async fn set_audio_sync_offset(&self, name: &str, offset: Duration) -> Result<()> {
self.client
.send_message(RequestType::SetInputAudioSyncOffset {
input_name,
input_audio_sync_offset,
})
.send_message(RequestType::SetInputAudioSyncOffset { name, offset })
.await
}
/// Gets the audio monitor type of input.
///
/// - `input_name`: Name of the input to get the audio monitor type of.
pub async fn get_input_audio_monitor_type(&self, input_name: &str) -> Result<MonitorType> {
pub async fn audio_monitor_type(&self, name: &str) -> Result<MonitorType> {
self.client
.send_message::<responses::AudioMonitorType>(RequestType::GetInputAudioMonitorType {
input_name,
name,
})
.await
.map(|amt| amt.monitor_type)
}
/// Sets the audio monitor type of input.
///
/// - `input_name`: Name of the input to set the audio monitor type of.
/// - `monitor_type`: Audio monitor type.
pub async fn set_input_audio_monitor_type(
pub async fn set_audio_monitor_type(
&self,
input_name: &str,
name: &str,
monitor_type: MonitorType,
) -> Result<()> {
self.client
.send_message(RequestType::SetInputAudioMonitorType {
input_name,
monitor_type,
})
.send_message(RequestType::SetInputAudioMonitorType { name, monitor_type })
.await
}
@ -252,20 +193,14 @@ impl<'a> Inputs<'a> {
///
/// **Note:** Use this in cases where an input provides a dynamic, selectable list of items. For
/// example, display capture, where it provides a list of available displays.
///
/// - `input_name`: Name of the input.
/// - `property_name`: Name of the list property to get the items of.
pub async fn get_input_properties_list_property_items(
pub async fn properties_list_property_items(
&self,
input_name: &str,
property_name: &str,
input: &str,
property: &str,
) -> Result<Vec<responses::ListPropertyItem>> {
self.client
.send_message::<responses::ListPropertyItems>(
RequestType::GetInputPropertiesListPropertyItems {
input_name,
property_name,
},
RequestType::GetInputPropertiesListPropertyItems { input, property },
)
.await
.map(|lpi| lpi.property_items)
@ -276,19 +211,9 @@ impl<'a> Inputs<'a> {
/// **Note:** Use this in cases where there is a button in the properties of an input that
/// cannot be accessed in any other way. For example, browser sources, where there is a refresh
/// button.
///
/// - `input_name`: Name of the input.
/// - `property_name`: Name of the button property to press.
pub async fn press_input_properties_button(
&self,
input_name: &str,
property_name: &str,
) -> Result<()> {
pub async fn press_properties_button(&self, input: &str, property: &str) -> Result<()> {
self.client
.send_message(RequestType::PressInputPropertiesButton {
input_name,
property_name,
})
.send_message(RequestType::PressInputPropertiesButton { input, property })
.await
}
}

@ -10,9 +10,7 @@ pub struct MediaInputs<'a> {
impl<'a> MediaInputs<'a> {
/// Gets the status of a media input.
///
/// - `input_name`: Name of the media input.
pub async fn get_media_input_status(&self, input_name: &str) -> Result<responses::MediaStatus> {
pub async fn status(&self, input_name: &str) -> Result<responses::MediaStatus> {
self.client
.send_message(RequestType::GetMediaInputStatus { input_name })
.await
@ -21,14 +19,7 @@ impl<'a> MediaInputs<'a> {
/// Sets the cursor position of a media input.
///
/// This request does not perform bounds checking of the cursor position.
///
/// - `input_name`: Name of the media input.
/// - `media_cursor`: New cursor position to set.
pub async fn set_media_input_cursor(
&self,
input_name: &str,
media_cursor: Duration,
) -> Result<()> {
pub async fn set_cursor(&self, input_name: &str, media_cursor: Duration) -> Result<()> {
self.client
.send_message(RequestType::SetMediaInputCursor {
input_name,
@ -40,10 +31,7 @@ impl<'a> MediaInputs<'a> {
/// Offsets the current cursor position of a media input by the specified value.
///
/// This request does not perform bounds checking of the cursor position.
///
/// - `input_name`: Name of the media input.
/// - `media_cursor_offset`: Value to offset the current cursor position by.
pub async fn offset_media_input_cursor(
pub async fn offset_cursor(
&self,
input_name: &str,
media_cursor_offset: Duration,
@ -57,14 +45,7 @@ impl<'a> MediaInputs<'a> {
}
/// Triggers an action on a media input.
///
/// - `input_name`: Name of the media input.
/// - `media_action`: Identifier of the media action.
pub async fn trigger_media_input_action(
&self,
input_name: &str,
media_action: MediaAction,
) -> Result<()> {
pub async fn trigger_action(&self, input_name: &str, media_action: MediaAction) -> Result<()> {
self.client
.send_message(RequestType::TriggerMediaInputAction {
input_name,

@ -81,7 +81,7 @@ pub struct Client {
/// of a request ID and the value is a oneshot sender that allows to send the response back to
/// the other end that waits for the response.
receivers: Arc<ReceiverList>,
/// A list of awaiting [`reidentify`](Self::reidentify) requests, waiting for confirmation. As
/// A list of awaiting [`Self::reidentify`] requests, waiting for confirmation. As
/// these requests don't carry any kind of ID, they're handled sequentially and must be tracked
/// separate from normal requests.
reidentify_receivers: Arc<ReidentifyReceiverList>,
@ -238,16 +238,20 @@ impl Client {
match message {
ServerMessage::RequestResponse(response) => {
trace!(id = %response.request_id, "got request-response message");
trace!(
id = %response.id,
status = ?response.status,
"got request-response message",
);
receivers2.notify(response).await?;
}
#[cfg(feature = "events")]
ServerMessage::Event(event) => {
trace!("got OBS event");
trace!(?event, "got OBS event");
events_tx.send(event).ok();
}
ServerMessage::Identified(identified) => {
trace!("got identified message");
trace!(?identified, "got identified message");
reidentify_receivers2.notify(identified).await;
}
_ => return Err(InnerError::UnexpectedMessage(message)),

@ -8,11 +8,11 @@ pub struct Outputs<'a> {
impl<'a> Outputs<'a> {
/// Gets the status of the virtual cam output.
pub async fn get_virtual_cam_status(&self) -> Result<bool> {
pub async fn virtual_cam_status(&self) -> Result<bool> {
self.client
.send_message::<responses::OutputActive>(RequestType::GetVirtualCamStatus)
.await
.map(|oa| oa.output_active)
.map(|oa| oa.active)
}
/// Toggles the state of the virtual cam output.
@ -20,7 +20,7 @@ impl<'a> Outputs<'a> {
self.client
.send_message::<responses::OutputActive>(RequestType::ToggleVirtualCam)
.await
.map(|oa| oa.output_active)
.map(|oa| oa.active)
}
/// Starts the virtual cam output.
@ -34,11 +34,11 @@ impl<'a> Outputs<'a> {
}
/// Gets the status of the replay buffer output.
pub async fn get_replay_buffer_status(&self) -> Result<bool> {
pub async fn replay_buffer_status(&self) -> Result<bool> {
self.client
.send_message::<responses::OutputActive>(RequestType::GetReplayBufferStatus)
.await
.map(|oa| oa.output_active)
.map(|oa| oa.active)
}
/// Toggles the state of the replay buffer output.
@ -46,7 +46,7 @@ impl<'a> Outputs<'a> {
self.client
.send_message::<responses::OutputActive>(RequestType::ToggleReplayBuffer)
.await
.map(|oa| oa.output_active)
.map(|oa| oa.active)
}
/// Starts the replay buffer output.
@ -71,7 +71,7 @@ impl<'a> Outputs<'a> {
}
/// Gets the file name of the last replay buffer save file.
pub async fn get_last_replay_buffer_replay(&self) -> Result<String> {
pub async fn last_replay_buffer_replay(&self) -> Result<String> {
self.client
.send_message::<responses::SavedReplayPath>(RequestType::GetLastReplayBufferReplay)
.await

@ -8,43 +8,43 @@ pub struct Recording<'a> {
impl<'a> Recording<'a> {
/// Gets the status of the record output.
pub async fn get_record_status(&self) -> Result<responses::RecordStatus> {
pub async fn status(&self) -> Result<responses::RecordStatus> {
self.client.send_message(RequestType::GetRecordStatus).await
}
/// Toggles the status of the record output.
pub async fn toggle_record(&self) -> Result<bool> {
pub async fn toggle(&self) -> Result<bool> {
self.client
.send_message::<responses::OutputActive>(RequestType::ToggleRecord)
.await
.map(|oa| oa.output_active)
.map(|oa| oa.active)
}
/// Starts the record output.
pub async fn start_record(&self) -> Result<()> {
pub async fn start(&self) -> Result<()> {
self.client.send_message(RequestType::StartRecord).await
}
/// Stops the record output.
pub async fn stop_record(&self) -> Result<()> {
pub async fn stop(&self) -> Result<()> {
self.client.send_message(RequestType::StopRecord).await
}
/// Toggles pause on the record output.
pub async fn toggle_record_pause(&self) -> Result<bool> {
pub async fn toggle_pause(&self) -> Result<bool> {
self.client
.send_message::<responses::OutputPaused>(RequestType::ToggleRecordPause)
.await
.map(|op| op.output_paused)
.map(|op| op.paused)
}
/// Pauses the record output.
pub async fn pause_record(&self) -> Result<()> {
pub async fn pause(&self) -> Result<()> {
self.client.send_message(RequestType::PauseRecord).await
}
/// Resumes the record output.
pub async fn resume_record(&self) -> Result<()> {
pub async fn resume(&self) -> Result<()> {
self.client.send_message(RequestType::ResumeRecord).await
}
}

@ -17,37 +17,25 @@ pub struct SceneItems<'a> {
impl<'a> SceneItems<'a> {
/// Gets a list of all scene items in a scene.
///
/// - `scene_name`: Name of the scene to get the items of.
pub async fn get_scene_item_list(&self, scene_name: &str) -> Result<Vec<responses::SceneItem>> {
pub async fn list(&self, scene: &str) -> Result<Vec<responses::SceneItem>> {
self.client
.send_message::<responses::SceneItemList>(RequestType::GetSceneItemList { scene_name })
.send_message::<responses::SceneItemList>(RequestType::GetSceneItemList { scene })
.await
.map(|sil| sil.scene_items)
}
/// Basically [`get_scene_item_list`](Self::get_scene_item_list), but for groups.
/// Basically [`Self::list`], but for groups.
///
/// Using groups at all in OBS is discouraged, as they are very broken under the hood.
///
/// - `scene_name`: Name of the group to get the items of.
pub async fn get_group_scene_item_list(
&self,
scene_name: &str,
) -> Result<Vec<responses::SceneItem>> {
pub async fn list_group(&self, scene: &str) -> Result<Vec<responses::SceneItem>> {
self.client
.send_message::<responses::SceneItemList>(RequestType::GetGroupSceneItemList {
scene_name,
})
.send_message::<responses::SceneItemList>(RequestType::GetGroupSceneItemList { scene })
.await
.map(|sil| sil.scene_items)
}
/// Searches a scene for a source, and returns its id.
///
/// - `scene_name`: Name of the scene or group to search in.
/// - `source_name`: Name of the source to find.
pub async fn get_scene_item_id(&self, get: GetSceneItemId<'_>) -> Result<i64> {
pub async fn id(&self, get: GetSceneItemId<'_>) -> Result<i64> {
self.client
.send_message::<responses::SceneItemId>(RequestType::GetSceneItemId(get))
.await
@ -55,7 +43,7 @@ impl<'a> SceneItems<'a> {
}
/// Creates a new scene item using a source.
pub async fn create_scene_item(&self, create: CreateSceneItem<'_>) -> Result<i64> {
pub async fn create(&self, create: CreateSceneItem<'_>) -> Result<i64> {
self.client
.send_message::<responses::SceneItemId>(RequestType::CreateSceneItem(create))
.await
@ -63,20 +51,14 @@ impl<'a> SceneItems<'a> {
}
/// Removes a scene item from a scene.
///
/// - `scene_name`: Name of the scene the item is in.
/// - `scene_item_id`: Numeric ID of the scene item.
pub async fn remove_scene_item(&self, scene_name: &str, scene_item_id: i64) -> Result<()> {
pub async fn remove(&self, scene: &str, item_id: i64) -> Result<()> {
self.client
.send_message(RequestType::RemoveSceneItem {
scene_name,
scene_item_id,
})
.send_message(RequestType::RemoveSceneItem { scene, item_id })
.await
}
/// Duplicates a scene item, copying all transform and crop info.
pub async fn duplicate_scene_item(&self, duplicate: DuplicateSceneItem<'_>) -> Result<i64> {
pub async fn duplicate(&self, duplicate: DuplicateSceneItem<'_>) -> Result<i64> {
self.client
.send_message::<responses::SceneItemId>(RequestType::DuplicateSceneItem(duplicate))
.await
@ -84,78 +66,58 @@ impl<'a> SceneItems<'a> {
}
/// Gets the transform and crop info of a scene item.
///
/// - `scene_name`: Name of the scene the item is in.
/// - `scene_item_id`: Numeric ID of the scene item.
pub async fn get_scene_item_transform(
pub async fn transform(
&self,
scene_name: &str,
scene_item_id: i64,
scene: &str,
item_id: i64,
) -> Result<responses::SceneItemTransform> {
self.client
.send_message::<responses::GetSceneItemTransform>(RequestType::GetSceneItemTransform {
scene_name,
scene_item_id,
scene,
item_id,
})
.await
.map(|gsit| gsit.scene_item_transform)
}
/// Sets the transform and crop info of a scene item.
pub async fn set_scene_item_transform(
&self,
transform: SetSceneItemTransform<'_>,
) -> Result<()> {
pub async fn set_transform(&self, transform: SetSceneItemTransform<'_>) -> Result<()> {
self.client
.send_message(RequestType::SetSceneItemTransform(transform))
.await
}
/// Gets the enable state of a scene item.
///
/// - `scene_name`: Name of the scene the item is in.
/// - `scene_item_id`: Numeric ID of the scene item.
pub async fn get_scene_item_enabled(
&self,
scene_name: &str,
scene_item_id: i64,
) -> Result<bool> {
pub async fn enabled(&self, scene: &str, item_id: i64) -> Result<bool> {
self.client
.send_message::<responses::SceneItemEnabled>(RequestType::GetSceneItemEnabled {
scene_name,
scene_item_id,
scene,
item_id,
})
.await
.map(|sie| sie.scene_item_enabled)
}
/// Sets the enable state of a scene item.
pub async fn set_scene_item_enabled(&self, enabled: SetSceneItemEnabled<'a>) -> Result<()> {
pub async fn set_enabled(&self, enabled: SetSceneItemEnabled<'a>) -> Result<()> {
self.client
.send_message(RequestType::SetSceneItemEnabled(enabled))
.await
}
/// Gets the lock state of a scene item.
///
/// - `scene_name`: Name of the scene the item is in.
/// - `scene_item_id`: Numeric ID of the scene item.
pub async fn get_scene_item_locked(
&self,
scene_name: &str,
scene_item_id: i64,
) -> Result<bool> {
pub async fn locked(&self, scene: &str, item_id: i64) -> Result<bool> {
self.client
.send_message::<responses::SceneItemLocked>(RequestType::GetSceneItemLocked {
scene_name,
scene_item_id,
scene,
item_id,
})
.await
.map(|sil| sil.scene_item_locked)
}
/// Sets the lock state of a scene item.
pub async fn set_scene_item_locked(&self, locked: SetSceneItemLocked<'_>) -> Result<()> {
pub async fn set_locked(&self, locked: SetSceneItemLocked<'_>) -> Result<()> {
self.client
.send_message(RequestType::SetSceneItemLocked(locked))
.await
@ -164,54 +126,38 @@ impl<'a> SceneItems<'a> {
/// Gets the index position of a scene item in a scene.
///
/// An index of 0 is at the bottom of the source list in the UI.
///
/// - `scene_name`: Name of the scene the item is in.
/// - `scene_item_id`: Numeric ID of the scene item.
pub async fn get_scene_item_index(&self, scene_name: &str, scene_item_id: i64) -> Result<u32> {
pub async fn index(&self, scene: &str, item_id: i64) -> Result<u32> {
self.client
.send_message::<responses::SceneItemIndex>(RequestType::GetSceneItemIndex {
scene_name,
scene_item_id,
scene,
item_id,
})
.await
.map(|sii| sii.scene_item_index)
}
/// Sets the index position of a scene item in a scene.
pub async fn set_scene_item_index(&self, index: SetSceneItemIndex<'_>) -> Result<()> {
pub async fn set_index(&self, index: SetSceneItemIndex<'_>) -> Result<()> {
self.client
.send_message(RequestType::SetSceneItemIndex(index))
.await
}
/// Gets private scene item settings.
///
/// - `scene_name`: Name of the scene the item is in.
/// - `scene_item_id`: Numeric ID of the scene item.
pub async fn get_scene_item_private_settings<T>(
&self,
scene_name: &str,
scene_item_id: i64,
) -> Result<T>
pub async fn private_settings<T>(&self, scene: &str, item_id: i64) -> Result<T>
where
T: DeserializeOwned,
{
self.client
.send_message::<responses::SceneItemSettings<T>>(
RequestType::GetSceneItemPrivateSettings {
scene_name,
scene_item_id,
},
RequestType::GetSceneItemPrivateSettings { scene, item_id },
)
.await
.map(|sis| sis.scene_item_settings)
}
/// Sets private scene item settings.
///
/// - `scene_name`: Name of the scene the item is in.
/// - `scene_item_id`: Numeric ID of the scene item.
pub async fn set_scene_item_private_settings<T>(
pub async fn set_private_settings<T>(
&self,
settings: SetSceneItemPrivateSettings<'_, T>,
) -> Result<()>
@ -221,9 +167,9 @@ impl<'a> SceneItems<'a> {
self.client
.send_message(RequestType::SetSceneItemPrivateSettings(
SetSceneItemPrivateSettingsInternal {
scene_name: settings.scene_name,
scene_item_id: settings.scene_item_id,
scene_item_settings: serde_json::to_value(&settings.scene_item_settings)
scene: settings.scene,
item_id: settings.item_id,
settings: serde_json::to_value(&settings.settings)
.map_err(Error::SerializeCustomData)?,
},
))

@ -11,7 +11,7 @@ pub struct Scenes<'a> {
impl<'a> Scenes<'a> {
/// Gets an array of all scenes in OBS.
pub async fn get_scene_list(&self) -> Result<responses::Scenes> {
pub async fn list(&self) -> Result<responses::Scenes> {
self.client.send_message(RequestType::GetSceneList).await
}
@ -19,7 +19,7 @@ impl<'a> Scenes<'a> {
///
/// Groups in OBS are actually scenes, but renamed and modified. In obs-websocket, we treat them
/// as scenes where we can.
pub async fn get_group_list(&self) -> Result<Vec<String>> {
pub async fn list_groups(&self) -> Result<Vec<String>> {
self.client
.send_message::<responses::Groups>(RequestType::GetGroupList)
.await
@ -27,7 +27,7 @@ impl<'a> Scenes<'a> {
}
/// Gets the current program scene.
pub async fn get_current_program_scene(&self) -> Result<String> {
pub async fn current_program_scene(&self) -> Result<String> {
self.client
.send_message::<responses::CurrentProgramScene>(RequestType::GetCurrentProgramScene)
.await
@ -35,8 +35,6 @@ impl<'a> Scenes<'a> {
}
/// Sets the current program scene.
///
/// - `scene_name`: Scene to set as the current program scene.
pub async fn set_current_program_scene(&self, scene_name: &str) -> Result<()> {
self.client
.send_message(RequestType::SetCurrentProgramScene { scene_name })
@ -46,7 +44,7 @@ impl<'a> Scenes<'a> {
/// Gets the current preview scene.
///
/// Only available when studio mode is enabled.
pub async fn get_current_preview_scene(&self) -> Result<String> {
pub async fn current_preview_scene(&self) -> Result<String> {
self.client
.send_message::<responses::CurrentPreviewScene>(RequestType::GetCurrentPreviewScene)
.await
@ -56,8 +54,6 @@ impl<'a> Scenes<'a> {
/// Sets the current preview scene.
///
/// Only available when studio mode is enabled.
///
/// - `scene_name`: Scene to set as the current preview scene.
pub async fn set_current_preview_scene(&self, scene_name: &str) -> Result<()> {
self.client
.send_message(RequestType::SetCurrentPreviewScene { scene_name })
@ -65,40 +61,28 @@ impl<'a> Scenes<'a> {
}
/// Sets the name of a scene (rename).
///
/// - `scene_name`: Name of the scene to be renamed.
/// - `new_scene_name`: New name for the scene.
pub async fn set_scene_name(&self, scene_name: &str, new_scene_name: &str) -> Result<()> {
pub async fn set_name(&self, name: &str, new: &str) -> Result<()> {
self.client
.send_message(RequestType::SetSceneName {
scene_name,
new_scene_name,
})
.send_message(RequestType::SetSceneName { name, new })
.await
}
/// Creates a new scene in OBS.
///
/// - `scene_name`: Name for the new scene.
pub async fn create_scene(&self, scene_name: &str) -> Result<()> {
pub async fn create(&self, name: &str) -> Result<()> {
self.client
.send_message(RequestType::CreateScene { scene_name })
.send_message(RequestType::CreateScene { name })
.await
}
/// Removes a scene from OBS.
///
/// - `scene_name`: Name of the scene to remove.
pub async fn remove_scene(&self, scene_name: &str) -> Result<()> {
pub async fn remove(&self, name: &str) -> Result<()> {
self.client
.send_message(RequestType::RemoveScene { scene_name })
.send_message(RequestType::RemoveScene { name })
.await
}
/// Gets the scene transition overridden for a scene.
///
/// - `scene_name`: Name of the scene.
pub async fn get_scene_scene_transition_override(
pub async fn transition_override(
&self,
scene_name: &str,
) -> Result<responses::SceneTransitionOverride> {
@ -108,7 +92,7 @@ impl<'a> Scenes<'a> {
}
/// Sets the scene transition overridden for a scene.
pub async fn set_scene_scene_transition_override(
pub async fn set_transition_override(
&self,
transition_override: SetSceneSceneTransitionOverride<'_>,
) -> Result<()> {

@ -11,24 +11,22 @@ pub struct Sources<'a> {
impl<'a> Sources<'a> {
/// Gets the active and show state of a source.
///
/// - `source_name`: Name of the source to get the active state of.
pub async fn get_source_active(&self, source_name: &str) -> Result<responses::SourceActive> {
pub async fn active(&self, name: &str) -> Result<responses::SourceActive> {
self.client
.send_message(RequestType::GetSourceActive { source_name })
.send_message(RequestType::GetSourceActive { name })
.await
}
/// Gets a Base64-encoded screenshot of a source.
///
/// The [`image_width`] and [`image_height`] parameters are treated as "scale to inner", meaning
/// The [`width`] and [`height`] parameters are treated as "scale to inner", meaning
/// the smallest ratio will be used and the aspect ratio of the original resolution is kept. If
/// [`image_width`] and [`image_height`] are not specified, the compressed image will use the
/// [`width`] and [`height`] are not specified, the compressed image will use the
/// full resolution of the source.
///
/// [`image_width`]: GetSourceScreenshot::image_width
/// [`image_height`]: GetSourceScreenshot::image_height
pub async fn get_source_screenshot(&self, settings: GetSourceScreenshot<'_>) -> Result<String> {
/// [`width`]: GetSourceScreenshot::width
/// [`height`]: GetSourceScreenshot::height
pub async fn take_screenshot(&self, settings: GetSourceScreenshot<'_>) -> Result<String> {
self.client
.send_message::<responses::ImageData>(RequestType::GetSourceScreenshot(settings))
.await
@ -37,14 +35,14 @@ impl<'a> Sources<'a> {
/// Saves a screenshot of a source to the file system.
///
/// The [`image_width`] and [`image_height`] parameters are treated as "scale to inner", meaning
/// The [`width`] and [`height`] parameters are treated as "scale to inner", meaning
/// the smallest ratio will be used and the aspect ratio of the original resolution is kept. If
/// [`image_width`] and [`image_height`] are not specified, the compressed image will use the
/// [`width`] and [`height`] are not specified, the compressed image will use the
/// full resolution of the source.
///
/// [`image_width`]: SaveSourceScreenshot::image_width
/// [`image_height`]: SaveSourceScreenshot::image_height
pub async fn save_source_screenshot(&self, settings: SaveSourceScreenshot<'_>) -> Result<()> {
/// [`width`]: SaveSourceScreenshot::width
/// [`height`]: SaveSourceScreenshot::height
pub async fn save_screenshot(&self, settings: SaveSourceScreenshot<'_>) -> Result<()> {
self.client
.send_message(RequestType::SaveSourceScreenshot(settings))
.await

@ -8,32 +8,30 @@ pub struct Streaming<'a> {
impl<'a> Streaming<'a> {
/// Gets the status of the stream output.
pub async fn get_stream_status(&self) -> Result<responses::StreamStatus> {
pub async fn status(&self) -> Result<responses::StreamStatus> {
self.client.send_message(RequestType::GetStreamStatus).await
}
/// Toggles the status of the stream output.
pub async fn toggle_stream(&self) -> Result<bool> {
pub async fn toggle(&self) -> Result<bool> {
self.client
.send_message::<responses::OutputActive>(RequestType::ToggleStream)
.await
.map(|ts| ts.output_active)
.map(|ts| ts.active)
}
/// Starts the stream output.
pub async fn start_stream(&self) -> Result<()> {
pub async fn start(&self) -> Result<()> {
self.client.send_message(RequestType::StartStream).await
}
/// Stops the stream output.
pub async fn stop_stream(&self) -> Result<()> {
pub async fn stop(&self) -> Result<()> {
self.client.send_message(RequestType::StopStream).await
}
/// Sends CEA-608 caption text over the stream output.
///
/// - `caption_text`: Caption text.
pub async fn send_stream_caption(&self, caption_text: &str) -> Result<()> {
pub async fn send_caption(&self, caption_text: &str) -> Result<()> {
self.client
.send_message(RequestType::SendStreamCaption { caption_text })
.await

@ -11,7 +11,7 @@ pub struct Transitions<'a> {
impl<'a> Transitions<'a> {
/// Gets an array of all available transition kinds.
pub async fn get_transition_kind_list(&self) -> Result<Vec<String>> {
pub async fn list_kinds(&self) -> Result<Vec<String>> {
self.client
.send_message::<responses::TransitionKinds>(RequestType::GetTransitionKindList)
.await
@ -19,14 +19,14 @@ impl<'a> Transitions<'a> {
}
/// Gets an array of all scene transitions in OBS.
pub async fn get_scene_transition_list(&self) -> Result<responses::SceneTransitionList> {
pub async fn list(&self) -> Result<responses::SceneTransitionList> {
self.client
.send_message(RequestType::GetSceneTransitionList)
.await
}
/// Gets information about the current scene transition.
pub async fn get_current_scene_transition(&self) -> Result<responses::CurrentSceneTransition> {
pub async fn current(&self) -> Result<responses::CurrentSceneTransition> {
self.client
.send_message(RequestType::GetCurrentSceneTransition)
.await
@ -36,44 +36,27 @@ impl<'a> Transitions<'a> {
///
/// **Small note:** While the namespace of scene transitions is generally unique, that
/// uniqueness is not a guarantee as it is with other resources like inputs.
///
/// - `transition_name`: Name of the transition to make active.
pub async fn set_current_scene_transition(&self, transition_name: &str) -> Result<()> {
pub async fn set_current(&self, name: &str) -> Result<()> {
self.client
.send_message(RequestType::SetCurrentSceneTransition { transition_name })
.send_message(RequestType::SetCurrentSceneTransition { name })
.await
}
/// Sets the duration of the current scene transition, if it is not fixed.
///
/// - `transition_duration`: Duration in milliseconds.
pub async fn set_current_scene_transition_duration(
&self,
transition_duration: Duration,
) -> Result<()> {
pub async fn set_current_duration(&self, duration: Duration) -> Result<()> {
self.client
.send_message(RequestType::SetCurrentSceneTransitionDuration {
transition_duration,
})
.send_message(RequestType::SetCurrentSceneTransitionDuration { duration })
.await
}
/// Sets the settings of the current scene transition.
///
/// - `transition_settings`: Settings object to apply to the transition.
/// - `overlay`: Whether to overlay over the current settings or replace them.
pub async fn set_current_scene_transition_settings<T>(
&self,
transition_settings: T,
overlay: Option<bool>,
) -> Result<()>
pub async fn set_current_settings<T>(&self, settings: T, overlay: Option<bool>) -> Result<()>
where
T: Serialize,
{
self.client
.send_message(RequestType::SetCurrentSceneTransitionSettings {
transition_settings: serde_json::to_value(&transition_settings)
.map_err(Error::SerializeCustomData)?,
settings: serde_json::to_value(&settings).map_err(Error::SerializeCustomData)?,
overlay,
})
.await
@ -82,7 +65,7 @@ impl<'a> Transitions<'a> {
/// Gets the cursor position of the current scene transition.
///
/// **Note:** `transitionCursor` will return `1.0` when the transition is inactive.
pub async fn get_current_scene_transition_cursor(&self) -> Result<f32> {
pub async fn current_cursor(&self) -> Result<f32> {
self.client
.send_message::<responses::TransitionCursor>(
RequestType::GetCurrentSceneTransitionCursor,
@ -93,7 +76,7 @@ impl<'a> Transitions<'a> {
/// Triggers the current scene transition. Same functionality as the `Transition` button in
/// studio mode.
pub async fn trigger_studio_mode_transition(&self) -> Result<()> {
pub async fn trigger(&self) -> Result<()> {
self.client
.send_message(RequestType::TriggerStudioModeTransition)
.await
@ -103,10 +86,6 @@ impl<'a> Transitions<'a> {
///
/// **Very important note:** This will be deprecated and replaced in a future version of
/// `obs-websocket`.
///
/// - `position`: New position.
/// - `release`: Whether to release the T-Bar. Only set `false` if you know that you will be
/// sending another position update.
pub async fn set_tbar_position(&self, position: f32, release: Option<bool>) -> Result<()> {
self.client
.send_message(RequestType::SetTbarPosition { position, release })

@ -8,53 +8,45 @@ pub struct Ui<'a> {
impl<'a> Ui<'a> {
/// Gets whether studio is enabled.
pub async fn get_studio_mode_enabled(&self) -> Result<bool> {
pub async fn studio_mode_enabled(&self) -> Result<bool> {
self.client
.send_message::<responses::StudioModeEnabled>(RequestType::GetStudioModeEnabled)
.await
.map(|sme| sme.studio_mode_enabled)
.map(|sme| sme.enabled)
}
/// Enables or disables studio mode.
///
/// - `studio_mode_enabled`: Enable or disable the studio mode.
pub async fn set_studio_mode_enabled(&self, studio_mode_enabled: bool) -> Result<()> {
/// - `enabled`: Enable or disable the studio mode.
pub async fn set_studio_mode_enabled(&self, enabled: bool) -> Result<()> {
self.client
.send_message(RequestType::SetStudioModeEnabled {
studio_mode_enabled,
})
.send_message(RequestType::SetStudioModeEnabled { enabled })
.await
}
/// Opens the properties dialog of an input.
///
/// - `input_name`: Name of the input to open the dialog of.
pub async fn open_input_properties_dialog(&self, input_name: &str) -> Result<()> {
pub async fn open_properties_dialog(&self, input: &str) -> Result<()> {
self.client
.send_message(RequestType::OpenInputPropertiesDialog { input_name })
.send_message(RequestType::OpenInputPropertiesDialog { input })
.await
}
/// Opens the filters dialog of an input.
///
/// - `input_name`: Name of the input to open the dialog of.
pub async fn open_input_filters_dialog(&self, input_name: &str) -> Result<()> {
pub async fn open_filters_dialog(&self, input: &str) -> Result<()> {
self.client
.send_message(RequestType::OpenInputFiltersDialog { input_name })
.send_message(RequestType::OpenInputFiltersDialog { input })
.await
}
/// Opens the interact dialog of an input.
///
/// - `input_name`: Name of the input to open the dialog of.
pub async fn open_input_interact_dialog(&self, input_name: &str) -> Result<()> {
pub async fn open_interact_dialog(&self, input: &str) -> Result<()> {
self.client
.send_message(RequestType::OpenInputInteractDialog { input_name })
.send_message(RequestType::OpenInputInteractDialog { input })
.await
}
/// Gets a list of connected monitors and information about them.
pub async fn get_monitor_list(&self) -> Result<Vec<responses::Monitor>> {
pub async fn list_monitors(&self) -> Result<Vec<responses::Monitor>> {
self.client
.send_message::<responses::MonitorList>(RequestType::GetMonitorList)
.await

@ -22,10 +22,10 @@ pub enum Event {
/// **Note:** We recommend using this event to trigger a pause of all polling requests, as
/// performing any requests during a scene collection change is considered undefined behavior
/// and can cause crashes!
#[serde(rename_all = "camelCase")]
CurrentSceneCollectionChanging {
/// Name of the current scene collection.
scene_collection_name: String,
#[serde(rename = "sceneCollectionName")]
name: String,
},
/// The current scene collection has changed.
///
@ -33,28 +33,28 @@ pub enum Event {
/// indicator to restart polling.
///
/// [`CurrentSceneCollectionChanging`]: Event::CurrentSceneCollectionChanging
#[serde(rename_all = "camelCase")]
CurrentSceneCollectionChanged {
/// Name of the new scene collection.
scene_collection_name: String,
#[serde(rename = "sceneCollectionName")]
name: String,
},
/// The scene collection list has changed.
#[serde(rename_all = "camelCase")]
SceneCollectionListChanged {
/// Updated list of scene collections.
scene_collections: Vec<String>,
#[serde(rename = "sceneCollections")]
collections: Vec<String>,
},
/// The current profile has begun changing.
#[serde(rename_all = "camelCase")]
CurrentProfileChanging {
/// Name of the current profile.
profile_name: String,
#[serde(rename = "profileName")]
name: String,
},
/// The current profile has changed.
#[serde(rename_all = "camelCase")]
CurrentProfileChanged {
/// Name of the new profile.
profile_name: String,
#[serde(rename = "profileName")]
name: String,
},
/// The profile list has changed.
#[serde(rename_all = "camelCase")]
@ -82,46 +82,51 @@ pub enum Event {
default_filter_settings: serde_json::Value,
},
/// A filter has been removed from a source.
#[serde(rename_all = "camelCase")]
SourceFilterRemoved {
/// Name of the source the filter was on.
source_name: String,
#[serde(rename = "sourceName")]
source: String,
/// Name of the filter.
filter_name: String,
#[serde(rename = "filterName")]
filter: String,
},
/// A source's filter list has been re-indexed.
#[serde(rename_all = "camelCase")]
SourceFilterListReindexed {
/// Name of the source.
source_name: String,
#[serde(rename = "sourceName")]
source: String,
/// Array of filter objects.
filters: Vec<SourceFilter>,
},
/// A source filter's enable state has changed.
#[serde(rename_all = "camelCase")]
SourceFilterEnableStateChanged {
/// Name of the source the filter is on.
source_name: String,
#[serde(rename = "sourceName")]
source: String,
/// Name of the filter.
filter_name: String,
#[serde(rename = "filterName")]
filter: String,
/// Whether the filter is enabled.
filter_enabled: bool,
#[serde(rename = "filterEnabled")]
enabled: bool,
},
/// The name of a source filter has changed.
#[serde(rename_all = "camelCase")]
SourceFilterNameChanged {
/// The source the filter is on.
source_name: String,
#[serde(rename = "sourceName")]
source: String,
/// Old name of the filter.
old_filter_name: String,
#[serde(rename = "oldFilterName")]
old_name: String,
/// New name of the filter.
filter_name: String,
#[serde(rename = "filterName")]
new_name: String,
},
// --------------------------------
// General
// --------------------------------
/// A custom event that was triggered by
/// [`broadcast_custom_event`](crate::client::General::broadcast_custom_event).
/// [`crate::client::General::broadcast_custom_event`].
///
/// The content can be any valid JSON object.
CustomEvent(serde_json::Value),
@ -159,88 +164,101 @@ pub enum Event {
default_input_settings: serde_json::Value,
},
/// An input has been removed.
#[serde(rename_all = "camelCase")]
InputRemoved {
/// Name of the input.
input_name: String,
#[serde(rename = "inputName")]
name: String,
},
/// The name of an input has changed.
#[serde(rename_all = "camelCase")]
InputNameChanged {
/// Old name of the input.
old_input_name: String,
#[serde(rename = "oldInputName")]
old_name: String,
/// New name of the input.
input_name: String,
#[serde(rename = "inputName")]
new_name: String,
},
/// An input's active state has changed.
///
/// When an input is active, it means it's being shown by the program feed.
#[serde(rename_all = "camelCase")]
InputActiveStateChanged {
/// Name of the input.
input_name: String,
#[serde(rename = "inputName")]
name: String,
/// Whether the input is active.
video_active: bool,
#[serde(rename = "videoActive")]
active: bool,
},
/// An input's show state has changed.
///
/// When an input is showing, it means it's being shown by the preview or a dialog.
#[serde(rename_all = "camelCase")]
InputShowStateChanged {
/// Name of the input.
input_name: String,
#[serde(rename = "inputName")]
name: String,
/// Whether the input is showing.
video_showing: bool,
#[serde(rename = "videoShowing")]
showing: bool,
},
/// An input's mute state has changed.
#[serde(rename_all = "camelCase")]
InputMuteStateChanged {
/// Name of the input.
input_name: String,
#[serde(rename = "inputName")]
name: String,
/// Whether the input is muted.
input_muted: bool,
#[serde(rename = "inputMuted")]
muted: bool,
},
/// An input's volume level has changed.
#[serde(rename_all = "camelCase")]
InputVolumeChanged {
/// Name of the input.
input_name: String,
#[serde(rename = "inputName")]
name: String,
/// New volume level in `multimap`.
input_volume_mul: f64,
#[serde(rename = "inputVolumeMul")]
mul: f64,
/// New volume level in `dB`.
input_volume_db: f64,
#[serde(rename = "inputVolumeDb")]
db: f64,
},
/// The audio balance value of an input has changed.
#[serde(rename_all = "camelCase")]
InputAudioBalanceChanged {
/// Name of the affected input.
input_name: String,
#[serde(rename = "inputName")]
name: String,
/// New audio balance value of the input.
input_audio_balance: f64,
#[serde(rename = "inputAudioBalance")]
audio_balance: f64,
},
/// The sync offset of an input has changed.
#[serde(rename_all = "camelCase")]
InputAudioSyncOffsetChanged {
/// Name of the input.
input_name: String,
#[serde(rename = "inputName")]
name: String,
/// New sync offset in milliseconds.
#[serde(deserialize_with = "crate::de::duration_millis")]
input_audio_sync_offset: Duration,
#[serde(
rename = "inputAudioSyncOffset",
deserialize_with = "crate::de::duration_millis"
)]
offset: Duration,
},
/// The audio tracks of an input have changed.
#[serde(rename_all = "camelCase")]
InputAudioTracksChanged {
/// Name of the input.
input_name: String,
#[serde(rename = "inputName")]
name: String,
/// Object of audio tracks along with their associated enable states.
input_audio_tracks: BTreeMap<String, bool>,
#[serde(rename = "inputAudioTracks")]
tracks: BTreeMap<String, bool>,
},
/// The monitor type of an input has changed.
#[serde(rename_all = "camelCase")]
InputAudioMonitorTypeChanged {
/// Name of the input.
input_name: String,
#[serde(rename = "inputName")]
name: String,
/// New monitor type of the input.
#[serde(rename = "monitorType")]
monitor_type: MonitorType,
},
/// A high-volume event providing volume levels of all active inputs every 50 milliseconds.
@ -253,180 +271,200 @@ pub enum Event {
// Media Inputs
// --------------------------------
/// A media input has started playing.
#[serde(rename_all = "camelCase")]
MediaInputPlaybackStarted {
/// Name of the input.
input_name: String,
#[serde(rename = "inputName")]
name: String,
},
/// A media input has finished playing.
#[serde(rename_all = "camelCase")]
MediaInputPlaybackEnded {
/// Name of the input.
input_name: String,
#[serde(rename = "inputName")]
name: String,
},
/// An action has been performed on an input.
#[serde(rename_all = "camelCase")]
MediaInputActionTriggered {
/// Name of the input.
input_name: String,
#[serde(rename = "inputName")]
name: String,
/// Action performed on the input.
#[serde(rename = "mediaAction")]
media_action: MediaAction,
},
// --------------------------------
// Outputs
// --------------------------------
/// The state of the stream output has changed.
#[serde(rename_all = "camelCase")]
StreamStateChanged {
/// Whether the output is active.
output_active: bool,
#[serde(rename = "outputActive")]
active: bool,
/// The specific state of the output.
output_state: OutputState,
#[serde(rename = "outputState")]
state: OutputState,
},
/// The state of the record output has changed.
#[serde(rename_all = "camelCase")]
RecordStateChanged {
/// Whether the output is active.
output_active: bool,
#[serde(rename = "outputActive")]
active: bool,
/// The specific state of the output.
output_state: OutputState,
#[serde(rename = "outputState")]
state: OutputState,
},
/// The state of the replay buffer output has changed.
#[serde(rename_all = "camelCase")]
ReplayBufferStateChanged {
/// Whether the output is active.
output_active: bool,
#[serde(rename = "outputActive")]
active: bool,
/// The specific state of the output.
output_state: OutputState,
#[serde(rename = "outputState")]
state: OutputState,
},
/// The state of the virtual cam output has changed.
#[serde(rename_all = "camelCase")]
VirtualcamStateChanged {
/// Whether the output is active.
output_active: bool,
#[serde(rename = "outputActive")]
active: bool,
/// The specific state of the output.
output_state: OutputState,
#[serde(rename = "outputState")]
state: OutputState,
},
/// The replay buffer has been saved.
#[serde(rename_all = "camelCase")]
ReplayBufferSaved {
/// Path of the saved replay file.
saved_replay_path: PathBuf,
#[serde(rename = "savedReplayPath")]
path: PathBuf,
},
// --------------------------------
// Scene Items
// --------------------------------
/// A scene item has been created.
#[serde(rename_all = "camelCase")]
SceneItemCreated {
/// Name of the scene the item was added to.
scene_name: String,
#[serde(rename = "sceneName")]
scene: String,
/// Name of the underlying source (input/scene).
source_name: String,
#[serde(rename = "sourceName")]
source: String,
/// Numeric ID of the scene item.
scene_item_id: u64,
#[serde(rename = "sceneItemId")]
item_id: u64,
/// Index position of the item.
scene_item_index: u32,
#[serde(rename = "sceneItemIndex")]
index: u32,
},
/// A scene item has been removed.
///
/// This event is not emitted when the scene the item is in is removed.
#[serde(rename_all = "camelCase")]
SceneItemRemoved {
/// Name of the scene the item was removed from.
scene_name: String,
#[serde(rename = "sceneName")]
scene: String,
/// Name of the underlying source (input/scene).
source_name: String,
#[serde(rename = "sourceName")]
source: String,
/// Numeric ID of the scene item.
scene_item_id: u64,
#[serde(rename = "sceneItemId")]
item_id: u64,
},
/// A scene's item list has been re-indexed.
#[serde(rename_all = "camelCase")]
SceneItemListReindexed {
/// Name of the scene.
scene_name: String,
#[serde(rename = "sceneName")]
scene: String,
/// Array of scene item objects.
scene_items: Vec<BasicSceneItem>,
#[serde(rename = "sceneItems")]
items: Vec<BasicSceneItem>,
},
/// A scene item's enable state has changed.
#[serde(rename_all = "camelCase")]
SceneItemEnableStateChanged {
/// Name of the scene the item is in.
scene_name: String,
#[serde(rename = "sceneName")]
scene: String,
/// Numeric ID of the scene item.
scene_item_id: u64,
#[serde(rename = "sceneItemId")]
item_id: u64,
/// Whether the scene item is enabled (visible).
scene_item_enabled: bool,
#[serde(rename = "sceneItemEnabled")]
enabled: bool,
},
/// A scene item's lock state has changed.
#[serde(rename_all = "camelCase")]
SceneItemLockStateChanged {
/// Name of the scene the item is in.
scene_name: String,
#[serde(rename = "sceneName")]
scene: String,
/// Numeric ID of the scene item.
scene_item_id: u64,
#[serde(rename = "sceneItemId")]
item_id: u64,
/// Whether the scene item is locked.
scene_item_locked: bool,
#[serde(rename = "sceneItemLocked")]
locked: bool,
},
/// A scene item has been selected in the UI.
#[serde(rename_all = "camelCase")]
SceneItemSelected {
/// Name of the scene the item is in.
scene_name: String,
#[serde(rename = "sceneName")]
scene: String,
/// Numeric ID of the scene item.
scene_item_id: u64,
#[serde(rename = "sceneItemId")]
item_id: u64,
},
/// The transform/crop of a scene item has changed.
#[serde(rename_all = "camelCase")]
SceneItemTransformChanged {
/// The name of the scene the item is in.
scene_name: String,
#[serde(rename = "sceneName")]
scene: String,
/// Numeric ID of the scene item.
scene_item_id: u64,
#[serde(rename = "sceneItemId")]
item_id: u64,
/// New transform/crop info of the scene item.
scene_item_transform: SceneItemTransform,
#[serde(rename = "sceneItemTransform")]
transform: SceneItemTransform,
},
// --------------------------------
// Scenes
// --------------------------------
/// A new scene has been created.
#[serde(rename_all = "camelCase")]
SceneCreated {
/// Name of the new scene.
scene_name: String,
#[serde(rename = "sceneName")]
name: String,
/// Whether the new scene is a group.
#[serde(rename = "isGroup")]
is_group: bool,
},
/// A scene has been removed.
#[serde(rename_all = "camelCase")]
SceneRemoved {
/// Name of the removed scene.
scene_name: String,
#[serde(rename = "sceneName")]
name: String,
/// Whether the scene was a group.
#[serde(rename = "isGroup")]
is_group: bool,
},
/// The name of a scene has changed.
#[serde(rename_all = "camelCase")]
SceneNameChanged {
/// Old name of the scene.
old_scene_name: String,
#[serde(rename = "oldSceneName")]
old_name: String,
/// New name of the scene.
scene_name: String,
#[serde(rename = "sceneName")]
new_name: String,
},
/// The current program scene has changed.
#[serde(rename_all = "camelCase")]
CurrentProgramSceneChanged {
/// Name of the scene that was switched to.
scene_name: String,
#[serde(rename = "sceneName")]
name: String,
},
/// The current preview scene has changed.
#[serde(rename_all = "camelCase")]
CurrentPreviewSceneChanged {
/// Name of the scene that was switched to.
scene_name: String,
#[serde(rename = "sceneName")]
name: String,
},
/// The list of scenes has changed.
#[serde(rename_all = "camelCase")]
SceneListChanged {
/// Updated array of scenes.
scenes: Vec<Scene>,
@ -435,31 +473,33 @@ pub enum Event {
// Transitions
// --------------------------------
/// The current scene transition has changed.
#[serde(rename_all = "camelCase")]
CurrentSceneTransitionChanged {
/// Name of the new transition.
transition_name: String,
#[serde(rename = "transitionName")]
name: String,
},
/// The current scene transition duration has changed.
#[serde(rename_all = "camelCase")]
CurrentSceneTransitionDurationChanged {
/// Transition duration in milliseconds.
#[serde(deserialize_with = "crate::de::duration_millis")]
transition_duration: Duration,
#[serde(
rename = "transitionDuration",
deserialize_with = "crate::de::duration_millis"
)]
duration: Duration,
},
/// A scene transition has started.
#[serde(rename_all = "camelCase")]
SceneTransitionStarted {
/// Scene transition name.
transition_name: String,
#[serde(rename = "transitionName")]
name: String,
},
/// A scene transition has completed fully.
///
/// **Note:** Does not appear to trigger when the transition is interrupted by the user.
#[serde(rename_all = "camelCase")]
SceneTransitionEnded {
/// Scene transition name.
transition_name: String,
#[serde(rename = "transitionName")]
name: String,
},
/// A scene transition's video has completed fully.
///
@ -468,19 +508,19 @@ pub enum Event {
/// transition playback.
///
/// **Note:** Appears to be called by every transition, regardless of relevance.
#[serde(rename_all = "camelCase")]
SceneTransitionVideoEnded {
/// Scene transition name.
transition_name: String,
#[serde(rename = "transitionName")]
name: String,
},
// --------------------------------
// UI
// --------------------------------
/// Studio mode has been enabled or disabled.
#[serde(rename_all = "camelCase")]
StudioModeStateChanged {
/// Whether the studio mode is enabled.
studio_mode_enabled: bool,
#[serde(rename = "studioModeEnabled")]
enabled: bool,
},
// --------------------------------
// Custom
@ -496,12 +536,13 @@ pub enum Event {
/// Volume meter information for a single input, describing the current volume level.
#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InputVolumeMeter {
/// Name of this input.
pub input_name: String,
/// List of volume levels, in Mul.
pub input_levels_mul: Vec<[f32; 3]>,
#[serde(rename = "inputName")]
pub name: String,
/// List of volume levels, in **Mul**.
#[serde(rename = "inputLevelsMul")]
pub levels: Vec<[f32; 3]>,
}
/// The output state describes the current status of any output (like recording, virtual-cam, ...).
@ -532,20 +573,22 @@ pub enum OutputState {
/// A basic scene item, only describing identifier and position.
#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BasicSceneItem {
/// Identifier of this scene item.
pub scene_item_id: u64,
#[serde(rename = "sceneItemId")]
pub id: u64,
/// Positional index within the owning scene.
pub scene_item_index: u32,
#[serde(rename = "sceneItemIndex")]
pub index: u32,
}
/// The scene describes basic details about a single scene setup in OBS.
#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Scene {
/// Name of this scene.
pub scene_name: String,
#[serde(rename = "sceneName")]
pub name: String,
/// Positional index in the scene list.
pub scene_index: usize,
#[serde(rename = "sceneIndex")]
pub index: usize,
}

@ -20,7 +20,7 @@
//! println!("{:#?}", version);
//!
//! /// Get a list of available scenes and print them out.
//! let scene_list = client.scenes().get_scene_list().await?;
//! let scene_list = client.scenes().get_list().await?;
//! println!("{:#?}", scene_list);
//!
//! Ok(())

@ -1,5 +1,5 @@
//! Additional structs for use with
//! [`Inputs::set_input_settings`](crate::client::Inputs::set_input_settings).
//! [`crate::client::Inputs::set_settings`].
use std::path::Path;
@ -483,17 +483,17 @@ pub struct TextFt2SourceV2<'a> {
pub drop_shadow: bool,
/// Settings for the font.
pub font: Font<'a>,
/// Load the text from a file (must be set in combination with [`text_file`](Self::text_file)).
/// Load the text from a file (must be set in combination with [`Self::text_file`]).
pub from_file: bool,
/// Amount of log lines if [`log_mode`](Self::log_mode) is `true`. Minimum value is `1`.
/// Amount of log lines if [`Self::log_mode`] is `true`. Minimum value is `1`.
pub log_lines: u32,
/// Log mode (not sure what this does).
pub log_mode: bool,
/// Draw a black border around the text corners.
pub outline: bool,
/// Text to display (only used if [`from_file`](Self::from_file) is `false`).
/// Text to display (only used if [`Self::from_file`] is `false`).
pub text: &'a str,
/// File to load the display text from ([`from_file`](Self::from_file) must be `true`). The
/// File to load the display text from ([`Self::from_file`] must be `true`). The
/// content must be in either **UTF-8** or **UTF-16** encoding.
pub text_file: &'a Path,
/// Wrap the words within the boundaries of the scene item.
@ -530,7 +530,7 @@ pub struct Font<'a> {
pub flags: FontFlags,
/// Display size.
pub size: u32,
/// Specific font style. Must eventually be set together with [`flags`](Self::flags).
/// Specific font style. Must eventually be set together with [`Self::flags`].
///
/// For example:
/// - [`FontFlags::BOLD`] and style `"Bold"`.
@ -592,29 +592,29 @@ impl<'a> Default for VlcSource<'a> {
pub struct AvCaptureInputV2<'a> {
/// Whether to use buffering.
pub buffering: bool,
/// Specific color space of the video. Only used if [`use_preset`](Self::use_preset) is
/// Specific color space of the video. Only used if [`Self::use_preset`] is
/// `false`).
pub color_space: ColorSpace,
/// Device identifier.
pub device: &'a str,
/// Name of the capture device.
pub device_name: &'a str,
/// Frame rate of the capture. Only used if [`use_preset`](Self::use_preset) is `false`).
/// Frame rate of the capture. Only used if [`Self::use_preset`] is `false`).
pub frame_rate: FrameRate,
/// Encoded input format. Only used if [`use_preset`](Self::use_preset) is `false`).
/// Encoded input format. Only used if [`Self::use_preset`] is `false`).
pub input_format: u32,
/// Pre-configured setting. Only used if [`use_preset`](Self::use_preset) is `true`).
/// Pre-configured setting. Only used if [`Self::use_preset`] is `true`).
pub preset: AvPreset,
/// Video resolution. Only used if [`use_preset`](Self::use_preset) is `false`).
/// Video resolution. Only used if [`Self::use_preset`] is `false`).
#[serde(serialize_with = "ser::json_string")]
pub resolution: Resolution,
/// Whether to use a setting preset.
pub use_preset: bool,
/// Video color range. Only used if [`use_preset`](Self::use_preset) is `false`).
/// Video color range. Only used if [`Self::use_preset`] is `false`).
pub video_range: VideoRange,
}
/// Color space as part of an [`AvCaptureInput`].
/// Color space as part of an [`AvCaptureInputV2`].
#[derive(Serialize_repr)]
#[repr(i8)]
pub enum ColorSpace {
@ -632,7 +632,7 @@ impl Default for ColorSpace {
}
}
/// Video color range as part of an [`AvCaptureInput`].
/// Video color range as part of an [`AvCaptureInputV2`].
#[derive(Serialize_repr)]
#[repr(i8)]
pub enum VideoRange {
@ -650,7 +650,7 @@ impl Default for VideoRange {
}
}
/// Different presets for the [`AvCaptureInput`].
/// Different presets for the [`AvCaptureInputV2`].
#[derive(Serialize)]
pub enum AvPreset {
/// Preset for resolution _3840x2160_ (may not be available).
@ -685,7 +685,7 @@ pub enum AvPreset {
Low,
}
/// Video frame rate of an [`AvCaptureInput`].
/// Video frame rate of an [`AvCaptureInputV2`].
///
/// The value is split into numerator and denominator as integer values instead of a floating point
/// value. To calculate the frame rate as FPS divide the `numerator` by the `denominator`.
@ -697,7 +697,7 @@ pub struct FrameRate {
pub denominator: u64,
}
/// Video resolution for an [`AvCaptureInput`].
/// Video resolution for an [`AvCaptureInputV2`].
#[derive(Serialize)]
pub struct Resolution {
/// Video width.

@ -1,5 +1,4 @@
//! Additional structs for use with
//! [`Inputs::set_input_settings`](crate::client::Inputs::set_input_settings).
//! Additional structs for use with [`crate::client::Inputs::set_settings`].
use std::path::Path;

File diff suppressed because it is too large Load Diff

@ -113,21 +113,23 @@ pub(crate) struct Identified {
/// `obs-websocket` is responding to a request coming from a client.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct RequestResponse {
#[allow(dead_code)]
pub request_type: String,
pub request_id: String,
pub request_status: Status,
#[serde(default)]
pub response_data: serde_json::Value,
#[serde(rename = "requestType")]
pub r#type: String,
#[serde(rename = "requestId")]
pub id: String,
#[serde(rename = "requestStatus")]
pub status: Status,
#[serde(rename = "responseData", default)]
pub data: serde_json::Value,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct RequestBatchResponse {
#[allow(dead_code)]
pub request_id: String,
#[serde(rename = "requestId")]
pub id: String,
#[allow(dead_code)]
pub results: Vec<serde_json::Value>,
}
@ -242,38 +244,39 @@ pub enum StatusCode {
CannotAct = 703,
}
/// Response value for
/// [`get_scene_collection_list`](crate::client::Config::get_scene_collection_list).
/// Response value for [`crate::client::Config::list_scene_collections`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SceneCollections {
/// The name of the current scene collection.
pub current_scene_collection_name: String,
#[serde(rename = "currentSceneCollectionName")]
pub current: String,
/// Array of all available scene collections.
pub scene_collections: Vec<String>,
#[serde(rename = "sceneCollections")]
pub collections: Vec<String>,
}
/// Response value for [`get_profile_list`](crate::client::Config::get_profile_list).
/// Response value for [`crate::client::Config::list_profiles`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Profiles {
/// The name of the current profile.
pub current_profile_name: String,
#[serde(rename = "currentProfileName")]
pub current: String,
/// Array of all available profiles.
pub profiles: Vec<String>,
}
/// Response value for [`get_profile_parameter`](crate::client::Config::get_profile_parameter).
/// Response value for [`crate::client::Config::get_profile_parameter`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProfileParameter {
/// Value associated with the parameter.
pub parameter_value: Option<String>,
#[serde(rename = "parameterValue")]
pub value: Option<String>,
/// Default value associated with the parameter.
pub default_parameter_value: Option<String>,
#[serde(rename = "defaultParameterValue")]
pub default_value: Option<String>,
}
/// Response value for [`get_video_settings`](crate::client::Config::get_video_settings).
/// Response value for [`crate::client::Config::video_settings`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VideoSettings {
@ -291,18 +294,19 @@ pub struct VideoSettings {
pub output_height: u32,
}
/// Response value for
/// [`get_stream_service_settings`](crate::client::Config::get_stream_service_settings).
/// Response value for [`crate::client::Config::stream_service_settings`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StreamServiceSettings<T> {
/// Stream service type, like `rtmp_custom` or `rtmp_common`.
pub stream_service_type: String,
#[serde(rename = "streamServiceType")]
pub r#type: String,
/// Stream service settings.
pub stream_service_settings: T,
#[serde(rename = "streamServiceSettings")]
pub settings: T,
}
/// Response value for [`get_source_filter_list`](crate::client::Filters::get_source_filter_list).
/// Response value for [`crate::client::Filters::get_source_filter_list`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct Filters {
@ -310,26 +314,28 @@ pub(crate) struct Filters {
pub filters: Vec<SourceFilter>,
}
/// Response value for [`get_source_filter_list`](crate::client::Filters::get_source_filter_list)
/// and [`get_source_filter`](crate::client::Filters::get_source_filter).
/// Response value for [`crate::client::Filters::list`] and [`crate::client::Filters::get`].
#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SourceFilter {
/// Whether the filter is enabled.
pub filter_enabled: bool,
#[serde(rename = "filterEnabled")]
pub enabled: bool,
/// Index of the filter in the list, beginning at 0.
pub filter_index: u32,
#[serde(rename = "filterIndex")]
pub index: u32,
/// The kind of filter.
pub filter_kind: String,
#[serde(rename = "filterKind")]
pub kind: String,
/// name of the filter.
#[serde(default)]
pub filter_name: String,
#[serde(rename = "filterName", default)]
pub name: String,
/// Settings object associated with the filter.
pub filter_settings: serde_json::Value,
#[serde(rename = "filterSettings")]
pub settings: serde_json::Value,
}
/// Response value for
/// [`get_source_filter_default_settings`](crate::client::Filters::get_source_filter_default_settings).
/// [`crate::client::Filters::get_source_filter_default_settings`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct DefaultFilterSettings<T> {
@ -337,7 +343,7 @@ pub(crate) struct DefaultFilterSettings<T> {
pub default_filter_settings: T,
}
/// Response value for [`get_version`](crate::client::General::get_version).
/// Response value for [`crate::client::General::version`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Version {
@ -358,7 +364,7 @@ pub struct Version {
pub platform_description: String,
}
/// Response value for [`get_stats`](crate::client::General::get_stats).
/// Response value for [`crate::client::General::stats`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Stats {
@ -386,7 +392,7 @@ pub struct Stats {
pub web_socket_session_outgoing_messages: u64,
}
/// Response value for [`get_hotkey_list`](crate::client::General::get_hotkey_list).
/// Response value for [`crate::client::General::get_hotkey_list`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct Hotkeys {
@ -394,15 +400,16 @@ pub(crate) struct Hotkeys {
pub hotkeys: Vec<String>,
}
/// Response value for [`get_studio_mode_enabled`](crate::client::Ui::get_studio_mode_enabled).
/// Response value for [`crate::client::Ui::get_studio_mode_enabled`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct StudioModeEnabled {
/// Whether studio mode is enabled.
pub studio_mode_enabled: bool,
#[serde(rename = "studioModeEnabled")]
pub enabled: bool,
}
/// Response value for [`call_vendor_request`](crate::client::General::call_vendor_request).
/// Response value for [`crate::client::General::call_vendor_request`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct CallVendorResponse<T> {
@ -410,7 +417,7 @@ pub(crate) struct CallVendorResponse<T> {
pub response_data: T,
}
/// Response value for [`get_input_list`](crate::client::Inputs::get_input_list).
/// Response value for [`crate::client::Inputs::get_input_list`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct Inputs {
@ -418,19 +425,21 @@ pub(crate) struct Inputs {
pub inputs: Vec<Input>,
}
/// Response value for [`get_input_list`](crate::client::Inputs::get_input_list).
/// Response value for [`crate::client::Inputs::list`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Input {
/// Name of the input source.
pub input_name: String,
#[serde(rename = "inputName")]
pub name: String,
/// Version input kind.
pub input_kind: String,
#[serde(rename = "inputKind")]
pub kind: String,
/// Kind of input, without the version part.
pub unversioned_input_kind: String,
#[serde(rename = "unversionedInputKind")]
pub unversioned_kind: String,
}
/// Response value for [`get_input_kind_list`](crate::client::Inputs::get_input_kind_list).
/// Response value for [`crate::client::Inputs::get_input_kind_list`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct InputKinds {
@ -439,7 +448,7 @@ pub(crate) struct InputKinds {
}
/// Response value for
/// [`get_input_default_settings`](crate::client::Inputs::get_input_default_settings).
/// [`crate::client::Inputs::get_input_default_settings`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct DefaultInputSettings<T> {
@ -447,53 +456,58 @@ pub(crate) struct DefaultInputSettings<T> {
pub default_input_settings: T,
}
/// Response value for [`get_input_settings`](crate::client::Inputs::get_input_settings).
/// Response value for [`crate::client::Inputs::settings`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InputSettings<T> {
/// Object of settings for the input.
pub input_settings: T,
#[serde(rename = "inputSettings")]
pub settings: T,
/// The kind of the input.
pub input_kind: String,
#[serde(rename = "inputKind")]
pub kind: String,
}
/// Response value for [`get_input_mute`](crate::client::Inputs::get_input_mute) and
/// [`toggle_input_mute`](crate::client::Inputs::toggle_input_mute).
/// Response value for [`crate::client::Inputs::get_input_mute`] and
/// [`crate::client::Inputs::toggle_input_mute`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct InputMuted {
/// Whether the input is muted.
pub input_muted: bool,
#[serde(rename = "inputMuted")]
pub muted: bool,
}
/// Response value for [`get_input_volume`](crate::client::Inputs::get_input_volume).
/// Response value for [`crate::client::Inputs::volume`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InputVolume {
/// Volume setting in mul.
pub input_volume_mul: f32,
#[serde(rename = "inputVolumeMul")]
pub mul: f32,
/// Volume setting in dB.
pub input_volume_db: f32,
#[serde(rename = "inputVolumeDb")]
pub db: f32,
}
/// Response value for
/// [`get_media_input_status`](crate::client::MediaInputs::get_media_input_status).
/// Response value for [`crate::client::MediaInputs::status`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MediaStatus {
/// State of the media input.
pub media_state: MediaState,
#[serde(rename = "mediaState")]
pub state: MediaState,
/// Total duration of the playing media. [`None`] if not playing.
#[serde(deserialize_with = "crate::de::duration_millis_opt")]
pub media_duration: Option<Duration>,
#[serde(
rename = "mediaDuration",
deserialize_with = "crate::de::duration_millis_opt"
)]
pub duration: Option<Duration>,
/// Position of the cursor. [`None`] if not playing.
#[serde(deserialize_with = "crate::de::duration_millis_opt")]
pub media_cursor: Option<Duration>,
#[serde(
rename = "mediaCursor",
deserialize_with = "crate::de::duration_millis_opt"
)]
pub cursor: Option<Duration>,
}
/// Response value for
/// [`get_media_input_status`](crate::client::MediaInputs::get_media_input_status) as part of
/// [`MediaStatus`].
/// Response value for [`crate::client::MediaInputs::status`] as part of [`MediaStatus`].
#[derive(Copy, Clone, Debug, Deserialize)]
pub enum MediaState {
/// No state.
@ -525,35 +539,45 @@ pub enum MediaState {
Unknown,
}
/// Response value for [`get_record_status`](crate::client::Recording::get_record_status).
/// Response value for [`crate::client::Recording::status`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RecordStatus {
/// Whether the output is active.
pub output_active: bool,
#[serde(rename = "outputActive")]
pub active: bool,
/// Whether the output is paused.
pub output_paused: bool,
#[serde(rename = "outputPaused")]
pub paused: bool,
/// Current formatted time code string for the output.
#[serde(deserialize_with = "crate::de::duration_timecode")]
pub output_timecode: Duration,
#[serde(
rename = "outputTimecode",
deserialize_with = "crate::de::duration_timecode"
)]
pub timecode: Duration,
/// Current duration in milliseconds for the output.
#[serde(deserialize_with = "crate::de::duration_millis")]
pub output_duration: Duration,
#[serde(
rename = "outputDuration",
deserialize_with = "crate::de::duration_millis"
)]
pub duration: Duration,
/// Number of bytes sent by the output.
pub output_bytes: u64,
#[serde(rename = "outputBytes")]
pub bytes: u64,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct OutputActive {
/// New state of the stream output.
pub output_active: bool,
#[serde(rename = "outputActive")]
pub active: bool,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct OutputPaused {
pub output_paused: bool,
#[serde(rename = "outputPaused")]
pub paused: bool,
}
#[derive(Debug, Deserialize)]
@ -577,15 +601,14 @@ pub(crate) struct SceneItemId {
}
/// Response value for
/// [`get_scene_item_transform`](crate::client::SceneItems::get_scene_item_transform).
/// [`crate::client::SceneItems::get_scene_item_transform`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct GetSceneItemTransform {
pub scene_item_transform: SceneItemTransform,
}
/// Response value for
/// [`get_scene_item_transform`](crate::client::SceneItems::get_scene_item_transform).
/// Response value for [`crate::client::SceneItems::transform`].
#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SceneItemTransform {
@ -629,8 +652,7 @@ pub struct SceneItemTransform {
pub crop_bottom: u32,
}
/// Response value for
/// [`get_scene_item_enabled`](crate::client::SceneItems::get_scene_item_enabled).
/// Response value for [`crate::client::SceneItems::get_enabled`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct SceneItemEnabled {
@ -638,7 +660,7 @@ pub(crate) struct SceneItemEnabled {
pub scene_item_enabled: bool,
}
/// Response value for [`get_scene_item_locked`](crate::client::SceneItems::get_scene_item_locked).
/// Response value for [`crate::client::SceneItems::get_locked`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct SceneItemLocked {
@ -646,7 +668,7 @@ pub(crate) struct SceneItemLocked {
pub scene_item_locked: bool,
}
/// Response value for [`get_scene_item_index`](crate::client::SceneItems::get_scene_item_index).
/// Response value for [`crate::client::SceneItems::get_index`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct SceneItemIndex {
@ -654,16 +676,14 @@ pub(crate) struct SceneItemIndex {
pub scene_item_index: u32,
}
/// Response value for
/// [`get_scene_item_private_settings`](crate::client::SceneItems::get_scene_item_private_settings).
/// Response value for [`crate::client::SceneItems::get_private_settings`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct SceneItemSettings<T> {
pub scene_item_settings: T,
}
/// Response value for
/// [`get_input_audio_sync_offset`](crate::client::Inputs::get_input_audio_sync_offset).
/// Response value for [`crate::client::Inputs::get_audio_sync_offset`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct AudioSyncOffset {
@ -672,8 +692,7 @@ pub(crate) struct AudioSyncOffset {
pub input_audio_sync_offset: Duration,
}
/// Response value for
/// [`get_input_audio_monitor_type`](crate::client::Inputs::get_input_audio_monitor_type).
/// Response value for [`crate::client::Inputs::get_audio_monitor_type`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct AudioMonitorType {
@ -681,8 +700,7 @@ pub(crate) struct AudioMonitorType {
pub monitor_type: MonitorType,
}
/// Response value for
/// [`get_input_properties_list_property_items`](crate::client::Inputs::get_input_properties_list_property_items).
/// Response value for [`crate::client::Inputs::get_properties_list_property_items`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ListPropertyItems {
@ -690,21 +708,22 @@ pub(crate) struct ListPropertyItems {
pub property_items: Vec<ListPropertyItem>,
}
/// Response value for
/// [`get_input_properties_list_property_items`](crate::client::Inputs::get_input_properties_list_property_items).
/// Response value for [`crate::client::Inputs::properties_list_property_items`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ListPropertyItem {
/// Name of the item.
pub item_name: String,
#[serde(rename = "itemName")]
pub name: String,
/// Whether this item is enabled in the UI.
pub item_enabled: bool,
#[serde(rename = "itemEnabled")]
pub enabled: bool,
/// Content of the item, depending on what it represents.
pub item_value: serde_json::Value,
#[serde(rename = "itemValue")]
pub value: serde_json::Value,
}
/// Response value for [`get_scene_item_list`](crate::client::SceneItems::get_scene_item_list) and
/// [`get_group_scene_item_list`](crate::client::SceneItems::get_group_scene_item_list).
/// Response value for [`crate::client::SceneItems::get_list`] and
/// [`crate::client::SceneItems::get_group_list`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct SceneItemList {
@ -712,15 +731,17 @@ pub(crate) struct SceneItemList {
pub scene_items: Vec<SceneItem>,
}
/// Response value for [`get_scene_item_list`](crate::client::SceneItems::get_scene_item_list) and
/// [`get_group_scene_item_list`](crate::client::SceneItems::get_group_scene_item_list).
/// Response value for [`crate::client::SceneItems::list`] and
/// [`crate::client::SceneItems::list_group`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SceneItem {
/// Identifier of the scene item.
pub scene_item_id: i64,
#[serde(rename = "sceneItemId")]
pub id: i64,
/// Positional index within a scene.
pub scene_item_index: u32,
#[serde(rename = "sceneItemIndex")]
pub index: u32,
/// Name of this source.
pub source_name: String,
/// The kind of source this item represents.
@ -748,7 +769,7 @@ pub enum SourceType {
Scene,
}
/// Response value for [`get_scene_list`](crate::client::Scenes::get_scene_list).
/// Response value for [`crate::client::Scenes::list`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Scenes {
@ -760,18 +781,19 @@ pub struct Scenes {
pub scenes: Vec<Scene>,
}
/// Response value for [`get_scene_list`](crate::client::Scenes::get_scene_list) as part of
/// [`Scenes`].
/// Response value for [`crate::client::Scenes::list`] as part of [`Scenes`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Scene {
/// Name of the scene.
pub scene_name: String,
#[serde(rename = "sceneName")]
pub name: String,
/// Positional index in the list of scenes.
pub scene_index: usize,
#[serde(rename = "sceneIndex")]
pub index: usize,
}
/// Response value for [`get_group_list`](crate::client::Scenes::get_group_list).
/// Response value for [`crate::client::Scenes::get_group_list`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct Groups {
@ -780,7 +802,7 @@ pub(crate) struct Groups {
}
/// Response value for
/// [`get_current_program_scene`](crate::client::Scenes::get_current_program_scene).
/// [`crate::client::Scenes::get_current_program_scene`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct CurrentProgramScene {
@ -789,7 +811,7 @@ pub(crate) struct CurrentProgramScene {
}
/// Response value for
/// [`get_current_preview_scene`](crate::client::Scenes::get_current_preview_scene).
/// [`crate::client::Scenes::get_current_preview_scene`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct CurrentPreviewScene {
@ -797,29 +819,33 @@ pub(crate) struct CurrentPreviewScene {
pub current_preview_scene_name: String,
}
/// Response value for
/// [`get_scene_scene_transition_override`](crate::client::Scenes::get_scene_scene_transition_override).
/// Response value for [`crate::client::Scenes::transition_override`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SceneTransitionOverride {
/// Name of the overridden scene transition.
pub transition_name: Option<String>,
#[serde(rename = "transitionName")]
pub name: Option<String>,
/// Duration of the overridden scene transition.
#[serde(deserialize_with = "crate::de::duration_millis_opt")]
pub transition_duration: Option<Duration>,
#[serde(
rename = "transitionDuration",
deserialize_with = "crate::de::duration_millis_opt"
)]
pub duration: Option<Duration>,
}
/// Response value for [`get_source_active`](crate::client::Sources::get_source_active).
/// Response value for [`crate::client::Sources::active`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SourceActive {
/// Whether the source is showing in program.
pub video_active: bool,
#[serde(rename = "videoActive")]
pub active: bool,
/// Whether the source is showing in the UI (preview, projector, properties).
pub video_showing: bool,
#[serde(rename = "videoShowing")]
pub showing: bool,
}
/// Response value for [`get_source_screenshot`](crate::client::Sources::get_source_screenshot).
/// Response value for [`crate::client::Sources::get_screenshot`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ImageData {
@ -827,30 +853,41 @@ pub(crate) struct ImageData {
pub image_data: String,
}
/// Response value for [`get_stream_status`](crate::client::Streaming::get_stream_status).
/// Response value for [`crate::client::Streaming::status`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StreamStatus {
/// Whether the output is active.
pub output_active: bool,
#[serde(rename = "outputActive")]
pub active: bool,
/// Whether the output is currently reconnecting.
pub output_reconnecting: bool,
#[serde(rename = "outputReconnecting")]
pub reconnecting: bool,
/// Current time code for the output.
#[serde(deserialize_with = "crate::de::duration_timecode")]
pub output_timecode: Duration,
#[serde(
rename = "outputTimecode",
deserialize_with = "crate::de::duration_timecode"
)]
pub timecode: Duration,
/// Current duration for the output.
#[serde(deserialize_with = "crate::de::duration_millis")]
pub output_duration: Duration,
#[serde(
rename = "outputDuration",
deserialize_with = "crate::de::duration_millis"
)]
pub duration: Duration,
/// Number of bytes sent by the output.
pub output_bytes: u64,
#[serde(rename = "outputBytes")]
pub bytes: u64,
/// Number of frames skipped by the output's process.
pub output_skipped_frames: u32,
#[serde(rename = "outputSkippedFrames")]
pub skipped_frames: u32,
/// Total number of frames delivered by the output's process.
pub output_total_frames: u32,
#[serde(rename = "outputTotalFrames")]
pub total_frames: u32,
}
/// Response value for
/// [`get_transition_kind_list`](crate::client::Transitions::get_transition_kind_list).
/// [`crate::client::Transitions::get_transition_kind_list`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct TransitionKinds {
@ -858,8 +895,7 @@ pub(crate) struct TransitionKinds {
pub transition_kinds: Vec<String>,
}
/// Response value for
/// [`get_scene_transition_list`](crate::client::Transitions::get_scene_transition_list).
/// Response value for [`crate::client::Transitions::list`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SceneTransitionList {
@ -871,44 +907,51 @@ pub struct SceneTransitionList {
pub transitions: Vec<Transition>,
}
/// Response value for
/// [`get_scene_transition_list`](crate::client::Transitions::get_scene_transition_list) as part of
/// [`SceneTransitionList`].
/// Response value for [`crate::client::Transitions::list`] as part of [`SceneTransitionList`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Transition {
/// Name of the transition.
pub transition_name: String,
#[serde(rename = "transitionName")]
pub name: String,
/// Kind of the transition.
pub transition_kind: String,
#[serde(rename = "transitionKind")]
pub kind: String,
/// Whether the transition uses a fixed (non-configurable) duration.
pub transition_fixed: bool,
#[serde(rename = "transitionFixed")]
pub fixed: bool,
/// Whether the transition supports being configured.
pub transition_configurable: bool,
#[serde(rename = "transitionConfigurable")]
pub configurable: bool,
}
/// Response value for
/// [`get_current_scene_transition`](crate::client::Transitions::get_current_scene_transition).
/// Response value for [`crate::client::Transitions::current`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CurrentSceneTransition {
/// Name of the transition.
pub transition_name: String,
#[serde(rename = "transitionName")]
pub name: String,
/// Kind of the transition.
pub transition_kind: String,
#[serde(rename = "transitionKind")]
pub kind: String,
/// Whether the transition uses a fixed (non-configurable) duration.
pub transition_fixed: bool,
#[serde(rename = "transitionFixed")]
pub fixed: bool,
/// Configured transition duration in milliseconds.
#[serde(deserialize_with = "crate::de::duration_millis_opt")]
pub transition_duration: Option<Duration>,
#[serde(
rename = "transitionDuration",
deserialize_with = "crate::de::duration_millis_opt"
)]
pub duration: Option<Duration>,
/// Whether the transition supports being configured.
pub transition_configurable: bool,
#[serde(rename = "transitionConfigurable")]
pub configurable: bool,
/// Object of settings for the transition.
pub transition_settings: Option<serde_json::Value>,
#[serde(rename = "transitionSettings")]
pub settings: Option<serde_json::Value>,
}
/// Response value for
/// [`get_current_scene_transition_cursor`](crate::client::Transitions::get_current_scene_transition_cursor).
/// [`crate::client::Transitions::get_current_scene_transition_cursor`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct TransitionCursor {
@ -916,25 +959,43 @@ pub(crate) struct TransitionCursor {
pub transition_cursor: f32,
}
/// Response value for [`get_monitor_list`](crate::client::Ui::get_monitor_list).
/// Response value for [`crate::client::Ui::get_monitor_list`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct MonitorList {
pub monitors: Vec<Monitor>,
}
/// Response value for [`get_monitor_list`](crate::client::Ui::get_monitor_list).
/// Response value for [`crate::client::Ui::list_monitors`].
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Monitor {
/// Name of this monitor.
pub monitor_name: String,
#[serde(rename = "monitorName")]
pub name: String,
/// Pixel size.
#[serde(flatten)]
pub size: MonitorSize,
/// Position on the screen.
#[serde(flatten)]
pub position: MonitorPosition,
}
#[derive(Debug, Deserialize)]
pub struct MonitorSize {
/// Pixel width.
pub monitor_width: u16,
#[serde(rename = "monitorWidth")]
pub width: u16,
/// Pixel height.
pub monitor_height: u16,
#[serde(rename = "monitorHeight")]
pub height: u16,
}
#[derive(Debug, Deserialize)]
pub struct MonitorPosition {
/// Horizontal position on the screen.
pub monitor_position_x: u16,
#[serde(rename = "monitorPositionX")]
pub x: u16,
/// Vertical position on the screen.
pub monitor_position_y: u16,
#[serde(rename = "monitorPositionY")]
pub y: u16,
}

@ -46,7 +46,7 @@ pub async fn new_client() -> Result<Client> {
}
async fn ensure_obs_setup(client: &Client) -> Result<()> {
let scenes = client.scenes().get_scene_list().await?;
let scenes = client.scenes().list().await?;
ensure!(
scenes.scenes.iter().any(is_required_scene),
"scene `{}` not found, required for scenes tests",
@ -68,14 +68,14 @@ async fn ensure_obs_setup(client: &Client) -> Result<()> {
TEST_SCENE_CREATE
);
let groups = client.scenes().get_group_list().await?;
let groups = client.scenes().list_groups().await?;
ensure!(
groups.iter().map(String::as_str).any(is_required_group),
"group `{}` not found, required for scenes and scene items tests",
TEST_GROUP
);
let inputs = client.inputs().get_input_list(None).await?;
let inputs = client.inputs().list(None).await?;
ensure!(
inputs.iter().any(is_required_text_input),
"text input `{}` not found, required for inputs tests",
@ -102,7 +102,7 @@ async fn ensure_obs_setup(client: &Client) -> Result<()> {
TEST_BROWSER_RENAME
);
let filters = client.filters().get_source_filter_list(TEST_TEXT).await?;
let filters = client.filters().list(TEST_TEXT).await?;
ensure!(
filters.iter().any(is_required_filter),
"filter `{}` not found, required for filters tests",
@ -119,32 +119,32 @@ async fn ensure_obs_setup(client: &Client) -> Result<()> {
TEST_FILTER_RENAME
);
let profiles = client.config().get_profile_list().await?.profiles;
let profiles = client.config().list_profiles().await?.profiles;
ensure!(
profiles.iter().map(String::as_str).any(is_required_profile),
"profile `{}` not found, required for profiles tests",
TEST_PROFILE
);
let studio_mode_enabled = client.ui().get_studio_mode_enabled().await?;
let studio_mode_enabled = client.ui().studio_mode_enabled().await?;
ensure!(
!studio_mode_enabled,
"studio mode enabled, required to be disabled for studio mode tests"
);
let recording_active = client.recording().get_record_status().await?.output_active;
let recording_active = client.recording().status().await?.active;
ensure!(
!recording_active,
"recording active, required to be stopped for recording tests"
);
let virtual_cam_active = client.outputs().get_virtual_cam_status().await?;
let virtual_cam_active = client.outputs().virtual_cam_status().await?;
ensure!(
!virtual_cam_active,
"virtual cam active, required to be stopped for outputs tests"
);
let replay_buffer_active = client.outputs().get_replay_buffer_status().await?;
let replay_buffer_active = client.outputs().replay_buffer_status().await?;
ensure!(
!replay_buffer_active,
"replay buffer active, required to be stopped for outputs tests"
@ -159,19 +159,19 @@ async fn ensure_obs_setup(client: &Client) -> Result<()> {
}
fn is_required_scene(scene: &Scene) -> bool {
scene.scene_name == TEST_SCENE
scene.name == TEST_SCENE
}
fn is_required_scene_2(scene: &Scene) -> bool {
scene.scene_name == TEST_SCENE_2
scene.name == TEST_SCENE_2
}
fn is_renamed_scene(scene: &Scene) -> bool {
scene.scene_name == TEST_SCENE_RENAME
scene.name == TEST_SCENE_RENAME
}
fn is_created_scene(scene: &Scene) -> bool {
scene.scene_name == TEST_SCENE_CREATE
scene.name == TEST_SCENE_CREATE
}
fn is_required_group(group: &str) -> bool {
@ -179,47 +179,47 @@ fn is_required_group(group: &str) -> bool {
}
fn is_required_text_input(input: &Input) -> bool {
input.input_name == TEST_TEXT && is_text_input(input)
input.name == TEST_TEXT && is_text_input(input)
}
fn is_required_text_2_input(input: &Input) -> bool {
input.input_name == TEST_TEXT_2 && is_text_input(input)
input.name == TEST_TEXT_2 && is_text_input(input)
}
fn is_required_browser_input(input: &Input) -> bool {
input.input_name == TEST_BROWSER && is_browser_input(input)
input.name == TEST_BROWSER && is_browser_input(input)
}
fn is_required_media_input(input: &Input) -> bool {
input.input_name == TEST_MEDIA && is_media_input(input)
input.name == TEST_MEDIA && is_media_input(input)
}
fn is_renamed_input(input: &Input) -> bool {
input.input_name == TEST_BROWSER_RENAME
input.name == TEST_BROWSER_RENAME
}
fn is_text_input(input: &Input) -> bool {
input.input_kind == INPUT_KIND_TEXT_FT2
input.kind == INPUT_KIND_TEXT_FT2
}
fn is_browser_input(input: &Input) -> bool {
input.input_kind == INPUT_KIND_BROWSER
input.kind == INPUT_KIND_BROWSER
}
fn is_media_input(input: &Input) -> bool {
input.input_kind == INPUT_KIND_VLC
input.kind == INPUT_KIND_VLC
}
fn is_required_filter(filter: &SourceFilter) -> bool {
filter.filter_name == TEST_FILTER
filter.name == TEST_FILTER
}
fn is_filter_2(filter: &SourceFilter) -> bool {
filter.filter_name == TEST_FILTER_2
filter.name == TEST_FILTER_2
}
fn is_renamed_filter(filter: &SourceFilter) -> bool {
filter.filter_name == TEST_FILTER_RENAME
filter.name == TEST_FILTER_RENAME
}
fn is_required_profile(profile: &str) -> bool {

@ -26,31 +26,20 @@ async fn config() -> Result<()> {
.await?;
let SceneCollections {
current_scene_collection_name,
scene_collections,
} = client.get_scene_collection_list().await?;
let other = scene_collections
.iter()
.find(|sc| *sc != &current_scene_collection_name)
.unwrap();
current,
collections,
} = client.list_scene_collections().await?;
let other = collections.iter().find(|sc| *sc != &current).unwrap();
client.set_current_scene_collection(other).await?;
time::sleep(Duration::from_secs(1)).await;
client
.set_current_scene_collection(&current_scene_collection_name)
.await?;
client.set_current_scene_collection(&current).await?;
time::sleep(Duration::from_secs(1)).await;
let Profiles {
current_profile_name,
profiles,
} = client.get_profile_list().await?;
let other = profiles
.iter()
.find(|p| *p != &current_profile_name)
.unwrap();
let Profiles { current, profiles } = client.list_profiles().await?;
let other = profiles.iter().find(|p| *p != &current).unwrap();
client.set_current_profile(other).await?;
time::sleep(Duration::from_secs(1)).await;
client.set_current_profile(&current_profile_name).await?;
client.set_current_profile(&current).await?;
time::sleep(Duration::from_secs(1)).await;
client.create_profile("OBWS-TEST-New-Profile").await?;
client.remove_profile("OBWS-TEST-New-Profile").await?;
@ -58,33 +47,30 @@ async fn config() -> Result<()> {
client.get_profile_parameter("General", "Name").await?;
client
.set_profile_parameter(SetProfileParameter {
parameter_category: "OBWS",
parameter_name: "Test",
parameter_value: Some("Value"),
category: "OBWS",
name: "Test",
value: Some("Value"),
})
.await?;
client
.set_profile_parameter(SetProfileParameter {
parameter_category: "OBWS",
parameter_name: "Test",
parameter_value: None,
category: "OBWS",
name: "Test",
value: None,
})
.await?;
let settings = client.get_video_settings().await?;
let settings = client.video_settings().await?;
client.set_video_settings(settings.into()).await?;
let settings = client
.get_stream_service_settings::<serde_json::Value>()
.stream_service_settings::<serde_json::Value>()
.await?;
client
.set_stream_service_settings(
&settings.stream_service_type,
&settings.stream_service_settings,
)
.set_stream_service_settings(&settings.r#type, &settings.settings)
.await?;
client.get_record_directory().await?;
client.record_directory().await?;
Ok(())
}

@ -13,67 +13,65 @@ async fn filters() -> Result<()> {
let client = common::new_client().await?;
let client = client.filters();
client.get_source_filter_list(TEST_TEXT).await?;
client.list(TEST_TEXT).await?;
client
.get_source_filter_default_settings::<serde_json::Value>(FILTER_COLOR)
.default_settings::<serde_json::Value>(FILTER_COLOR)
.await?;
client
.create_source_filter(CreateSourceFilter {
source_name: TEST_TEXT,
filter_name: TEST_FILTER_2,
filter_kind: FILTER_COLOR,
filter_settings: Some(serde_json::Map::new()),
.create(CreateSourceFilter {
source: TEST_TEXT,
filter: TEST_FILTER_2,
kind: FILTER_COLOR,
settings: Some(serde_json::Map::new()),
})
.await?;
client
.remove_source_filter(TEST_TEXT, TEST_FILTER_2)
.await?;
client.remove(TEST_TEXT, TEST_FILTER_2).await?;
client
.set_source_filter_name(SetSourceFilterName {
source_name: TEST_TEXT,
filter_name: TEST_FILTER,
new_filter_name: TEST_FILTER_RENAME,
.set_name(SetSourceFilterName {
source: TEST_TEXT,
filter: TEST_FILTER,
new_name: TEST_FILTER_RENAME,
})
.await?;
client
.set_source_filter_name(SetSourceFilterName {
source_name: TEST_TEXT,
filter_name: TEST_FILTER_RENAME,
new_filter_name: TEST_FILTER,
.set_name(SetSourceFilterName {
source: TEST_TEXT,
filter: TEST_FILTER_RENAME,
new_name: TEST_FILTER,
})
.await?;
client.get_source_filter(TEST_TEXT, TEST_FILTER).await?;
client.get(TEST_TEXT, TEST_FILTER).await?;
client
.set_source_filter_index(SetSourceFilterIndex {
source_name: TEST_TEXT,
filter_name: TEST_FILTER,
filter_index: 0,
.set_index(SetSourceFilterIndex {
source: TEST_TEXT,
filter: TEST_FILTER,
index: 0,
})
.await?;
client
.set_source_filter_settings(SetSourceFilterSettings {
source_name: TEST_TEXT,
filter_name: TEST_FILTER,
filter_settings: serde_json::Map::new(),
.set_settings(SetSourceFilterSettings {
source: TEST_TEXT,
filter: TEST_FILTER,
settings: serde_json::Map::new(),
overlay: Some(true),
})
.await?;
client
.set_source_filter_enabled(SetSourceFilterEnabled {
source_name: TEST_TEXT,
filter_name: TEST_FILTER,
filter_enabled: false,
.set_enabled(SetSourceFilterEnabled {
source: TEST_TEXT,
filter: TEST_FILTER,
enabled: false,
})
.await?;
client
.set_source_filter_enabled(SetSourceFilterEnabled {
source_name: TEST_TEXT,
filter_name: TEST_FILTER,
filter_enabled: true,
.set_enabled(SetSourceFilterEnabled {
source: TEST_TEXT,
filter: TEST_FILTER,
enabled: true,
})
.await?;

@ -12,14 +12,14 @@ async fn general() -> Result<()> {
tokio::pin!(events);
client.get_version().await?;
client.version().await?;
client
.broadcast_custom_event(&CustomEvent { hello: "world!" })
.await?;
wait_for!(events, Event::CustomEvent(_));
client.get_stats().await?;
client.stats().await?;
client.get_hotkey_list().await?;
client.list_hotkeys().await?;
client.trigger_hotkey_by_name("ReplayBuffer.Save").await?;
client
.trigger_hotkey_by_key_sequence("OBS_KEY_P", KeyModifiers::default())

@ -12,56 +12,50 @@ async fn inputs() -> Result<()> {
let client = common::new_client().await?;
let client = client.inputs();
client.get_input_list(None).await?;
client.get_input_kind_list(false).await?;
client.list(None).await?;
client.list_kinds(false).await?;
client
.get_input_default_settings::<serde_json::Value>(INPUT_KIND_BROWSER)
.default_settings::<serde_json::Value>(INPUT_KIND_BROWSER)
.await?;
let settings = client
.get_input_settings::<serde_json::Value>(TEST_BROWSER)
.settings::<serde_json::Value>(TEST_BROWSER)
.await?
.input_settings;
.settings;
client
.set_input_settings(SetInputSettings {
input_name: TEST_BROWSER,
input_settings: &settings,
.set_settings(SetInputSettings {
input: TEST_BROWSER,
settings: &settings,
overlay: Some(false),
})
.await?;
let muted = client.get_input_mute(TEST_MEDIA).await?;
client.set_input_mute(TEST_MEDIA, !muted).await?;
client.set_input_mute(TEST_MEDIA, muted).await?;
client.toggle_input_mute(TEST_MEDIA).await?;
client.toggle_input_mute(TEST_MEDIA).await?;
let muted = client.muted(TEST_MEDIA).await?;
client.set_muted(TEST_MEDIA, !muted).await?;
client.set_muted(TEST_MEDIA, muted).await?;
client.toggle_mute(TEST_MEDIA).await?;
client.toggle_mute(TEST_MEDIA).await?;
let volume = client.get_input_volume(TEST_MEDIA).await?;
let volume = client.volume(TEST_MEDIA).await?;
client
.set_input_volume(TEST_MEDIA, Volume::Mul(volume.input_volume_mul))
.set_volume(TEST_MEDIA, Volume::Mul(volume.mul))
.await?;
client
.set_input_name(TEST_BROWSER, TEST_BROWSER_RENAME)
.await?;
client
.set_input_name(TEST_BROWSER_RENAME, TEST_BROWSER)
.await?;
client.set_name(TEST_BROWSER, TEST_BROWSER_RENAME).await?;
client.set_name(TEST_BROWSER_RENAME, TEST_BROWSER).await?;
let offset = client.get_input_audio_sync_offset(TEST_MEDIA).await?;
client
.set_input_audio_sync_offset(TEST_MEDIA, Duration::milliseconds(500))
.await?;
let offset = client.audio_sync_offset(TEST_MEDIA).await?;
client
.set_input_audio_sync_offset(TEST_MEDIA, offset)
.set_audio_sync_offset(TEST_MEDIA, Duration::milliseconds(500))
.await?;
client.set_audio_sync_offset(TEST_MEDIA, offset).await?;
let monitor_type = client.get_input_audio_monitor_type(TEST_MEDIA).await?;
let monitor_type = client.audio_monitor_type(TEST_MEDIA).await?;
client
.set_input_audio_monitor_type(TEST_MEDIA, MonitorType::MonitorAndOutput)
.set_audio_monitor_type(TEST_MEDIA, MonitorType::MonitorAndOutput)
.await?;
client
.set_input_audio_monitor_type(TEST_MEDIA, monitor_type)
.set_audio_monitor_type(TEST_MEDIA, monitor_type)
.await?;
Ok(())

@ -9,16 +9,12 @@ async fn media_inputs() -> Result<()> {
let client = common::new_client().await?;
let client = client.media_inputs();
client.get_media_input_status(TEST_MEDIA).await?;
client.status(TEST_MEDIA).await?;
client.set_cursor(TEST_MEDIA, Duration::seconds(1)).await?;
client
.set_media_input_cursor(TEST_MEDIA, Duration::seconds(1))
.await?;
client
.offset_media_input_cursor(TEST_MEDIA, Duration::seconds(1))
.await?;
client
.trigger_media_input_action(TEST_MEDIA, MediaAction::Next)
.offset_cursor(TEST_MEDIA, Duration::seconds(1))
.await?;
client.trigger_action(TEST_MEDIA, MediaAction::Next).await?;
Ok(())
}

@ -16,13 +16,13 @@ async fn outputs() -> Result<()> {
tokio::pin!(events);
client.get_virtual_cam_status().await?;
client.virtual_cam_status().await?;
client.toggle_virtual_cam().await?;
wait_for!(
events,
Event::VirtualcamStateChanged {
output_state: OutputState::Started,
state: OutputState::Started,
..
}
);
@ -31,7 +31,7 @@ async fn outputs() -> Result<()> {
wait_for!(
events,
Event::VirtualcamStateChanged {
output_state: OutputState::Stopped,
state: OutputState::Stopped,
..
}
);
@ -40,7 +40,7 @@ async fn outputs() -> Result<()> {
wait_for!(
events,
Event::VirtualcamStateChanged {
output_state: OutputState::Started,
state: OutputState::Started,
..
}
);
@ -49,19 +49,19 @@ async fn outputs() -> Result<()> {
wait_for!(
events,
Event::VirtualcamStateChanged {
output_state: OutputState::Stopped,
state: OutputState::Stopped,
..
}
);
time::sleep(Duration::from_secs(1)).await;
client.get_replay_buffer_status().await?;
client.replay_buffer_status().await?;
client.toggle_replay_buffer().await?;
wait_for!(
events,
Event::ReplayBufferStateChanged {
output_state: OutputState::Started,
state: OutputState::Started,
..
}
);
@ -70,7 +70,7 @@ async fn outputs() -> Result<()> {
wait_for!(
events,
Event::ReplayBufferStateChanged {
output_state: OutputState::Stopped,
state: OutputState::Stopped,
..
}
);
@ -79,18 +79,18 @@ async fn outputs() -> Result<()> {
wait_for!(
events,
Event::ReplayBufferStateChanged {
output_state: OutputState::Started,
state: OutputState::Started,
..
}
);
time::sleep(Duration::from_secs(1)).await;
client.save_replay_buffer().await?;
client.get_last_replay_buffer_replay().await?;
client.last_replay_buffer_replay().await?;
client.stop_replay_buffer().await?;
wait_for!(
events,
Event::ReplayBufferStateChanged {
output_state: OutputState::Stopped,
state: OutputState::Stopped,
..
}
);

@ -14,77 +14,77 @@ async fn recording() -> Result<()> {
tokio::pin!(events);
client.get_record_status().await?;
client.status().await?;
client.start_record().await?;
client.start().await?;
wait_for!(
events,
Event::RecordStateChanged {
output_state: OutputState::Started,
state: OutputState::Started,
..
}
);
time::sleep(Duration::from_secs(1)).await;
client.pause_record().await?;
client.pause().await?;
wait_for!(
events,
Event::RecordStateChanged {
output_state: OutputState::Paused,
state: OutputState::Paused,
..
}
);
time::sleep(Duration::from_secs(1)).await;
client.resume_record().await?;
client.resume().await?;
wait_for!(
events,
Event::RecordStateChanged {
output_state: OutputState::Resumed,
state: OutputState::Resumed,
..
}
);
time::sleep(Duration::from_secs(1)).await;
client.stop_record().await?;
client.stop().await?;
wait_for!(
events,
Event::RecordStateChanged {
output_state: OutputState::Stopped,
state: OutputState::Stopped,
..
}
);
time::sleep(Duration::from_secs(1)).await;
client.toggle_record().await?;
client.toggle().await?;
wait_for!(
events,
Event::RecordStateChanged {
output_state: OutputState::Started,
state: OutputState::Started,
..
}
);
time::sleep(Duration::from_secs(1)).await;
client.toggle_record_pause().await?;
client.toggle_pause().await?;
wait_for!(
events,
Event::RecordStateChanged {
output_state: OutputState::Paused,
state: OutputState::Paused,
..
}
);
time::sleep(Duration::from_secs(1)).await;
client.toggle_record_pause().await?;
client.toggle_pause().await?;
wait_for!(
events,
Event::RecordStateChanged {
output_state: OutputState::Resumed,
state: OutputState::Resumed,
..
}
);
time::sleep(Duration::from_secs(1)).await;
client.toggle_record().await?;
client.toggle().await?;
wait_for!(
events,
Event::RecordStateChanged {
output_state: OutputState::Stopped,
state: OutputState::Stopped,
..
}
);

@ -2,7 +2,7 @@ use anyhow::Result;
use obws::{
common::BoundsType,
requests::{
CreateSceneItem, DuplicateSceneItem, GetSceneItemId, SceneItemTransform,
Bounds, CreateSceneItem, DuplicateSceneItem, GetSceneItemId, SceneItemTransform,
SetSceneItemEnabled, SetSceneItemIndex, SetSceneItemLocked, SetSceneItemTransform,
},
};
@ -14,110 +14,108 @@ async fn scene_items() -> Result<()> {
let client = common::new_client().await?;
let client = client.scene_items();
client.get_scene_item_list(TEST_SCENE).await?;
client.get_group_scene_item_list(TEST_GROUP).await?;
client.list(TEST_SCENE).await?;
client.list_group(TEST_GROUP).await?;
let test_text_id = client
.get_scene_item_id(GetSceneItemId {
scene_name: TEST_SCENE,
source_name: TEST_TEXT,
.id(GetSceneItemId {
scene: TEST_SCENE,
source: TEST_TEXT,
search_offset: None,
})
.await?;
let id = client
.duplicate_scene_item(DuplicateSceneItem {
scene_name: TEST_SCENE,
scene_item_id: test_text_id,
destination_scene_name: Some(TEST_SCENE_2),
.duplicate(DuplicateSceneItem {
scene: TEST_SCENE,
item_id: test_text_id,
destination: Some(TEST_SCENE_2),
})
.await?;
client.remove_scene_item(TEST_SCENE_2, id).await?;
client.remove(TEST_SCENE_2, id).await?;
let id = client
.create_scene_item(CreateSceneItem {
scene_name: TEST_SCENE_2,
source_name: TEST_TEXT,
scene_item_enabled: Some(true),
.create(CreateSceneItem {
scene: TEST_SCENE_2,
source: TEST_TEXT,
enabled: Some(true),
})
.await?;
client.remove_scene_item(TEST_SCENE_2, id).await?;
client.remove(TEST_SCENE_2, id).await?;
let transform = client
.get_scene_item_transform(TEST_SCENE, test_text_id)
.await?;
let transform = client.transform(TEST_SCENE, test_text_id).await?;
client
.set_scene_item_transform(SetSceneItemTransform {
scene_name: TEST_SCENE,
scene_item_id: test_text_id,
scene_item_transform: SceneItemTransform {
bounds_type: Some(BoundsType::Stretch),
.set_transform(SetSceneItemTransform {
scene: TEST_SCENE,
item_id: test_text_id,
transform: SceneItemTransform {
bounds: Some(Bounds {
r#type: Some(BoundsType::Stretch),
..Bounds::default()
}),
..SceneItemTransform::default()
},
})
.await?;
client
.set_scene_item_transform(SetSceneItemTransform {
scene_name: TEST_SCENE,
scene_item_id: test_text_id,
scene_item_transform: SceneItemTransform {
bounds_type: Some(transform.bounds_type),
.set_transform(SetSceneItemTransform {
scene: TEST_SCENE,
item_id: test_text_id,
transform: SceneItemTransform {
bounds: Some(Bounds {
r#type: Some(transform.bounds_type),
..Bounds::default()
}),
..SceneItemTransform::default()
},
})
.await?;
let enabled = client
.get_scene_item_enabled(TEST_SCENE, test_text_id)
.await?;
let enabled = client.enabled(TEST_SCENE, test_text_id).await?;
client
.set_scene_item_enabled(SetSceneItemEnabled {
scene_name: TEST_SCENE,
scene_item_id: test_text_id,
scene_item_enabled: !enabled,
.set_enabled(SetSceneItemEnabled {
scene: TEST_SCENE,
item_id: test_text_id,
enabled: !enabled,
})
.await?;
client
.set_scene_item_enabled(SetSceneItemEnabled {
scene_name: TEST_SCENE,
scene_item_id: test_text_id,
scene_item_enabled: enabled,
.set_enabled(SetSceneItemEnabled {
scene: TEST_SCENE,
item_id: test_text_id,
enabled,
})
.await?;
let locked = client
.get_scene_item_locked(TEST_SCENE, test_text_id)
.await?;
let locked = client.locked(TEST_SCENE, test_text_id).await?;
client
.set_scene_item_locked(SetSceneItemLocked {
scene_name: TEST_SCENE,
scene_item_id: test_text_id,
scene_item_locked: !locked,
.set_locked(SetSceneItemLocked {
scene: TEST_SCENE,
item_id: test_text_id,
locked: !locked,
})
.await?;
client
.set_scene_item_locked(SetSceneItemLocked {
scene_name: TEST_SCENE,
scene_item_id: test_text_id,
scene_item_locked: locked,
.set_locked(SetSceneItemLocked {
scene: TEST_SCENE,
item_id: test_text_id,
locked,
})
.await?;
let index = client
.get_scene_item_index(TEST_SCENE, test_text_id)
.await?;
let index = client.index(TEST_SCENE, test_text_id).await?;
client
.set_scene_item_index(SetSceneItemIndex {
scene_name: TEST_SCENE,
scene_item_id: test_text_id,
scene_item_index: 0,
.set_index(SetSceneItemIndex {
scene: TEST_SCENE,
item_id: test_text_id,
index: 0,
})
.await?;
client
.set_scene_item_index(SetSceneItemIndex {
scene_name: TEST_SCENE,
scene_item_id: test_text_id,
scene_item_index: index,
.set_index(SetSceneItemIndex {
scene: TEST_SCENE,
item_id: test_text_id,
index,
})
.await?;

@ -12,48 +12,38 @@ async fn scenes() -> Result<()> {
ui.set_studio_mode_enabled(true).await?;
let scenes = client.get_scene_list().await?.scenes;
client.get_group_list().await?;
let current = client.get_current_program_scene().await?;
let other = &scenes
.iter()
.find(|s| s.scene_name != current)
.unwrap()
.scene_name;
let scenes = client.list().await?.scenes;
client.list_groups().await?;
let current = client.current_program_scene().await?;
let other = &scenes.iter().find(|s| s.name != current).unwrap().name;
client.set_current_program_scene(other).await?;
client.set_current_program_scene(&current).await?;
let current = client.get_current_preview_scene().await?;
let other = &scenes
.iter()
.find(|s| s.scene_name != current)
.unwrap()
.scene_name;
let current = client.current_preview_scene().await?;
let other = &scenes.iter().find(|s| s.name != current).unwrap().name;
client.set_current_preview_scene(other).await?;
client.set_current_preview_scene(&current).await?;
client.set_scene_name(TEST_SCENE, TEST_SCENE_RENAME).await?;
client.set_scene_name(TEST_SCENE_RENAME, TEST_SCENE).await?;
client.set_name(TEST_SCENE, TEST_SCENE_RENAME).await?;
client.set_name(TEST_SCENE_RENAME, TEST_SCENE).await?;
client.create_scene(TEST_SCENE_CREATE).await?;
client.remove_scene(TEST_SCENE_CREATE).await?;
client.create(TEST_SCENE_CREATE).await?;
client.remove(TEST_SCENE_CREATE).await?;
let to = client
.get_scene_scene_transition_override(TEST_SCENE)
.await?;
let to = client.transition_override(TEST_SCENE).await?;
client
.set_scene_scene_transition_override(SetSceneSceneTransitionOverride {
scene_name: TEST_SCENE,
transition_name: Some(TEST_TRANSITION),
transition_duration: Some(Duration::seconds(5)),
.set_transition_override(SetSceneSceneTransitionOverride {
scene: TEST_SCENE,
transition: Some(TEST_TRANSITION),
duration: Some(Duration::seconds(5)),
})
.await?;
client
.set_scene_scene_transition_override(SetSceneSceneTransitionOverride {
scene_name: TEST_SCENE,
transition_name: to.transition_name.as_deref(),
transition_duration: to.transition_duration,
.set_transition_override(SetSceneSceneTransitionOverride {
scene: TEST_SCENE,
transition: to.name.as_deref(),
duration: to.duration,
})
.await?;

@ -10,26 +10,26 @@ async fn sources() -> Result<()> {
let client = common::new_client().await?;
let client = client.sources();
client.get_source_active(TEST_TEXT).await?;
client.active(TEST_TEXT).await?;
client
.get_source_screenshot(GetSourceScreenshot {
source_name: TEST_TEXT,
image_width: Some(100),
image_height: Some(100),
image_compression_quality: Some(50),
image_format: "jpg",
.take_screenshot(GetSourceScreenshot {
source: TEST_TEXT,
width: Some(100),
height: Some(100),
compression_quality: Some(50),
format: "jpg",
})
.await?;
let file = env::temp_dir().join("obws-test-image.png");
client
.save_source_screenshot(SaveSourceScreenshot {
source_name: TEST_TEXT,
image_file_path: &file,
image_width: None,
image_height: None,
image_compression_quality: None,
image_format: "png",
.save_screenshot(SaveSourceScreenshot {
source: TEST_TEXT,
file_path: &file,
width: None,
height: None,
compression_quality: None,
format: "png",
})
.await?;

@ -7,7 +7,7 @@ async fn streaming() -> Result<()> {
let client = common::new_client().await?;
let client = client.streaming();
client.get_stream_status().await?;
client.status().await?;
// TODO: Dangerous to run as it would make us live stream.
// client.start_stream().await?;

@ -8,23 +8,23 @@ async fn transitions() -> Result<()> {
let ui = client.ui();
let client = client.transitions();
client.get_transition_kind_list().await?;
client.get_scene_transition_list().await?;
client.list_kinds().await?;
client.list().await?;
client.set_current_scene_transition(TEST_TRANSITION).await?;
let transition = client.get_current_scene_transition().await?;
client.set_current(TEST_TRANSITION).await?;
let transition = client.current().await?;
client
.set_current_scene_transition_duration(transition.transition_duration.unwrap())
.set_current_duration(transition.duration.unwrap())
.await?;
client
.set_current_scene_transition_settings(transition.transition_settings.unwrap(), None)
.set_current_settings(transition.settings.unwrap(), None)
.await?;
client.get_current_scene_transition_cursor().await?;
client.current_cursor().await?;
ui.set_studio_mode_enabled(true).await?;
client.trigger_studio_mode_transition().await?;
client.trigger().await?;
client.set_tbar_position(0.5, None).await?;
ui.set_studio_mode_enabled(false).await?;

@ -7,7 +7,7 @@ async fn ui() -> Result<()> {
let client = common::new_client().await?;
let client = client.ui();
let enabled = client.get_studio_mode_enabled().await?;
let enabled = client.studio_mode_enabled().await?;
client.set_studio_mode_enabled(!enabled).await?;
client.set_studio_mode_enabled(enabled).await?;

Loading…
Cancel
Save