From 8a3b535856f199be1b75563dfb443cb21be369af Mon Sep 17 00:00:00 2001 From: Baud Date: Tue, 19 Mar 2024 23:19:07 +0000 Subject: [PATCH] feat: _MeC --- .../src/commands/device_profile.rs | 1 + .../device_profile/mix_effect_block_config.rs | 40 +++++++++++++++++++ .../src/commands/parse_commands.rs | 6 +++ atem-connection-rs/src/state/info.rs | 2 +- 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 atem-connection-rs/src/commands/device_profile/mix_effect_block_config.rs diff --git a/atem-connection-rs/src/commands/device_profile.rs b/atem-connection-rs/src/commands/device_profile.rs index 901c7c4..79123fc 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 mix_effect_block_config; pub mod product_identifier; pub mod topology; pub mod version; diff --git a/atem-connection-rs/src/commands/device_profile/mix_effect_block_config.rs b/atem-connection-rs/src/commands/device_profile/mix_effect_block_config.rs new file mode 100644 index 0000000..0b7c9cc --- /dev/null +++ b/atem-connection-rs/src/commands/device_profile/mix_effect_block_config.rs @@ -0,0 +1,40 @@ +use std::sync::Arc; + +use crate::{ + commands::command_base::{CommandDeserializer, DeserializedCommand}, + state::info::MixEffectInfo, +}; + +pub const DESERIALIZE_MIX_EFFECT_BLOCK_CONFIG_NAME: &str = "_MeC"; + +#[derive(Debug)] +pub struct MixEffectBlockConfig { + mix_effect: u8, + key_count: u8, +} + +impl DeserializedCommand for MixEffectBlockConfig { + fn raw_name(&self) -> &'static str { + DESERIALIZE_MIX_EFFECT_BLOCK_CONFIG_NAME + } + + fn apply_to_state(&self, state: &mut crate::state::AtemState) { + state.info.mix_effects[self.mix_effect as usize] = Some(MixEffectInfo::new(self.key_count)); + } +} + +#[derive(Default)] +pub struct MixEffectBlockConfigDeserializer {} + +impl CommandDeserializer for MixEffectBlockConfigDeserializer { + fn deserialize( + &self, + buffer: &[u8], + _version: &crate::enums::ProtocolVersion, + ) -> std::sync::Arc { + Arc::new(MixEffectBlockConfig { + mix_effect: buffer[0], + key_count: buffer[1], + }) + } +} diff --git a/atem-connection-rs/src/commands/parse_commands.rs b/atem-connection-rs/src/commands/parse_commands.rs index acbd4a6..6cfb3f1 100644 --- a/atem-connection-rs/src/commands/parse_commands.rs +++ b/atem-connection-rs/src/commands/parse_commands.rs @@ -8,6 +8,9 @@ use crate::{ use super::{ command_base::{CommandDeserializer, DeserializedCommand}, device_profile::{ + mix_effect_block_config::{ + MixEffectBlockConfigDeserializer, DESERIALIZE_MIX_EFFECT_BLOCK_CONFIG_NAME, + }, product_identifier::{ ProductIdentifierDeserializer, DESERIALIZE_PRODUCT_IDENTIFIER_RAW_NAME, }, @@ -68,6 +71,9 @@ fn command_deserializer_from_string(command_str: &str) -> Option Some(Box::::default()), DESERIALIZE_TIME_RAW_NAME => Some(Box::::default()), DESERIALIZE_TOPOLOGY_RAW_NAME => Some(Box::::default()), + DESERIALIZE_MIX_EFFECT_BLOCK_CONFIG_NAME => { + Some(Box::::default()) + } DESERIALIZE_PRODUCT_IDENTIFIER_RAW_NAME => { Some(Box::::default()) } diff --git a/atem-connection-rs/src/state/info.rs b/atem-connection-rs/src/state/info.rs index 2f965f9..233a478 100644 --- a/atem-connection-rs/src/state/info.rs +++ b/atem-connection-rs/src/state/info.rs @@ -21,7 +21,7 @@ pub struct AtemCapabilites { #[derive(Clone, PartialEq, Getters, new)] pub struct MixEffectInfo { - key_count: u64, + key_count: u8, } #[derive(Clone, PartialEq, Getters, new)]