From 34ff52c65cbee66c971004f119e705c3c3d0f540 Mon Sep 17 00:00:00 2001 From: Baud Date: Mon, 8 Apr 2024 20:12:26 +0100 Subject: [PATCH] feat: _mpl --- .../src/commands/device_profile.rs | 1 + .../device_profile/media_pool_config.rs | 40 +++++++++++++++++++ .../src/commands/parse_commands.rs | 2 + atem-connection-rs/src/state/info.rs | 4 +- 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 atem-connection-rs/src/commands/device_profile/media_pool_config.rs diff --git a/atem-connection-rs/src/commands/device_profile.rs b/atem-connection-rs/src/commands/device_profile.rs index 79123fc..b45eb6b 100644 --- a/atem-connection-rs/src/commands/device_profile.rs +++ b/atem-connection-rs/src/commands/device_profile.rs @@ -1,3 +1,4 @@ +pub mod media_pool_config; pub mod mix_effect_block_config; pub mod product_identifier; pub mod topology; diff --git a/atem-connection-rs/src/commands/device_profile/media_pool_config.rs b/atem-connection-rs/src/commands/device_profile/media_pool_config.rs new file mode 100644 index 0000000..285cb55 --- /dev/null +++ b/atem-connection-rs/src/commands/device_profile/media_pool_config.rs @@ -0,0 +1,40 @@ +use std::sync::Arc; + +use crate::{ + commands::command_base::{CommandDeserializer, DeserializedCommand}, + state::info::MediaPoolInfo, +}; + +pub const DESERIALIZE_MEDIA_POOL_CONFIG_NAME: &str = "_mpl"; + +#[derive(Debug)] +pub struct MediaPoolConfig { + still_count: u8, + clip_count: u8, +} + +impl DeserializedCommand for MediaPoolConfig { + fn raw_name(&self) -> &'static str { + DESERIALIZE_MEDIA_POOL_CONFIG_NAME + } + + fn apply_to_state(&self, state: &mut crate::state::AtemState) { + state.info.media_pool = Some(MediaPoolInfo::new(self.still_count, self.clip_count)) + } +} + +#[derive(Default)] +pub struct MediaPoolConfigDeserializer {} + +impl CommandDeserializer for MediaPoolConfigDeserializer { + fn deserialize( + &self, + buffer: &[u8], + _version: &crate::enums::ProtocolVersion, + ) -> std::sync::Arc { + Arc::new(MediaPoolConfig { + still_count: buffer[0], + clip_count: buffer[1], + }) + } +} diff --git a/atem-connection-rs/src/commands/parse_commands.rs b/atem-connection-rs/src/commands/parse_commands.rs index 6cfb3f1..baa2305 100644 --- a/atem-connection-rs/src/commands/parse_commands.rs +++ b/atem-connection-rs/src/commands/parse_commands.rs @@ -8,6 +8,7 @@ use crate::{ use super::{ command_base::{CommandDeserializer, DeserializedCommand}, device_profile::{ + media_pool_config::{MediaPoolConfigDeserializer, DESERIALIZE_MEDIA_POOL_CONFIG_NAME}, mix_effect_block_config::{ MixEffectBlockConfigDeserializer, DESERIALIZE_MIX_EFFECT_BLOCK_CONFIG_NAME, }, @@ -77,6 +78,7 @@ fn command_deserializer_from_string(command_str: &str) -> Option { Some(Box::::default()) } + DESERIALIZE_MEDIA_POOL_CONFIG_NAME => Some(Box::::default()), _ => None, } } diff --git a/atem-connection-rs/src/state/info.rs b/atem-connection-rs/src/state/info.rs index 233a478..e459622 100644 --- a/atem-connection-rs/src/state/info.rs +++ b/atem-connection-rs/src/state/info.rs @@ -49,8 +49,8 @@ pub struct MacroPoolInfo { #[derive(Clone, PartialEq, Getters, new)] pub struct MediaPoolInfo { - still_count: u64, - clip_count: u64, + still_count: u8, + clip_count: u8, } #[derive(Clone, PartialEq, Getters, new)]