diff --git a/aes67.c b/aes67.c index 424b01b..aa23841 100644 --- a/aes67.c +++ b/aes67.c @@ -252,12 +252,10 @@ static void aes67_rx_net(struct work_struct *work) return; } - msg.msg_flags = MSG_WAITFORONE; + msg.msg_flags = MSG_DONTWAIT; snd_printk(KERN_INFO "Starting network receive loop\n"); - for (;;) { - if (!stream->running) - break; + while (stream->running) { struct kvec iv; iv.iov_base = recv_buf; @@ -267,10 +265,7 @@ static void aes67_rx_net(struct work_struct *work) iv.iov_len, msg.msg_flags); if (msglen == -EAGAIN) { - snd_printk( - KERN_WARNING - "Failed to receive message. With EAGAIN, Sleeping and trying again\n"); - msleep(1000); + msleep(10); continue; } @@ -506,7 +501,7 @@ static int aes67_stream_create(struct aes67_stream **stream, int direction) struct sockaddr_in addr = { .sin_family = AF_INET, .sin_port = htons(9375), - .sin_addr = { htonl(INADDR_LOOPBACK) } }; + .sin_addr = { htonl(INADDR_ANY) } }; strm->socket->ops->bind(strm->socket, (struct sockaddr *)&addr, sizeof(addr)); diff --git a/media/OpenArms-2-Master.mp3 b/media/OpenArms-2-Master.mp3 new file mode 100644 index 0000000..ba7f480 Binary files /dev/null and b/media/OpenArms-2-Master.mp3 differ diff --git a/media/OpenArms-2-Master.raw b/media/OpenArms-2-Master.raw new file mode 100644 index 0000000..7b693af Binary files /dev/null and b/media/OpenArms-2-Master.raw differ diff --git a/media/OpenArms-2-Master.raw.rsrc.txt b/media/OpenArms-2-Master.raw.rsrc.txt new file mode 100644 index 0000000..db0ba0e Binary files /dev/null and b/media/OpenArms-2-Master.raw.rsrc.txt differ diff --git a/tools/rtp-tools/.gitignore b/tools/rtp-tools/.gitignore new file mode 100644 index 0000000..2c96eb1 --- /dev/null +++ b/tools/rtp-tools/.gitignore @@ -0,0 +1,2 @@ +target/ +Cargo.lock diff --git a/tools/rtp-tools/Cargo.toml b/tools/rtp-tools/Cargo.toml new file mode 100644 index 0000000..aaa7855 --- /dev/null +++ b/tools/rtp-tools/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "rtp-tools" +version = "0.1.0" +edition = "2021" + +[dependencies] +anyhow = "1.0.87" +clap = { version = "4.5.17", features = ["derive"] } diff --git a/tools/rtp-tools/rtp-tools b/tools/rtp-tools/rtp-tools new file mode 120000 index 0000000..bedb82f --- /dev/null +++ b/tools/rtp-tools/rtp-tools @@ -0,0 +1 @@ +target/debug/rtp-tools \ No newline at end of file diff --git a/tools/rtp-tools/src/main.rs b/tools/rtp-tools/src/main.rs new file mode 100644 index 0000000..d42c8b8 --- /dev/null +++ b/tools/rtp-tools/src/main.rs @@ -0,0 +1,87 @@ +use std::{ + fs::File, + io::Read, + vec::Vec, + cmp::min +}; + +use anyhow::Result; + +use clap::{Parser, Subcommand}; + +#[derive(Parser, Debug)] +#[command(version, about, long_about = None)] +struct Args { + #[arg(short, long, value_name = "x.x.x.x:port")] + bind: Option, + + #[command(subcommand)] + command: Option, +} + +#[derive(Subcommand, Debug)] +enum Commands { + Play { + file: std::path::PathBuf, + addr: String, + }, + Listen, +} + +const MTU: usize = 1500; + +fn main() -> Result<()> { + let cli = Args::parse(); + + match &cli.command { + Some(Commands::Play { file, addr }) => { + println!("Playing {file:?} -> {addr}"); + //open file + let mut fd = File::open(file)?; + + //buffer + let mut file_buffer = Vec::with_capacity(1500 * 512); + let read_bytes = fd.read_to_end(&mut file_buffer)?; + + let buffer_len = file_buffer.len(); + println!("ReadBytes {read_bytes} Len {buffer_len}"); + + let header_len = MTU - 8 - 176; + let mut packet_len = buffer_len / header_len; + if buffer_len % header_len > 0 { + packet_len += 1 + } + + let mut packets: Vec> = vec![Vec::with_capacity(header_len); packet_len]; + let loop_len = min(buffer_len, header_len); + + 'outer: for i in 0..loop_len { + for j in 0..packet_len { + let index = i + (header_len * j); + if index == buffer_len { + break 'outer; + } + packets[j].push(file_buffer[index]); + } + } + + for packet in packets { + let s = String::from_utf8(packet)?; + println!("Packet: {s}"); + } + + //open socket + + //stream file to socket + Ok(()) + } + Some(Commands::Listen) => { + println!("Listen!"); + Ok(()) + } + None => { + println!("Use --help for commands"); + Ok(()) + } + } +}