Compare commits
5
Commits
somethings
...
9d872eecc9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d872eecc9 | ||
|
|
2ee3d71e78 | ||
|
|
80b73922ac | ||
|
|
de6f4b2a4d | ||
|
|
621b085381 |
Generated
+180
@@ -26,6 +26,54 @@ dependencies = [
|
||||
"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]]
|
||||
name = "atem-connection-rs"
|
||||
version = "0.1.0"
|
||||
@@ -42,8 +90,10 @@ name = "atem-test"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"atem-connection-rs",
|
||||
"clap",
|
||||
"color-eyre",
|
||||
"env_logger",
|
||||
"log",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
@@ -103,6 +153,46 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "color-eyre"
|
||||
version = "0.5.11"
|
||||
@@ -130,6 +220,12 @@ dependencies = [
|
||||
"tracing-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
|
||||
[[package]]
|
||||
name = "derive-getters"
|
||||
version = "0.2.0"
|
||||
@@ -181,6 +277,12 @@ version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
@@ -430,6 +532,12 @@ version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.74"
|
||||
@@ -586,6 +694,12 @@ version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
@@ -616,3 +730,69 @@ name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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"
|
||||
|
||||
@@ -7,13 +7,3 @@ pub struct AtemOptions {
|
||||
disable_multi_threaded: bool,
|
||||
child_process_timeout: Option<u64>,
|
||||
}
|
||||
|
||||
pub enum AtemEvents {
|
||||
Error(String),
|
||||
Info(String),
|
||||
Debug(String),
|
||||
Connected,
|
||||
Disconnected,
|
||||
StateChanged(Box<(AtemState, Vec<String>)>),
|
||||
ReceivedCommands(Vec<Box<dyn DeserializedCommand>>),
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
use std::{
|
||||
io,
|
||||
net::SocketAddr,
|
||||
sync::Arc,
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
|
||||
use log::debug;
|
||||
use tokio::net::UdpSocket;
|
||||
|
||||
use crate::atem_lib::atem_util;
|
||||
use crate::{
|
||||
atem_lib::atem_util,
|
||||
commands::{command_base::DeserializedCommand, parse_commands::deserialize_commands},
|
||||
};
|
||||
|
||||
const IN_FLIGHT_TIMEOUT: u64 = 60;
|
||||
const CONNECTION_TIMEOUT: u64 = 5000;
|
||||
@@ -21,6 +25,17 @@ const MAX_PACKET_PER_ACK: u16 = 16;
|
||||
const MAX_PACKET_RECEIVE_SIZE: usize = 65535;
|
||||
const ACK_PACKET_LENGTH: u16 = 12;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum AtemEvent {
|
||||
Error(String),
|
||||
Info(String),
|
||||
Debug(String),
|
||||
Connected,
|
||||
Disconnected,
|
||||
ReceivedCommand(Arc<dyn DeserializedCommand>),
|
||||
AckedCommand(AckedPacket),
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone)]
|
||||
enum ConnectionState {
|
||||
Closed,
|
||||
@@ -69,6 +84,7 @@ struct InFlightPacket {
|
||||
pub resent: u16,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct AckedPacket {
|
||||
packet_id: u16,
|
||||
tracking_id: u64,
|
||||
@@ -97,6 +113,8 @@ pub struct AtemSocketInner {
|
||||
in_flight: Vec<InFlightPacket>,
|
||||
ack_timer: Option<SystemTime>,
|
||||
received_without_ack: u16,
|
||||
|
||||
atem_event_tx: tokio::sync::broadcast::Sender<AtemEvent>,
|
||||
}
|
||||
|
||||
enum AtemSocketReceiveError {
|
||||
@@ -114,6 +132,8 @@ enum AtemSocketWriteError {
|
||||
|
||||
impl AtemSocketInner {
|
||||
pub fn new() -> Self {
|
||||
let (atem_event_tx, _) = tokio::sync::broadcast::channel(100);
|
||||
|
||||
AtemSocketInner {
|
||||
connection_state: ConnectionState::Closed,
|
||||
reconnect_timer: None,
|
||||
@@ -131,6 +151,8 @@ impl AtemSocketInner {
|
||||
in_flight: vec![],
|
||||
ack_timer: None,
|
||||
received_without_ack: 0,
|
||||
|
||||
atem_event_tx,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,8 +227,6 @@ impl AtemSocketInner {
|
||||
buffer[20..20 + payload.len()].copy_from_slice(payload);
|
||||
self.send_packet(&buffer).await;
|
||||
|
||||
debug!("{:x?}", buffer);
|
||||
|
||||
self.in_flight.push(InFlightPacket {
|
||||
packet_id,
|
||||
tracking_id,
|
||||
@@ -216,6 +236,10 @@ impl AtemSocketInner {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn subscribe_to_events(&self) -> tokio::sync::broadcast::Receiver<AtemEvent> {
|
||||
self.atem_event_tx.subscribe()
|
||||
}
|
||||
|
||||
async fn restart_connection(&mut self) {
|
||||
self.disconnect();
|
||||
self.connect(self.address.clone(), self.port).await.ok();
|
||||
@@ -277,7 +301,7 @@ impl AtemSocketInner {
|
||||
}
|
||||
|
||||
async fn recieved_packet(&mut self, packet: &[u8]) {
|
||||
debug!("RECV {:x?}", packet);
|
||||
debug!("Received {:x?}", packet);
|
||||
|
||||
if packet.len() < 12 {
|
||||
debug!("Invalid packet from ATEM {:x?}", packet);
|
||||
@@ -322,7 +346,7 @@ impl AtemSocketInner {
|
||||
self.send_or_queue_ack().await;
|
||||
|
||||
if length > 12 {
|
||||
self.on_command_received(&packet[12..], remote_packet_id);
|
||||
self.on_command_received(&packet[12..]);
|
||||
}
|
||||
} else if self
|
||||
.is_packet_covered_by_ack(self.last_received_packed_id, remote_packet_id)
|
||||
@@ -440,16 +464,18 @@ impl AtemSocketInner {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_command_received(&mut self, payload: &[u8], packet_id: u16) {
|
||||
// TODO: Emit some event
|
||||
fn on_command_received(&mut self, payload: &[u8]) {
|
||||
let commands = deserialize_commands(payload);
|
||||
}
|
||||
|
||||
fn on_command_acknowledged(&mut self, ids: Vec<AckedPacket>) {
|
||||
// TODO: Emit some event
|
||||
fn on_command_acknowledged(&mut self, packets: Vec<AckedPacket>) {
|
||||
for ack in packets {
|
||||
let _ = self.atem_event_tx.send(AtemEvent::AckedCommand(ack));
|
||||
}
|
||||
}
|
||||
|
||||
fn on_disconnect(&mut self) {
|
||||
// TODO: Emit some event
|
||||
let _ = self.atem_event_tx.send(AtemEvent::Disconnected);
|
||||
}
|
||||
|
||||
fn start_timers(&mut self) {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
use std::collections::HashMap;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use crate::{enums::ProtocolVersion, state::AtemState};
|
||||
|
||||
pub trait DeserializedCommand {
|
||||
pub trait DeserializedCommand: Send + Sync {
|
||||
fn deserialize(buffer: &[u8]) -> Self
|
||||
where
|
||||
Self: Sized;
|
||||
fn apply_to_state(&self, state: &mut AtemState) -> Vec<String>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,3 @@
|
||||
use super::command_base::{BasicWritableCommand, SerializableCommand};
|
||||
|
||||
#[derive(new)]
|
||||
pub struct ProgramInput {
|
||||
mix_effect: u8,
|
||||
source: u16,
|
||||
}
|
||||
|
||||
impl SerializableCommand for ProgramInput {
|
||||
fn payload(&self, _version: crate::enums::ProtocolVersion) -> Vec<u8> {
|
||||
let mut buf = vec![0; 4];
|
||||
buf[..1].copy_from_slice(&self.mix_effect.to_be_bytes());
|
||||
buf[2..].copy_from_slice(&self.source.to_be_bytes());
|
||||
|
||||
buf
|
||||
}
|
||||
}
|
||||
|
||||
impl BasicWritableCommand for ProgramInput {
|
||||
fn get_raw_name(&self) -> &'static str {
|
||||
"CPgI"
|
||||
}
|
||||
|
||||
fn get_minimum_version(&self) -> crate::enums::ProtocolVersion {
|
||||
crate::enums::ProtocolVersion::Unknown
|
||||
}
|
||||
}
|
||||
pub mod program_input;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
use crate::commands::command_base::{BasicWritableCommand, SerializableCommand};
|
||||
|
||||
#[derive(new)]
|
||||
pub struct ProgramInput {
|
||||
mix_effect: u8,
|
||||
source: u16,
|
||||
}
|
||||
|
||||
impl SerializableCommand for ProgramInput {
|
||||
fn payload(&self, _version: crate::enums::ProtocolVersion) -> Vec<u8> {
|
||||
let mut buf = vec![0; 4];
|
||||
buf[..1].copy_from_slice(&self.mix_effect.to_be_bytes());
|
||||
buf[2..].copy_from_slice(&self.source.to_be_bytes());
|
||||
|
||||
buf
|
||||
}
|
||||
}
|
||||
|
||||
impl BasicWritableCommand for ProgramInput {
|
||||
fn get_raw_name(&self) -> &'static str {
|
||||
"CPgI"
|
||||
}
|
||||
|
||||
fn get_minimum_version(&self) -> crate::enums::ProtocolVersion {
|
||||
crate::enums::ProtocolVersion::Unknown
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,4 @@
|
||||
pub mod command_base;
|
||||
pub mod mix_effects;
|
||||
pub mod parse_commands;
|
||||
pub mod tally_by_source;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::commands::tally_by_source::TallyBySource;
|
||||
|
||||
use super::command_base::DeserializedCommand;
|
||||
|
||||
pub fn deserialize_commands(payload: &[u8]) -> Vec<Arc<dyn DeserializedCommand>> {
|
||||
let mut parsed_commands = vec![];
|
||||
let mut head = 0;
|
||||
|
||||
while payload.len() > head + 8 {
|
||||
// log::debug!("Head at {} out of {}", head, payload.len());
|
||||
let length = u16::from_be_bytes([payload[head], payload[head + 1]]) as usize;
|
||||
let Ok(name) = String::from_utf8(payload[(head + 4)..(head + 8)].to_vec()) else {
|
||||
break;
|
||||
};
|
||||
|
||||
if length < 8 {
|
||||
break;
|
||||
}
|
||||
|
||||
log::debug!("Received command {} with length {}", name, length);
|
||||
|
||||
match name.as_str() {
|
||||
"TlSr" => {
|
||||
let tally = TallyBySource::deserialize(&payload[head + 8..head + length]);
|
||||
for (source, state) in tally.sources {
|
||||
log::info!(
|
||||
"Source {} Program: {}, Preview: {}",
|
||||
source,
|
||||
state.program,
|
||||
state.preview
|
||||
)
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
head += length;
|
||||
}
|
||||
|
||||
parsed_commands
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::commands::command_base::{BasicWritableCommand, SerializableCommand};
|
||||
|
||||
use super::command_base::{DeserializableCommand, DeserializedCommand};
|
||||
|
||||
pub struct TallySource {
|
||||
pub program: bool,
|
||||
pub preview: bool,
|
||||
}
|
||||
|
||||
#[derive(new)]
|
||||
pub struct TallyBySource {
|
||||
pub sources: HashMap<u16, TallySource>,
|
||||
}
|
||||
|
||||
impl DeserializableCommand for TallyBySource {
|
||||
fn get_raw_name(&self) -> &'static str {
|
||||
"TlSr"
|
||||
}
|
||||
|
||||
fn get_minimum_version(&self) -> crate::enums::ProtocolVersion {
|
||||
crate::enums::ProtocolVersion::Unknown
|
||||
}
|
||||
}
|
||||
|
||||
impl DeserializedCommand for TallyBySource {
|
||||
fn deserialize(buffer: &[u8]) -> Self {
|
||||
let source_count = u16::from_be_bytes([buffer[0], buffer[1]]) as usize;
|
||||
|
||||
log::debug!("{:?}", buffer);
|
||||
log::debug!("Source count: {}", source_count);
|
||||
|
||||
let mut sources = HashMap::new();
|
||||
for i in 0..source_count {
|
||||
let source_byte_offset = 2 + (i * 3);
|
||||
let source =
|
||||
u16::from_be_bytes([buffer[source_byte_offset], buffer[source_byte_offset + 1]]);
|
||||
let value_byte_offset = 4 + (i * 3);
|
||||
let value = u8::from_be_bytes([buffer[value_byte_offset]]);
|
||||
sources.insert(
|
||||
source,
|
||||
TallySource {
|
||||
program: (value & 0x01) > 0,
|
||||
preview: (value & 0x02) > 0,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Self { sources }
|
||||
}
|
||||
|
||||
fn apply_to_state(&self, state: &mut crate::state::AtemState) -> Vec<String> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
#[derive(Default)]
|
||||
pub enum Model {
|
||||
#[default]
|
||||
Unknown = 0x00,
|
||||
TVS = 0x01,
|
||||
OneME = 0x02,
|
||||
@@ -19,13 +21,9 @@ pub enum Model {
|
||||
MiniExtremeISO = 0x11,
|
||||
}
|
||||
|
||||
impl Default for Model {
|
||||
fn default() -> Self {
|
||||
Model::Unknown
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub enum ProtocolVersion {
|
||||
#[default]
|
||||
Unknown = 0,
|
||||
V7_2 = 0x00020016, // 2.22 // TODO - verify this is correct
|
||||
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
|
||||
}
|
||||
|
||||
impl Default for ProtocolVersion {
|
||||
fn default() -> Self {
|
||||
ProtocolVersion::Unknown
|
||||
}
|
||||
}
|
||||
|
||||
pub enum TransitionStyle {
|
||||
MIX = 0x00,
|
||||
DIP = 0x01,
|
||||
@@ -257,7 +249,9 @@ pub enum TransferMode {
|
||||
WriteAudio = 256,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub enum VideoMode {
|
||||
#[default]
|
||||
N525i5994NTSC = 0,
|
||||
P625i50PAL = 1,
|
||||
N525i5994169 = 2,
|
||||
@@ -293,12 +287,6 @@ pub enum VideoMode {
|
||||
N1080p60 = 27,
|
||||
}
|
||||
|
||||
impl Default for VideoMode {
|
||||
fn default() -> Self {
|
||||
VideoMode::N525i5994NTSC
|
||||
}
|
||||
}
|
||||
|
||||
pub enum TransferState {
|
||||
Queued,
|
||||
Locked,
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
pub struct ColorGeneratorState {
|
||||
pub hue: u64,
|
||||
pub saturation: u64,
|
||||
pub luma: u64
|
||||
pub luma: u64,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
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)]
|
||||
pub struct FairlightAudioDynamicsState {
|
||||
@@ -8,7 +11,7 @@ pub struct FairlightAudioDynamicsState {
|
||||
|
||||
pub limiter: Option<FairlightAudioLimiterState>,
|
||||
pub compressor: Option<FairlightAudioCompressorState>,
|
||||
pub expander: Option<FairlightAudioExpanderState>
|
||||
pub expander: Option<FairlightAudioExpanderState>,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
@@ -17,7 +20,7 @@ pub struct FairlightAudioLimiterState {
|
||||
pub threshold: u64,
|
||||
pub attack: u64,
|
||||
pub hold: u64,
|
||||
pub release: u64
|
||||
pub release: u64,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
@@ -27,7 +30,7 @@ pub struct FairlightAudioCompressorState {
|
||||
pub ratio: u64,
|
||||
pub attack: u64,
|
||||
pub hold: u64,
|
||||
pub release: u64
|
||||
pub release: u64,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
@@ -39,7 +42,7 @@ pub struct FairlightAudioExpanderState {
|
||||
pub ratio: u64,
|
||||
pub attack: u64,
|
||||
pub hold: u64,
|
||||
pub release: u64
|
||||
pub release: u64,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
@@ -47,22 +50,22 @@ pub struct FairlightAudioEqualizerBandState {
|
||||
pub band_enabled: bool,
|
||||
|
||||
supported_shapes: Vec<u64>, // TODO
|
||||
pub shape: u64, // TODO
|
||||
pub shape: u64, // TODO
|
||||
|
||||
supported_frequency_ranges: Vec<u64>, // TODO
|
||||
pub frequency_ranges: u64, // TODO
|
||||
pub frequency_ranges: u64, // TODO
|
||||
|
||||
pub frequency: u64,
|
||||
|
||||
pub gain: u64,
|
||||
pub q_factor: u64
|
||||
pub q_factor: u64,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
pub struct FairlightAudioMasterChannelPropertiesState {
|
||||
// Gain in decibel, -Infinity to +6dB
|
||||
pub fader_gain: u64,
|
||||
pub follow_fade_to_black: bool
|
||||
pub follow_fade_to_black: bool,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
@@ -78,21 +81,21 @@ pub struct FairlightAudioMonitorChannel {
|
||||
pub gain: u64,
|
||||
pub input_master_gain: u64,
|
||||
pub input_talkback_gain: u64,
|
||||
pub input_sidetone_gain: u64
|
||||
pub input_sidetone_gain: u64,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
pub struct FairlightAudioSource {
|
||||
pub properties: Option<FairlightAudioSourcePropertiesState>,
|
||||
pub equalizer: Option<FairlightAudioEqualizerState>,
|
||||
pub dynamics: Option<FairlightAudioDynamicsState>
|
||||
pub dynamics: Option<FairlightAudioDynamicsState>,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
pub struct FairlightAudioEqualizerState {
|
||||
pub enabled: bool,
|
||||
pub gain: u64,
|
||||
bands: Vec<FairlightAudioEqualizerBandState>
|
||||
bands: Vec<FairlightAudioEqualizerBandState>,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
@@ -110,13 +113,13 @@ pub struct FairlightAudioSourcePropertiesState {
|
||||
pub fader_gain: u64,
|
||||
|
||||
supported_mix_options: Vec<FairlightAudioMixOption>,
|
||||
pub mix_option: FairlightAudioMixOption
|
||||
pub mix_option: FairlightAudioMixOption,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
pub struct FairlightAudioInput {
|
||||
pub properties: Option<FairlightAudioInputProperties>,
|
||||
pub sources: HashMap<String, FairlightAudioSource>
|
||||
pub sources: HashMap<String, FairlightAudioSource>,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
@@ -128,7 +131,7 @@ pub struct FairlightAudioInputProperties {
|
||||
pub active_configuration: FairlightInputConfiguration,
|
||||
|
||||
supported_input_levels: Vec<FairlightAnalogInputLevel>,
|
||||
pub activeInputLevel: FairlightAnalogInputLevel
|
||||
pub active_input_level: FairlightAnalogInputLevel,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
@@ -137,5 +140,5 @@ pub struct AtemFairlightAudioState {
|
||||
pub master: Option<FairlightAudioMasterChannel>,
|
||||
pub monitor: Option<FairlightAudioMonitorChannel>,
|
||||
|
||||
pub audio_follow_video_crossfade_transition_enabled: Option<bool>
|
||||
pub audio_follow_video_crossfade_transition_enabled: Option<bool>,
|
||||
}
|
||||
|
||||
@@ -10,5 +10,5 @@ pub struct InputChannel {
|
||||
pub external_port_type: ExternalPortType,
|
||||
internal_port_type: InternalPortType,
|
||||
source_availability: SourceAvailability,
|
||||
me_availability: MeAvailability
|
||||
me_availability: MeAvailability,
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ pub struct RecordingState {
|
||||
|
||||
pub duration: Option<Timecode>,
|
||||
|
||||
pub disks: HashMap<u64, RecordingDiskProperties>
|
||||
pub disks: HashMap<u64, RecordingDiskProperties>,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
@@ -19,7 +19,7 @@ pub struct RecordingDiskProperties {
|
||||
pub disk_id: u64,
|
||||
pub volume_name: String,
|
||||
pub recording_time_available: u64,
|
||||
pub status: RecordingDiskStatus
|
||||
pub status: RecordingDiskStatus,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
@@ -27,7 +27,7 @@ pub struct RecordingStateStatus {
|
||||
pub state: RecordingStatus,
|
||||
pub error: RecordingError,
|
||||
|
||||
pub recording_time_available: u64
|
||||
pub recording_time_available: u64,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
@@ -37,5 +37,5 @@ pub struct RecordingStateProperties {
|
||||
pub working_set_1_disk_id: u64,
|
||||
pub working_set_2_disk_id: u64,
|
||||
|
||||
pub record_in_all_cameras: bool
|
||||
pub record_in_all_cameras: bool,
|
||||
}
|
||||
|
||||
@@ -8,19 +8,19 @@ pub struct StreamingState {
|
||||
pub stats: Option<StreamingStateStats>,
|
||||
pub service: StreamingServiceProperties,
|
||||
|
||||
pub duration: Option<Timecode>
|
||||
pub duration: Option<Timecode>,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
pub struct StreamingStateStatus {
|
||||
state: StreamingStatus,
|
||||
error: StreamingError
|
||||
error: StreamingError,
|
||||
}
|
||||
|
||||
#[derive(Getters, new)]
|
||||
pub struct StreamingStateStats {
|
||||
cache_used: u64,
|
||||
encoding_bitrate: u64
|
||||
encoding_bitrate: u64,
|
||||
}
|
||||
|
||||
pub struct StreamingServiceProperties {
|
||||
@@ -28,5 +28,5 @@ pub struct StreamingServiceProperties {
|
||||
pub url: String,
|
||||
pub key: String,
|
||||
|
||||
bitrates: (u64, u64)
|
||||
bitrates: (u64, u64),
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
atem-connection-rs = { path = "../atem-connection-rs" }
|
||||
clap = { version = "4.4.18", features = ["derive"] }
|
||||
color-eyre = "0.5.11"
|
||||
env_logger = "0.9.0"
|
||||
log = "0.4.14"
|
||||
tokio = "1.14.0"
|
||||
|
||||
+15
-2
@@ -4,25 +4,38 @@ use atem_connection_rs::{
|
||||
atem_lib::atem_socket::AtemSocket,
|
||||
commands::{
|
||||
command_base::{BasicWritableCommand, SerializableCommand},
|
||||
mix_effects::ProgramInput,
|
||||
mix_effects::program_input::ProgramInput,
|
||||
},
|
||||
};
|
||||
|
||||
use clap::Parser;
|
||||
use color_eyre::Report;
|
||||
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]
|
||||
async fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
setup_logging().unwrap();
|
||||
|
||||
let switch_to_source_1 = ProgramInput::new(0, 1);
|
||||
let switch_to_source_2 = ProgramInput::new(0, 2);
|
||||
|
||||
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;
|
||||
loop {
|
||||
tracking_id += 1;
|
||||
sleep(Duration::from_millis(5000)).await;
|
||||
atem.send_command(
|
||||
&switch_to_source_1.payload(atem_connection_rs::enums::ProtocolVersion::Unknown),
|
||||
|
||||
Reference in New Issue
Block a user