From 2bbf2c5c6bb108780347f2d61e3a0e0cc29749cd Mon Sep 17 00:00:00 2001 From: Baud Date: Sun, 10 Mar 2024 02:08:35 +0000 Subject: [PATCH] wip: More command handling --- atem-connection-rs/src/atem.rs | 10 +- .../src/commands/command_base.rs | 2 +- .../src/commands/device_profile.rs | 4 +- .../src/commands/init_complete.rs | 4 +- .../src/commands/mix_effects/program_input.rs | 4 +- .../src/commands/tally_by_source.rs | 4 +- atem-connection-rs/src/commands/time.rs | 4 +- atem-connection-rs/src/enums/mod.rs | 41 +- atem-connection-rs/src/state/atem_macro.rs | 8 +- atem-connection-rs/src/state/audio.rs | 12 +- atem-connection-rs/src/state/color.rs | 2 +- atem-connection-rs/src/state/common.rs | 2 +- atem-connection-rs/src/state/fairlight.rs | 28 +- atem-connection-rs/src/state/info.rs | 20 +- atem-connection-rs/src/state/input.rs | 2 +- atem-connection-rs/src/state/media.rs | 10 +- atem-connection-rs/src/state/mod.rs | 2 +- atem-connection-rs/src/state/recording.rs | 8 +- atem-connection-rs/src/state/settings.rs | 8 +- atem-connection-rs/src/state/streaming.rs | 7 +- .../src/state/video/downstream_keyers.rs | 8 +- atem-connection-rs/src/state/video/mod.rs | 22 +- .../src/state/video/super_source.rs | 8 +- .../src/state/video/upstream_keyers.rs | 409 +----------------- 24 files changed, 146 insertions(+), 483 deletions(-) diff --git a/atem-connection-rs/src/atem.rs b/atem-connection-rs/src/atem.rs index 7468406..aacc2cc 100644 --- a/atem-connection-rs/src/atem.rs +++ b/atem-connection-rs/src/atem.rs @@ -139,6 +139,7 @@ impl Atem { status: &mut AtemConnectionStatus, commands: VecDeque>, ) { + let new_state = state.clone(); for command in commands { match command.raw_name() { DESERIALIZE_VERSION_RAW_NAME => { @@ -149,8 +150,15 @@ impl Atem { DESERIALIZE_TIME_RAW_NAME => { todo!("Time command") } - _ => {} + _ => { + command.apply_to_state(state); + } } } + + if new_state != *state { + *state = new_state; + todo!("Emit change"); + } } } diff --git a/atem-connection-rs/src/commands/command_base.rs b/atem-connection-rs/src/commands/command_base.rs index a7940d9..768db79 100644 --- a/atem-connection-rs/src/commands/command_base.rs +++ b/atem-connection-rs/src/commands/command_base.rs @@ -4,7 +4,7 @@ use crate::{enums::ProtocolVersion, state::AtemState}; pub trait DeserializedCommand: Send + Sync + Debug { fn raw_name(&self) -> &'static str; - fn apply_to_state(&self, state: &mut AtemState) -> Vec; + fn apply_to_state(&self, state: &mut AtemState) -> bool; } pub trait CommandDeserializer: Send + Sync { diff --git a/atem-connection-rs/src/commands/device_profile.rs b/atem-connection-rs/src/commands/device_profile.rs index 9fc9c73..b60d968 100644 --- a/atem-connection-rs/src/commands/device_profile.rs +++ b/atem-connection-rs/src/commands/device_profile.rs @@ -16,8 +16,8 @@ impl DeserializedCommand for VersionCommand { DESERIALIZE_VERSION_RAW_NAME } - fn apply_to_state(&self, state: &mut crate::state::AtemState) -> Vec { - todo!() + fn apply_to_state(&self, state: &mut crate::state::AtemState) -> bool { + todo!("Apply to state: Version") } } diff --git a/atem-connection-rs/src/commands/init_complete.rs b/atem-connection-rs/src/commands/init_complete.rs index 71df0c3..85cec9c 100644 --- a/atem-connection-rs/src/commands/init_complete.rs +++ b/atem-connection-rs/src/commands/init_complete.rs @@ -12,8 +12,8 @@ impl DeserializedCommand for InitComplete { DESERIALIZE_INIT_COMPLETE_RAW_NAME } - fn apply_to_state(&self, state: &mut crate::state::AtemState) -> Vec { - todo!() + fn apply_to_state(&self, state: &mut crate::state::AtemState) -> bool { + todo!("Apply to state: Init Complete") } } diff --git a/atem-connection-rs/src/commands/mix_effects/program_input.rs b/atem-connection-rs/src/commands/mix_effects/program_input.rs index dd25fa7..0253a59 100644 --- a/atem-connection-rs/src/commands/mix_effects/program_input.rs +++ b/atem-connection-rs/src/commands/mix_effects/program_input.rs @@ -37,8 +37,8 @@ impl DeserializedCommand for ProgramInput { DESERIALIZE_PROGRAM_INPUT_RAW_NAME } - fn apply_to_state(&self, state: &mut crate::state::AtemState) -> Vec { - todo!() + fn apply_to_state(&self, state: &mut crate::state::AtemState) -> bool { + todo!("Apply to state: Program Input") } } diff --git a/atem-connection-rs/src/commands/tally_by_source.rs b/atem-connection-rs/src/commands/tally_by_source.rs index 07dd38d..25c00c9 100644 --- a/atem-connection-rs/src/commands/tally_by_source.rs +++ b/atem-connection-rs/src/commands/tally_by_source.rs @@ -20,8 +20,8 @@ impl DeserializedCommand for TallyBySource { DESERIALIZE_TALLY_BY_SOURCE_RAW_NAME } - fn apply_to_state(&self, state: &mut crate::state::AtemState) -> Vec { - todo!() + fn apply_to_state(&self, state: &mut crate::state::AtemState) -> bool { + todo!("Apply to state: Tally By Source") } } diff --git a/atem-connection-rs/src/commands/time.rs b/atem-connection-rs/src/commands/time.rs index f88447d..dd108c8 100644 --- a/atem-connection-rs/src/commands/time.rs +++ b/atem-connection-rs/src/commands/time.rs @@ -23,8 +23,8 @@ impl DeserializedCommand for Time { DESERIALIZE_TIME_RAW_NAME } - fn apply_to_state(&self, state: &mut crate::state::AtemState) -> Vec { - todo!() + fn apply_to_state(&self, state: &mut crate::state::AtemState) -> bool { + false } } diff --git a/atem-connection-rs/src/enums/mod.rs b/atem-connection-rs/src/enums/mod.rs index 34c4192..cd531ce 100644 --- a/atem-connection-rs/src/enums/mod.rs +++ b/atem-connection-rs/src/enums/mod.rs @@ -1,4 +1,4 @@ -#[derive(Default)] +#[derive(Clone, Default, PartialEq)] pub enum Model { #[default] Unknown = 0x00, @@ -21,7 +21,7 @@ pub enum Model { MiniExtremeISO = 0x11, } -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone, PartialEq)] pub enum ProtocolVersion { #[default] Unknown = 0, @@ -48,6 +48,7 @@ impl TryFrom for ProtocolVersion { } } +#[derive(Clone, PartialEq)] pub enum TransitionStyle { MIX = 0x00, DIP = 0x01, @@ -56,6 +57,7 @@ pub enum TransitionStyle { STING = 0x04, } +#[derive(Clone, PartialEq)] pub enum TransitionSelection { Background = 1 << 0, Key1 = 1 << 1, @@ -64,6 +66,7 @@ pub enum TransitionSelection { Key4 = 1 << 4, } +#[derive(Clone, PartialEq)] pub enum DVEEffect { SwooshTopLeft = 0, SwooshTop = 1, @@ -106,6 +109,7 @@ pub enum DVEEffect { GraphicLogoWipe = 34, } +#[derive(Clone, PartialEq)] pub enum MacroAction { Run = 0, Stop = 1, @@ -115,6 +119,7 @@ pub enum MacroAction { Delete = 5, } +#[derive(Clone, PartialEq)] pub enum ExternalPortType { Unknown = 0, SDI = 1, @@ -131,6 +136,7 @@ pub enum ExternalPortType { TRSJack = 2048, } +#[derive(Clone, PartialEq)] pub enum InternalPortType { External = 0, Black = 1, @@ -157,6 +163,8 @@ const SOURCE_AVAILABILITY_SUPERSOURCE_BOX: isize = 1 << 3; const SOURCE_AVAILABILITY_KEY_SOURCE: isize = 1 << 4; const SOURCE_AVAILABILITY_AUXILIARY_1: isize = 1 << 5; const SOURCE_AVAILABILITY_AUXILIARY_2: isize = 1 << 6; + +#[derive(Clone, PartialEq)] pub enum SourceAvailability { None = SOURCE_AVAILABILITY_NONE, Auxiliary = SOURCE_AVAILABILITY_AUXILIARY, @@ -180,6 +188,8 @@ const ME_AVAILABILITY_ME_1: isize = 1 << 0; const ME_AVAILABILITY_ME_2: isize = 1 << 1; const ME_AVAILABILITY_ME_3: isize = 1 << 2; const ME_AVAILABILITY_ME_4: isize = 1 << 3; + +#[derive(Clone, PartialEq)] pub enum MeAvailability { None = ME_AVAILABILITY_NONE, Me1 = ME_AVAILABILITY_ME_1, @@ -189,6 +199,7 @@ pub enum MeAvailability { All = ME_AVAILABILITY_ME_1 | ME_AVAILABILITY_ME_2 | ME_AVAILABILITY_ME_3 | ME_AVAILABILITY_ME_4, } +#[derive(Clone, PartialEq)] pub enum BorderBevel { None = 0, InOut = 1, @@ -196,6 +207,7 @@ pub enum BorderBevel { Out = 3, } +#[derive(Clone, PartialEq)] pub enum IsAtKeyFrame { None = 0, A = 1 << 0, @@ -203,6 +215,7 @@ pub enum IsAtKeyFrame { RunToInfinite = 1 << 2, } +#[derive(Clone, PartialEq)] pub enum Pattern { LeftToRightBar = 0, TopToBottomBar = 1, @@ -224,7 +237,7 @@ pub enum Pattern { TopRightDiagonal = 17, } -#[derive(Clone, Copy)] +#[derive(Clone, Copy, PartialEq)] pub enum MixEffectKeyType { Luma = 0, Chroma = 1, @@ -232,6 +245,7 @@ pub enum MixEffectKeyType { DVE = 3, } +#[derive(Clone, PartialEq)] pub enum FlyKeyKeyFrame { None = 0, A = 1, @@ -240,6 +254,7 @@ pub enum FlyKeyKeyFrame { RunToInfinite = 4, } +#[derive(Clone, PartialEq)] pub enum FlyKeyDirection { CentreOfKey = 0, TopLeft = 1, @@ -253,11 +268,13 @@ pub enum FlyKeyDirection { BottomRight = 9, } +#[derive(Clone, PartialEq)] pub enum SuperSourceArtOption { Background, Foreground, } +#[derive(Clone, PartialEq)] pub enum TransferMode { NoOp, Write, @@ -265,7 +282,7 @@ pub enum TransferMode { WriteAudio = 256, } -#[derive(Default)] +#[derive(Clone, Default, PartialEq)] pub enum VideoMode { #[default] N525i5994NTSC = 0, @@ -303,6 +320,7 @@ pub enum VideoMode { N1080p60 = 27, } +#[derive(Clone, PartialEq)] pub enum TransferState { Queued, Locked, @@ -310,29 +328,34 @@ pub enum TransferState { Finished, } +#[derive(Clone, PartialEq)] pub enum MediaSourceType { Still = 1, Clip, } +#[derive(Clone, PartialEq)] pub enum AudioMixOption { Off = 0, On = 1, AudioFollowVideo = 2, } +#[derive(Clone, PartialEq)] pub enum AudioSourceType { ExternalVideo, MediaPlayer, ExternalAudio, } +#[derive(Clone, PartialEq)] pub enum StreamingError { None, InvalidState = 1 << 4, Unknown = 1 << 15, } +#[derive(Clone, PartialEq)] pub enum StreamingStatus { Idle = 1 << 0, Connecting = 1 << 1, @@ -340,6 +363,7 @@ pub enum StreamingStatus { Stopping = 1 << 5, // + Streaming } +#[derive(Clone, PartialEq)] pub enum RecordingError { None = 1 << 1, NoMedia = 0, @@ -350,12 +374,14 @@ pub enum RecordingError { Unknown = 1 << 15, } +#[derive(Clone, PartialEq)] pub enum RecordingStatus { Idle = 0, Recording = 1 << 0, Stopping = 1 << 7, } +#[derive(Clone, PartialEq)] pub enum RecordingDiskStatus { Idle = 1 << 0, Unformatted = 1 << 1, @@ -365,18 +391,21 @@ pub enum RecordingDiskStatus { Removed = 1 << 5, } +#[derive(Clone, PartialEq)] pub enum FairlightAudioMixOption { Off = 1, On = 2, AudioFollowVideo = 4, } +#[derive(Clone, PartialEq)] pub enum FairlightInputConfiguration { Mono = 1, Stereo = 2, DualMono = 4, } +#[derive(Clone, PartialEq)] pub enum FairlightAnalogInputLevel { Microphone = 1, ConsumerLine = 2, @@ -384,11 +413,13 @@ pub enum FairlightAnalogInputLevel { ProLine = 4, } +#[derive(Clone, PartialEq)] pub enum FairlightAudioSourceType { Mono = 0, Stereo = 1, } +#[derive(Clone, PartialEq)] pub enum FairlightInputType { EmbeddedWithVideo = 0, MediaPlayer = 1, @@ -401,6 +432,8 @@ const MULTI_VIEWER_LAYOUT_TOP_LEFT_SMALL: isize = 1; const MULTI_VIEWER_LAYOUT_TOP_RIGHT_SMALL: isize = 2; const MULTI_VIEWER_LAYOUT_BOTTOM_LEFT_SMALL: isize = 4; const MULTI_VIEWER_LAYOUT_BOTTOM_RIGHT_SMALL: isize = 8; + +#[derive(Clone, PartialEq)] pub enum MultiViewerLayout { Default = MULTI_VIEWER_LAYOUT_DEFAULT, TopLeftSmall = MULTI_VIEWER_LAYOUT_TOP_LEFT_SMALL, diff --git a/atem-connection-rs/src/state/atem_macro.rs b/atem-connection-rs/src/state/atem_macro.rs index 5bbc8f9..4236470 100644 --- a/atem-connection-rs/src/state/atem_macro.rs +++ b/atem-connection-rs/src/state/atem_macro.rs @@ -1,4 +1,4 @@ -#[derive(Getters, new, Default)] +#[derive(Clone, PartialEq, Getters, new, Default)] pub struct MacroPlayerState { pub is_running: bool, pub is_waiting: bool, @@ -6,13 +6,13 @@ pub struct MacroPlayerState { pub macro_index: u64, } -#[derive(Getters, new, Default)] +#[derive(Clone, PartialEq, Getters, new, Default)] pub struct MacroRecorderState { pub is_recording: bool, pub macro_index: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct MacroPropertiesState { is_used: bool, has_unsupported_ops: bool, @@ -20,7 +20,7 @@ pub struct MacroPropertiesState { pub description: String, } -#[derive(Getters, new, Default)] +#[derive(Clone, PartialEq, Getters, new, Default)] pub struct MacroState { pub macro_player: MacroPlayerState, pub macro_recorder: MacroRecorderState, diff --git a/atem-connection-rs/src/state/audio.rs b/atem-connection-rs/src/state/audio.rs index 0e478a7..72046d2 100644 --- a/atem-connection-rs/src/state/audio.rs +++ b/atem-connection-rs/src/state/audio.rs @@ -6,7 +6,7 @@ pub type AudioChannel = ClassicAudioChannel; pub type AudioMasterChannel = ClassicAudioMasterChannel; pub type AtemAudioState = AtemClassicAudioState; -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct ClassicAudioChannel { source_type: AudioSourceType, pub port_type: ExternalPortType, @@ -18,14 +18,14 @@ pub struct ClassicAudioChannel { pub rca_to_xlr_enabled: bool, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct ClassicAudioMasterChannel { pub gain: f64, pub balance: f64, pub follow_fade_to_black: bool, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct ClassicAudioMonitorChannel { pub enabled: bool, pub gain: f64, @@ -36,7 +36,7 @@ pub struct ClassicAudioMonitorChannel { pub dim_level: f64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct ClassicAudioHeadphoneOutputChannel { pub gain: f64, pub program_out_gain: f64, @@ -44,11 +44,11 @@ pub struct ClassicAudioHeadphoneOutputChannel { pub talkback_gain: f64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct AtemClassicAudioState { number_of_channels: Option, has_monitor: Option, - pub channels: HashMap, + pub channels: HashMap, pub monitor: Option, pub headphones: Option, pub master: Option, diff --git a/atem-connection-rs/src/state/color.rs b/atem-connection-rs/src/state/color.rs index 60b07fb..9fd9290 100644 --- a/atem-connection-rs/src/state/color.rs +++ b/atem-connection-rs/src/state/color.rs @@ -1,4 +1,4 @@ -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct ColorGeneratorState { pub hue: u64, pub saturation: u64, diff --git a/atem-connection-rs/src/state/common.rs b/atem-connection-rs/src/state/common.rs index 11b2d98..aaf2f02 100644 --- a/atem-connection-rs/src/state/common.rs +++ b/atem-connection-rs/src/state/common.rs @@ -1,4 +1,4 @@ -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct Timecode { pub hours: u64, pub minutes: u64, diff --git a/atem-connection-rs/src/state/fairlight.rs b/atem-connection-rs/src/state/fairlight.rs index df89107..ba97e30 100644 --- a/atem-connection-rs/src/state/fairlight.rs +++ b/atem-connection-rs/src/state/fairlight.rs @@ -5,7 +5,7 @@ use crate::enums::{ FairlightInputConfiguration, FairlightInputType, }; -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioDynamicsState { pub make_up_gain: Option, @@ -14,7 +14,7 @@ pub struct FairlightAudioDynamicsState { pub expander: Option, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioLimiterState { pub limiter_enabled: bool, pub threshold: u64, @@ -23,7 +23,7 @@ pub struct FairlightAudioLimiterState { pub release: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioCompressorState { pub compressor_enabled: bool, pub threshold: u64, @@ -33,7 +33,7 @@ pub struct FairlightAudioCompressorState { pub release: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioExpanderState { pub expander_enabled: bool, pub gate_enabled: bool, @@ -45,7 +45,7 @@ pub struct FairlightAudioExpanderState { pub release: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioEqualizerBandState { pub band_enabled: bool, @@ -61,14 +61,14 @@ pub struct FairlightAudioEqualizerBandState { pub q_factor: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioMasterChannelPropertiesState { // Gain in decibel, -Infinity to +6dB pub fader_gain: u64, pub follow_fade_to_black: bool, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioMasterChannel { pub properties: Option, @@ -76,7 +76,7 @@ pub struct FairlightAudioMasterChannel { pub dynamicss: Option, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioMonitorChannel { pub gain: u64, pub input_master_gain: u64, @@ -84,21 +84,21 @@ pub struct FairlightAudioMonitorChannel { pub input_sidetone_gain: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioSource { pub properties: Option, pub equalizer: Option, pub dynamics: Option, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioEqualizerState { pub enabled: bool, pub gain: u64, bands: Vec, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioSourcePropertiesState { source_type: FairlightAudioSourceType, @@ -116,13 +116,13 @@ pub struct FairlightAudioSourcePropertiesState { pub mix_option: FairlightAudioMixOption, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioInput { pub properties: Option, pub sources: HashMap, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioInputProperties { input_type: FairlightInputType, external_port_type: ExternalPortType, @@ -134,7 +134,7 @@ pub struct FairlightAudioInputProperties { pub active_input_level: FairlightAnalogInputLevel, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct AtemFairlightAudioState { pub inputs: HashMap, pub master: Option, diff --git a/atem-connection-rs/src/state/info.rs b/atem-connection-rs/src/state/info.rs index 4620c73..0bb4fd7 100644 --- a/atem-connection-rs/src/state/info.rs +++ b/atem-connection-rs/src/state/info.rs @@ -1,6 +1,6 @@ use crate::enums::{Model, ProtocolVersion}; -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct AtemCapabilites { mix_effects: u64, sources: u64, @@ -19,47 +19,47 @@ pub struct AtemCapabilites { only_configurable_outputs: bool, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct MixEffectInfo { key_count: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct SuperSourceInfo { box_count: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct AudioMixerInfo { inputs: u64, monitors: u64, headphones: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FairlightAudioMixerInfo { inputs: u64, monitors: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct MacroPoolInfo { macro_count: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct MediaPoolInfo { still_count: u64, clip_count: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct MultiviewerInfo { count: u64, window_count: u64, } -#[derive(new)] +#[derive(Clone, PartialEq, new)] pub struct TimeInfo { pub hour: u64, pub minute: u64, @@ -68,7 +68,7 @@ pub struct TimeInfo { pub drop_frame: bool, } -#[derive(new, Default)] +#[derive(Clone, PartialEq, Getters, new, Default)] pub struct DeviceInfo { pub api_version: ProtocolVersion, pub capabilities: Option, diff --git a/atem-connection-rs/src/state/input.rs b/atem-connection-rs/src/state/input.rs index a53742a..0c3c654 100644 --- a/atem-connection-rs/src/state/input.rs +++ b/atem-connection-rs/src/state/input.rs @@ -1,6 +1,6 @@ use crate::enums::{ExternalPortType, InternalPortType, MeAvailability, SourceAvailability}; -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct InputChannel { input_id: u64, pub long_name: String, diff --git a/atem-connection-rs/src/state/media.rs b/atem-connection-rs/src/state/media.rs index f71788f..f32824e 100644 --- a/atem-connection-rs/src/state/media.rs +++ b/atem-connection-rs/src/state/media.rs @@ -1,6 +1,6 @@ use crate::enums; -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct MediaPlayer { pub playing: bool, pub is_loop: bool, @@ -8,7 +8,7 @@ pub struct MediaPlayer { pub clip_frame: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct MediaPlayerSource { pub source_type: enums::MediaSourceType, pub clip_index: u64, @@ -17,21 +17,21 @@ pub struct MediaPlayerSource { pub type MediaPlayerState = (MediaPlayer, MediaPlayerSource); -#[derive(Getters, new, Default)] +#[derive(Clone, PartialEq, Getters, new, Default)] pub struct MediaState { still_pool: Vec, clip_pool: Vec, players: Vec, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct StillFrame { pub is_used: bool, pub hash: String, pub file_name: String, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct ClipBank { pub is_used: bool, pub name: String, diff --git a/atem-connection-rs/src/state/mod.rs b/atem-connection-rs/src/state/mod.rs index ea46c34..143a873 100644 --- a/atem-connection-rs/src/state/mod.rs +++ b/atem-connection-rs/src/state/mod.rs @@ -14,7 +14,7 @@ pub mod streaming; pub mod util; pub mod video; -#[derive(Default)] +#[derive(Default, Clone, PartialEq)] pub struct AtemState { info: info::DeviceInfo, video: video::AtemVideoState, diff --git a/atem-connection-rs/src/state/recording.rs b/atem-connection-rs/src/state/recording.rs index 10ac4de..4aa8220 100644 --- a/atem-connection-rs/src/state/recording.rs +++ b/atem-connection-rs/src/state/recording.rs @@ -4,7 +4,7 @@ use crate::enums::{RecordingDiskStatus, RecordingError, RecordingStatus}; use super::common::Timecode; -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct RecordingState { pub status: Option, pub properties: RecordingStateProperties, @@ -14,7 +14,7 @@ pub struct RecordingState { pub disks: HashMap, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct RecordingDiskProperties { pub disk_id: u64, pub volume_name: String, @@ -22,7 +22,7 @@ pub struct RecordingDiskProperties { pub status: RecordingDiskStatus, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct RecordingStateStatus { pub state: RecordingStatus, pub error: RecordingError, @@ -30,7 +30,7 @@ pub struct RecordingStateStatus { pub recording_time_available: u64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct RecordingStateProperties { pub filename: String, diff --git a/atem-connection-rs/src/state/settings.rs b/atem-connection-rs/src/state/settings.rs index ae4450c..2f601cc 100644 --- a/atem-connection-rs/src/state/settings.rs +++ b/atem-connection-rs/src/state/settings.rs @@ -9,7 +9,7 @@ pub trait MultiViewerSourceState { fn get_supports_safe_area(&self) -> bool; } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct MultiViewerWindowState { pub safe_title: Option, pub audio_meter: Option, @@ -40,13 +40,13 @@ impl MultiViewerSourceState for MultiViewerWindowState { } } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct MultiViewerPropertiesState { pub layout: MultiViewerLayout, pub program_preview_swapped: bool, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct MultiViewer { index: u64, windows: Vec, @@ -54,7 +54,7 @@ pub struct MultiViewer { pub vu_opacity: Option, } -#[derive(Getters, new, Default)] +#[derive(Clone, PartialEq, Getters, new, Default)] pub struct SettingsState { multi_viewers: Vec, pub video_mode: VideoMode, diff --git a/atem-connection-rs/src/state/streaming.rs b/atem-connection-rs/src/state/streaming.rs index a53bc56..c94644b 100644 --- a/atem-connection-rs/src/state/streaming.rs +++ b/atem-connection-rs/src/state/streaming.rs @@ -2,7 +2,7 @@ use crate::enums::{StreamingError, StreamingStatus}; use super::common::Timecode; -#[derive(Getters)] +#[derive(Clone, PartialEq, Getters)] pub struct StreamingState { pub status: Option, pub stats: Option, @@ -11,18 +11,19 @@ pub struct StreamingState { pub duration: Option, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct StreamingStateStatus { state: StreamingStatus, error: StreamingError, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct StreamingStateStats { cache_used: u64, encoding_bitrate: u64, } +#[derive(Clone, PartialEq)] pub struct StreamingServiceProperties { pub service_name: String, pub url: String, diff --git a/atem-connection-rs/src/state/video/downstream_keyers.rs b/atem-connection-rs/src/state/video/downstream_keyers.rs index 0eb9433..06d244d 100644 --- a/atem-connection-rs/src/state/video/downstream_keyers.rs +++ b/atem-connection-rs/src/state/video/downstream_keyers.rs @@ -9,7 +9,7 @@ pub trait DownstreamKeyerBase { fn set_is_towards_on_air(&mut self, on_air: Option); } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct DownstreamKeyer { pub sources: Option, pub properties: Option, @@ -57,7 +57,7 @@ pub trait DownstreamKeyerGeneral { fn set_invert(&mut self, invert: bool); } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct DownstreamKeyerMask { pub enabled: bool, pub top: f64, @@ -66,7 +66,7 @@ pub struct DownstreamKeyerMask { pub right: f64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct DownstreamKeyerProperties { pub tie: bool, pub rate: f64, @@ -104,7 +104,7 @@ impl DownstreamKeyerGeneral for DownstreamKeyerProperties { } } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct DownstreamKeyerSources { pub fill_source: f64, pub cut_source: f64, diff --git a/atem-connection-rs/src/state/video/mod.rs b/atem-connection-rs/src/state/video/mod.rs index 57fb684..8085848 100644 --- a/atem-connection-rs/src/state/video/mod.rs +++ b/atem-connection-rs/src/state/video/mod.rs @@ -4,13 +4,13 @@ mod downstream_keyers; mod super_source; mod upstream_keyers; -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct DipTransitionSettings { pub rate: f64, pub input: f64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct DVETransitionSettings { pub rate: f64, pub logo_rate: f64, @@ -27,12 +27,12 @@ pub struct DVETransitionSettings { pub flip_flop: bool, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct MixTransitionSettings { pub rate: f64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct StingerTransitionSettings { pub source: f64, pub pre_multiplied_key: bool, @@ -47,7 +47,7 @@ pub struct StingerTransitionSettings { pub mix_rate: f64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct WipeTransitionSettings { pub rate: f64, pub pattern: f64, @@ -61,7 +61,7 @@ pub struct WipeTransitionSettings { pub flip_flop: bool, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct TransitionProperties { style: enums::TransitionStyle, selection: Vec, @@ -69,7 +69,7 @@ pub struct TransitionProperties { pub next_selection: Vec, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct TransitionSettings { pub dip: Option, pub dve: Option, @@ -78,14 +78,14 @@ pub struct TransitionSettings { pub wipe: Option, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct TransitionPosition { in_transition: bool, remaining_frames: f64, pub handle_position: f64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct MixEffect { index: f64, pub program_input: f64, @@ -98,7 +98,7 @@ pub struct MixEffect { upstream_keyers: Vec, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct FadeToBlackProperties { is_fully_black: bool, in_transition: bool, @@ -106,7 +106,7 @@ pub struct FadeToBlackProperties { pub rate: f64, } -#[derive(Getters, new, Default)] +#[derive(Clone, PartialEq, Getters, new, Default)] pub struct AtemVideoState { mix_effects: Vec, downstream_keyers: Vec, diff --git a/atem-connection-rs/src/state/video/super_source.rs b/atem-connection-rs/src/state/video/super_source.rs index 400cb2b..92d85cd 100644 --- a/atem-connection-rs/src/state/video/super_source.rs +++ b/atem-connection-rs/src/state/video/super_source.rs @@ -1,6 +1,6 @@ use crate::enums; -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct SuperSourceBox { pub enabled: bool, pub source: f64, @@ -14,7 +14,7 @@ pub struct SuperSourceBox { pub crop_right: f64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct SuperSourceProperties { pub art_fill_source: f64, pub art_cut_source: f64, @@ -25,7 +25,7 @@ pub struct SuperSourceProperties { pub art_invert_key: bool, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct SuperSourceBorder { pub border_enabled: bool, pub border_bevel: enums::BorderBevel, @@ -42,7 +42,7 @@ pub struct SuperSourceBorder { pub border_light_source_altitude: f64, } -#[derive(Getters, new)] +#[derive(Clone, PartialEq, Getters, new)] pub struct SuperSource { index: f64, boxes: [Option; 4], diff --git a/atem-connection-rs/src/state/video/upstream_keyers.rs b/atem-connection-rs/src/state/video/upstream_keyers.rs index 511af5b..a7ad15a 100644 --- a/atem-connection-rs/src/state/video/upstream_keyers.rs +++ b/atem-connection-rs/src/state/video/upstream_keyers.rs @@ -16,57 +16,7 @@ pub trait UpstreamKeyerTypeSettings { fn set_fly_enabled(&mut self, enabled: bool); } -pub trait UpstreamKeyerMaskSettings: Send { - fn get_mask_enabled(&self) -> bool; - fn set_mask_enabled(&mut self, enabled: bool); - fn get_mask_top(&self) -> f64; - fn set_mask_top(&mut self, mask: f64); - fn get_mask_bottom(&self) -> f64; - fn set_mask_bottom(&mut self, mask: f64); - fn get_mask_left(&self) -> f64; - fn set_mask_right(&mut self, mask: f64); -} - -pub trait UpstreamKeyerDVEBase: UpstreamKeyerMaskSettings { - fn get_size_x(&self) -> f64; - fn set_size_x(&mut self, size_x: f64); - fn get_size_y(&self) -> f64; - fn set_size_y(&mut self, size_y: f64); - fn get_position_x(&self) -> f64; - fn set_position_x(&mut self, position_x: f64); - fn get_position_y(&self) -> f64; - fn set_position_y(&mut self, position_y: f64); - fn get_rotation(&self) -> f64; - fn set_rotation(&mut self, rotation: f64); - - fn get_border_outer_width(&self) -> f64; - fn set_border_outer_width(&mut self, width: f64); - fn get_border_inner_width(&self) -> f64; - fn set_border_inner_width(&mut self, width: f64); - fn get_border_outer_softness(&self) -> f64; - fn set_border_outer_softness(&mut self, softness: f64); - fn get_border_inner_softness(&self) -> f64; - fn set_border_inner_softness(&mut self, softness: f64); - fn get_border_bevel_softness(&self) -> f64; - fn set_border_bevel_softness(&mut self, softness: f64); - fn get_border_bevel_position(&self) -> f64; - fn set_border_bevel_position(&mut self, position: f64); - - fn get_border_opacity(&self) -> f64; - fn set_border_opacity(&mut self, opacity: f64); - fn get_border_hue(&self) -> f64; - fn set_border_hue(&mut self, hue: f64); - fn get_border_saturation(&self) -> f64; - fn set_border_saturation(&mut self, saturation: f64); - fn get_border_luma(&self) -> f64; - fn set_border_luma(&mut self, luma: f64); - - fn get_light_source_direction(&self) -> f64; - fn set_light_source_direction(&mut self, direction: f64); - fn get_light_source_altitude(&self) -> f64; - fn set_light_source_altitude(&mut self, altitude: f64); -} - +#[derive(Clone, PartialEq)] pub struct UpstreamKeyerDVESettings { pub border_enabled: bool, pub shadow_enabled: bool, @@ -101,178 +51,7 @@ pub struct UpstreamKeyerDVESettings { pub light_source_altitude: f64, } -impl UpstreamKeyerMaskSettings for UpstreamKeyerDVESettings { - fn get_mask_enabled(&self) -> bool { - self.mask_enabled - } - - fn set_mask_enabled(&mut self, enabled: bool) { - self.mask_enabled = enabled - } - - fn get_mask_top(&self) -> f64 { - self.mask_top - } - - fn set_mask_top(&mut self, mask: f64) { - self.mask_top = mask - } - - fn get_mask_bottom(&self) -> f64 { - self.mask_bottom - } - - fn set_mask_bottom(&mut self, mask: f64) { - self.mask_bottom = mask - } - - fn get_mask_left(&self) -> f64 { - self.mask_left - } - - fn set_mask_right(&mut self, mask: f64) { - self.mask_left = mask - } -} - -impl UpstreamKeyerDVEBase for UpstreamKeyerDVESettings { - fn get_size_x(&self) -> f64 { - self.size_x - } - - fn set_size_x(&mut self, size_x: f64) { - self.size_x = size_x - } - - fn get_size_y(&self) -> f64 { - self.size_y - } - - fn set_size_y(&mut self, size_y: f64) { - self.size_y = size_y - } - - fn get_position_x(&self) -> f64 { - self.position_x - } - - fn set_position_x(&mut self, position_x: f64) { - self.position_x = position_x - } - - fn get_position_y(&self) -> f64 { - self.position_y - } - - fn set_position_y(&mut self, position_y: f64) { - self.position_y = position_y - } - - fn get_rotation(&self) -> f64 { - self.rotation - } - - fn set_rotation(&mut self, rotation: f64) { - self.rotation = rotation - } - - fn get_border_outer_width(&self) -> f64 { - self.border_outer_width - } - - fn set_border_outer_width(&mut self, width: f64) { - self.border_outer_width = width - } - - fn get_border_inner_width(&self) -> f64 { - self.border_inner_width - } - - fn set_border_inner_width(&mut self, width: f64) { - self.border_inner_width = width - } - - fn get_border_outer_softness(&self) -> f64 { - self.border_outer_softness - } - - fn set_border_outer_softness(&mut self, softness: f64) { - self.border_outer_softness = softness - } - - fn get_border_inner_softness(&self) -> f64 { - self.border_inner_softness - } - - fn set_border_inner_softness(&mut self, softness: f64) { - self.border_inner_softness = softness - } - - fn get_border_bevel_softness(&self) -> f64 { - self.border_bevel_softness - } - - fn set_border_bevel_softness(&mut self, softness: f64) { - self.border_bevel_softness = softness - } - - fn get_border_bevel_position(&self) -> f64 { - self.border_bevel_position - } - - fn set_border_bevel_position(&mut self, position: f64) { - self.border_bevel_position = position - } - - fn get_border_opacity(&self) -> f64 { - self.border_opacity - } - - fn set_border_opacity(&mut self, opacity: f64) { - self.border_opacity = opacity - } - - fn get_border_hue(&self) -> f64 { - self.border_hue - } - - fn set_border_hue(&mut self, hue: f64) { - self.border_hue = hue - } - - fn get_border_saturation(&self) -> f64 { - self.border_saturation - } - - fn set_border_saturation(&mut self, saturation: f64) { - self.border_saturation = saturation - } - - fn get_border_luma(&self) -> f64 { - self.border_luma - } - - fn set_border_luma(&mut self, luma: f64) { - self.border_luma = luma - } - - fn get_light_source_direction(&self) -> f64 { - self.light_source_direction - } - - fn set_light_source_direction(&mut self, direction: f64) { - self.light_source_direction = direction - } - - fn get_light_source_altitude(&self) -> f64 { - self.light_source_altitude - } - - fn set_light_source_altitude(&mut self, altitude: f64) { - self.light_source_altitude = altitude - } -} - +#[derive(Clone, PartialEq)] pub struct UpstreamKeyerFlyKeyFrame { key_frame_id: f64, @@ -304,178 +83,13 @@ pub struct UpstreamKeyerFlyKeyFrame { pub light_source_altitude: f64, } -impl UpstreamKeyerMaskSettings for UpstreamKeyerFlyKeyFrame { - fn get_mask_enabled(&self) -> bool { - self.mask_enabled - } - - fn set_mask_enabled(&mut self, enabled: bool) { - self.mask_enabled = enabled - } - - fn get_mask_top(&self) -> f64 { - self.mask_top - } - - fn set_mask_top(&mut self, mask: f64) { - self.mask_top = mask - } - - fn get_mask_bottom(&self) -> f64 { - self.mask_bottom - } - - fn set_mask_bottom(&mut self, mask: f64) { - self.mask_bottom = mask - } - - fn get_mask_left(&self) -> f64 { - self.mask_left - } - - fn set_mask_right(&mut self, mask: f64) { - self.mask_left = mask - } -} - -impl UpstreamKeyerDVEBase for UpstreamKeyerFlyKeyFrame { - fn get_size_x(&self) -> f64 { - self.size_x - } - - fn set_size_x(&mut self, size_x: f64) { - self.size_x = size_x - } - - fn get_size_y(&self) -> f64 { - self.size_y - } - - fn set_size_y(&mut self, size_y: f64) { - self.size_y = size_y - } - - fn get_position_x(&self) -> f64 { - self.position_x - } - - fn set_position_x(&mut self, position_x: f64) { - self.position_x = position_x - } - - fn get_position_y(&self) -> f64 { - self.position_y - } - - fn set_position_y(&mut self, position_y: f64) { - self.position_y = position_y - } - - fn get_rotation(&self) -> f64 { - self.rotation - } - - fn set_rotation(&mut self, rotation: f64) { - self.rotation = rotation - } - - fn get_border_outer_width(&self) -> f64 { - self.border_outer_width - } - - fn set_border_outer_width(&mut self, width: f64) { - self.border_outer_width = width - } - - fn get_border_inner_width(&self) -> f64 { - self.border_inner_width - } - - fn set_border_inner_width(&mut self, width: f64) { - self.border_inner_width = width - } - - fn get_border_outer_softness(&self) -> f64 { - self.border_outer_softness - } - - fn set_border_outer_softness(&mut self, softness: f64) { - self.border_outer_softness = softness - } - - fn get_border_inner_softness(&self) -> f64 { - self.border_inner_softness - } - - fn set_border_inner_softness(&mut self, softness: f64) { - self.border_inner_softness = softness - } - - fn get_border_bevel_softness(&self) -> f64 { - self.border_bevel_softness - } - - fn set_border_bevel_softness(&mut self, softness: f64) { - self.border_bevel_softness = softness - } - - fn get_border_bevel_position(&self) -> f64 { - self.border_bevel_position - } - - fn set_border_bevel_position(&mut self, position: f64) { - self.border_bevel_position = position - } - - fn get_border_opacity(&self) -> f64 { - self.border_opacity - } - - fn set_border_opacity(&mut self, opacity: f64) { - self.border_opacity = opacity - } - - fn get_border_hue(&self) -> f64 { - self.border_hue - } - - fn set_border_hue(&mut self, hue: f64) { - self.border_hue = hue - } - - fn get_border_saturation(&self) -> f64 { - self.border_saturation - } - - fn set_border_saturation(&mut self, saturation: f64) { - self.border_saturation = saturation - } - - fn get_border_luma(&self) -> f64 { - self.border_luma - } - - fn set_border_luma(&mut self, luma: f64) { - self.border_luma = luma - } - - fn get_light_source_direction(&self) -> f64 { - self.light_source_direction - } - - fn set_light_source_direction(&mut self, direction: f64) { - self.light_source_direction = direction - } - - fn get_light_source_altitude(&self) -> f64 { - self.light_source_altitude - } - - fn set_light_source_altitude(&mut self, altitude: f64) { - self.light_source_altitude = altitude - } +#[derive(Clone, PartialEq)] +enum UpstreamKeyerMaskSettings { + DVE(UpstreamKeyerDVESettings), + FlyKeyFrame(UpstreamKeyerFlyKeyFrame), } +#[derive(Clone, PartialEq)] pub struct UpstreamKeyerChromaSettings { pub hue: f64, pub gain: f64, @@ -484,11 +98,13 @@ pub struct UpstreamKeyerChromaSettings { pub narrow: bool, } +#[derive(Clone, PartialEq)] pub struct UpstreamKeyerAdvancedChromaSettings { pub properties: Option, pub sample: Option, } +#[derive(Clone, PartialEq)] pub struct UpstreamKeyerAdvancedChromaProperties { pub foreground_level: f64, pub background_level: f64, @@ -505,6 +121,7 @@ pub struct UpstreamKeyerAdvancedChromaProperties { pub blue: f64, } +#[derive(Clone, PartialEq)] pub struct UpstreamKeyerAdvancedChromaSample { pub enable_cursor: bool, pub preview: bool, @@ -516,6 +133,7 @@ pub struct UpstreamKeyerAdvancedChromaSample { pub sampled_cr: f64, } +#[derive(Clone, PartialEq)] pub struct UpstreamKeyerLumaSettings { pub pre_multiplied: bool, pub clip: f64, @@ -523,6 +141,7 @@ pub struct UpstreamKeyerLumaSettings { pub invert: bool, } +#[derive(Clone, PartialEq)] pub struct UpstreamKeyerPatternSettings { pub style: enums::Pattern, pub size: f64, @@ -533,6 +152,7 @@ pub struct UpstreamKeyerPatternSettings { pub invert: bool, } +#[derive(Clone, PartialEq)] pub struct UpstreamKeyerFlySettings { is_a_set: bool, is_b_set: bool, @@ -540,6 +160,7 @@ pub struct UpstreamKeyerFlySettings { run_to_infinite_index: f64, } +#[derive(Clone, PartialEq)] pub struct UpstreamKeyer { pub mix_effect_key_type: enums::MixEffectKeyType, pub fly_enabled: bool, @@ -556,7 +177,7 @@ pub struct UpstreamKeyer { pub pattern_settings: Option, pub fly_keyframes: [Option; 2], pub fly_properties: Option, - pub mask_settings: Box, + pub mask_settings: UpstreamKeyerMaskSettings, pub on_air: bool, pub mask_enabled: bool,