Document and update recording commands

v5-api
Dominik Nakamura 2 years ago
parent 5f3edcd188
commit 891a29dc37
No known key found for this signature in database
GPG Key ID: E4C6A749B2491910

@ -7,10 +7,12 @@ 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> {
self.client.send_message(RequestType::GetRecordStatus).await
}
/// Toggles the status of the record output.
pub async fn toggle_record(&self) -> Result<bool> {
self.client
.send_message::<responses::OutputActive>(RequestType::ToggleRecord)
@ -18,14 +20,17 @@ impl<'a> Recording<'a> {
.map(|oa| oa.output_active)
}
/// Starts the record output.
pub async fn start_record(&self) -> Result<()> {
self.client.send_message(RequestType::StartRecord).await
}
/// Stops the record output.
pub async fn stop_record(&self) -> Result<()> {
self.client.send_message(RequestType::StopRecord).await
}
/// Toggles pause on the record output.
pub async fn toggle_record_pause(&self) -> Result<bool> {
self.client
.send_message::<responses::OutputPaused>(RequestType::ToggleRecordPause)
@ -33,16 +38,17 @@ impl<'a> Recording<'a> {
.map(|op| op.output_paused)
}
/// Pauses the record output.
pub async fn pause_record(&self) -> Result<()> {
self.client.send_message(RequestType::PauseRecord).await
}
/// Resumes the record output.
pub async fn resume_record(&self) -> Result<()> {
self.client.send_message(RequestType::ResumeRecord).await
}
// Currently disabled in obs-websocket and will always fail.
#[doc(hidden)]
/// Gets the current directory that the record output is set to.
pub async fn get_record_directory(&self) -> Result<String> {
self.client
.send_message::<responses::RecordDirectory>(RequestType::GetRecordDirectory)

@ -426,12 +426,17 @@ pub enum MediaState {
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RecordStatus {
/// Whether the output is active.
pub output_active: bool,
/// Whether the output is paused.
pub output_paused: bool,
/// Current formatted timecode string for the output.
#[serde(deserialize_with = "crate::de::duration_timecode")]
pub output_timecode: Duration,
#[serde(deserialize_with = "crate::de::duration_nanos")]
/// Current duration in milliseconds for the output.
#[serde(deserialize_with = "crate::de::duration_millis")]
pub output_duration: Duration,
/// Number of bytes sent by the output.
pub output_bytes: u64,
}
@ -451,6 +456,7 @@ pub(crate) struct OutputPaused {
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct RecordDirectory {
/// Output directory.
pub record_directory: String,
}

@ -15,6 +15,7 @@ async fn recording() -> Result<()> {
tokio::pin!(events);
client.get_record_status().await?;
client.get_record_directory().await?;
client.start_record().await?;
wait_for!(

Loading…
Cancel
Save