Skip to main content

rodecaster_protocol/names/
input_source.rs

1//! [`InputSourceParam`]: the per-source `INPUTSOURCE`-node parameter family.
2
3// The twelve properties a real Pro II / Duo fullSync carries on every
4// INPUTSOURCE node (confirmed from capture, firmware 1.7.3).
5wire_param_enum! {
6    /// A per-input-source parameter: one of the flat properties the device
7    /// carries on an `INPUTSOURCE` node (preamp gain, power/48V, mic type,
8    /// phase, colour, wireless serial, SIP/RCV routing).
9    ///
10    /// These are **not** channel-strip params: a source exists independently of
11    /// which fader (if any) it is assigned to, and a real fullSync shows every
12    /// input* property on `INPUTSOURCE`, never on `CHANNEL`. Address an input
13    /// source by [`crate::Source`] (the source ordinal == `inputId`).
14    InputSourceParam {
15    InputId => "inputId",
16    InputColour => "inputColour",
17    InputType => "inputType",
18    InputPower => "inputPower",
19    InputMicrophoneType => "inputMicrophoneType",
20    InputMicrophoneGain => "inputMicrophoneGain",
21    InputDigitalGain => "inputDigitalGain",
22    InputInstrumentGain => "inputInstrumentGain",
23    InputPhaseFlip => "inputPhaseFlip",
24    InputWirelessSn => "inputWirelessSN",
25    InputSipCallSlot => "inputSipCallSlot",
26    InputRcvAudioSourceType => "inputRcvAudioSourceType",
27    }
28}
29
30#[cfg(test)]
31mod tests {
32    use super::*;
33
34    #[test]
35    fn input_source_param_name_round_trips() {
36        // Every typed INPUTSOURCE param: from_name(as_str(x)) == x.
37        let params = [
38            InputSourceParam::InputId,
39            InputSourceParam::InputColour,
40            InputSourceParam::InputType,
41            InputSourceParam::InputPower,
42            InputSourceParam::InputMicrophoneType,
43            InputSourceParam::InputMicrophoneGain,
44            InputSourceParam::InputDigitalGain,
45            InputSourceParam::InputInstrumentGain,
46            InputSourceParam::InputPhaseFlip,
47            InputSourceParam::InputWirelessSn,
48            InputSourceParam::InputSipCallSlot,
49            InputSourceParam::InputRcvAudioSourceType,
50        ];
51        for p in params {
52            assert_eq!(InputSourceParam::from_name(p.as_str()), p);
53            assert!(p.is_known());
54            assert_eq!(p.to_string(), p.as_str());
55        }
56    }
57
58    #[test]
59    fn input_source_param_exact_wire_names() {
60        // Acronym casing must match the firmware exactly.
61        assert_eq!(
62            InputSourceParam::InputWirelessSn.as_str(),
63            "inputWirelessSN"
64        );
65        assert_eq!(
66            InputSourceParam::InputRcvAudioSourceType.as_str(),
67            "inputRcvAudioSourceType"
68        );
69        assert_eq!(InputSourceParam::InputId.as_str(), "inputId");
70    }
71
72    #[test]
73    fn input_source_param_unknown_falls_back_to_other() {
74        let p = InputSourceParam::from_name("inputMysteryFlag");
75        assert_eq!(p, InputSourceParam::Other("inputMysteryFlag".to_string()));
76        assert!(!p.is_known());
77        assert_eq!(p.as_str(), "inputMysteryFlag");
78        assert_eq!(InputSourceParam::from_name(p.as_str()), p);
79    }
80}