Compare commits

...

4 Commits

Author SHA1 Message Date
Baud 2ee3d71e78 feat: IP arg 2024-02-05 21:34:03 +00:00
Baud 80b73922ac chore: Some logging 2024-02-05 21:33:48 +00:00
Baud de6f4b2a4d chore: Derive default 2024-02-05 21:13:53 +00:00
Baud 621b085381 chore: cargo fmt 2024-02-05 21:12:17 +00:00
10 changed files with 230 additions and 49 deletions

179
Cargo.lock generated
View File

@ -26,6 +26,54 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "anstream"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc"
[[package]]
name = "anstyle-parse"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
dependencies = [
"anstyle",
"windows-sys",
]
[[package]] [[package]]
name = "atem-connection-rs" name = "atem-connection-rs"
version = "0.1.0" version = "0.1.0"
@ -42,6 +90,7 @@ name = "atem-test"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"atem-connection-rs", "atem-connection-rs",
"clap",
"color-eyre", "color-eyre",
"env_logger", "env_logger",
"tokio", "tokio",
@ -103,6 +152,46 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[package]]
name = "clap_lex"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
[[package]] [[package]]
name = "color-eyre" name = "color-eyre"
version = "0.5.11" version = "0.5.11"
@ -130,6 +219,12 @@ dependencies = [
"tracing-error", "tracing-error",
] ]
[[package]]
name = "colorchoice"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]] [[package]]
name = "derive-getters" name = "derive-getters"
version = "0.2.0" version = "0.2.0"
@ -181,6 +276,12 @@ version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7"
[[package]]
name = "heck"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.19" version = "0.1.19"
@ -430,6 +531,12 @@ version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.74" version = "1.0.74"
@ -586,6 +693,12 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "utf8parse"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"
@ -616,3 +729,69 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]]
name = "windows_i686_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]]
name = "windows_i686_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"

View File

@ -205,8 +205,6 @@ impl AtemSocketInner {
buffer[20..20 + payload.len()].copy_from_slice(payload); buffer[20..20 + payload.len()].copy_from_slice(payload);
self.send_packet(&buffer).await; self.send_packet(&buffer).await;
debug!("{:x?}", buffer);
self.in_flight.push(InFlightPacket { self.in_flight.push(InFlightPacket {
packet_id, packet_id,
tracking_id, tracking_id,
@ -277,7 +275,7 @@ impl AtemSocketInner {
} }
async fn recieved_packet(&mut self, packet: &[u8]) { async fn recieved_packet(&mut self, packet: &[u8]) {
debug!("RECV {:x?}", packet); debug!("Received {:x?}", packet);
if packet.len() < 12 { if packet.len() < 12 {
debug!("Invalid packet from ATEM {:x?}", packet); debug!("Invalid packet from ATEM {:x?}", packet);

View File

@ -1,4 +1,6 @@
#[derive(Default)]
pub enum Model { pub enum Model {
#[default]
Unknown = 0x00, Unknown = 0x00,
TVS = 0x01, TVS = 0x01,
OneME = 0x02, OneME = 0x02,
@ -19,13 +21,9 @@ pub enum Model {
MiniExtremeISO = 0x11, MiniExtremeISO = 0x11,
} }
impl Default for Model { #[derive(Default)]
fn default() -> Self {
Model::Unknown
}
}
pub enum ProtocolVersion { pub enum ProtocolVersion {
#[default]
Unknown = 0, Unknown = 0,
V7_2 = 0x00020016, // 2.22 // TODO - verify this is correct V7_2 = 0x00020016, // 2.22 // TODO - verify this is correct
V7_5_2 = 0x0002001b, // 2.27 // The naming of this may be off V7_5_2 = 0x0002001b, // 2.27 // The naming of this may be off
@ -34,12 +32,6 @@ pub enum ProtocolVersion {
V8_1_1 = 0x0002001e, // 2.30 V8_1_1 = 0x0002001e, // 2.30
} }
impl Default for ProtocolVersion {
fn default() -> Self {
ProtocolVersion::Unknown
}
}
pub enum TransitionStyle { pub enum TransitionStyle {
MIX = 0x00, MIX = 0x00,
DIP = 0x01, DIP = 0x01,
@ -257,7 +249,9 @@ pub enum TransferMode {
WriteAudio = 256, WriteAudio = 256,
} }
#[derive(Default)]
pub enum VideoMode { pub enum VideoMode {
#[default]
N525i5994NTSC = 0, N525i5994NTSC = 0,
P625i50PAL = 1, P625i50PAL = 1,
N525i5994169 = 2, N525i5994169 = 2,
@ -293,12 +287,6 @@ pub enum VideoMode {
N1080p60 = 27, N1080p60 = 27,
} }
impl Default for VideoMode {
fn default() -> Self {
VideoMode::N525i5994NTSC
}
}
pub enum TransferState { pub enum TransferState {
Queued, Queued,
Locked, Locked,

View File

@ -2,5 +2,5 @@
pub struct ColorGeneratorState { pub struct ColorGeneratorState {
pub hue: u64, pub hue: u64,
pub saturation: u64, pub saturation: u64,
pub luma: u64 pub luma: u64,
} }

View File

@ -1,6 +1,9 @@
use std::collections::HashMap; use std::collections::HashMap;
use crate::enums::{ExternalPortType, FairlightAnalogInputLevel, FairlightAudioMixOption, FairlightAudioSourceType, FairlightInputConfiguration, FairlightInputType}; use crate::enums::{
ExternalPortType, FairlightAnalogInputLevel, FairlightAudioMixOption, FairlightAudioSourceType,
FairlightInputConfiguration, FairlightInputType,
};
#[derive(Getters, new)] #[derive(Getters, new)]
pub struct FairlightAudioDynamicsState { pub struct FairlightAudioDynamicsState {
@ -8,7 +11,7 @@ pub struct FairlightAudioDynamicsState {
pub limiter: Option<FairlightAudioLimiterState>, pub limiter: Option<FairlightAudioLimiterState>,
pub compressor: Option<FairlightAudioCompressorState>, pub compressor: Option<FairlightAudioCompressorState>,
pub expander: Option<FairlightAudioExpanderState> pub expander: Option<FairlightAudioExpanderState>,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
@ -17,7 +20,7 @@ pub struct FairlightAudioLimiterState {
pub threshold: u64, pub threshold: u64,
pub attack: u64, pub attack: u64,
pub hold: u64, pub hold: u64,
pub release: u64 pub release: u64,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
@ -27,7 +30,7 @@ pub struct FairlightAudioCompressorState {
pub ratio: u64, pub ratio: u64,
pub attack: u64, pub attack: u64,
pub hold: u64, pub hold: u64,
pub release: u64 pub release: u64,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
@ -39,7 +42,7 @@ pub struct FairlightAudioExpanderState {
pub ratio: u64, pub ratio: u64,
pub attack: u64, pub attack: u64,
pub hold: u64, pub hold: u64,
pub release: u64 pub release: u64,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
@ -55,14 +58,14 @@ pub struct FairlightAudioEqualizerBandState {
pub frequency: u64, pub frequency: u64,
pub gain: u64, pub gain: u64,
pub q_factor: u64 pub q_factor: u64,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
pub struct FairlightAudioMasterChannelPropertiesState { pub struct FairlightAudioMasterChannelPropertiesState {
// Gain in decibel, -Infinity to +6dB // Gain in decibel, -Infinity to +6dB
pub fader_gain: u64, pub fader_gain: u64,
pub follow_fade_to_black: bool pub follow_fade_to_black: bool,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
@ -78,21 +81,21 @@ pub struct FairlightAudioMonitorChannel {
pub gain: u64, pub gain: u64,
pub input_master_gain: u64, pub input_master_gain: u64,
pub input_talkback_gain: u64, pub input_talkback_gain: u64,
pub input_sidetone_gain: u64 pub input_sidetone_gain: u64,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
pub struct FairlightAudioSource { pub struct FairlightAudioSource {
pub properties: Option<FairlightAudioSourcePropertiesState>, pub properties: Option<FairlightAudioSourcePropertiesState>,
pub equalizer: Option<FairlightAudioEqualizerState>, pub equalizer: Option<FairlightAudioEqualizerState>,
pub dynamics: Option<FairlightAudioDynamicsState> pub dynamics: Option<FairlightAudioDynamicsState>,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
pub struct FairlightAudioEqualizerState { pub struct FairlightAudioEqualizerState {
pub enabled: bool, pub enabled: bool,
pub gain: u64, pub gain: u64,
bands: Vec<FairlightAudioEqualizerBandState> bands: Vec<FairlightAudioEqualizerBandState>,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
@ -110,13 +113,13 @@ pub struct FairlightAudioSourcePropertiesState {
pub fader_gain: u64, pub fader_gain: u64,
supported_mix_options: Vec<FairlightAudioMixOption>, supported_mix_options: Vec<FairlightAudioMixOption>,
pub mix_option: FairlightAudioMixOption pub mix_option: FairlightAudioMixOption,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
pub struct FairlightAudioInput { pub struct FairlightAudioInput {
pub properties: Option<FairlightAudioInputProperties>, pub properties: Option<FairlightAudioInputProperties>,
pub sources: HashMap<String, FairlightAudioSource> pub sources: HashMap<String, FairlightAudioSource>,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
@ -128,7 +131,7 @@ pub struct FairlightAudioInputProperties {
pub active_configuration: FairlightInputConfiguration, pub active_configuration: FairlightInputConfiguration,
supported_input_levels: Vec<FairlightAnalogInputLevel>, supported_input_levels: Vec<FairlightAnalogInputLevel>,
pub activeInputLevel: FairlightAnalogInputLevel pub active_input_level: FairlightAnalogInputLevel,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
@ -137,5 +140,5 @@ pub struct AtemFairlightAudioState {
pub master: Option<FairlightAudioMasterChannel>, pub master: Option<FairlightAudioMasterChannel>,
pub monitor: Option<FairlightAudioMonitorChannel>, pub monitor: Option<FairlightAudioMonitorChannel>,
pub audio_follow_video_crossfade_transition_enabled: Option<bool> pub audio_follow_video_crossfade_transition_enabled: Option<bool>,
} }

View File

@ -10,5 +10,5 @@ pub struct InputChannel {
pub external_port_type: ExternalPortType, pub external_port_type: ExternalPortType,
internal_port_type: InternalPortType, internal_port_type: InternalPortType,
source_availability: SourceAvailability, source_availability: SourceAvailability,
me_availability: MeAvailability me_availability: MeAvailability,
} }

View File

@ -11,7 +11,7 @@ pub struct RecordingState {
pub duration: Option<Timecode>, pub duration: Option<Timecode>,
pub disks: HashMap<u64, RecordingDiskProperties> pub disks: HashMap<u64, RecordingDiskProperties>,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
@ -19,7 +19,7 @@ pub struct RecordingDiskProperties {
pub disk_id: u64, pub disk_id: u64,
pub volume_name: String, pub volume_name: String,
pub recording_time_available: u64, pub recording_time_available: u64,
pub status: RecordingDiskStatus pub status: RecordingDiskStatus,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
@ -27,7 +27,7 @@ pub struct RecordingStateStatus {
pub state: RecordingStatus, pub state: RecordingStatus,
pub error: RecordingError, pub error: RecordingError,
pub recording_time_available: u64 pub recording_time_available: u64,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
@ -37,5 +37,5 @@ pub struct RecordingStateProperties {
pub working_set_1_disk_id: u64, pub working_set_1_disk_id: u64,
pub working_set_2_disk_id: u64, pub working_set_2_disk_id: u64,
pub record_in_all_cameras: bool pub record_in_all_cameras: bool,
} }

View File

@ -8,19 +8,19 @@ pub struct StreamingState {
pub stats: Option<StreamingStateStats>, pub stats: Option<StreamingStateStats>,
pub service: StreamingServiceProperties, pub service: StreamingServiceProperties,
pub duration: Option<Timecode> pub duration: Option<Timecode>,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
pub struct StreamingStateStatus { pub struct StreamingStateStatus {
state: StreamingStatus, state: StreamingStatus,
error: StreamingError error: StreamingError,
} }
#[derive(Getters, new)] #[derive(Getters, new)]
pub struct StreamingStateStats { pub struct StreamingStateStats {
cache_used: u64, cache_used: u64,
encoding_bitrate: u64 encoding_bitrate: u64,
} }
pub struct StreamingServiceProperties { pub struct StreamingServiceProperties {
@ -28,5 +28,5 @@ pub struct StreamingServiceProperties {
pub url: String, pub url: String,
pub key: String, pub key: String,
bitrates: (u64, u64) bitrates: (u64, u64),
} }

View File

@ -7,6 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
atem-connection-rs = { path = "../atem-connection-rs" } atem-connection-rs = { path = "../atem-connection-rs" }
clap = { version = "4.4.18", features = ["derive"] }
color-eyre = "0.5.11" color-eyre = "0.5.11"
env_logger = "0.9.0" env_logger = "0.9.0"
tokio = "1.14.0" tokio = "1.14.0"

View File

@ -8,18 +8,30 @@ use atem_connection_rs::{
}, },
}; };
use clap::Parser;
use color_eyre::Report; use color_eyre::Report;
use tokio::time::sleep; use tokio::time::sleep;
/// ATEM Rust Library Test App
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
/// IP of the ATEM to connect to
#[arg(short, long)]
ip: String,
}
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
let args = Args::parse();
setup_logging().unwrap(); setup_logging().unwrap();
let switch_to_source_1 = ProgramInput::new(0, 1); let switch_to_source_1 = ProgramInput::new(0, 1);
let switch_to_source_2 = ProgramInput::new(0, 2); let switch_to_source_2 = ProgramInput::new(0, 2);
let mut atem = AtemSocket::new(); let mut atem = AtemSocket::new();
atem.connect("127.0.0.1".to_string(), 9910).await.ok(); atem.connect(args.ip, 9910).await.ok();
let mut tracking_id = 0; let mut tracking_id = 0;
loop { loop {