From 4f734bea64379847880d7b8e08b83da93ae8b4d4 Mon Sep 17 00:00:00 2001 From: Dominik Nakamura Date: Sat, 18 Nov 2023 00:44:47 +0900 Subject: [PATCH] Add features from obs-websocket v5.3 --- CHANGELOG.md | 10 ++++++++-- src/client/config.rs | 8 ++++++++ src/requests/config.rs | 6 ++++++ src/responses/mod.rs | 5 +++++ tests/integration/config.rs | 3 ++- 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0a88e2..fa337ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Added + +- New features from obs-websocket v5.3.0 + - New `set_record_directory` command, that allows to modify the output directory for recordings. + - New `NotReady` status code, that signals the obs-websocket server is not ready yet to accept any commands. + ## [0.11.5] - 2023-09-04 ### Changed @@ -58,7 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - **BREAKING CHANGE:** Due to the update of `bitflags` the list of derived traits changed. -- Update all dependencies to their lates version, most notably `base64`, `bitflags` and +- Update all dependencies to their latest version, most notably `base64`, `bitflags` and `tokio-tungstenite`. - The MSRV is now **1.68**. @@ -76,7 +82,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 for testing out these changes pre-release ❤️. Your ideas and bug reports helped a lot! - All response and event data structures now implement the recommended common traits, where possible. In addition, `serde::Serialize` and `serde::Deserialize` is implemented for all of - them. That means, they can now be constructred easier, and used in more places, for example, as a + them. That means, they can now be constructed easier, and used in more places, for example, as a `HashMap` key. ## [0.9.1] - 2022-02-25 diff --git a/src/client/config.rs b/src/client/config.rs index f1a3dbd..407cff9 100644 --- a/src/client/config.rs +++ b/src/client/config.rs @@ -90,4 +90,12 @@ impl<'a> Config<'a> { .await .map(|rd| rd.record_directory) } + + /// Sets the current directory that the record output writes files to. + #[doc(alias = "SetRecordDirectory")] + pub async fn set_record_directory(&self, directory: &'a str) -> Result<()> { + self.client + .send_message(Request::SetRecordDirectory { directory }) + .await + } } diff --git a/src/requests/config.rs b/src/requests/config.rs index fd51512..4256e1f 100644 --- a/src/requests/config.rs +++ b/src/requests/config.rs @@ -34,6 +34,12 @@ pub(crate) enum Request<'a> { }, #[serde(rename = "GetRecordDirectory")] RecordDirectory, + #[serde(rename = "SetRecordDirectory")] + SetRecordDirectory { + /// Output directory. + #[serde(rename = "recordDirectory")] + directory: &'a str, + }, } impl<'a> From> for super::RequestType<'a> { diff --git a/src/responses/mod.rs b/src/responses/mod.rs index 598876b..65549f9 100644 --- a/src/responses/mod.rs +++ b/src/responses/mod.rs @@ -194,6 +194,11 @@ pub enum StatusCode { GenericError = 205, /// The request batch execution type is not supported. UnsupportedRequestBatchExecutionType = 206, + /// The server is not ready to handle the request. + /// + /// **Note:** This usually occurs during OBS scene collection change or exit. Requests may be + /// tried again after a delay if this code is given. + NotReady = 207, /// A required request field is missing. MissingRequestField = 300, diff --git a/tests/integration/config.rs b/tests/integration/config.rs index bff3a55..47bd1bc 100644 --- a/tests/integration/config.rs +++ b/tests/integration/config.rs @@ -29,7 +29,8 @@ async fn config() -> Result<()> { .set_stream_service_settings(&settings.r#type, &settings.settings) .await?; - client.record_directory().await?; + let directory = client.record_directory().await?; + client.set_record_directory(&directory).await?; Ok(()) }