add media and start working on RTP tools for testing capture

This commit is contained in:
Preston Baxter 2024-09-07 17:05:24 -05:00
parent ffd7fedf70
commit f774eb52cb
8 changed files with 102 additions and 9 deletions

13
aes67.c
View File

@ -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));

BIN
media/OpenArms-2-Master.mp3 Normal file

Binary file not shown.

BIN
media/OpenArms-2-Master.raw Normal file

Binary file not shown.

Binary file not shown.

2
tools/rtp-tools/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
target/
Cargo.lock

View File

@ -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"] }

1
tools/rtp-tools/rtp-tools Symbolic link
View File

@ -0,0 +1 @@
target/debug/rtp-tools

View File

@ -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<String>,
#[command(subcommand)]
command: Option<Commands>,
}
#[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<u8>> = 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(())
}
}
}